diff --git a/contrib/unifdef/unifdef.c b/contrib/unifdef/unifdef.c index 3dd4ace7b81..ce8a1367adc 100644 --- a/contrib/unifdef/unifdef.c +++ b/contrib/unifdef/unifdef.c @@ -1488,7 +1488,7 @@ findsym(const char **strp) static void indirectsym(void) { - const char *cp; + struct macro key = { 0 }; int changed; struct macro *sym, *ind; @@ -1497,10 +1497,9 @@ indirectsym(void) RB_FOREACH(sym, MACROMAP, ¯o_tree) { if (sym->value == NULL) continue; - cp = sym->value; - ind = findsym(&cp); + key.name = sym->value; + ind = RB_FIND(MACROMAP, ¯o_tree, &key); if (ind == NULL || ind == sym || - *cp != '\0' || ind->value == NULL || ind->value == sym->value) continue; @@ -1539,10 +1538,10 @@ addsym1(bool ignorethis, bool definethis, char *symval) static void addsym2(bool ignorethis, const char *symname, const char *val) { - const char *cp = symname; + struct macro key = { .name = symname }; struct macro *sym, *r; - sym = findsym(&cp); + sym = RB_FIND(MACROMAP, ¯o_tree, &key); if (sym == NULL) { sym = calloc(1, sizeof(*sym)); sym->ignore = ignorethis; diff --git a/usr.bin/unifdef/tests/unifdef_test.sh b/usr.bin/unifdef/tests/unifdef_test.sh index dfb08c18772..97a1b1aa631 100644 --- a/usr.bin/unifdef/tests/unifdef_test.sh +++ b/usr.bin/unifdef/tests/unifdef_test.sh @@ -37,7 +37,17 @@ EOF atf_check -s exit:1 -o inline:"b\n" unifdef -DFOO -DFOO=0