Bug in gpc-cpp ?

Peter Gerwinski peter at gerwinski.de
Tue Dec 8 16:41:36 CET 1998


Hi!

> After getting a bug fix for the set addition problem from Peter
> (thanks very much Peter!) within 24 hours I've decided to try my
> luck again.

You are welcome.  (-: But please don't kill me if it takes me
longer next time ... ;-)

> There is some strangeness with the gpc-cpp preprocessor; here is some
> code to trigger it: [...]

The strange behaviour comes from a feature of the preprocessor
to include a header file with a "control macro" only once.
(In C, it is encouraged to write

   <start of file>
   #ifndef FOO_H
   #define FOO_H

   <acutal contents>

   #endif
   <end of file>

to avoid trouble if this header file is included more than once
from the same C file.)  The mechanism that tries to determine
whether a given #ifndef belongs to this kind of macros got
confused on two Pascal comments in sequence.

> I can easily work around this of course, but a fix would be better!

I agree.

Fix enclosed.

Greetings,

    Peter

-- 
Peter Gerwinski, Essen, Germany, http://home.pages.de/~Peter.Gerwinski/
Maintainer GNU Pascal - http://home.pages.de/~GNU-Pascal/ - gpc-980830
  PGP key on request - 6C 94 45 BE 28 A4 96 - 0E CC E9 12 47 25 82 75
Fight the SPAM and UBE! - http://spam.abuse.net/ - http://maps.vix.com/

--- gpc-cccp.c.orig	Tue Nov 24 15:54:28 1998
+++ gpc-cccp.c	Tue Dec  8 16:29:42 1998
@@ -8347,12 +8347,13 @@
 	      if (! pascal_comments)
 		goto fail;
 	      else
 		{
 		  int junk = 0;
 		  U_CHAR *save_bufp = ip->bufp;
+	          ip->bufp = p;
 		  p = skip_to_end_of_comment (ip, &junk, 1, '}');
 		  ip->bufp = save_bufp;
 		}
 	    }
 	  else if (c == comment_start_char
 	      && (*p == '*' || (cplusplus_comments && *p == '/'))) {




More information about the Gpc mailing list