Changeset 846 for trunk/src/corelib/tools/qlocale.cpp
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/src/corelib/tools/qlocale.cpp
r769 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 201 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 82 82 #include <time.h> 83 83 84 #if defined( Q_OS_LINUX) && !defined(__UCLIBC__)84 #if defined() && !defined(__UCLIBC__) 85 85 # include <fenv.h> 86 86 #endif … … 134 134 #endif 135 135 136 137 138 139 140 136 141 /****************************************************************************** 137 142 ** Helpers for accessing Qt locale database … … 175 180 176 181 // Assumes that code is a 177 // QChar code[ 2];182 // QChar code[]; 178 183 static QLocale::Country codeToCountry(const QChar *code) 179 184 { 180 185 ushort uc1 = code[0].unicode(); 181 186 ushort uc2 = code[1].unicode(); 187 182 188 183 189 const unsigned char *c = country_code_list; 184 for (; *c != 0; c += 2) {185 if (uc1 == c[0] && uc2 == c[1] )186 return QLocale::Country((c - country_code_list)/ 2);190 for (; *c != 0; c += ) { 191 if (uc1 == c[0] && uc2 == c[1]) 192 return QLocale::Country((c - country_code_list)/); 187 193 } 188 194 … … 212 218 return QString(); 213 219 214 QString code(2, Qt::Uninitialized); 215 const unsigned char *c = country_code_list + 2*(uint(country)); 220 const unsigned char *c = country_code_list + 3*(uint(country)); 221 222 QString code(c[2] == 0 ? 2 : 3, Qt::Uninitialized); 223 216 224 code[0] = ushort(c[0]); 217 225 code[1] = ushort(c[1]); 226 227 228 218 229 return code; 219 230 } … … 251 262 for (int i = 0; i < 3; ++i) 252 263 lang_begin[i] = 0; 253 for (int i = 0; i < 2; ++i)264 for (int i = 0; i < ; ++i) 254 265 cntry_begin[i] = 0; 255 266 … … 282 293 case 1: 283 294 // parsing country 284 if (cntry - cntry_begin == 2) {295 if (cntry - cntry_begin == ) { 285 296 cntry_begin[0] = 0; 286 297 break; … … 306 317 307 318 QChar lang_code[3]; 308 QChar cntry_code[ 2];319 QChar cntry_code[]; 309 320 if (!splitLocaleName(name, lang_code, cntry_code)) 310 321 return; … … 450 461 result = envVarLocale(); 451 462 QChar lang[3]; 452 QChar cntry[ 2];463 QChar cntry[]; 453 464 if ( result == "C" || (!result.isEmpty() 454 465 && splitLocaleName(QString::fromLocal8Bit(result), lang, cntry)) ) { … … 496 507 result += QLatin1String("''"); 497 508 else 498 result += Q Latin1Char('\'') + text + QLatin1Char('\'');509 result += Q); 499 510 continue; 500 511 } … … 712 723 case DateTimeFormatLong: 713 724 case DateTimeFormatShort: 714 return query(type == DateTimeFormatLong ? DateFormatLong : DateFormatShort).toString()715 + QLatin1Char(' ') + query(type == DateTimeFormatLong ? TimeFormatLong : TimeFormatShort).toString() ;725 return query(type == DateTimeFormatLong ? DateFormatLong : DateFormatShort).toString() 726 + QLatin1Char(' ') + query(type == DateTimeFormatLong ? TimeFormatLong : TimeFormatShort).toString(); 716 727 case DayNameLong: 717 728 case DayNameShort: … … 729 740 case DateTimeToStringLong: { 730 741 const QDateTime dt = in.toDateTime(); 731 return winDateToString(dt.date(), type == DateTimeToStringShort ? DATE_SHORTDATE : DATE_LONGDATE)732 + QLatin1Char(' ') + winTimeToString(dt.time()) ; }742 return winDateToString(dt.date(), type == DateTimeToStringShort ? DATE_SHORTDATE : DATE_LONGDATE) 743 + QLatin1Char(' ') + winTimeToString(dt.time()); } 733 744 734 745 case ZeroDigit: … … 1196 1207 1197 1208 QChar lang[3]; 1198 QChar cntry[ 2];1209 QChar cntry[]; 1199 1210 if (result.isEmpty() || result != "C" 1200 1211 && !splitLocaleName(QString::fromLocal8Bit(result), lang, cntry)) { … … 1466 1477 case CountryId: { 1467 1478 QString preferredLanguage; 1468 QString preferredCountry ;1479 QString preferredCountry 1469 1480 getMacPreferredLanguageAndCountry(&preferredLanguage, &preferredCountry); 1470 1481 QLocale::Language languageCode = (preferredLanguage.isEmpty() ? QLocale::C : codeToLanguage(preferredLanguage.data())); … … 1658 1669 if (_systemLocale) 1659 1670 return _systemLocale; 1671 1672 1673 1660 1674 return QSystemLocale_globalSystemLocale(); 1661 1675 } … … 1667 1681 system_lp = globalLocalePrivate(); 1668 1682 *system_lp = *sys_locale->fallbackLocale().d(); 1683 1684 1685 1686 1669 1687 1670 1688 QVariant res = sys_locale->query(QSystemLocale::LanguageId, QVariant()); … … 1808 1826 \endlist 1809 1827 1810 The "C" locale is identical in behavior to \l{English}/\l{UnitedStates}.1811 1812 1828 Use language() and country() to determine the actual language and 1813 1829 country values used. … … 1821 1837 pair; it does not use the system locale database. 1822 1838 1823 QLocale's data is based on Common Locale Data Repository v1. 6.1.1839 QLocale's data is based on Common Locale Data Repository v1..1. 1824 1840 1825 1841 The double-to-string and string-to-double conversion functions are … … 2022 2038 \value Tyap 2023 2039 \value Chewa 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2024 2089 \omitvalue LastLanguage 2025 2090 … … 2274 2339 \value Zambia 2275 2340 \value Zimbabwe 2341 2342 2343 2344 2345 2346 2276 2347 \omitvalue LastCountry 2277 2348 … … 3168 3239 QDateTime QLocale::toDateTime(const QString &string, FormatType format) const 3169 3240 { 3170 return toDateTime(string, date Format(format));3241 return toDateTime(string, dateFormat(format)); 3171 3242 } 3172 3243 #endif … … 3398 3469 formats specified in the system configuration panel. 3399 3470 3400 \sa QTextCodec::locale()c()3471 \sa c() 3401 3472 */ 3402 3473 … … 3654 3725 return meas; 3655 3726 } 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3656 3746 3657 3747 /*! … … 4544 4634 const bool scientific = numMode == DoubleScientificMode; 4545 4635 bool lastWasE = false; 4636 4546 4637 int eCnt = 0; 4547 4638 int decPointCnt = 0; … … 4558 4649 return false; 4559 4650 } 4651 4560 4652 } else { 4561 4653 switch (c) { … … 4595 4687 4596 4688 case ',': 4597 return false; 4689 //it can only be placed after a digit which is before the decimal point 4690 if (!lastWasDigit || decPointCnt > 0) 4691 return false; 4692 break; 4598 4693 4599 4694 case 'e': … … 4613 4708 return false; 4614 4709 } 4710 4615 4711 } 4616 4712 4617 4713 lastWasE = c == 'e'; 4618 buff->append(c); 4714 if (c != ',') 4715 buff->append(c); 4619 4716 } 4620 4717 … … 6788 6885 #endif 6789 6886 6790 #if defined( Q_OS_LINUX) && !defined(__UCLIBC__)6887 #if defined() && !defined(__UCLIBC__) 6791 6888 fenv_t envp; 6792 6889 feholdexcept(&envp); … … 6804 6901 #endif //Q_OS_WIN 6805 6902 6806 #if defined( Q_OS_LINUX) && !defined(__UCLIBC__)6903 #if defined() && !defined(__UCLIBC__) 6807 6904 fesetenv(&envp); 6808 6905 #endif … … 7459 7556 Q_CORE_EXPORT double qstrtod(const char *s00, const char **se, bool *ok) 7460 7557 { 7558 7461 7559 double ret = strtod((char*)s00, (char**)se); 7462 7560 if (ok) {
Note:
See TracChangeset
for help on using the changeset viewer.