felipeprov / include-what-you-use

Automatically exported from code.google.com/p/include-what-you-use
Other
0 stars 0 forks source link

pragma parsing chokes on \r #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
When source files are using 'PC' (\r\n) line endings, ProcessPragmasInFile 
fails to operate correctly. In my test case I have this line:

#include <stddef.h>  // IWYU pragma: keep

And IWYU gives this warning:

<blah>/Core/Types.h:3:47: warning: Unknown or malformed pragma (keep)

Stepping through in the debugger, pragma_text is "keep\r".

The attached patch resolves this issue for me, but I'm unable to run the 
testsuite to see if there are any regressions.

Original issue reported on code.google.com by paul.hol...@gmail.com on 9 Mar 2011 at 10:58

Attachments:

GoogleCodeExporter commented 9 years ago
Makes sense to me.  Applied in r59.

Note we'll still have trouble with mac line endings ('\r' instead of '\n'), 
which we'd have to fix in iwyu_lexer_utils.cc, in the routine that searches for 
the end of the line.  But I'm happy to not worry about that for now. :-)

Original comment by csilv...@gmail.com on 9 Mar 2011 at 11:50