summaryrefslogtreecommitdiff
path: root/function.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2012-03-03 22:12:46 +0000
committerPaul Smith <psmith@gnu.org>2012-03-03 22:12:46 +0000
commita77c5c09100ef56940546b543dd1c515529ca4bb (patch)
treedc4aa65797a96e5d72b02ab479429fa51784c151 /function.c
parent88f1bc8b55b9f5abf35fdf974310c1063fa41068 (diff)
downloadgunmake-a77c5c09100ef56940546b543dd1c515529ca4bb.tar.gz
Fix Savannah bug #35410: handle escape chars in filter/filter-out
Also add a valgrind suppression file for Guile-enabled make.
Diffstat (limited to 'function.c')
-rw-r--r--function.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/function.c b/function.c
index 5acbb76..d68bc4d 100644
--- a/function.c
+++ b/function.c
@@ -905,7 +905,6 @@ struct a_pattern
char *str;
char *percent;
int length;
- int save_c;
};
static char *
@@ -928,7 +927,9 @@ func_filter_filterout (char *o, char **argv, const char *funcname)
char *p;
unsigned int len;
- /* Chop ARGV[0] up into patterns to match against the words. */
+ /* Chop ARGV[0] up into patterns to match against the words.
+ We don't need to preserve it because our caller frees all the
+ argument memory anyway. */
pattail = &pathead;
while ((p = find_next_token (&pat_iterator, &len)) != 0)
@@ -942,12 +943,13 @@ func_filter_filterout (char *o, char **argv, const char *funcname)
++pat_iterator;
pat->str = p;
- pat->length = len;
- pat->save_c = p[len];
p[len] = '\0';
pat->percent = find_percent (p);
if (pat->percent == 0)
literals++;
+
+ /* find_percent() might shorten the string so LEN is wrong. */
+ pat->length = strlen (pat->str);
}
*pattail = 0;
@@ -1029,9 +1031,6 @@ func_filter_filterout (char *o, char **argv, const char *funcname)
--o;
}
- for (pp = pathead; pp != 0; pp = pp->next)
- pp->str[pp->length] = pp->save_c;
-
if (hashing)
hash_free (&a_word_table, 0);
@@ -2377,7 +2376,7 @@ handle_function (char **op, const char **stringp)
if (entry_p->expand_args)
for (argvp=argv; *argvp != 0; ++argvp)
free (*argvp);
- if (abeg)
+ else if (abeg)
free (abeg);
return 1;