aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-08-18 03:35:08 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-08-18 03:35:08 +0000
commit2efb8e80703532744a7caf35244dfe7ad8a85cff (patch)
tree6b4ed31f93c9ef7652ad1fc1b10ef8b26ded4ffc
parent2c6b34d95980a102ab0c7f1049ec2869ab01ac74 (diff)
downloadpostgresql-2efb8e80703532744a7caf35244dfe7ad8a85cff.tar.gz
postgresql-2efb8e80703532744a7caf35244dfe7ad8a85cff.zip
Code review for 'at character n' patch --- point at proper end of
a token scanned by multiple lex rules.
-rw-r--r--src/backend/parser/scan.l15
-rw-r--r--src/test/regress/expected/strings.out2
2 files changed, 9 insertions, 8 deletions
diff --git a/src/backend/parser/scan.l b/src/backend/parser/scan.l
index 51e1aa4be8e..5092f82e5e0 100644
--- a/src/backend/parser/scan.l
+++ b/src/backend/parser/scan.l
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.99 2002/08/17 13:06:50 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/scan.l,v 1.100 2002/08/18 03:35:08 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -582,12 +582,13 @@ other .
void
yyerror(const char *message)
{
- if(yyleng == 1 && *yytext == YY_END_OF_BUFFER_CHAR)
- elog(ERROR, "parser: %s at end of input",message);
- else
- elog(ERROR, "parser: %s at or near \"%s\" at character %i",
- message,token_start ? token_start : yytext,
- (unsigned int)(yytext - scanbuf + 1));
+ const char *loc = token_start ? token_start : yytext;
+
+ if (*loc == YY_END_OF_BUFFER_CHAR)
+ elog(ERROR, "parser: %s at end of input", message);
+ else
+ elog(ERROR, "parser: %s at or near \"%s\" at character %d",
+ message, loc, (loc - scanbuf + 1));
}
diff --git a/src/test/regress/expected/strings.out b/src/test/regress/expected/strings.out
index b275df2ff86..67dbd1a2d92 100644
--- a/src/test/regress/expected/strings.out
+++ b/src/test/regress/expected/strings.out
@@ -18,7 +18,7 @@ SELECT 'first line'
' - next line' /* this comment is not allowed here */
' - third line'
AS "Illegal comment within continuation";
-ERROR: parser: parse error at or near "' - third line'" at character 89
+ERROR: parser: parse error at or near "' - third line'" at character 75
--
-- test conversions between various string types
-- E021-10 implicit casting among the character data types