#1004911 flex: Line numbers in C code incorrect for .l source

Package:
flex
Source:
flex
Description:
fast lexical analyzer generator
Submitter:
Bill Currie
Date:
2022-02-03 14:15:04 UTC
Severity:
normal
#1004911#5
Date:
2022-02-03 13:08:22 UTC
From:
To:
Dear Maintainer,

Line numbers refering to the source .l file are generally out by one,
making it difficult to handle compiler error messages (especially when
gcc tries to be helpful by displaying the line, but instead shows the
wrong line) or to debug in gdb as gdb shows the wrong line.

Injecting an error into the code:
^#{s}+{D}+{s}+\"(\.|[^"\n])*\".*$ { li ne_info (yytext + 1); } // line 120

Produces:
../tools/qfcc/source/qc-lex.l:121:3: error: unknown type name ‘li’
  121 | ^#line{s}+{D}+{s}+\"(\.|[^"\n])*\".*$ { line_info (yytext + 5); }