diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2011-03-22 13:24:12 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2011-03-22 13:25:08 (GMT) |
commit | 82a1b2570fee1174e3198b06c992c9593103a1db (patch) | |
tree | f3b7be0231dd8a43ab42862061bc85cd2c515dae | |
parent | 0122202baae21a19aab808eab39e15551953825c (diff) | |
download | Qt-82a1b2570fee1174e3198b06c992c9593103a1db.zip Qt-82a1b2570fee1174e3198b06c992c9593103a1db.tar.gz Qt-82a1b2570fee1174e3198b06c992c9593103a1db.tar.bz2 |
QLocale: Compile fix for windows
Reviewed-by: trustme
-rw-r--r-- | src/corelib/tools/qlocale_win.cpp | 87 |
1 files changed, 43 insertions, 44 deletions
diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index bd55abf..b1b1962 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -117,7 +117,7 @@ private: // cached values: LCID lcid; SubstitutionType substitutionType; - QChar zeroDigit; + QChar zero; QString getLocaleInfo(LCTYPE type, int maxlen = 0); int getLocaleInfo_int(LCTYPE type, int maxlen = 0); @@ -179,7 +179,7 @@ QSystemLocalePrivate::SubstitutionType QSystemLocalePrivate::substitution() if (buf[0] == '1') substitutionType = QSystemLocalePrivate::SNever; else if (buf[0] == '0') - substitutionType QSystemLocalePrivate::SContext; + substitutionType = QSystemLocalePrivate::SContext; else if (buf[0] == '2') substitutionType = QSystemLocalePrivate::SAlways; else { @@ -200,7 +200,7 @@ QSystemLocalePrivate::SubstitutionType QSystemLocalePrivate::substitution() QString &QSystemLocalePrivate::substituteDigits(QString &string) { - ushort zero = zeroDigit(); + ushort zero = zeroDigit().unicode(); ushort *qch = (ushort *)string.data(); for (ushort *end = qch + string.size(); qch != end; ++qch) { if (*qch >= '0' && *qch <= '9') @@ -211,9 +211,9 @@ QString &QSystemLocalePrivate::substituteDigits(QString &string) QChar QSystemLocalePrivate::zeroDigit() { - if (zeroDigit.isNull()) - zeroDigit = getLocaleInfo_qchar(LOCALE_SNATIVEDIGITS); - return zeroDigit; + if (zero.isNull()) + zero = getLocaleInfo_qchar(LOCALE_SNATIVEDIGITS); + return zero; } QChar QSystemLocalePrivate::decimalPoint() @@ -565,44 +565,7 @@ void QSystemLocalePrivate::update() { lcid = GetUserDefaultLCID(); substitutionType = SUnknown; - zeroDigit = QChar(); -} - - -static QByteArray getWinLocaleName(LCID id) -{ - QByteArray result; - if (id == LOCALE_USER_DEFAULT) { - static QByteArray langEnvVar = qgetenv("LANG"); - result = langEnvVar; - QString lang, script, cntry; - if ( result == "C" || (!result.isEmpty() - && splitLocaleName(QString::fromLocal8Bit(result), lang, script, cntry)) ) { - long id = 0; - bool ok = false; - id = qstrtoll(result.data(), 0, 0, &ok); - if ( !ok || id == 0 || id < INT_MIN || id > INT_MAX ) - return result; - else - return winLangCodeToIsoName( (int)id ); - } - } - -#if defined(Q_OS_WINCE) - result = winLangCodeToIsoName(id != LOCALE_USER_DEFAULT ? id : GetUserDefaultLCID()); -#else - if (id == LOCALE_USER_DEFAULT) - id = GetUserDefaultLCID(); - QString resultuage = winIso639LangName(id); - QString country = winIso3116CtryName(id); - result = resultuage.toLatin1(); - if (!country.isEmpty()) { - result += '_'; - result += country.toLatin1(); - } -#endif - - return result; + zero = QChar(); } QString QSystemLocalePrivate::winToQtFormat(const QString &sys_fmt) @@ -956,6 +919,42 @@ static QString winIso3116CtryName(LCID id) return result; } +static QByteArray getWinLocaleName(LCID id) +{ + QByteArray result; + if (id == LOCALE_USER_DEFAULT) { + static QByteArray langEnvVar = qgetenv("LANG"); + result = langEnvVar; + QString lang, script, cntry; + if ( result == "C" || (!result.isEmpty() + && splitLocaleName(QString::fromLocal8Bit(result), lang, script, cntry)) ) { + long id = 0; + bool ok = false; + id = qstrtoll(result.data(), 0, 0, &ok); + if ( !ok || id == 0 || id < INT_MIN || id > INT_MAX ) + return result; + else + return winLangCodeToIsoName( (int)id ); + } + } + +#if defined(Q_OS_WINCE) + result = winLangCodeToIsoName(id != LOCALE_USER_DEFAULT ? id : GetUserDefaultLCID()); +#else + if (id == LOCALE_USER_DEFAULT) + id = GetUserDefaultLCID(); + QString resultuage = winIso639LangName(id); + QString country = winIso3116CtryName(id); + result = resultuage.toLatin1(); + if (!country.isEmpty()) { + result += '_'; + result += country.toLatin1(); + } +#endif + + return result; +} + Q_CORE_EXPORT QLocale qt_localeFromLCID(LCID id) { return QLocale(QString::fromLatin1(getWinLocaleName(id))); |