Menu

Line numbers misreported with -K

2008-04-02
2013-05-28
  • Benjamin Smedberg

    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.

     
    • Benjamin Smedberg

      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)

       
    • Kiyoshi Matsui

      Kiyoshi Matsui - 2008-04-03

      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.

       

Log in to post a comment.