diff options
author | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-12 12:13:54 (GMT) |
---|---|---|
committer | Bjørn Erik Nilsen <bjorn.nilsen@nokia.com> | 2009-06-12 12:13:54 (GMT) |
commit | d758080a6c345abec5e06a36ed26a2757a53c65f (patch) | |
tree | 8cb37f0d10ce187bb2e30b91adbb117c3671b672 /src/corelib | |
parent | 79f58df5b28dca88a4359ea9a76325e1a4a7f4e5 (diff) | |
parent | f2b93868f48a3e2d6e462ca8a051ab47eefef49d (diff) | |
download | Qt-d758080a6c345abec5e06a36ed26a2757a53c65f.zip Qt-d758080a6c345abec5e06a36ed26a2757a53c65f.tar.gz Qt-d758080a6c345abec5e06a36ed26a2757a53c65f.tar.bz2 |
Merge commit 'qt/master' into kinetic-declarativeui
Conflicts:
doc/src/qnamespace.qdoc
src/gui/painting/qdrawutil.cpp
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/codecs/qtextcodec.cpp | 57 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.h | 2 |
2 files changed, 27 insertions, 32 deletions
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp index e6fdc08..2aec40f 100644 --- a/src/corelib/codecs/qtextcodec.cpp +++ b/src/corelib/codecs/qtextcodec.cpp @@ -448,10 +448,10 @@ static const char * const tis_620locales[] = { // static const char * const tcvnlocales[] = { // "vi", "vi_VN", 0 }; -static bool try_locale_list(const char * const locale[], const char * lang) +static bool try_locale_list(const char * const locale[], const QByteArray &lang) { int i; - for(i=0; locale[i] && *locale[i] && strcmp(locale[i], lang); i++) + for(i=0; locale[i] && lang != locale[i]; i++) ; return locale[i] != 0; } @@ -503,13 +503,12 @@ static QTextCodec * ru_RU_hack(const char * i) { #endif #if !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE) -static QTextCodec *checkForCodec(const char *name) { +static QTextCodec *checkForCodec(const QByteArray &name) { QTextCodec *c = QTextCodec::codecForName(name); if (!c) { - const char *at = strchr(name, '@'); - if (at) { - QByteArray n(name, at - name); - c = QTextCodec::codecForName(n.data()); + const int index = name.indexOf('@'); + if (index != -1) { + c = QTextCodec::codecForName(name.left(index)); } } return c; @@ -550,21 +549,19 @@ static void setupLocaleMapper() // definitely knows it, but since we cannot fully trust it, get ready // to fall back to environment variables. #if !defined(QT_NO_SETLOCALE) - char * ctype = qstrdup(setlocale(LC_CTYPE, 0)); + const QByteArray ctype = setlocale(LC_CTYPE, 0); #else - char * ctype = qstrdup(""); + const QByteArray ctype; #endif // Get the first nonempty value from $LC_ALL, $LC_CTYPE, and $LANG // environment variables. - char * lang = qstrdup(qgetenv("LC_ALL").constData()); - if (!lang || lang[0] == 0 || strcmp(lang, "C") == 0) { - if (lang) delete [] lang; - lang = qstrdup(qgetenv("LC_CTYPE").constData()); + QByteArray lang = qgetenv("LC_ALL"); + if (lang.isEmpty() || lang == "C") { + lang = qgetenv("LC_CTYPE"); } - if (!lang || lang[0] == 0 || strcmp(lang, "C") == 0) { - if (lang) delete [] lang; - lang = qstrdup(qgetenv("LANG").constData()); + if (lang.isEmpty() || lang == "C") { + lang = qgetenv("LANG"); } // Now try these in order: @@ -577,35 +574,35 @@ static void setupLocaleMapper() // 7. guess locale from lang // 1. CODESET from ctype if it contains a .CODESET part (e.g. en_US.ISO8859-15) - char * codeset = ctype ? strchr(ctype, '.') : 0; - if (codeset && *codeset == '.') - localeMapper = checkForCodec(codeset + 1); + int indexOfDot = ctype.indexOf('.'); + if (indexOfDot != -1) + localeMapper = checkForCodec( ctype.mid(indexOfDot + 1) ); // 2. CODESET from lang if it contains a .CODESET part - codeset = lang ? strchr(lang, '.') : 0; - if (!localeMapper && codeset && *codeset == '.') - localeMapper = checkForCodec(codeset + 1); + if (!localeMapper) { + indexOfDot = lang.indexOf('.'); + if (indexOfDot != -1) + localeMapper = checkForCodec( lang.mid(indexOfDot + 1) ); + } // 3. ctype (maybe the locale is named "ISO-8859-1" or something) - if (!localeMapper && ctype && *ctype != 0 && strcmp (ctype, "C") != 0) + if (!localeMapper && !ctype.isEmpty() && ctype != "C") localeMapper = checkForCodec(ctype); // 4. locale (ditto) - if (!localeMapper && lang && *lang != 0) + if (!localeMapper && !lang.isEmpty()) localeMapper = checkForCodec(lang); // 5. "@euro" - if ((!localeMapper && ctype && strstr(ctype, "@euro")) || (lang && strstr(lang, "@euro"))) + if ((!localeMapper && ctype.contains("@euro")) || lang.contains("@euro")) localeMapper = checkForCodec("ISO 8859-15"); // 6. guess locale from ctype unless ctype is "C" // 7. guess locale from lang - char * try_by_name = ctype; - if (ctype && *ctype != 0 && strcmp (ctype, "C") != 0) - try_by_name = lang; + const QByteArray &try_by_name = (!ctype.isEmpty() && ctype != "C") ? lang : ctype; // Now do the guessing. - if (lang && *lang && !localeMapper && try_by_name && *try_by_name) { + if (!lang.isEmpty() && !localeMapper && !try_by_name.isEmpty()) { if (try_locale_list(iso8859_15locales, lang)) localeMapper = QTextCodec::codecForName("ISO 8859-15"); else if (try_locale_list(iso8859_2locales, lang)) @@ -638,8 +635,6 @@ static void setupLocaleMapper() localeMapper = ru_RU_hack(lang); } - delete [] ctype; - delete [] lang; } // If everything failed, we default to 8859-1 diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 22214a4..687a070 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -89,7 +89,7 @@ public: // This logic must match the one in qglobal.h #if defined(QT_COORD_TYPE) QReal = 0, -#elif defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) +#elif defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN) QReal = Float, #else QReal = Double, |