summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-07-16 23:46:10 +0200
committerThiago Macieira <thiago.macieira@nokia.com>2009-07-20 12:11:51 +0200
commit3d6381b47a6048d04dbfc7b6984cae81c02d4fe6 (patch)
treef01d558911f1d4269c00db0cd78abc752e46805d
parent0f494029a61a2f9f31917be6e6e954b6bb606085 (diff)
downloadqt4-tools-3d6381b47a6048d04dbfc7b6984cae81c02d4fe6.tar.gz
Fix QTextCodec case-insensitive comparison while in a Turkish locale.
In Turkish, lowercase('I') is 'ı', which means comparing "iso-8859-1" to "ISO-8859-1" will fail. Reviewed-by: Denis Dzyubenko
-rw-r--r--src/corelib/codecs/qtextcodec.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index df150bd67c..2187cbe5ef 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -99,6 +99,10 @@ Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
(QTextCodecFactoryInterface_iid, QLatin1String("/codecs")))
#endif
+static char qtolower(register char c)
+{ if (c >= 'A' && c <= 'Z') return c + 0x20; return c; }
+static bool qisalnum(register char c)
+{ return (c >= '0' && c <= '9') || ((c | 0x20) >= 'a' && (c | 0x20) <= 'z'); }
static bool nameMatch(const QByteArray &name, const QByteArray &test)
{
@@ -111,21 +115,21 @@ static bool nameMatch(const QByteArray &name, const QByteArray &test)
// if the letters and numbers are the same, we have a match
while (*n != '\0') {
- if (isalnum((uchar)*n)) {
+ if (qisalnum(*n)) {
for (;;) {
if (*h == '\0')
return false;
- if (isalnum((uchar)*h))
+ if (qisalnum(*h))
break;
++h;
}
- if (tolower((uchar)*n) != tolower((uchar)*h))
+ if (qtolower(*n) != qtolower(*h))
return false;
++h;
}
++n;
}
- while (*h && !isalnum((uchar)*h))
+ while (*h && !qisalnum(*h))
++h;
return (*h == '\0');
}