summaryrefslogtreecommitdiff
path: root/implicit.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2009-09-16 17:07:01 +0000
committerPaul Smith <psmith@gnu.org>2009-09-16 17:07:01 +0000
commit8f30b68871bde8687c7fcff8bac66e2b5765129e (patch)
tree78e7e64f0c47dff023bebe15ee57b85f8db6a826 /implicit.c
parent5abe47762071f024409f7fd16c9cb76b31833379 (diff)
downloadgunmake-8f30b68871bde8687c7fcff8bac66e2b5765129e.tar.gz
- Add xcalloc() and call it
- Fix memory errors found by valgrind - Remove multi_glob() and empower parse_file_seq() to do its job: the goal here is to remove the confusing reverse/re-reverse we do on the file lists: needed for future fixes. - Add a prefix arg to parse_file_seq() - Make concat() variadic so it can take arbitrary #'s of strings
Diffstat (limited to 'implicit.c')
-rw-r--r--implicit.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/implicit.c b/implicit.c
index ee88f97..4285b66 100644
--- a/implicit.c
+++ b/implicit.c
@@ -489,6 +489,7 @@ pattern_search (struct file *file, int archive,
while (1)
{
+ const char *dir = NULL;
int add_dir = 0;
int had_stem = 0;
@@ -570,6 +571,16 @@ pattern_search (struct file *file, int archive,
p2 = depname;
}
+ /* If we need to add the directory prefix set it up. */
+ if (add_dir)
+ {
+ unsigned long l = lastslash - filename + 1;
+ char *n = alloca (l + 1);
+ memcpy (n, filename, l);
+ n[l] = '\0';
+ dir = n;
+ }
+
/* Parse the dependencies. */
while (1)
@@ -580,33 +591,16 @@ pattern_search (struct file *file, int archive,
;
*id_ptr = (struct idep *)
- multi_glob (
- parse_file_seq (&p2,
- order_only ? '\0' : '|',
- sizeof (struct idep),
- 1), sizeof (struct idep), 0);
+ parse_file_seq (&p2, sizeof (struct idep),
+ order_only ? '\0' : '|', dir, 0);
- /* @@ It would be nice to teach parse_file_seq or
- multi_glob to add prefix. This would save us some
- reallocations. */
-
- if (order_only || add_dir || had_stem)
+ if (order_only || had_stem)
{
- unsigned long l = lastslash - filename + 1;
-
for (d = *id_ptr; d != 0; d = d->next)
{
if (order_only)
d->ignore_mtime = 1;
- if (add_dir)
- {
- char *n = alloca (strlen (d->name) + l + 1);
- memcpy (n, filename, l);
- memcpy (n+l, d->name, strlen (d->name) + 1);
- d->name = strcache_add (n);
- }
-
if (had_stem)
d->had_stem = 1;
}