PIDL: fix parsing linemarkers in preprocessor output
authorAlexander Bokovoy <ab@samba.org>
Wed, 6 Feb 2013 08:17:57 +0000 (10:17 +0200)
committerAlexander Bokovoy <ab@samba.org>
Wed, 6 Feb 2013 10:51:11 +0000 (11:51 +0100)
When PIDL calls out to C preprocessor to expand IDL files
and parse the output, it filters out linemarkers and line control
information as described in http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
and http://gcc.gnu.org/onlinedocs/cpp/Line-Control.html#Line-Control

With gcc 4.8 stdc-predef.h is included automatically and linemarker for the
file has extended flags that PIDL couldn't parse ('system header that needs to
be extern "C" protected for C++')

Thanks to Jakub Jelinek <jakub@redhat.com> for explanation of the linemarker format.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=906517

Reviewed-by: Andreas Schneider <asn@samba.org>
pidl/idl.yp
pidl/lib/Parse/Pidl/IDL.pm

index b5c5185fbe1a78e9b8e6395c5eab53630f988915..c8a65f6f629328e752c26eecfe5a6cd42d05b446 100644 (file)
@@ -610,7 +610,9 @@ again:
 
        for ($parser->YYData->{INPUT}) {
                if (/^\#/) {
-                       if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
+                       # Linemarker format is described at
+                       # http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
+                       if (s/^\# (\d+) \"(.*?)\"(( \d+){1,4}|)//) {
                                $parser->YYData->{LINE} = $1-1;
                                $parser->YYData->{FILE} = $2;
                                goto again;
index d4820ffe92cdf7e97d5b49f336456841e5878c59..6927c892556b8bc6f5d174091b7e5c45d140b77e 100644 (file)
@@ -2576,7 +2576,9 @@ again:
 
        for ($parser->YYData->{INPUT}) {
                if (/^\#/) {
-                       if (s/^\# (\d+) \"(.*?)\"( \d+|)//) {
+                       # Linemarker format is described at
+                       # http://gcc.gnu.org/onlinedocs/cpp/Preprocessor-Output.html
+                       if (s/^\# (\d+) \"(.*?)\"(( \d+){1,4}|)//) {
                                $parser->YYData->{LINE} = $1-1;
                                $parser->YYData->{FILE} = $2;
                                goto again;