From: eck Date: Wed, 18 Apr 1990 16:40:17 +0000 (+0000) Subject: the -U option did not work properly; call do_undef() now X-Git-Tag: release-5-5~1738 X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=64e9d11570d9a5c8e7c7650290b56b8b8e902fe4;p=ack.git the -U option did not work properly; call do_undef() now --- diff --git a/lang/cem/cemcom.ansi/domacro.c b/lang/cem/cemcom.ansi/domacro.c index 8561bae03..ffd3fb29c 100644 --- a/lang/cem/cemcom.ansi/domacro.c +++ b/lang/cem/cemcom.ansi/domacro.c @@ -123,7 +123,7 @@ domacro() do_pragma(); break; case K_UNDEF: /* "undef" */ - do_undef(); + do_undef((struct idf *) 0); break; default: /* invalid word seen after the '#' */ @@ -422,12 +422,14 @@ do_ifdef(how) SkipToNewLine(); } -do_undef() +/* argidf != NULL when the undef came from a -U option */ +do_undef(argidf) + struct idf *argidf; { - register struct idf *id; + register struct idf *id = argidf; /* Forget a macro definition. */ - if (id = GetIdentifier(1)) { + if (id || (id = GetIdentifier(1))) { if (id->id_macro) { /* forget the macro */ if (id->id_macro->mc_flag & NOUNDEF) { lexerror("it is not allowed to undef %s", id->id_text); @@ -437,7 +439,7 @@ do_undef() id->id_macro = (struct macro *) 0; } } /* else: don't complain */ - SkipToNewLine(); + if (!argidf) SkipToNewLine(); } else lexerror("illegal #undef construction"); diff --git a/lang/cem/cemcom.ansi/options.c b/lang/cem/cemcom.ansi/options.c index 19878b040..3e35067f7 100644 --- a/lang/cem/cemcom.ansi/options.c +++ b/lang/cem/cemcom.ansi/options.c @@ -224,14 +224,7 @@ deleted, is now a debug-flag case 'U' : { /* -Uname : undefine predefined */ #ifndef NOPP - register struct idf *idef; - - if (*text) { - if ((idef = str2idf(text))->id_macro) { - free_macro(idef->id_macro); - idef->id_macro = (struct macro *) 0; - } - } + if (*text) do_undef(str2idf(text)); #else NOPP warning("-U option ignored"); #endif NOPP diff --git a/lang/cem/cpp.ansi/domacro.c b/lang/cem/cpp.ansi/domacro.c index 89c054e4c..86d17b040 100644 --- a/lang/cem/cpp.ansi/domacro.c +++ b/lang/cem/cpp.ansi/domacro.c @@ -133,7 +133,7 @@ domacro() do_pragma(); break; case K_UNDEF: /* "undef" */ - do_undef(); + do_undef((char *)0); break; default: /* invalid word seen after the '#' */ @@ -439,13 +439,15 @@ do_ifdef(how) SkipToNewLine(); } -do_undef() +/* argstr != NULL when the undef came from a -U option */ +do_undef(argstr) + char *argstr; { register struct idf *id; - register char *str; + register char *str = argstr; /* Forget a macro definition. */ - if (str = GetIdentifier(1)) { + if (str || (str = GetIdentifier(1))) { if ((id = findidf(str)) && id->id_macro) { if (id->id_macro->mc_flag & NOUNDEF) { error("it is not allowed to #undef %s", str); @@ -455,8 +457,10 @@ do_undef() id->id_macro = (struct macro *) 0; } } /* else: don't complain */ - free(str); - SkipToNewLine(); + if (!argstr){ + free(str); + SkipToNewLine(); + } } else error("illegal #undef construction"); diff --git a/lang/cem/cpp.ansi/options.c b/lang/cem/cpp.ansi/options.c index a32bfe080..d3533d659 100644 --- a/lang/cem/cpp.ansi/options.c +++ b/lang/cem/cpp.ansi/options.c @@ -109,14 +109,7 @@ do_option(text) options['P'] = 1; break; case 'U' : /* -Uname : undefine predefined */ - if (*text) { - register struct idf *idef = findidf(text); - - if (idef && idef->id_macro) { - free_macro(idef->id_macro); - idef->id_macro = (struct macro *) 0; - } - } + if (*text) do_undef(text); break; } }