From: Olivier Courtin Date: Wed, 4 Nov 2009 21:10:40 +0000 (+0000) Subject: Allow a double to not have digit after dot (related to #175). Update unit test case X-Git-Tag: 1.5.0b1~294 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8d09ad000f49e9649e455c962a5436921401e426;p=postgis Allow a double to not have digit after dot (related to #175). Update unit test case git-svn-id: http://svn.osgeo.org/postgis/trunk@4741 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/liblwgeom/wktparse.lex b/liblwgeom/wktparse.lex index ffc21991a..22ea82ed9 100644 --- a/liblwgeom/wktparse.lex +++ b/liblwgeom/wktparse.lex @@ -28,7 +28,7 @@ static YY_BUFFER_STATE buf_state; %% -[-|\+]?[0-9]+(\.)?([0-9]+)?([Ee](\+|-)?[0-9]+)? { lwg_parse_yylval.value=atof(lwg_parse_yytext); UPDATE_YYLLOC(); return VALUE; } +[-|\+]?[0-9]+(\.[0-9]+)?([Ee](\+|-)?[0-9]+)? { lwg_parse_yylval.value=atof(lwg_parse_yytext); UPDATE_YYLLOC(); return VALUE; } [-|\+]?(\.[0-9]+)([Ee](\+|-)?[0-9]+)? { lwg_parse_yylval.value=atof(lwg_parse_yytext); UPDATE_YYLLOC(); return VALUE; } 00[0-9A-F]* { lwg_parse_yylval.wkb=lwg_parse_yytext; return WKB;} diff --git a/postgis/lwgeom_in_gml.c b/postgis/lwgeom_in_gml.c index e4efb51e9..8a6d4f3dc 100644 --- a/postgis/lwgeom_in_gml.c +++ b/postgis/lwgeom_in_gml.c @@ -463,8 +463,7 @@ static double parse_gml_double(char *d, bool space_before, bool space_after) /* * Double pattern - * [-|\+]?[0-9]+(\.[0-9]+)?([Ee](\+|-)?[0-9]+) - * + * [-|\+]?[0-9]+(\.)?([0-9]+)?([Ee](\+|-)?[0-9]+)? * We could also meet spaces before or after * this pattern upon parameters */ @@ -491,12 +490,13 @@ static double parse_gml_double(char *d, bool space_before, bool space_after) } else if (isspace(*p)) { if (!space_after) lwerror("invalid GML representation"); if (st == DIG || st == DIG_DEC || st == DIG_EXP)st = END; + else if (st == NEED_DIG_DEC) st = END; else if (st == END); else lwerror("invalid GML representation"); } else lwerror("invalid GML representation"); } - if (st != DIG && st != DIG_DEC && st != DIG_EXP && st != END) + if (st != DIG && st != NEED_DIG_DEC && st != DIG_DEC && st != DIG_EXP && st != END) lwerror("invalid GML representation"); return atof(d); diff --git a/regress/in_gml.sql b/regress/in_gml.sql index ea0b0f9cd..58dde924b 100644 --- a/regress/in_gml.sql +++ b/regress/in_gml.sql @@ -826,7 +826,7 @@ SELECT 'double_5', ST_AsEWKT(ST_GeomFromGML('1 1-1 SELECT 'double_6', ST_AsEWKT(ST_GeomFromGML('1 1.2')); SELECT 'double_7', ST_AsEWKT(ST_GeomFromGML('1 1.23')); --- ERROR: no digit after dot +-- no digit after dot SELECT 'double_8', ST_AsEWKT(ST_GeomFromGML('1 1.')); -- ERROR: several dots diff --git a/regress/in_gml_expected b/regress/in_gml_expected index aa7841cfd..4bad3fd87 100644 --- a/regress/in_gml_expected +++ b/regress/in_gml_expected @@ -258,7 +258,7 @@ ERROR: invalid GML representation ERROR: invalid GML representation double_6|POINT(1 1.2) double_7|POINT(1 1.23) -ERROR: invalid GML representation +double_8|POINT(1 1) ERROR: invalid GML representation ERROR: invalid GML representation ERROR: invalid GML representation