Added proper number suffixes in GLSL parser

Numbers like "1.0f" or "10u" are now allowed
in GLSL, so I added code to do proper parsing
of these numbers.

Change-Id: Ia4635ab2b449399bd4adea2c5c94567b5b8a5f8e
Reviewed-on: https://swiftshader-review.googlesource.com/3434
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/compiler/util.cpp b/src/OpenGL/compiler/util.cpp
index b46e4d0..e20068b 100644
--- a/src/OpenGL/compiler/util.cpp
+++ b/src/OpenGL/compiler/util.cpp
@@ -4,30 +4,23 @@
 // found in the LICENSE file.
 //
 
-#include <math.h>
-#include <stdlib.h>
+#include <limits>
 
 #include "util.h"
+#include "preprocessor/numeric_lex.h"
 
-#ifdef _MSC_VER
-    #include <locale.h>
-#else
-    #include <sstream>
-#endif
-
-double atof_dot(const char *str)
+bool atof_clamp(const char *str, float *value)
 {
-#ifdef _MSC_VER
-    _locale_t l = _create_locale(LC_NUMERIC, "C");
-    double result = _atof_l(str, l);
-    _free_locale(l);
-    return result;
-#else
-    double result;
-    std::istringstream s(str);
-    std::locale l("C");
-    s.imbue(l);
-    s >> result;
-    return result;
-#endif
+	bool success = pp::numeric_lex_float(str, value);
+	if(!success)
+		*value = std::numeric_limits<float>::max();
+	return success;
+}
+
+bool atoi_clamp(const char *str, int *value)
+{
+	bool success = pp::numeric_lex_int(str, value);
+	if(!success)
+		*value = std::numeric_limits<int>::max();
+	return success;
 }