Skip to content

Commit a7dbf60

Browse files
Merge pull request #812 from g-maxime/double
Always Use C style double conversion
2 parents 443ec2f + 863fbcd commit a7dbf60

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Source/Checker/Checker.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,19 @@ bool PolicyChecker::RuleElement::compare(const std::string& v1, const std::stri
307307
{
308308
bool to_return = false;
309309

310-
char* val_end=NULL;
311-
double val = strtod(v2.c_str(), &val_end);
312-
char* ref_end=NULL;
313-
double ref = strtod(v1.c_str(), &ref_end);
310+
char* val_end = NULL;
311+
char* ref_end = NULL;
312+
#ifdef _WIN32
313+
_locale_t c_locale = _create_locale(LC_NUMERIC, "C");
314+
double val = _strtod_l(v2.c_str(), &val_end, c_locale);
315+
double ref = _strtod_l(v1.c_str(), &ref_end, c_locale);
316+
_free_locale(c_locale);
317+
#else
318+
locale_t c_locale = newlocale(LC_NUMERIC_MASK, "C", NULL);
319+
double val = strtod_l(v2.c_str(), &val_end, c_locale);
320+
double ref = strtod_l(v1.c_str(), &ref_end, c_locale);
321+
freelocale(c_locale);
322+
#endif // _WIN32
314323

315324
if (operand=="starts with")
316325
{

0 commit comments

Comments
 (0)