]> granicus.if.org Git - flex/commitdiff
filter: Output correct #line value for current file.
authorJeff Smith <whydoubt@gmail.com>
Sat, 1 Apr 2017 06:18:12 +0000 (01:18 -0500)
committerWill Estes <westes575@gmail.com>
Sun, 14 May 2017 10:31:56 +0000 (06:31 -0400)
A #line pre-processor directive specifies the line number and source
file of the following lines. If the source file _is_ the current file,
the line number should be that of the line following the directive. So
the specified line number should be the current line number plus 1.

src/filter.c

index 71f3635fe5200a357560857466a2193f459dcef6..ed3bfe395c80508ea4e022649db23c0565b62262 100644 (file)
@@ -391,7 +391,7 @@ int filter_fix_linedirs (struct filter *chain)
                                /* Adjust the line directives. */
                                in_gen = true;
                                snprintf (buf, readsz, "#line %d \"%s\"\n",
-                                         lineno, filename);
+                                         lineno + 1, filename);
                        }
                        else {
                                /* it's a #line directive for code we didn't write */