[Developers] Handle empty macro arguments correctly in cpp.pl

Erik Schnetter schnetter at cct.lsu.edu
Tue Oct 4 23:13:19 CDT 2005

The perl cpp does not handle empty macro arguments correctly.  When  
the last macro argument is empty, it thinks there is one argument too  
few.  That is, the following code

#define M2(a,b)

leads to an error message stating that M2 was used with only a single  
argument.  This is wrong, as it is called with two arguments, where  
the second argument is the empty string.  After reading the GNU cpp  
manual, I think that the ANSI standard requires that empty arguments  
must be handled.

The problem is that the routine SplitArgs that decodes the macro  
arguments cannot distinguish between an empty last argument and no  
argument, as both are represented by an empty string.  I change the  
routine so that an empty string always means "empty argument".  This  
means that SplitArgs cannot be called any more if there are no  
arguments -- but this does not matter.  I place a corresponding if  
statement around the call.


Erik Schnetter <schnetter at cct.lsu.edu>

My email is as private as my paper mail.  I therefore support encrypting
and signing email messages.  Get my PGP key from www.keyserver.net.

--- StripMime Report -- processed MIME parts ---
    text/plain (text body -- kept)

More information about the Developers mailing list