1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-28 13:00:45 +00:00

fix if_existing bugs

- it was returning reverse results when searching strings in file
- if didn't detect that files didn't exist when searching for strings
This commit is contained in:
Nikolas Garofil 2012-07-20 13:44:53 +02:00
parent 3cca68ed3e
commit 19b9441704

View File

@ -594,17 +594,14 @@ static int check_contains(char *f, char *s)
int if_existing_iftest(struct text_object *obj) int if_existing_iftest(struct text_object *obj)
{ {
char *spc; char *spc;
int result = 1; int result;
spc = strchr(obj->data.s, ' '); spc = strchr(obj->data.s, ' ');
if (!spc && access(obj->data.s, F_OK)) { if(spc != NULL) *spc = 0;
result = 0; if (access(obj->data.s, F_OK) == 0) {
} else if (spc) { if(spc == NULL || check_contains(obj->data.s, spc + 1)) result = 1;
*spc = '\0'; } else result = 0;
if (check_contains(obj->data.s, spc + 1)) if(spc != NULL) *spc = ' ';
result = 0;
*spc = ' ';
}
return result; return result;
} }