diff --git a/sqlparse.y b/sqlparse.y index 3fde7ef..52e6f37 100644 --- a/sqlparse.y +++ b/sqlparse.y @@ -1,4 +1,9 @@ -%define api.prefix {orafce_sql_yy} +/* + * %define api.prefix {orafce_sql_yy} is not compileable on old bison 2.4 + * so I am using obsolete but still working option. + */ + +%name-prefix "orafce_sql_yy" %{ @@ -46,8 +51,6 @@ static int scanbuflen; void orafce_sql_yyerror(List **result, const char *message); - -#define ORAFCE_SQL_YYLTYPE int #define YYMALLOC malloc /* XXX: should use palloc? */ #define YYFREE free /* XXX: should use pfree? */ diff --git a/sqlscan.l b/sqlscan.l index 9c04480..c2a1749 100644 --- a/sqlscan.l +++ b/sqlscan.l @@ -48,7 +48,7 @@ static bool extended_string = false; static YY_BUFFER_STATE scanbufhandle; -#define SET_YYLLOC() (orafce_sql_yylval.val.lloc = orafce_sql_yylloc = yytext - scanbuf) +#define SET_YYLLOC() (orafce_sql_yylval.val.lloc = yytext - scanbuf) /* Handles to the buffer that the lexer uses internally */ static char *scanbuf; @@ -884,7 +884,7 @@ lexer_errposition(void) int pos; /* Convert byte offset to character number */ - pos = _pg_mbstrlen_with_len(scanbuf, yylloc) + 1; + pos = _pg_mbstrlen_with_len(scanbuf, orafce_sql_yylval.val.lloc) + 1; /* And pass it to the ereport mechanism */ return errposition(pos); } @@ -902,13 +902,12 @@ lexer_errposition(void) void orafce_sql_yyerror(List **result, const char *message) { - const char *loc = scanbuf + yylloc; + const char *loc = scanbuf + orafce_sql_yylval.val.lloc; if (*loc == YY_END_OF_BUFFER_CHAR) { ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - /* translator: %s is typically "syntax error" */ errmsg("%s at end of input", _(message)), lexer_errposition())); } @@ -916,7 +915,6 @@ orafce_sql_yyerror(List **result, const char *message) { ereport(ERROR, (errcode(ERRCODE_SYNTAX_ERROR), - /* translator: first %s is typically "syntax error" */ errmsg("%s at or near \"%s\"", _(message), loc), lexer_errposition())); }