From: kramm Date: Sun, 30 Mar 2003 15:16:05 +0000 (+0000) Subject: fix for line/column numbers when including files X-Git-Tag: release-0-4-4~68 X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=commitdiff_plain;h=ee15a3b589d20a918d60e91a58eea067faf75cfc fix for line/column numbers when including files --- diff --git a/src/parser.lex b/src/parser.lex index 7da8d5e..beca943 100644 --- a/src/parser.lex +++ b/src/parser.lex @@ -1,6 +1,8 @@ %{ #include +#include +#include #include "q.h" #include "parser.h" @@ -118,6 +120,8 @@ static void store(enum type_t type, int line, int column, char*text, int length) #define MAX_INCLUDE_DEPTH 16 YY_BUFFER_STATE include_stack[MAX_INCLUDE_DEPTH]; +int line_stack[MAX_INCLUDE_DEPTH]; +int column_stack[MAX_INCLUDE_DEPTH]; int include_stack_ptr = 0; void handleInclude(char*text, int len) @@ -137,7 +141,10 @@ void handleInclude(char*text, int len) fprintf( stderr, "Includes nested too deeply" ); exit( 1 ); } - include_stack[include_stack_ptr++] = YY_CURRENT_BUFFER; + include_stack[include_stack_ptr] = YY_CURRENT_BUFFER; + line_stack[include_stack_ptr] = line; + column_stack[include_stack_ptr] = column; + include_stack_ptr++; yyin = fopen(text, "rb"); if (!yyin) { fprintf(stderr, "Couldn't open %s\n", text); @@ -208,6 +215,8 @@ RVALUE \"{STRING}\"|([^ \n\r\t]+) yy_delete_buffer( YY_CURRENT_BUFFER ); yy_switch_to_buffer( include_stack[include_stack_ptr] ); + column = column_stack[include_stack_ptr]; + line = line_stack[include_stack_ptr]; } }