*** empty log message ***

svn path=/trunk/boinc/; revision=5315
This commit is contained in:
Rom Walton 2005-02-04 10:14:03 +00:00
parent 55cb78adc4
commit 867a2fc1fe
3 changed files with 19 additions and 1 deletions

View File

@ -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

View File

@ -89,6 +89,7 @@
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <locale>
#else
#include <assert.h>
#include <ctype.h>
@ -100,6 +101,7 @@
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <locale.h>
#endif
// C++ headers
@ -113,7 +115,6 @@
#include <vector>
#include <deque>
#include <list>
#include <locale>
#endif

View File

@ -31,6 +31,7 @@
#ifndef _WIN32
#include <cstring>
#include <cstdlib>
#include <locale>
#include <string>
#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;
}