summaryrefslogtreecommitdiff
path: root/glcpp/glcpp-lex.l
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2010-06-18 15:23:50 -0700
committerKenneth Graunke <kenneth@whitecape.org>2010-06-21 12:31:03 -0700
commit8f322216382e2f017b4f3adefd441f84f45b0249 (patch)
treee6b819e573b244012f3b0c240801930f673bae61 /glcpp/glcpp-lex.l
parente8e93a45436b06713b83e3d353ab848d85de6758 (diff)
glcpp: Fix line and column numbering.
Lines were off by one, and column numbering was completely daft.
Diffstat (limited to 'glcpp/glcpp-lex.l')
-rw-r--r--glcpp/glcpp-lex.l7
1 files changed, 6 insertions, 1 deletions
diff --git a/glcpp/glcpp-lex.l b/glcpp/glcpp-lex.l
index 3703ad90fe..3eb0fbc1d3 100644
--- a/glcpp/glcpp-lex.l
+++ b/glcpp/glcpp-lex.l
@@ -32,7 +32,7 @@
do { \
yylloc->source = 0; \
yylloc->first_column = yycolumn + 1; \
- yylloc->first_line = yylineno + 1; \
+ yylloc->first_line = yylineno; \
yycolumn += yyleng; \
} while(0);
%}
@@ -82,6 +82,8 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
* Simply pass them through to the main compiler's lexer/parser. */
{HASH}(extension|version|pragma).*\n {
yylval->str = xtalloc_strdup (yyextra, yytext);
+ yylineno++;
+ yycolumn = 0;
return OTHER;
}
@@ -126,6 +128,9 @@ HEXADECIMAL_INTEGER 0[xX][0-9a-fA-F]+[uU]?
* We use the lexing_if flag to avoid skipping any part of an
* if conditional expression. */
[^\n]+/\n {
+ /* Since this rule always matches, YY_USER_ACTION gets called for it,
+ * wrongly incrementing yycolumn. We undo that effect here. */
+ yycolumn -= yyleng;
if (yyextra->lexing_if ||
yyextra->skip_stack == NULL ||
yyextra->skip_stack->type == SKIP_NO_SKIP)