Explorar el Código

Use our own white space functions in string utilities

Michael Ragazzon hace 6 años
padre
commit
111de6bcc7
Se han modificado 1 ficheros con 8 adiciones y 4 borrados
  1. 8 4
      Source/Core/StringUtilities.cpp

+ 8 - 4
Source/Core/StringUtilities.cpp

@@ -28,7 +28,6 @@
 
 
 #include "precompiled.h"
 #include "precompiled.h"
 #include "../../Include/RmlUi/Core/StringUtilities.h"
 #include "../../Include/RmlUi/Core/StringUtilities.h"
-#include <ctype.h>
 #include <stdio.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdarg.h>
 
 
@@ -84,7 +83,12 @@ String CreateString(size_t max_size, const char* format, ...)
 
 
 String StringUtilities::ToLower(const String& string) {
 String StringUtilities::ToLower(const String& string) {
 	String str_lower = string;
 	String str_lower = string;
-	std::transform(str_lower.begin(), str_lower.end(), str_lower.begin(), ::tolower);
+	std::transform(str_lower.begin(), str_lower.end(), str_lower.begin(), [](char c) {
+		if (c >= 'A' && c <= 'Z')
+			c += char( 'a' - 'A' );
+		return c;
+		}
+	);
 	return str_lower;
 	return str_lower;
 }
 }
 
 
@@ -151,7 +155,7 @@ void StringUtilities::ExpandString(StringList& string_list, const String& string
 			start_ptr = nullptr;
 			start_ptr = nullptr;
 		}
 		}
 		// Otherwise if its not white space or we're in quote mode, advance the pointers
 		// Otherwise if its not white space or we're in quote mode, advance the pointers
-		else if (!isspace(*ptr) || quote)
+		else if (!IsWhitespace(*ptr) || quote)
 		{
 		{
 			if (!start_ptr)
 			if (!start_ptr)
 				start_ptr = ptr;
 				start_ptr = ptr;
@@ -198,7 +202,7 @@ void StringUtilities::ExpandString(StringList& string_list, const String& string
 			start_ptr = nullptr;
 			start_ptr = nullptr;
 		}
 		}
 		// Otherwise if its not white space or we're in quote mode, advance the pointers
 		// Otherwise if its not white space or we're in quote mode, advance the pointers
-		else if (!isspace(*ptr) || quote_mode_depth > 0)
+		else if (!IsWhitespace(*ptr) || quote_mode_depth > 0)
 		{
 		{
 			if (!start_ptr)
 			if (!start_ptr)
 				start_ptr = ptr;
 				start_ptr = ptr;