[postgis-tickets] r17128 - Fix other test cases and move change closer to

Paul Ramsey pramsey at cleverelephant.ca
Wed Jan 9 11:43:03 PST 2019


Author: pramsey
Date: 2019-01-09 11:43:03 -0800 (Wed, 09 Jan 2019)
New Revision: 17128

Modified:
   trunk/liblwgeom/cunit/cu_in_wkt.c
   trunk/liblwgeom/cunit/cu_out_x3d.c
   trunk/liblwgeom/lwin_wkt_parse.c
   trunk/postgis/lwgeom_inout.c
   trunk/postgis/lwgeom_ogc.c
Log:
Fix other test cases and move change closer to
the problem.
References #4273


Modified: trunk/liblwgeom/cunit/cu_in_wkt.c
===================================================================
--- trunk/liblwgeom/cunit/cu_in_wkt.c	2019-01-09 16:42:23 UTC (rev 17127)
+++ trunk/liblwgeom/cunit/cu_in_wkt.c	2019-01-09 19:43:03 UTC (rev 17128)
@@ -67,6 +67,11 @@
 
 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)") );

Modified: trunk/liblwgeom/cunit/cu_out_x3d.c
===================================================================
--- trunk/liblwgeom/cunit/cu_out_x3d.c	2019-01-09 16:42:23 UTC (rev 17127)
+++ trunk/liblwgeom/cunit/cu_out_x3d.c	2019-01-09 19:43:03 UTC (rev 17128)
@@ -77,7 +77,7 @@
 
 	/* huge data */
 	do_x3d3_test(
-	    "POINT(1E300 -105E-153 4E300)'", "1e+300 0 4e+300", NULL, 0, 0);
+	    "POINT(1E300 -105E-153 4E300)", "1e+300 0 4e+300", NULL, 0, 0);
 }
 
 

Modified: trunk/liblwgeom/lwin_wkt_parse.c
===================================================================
--- trunk/liblwgeom/lwin_wkt_parse.c	2019-01-09 16:42:23 UTC (rev 17127)
+++ trunk/liblwgeom/lwin_wkt_parse.c	2019-01-09 19:43:03 UTC (rev 17128)
@@ -95,16 +95,16 @@
 /* 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;
@@ -137,14 +137,14 @@
 	/* 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 )
 		{
@@ -153,17 +153,17 @@
 			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();

Modified: trunk/postgis/lwgeom_inout.c
===================================================================
--- trunk/postgis/lwgeom_inout.c	2019-01-09 16:42:23 UTC (rev 17127)
+++ trunk/postgis/lwgeom_inout.c	2019-01-09 19:43:03 UTC (rev 17128)
@@ -143,8 +143,7 @@
 	/* WKT then. */
 	else
 	{
-		int rv = lwgeom_parse_wkt(&lwg_parser_result, str, LW_PARSER_CHECK_ALL);
-		if ( rv == LW_FAILURE || lwg_parser_result.errcode )
+		if ( lwgeom_parse_wkt(&lwg_parser_result, str, LW_PARSER_CHECK_ALL) == LW_FAILURE )
 		{
 			PG_PARSER_ERROR(lwg_parser_result);
 			PG_RETURN_NULL();

Modified: trunk/postgis/lwgeom_ogc.c
===================================================================
--- trunk/postgis/lwgeom_ogc.c	2019-01-09 16:42:23 UTC (rev 17127)
+++ trunk/postgis/lwgeom_ogc.c	2019-01-09 19:43:03 UTC (rev 17128)
@@ -788,13 +788,11 @@
 	LWGEOM_PARSER_RESULT lwg_parser_result;
 	GSERIALIZED *geom_result = NULL;
 	LWGEOM *lwgeom;
-	int rv;
 
 	POSTGIS_DEBUG(2, "LWGEOM_from_text");
 	POSTGIS_DEBUGF(3, "wkt: [%s]", wkt);
 
-	rv = lwgeom_parse_wkt(&lwg_parser_result, wkt, LW_PARSER_CHECK_ALL);
-	if (rv == LW_FAILURE || lwg_parser_result.errcode)
+	if (lwgeom_parse_wkt(&lwg_parser_result, wkt, LW_PARSER_CHECK_ALL) == LW_FAILURE )
 		PG_PARSER_ERROR(lwg_parser_result);
 
 	lwgeom = lwg_parser_result.geom;



More information about the postgis-tickets mailing list