From 8d87edcd51653b47ca955cc3a9ac744f41988d92 Mon Sep 17 00:00:00 2001 From: Mike Taves Date: Mon, 15 Jan 2024 09:26:11 +1300 Subject: [PATCH] Fix StringTokenizer::peekNextToken (#1025) --- NEWS.md | 1 + src/io/StringTokenizer.cpp | 6 ++---- tests/unit/io/WKTReaderTest.cpp | 10 ++++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index f87417ae74..4168532c92 100644 --- a/NEWS.md +++ b/NEWS.md @@ -24,6 +24,7 @@ - Fix DiscreteHausdorffDistance for LinearRing (GH-1000, Martin Davis) - Fix IsSimpleOp for MultiPoint with empty element (GH-1005, Martin Davis) - Fix PreparedPolygonContains for GC with MultiPoint (GH-1008, Martin Davis) + - Fix reading WKT with EMPTY token with white space (GH-1025, Mike Taves) ## Changes in 3.12.0 2023-06-27 diff --git a/src/io/StringTokenizer.cpp b/src/io/StringTokenizer.cpp index 5735913ccd..e016299eb4 100644 --- a/src/io/StringTokenizer.cpp +++ b/src/io/StringTokenizer.cpp @@ -154,10 +154,8 @@ StringTokenizer::peekNextToken() return str[pos]; } - // It's either a Number or a Word, let's - // see when it ends - - pos = str.find_first_of("\n\r\t() ,", static_cast(iter - str.begin())); + // It's either a Number or a Word, let's see when it ends + pos = str.find_first_of("\n\r\t() ,", pos + 1); if(pos == string::npos) { if(iter != str.end()) { diff --git a/tests/unit/io/WKTReaderTest.cpp b/tests/unit/io/WKTReaderTest.cpp index b247ba844e..59e5f1b252 100644 --- a/tests/unit/io/WKTReaderTest.cpp +++ b/tests/unit/io/WKTReaderTest.cpp @@ -462,5 +462,15 @@ void object::test<23> ensure(std::isnan(coords->getY(0))); } +// EMPTY token with some white space +template<> +template<> +void object::test<24> +() +{ + GeomPtr geom(wktreader.read("MULTIPOINT( EMPTY, (10 10), (20 20))")); + + ensure_equals(geom->getNumGeometries(), 3u); +} } // namespace tut