diff options
author | Ron Yorston <rmy@pobox.com> | 2025-01-21 09:25:46 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2025-01-21 09:25:46 +0000 |
commit | 89b641cbb52bdc29e7e078c7f1ebcfbe7364ba18 (patch) | |
tree | 6e761dd6d6e8dd193536bd6acb57b0d383406847 /miscutils/make.c | |
parent | 73ca192b94f06c24d9638aebf271eaf2a6bd92d5 (diff) | |
download | busybox-w32-89b641cbb52bdc29e7e078c7f1ebcfbe7364ba18.tar.gz busybox-w32-89b641cbb52bdc29e7e078c7f1ebcfbe7364ba18.tar.bz2 busybox-w32-89b641cbb52bdc29e7e078c7f1ebcfbe7364ba18.zip |
make: fix single-suffix inference rule regression
Commit 85bbce87d (make: support GNU/BSD suffixes and inference
rules) added code to handle inference rules with arbitrary
suffixes. Unfortunately it failed to check for a single-suffix
rule in the case where no known suffix was found. Add the
necessary code and a test which would have caught the problem.
Adds 48 bytes.
(pdpmake GitHub issue 72)
Diffstat (limited to 'miscutils/make.c')
-rw-r--r-- | miscutils/make.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/miscutils/make.c b/miscutils/make.c index ceac1d91d..39c0081ab 100644 --- a/miscutils/make.c +++ b/miscutils/make.c | |||
@@ -1100,22 +1100,34 @@ dyndep(struct name *np, struct rule *infrule, const char **ptsuff) | |||
1100 | // targets of the form lib.a(member.o). | 1100 | // targets of the form lib.a(member.o). |
1101 | if (!posix && member == NULL) { | 1101 | if (!posix && member == NULL) { |
1102 | struct name *xp = newname(".SUFFIXES"); | 1102 | struct name *xp = newname(".SUFFIXES"); |
1103 | int found_suffix = FALSE; | ||
1104 | |||
1103 | for (struct rule *rp = xp->n_rule; rp; rp = rp->r_next) { | 1105 | for (struct rule *rp = xp->n_rule; rp; rp = rp->r_next) { |
1104 | for (struct depend *dp = rp->r_dep; dp; dp = dp->d_next) { | 1106 | for (struct depend *dp = rp->r_dep; dp; dp = dp->d_next) { |
1105 | tsuff = dp->d_name->n_name; | 1107 | tsuff = dp->d_name->n_name; |
1106 | base = has_suffix(name, tsuff); | 1108 | base = has_suffix(name, tsuff); |
1107 | if (base) { | 1109 | if (base) { |
1110 | found_suffix = TRUE; | ||
1108 | pp = dyndep0(base, tsuff, infrule); | 1111 | pp = dyndep0(base, tsuff, infrule); |
1109 | free(base); | 1112 | free(base); |
1110 | if (pp) { | 1113 | if (pp) { |
1111 | if (ptsuff) | ||
1112 | *ptsuff = tsuff; | ||
1113 | goto done; | 1114 | goto done; |
1114 | } | 1115 | } |
1115 | } | 1116 | } |
1116 | } | 1117 | } |
1117 | } | 1118 | } |
1118 | 1119 | ||
1120 | if (!found_suffix) { | ||
1121 | // The name didn't have a known suffix. Try single-suffix rule. | ||
1122 | tsuff = ""; | ||
1123 | pp = dyndep0(name, tsuff, infrule); | ||
1124 | if (pp) { | ||
1125 | done: | ||
1126 | if (ptsuff) { | ||
1127 | *ptsuff = tsuff; | ||
1128 | } | ||
1129 | } | ||
1130 | } | ||
1119 | } else { | 1131 | } else { |
1120 | tsuff = xstrdup(suffix(name)); | 1132 | tsuff = xstrdup(suffix(name)); |
1121 | base = member ? member : name; | 1133 | base = member ? member : name; |
@@ -1124,7 +1136,6 @@ dyndep(struct name *np, struct rule *infrule, const char **ptsuff) | |||
1124 | pp = dyndep0(base, tsuff, infrule); | 1136 | pp = dyndep0(base, tsuff, infrule); |
1125 | free((void *)tsuff); | 1137 | free((void *)tsuff); |
1126 | } | 1138 | } |
1127 | done: | ||
1128 | free(name); | 1139 | free(name); |
1129 | 1140 | ||
1130 | return pp; | 1141 | return pp; |