Change 18270 by [EMAIL PROTECTED] on 2002/12/09 00:25:26
Subject: [perl #18256] xsubpp can make nested comments in C code
From: Nicholas Clark (via RT) <[EMAIL PROTECTED]>
Date: 7 Nov 2002 14:58:14 -0000
Message-Id: <[EMAIL PROTECTED]>
Affected files ...
.... //depot/perl/lib/ExtUtils/xsubpp#63 edit
Differences ...
==== //depot/perl/lib/ExtUtils/xsubpp#63 (xtext) ====
Index: perl/lib/ExtUtils/xsubpp
--- perl/lib/ExtUtils/xsubpp#62~17832~ Wed Sep 4 05:39:42 2002
+++ perl/lib/ExtUtils/xsubpp Sun Dec 8 16:25:26 2002
@@ -907,7 +907,19 @@
my $podstartline = $.;
do {
if (/^=cut\s*$/) {
- print("/* Skipped embedded POD. */\n");
+ # We can't just write out a /* */ comment, as our embedded
+ # POD might itself be in a comment. We can't put a /**/
+ # comment inside #if 0, as the C standard says that the source
+ # file is decomposed into preprocessing characters in the stage
+ # before preprocessing commands are executed.
+ # I don't want to leave the text as barewords, because the spec
+ # isn't clear whether macros are expanded before or after
+ # preprocessing commands are executed, and someone pathological
+ # may just have defined one of the 3 words as a macro that does
+ # something strange. Multiline strings are illegal in C, so
+ # the "" we write must be a string literal. And they aren't
+ # concatenated until 2 steps later, so we are safe.
+ print("#if 0\n \"Skipped embedded POD.\"\n#endif\n");
printf("#line %d \"$filename\"\n", $. + 1)
if $WantLineNumbers;
next firstmodule
End of Patch.