On 2014-05-04 09:34, Manoj Srivastava wrote:
> On Fri, May 27 2011, Denis Excoffier wrote:
> 
>> On 2010-04-15 00:48, Marcus Rausch wrote:
>>> Hi,
>>> 
>>> how about the patch below? It  apparently solves the problem, but I
>>> don't know if it has any unwanted side effects.
>>> 
>>> Best regards
>>> Marcus
>>> 
>>> 
>>> *** gen.c-old   2007-05-31 08:21:57.000000000 +0200
>>> --- gen.c       2010-04-14 23:58:47.000000000 +0200
>>> ***************
>>> *** 2159,2164 ****
>>> --- 2159,2165 ----
>>> 
>>>       /* Copy remainder of input to output. */
>>> 
>>> +       linenum--;
>>>       line_directive_out (stdout, 1);
>>> 
>>>       if (sectnum == 3) {
> 
>> Seems to work (i tested it).
> 
>        If that is the case, I can install the patch.
> 
>> However, i would prefer that you remove one of the blank lines
>> *after* this #line directive. That way, the linenum variable
>> is left unchanged.
> 
>        Could you elaborate? Where is this blank line being emitted?

Take a flex-2.5.39 with no patch, feed it with the following foo.lex:
% cat foo.lex
/* myline 1 */
%%
  /* myline 3 */
%%
/* myline 5 */ int main() {
  yylex();
  fprintf(stdout, "%s %u\n", __FILE__, __LINE__);
  return(0);
}
/* myline 10 */
%

In the output, you get 2 empty lines just before ‘/* myline 5 */‘. If you
remove one of these, you get the same effect as with --linenum.
I think this is preferable to ‘--linenum’ (because you don’t have any reason to
have 2 empty lines at the first place). Currently, i was not able to
understand how to make this line disappear.

By the way, you also get an unexpected extra empty line after ‘/* myline 10 
*/‘. To
omit this one, the easiest way is to replace ‘OUT_END_CODE ()’ in gen.c with
outc(‘]’); outc(‘]’); outc(‘)’)
The drawback is that you don’t get an extra newline in case foo.lex does
not end with a newline, but you don’t have any source files not ending
with newline do you?

You also get many warnings when compiling under various options of GCC’s, but 
this is another
story. If you are interested, i can send you the patches i use for flex.skl, 
gen.c
and main.c, in order to silence the GCC warnings, but i suspect nearly everyone 
has its own set.
In bison, they have driven a campaign to remove these warnings. You must know 
this.

Regards, see you in three years (or before),

Denis Excoffier.


--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to