From e2d20a0c2dc9f90c584ce5b48f46a994c246f323 Mon Sep 17 00:00:00 2001 From: Brad Arant Date: Thu, 26 Sep 2024 12:32:04 -0700 Subject: [PATCH] Changed startsWithDouble to startsWithNumber. --- ZString.cpp | 9 ++------- ZString.h | 2 +- testing/zstring_test.cpp | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/ZString.cpp b/ZString.cpp index 6387e08..f66c77b 100644 --- a/ZString.cpp +++ b/ZString.cpp @@ -322,13 +322,8 @@ namespace coreutils { return strncmp(cursor, value, strlen(value)) == 0; } - bool ZString::startsWithDouble() { - push(); - char *tempc = cursor; - double temp = strtod(cursor, &cursor); - int diff = cursor - tempc; - pop(); - return diff != 0; + bool ZString::startsWithNumber() { + return ((*cursor >= '0') && (*cursor <= '9')); } int ZString::compare(ZString zstring) { diff --git a/ZString.h b/ZString.h index 0a1b899..e08e0a7 100644 --- a/ZString.h +++ b/ZString.h @@ -252,7 +252,7 @@ namespace coreutils { /// /// - bool startsWithDouble(); + bool startsWithNumber(); /// /// diff --git a/testing/zstring_test.cpp b/testing/zstring_test.cpp index fe8cf6b..7ebb697 100644 --- a/testing/zstring_test.cpp +++ b/testing/zstring_test.cpp @@ -100,7 +100,7 @@ int main(int argc, char **argv) { test18.reset(); std::cout << "[" << test18.find("x") << "] " << test18.parsed() << ":" << test18.unparsed() << std::endl; - coreutils::ZString test19("-16473.65476Z"); + coreutils::ZString test19("1,"); std::cout << test19.asDouble() << ":" << test19.unparsed() << std::endl; }