From: Peter Johnson Date: Tue, 29 Apr 2008 05:11:52 +0000 (-0000) Subject: Fix GAS handling of NASM preproc %line. X-Git-Tag: v0.7.2~7^2~22 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5bdb018c95c3b6db229393b68c5fcf5cab385272;p=yasm Fix GAS handling of NASM preproc %line. Reported by: Brian Gladman svn path=/trunk/yasm/; revision=2078 --- diff --git a/modules/parsers/gas/gas-parse.c b/modules/parsers/gas/gas-parse.c index 1873521a..a0e09156 100644 --- a/modules/parsers/gas/gas-parse.c +++ b/modules/parsers/gas/gas-parse.c @@ -395,6 +395,15 @@ nasm_line_marker(yasm_parser_gas *parser_gas) line = yasm_intnum_get_uint(INTNUM_val); + /* + Set to (line - 1) since the directive indicates that the *next* line + will have the number given. + + cpp should never produce line=0, but the if keeps us safe just incase. + */ + if (line != 0) + line--; + yasm_intnum_destroy(INTNUM_val); get_next_token(); /* INTNUM */ @@ -425,7 +434,6 @@ nasm_line_marker(yasm_parser_gas *parser_gas) } filename = STRING_val.contents; - get_next_token(); /* STRING */ /* Set linemap. */ yasm_linemap_set(parser_gas->linemap, filename, line, incr); @@ -447,6 +455,10 @@ nasm_line_marker(yasm_parser_gas *parser_gas) yasm_vps_delete(&vps); } else yasm_xfree(filename); + + /* We need to poke back on the \n that was consumed by the tokenizer */ + parser_gas->peek_token = '\n'; + get_next_token(); } /* Line directive */