Bug in cpplib (was: Re: typos in f77 docs)

Zack Weinberg zack@rabi.columbia.edu
Sat Mar 27 10:07:00 GMT 1999


On Sat, 27 Mar 1999 00:19:18 -0500, Daniel Jacobowitz wrote:
>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.

It /should/ always be escaped, but I can imagine conditions where it
wouldn't.  Read through macarg() and that should tell you.

Your code to unescape @ is incorrect in general.  You want to translate '@@'
to '@', '@ ' and '@-' to nothing, and leave all other @'s alone.  (Deleting
'@ ' may cause other problems, such as mysterious, inappropriate token
concatenation.  However, it shouldn't.)

The macro expansion code really needs to be gutted and rewritten.  It
suffers from excessive cleverness.  Also I think it's the next performance
bottleneck.

zw


More information about the Gcc-patches mailing list