You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-libs/icu/files/icu-4.8.1-fix_nan.patch

69 lines
2.2 KiB

https://bugs.gentoo.org/show_bug.cgi?id=380827
http://bugs.icu-project.org/trac/ticket/8561
http://bugs.icu-project.org/trac/changeset/30689
http://code.google.com/p/chromium/issues/detail?id=92847
--- source/i18n/digitlst.cpp.orig 2011-07-19 23:16:00.000000000 +0200
+++ source/i18n/digitlst.cpp 2011-10-12 23:47:08.000000000 +0200
@@ -60,6 +60,18 @@
U_NAMESPACE_BEGIN
+static void
+loadDecimalChar() {
+ if (gDecimal == 0) {
+ char rep[MAX_DIGITS];
+ // For machines that decide to change the decimal on you,
+ // and try to be too smart with localization.
+ // This normally should be just a '.'.
+ sprintf(rep, "%+1.1f", 1.0);
+ gDecimal = rep[2];
+ }
+}
+
// -------------------------------------
// default constructor
@@ -408,15 +420,6 @@
}
DigitList *nonConstThis = const_cast<DigitList *>(this);
- if (gDecimal == 0) {
- char rep[MAX_DIGITS];
- // For machines that decide to change the decimal on you,
- // and try to be too smart with localization.
- // This normally should be just a '.'.
- sprintf(rep, "%+1.1f", 1.0);
- gDecimal = rep[2];
- }
-
if (isZero()) {
nonConstThis->fDouble = 0.0;
if (decNumberIsNegative(fDecNumber)) {
@@ -451,6 +454,7 @@
}
U_ASSERT(uprv_strlen(&s[0]) < MAX_DBL_DIGITS+18);
+ loadDecimalChar();
if (gDecimal != '.') {
char *decimalPt = strchr(s, '.');
if (decimalPt != NULL) {
@@ -741,6 +745,17 @@
sprintf(rep, "%+1.*e", MAX_DBL_DIGITS - 1, source);
U_ASSERT(uprv_strlen(rep) < sizeof(rep));
+ // uprv_decNumberFromString() will parse the string expecting '.' as a
+ // decimal separator, however sprintf() can use ',' in certain locales.
+ // Overwrite a different decimal separator with '.' here before proceeding.
+ loadDecimalChar();
+ if (gDecimal != '.') {
+ char *decimalPt = strchr(rep, gDecimal);
+ if (decimalPt != NULL) {
+ *decimalPt = '.';
+ }
+ }
+
// Create a decNumber from the string.
uprv_decNumberFromString(fDecNumber, rep, &fContext);
uprv_decNumberTrim(fDecNumber);