static void test_wkt_in_point(void)
{
+ s = "POINT(1 2) foobar";
+ r = cu_wkt_in(s, WKT_SFSQL);
+ CU_ASSERT_STRING_EQUAL("parse error - invalid geometry", r);
+ lwfree(r);
+
s = "POINT(1e700 0)";
r = cu_wkt_in(s, WKT_SFSQL);
CU_TEST ( ! strcmp(r, "POINT(inf 0)") || ! strcmp(r, "POINT(1.#INF 0)") || ! strcmp(r, "POINT(Infinity 0)") );
/* Turn on/off verbose parsing (turn off for production) */
int wkt_yydebug = 0;
-/*
-* Error handler called by the bison parser. Mostly we will be
+/*
+* Error handler called by the bison parser. Mostly we will be
* catching our own errors and filling out the message and errlocation
-* from WKT_ERROR in the grammar, but we keep this one
+* from WKT_ERROR in the grammar, but we keep this one
* around just in case.
*/
void wkt_yyerror(__attribute__((__unused__)) const char *str)
{
/* If we haven't already set a message and location, let's set one now. */
- if ( ! global_parser_result.message )
+ if ( ! global_parser_result.message )
{
global_parser_result.message = parser_error_messages[PARSER_ERROR_OTHER];
global_parser_result.errcode = PARSER_ERROR_OTHER;
/* Set the input text string, and parse checks. */
global_parser_result.wkinput = wktstr;
global_parser_result.parser_check_flags = parser_check_flags;
-
+
wkt_lexer_init(wktstr); /* Lexer ready */
parse_rv = wkt_yyparse(); /* Run the parse */
LWDEBUGF(4,"wkt_yyparse returned %d", parse_rv);
wkt_lexer_close(); /* Clean up lexer */
-
+
/* A non-zero parser return is an error. */
- if ( parse_rv != 0 )
+ if ( parse_rv || global_parser_result.errcode )
{
if( ! global_parser_result.errcode )
{
global_parser_result.errlocation = wkt_yylloc.last_column;
}
- LWDEBUGF(5, "error returned by wkt_yyparse() @ %d: [%d] '%s'",
- global_parser_result.errlocation,
- global_parser_result.errcode,
+ LWDEBUGF(5, "error returned by wkt_yyparse() @ %d: [%d] '%s'",
+ global_parser_result.errlocation,
+ global_parser_result.errcode,
global_parser_result.message);
-
+
/* Copy the global values into the return pointer */
*parser_result = global_parser_result;
wkt_yylex_destroy();
return LW_FAILURE;
}
-
+
/* Copy the global value into the return pointer */
*parser_result = global_parser_result;
wkt_yylex_destroy();