I revised the newline synchronization on -K option so that the annotations on #if, #else, #endif and the like lines exactly synchronize to number of newlines and #line.
I committed SVN revision 96.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have found a bug with the -K option and incorrect line numbering: an input file like this:
"""struct A;
#if 1
struct B;
#endif
"""
Is preprocessed as follows:
"""# 1 "/builds/testcases/mcpp/kifdef.cpp"
struct A;
/*if 3*//*i T*/
struct B;
/*endif 5*/
"""
I can't figure out whether the bug is stripping the empty line, or not inserting a # line directive to make the line numbers match up.
This patch fixes the problem for me, though the newlines get put in an odd spot.
Index: src/directive.c
--- src/directive.c (revision 95)
+++ src/directive.c (working copy)
@@ -464,7 +464,7 @@
if (mcpp_debug & MACRO_CALL) {
mcpp_fprintf( OUT, "/*i %c*/\n", compiling ? 'T' : 'F');
/* Report wheather the directive is evaluated TRUE or FALSE */
- newlines = -1;
+ --newlines;
}
return TRUE;
}
@@ -1456,7 +1456,7 @@
if ((mcpp_debug & MACRO_CALL) && dp->mline) {
/* Notice this directive unless the macro is predefined */
mcpp_fprintf( OUT, "/*undef %ld*//*%s*/\n", src_line, dp->name);
- newlines = -1;
+ --newlines;
}
free( dp); /* Delete the definition */
if (standard)
Thanks for the bug report.
I revised the newline synchronization on -K option so that the annotations on #if, #else, #endif and the like lines exactly synchronize to number of newlines and #line.
I committed SVN revision 96.