simplify if_existing evaluation
authorPhil Sutter <phil@nwl.cc>
Mon, 15 Dec 2008 15:39:48 +0000 (16:39 +0100)
committerPhil Sutter <phil@nwl.cc>
Mon, 15 Dec 2008 18:40:37 +0000 (19:40 +0100)
src/conky.c

index dbd5816..e016068 100644 (file)
@@ -5110,24 +5110,16 @@ static void generate_text_internal(char *p, int p_max_size,
                                free(tmp_info);
                        }
                        OBJ(if_existing) {
-                               struct stat tmp;
-
-                               if ((obj->data.ifblock.s)
-                                               && (stat(obj->data.ifblock.s, &tmp) == -1)) {
+                               if_jumped = 0;
+                               if (obj->data.ifblock.str
+                                   && !check_contains(obj->data.ifblock.s,
+                                                      obj->data.ifblock.str)) {
+                                       i = obj->data.ifblock.pos;
+                                       if_jumped = 1;
+                               } else if (obj->data.ifblock.s
+                                          && access(obj->data.ifblock.s, F_OK)) {
                                        i = obj->data.ifblock.pos;
                                        if_jumped = 1;
-                               } else {
-                                       if (obj->data.ifblock.str) {
-                                               if (!check_contains(obj->data.ifblock.s,
-                                                               obj->data.ifblock.str)) {
-                                                       i = obj->data.ifblock.pos;
-                                                       if_jumped = 1;
-                                               } else {
-                                                       if_jumped = 0;
-                                               }
-                                       } else {
-                                               if_jumped = 0;
-                                       }
                                }
                        }
                        OBJ(if_mounted) {