[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scan-gram.l patch to fix wrong columns in Bison EOF diagnostic
From: |
Paul Eggert |
Subject: |
scan-gram.l patch to fix wrong columns in Bison EOF diagnostic |
Date: |
Sat, 9 Nov 2002 21:25:55 -0800 (PST) |
I installed the following patch to fix a bug that I introduced in my
2002-11-07 patch.
2002-11-09 Paul Eggert <address@hidden>
* src/scan-gram.l (unexpected_end_of_file): Fix bug: columns were
counted in the token inserted at end of file. Now takes
location_t *, not location_t, so that the location can be
adjusted. All uses changed.
Index: src/scan-gram.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-gram.l,v
retrieving revision 1.37
diff -p -u -r1.37 scan-gram.l
--- src/scan-gram.l 8 Nov 2002 05:20:20 -0000 1.37
+++ src/scan-gram.l 9 Nov 2002 23:14:38 -0000
@@ -168,7 +168,7 @@ static void handle_at (braced_code_t cod
char *cp, location_t location);
static void handle_syncline (char *args, location_t *location);
static int convert_ucn_to_byte (char const *hex_text);
-static void unexpected_end_of_file (location_t, char const *);
+static void unexpected_end_of_file (location_t *, char const *);
%}
%x SC_COMMENT SC_LINE_COMMENT SC_YACC_COMMENT
@@ -331,7 +331,7 @@ splice (\\[ \f\t\v]*\n)*
}
.|\n ;
- <<EOF>> unexpected_end_of_file (*yylloc, "*/");
+ <<EOF>> unexpected_end_of_file (yylloc, "*/");
}
@@ -342,7 +342,7 @@ splice (\\[ \f\t\v]*\n)*
<SC_COMMENT>
{
"*"{splice}"/" YY_OBS_GROW; BEGIN c_context;
- <<EOF>> unexpected_end_of_file (*yylloc, "*/");
+ <<EOF>> unexpected_end_of_file (yylloc, "*/");
}
@@ -375,7 +375,7 @@ splice (\\[ \f\t\v]*\n)*
}
.|\n YY_OBS_GROW;
- <<EOF>> unexpected_end_of_file (*yylloc, "\"");
+ <<EOF>> unexpected_end_of_file (yylloc, "\"");
}
/*---------------------------------------------------------------.
@@ -399,7 +399,7 @@ splice (\\[ \f\t\v]*\n)*
}
.|\n YY_OBS_GROW;
- <<EOF>> unexpected_end_of_file (*yylloc, "'");
+ <<EOF>> unexpected_end_of_file (yylloc, "'");
}
@@ -472,7 +472,7 @@ splice (\\[ \f\t\v]*\n)*
"'" YY_OBS_GROW; BEGIN c_context;
\\{splice}[^\[\]] YY_OBS_GROW;
{splice} YY_OBS_GROW;
- <<EOF>> unexpected_end_of_file (*yylloc, "'");
+ <<EOF>> unexpected_end_of_file (yylloc, "'");
}
@@ -486,7 +486,7 @@ splice (\\[ \f\t\v]*\n)*
"\"" YY_OBS_GROW; BEGIN c_context;
\\{splice}[^\[\]] YY_OBS_GROW;
{splice} YY_OBS_GROW;
- <<EOF>> unexpected_end_of_file (*yylloc, "\"");
+ <<EOF>> unexpected_end_of_file (yylloc, "\"");
}
@@ -534,7 +534,7 @@ splice (\\[ \f\t\v]*\n)*
"@"(-?[0-9]+|"$") { handle_at (current_braced_code,
yytext, *yylloc); }
- <<EOF>> unexpected_end_of_file (*yylloc, "}");
+ <<EOF>> unexpected_end_of_file (yylloc, "}");
}
@@ -551,7 +551,7 @@ splice (\\[ \f\t\v]*\n)*
return PROLOGUE;
}
- <<EOF>> unexpected_end_of_file (*yylloc, "%}");
+ <<EOF>> unexpected_end_of_file (yylloc, "%}");
}
@@ -842,13 +842,18 @@ handle_syncline (char *args, location_t
`-------------------------------------------------------------*/
static void
-unexpected_end_of_file (location_t loc, char const *token_end)
+unexpected_end_of_file (location_t *loc, char const *token_end)
{
- size_t i;
+ size_t i = strlen (token_end);
- complain_at (loc, _("missing `%s' at end of file"), token_end);
- for (i = strlen (token_end); i != 0; i--)
- unput (token_end[i - 1]);
+ complain_at (*loc, _("missing `%s' at end of file"), token_end);
+
+ /* Adjust location's last column so that any later message does not
+ mention the characters just inserted. */
+ loc->last_column -= i;
+
+ while (i != 0)
+ unput (token_end[--i]);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scan-gram.l patch to fix wrong columns in Bison EOF diagnostic,
Paul Eggert <=