From 19b94417049b954950687cb3ba479bc66f61810c Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Fri, 20 Jul 2012 13:44:53 +0200 Subject: [PATCH] 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 --- src/common.cc | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/common.cc b/src/common.cc index fe803518..c2ebd691 100644 --- a/src/common.cc +++ b/src/common.cc @@ -594,17 +594,14 @@ static int check_contains(char *f, char *s) int if_existing_iftest(struct text_object *obj) { char *spc; - int result = 1; + int result; spc = strchr(obj->data.s, ' '); - if (!spc && access(obj->data.s, F_OK)) { - result = 0; - } else if (spc) { - *spc = '\0'; - if (check_contains(obj->data.s, spc + 1)) - result = 0; - *spc = ' '; - } + if(spc != NULL) *spc = 0; + if (access(obj->data.s, F_OK) == 0) { + if(spc == NULL || check_contains(obj->data.s, spc + 1)) result = 1; + } else result = 0; + if(spc != NULL) *spc = ' '; return result; }