[Mesa-dev] [PATCH 05/10] glsl: Fix error message to include correct source string number

Carl Worth cworth at cworth.org
Sat Dec 8 13:43:40 PST 2012


We were going through the work to parse a directive like "#line 0 2" and
setting the source to 2. But then, we were re-setting the source to 0
at the beginning of every lex action. Instead, reset it to 0 only once at
the beginning of all lexing.

With this fix, correct source numbers will actually appear in error messages.
---
 src/glsl/glsl_lexer.ll |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index 2a0e01b..04cc778 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -36,13 +36,12 @@ static int classify_identifier(struct _mesa_glsl_parse_state *, const char *);
 
 #define YY_USER_ACTION						\
    do {								\
-      yylloc->source = 0;					\
       yylloc->first_column = yycolumn + 1;			\
       yylloc->first_line = yylineno + 1;			\
       yycolumn += yyleng;					\
    } while(0);
 
-#define YY_USER_INIT yylineno = 0; yycolumn = 0;
+#define YY_USER_INIT yylineno = 0; yycolumn = 0; yylloc->source = 0;
 
 /* A macro for handling reserved words and keywords across language versions.
  *
-- 
1.7.10



More information about the mesa-dev mailing list