From 980cf57ff4d21e4734c847f0772c1f98fcbff86f Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Thu, 27 Jul 2023 09:24:10 -0700 Subject: [PATCH] XPath: Account for non-English locales during number->string conversion We use a special number formatting routine to generate the XPath REC-compliant number representation; it relies on being able to get a decimal representation of the source number, which we use sprintf for as a fallback. This is fairly insensitive to current locale, except for an assertion that validates the decimal point as a precaution, and this check triggers when the locale decimal point is not a dot. Ideally we'd use a locale-insensitive routine here. On some systems we have ecvt_r (similarly to MSVC's ecvt_s), but it's deprecated so adopting it might be fraught with peril. For now let's simply adjust the assertion to account for locales with comma as a separator. This is probably not fully comprehensive but probably gets us from a 90% solution to a 99% solution... Fixes #574. --- src/pugixml.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pugixml.cpp b/src/pugixml.cpp index ebc8e79..e02a137 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -8458,7 +8458,7 @@ PUGI_IMPL_NS_BEGIN // extract mantissa string: skip sign char* mantissa = buffer[0] == '-' ? buffer + 1 : buffer; - assert(mantissa[0] != '0' && mantissa[1] == '.'); + assert(mantissa[0] != '0' && (mantissa[1] == '.' || mantissa[1] == ',')); // divide mantissa by 10 to eliminate integer part mantissa[1] = mantissa[0];