1 |
dilfridge 12/01/30 22:47:31 |
2 |
|
3 |
Added: kdelibs-4.7.4-klocale.patch |
4 |
Log: |
5 |
Backport upstream fix for KLocale |
6 |
|
7 |
(Portage version: 2.1.10.44/cvs/Linux x86_64) |
8 |
|
9 |
Revision Changes Path |
10 |
1.1 kde-base/kdelibs/files/kdelibs-4.7.4-klocale.patch |
11 |
|
12 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/kde-base/kdelibs/files/kdelibs-4.7.4-klocale.patch?rev=1.1&view=markup |
13 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/kde-base/kdelibs/files/kdelibs-4.7.4-klocale.patch?rev=1.1&content-type=text/plain |
14 |
|
15 |
Index: kdelibs-4.7.4-klocale.patch |
16 |
=================================================================== |
17 |
From 2993b24bc21a340695ad35b4f014a684f4d0c651 Mon Sep 17 00:00:00 2001 |
18 |
From: John Layt <jlayt@×××.org> |
19 |
Date: Sat, 17 Dec 2011 16:27:51 +0000 |
20 |
Subject: [PATCH] KLocale: Fix readNumber() and readMoney() for lenient group parsing |
21 |
|
22 |
Restore the old pre-4.7 behaviour of accepting as valid any numbers |
23 |
that do not contain any group separators but strictly enforce group |
24 |
rules when the number contains 1 or more group separators. |
25 |
|
26 |
Distro's will really want to backport this fix to all versions of 4.7 |
27 |
as previously number entry for all KDE apps would have been seriously |
28 |
broken. |
29 |
|
30 |
I'm amazed I wasn't beaten up for this earlier! |
31 |
|
32 |
BUG: 288963 |
33 |
FIXED-IN: 4.7.5 |
34 |
CCMAIL: kde-packager@×××.org |
35 |
--- |
36 |
kdecore/localization/klocale_kde.cpp | 10 ++++++++-- |
37 |
kdecore/tests/klocaletest.cpp | 34 +++++++++++++++++++++++++++++----- |
38 |
2 files changed, 37 insertions(+), 7 deletions(-) |
39 |
|
40 |
diff --git a/kdecore/localization/klocale_kde.cpp b/kdecore/localization/klocale_kde.cpp |
41 |
index 6cf85f9..6690f4a 100644 |
42 |
--- a/kdecore/localization/klocale_kde.cpp |
43 |
+++ b/kdecore/localization/klocale_kde.cpp |
44 |
@@ -1894,7 +1894,10 @@ double KLocalePrivate::readNumber(const QString &_str, bool * ok) const |
45 |
|
46 |
// Remove group separators |
47 |
bool groupOk = true; |
48 |
- str = parseDigitGroup(str, thousandsSeparator(), decimalSymbol(), numericDigitGrouping(), &groupOk); |
49 |
+ if(str.contains(thousandsSeparator())) { |
50 |
+ str = parseDigitGroup(str, thousandsSeparator(), decimalSymbol(), |
51 |
+ numericDigitGrouping(), &groupOk); |
52 |
+ } |
53 |
|
54 |
if (!groupOk) { |
55 |
if (ok) { |
56 |
@@ -2013,7 +2016,10 @@ double KLocalePrivate::readMoney(const QString &_str, bool *ok) const |
57 |
|
58 |
// Remove group separators |
59 |
bool groupOk = true; |
60 |
- str = parseDigitGroup(str, monetaryThousandsSeparator(), monetaryDecimalSymbol(), monetaryDigitGrouping(), &groupOk); |
61 |
+ if(str.contains(monetaryThousandsSeparator())) { |
62 |
+ str = parseDigitGroup(str, monetaryThousandsSeparator(), monetaryDecimalSymbol(), |
63 |
+ monetaryDigitGrouping(), &groupOk); |
64 |
+ } |
65 |
|
66 |
if (!groupOk) { |
67 |
if (ok) { |
68 |
diff --git a/kdecore/tests/klocaletest.cpp b/kdecore/tests/klocaletest.cpp |
69 |
index 97a3bce..f80de85 100644 |
70 |
--- a/kdecore/tests/klocaletest.cpp |
71 |
+++ b/kdecore/tests/klocaletest.cpp |
72 |
@@ -180,9 +180,13 @@ KLocaleTest::readNumber() |
73 |
QVERIFY(!ok); |
74 |
QCOMPARE(locale.readNumber(QString("123,456,789.01"), &ok), 0.0); |
75 |
QVERIFY(!ok); |
76 |
- QCOMPARE(locale.readNumber(QString("123456789"), &ok), 0.0); |
77 |
+ QCOMPARE(locale.readNumber(QString("123456789"), &ok), 123456789.0); |
78 |
+ QVERIFY(ok); |
79 |
+ QCOMPARE(locale.readNumber(QString("123456789.01"), &ok), 123456789.01); |
80 |
+ QVERIFY(ok); |
81 |
+ QCOMPARE(locale.readNumber(QString("123456,789"), &ok), 0.0); |
82 |
QVERIFY(!ok); |
83 |
- QCOMPARE(locale.readNumber(QString("123456789.01"), &ok), 0.0); |
84 |
+ QCOMPARE(locale.readNumber(QString("123456,789.01"), &ok), 0.0); |
85 |
QVERIFY(!ok); |
86 |
|
87 |
//Test it parses correctly with an empty separator. |
88 |
@@ -204,6 +208,14 @@ KLocaleTest::readNumber() |
89 |
QVERIFY(ok); |
90 |
QCOMPARE(locale.readNumber(QString("123 456 789.01"), &ok), 123456789.01); |
91 |
QVERIFY(ok); |
92 |
+ QCOMPARE(locale.readNumber(QString("123456789"), &ok), 123456789.0); |
93 |
+ QVERIFY(ok); |
94 |
+ QCOMPARE(locale.readNumber(QString("123456789.01"), &ok), 123456789.01); |
95 |
+ QVERIFY(ok); |
96 |
+ QCOMPARE(locale.readNumber(QString("123456 789"), &ok), 0.0); |
97 |
+ QVERIFY(!ok); |
98 |
+ QCOMPARE(locale.readNumber(QString("123456 789.01"), &ok), 0.0); |
99 |
+ QVERIFY(!ok); |
100 |
QCOMPARE(locale.readNumber(QString("123,456,789"), &ok), 0.0); |
101 |
QVERIFY(!ok); |
102 |
QCOMPARE(locale.readNumber(QString("123,456,789.01"), &ok), 0.0); |
103 |
@@ -479,6 +491,10 @@ void KLocaleTest::readMoney() |
104 |
QVERIFY(ok); |
105 |
QCOMPARE(locale.readMoney("$ 987,654,321.12", &ok), 987654321.12); |
106 |
QVERIFY(ok); |
107 |
+ QCOMPARE(locale.readMoney("$ 987654321.12", &ok), 987654321.12); |
108 |
+ QVERIFY(ok); |
109 |
+ QCOMPARE(locale.readMoney("$ 987654,321.12", &ok), 0.0); |
110 |
+ QVERIFY(!ok); |
111 |
|
112 |
QCOMPARE(locale.readMoney( "$ -1.12", &ok), -1.12); |
113 |
QVERIFY(ok); |
114 |
@@ -498,6 +514,10 @@ void KLocaleTest::readMoney() |
115 |
QVERIFY(ok); |
116 |
QCOMPARE(locale.readMoney("$ -987,654,321.12", &ok), -987654321.12); |
117 |
QVERIFY(ok); |
118 |
+ QCOMPARE(locale.readMoney("$ -987654321.12", &ok), -987654321.12); |
119 |
+ QVERIFY(ok); |
120 |
+ QCOMPARE(locale.readMoney("$ -987654,321.12", &ok), 0.0); |
121 |
+ QVERIFY(!ok); |
122 |
|
123 |
// Test incomplete formats |
124 |
QCOMPARE(locale.readMoney( "$ 1", &ok), 1.00); |
125 |
@@ -521,17 +541,21 @@ void KLocaleTest::readMoney() |
126 |
|
127 |
// Test Grouping |
128 |
locale.d->setMonetaryDigitGrouping(QList<int>()); |
129 |
- QCOMPARE(locale.readMoney( "$ 987654321.12", &ok), 987654321.12); |
130 |
+ QCOMPARE(locale.readMoney("$ 987654321.12", &ok), 987654321.12); |
131 |
QVERIFY(ok); |
132 |
QCOMPARE(locale.readMoney("$ -987654321.12", &ok), -987654321.12); |
133 |
QVERIFY(ok); |
134 |
locale.d->setMonetaryDigitGrouping(QList<int>() << 3 << 2); |
135 |
- QCOMPARE(locale.readMoney( "$ 98,76,54,321.12", &ok), 987654321.12); |
136 |
+ QCOMPARE(locale.readMoney("$ 98,76,54,321.12", &ok), 987654321.12); |
137 |
QVERIFY(ok); |
138 |
QCOMPARE(locale.readMoney("$ -98,76,54,321.12", &ok), -987654321.12); |
139 |
QVERIFY(ok); |
140 |
+ QCOMPARE(locale.readMoney("$ 987654321.12", &ok), 987654321.12); |
141 |
+ QVERIFY(ok); |
142 |
+ QCOMPARE(locale.readMoney("$ -987654321.12", &ok), -987654321.12); |
143 |
+ QVERIFY(ok); |
144 |
locale.d->setMonetaryDigitGrouping(QList<int>() << 3 << -1); |
145 |
- QCOMPARE(locale.readMoney( "$ 987654,321.12", &ok), 987654321.12); |
146 |
+ QCOMPARE(locale.readMoney("$ 987654,321.12", &ok), 987654321.12); |
147 |
QVERIFY(ok); |
148 |
QCOMPARE(locale.readMoney("$ -987654,321.12", &ok), -987654321.12); |
149 |
QVERIFY(ok); |
150 |
-- |
151 |
1.7.3.4 |