From 3225be6d9e7411aabaaec1b76bfc287444d86442 Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 11 Feb 2021 21:44:33 -0800 Subject: [PATCH] Fix is_number() accepting "-" as a number The function would accept the string "-" as a number, when it isn't one. To fix this, don't put it as part of the loop, just add another special case. --- desktop_version/src/UtilityClass.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/desktop_version/src/UtilityClass.cpp b/desktop_version/src/UtilityClass.cpp index 6915f9a3..56117e7c 100644 --- a/desktop_version/src/UtilityClass.cpp +++ b/desktop_version/src/UtilityClass.cpp @@ -272,6 +272,11 @@ bool is_number(const char* str) return false; } + if (str[0] == '-' && str[1] == '\0') + { + return false; + } + for (size_t i = 1; str[i] != '\0'; ++i) { if (!SDL_isdigit(str[i]))