From 867a2fc1feefe93b3802b21649bc04982987dada Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Fri, 4 Feb 2005 10:14:03 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=5315 --- checkin_notes | 10 ++++++++++ lib/boinc_win.h | 3 ++- lib/parse.C | 7 +++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/checkin_notes b/checkin_notes index b531d85c14..8aa3712be4 100755 --- a/checkin_notes +++ b/checkin_notes @@ -23981,3 +23981,13 @@ Janus 4 Feb 2005 html/inc/ sanitize_html.php +Rom 4 Feb 2005 + - Bug Fix: Surround the calls to atol and atof in parse_int and parse_double + with setlocale calls so that we can parse numerical types from the core + client even while the manager is configured for a different locale. + + lib/ + boinc_win.h + parse.C + + \ No newline at end of file diff --git a/lib/boinc_win.h b/lib/boinc_win.h index fcef932784..edbd3e3983 100644 --- a/lib/boinc_win.h +++ b/lib/boinc_win.h @@ -89,6 +89,7 @@ #include #include #include +#include #else #include #include @@ -100,6 +101,7 @@ #include #include #include +#include #endif // C++ headers @@ -113,7 +115,6 @@ #include #include #include -#include #endif diff --git a/lib/parse.C b/lib/parse.C index 68b06c6445..89289b2ecf 100644 --- a/lib/parse.C +++ b/lib/parse.C @@ -31,6 +31,7 @@ #ifndef _WIN32 #include #include +#include #include #endif @@ -62,7 +63,10 @@ bool match_tag(const std::string &s, const char* tag) { bool parse_int(const char* buf, const char* tag, int& x) { char* p = strstr(buf, tag); if (!p) return false; + std::string strLocale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); x = strtol(p+strlen(tag), 0, 0); // this parses 0xabcd correctly + setlocale(LC_NUMERIC, strLocale.c_str()); return true; } @@ -71,7 +75,10 @@ bool parse_int(const char* buf, const char* tag, int& x) { bool parse_double(const char* buf, const char* tag, double& x) { char* p = strstr(buf, tag); if (!p) return false; + std::string strLocale = setlocale(LC_NUMERIC, NULL); + setlocale(LC_NUMERIC, "C"); x = atof(p+strlen(tag)); + setlocale(LC_NUMERIC, strLocale.c_str()); return true; }