Use the same mechanism to process int/float literals

This also fixes the float overflow errno leaking bug.

BUG=
R=alokp@chromium.org

Review URL: https://codereview.appspot.com/13368050
diff --git a/src/compiler/util.cpp b/src/compiler/util.cpp
index ec375a4..d6e5eee 100644
--- a/src/compiler/util.cpp
+++ b/src/compiler/util.cpp
@@ -4,39 +4,15 @@
 // found in the LICENSE file.
 //
 
-#include <math.h>
-#include <stdlib.h>
+#include "compiler/util.h"
 
-#include <cerrno>
 #include <limits>
 
-#include "util.h"
-
-#ifdef _MSC_VER
-    #include <locale.h>
-#else
-    #include <sstream>
-#endif
+#include "compiler/preprocessor/numeric_lex.h"
 
 bool atof_clamp(const char *str, float *value)
 {
-    bool success = true;
-#ifdef _MSC_VER
-    _locale_t l = _create_locale(LC_NUMERIC, "C");
-    double dvalue = _atof_l(str, l);
-    _free_locale(l);
-    if (errno == ERANGE || dvalue > std::numeric_limits<float>::max())
-        success = false;
-    else
-        *value = static_cast<float>(dvalue);
-#else
-    std::istringstream s(str);
-    std::locale l("C");
-    s.imbue(l);
-    s >> *value;
-    if (s.fail())
-        success = false;
-#endif
+    bool success = pp::numeric_lex_float(str, value);
     if (!success)
         *value = std::numeric_limits<float>::max();
     return success;
@@ -44,13 +20,9 @@
 
 bool atoi_clamp(const char *str, int *value)
 {
-    long int lvalue = strtol(str, 0, 0);
-    if (errno == ERANGE || lvalue > std::numeric_limits<int>::max())
-    {
+    bool success = pp::numeric_lex_int(str, value);
+    if (!success)
         *value = std::numeric_limits<int>::max();
-        return  false;
-    }
-    *value = static_cast<int>(lvalue);
-    return true;
+    return success;
 }