-
Notifications
You must be signed in to change notification settings - Fork 544
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
flex %option noline
outputs a #line directive
#268
Comments
Would dec42ee solve this issue? |
Until the issue is fixed here a suggestion for a workaround: Pipe flex's output through
by
NB: flex automatically copies verbatim line directives as part of |
Yes, it should be straightforward to workaround. It would be nice to fix this in Flex itself though, as #344 seems to achieve. For the curious reader, what led me to trip over this was attempting to make a reproducible build for Debian packaging. Do we have any estimate on when 2.6.6 is likely to ship? |
I don't do time estimates. Noted about the need and priority, however.
…On Wednesday, 18 March 2020, 12:06 pm -0700, Matthew Fernandez ***@***.***> wrote:
Yes, it should be straightforward to workaround. It would be nice to fix this in Flex itself though, as #344 seems to achieve. For the curious reader, what led me to trip over this was attempting to make a [reproducible build for Debian packaging](https://wiki.debian.org/ReproducibleBuilds). Do we have any estimate on when 2.6.6 is likely to ship?
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#268 (comment)
--
Will Estes
[email protected]
|
I have not yet bisected, but I think this was possibly (silently) fixed in 64cf032, the relevant hunk being: diff --git src/scan.l src/scan.l
index 099d153..82d57df 100644
--- src/scan.l
+++ src/scan.l
@@ -164,9 +164,13 @@ M4QEND "]""]"
^"%x"{NAME}? return XSCDECL;
^"%{".*{NL} START_CODEBLOCK(false);
^"%top"[[:blank:]]*"{"[[:blank:]]*{NL} {
+ char trampoline[512];
brace_start_line = linenum;
++linenum;
- buf_linedir( &top_buf, infilename?infilename:"<stdin>", linenum);
+ snprintf(trampoline, sizeof(trampoline),
+ "M4_HOOK_TRACE_LINE_FORMAT(%d, [[%s]])",
+ linenum, infilename?infilename:"<stdin>");
+ buf_strappend(&top_buf, trampoline);
brace_depth = 1;
yy_push_state(CODEBLOCK_MATCH_BRACE);
} |
Sorry, ignore the above. While the discussion about segfaulting in prior commits is accurate, this bug is not fixed. I guess I was bamboozled by all the cross-cutting issues, but in trying to confirm my results I cannot. The bug is still reproducible on the current head of master, 7ea145a. Can someone with authority please re-open this issue? |
This aids reproducible builds, which we have gradually been progressing towards. At this point it seems unlikely the Flex bug¹ that prevents using `%option noline` will ever be fixed. So lets just use the work around for it. ¹ westes/flex#268
This aids reproducible builds, which we have gradually been progressing towards. At this point it seems unlikely the Flex bug¹ that prevents using `%option noline` will ever be fixed. So lets just use the work around for it. ¹ westes/flex#268
This aids reproducible builds, which we have gradually been progressing towards. At this point it seems unlikely the Flex bug¹ that prevents using `%option noline` will ever be fixed. So lets just use the work around for it. ¹ westes/flex#268
Used flex version
2.6.4
download from https://github.com/westes/flex/releases/download/v2.6.4/flex-2.6.4.tar.gz
Input file
I have a file which filename is
test.flex
,the content is
Process
I used command line
flex test.flex
to generate filelex.yy.option_noline.cc
,then I remove the
%option noline
from filetest.flex
,I use command line
flex --noline test.flex
to generate filelex.yy.commandline_noline.cc
.git diff the two generate file, a part of the diff is:
We can see, if we use
%option noline
, flex also outputs#line
to the generate.cc
file (lex.yy.option_noline.cc
) which was not expected. On the other hand, the command line optionflex --noline
is not outputs#line
.Found & Research
I found in the flex source code, it use a global variable
int gen_line_dirs
to decide flex is outputs
#line
or not. but when flex outputs#line
the variablegen_line_dirs
is 1, then it make outputs.I debug the source code, the callstack is:
The line number at the end of callstack line maybe not right, I add some
fflush(stdout)
in the file for debug, it will affect the line number.Releated issues of this repo
#55 flex --noline outputs a #line directive
#161 filter: Don't emit #line directive to header if noline option is set
#56 %option noline generates and error message
Attachment
the file
test.flex
andlex.diff
:check_lineno.zip
The text was updated successfully, but these errors were encountered: