Bug in cpplib (was: Re: typos in f77 docs)
Daniel Jacobowitz
drow@false.org
Fri Mar 26 21:19:00 GMT 1999
On Thu, Mar 25, 1999 at 04:41:53PM -0500, Zack Weinberg wrote:
> cpplib uses @ as an escape character internally. Look in cpphash.c at
> macroexpand(), macarg(), and their subroutines. The bug will be related to
> the fact that @ is not considered to be an escape inside a quoted string.
> It is doubled when read since it's not in a string then, but the
> string-quote operator isn't taking it out again.
>
> I'll look at this eventually, but I can't do any real development right now
> since my computer is dead.
Well, I have a fix to this based on your description.
My only doubt about it is whether the string being stringified will
always be escaped already; I can't see any reason it wouldn't be, but I
haven't spent a lot of time working through cpplib. Here's a patch
that fixes the problem for me; bootstrapped on
powerpc-debian-linux-gnu.
Dan
/--------------------------------\ /--------------------------------\
| Daniel Jacobowitz |__| CMU, CS class of 2002 |
| Debian GNU/Linux Developer __ Part-Time Systems Programmer |
| dan@debian.org | | drow@cs.cmu.edu |
\--------------------------------/ \--------------------------------/
Sat Mar 27 00:10:21 1999 Daniel Jacobowitz <dan@debian.org>
* Unescape '@@' inside macro arguments.
Index: gcc/cpphash.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cpphash.c,v
retrieving revision 1.16
diff -u -r1.16 cpphash.c
--- cpphash.c 1999/03/16 13:10:15 1.16
+++ cpphash.c 1999/03/27 05:00:53
@@ -1203,6 +1203,7 @@
int arglen = arg->raw_length;
int escaped = 0;
int in_string = 0;
+ int at_sign = 0;
int c;
/* Initially need_space is -1. Otherwise, 1 means the
previous character was a space, but we suppressed it;
@@ -1215,6 +1216,23 @@
for (; i < arglen; i++)
{
c = (ARG_BASE + arg->raw)[i];
+
+ /* The argument has already been @ escaped.
+ Undouble the @'s which got doubled. */
+ if (!in_string && (c == '@'))
+ {
+ if(at_sign)
+ {
+ at_sign = 0;
+ continue;
+ }
+ else
+ {
+ CPP_PUTC (pfile, '@');
+ at_sign = 1;
+ continue;
+ }
+ }
if (!in_string)
{
More information about the Gcc-patches
mailing list