This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
cpplib: command-line #unassert
- To: gcc-patches at gcc dot gnu dot org
- Subject: cpplib: command-line #unassert
- From: Neil Booth <NeilB at earthling dot net>
- Date: Thu, 16 Mar 2000 00:28:23 +0900
- Cc: Zack Weinberg <zack at wolery dot cumb dot org>
This is a simple patch to implement #unassert as a command line
option -A- followed by whatever would come after the #unassert; e.g.
"-A-system(gnu)"
or
-A "-system(gnu)"
The patch's substance is really only a few lines; it looks big because
of editing a comment and changing indentation.
Zack, I looked at doing the assert / unassert with "=" as you
suggested, but I think it's best to wait until you implement your
token list stuff.
OK to commit?
Neil.
* cppinit.c (handle_option): Implement #unassert directive
as -A- command line option.
Index: cppinit.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cppinit.c,v
retrieving revision 1.64
diff -u -p -r1.64 cppinit.c
--- cppinit.c 2000/03/13 22:01:07 1.64
+++ cppinit.c 2000/03/15 15:19:40
@@ -1493,26 +1493,35 @@ handle_option (pfile, argc, argv)
opts->no_output = 1;
break;
case OPT_A:
- if (strcmp (arg, "-"))
- new_pending_directive (opts, arg, cpp_assert);
- else
+ if (arg[0] == '-')
{
- /* -A- eliminates all predefined macros and assertions.
- Let's include also any that were specified earlier
- on the command line. That way we can get rid of any
- that were passed automatically in from GCC. */
- struct pending_option *o1, *o2;
+ /* -A with an argument beginning with '-' acts as
+ #unassert on whatever immediately follows the '-'.
+ If "-" is the whole argument, we eliminate all
+ predefined macros and assertions, including those
+ that were specified earlier on the command line.
+ That way we can get rid of any that were passed
+ automatically in from GCC. */
- o1 = opts->pending->directive_head;
- while (o1)
+ if (arg[1] == '\0')
{
- o2 = o1->next;
- free (o1);
- o1 = o2;
+ struct pending_option *o1, *o2;
+
+ o1 = opts->pending->directive_head;
+ while (o1)
+ {
+ o2 = o1->next;
+ free (o1);
+ o1 = o2;
+ }
+ opts->pending->directive_head = NULL;
+ opts->pending->directive_tail = NULL;
}
- opts->pending->directive_head = NULL;
- opts->pending->directive_tail = NULL;
+ else
+ new_pending_directive (opts, arg + 1, cpp_unassert);
}
+ else
+ new_pending_directive (opts, arg, cpp_assert);
break;
case OPT_U:
new_pending_directive (opts, arg, cpp_undef);