From: Raúl Marín Rodríguez Date: Mon, 23 Jul 2018 15:42:59 +0000 (+0000) Subject: Fix WKT parser accepting numbers with multiple dots X-Git-Tag: 2.5.0beta2~24 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ba28a8ea39e8be0eabc322c992a315d9c09528e;p=postgis Fix WKT parser accepting numbers with multiple dots Closes #4109 Closes https://github.com/postgis/postgis/pull/277 git-svn-id: http://svn.osgeo.org/postgis/trunk@16662 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/NEWS b/NEWS index f0ed68f9b..c4cae3d5b 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,8 @@ New since PostGIS 2.5.0beta1 - #4120, ST_AsMVTGeom: Clip using tile coordinates (Raúl Marín). - #4132, ST_Intersection on Raster now works without throwing TopologyException (Vinícius A.B. Schmidt, Darafei Praliaskouski) + - #4109, Fix WKT parser accepting and interpreting numbers numbers with + multiple dots (Raúl Marín, Paul Ramsey) See PostGIS 2.5.0 section for full details diff --git a/liblwgeom/cunit/cu_in_wkt.c b/liblwgeom/cunit/cu_in_wkt.c index 04e41c6b0..adc615f74 100644 --- a/liblwgeom/cunit/cu_in_wkt.c +++ b/liblwgeom/cunit/cu_in_wkt.c @@ -346,6 +346,40 @@ static void test_wkt_in_errlocation(void) } +static void test_wkt_double(void) +{ + LWGEOM_PARSER_RESULT p; + int rv = 0; + char *wkt = 0; + + wkt = "LINESTRING(1.1.1, 2.2.2)"; + lwgeom_parser_result_init(&p); + rv = lwgeom_parse_wkt(&p, wkt, LW_PARSER_CHECK_ALL); + CU_ASSERT_EQUAL( rv, LW_FAILURE ); + + wkt = "LINESTRING(1.1 .1, 2.2 .2)"; + lwgeom_parser_result_init(&p); + rv = lwgeom_parse_wkt(&p, wkt, LW_PARSER_CHECK_ALL); + CU_ASSERT_EQUAL( rv, LW_SUCCESS ); + + wkt = "LINESTRING( 1.1 .1 , 2.2 .2 )"; + lwgeom_parser_result_init(&p); + rv = lwgeom_parse_wkt(&p, wkt, LW_PARSER_CHECK_ALL); + CU_ASSERT_EQUAL( rv, LW_SUCCESS ); + + wkt = "LINESTRING(\n1.1\n.1,\n2.2\n.2\n)"; + lwgeom_parser_result_init(&p); + rv = lwgeom_parse_wkt(&p, wkt, LW_PARSER_CHECK_ALL); + CU_ASSERT_EQUAL( rv, LW_SUCCESS ); + + wkt = "LINESTRING(1.1\t.1\t,\t2.2\t.2\t)"; + lwgeom_parser_result_init(&p); + rv = lwgeom_parse_wkt(&p, wkt, LW_PARSER_CHECK_ALL); + CU_ASSERT_EQUAL( rv, LW_SUCCESS ); + + lwgeom_parser_result_free(&p); +} + /* ** Used by test harness to register the tests in this file. */ @@ -368,4 +402,5 @@ void wkt_in_suite_setup(void) PG_ADD_TEST(suite, test_wkt_in_tin); PG_ADD_TEST(suite, test_wkt_in_polyhedralsurface); PG_ADD_TEST(suite, test_wkt_in_errlocation); -} + PG_ADD_TEST(suite, test_wkt_double); +} \ No newline at end of file diff --git a/liblwgeom/lwin_wkt_lex.c b/liblwgeom/lwin_wkt_lex.c index 08e80b10a..bce3b1f8d 100644 --- a/liblwgeom/lwin_wkt_lex.c +++ b/liblwgeom/lwin_wkt_lex.c @@ -623,27 +623,27 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[172] = +static const flex_int16_t yy_accept[173] = { 0, 0, 0, 27, 25, 24, 24, 20, 21, 22, 25, - 25, 1, 23, 25, 25, 25, 25, 19, 25, 25, - 25, 19, 24, 0, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, - 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, + 25, 25, 23, 25, 25, 25, 25, 19, 25, 25, + 25, 19, 24, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, + 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, + 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 13, 6, 0, 8, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, - 5, 4, 0, 0, 11, 0, 0, 0, 12, 0, - 0, 0, 0, 7, 0, 0, 0, 0, 14, 3, - 0 + 0, 13, 6, 0, 8, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 9, 0, + 0, 5, 4, 0, 0, 11, 0, 0, 0, 12, + 0, 0, 0, 0, 7, 0, 0, 0, 0, 14, + 3, 0 } ; static const YY_CHAR yy_ec[256] = @@ -688,103 +688,105 @@ static const YY_CHAR yy_meta[53] = 1, 1 } ; -static const flex_int16_t yy_base[172] = +static const flex_int16_t yy_base[173] = { 0, - 0, 0, 353, 366, 51, 53, 366, 366, 366, 48, - 342, 50, 366, 41, 40, 47, 44, 38, 44, 43, - 51, 50, 71, 341, 84, 85, 340, 70, 53, 74, - 72, 77, 79, 81, 84, 86, 88, 86, 90, 366, - 339, 338, 97, 87, 83, 86, 93, 101, 91, 113, - 107, 125, 366, 128, 113, 119, 128, 114, 130, 120, - 128, 121, 132, 335, 129, 132, 125, 130, 366, 129, - 131, 166, 366, 152, 162, 173, 164, 171, 162, 162, - 162, 163, 161, 172, 170, 166, 174, 184, 336, 65, - 180, 177, 201, 197, 189, 202, 198, 202, 206, 202, - - 366, 203, 214, 204, 218, 202, 220, 212, 207, 223, - 218, 212, 239, 245, 366, 232, 233, 246, 241, 248, - 251, 241, 241, 252, 258, 251, 247, 248, 251, 256, - 366, 366, 251, 366, 257, 269, 269, 278, 270, 279, - 283, 279, 283, 291, 279, 286, 294, 366, 295, 292, - 366, 366, 287, 296, 366, 301, 294, 302, 366, 293, - 305, 323, 318, 366, 326, 318, 328, 322, 366, 366, - 366 + 0, 0, 202, 384, 51, 53, 384, 384, 384, 48, + 190, 57, 384, 41, 41, 52, 49, 42, 48, 48, + 56, 53, 75, 186, 0, 96, 384, 106, 109, 54, + 62, 61, 80, 86, 91, 97, 100, 102, 100, 104, + 384, 179, 126, 112, 102, 105, 109, 117, 129, 120, + 126, 119, 136, 384, 139, 124, 130, 140, 127, 144, + 134, 142, 135, 148, 85, 141, 154, 148, 154, 384, + 157, 160, 195, 384, 166, 175, 184, 175, 185, 178, + 179, 178, 180, 178, 192, 190, 186, 194, 204, 76, + 69, 204, 202, 215, 210, 202, 218, 215, 220, 226, + + 218, 384, 223, 236, 227, 241, 225, 243, 236, 230, + 246, 242, 237, 253, 258, 384, 245, 249, 263, 259, + 266, 270, 260, 261, 274, 281, 274, 270, 271, 275, + 279, 384, 384, 274, 384, 281, 294, 283, 291, 283, + 295, 300, 297, 301, 310, 298, 306, 316, 384, 318, + 315, 384, 384, 310, 319, 384, 325, 317, 325, 384, + 317, 330, 337, 331, 384, 339, 334, 345, 340, 384, + 384, 384 } ; -static const flex_int16_t yy_def[172] = +static const flex_int16_t yy_def[173] = { 0, - 171, 1, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 0 + 172, 1, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 12, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 0 } ; -static const flex_int16_t yy_nxt[419] = +static const flex_int16_t yy_nxt[437] = { 0, 4, 5, 6, 7, 8, 4, 9, 10, 11, 12, 13, 4, 4, 14, 4, 15, 4, 16, 4, 4, 17, 18, 4, 4, 19, 4, 20, 21, 4, 4, 4, 22, 4, 14, 4, 15, 4, 16, 4, 4, 17, 18, 4, 4, 19, 4, 20, 21, 4, 4, - 4, 22, 23, 23, 23, 23, 24, 25, 27, 25, - 29, 32, 33, 34, 30, 28, 35, 36, 37, 31, - 38, 40, 23, 23, 90, 41, 39, 41, 43, 42, - 29, 32, 33, 34, 30, 28, 35, 36, 37, 31, - 38, 40, 27, 25, 26, 44, 39, 45, 43, 28, - - 28, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 44, 60, 45, 61, 28, - 28, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58, 59, 62, 60, 63, 61, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 77, 78, 79, 80, 62, 81, 63, 82, 64, - 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - 75, 77, 78, 79, 80, 87, 81, 88, 82, 83, - 89, 91, 90, 92, 93, 94, 84, 95, 96, 97, - 85, 98, 86, 99, 100, 87, 101, 88, 102, 83, - - 103, 91, 104, 92, 93, 94, 84, 95, 96, 97, - 85, 98, 86, 99, 100, 105, 101, 106, 102, 107, - 103, 108, 104, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 105, 121, 106, 122, 107, - 123, 108, 124, 109, 110, 111, 112, 113, 114, 115, - 116, 117, 118, 119, 120, 125, 121, 126, 122, 127, - 123, 128, 124, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 125, 141, 126, 142, 127, - 143, 128, 144, 129, 130, 131, 132, 133, 134, 135, - 136, 137, 138, 139, 140, 145, 141, 146, 142, 147, - - 143, 148, 144, 149, 150, 151, 152, 153, 154, 155, - 156, 157, 158, 159, 160, 145, 161, 146, 162, 147, - 163, 148, 164, 149, 150, 151, 152, 153, 154, 155, - 156, 157, 158, 159, 160, 165, 161, 166, 162, 167, - 163, 168, 164, 169, 170, 90, 76, 42, 42, 26, - 26, 26, 171, 171, 171, 165, 171, 166, 171, 167, - 171, 168, 171, 169, 170, 3, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171 + 4, 22, 23, 23, 23, 23, 24, 25, 27, 27, + 30, 27, 33, 27, 31, 28, 25, 34, 35, 32, + 36, 37, 29, 38, 41, 39, 23, 23, 91, 44, + 30, 40, 33, 45, 31, 91, 46, 34, 35, 32, + 36, 37, 29, 38, 41, 39, 77, 27, 27, 44, + + 27, 40, 27, 45, 47, 26, 46, 27, 27, 48, + 27, 29, 27, 49, 42, 26, 42, 50, 43, 51, + 52, 53, 54, 55, 47, 56, 57, 27, 27, 48, + 27, 29, 27, 49, 58, 43, 59, 50, 60, 51, + 52, 53, 54, 55, 61, 56, 57, 62, 63, 64, + 65, 66, 67, 68, 58, 69, 59, 70, 60, 71, + 72, 73, 74, 78, 61, 75, 76, 62, 63, 64, + 65, 66, 67, 68, 79, 69, 80, 70, 81, 71, + 72, 73, 74, 78, 82, 75, 76, 83, 43, 88, + 89, 90, 92, 91, 79, 26, 80, 93, 81, 26, + + 94, 172, 95, 96, 82, 97, 98, 83, 84, 88, + 89, 99, 92, 100, 101, 85, 102, 93, 103, 86, + 94, 87, 95, 96, 104, 97, 98, 105, 84, 106, + 107, 99, 108, 100, 101, 85, 102, 109, 103, 86, + 110, 87, 111, 114, 104, 112, 113, 105, 115, 106, + 107, 116, 108, 117, 118, 119, 120, 109, 121, 122, + 110, 123, 111, 114, 124, 112, 113, 125, 115, 126, + 127, 116, 128, 117, 118, 119, 120, 129, 121, 122, + 130, 123, 131, 132, 124, 133, 134, 125, 135, 126, + 127, 136, 128, 137, 138, 139, 140, 129, 141, 142, + + 130, 143, 131, 132, 144, 133, 134, 145, 135, 146, + 147, 136, 148, 137, 138, 139, 140, 149, 141, 142, + 150, 143, 151, 152, 144, 153, 154, 145, 155, 146, + 147, 156, 148, 157, 158, 159, 160, 149, 161, 162, + 150, 163, 151, 152, 164, 153, 154, 165, 155, 166, + 167, 156, 168, 157, 158, 159, 160, 169, 161, 162, + 170, 163, 171, 172, 164, 172, 172, 165, 172, 166, + 167, 172, 168, 172, 172, 172, 172, 169, 172, 172, + 170, 172, 171, 3, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172 } ; -static const flex_int16_t yy_chk[419] = +static const flex_int16_t yy_chk[437] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -792,46 +794,48 @@ static const flex_int16_t yy_chk[419] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 6, 6, 10, 10, 12, 12, - 14, 15, 16, 17, 14, 12, 18, 19, 20, 14, - 21, 22, 23, 23, 90, 28, 21, 28, 29, 28, - 14, 15, 16, 17, 14, 12, 18, 19, 20, 14, - 21, 22, 25, 25, 26, 30, 21, 31, 29, 25, - - 26, 32, 33, 34, 35, 36, 36, 37, 38, 39, - 43, 44, 45, 46, 47, 30, 48, 31, 49, 25, - 26, 32, 33, 34, 35, 36, 36, 37, 38, 39, - 43, 44, 45, 46, 47, 50, 48, 51, 49, 52, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 63, 65, 66, 67, 68, 50, 70, 51, 71, 52, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 63, 65, 66, 67, 68, 74, 70, 75, 71, 72, - 76, 77, 76, 78, 79, 80, 72, 81, 82, 83, - 72, 84, 72, 85, 86, 74, 87, 75, 88, 72, - - 91, 77, 92, 78, 79, 80, 72, 81, 82, 83, - 72, 84, 72, 85, 86, 93, 87, 94, 88, 95, - 91, 96, 92, 97, 98, 99, 99, 100, 102, 103, - 104, 105, 106, 107, 108, 93, 109, 94, 110, 95, - 111, 96, 112, 97, 98, 99, 99, 100, 102, 103, - 104, 105, 106, 107, 108, 113, 109, 114, 110, 116, - 111, 117, 112, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 128, 129, 113, 130, 114, 133, 116, - 135, 117, 136, 118, 119, 120, 121, 122, 123, 124, - 125, 126, 127, 128, 129, 137, 130, 138, 133, 139, - - 135, 140, 136, 141, 142, 143, 144, 145, 146, 147, - 149, 150, 153, 154, 156, 137, 157, 138, 158, 139, - 160, 140, 161, 141, 142, 143, 144, 145, 146, 147, - 149, 150, 153, 154, 156, 162, 157, 163, 158, 165, - 160, 166, 161, 167, 168, 89, 64, 42, 41, 27, - 24, 11, 3, 0, 0, 162, 0, 163, 0, 165, - 0, 166, 0, 167, 168, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - - 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, - 171, 171, 171, 171, 171, 171, 171, 171 + 14, 12, 15, 12, 14, 12, 12, 16, 17, 14, + 18, 19, 12, 20, 22, 21, 23, 23, 91, 30, + 14, 21, 15, 31, 14, 90, 32, 16, 17, 14, + 18, 19, 12, 20, 22, 21, 65, 26, 26, 30, + + 26, 21, 26, 31, 33, 26, 32, 28, 28, 34, + 28, 26, 28, 35, 29, 28, 29, 36, 29, 37, + 37, 38, 39, 40, 33, 44, 45, 43, 43, 34, + 43, 26, 43, 35, 46, 43, 47, 36, 48, 37, + 37, 38, 39, 40, 49, 44, 45, 50, 51, 52, + 53, 55, 56, 57, 46, 58, 47, 59, 48, 60, + 61, 62, 63, 66, 49, 64, 64, 50, 51, 52, + 53, 55, 56, 57, 67, 58, 68, 59, 69, 60, + 61, 62, 63, 66, 71, 64, 64, 72, 42, 75, + 76, 77, 78, 77, 67, 24, 68, 79, 69, 11, + + 80, 3, 81, 82, 71, 83, 84, 72, 73, 75, + 76, 85, 78, 86, 87, 73, 88, 79, 89, 73, + 80, 73, 81, 82, 92, 83, 84, 93, 73, 94, + 95, 85, 96, 86, 87, 73, 88, 97, 89, 73, + 98, 73, 99, 101, 92, 100, 100, 93, 103, 94, + 95, 104, 96, 105, 106, 107, 108, 97, 109, 110, + 98, 111, 99, 101, 112, 100, 100, 113, 103, 114, + 115, 104, 117, 105, 106, 107, 108, 118, 109, 110, + 119, 111, 120, 121, 112, 122, 123, 113, 124, 114, + 115, 125, 117, 126, 127, 128, 129, 118, 130, 131, + + 119, 134, 120, 121, 136, 122, 123, 137, 124, 138, + 139, 125, 140, 126, 127, 128, 129, 141, 130, 131, + 142, 134, 143, 144, 136, 145, 146, 137, 147, 138, + 139, 148, 140, 150, 151, 154, 155, 141, 157, 158, + 142, 159, 143, 144, 161, 145, 146, 162, 147, 163, + 164, 148, 166, 150, 151, 154, 155, 167, 157, 158, + 168, 159, 169, 0, 161, 0, 0, 162, 0, 163, + 164, 0, 166, 0, 0, 0, 0, 167, 0, 0, + 168, 0, 169, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172 } ; static yy_state_type yy_last_accepting_state; @@ -886,10 +890,10 @@ static void wkt_lexer_unknown() } while (0); -#line 889 "lwin_wkt_lex.c" +#line 893 "lwin_wkt_lex.c" #define YY_NO_INPUT 1 /* Suppress the default implementations. */ -#line 892 "lwin_wkt_lex.c" +#line 896 "lwin_wkt_lex.c" #define INITIAL 0 @@ -1107,7 +1111,7 @@ YY_DECL #line 49 "lwin_wkt_lex.l" -#line 1110 "lwin_wkt_lex.c" +#line 1114 "lwin_wkt_lex.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1134,13 +1138,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 172 ) + if ( yy_current_state >= 173 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_current_state != 171 ); + while ( yy_current_state != 172 ); yy_cp = (yy_last_accepting_cpos); yy_current_state = (yy_last_accepting_state); @@ -1161,17 +1165,19 @@ do_action: /* This label is used only to access EOF actions. */ goto yy_find_action; case 1: +/* rule 1 can match eol */ YY_RULE_SETUP #line 51 "lwin_wkt_lex.l" -{ +{ LWDEBUG(5,"DOUBLE"); - wkt_yylval.doublevalue = atof(wkt_yytext); + wkt_yylval.doublevalue = atof(wkt_yytext); + yyless(wkt_yyleng-1); return DOUBLE_TOK; } YY_BREAK case 2: YY_RULE_SETUP -#line 57 "lwin_wkt_lex.l" +#line 58 "lwin_wkt_lex.l" { LWDEBUG(5,"SRID"); wkt_yylval.integervalue = wkt_lexer_read_srid(wkt_yytext); @@ -1180,87 +1186,87 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 63 "lwin_wkt_lex.l" +#line 64 "lwin_wkt_lex.l" { return COLLECTION_TOK; } YY_BREAK case 4: YY_RULE_SETUP -#line 64 "lwin_wkt_lex.l" +#line 65 "lwin_wkt_lex.l" { return MSURFACE_TOK; } YY_BREAK case 5: YY_RULE_SETUP -#line 65 "lwin_wkt_lex.l" +#line 66 "lwin_wkt_lex.l" { return MPOLYGON_TOK; } YY_BREAK case 6: YY_RULE_SETUP -#line 66 "lwin_wkt_lex.l" +#line 67 "lwin_wkt_lex.l" { return MCURVE_TOK; } YY_BREAK case 7: YY_RULE_SETUP -#line 67 "lwin_wkt_lex.l" +#line 68 "lwin_wkt_lex.l" { return MLINESTRING_TOK; } YY_BREAK case 8: YY_RULE_SETUP -#line 68 "lwin_wkt_lex.l" +#line 69 "lwin_wkt_lex.l" { return MPOINT_TOK; } YY_BREAK case 9: YY_RULE_SETUP -#line 69 "lwin_wkt_lex.l" +#line 70 "lwin_wkt_lex.l" { return CURVEPOLYGON_TOK; } YY_BREAK case 10: YY_RULE_SETUP -#line 70 "lwin_wkt_lex.l" +#line 71 "lwin_wkt_lex.l" { return POLYGON_TOK; } YY_BREAK case 11: YY_RULE_SETUP -#line 71 "lwin_wkt_lex.l" +#line 72 "lwin_wkt_lex.l" { return COMPOUNDCURVE_TOK; } YY_BREAK case 12: YY_RULE_SETUP -#line 72 "lwin_wkt_lex.l" +#line 73 "lwin_wkt_lex.l" { return CIRCULARSTRING_TOK; } YY_BREAK case 13: YY_RULE_SETUP -#line 73 "lwin_wkt_lex.l" +#line 74 "lwin_wkt_lex.l" { return LINESTRING_TOK; } YY_BREAK case 14: YY_RULE_SETUP -#line 74 "lwin_wkt_lex.l" +#line 75 "lwin_wkt_lex.l" { return POLYHEDRALSURFACE_TOK; } YY_BREAK case 15: YY_RULE_SETUP -#line 75 "lwin_wkt_lex.l" +#line 76 "lwin_wkt_lex.l" { return TRIANGLE_TOK; } YY_BREAK case 16: YY_RULE_SETUP -#line 76 "lwin_wkt_lex.l" +#line 77 "lwin_wkt_lex.l" { return TIN_TOK; } YY_BREAK case 17: YY_RULE_SETUP -#line 77 "lwin_wkt_lex.l" +#line 78 "lwin_wkt_lex.l" { return POINT_TOK; } YY_BREAK case 18: YY_RULE_SETUP -#line 78 "lwin_wkt_lex.l" +#line 79 "lwin_wkt_lex.l" { return EMPTY_TOK; } YY_BREAK case 19: YY_RULE_SETUP -#line 80 "lwin_wkt_lex.l" +#line 81 "lwin_wkt_lex.l" { LWDEBUG(5,"DIMENSIONALITY"); wkt_yylval.stringvalue = wkt_yytext; @@ -1269,33 +1275,33 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 86 "lwin_wkt_lex.l" +#line 87 "lwin_wkt_lex.l" { LWDEBUG(5,"LBRACKET"); return LBRACKET_TOK; } YY_BREAK case 21: YY_RULE_SETUP -#line 87 "lwin_wkt_lex.l" +#line 88 "lwin_wkt_lex.l" { LWDEBUG(5,"RBRACKET"); return RBRACKET_TOK; } YY_BREAK case 22: YY_RULE_SETUP -#line 88 "lwin_wkt_lex.l" +#line 89 "lwin_wkt_lex.l" { LWDEBUG(5,"COMMA"); return COMMA_TOK; } YY_BREAK case 23: YY_RULE_SETUP -#line 89 "lwin_wkt_lex.l" +#line 90 "lwin_wkt_lex.l" { LWDEBUG(5,"SEMICOLON"); return SEMICOLON_TOK; } YY_BREAK case 24: /* rule 24 can match eol */ YY_RULE_SETUP -#line 91 "lwin_wkt_lex.l" +#line 92 "lwin_wkt_lex.l" { /* ignore whitespace */ LWDEBUG(5,"WHITESPACE"); } YY_BREAK case 25: YY_RULE_SETUP -#line 93 "lwin_wkt_lex.l" +#line 94 "lwin_wkt_lex.l" { /* Error out and stop parsing on unknown/unexpected characters */ LWDEBUG(5,"UNKNOWN"); wkt_lexer_unknown(); @@ -1304,10 +1310,10 @@ YY_RULE_SETUP YY_BREAK case 26: YY_RULE_SETUP -#line 99 "lwin_wkt_lex.l" +#line 100 "lwin_wkt_lex.l" ECHO; YY_BREAK -#line 1310 "lwin_wkt_lex.c" +#line 1316 "lwin_wkt_lex.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1605,7 +1611,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 172 ) + if ( yy_current_state >= 173 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1633,11 +1639,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 172 ) + if ( yy_current_state >= 173 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 171); + yy_is_jam = (yy_current_state == 172); return yy_is_jam ? 0 : yy_current_state; } @@ -2253,7 +2259,7 @@ static int yy_flex_strlen (const char * s ) #define YYTABLES_NAME "yytables" -#line 99 "lwin_wkt_lex.l" +#line 100 "lwin_wkt_lex.l" void *wkt_yyalloc (yy_size_t size ) diff --git a/liblwgeom/lwin_wkt_lex.l b/liblwgeom/lwin_wkt_lex.l index 27e90d493..234b64bbc 100644 --- a/liblwgeom/lwin_wkt_lex.l +++ b/liblwgeom/lwin_wkt_lex.l @@ -48,9 +48,10 @@ static void wkt_lexer_unknown() %% --?(([0-9]+\.?)|([0-9]*\.?[0-9]+)([eE][-+]?[0-9]+)?) { +-?(([0-9]+\.?)|([0-9]*\.?[0-9]+)([eE][-+]?[0-9]+)?)[ \,\)\t\n\r] { LWDEBUG(5,"DOUBLE"); - wkt_yylval.doublevalue = atof(wkt_yytext); + wkt_yylval.doublevalue = atof(wkt_yytext); + yyless(wkt_yyleng-1); return DOUBLE_TOK; }