ned14 / pcpp

A C99 preprocessor written in pure Python
Other
215 stars 39 forks source link

Macro line continuation bug #63

Closed dslijepcevic closed 3 years ago

dslijepcevic commented 3 years ago

test.c:

#define x\
 \

#include "test.h"

test.h:

int f();

Running pcpp --line-directive= --passthru-defines test.c produces the following output:

#define x int f();

If I omit the leading space on the second line of #define x then I get:

Traceback (most recent call last):
  File "/home/dux/.local/lib/python2.7/site-packages/pcpp/pcmd.py", line 140, in __init__
    self.write(self.args.output)
  File "/home/dux/.local/lib/python2.7/site-packages/pcpp/preprocessor.py", line 1341, in write
    toks[n-1].value = toks[n-1].value[0]
IndexError: string index out of range
None

INTERNAL PREPROCESSOR ERROR AT AROUND test.c:3, FATALLY EXITING NOW
ned14 commented 3 years ago

Confirmed.

ned14 commented 3 years ago

Fixed. Let me know if it isn't fixed for you. Thanks for reporting the issue!