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: GCC accepts wide strings in #line directives


On Wed, Feb 16, 2000 at 07:02:20AM -0200, Alexandre Oliva wrote:
> On Feb 16, 2000, Zack Weinberg <zack@wolery.cumb.org> wrote:
> 
> > Rather than duplicate the test all over the place, please add
> > CPP_WSTRING and CPP_WCHAR token types for L"foo" and L'x'
> > respectively.
> 
> Good idea!
> 
> > That way, you only have to modify cpp_get_token and add a couple of
> > cases to cpp_lex over in cppexp.c.
> 
> I wish I had this last sentence before jumping into the code :-(

Sorry, I should've realized this was the right move earlier.

> Here's the patch, third generation.  Ok to install?

One more adjustment, please:

> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/cpplib.c,v
> retrieving revision 1.116
> diff -p -u -r1.116 cpplib.c
> --- gcc/cpplib.c	2000/02/16 08:43:57	1.116
> +++ gcc/cpplib.c	2000/02/16 08:57:28
> @@ -2407,6 +2407,8 @@ cpp_get_token (pfile)
>      }
>    else
>      {
> +      int wide;
> +
>        switch (c)
>  	{
>  	case '/':
> @@ -2447,10 +2449,13 @@ cpp_get_token (pfile)
>  
>  	case '\"':
>  	case '\'':
> +	  wide = 0;
>  	string:
>  	  parse_string (pfile, c);
>  	  pfile->only_seen_white = 0;
> -	  return c == '\'' ? CPP_CHAR : CPP_STRING;
> +	  return c == '\''
> +	    ? (wide ? CPP_WCHAR   : CPP_CHAR)
> +	    : (wide ? CPP_WSTRING : CPP_STRING);

Leave this part alone, except take out the string: label, and down
below... 

>  
>  	case '$':
>  	  if (!opts->dollars_in_ident)
> @@ -2600,6 +2605,7 @@ cpp_get_token (pfile)
>  	    {
>  	      CPP_PUTC (pfile, c);
>  	      c = GETC ();
> +	      wide = 1;
>  	      goto string;
>  	    }
>  	  goto letter;

just call parse_string directly from here.  That's a lot more
straightforward.  The existing structure is a hangover from when
parse_string wasn't a separate function, and there's no reason to
preserve it.

zw

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