summaryrefslogtreecommitdiff
path: root/implicit.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1991-10-08 20:04:11 +0000
committerRoland McGrath <roland@redhat.com>1991-10-08 20:04:11 +0000
commit42289c5f18281fd14b55b5118839c9e2c36b9c5c (patch)
tree728203998d269d25340f55a22ecf8fb6056ad2a2 /implicit.c
parentfb0ffcddc81da7d9d9756c364805a190ee61fd80 (diff)
downloadgunmake-42289c5f18281fd14b55b5118839c9e2c36b9c5c.tar.gz
Formerly implicit.c.~4~
Diffstat (limited to 'implicit.c')
-rw-r--r--implicit.c51
1 files changed, 17 insertions, 34 deletions
diff --git a/implicit.c b/implicit.c
index 7961e9c..15b0b3a 100644
--- a/implicit.c
+++ b/implicit.c
@@ -546,41 +546,24 @@ pattern_search (file, archive, depth, recursions)
/* If there was only one target, there is nothing to do. */
if (rule->targets[1] != 0)
- {
- unsigned int max_targets = 2;
- register unsigned int idx;
-
- file->also_make = (char **) xmalloc (2 * sizeof (char *));
+ for (i = 0; rule->targets[i] != 0; ++i)
+ if (i != matches[foundrule])
+ {
+ struct dep *new = (struct dep *) xmalloc (sizeof (struct dep));
+ new->name = p = (char *) xmalloc (rule->lens[i] + stemlen + 1);
+ bcopy (rule->targets[i], p,
+ rule->suffixes[i] - rule->targets[i] - 1);
+ p += rule->suffixes[i] - rule->targets[i] - 1;
+ bcopy (stem, p, stemlen);
+ p += stemlen;
+ bcopy (rule->suffixes[i], p,
+ rule->lens[i]
+ - (rule->suffixes[i] - rule->targets[i] - 1) + 1);
+ new->file = enter_file (new->name);
+ new->next = file->also_make;
+ file->also_make = new;
+ }
- idx = 0;
- for (i = 0; rule->targets[i] != 0; ++i)
- if (i != matches[foundrule])
- {
- if (idx == max_targets - 1)
- {
- max_targets += 5;
- file->also_make
- = (char **) xrealloc ((char *) file->also_make,
- max_targets * sizeof (char *));
- }
-
- p = file->also_make[idx++] = (char *) xmalloc (rule->lens[i] +
- stemlen + 1);
- bcopy (rule->targets[i], p,
- rule->suffixes[i] - rule->targets[i] - 1);
- p += rule->suffixes[i] - rule->targets[i] - 1;
- bcopy (stem, p, stemlen);
- p += stemlen;
- bcopy (rule->suffixes[i], p,
- rule->lens[i]
- - (rule->suffixes[i] - rule->targets[i] - 1) + 1);
- }
-
- file->also_make[idx] = 0;
- if (idx < max_targets - 1)
- file->also_make = (char **) xrealloc ((char *) file->also_make,
- (idx + 1) * sizeof (char *));
- }
return 1;
}