rpcgen: skip over #define lines in CPP output [BZ #21205]
diff mbox

Message ID 20170228202012.13576-1-vapier@gentoo.org
State New
Headers show

Commit Message

Mike Frysinger Feb. 28, 2017, 8:20 p.m. UTC
Sometimes the preprocessor will include #define lines in its output (like
when using gcc w/-ggdb3).  This causes rpcgen to choke with an error:
$ CPP='gcc -ggdb3 -E -x c-header' rpcgen -Y ../scripts/ -h rpcsvc/rex.x -o foo

rpcsvc/rex.x, line 1: preprocessor error

Change the parser to skip #define lines instead.
---
 sunrpc/rpc_scan.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Mike Frysinger March 17, 2017, 4:41 a.m. UTC | #1
On 28 Feb 2017 13:20, Mike Frysinger wrote:
> Sometimes the preprocessor will include #define lines in its output (like
> when using gcc w/-ggdb3).  This causes rpcgen to choke with an error:
> $ CPP='gcc -ggdb3 -E -x c-header' rpcgen -Y ../scripts/ -h rpcsvc/rex.x -o foo
> 
> rpcsvc/rex.x, line 1: preprocessor error
> 
> Change the parser to skip #define lines instead.

ping ?
-mike
Florian Weimer June 25, 2017, 4:19 p.m. UTC | #2
On 02/28/2017 09:20 PM, Mike Frysinger wrote:
> +  if (strncmp (line, "define", 6) == 0)
> +    return;

Please add a comment and perhaps a test case.

Thanks,
Florian

Patch
diff mbox

diff --git a/sunrpc/rpc_scan.c b/sunrpc/rpc_scan.c
index 0a88bafe768b..a230aa396b37 100644
--- a/sunrpc/rpc_scan.c
+++ b/sunrpc/rpc_scan.c
@@ -507,6 +507,8 @@  docppline (const char *line, int *lineno, const char **fname)
     {
       line++;
     }
+  if (strncmp (line, "define", 6) == 0)
+    return;
   num = atoi (line);
   while (isdigit (*line))
     {