Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: patches/nan.patch

Issue 7004021: Fixed handling of different decimal separators on DigitList::set(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/icu46/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « README.chromium ('k') | source/i18n/digitlst.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 Index: source/i18n/digitlst.cpp
2 ===================================================================
3 --- source/i18n/digitlst.cpp (revision 88316)
4 +++ source/i18n/digitlst.cpp (working copy)
5 @@ -60,6 +60,18 @@
6
7 U_NAMESPACE_BEGIN
8
9 +static void
10 +loadDecimalChar() {
11 + if (gDecimal == 0) {
12 + char rep[MAX_DIGITS];
13 + // For machines that decide to change the decimal on you,
14 + // and try to be too smart with localization.
15 + // This normally should be just a '.'.
16 + sprintf(rep, "%+1.1f", 1.0);
17 + gDecimal = rep[2];
18 + }
19 +}
20 +
21 // -------------------------------------
22 // default constructor
23
24 @@ -398,15 +410,6 @@
25 }
26 DigitList *nonConstThis = const_cast<DigitList *>(this);
27
28 - if (gDecimal == 0) {
29 - char rep[MAX_DIGITS];
30 - // For machines that decide to change the decimal on you,
31 - // and try to be too smart with localization.
32 - // This normally should be just a '.'.
33 - sprintf(rep, "%+1.1f", 1.0);
34 - gDecimal = rep[2];
35 - }
36 -
37 if (isZero()) {
38 nonConstThis->fDouble = 0.0;
39 if (decNumberIsNegative(fDecNumber)) {
40 @@ -441,6 +444,7 @@
41 }
42 U_ASSERT(uprv_strlen(&s[0]) < MAX_DBL_DIGITS+18);
43
44 + loadDecimalChar();
45 if (gDecimal != '.') {
46 char *decimalPt = strchr(s, '.');
47 if (decimalPt != NULL) {
48 @@ -727,6 +731,17 @@
49 sprintf(rep, "%+1.*e", MAX_DBL_DIGITS - 1, source);
50 U_ASSERT(uprv_strlen(rep) < sizeof(rep));
51
52 + // uprv_decNumberFromString() will parse the string expecting '.' as a
53 + // decimal separator, however sprintf() can use ',' in certain locales.
54 + // Overwrite a different decimal separator with '.' here before proceeding.
55 + loadDecimalChar();
56 + if (gDecimal != '.') {
57 + char *decimalPt = strchr(rep, gDecimal);
58 + if (decimalPt != NULL) {
59 + *decimalPt = '.';
60 + }
61 + }
62 +
63 // Create a decNumber from the string.
64 uprv_decNumberFromString(fDecNumber, rep, &fContext);
65 uprv_decNumberTrim(fDecNumber);
OLDNEW
« no previous file with comments | « README.chromium ('k') | source/i18n/digitlst.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698