This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: tradtradcpp0, cpp spec bugs, and use of '|'


Neil Booth <neilb@earthling.net> writes:
> Specs are real voodoo.

I think "real voodoo"'s too neutral.  How about just Pure Evil?  8-)


> The docs read
> 
>  %{S|P:X} substitutes X if either -S or -P was given to CC.  This may be
> 	  combined with ! and . as above binding stronger than the OR.
>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> so I think your loop should also involve the check for '!' a couple of
> lines above.  Otherwise, it looks OK to me.

yes; quite.  I knew about that functionality, i just wasn't seeing
past the end of my nose when i wrote the patch.

An updated patch is below, that moves the '!' check and deletes one
blank line that i found aesthetically unpleasant.

It's tested as well as the previous patch was.  I.e. it works for me,
and solves the 'unrecognized option' problem for -traditional-cpp, but
it's not been bootstrapped or anything...



chris

2000-11-21  Chris Demetriou  <cgd@sibyte.com>

        * gcc.c (validate_switches): Validate multiple switches named
        in '|' (or) expressions in specs.

Index: gcc.c
===================================================================
RCS file: /cvsroot/systemsw/tools/src/gcc/gcc/gcc.c,v
retrieving revision 1.3
diff -c -r1.3 gcc.c
*** gcc.c	2000/10/29 00:35:18	1.3
--- gcc.c	2000/11/21 18:31:19
***************
*** 5892,5910 ****
    register const char *p = start;
    const char *filter;
    register int i;
!   int suffix = 0;
  
    if (*p == '|')
      ++p;
  
    if (*p == '!')
      ++p;
  
    if (*p == '.')
      suffix = 1, ++p;
  
    filter = p;
!   while (*p != ':' && *p != '}')
      p++;
  
    if (suffix)
--- 5892,5912 ----
    register const char *p = start;
    const char *filter;
    register int i;
!   int suffix;
  
    if (*p == '|')
      ++p;
  
+ next_member:
    if (*p == '!')
      ++p;
  
+   suffix = 0;
    if (*p == '.')
      suffix = 1, ++p;
  
    filter = p;
!   while (*p != ':' && *p != '}' && *p != '|')
      p++;
  
    if (suffix)
***************
*** 5912,5920 ****
    else if (p[-1] == '*')
      {
        /* Mark all matching switches as valid.  */
-       --p;
        for (i = 0; i < n_switches; i++)
! 	if (!strncmp (switches[i].part1, filter, p - filter))
  	  switches[i].validated = 1;
      }
    else
--- 5914,5921 ----
    else if (p[-1] == '*')
      {
        /* Mark all matching switches as valid.  */
        for (i = 0; i < n_switches; i++)
! 	if (!strncmp (switches[i].part1, filter, p - filter - 1))
  	  switches[i].validated = 1;
      }
    else
***************
*** 5927,5932 ****
--- 5928,5936 ----
  	    switches[i].validated = 1;
  	}
      }
+ 
+   if (*p++ == '|')
+     goto next_member;
  }
  
  /* Check whether a particular argument was used.  The first time we

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]