summaryrefslogtreecommitdiffstats
path: root/src/corelib/text/qlocale_win.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Pass QVariant to QSystemLocale::query() as rvalue referenceEdward Welbourne2024-04-091-1/+1
| | | | | | | | | | QVariant is rather big for passing by value; and no caller has any further use for the QVariant it's passing in. Pick-to: 6.7 6.5 Task-number: QTBUG-122619 Change-Id: I2751745e715aacfa8982ac97b4ae777fde5e88de Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Tidy up, check platform and add comments in qlocale_win.cppEdward Welbourne2024-01-291-6/+4
| | | | | | | | | | | | | | MS says we should stop using LCID, so make a note about that. This file should only be compiled when Q_OS_WIN is defined, so don't bother with #if-ery to check that. Remove two redundant forward-declarations. Record what qt_localeFromLCID is for - undocumented private API exported for the use of a platform plugin - since that isn't immediately obvious to someone only looking at QLocale. Change-Id: I81ad945bb92d4f81a3ca2aaf97a945635b137a2e Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Make QLocale self-consistent on WindowsEdward Welbourne2024-01-191-16/+45
| | | | | | | | | | | | | | | | | | | | | | | The constructor and update() method for the system locale were using GetUserDefaultLCID(), where query() and the fallback locale first checked the LANG environment variable, leading to inconsistent results if the user set the environment variable to something different from the system's configured locale. Break out the logic of parsing %LANG% into a static helper, replace the existing parsing with a call to this and add a helper to get the right ID to use, possibly via it, using GetUserDefaultLCID() as fall-back. Drive-by: initialize substititionType in its declaration. Also look up %LANG% each time we want it; it's not that expensive, given how rarely this code is called, and client code could change its value at runtime. Partially inspired by a patch from Wladimir Leuschner <wladimir.leuschner@qt.io> Pick-to: 6.5 6.6 6.7 Fixes: QTBUG-120961 Change-Id: Ie706c7089bd2b3757a3eab627723ec34a5e2b07f Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale/MS: extract function to save some repetitionEdward Welbourne2023-11-031-18/+12
| | | | | | | | | | With one exception in a kludge-around, substituteDigits() calls were always subject to the same condition, so wrap that in a trivial method and simplify the code calling it. Change-Id: I6d8f3ca9179e32f03348cd718f9ee9de573221b9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* QLocale/MS: polish some arrays and their accessEdward Welbourne2023-11-031-12/+9
| | | | | | | | | The arrays can be constexpr, and we can avoid some repetition by making only the choice of which to look in conditional, when we do the same thing thereafter. Change-Id: I8c9f95b3967017cf67a76de9d2a7a8729ee430f0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale/MS: return null variant, not empty string, on failuresEdward Welbourne2023-11-031-29/+47
| | | | | | | | | | | | | | | Likewise for the string list in uiLanguages(). Document the exception (for grouping separator) and the other corner case (currency symbol). In commit 089bbfc30758265d3fce804b950f56a15225e32c we changed the system locale look-ups to rely on backends to return null QVariant on failed look-up, but the MS backend has several places where it would return an empty string for lookups that really shouldn't. Pick-to: 6.6 6.5 Fixes: QTBUG-118703 Change-Id: I1a5622beebc4e5639d643250829937a829e23363 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale: clean out assorted over-namespacingEdward Welbourne2023-08-091-8/+8
| | | | | | | | The code of a class doesn't need that class's prefix to access members of the class. Change-Id: I4cc2f72c90cff48b331dc12d390c45c0639606b3 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* qt_inIsoNametoLCID: protect against a nullptr nameMarc Mutz2023-02-221-0/+2
| | | | | | | | | | | | | | | | | | | | | | | The only user of the function, QCollatorPrivate::init(), passes QLocalePrivate::bcp47Name().constData(). bcp47Name() may return a default-constructed QByteArray (e.g. for QLocale::AnyLanguage), so constData() may be nullptr (QT5_NULL_STRINGS != 1). Passing nullptr to strncmp() or strncpy() is UB, though. Instead of using the nullptr-hardened q... versions of these functions, check name for nullptr once, at the top of the function, and avoid all the lookup code that follows and is known to fail (because windows_to_iso_list does not contain empty entries). This way, we take advantage of the std functions' UB for performance reasons (fewer repeated nullptr checks), instead of being taken advantage of. Qt 5 is not affected, as constData() never returns nullptr there. Pick-to: 6.5 6.4 6.2 Change-Id: I980dace2bca1e983ac526e89fadeb92239ab5f11 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Pass short time format to GetTimeFormat from GetLocaleInfoIlya Fedin2023-01-301-3/+5
| | | | | | | | | | TIME_NOSECONDS doesn't really switches to short time format, just removes the seconds from long time format Fixes: QTBUG-110627 Pick-to: 6.5 6.4 6.2 5.15 Change-Id: Ie799958f3942c657f00bc8196588258661ddc1d9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSystemLocale/Win: use LOCALE_RETURN_NUMBER to get numbersThiago Macieira2023-01-241-4/+5
| | | | | | | | | Instead of parsing from a QString, which actually recurses back into QSystemLocale. Pick-to: 6.5 Change-Id: I3c79b7e08fa346988dfefffd171f9b78e1d8d6ce Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Introduce qt_winrtbase_p.hOliver Wolff2023-01-231-9/+2
| | | | | | | | | | | | | | Due to a bug in earlier Windows SDKs developers have copy paste a workaround whenever they are including winrt/base.h. In addition to that our usage winrt API also forces them to include qfactorycacheregistration_p.h whenever they include that file. To make things easier all that magic can now be done with one single include of qt_winrtbase_p.h. Pick-to: 6.4 Change-Id: Ic6a80d6d3723af381cf0ecc0f0ab43c2e6839a7d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* QSystemLocale[Win]: Catch potential WinRT exceptionsVladimir Belyavsky2022-11-271-3/+7
| | | | | | | | | | Some Windows SDKs seem to throw an exception from winrt::check_hresult() We need to handle this accordingly. Fixes: QTBUG-108605 Pick-to: 6.2 6.4 Change-Id: I14ad3b6dbd9b5fdf0120f9d3336a4d922167d169 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix out-of-bounds assert in winIso639LangName()Edward Welbourne2022-11-251-1/+1
| | | | | | | | | | | | | | | QByteArray doesn't allow accessing, with operator[], the '\0' byte it stores at index size(). Previously we accessed it indirectly by dereferencing a pointer offset from its data() instead of indexing; my recent change converted the return of an endptr to the return of its index, so used operator[]. This is a follow-up to commit 6c435e5dd41177308f22ba4b55931b2c463cb0d8 Change-Id: I9faf9dfa3dcc8df1e841e5538e452afef9ba610c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
* Restore end-of-parse reporting to qstrntod()Edward Welbourne2022-11-241-4/+4
| | | | | | | | | | | | | | | | | | Rework QSimpleParsedNumber to store a qsizetype whose sign serves as ok flag (positive is ok, zero and negative are not) and magnitude is the number of characters used. This replaces an endptr that was set to null to indicate !ok, but that deprived us of end-of-parse information, which is needed for number-parsing. In particular, JS's parsing of numbers accepts overflow (where qstrntod() flags it as invalid) as infinity; so qstrntod() does need to say how long the overflowing (but JS-valid, none the less) number-text was. Modify all callers of functions using this (recently-introduced) type and add tests that fail without this fix. Fixes: QTBUG-108628 Change-Id: I416cd213e1fb8101b1af5a6d43615b970a5db9b4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QLocale: make qstrnto(u)ll not have output argumentsThiago Macieira2022-11-161-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | That is, return everything in the return argument. On the SysV ABI, that means everything gets returned in registers, in both 32- and 64-bit platforms (unlike QtPrivate::ParsedNumber). There's a minor but perceptible performance improvement in parsing strings and byte arrays. Before: Parsed string "42" "1234" "-1548860221" Clock (ns) 16.673 18.878 25.517 CPU cycles 46.548 52.704 71.243 Instructions 201 233 331 After: Parsed string "42" "1234" "-1548860221" Clock (ns) 15.577 17.998 24.198 CPU cycles 43.491 49.942 67.552 Instructions 179 211 308 On my Core i7-1165G7 @ 2.80 GHz, the 22-23 instruction gain per iteration results in half the expected clock gain in runtime (22 / 2.8 GHz = 7.8 ns) because of a slightly lower instruction per cycle rate. That's acceptable because we need less speculative execution. Pick-to: 6.4 Task-number: QTBUG-107788 Change-Id: I07ec23f3cb174fb197c3fffd17220fd64d473cc0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Proper clearing of WinRT factory cacheAndreas Buhr2022-10-311-0/+1
| | | | | | | | | | | | | | | | | | | If we use winrt's factories we have to make sure to to clear the factory cache when one of our dlls is unloaded or we will run into dangling factory entries which might result in crashes. So we have to make sure that winrt::clear_factory_cache is called on every dll unload. In order not to increase compile times and dependencies too much qfactorycacheregistration_p.h needs to be included in Qt code whenever we use winrt's factory cache. A rule of thumb being: Include qfactorycacheregistration_p.h whenever including winrt/base.h. Other Qt modules which use winrt's factories need to be updated too. Fixes: QTBUG-103611 Pick-to: 6.2 6.4 Change-Id: I7ab24e4b18bffaca653c5b7f56a66ce99212e339 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QLocale: port to qsizetype [2/N]: remainder (qlocale_win.cpp partial)Marc Mutz2022-09-011-2/+2
| | | | | | | | | | | | | | | | | | Port ints to qsizetypes where they're not blatantly wrong. This includes indexed loops that don't require the additional range, because int these days is a code smell, so if we can save the next code reader a few moments of digging to convince herself that the int is ok even in 64-bit builds, then let's do it. The Windows implementation only has the most obvious occurrences ported, because I lack platform access. Created QTBUG-105100 to track the missing changes. OSX should be fine, provided sizeof(long) == 8 on 64-bit OSX. Pick-to: 6.4 6.3 Task-number: QTBUG-103531 Change-Id: I679183f28ed42e89e2879e29457e6a4e487fed0d Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Remove superfluous clang preprocessor check for cpp/winrtOliver Wolff2022-08-261-4/+4
| | | | | | | | | The cpp/winrt configure test fails if clang is being used so there is no need to explicitly check for the compiler. Change-Id: Ifb2cb792cf3ea2d2ff09be6e47d741f09aec765f Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
* Port qt_readEscapedFormatString() to qsizetypeMarc Mutz2022-08-121-1/+1
| | | | | | | | | More of the usual missing int -> qsizetype porting... Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-103531 Change-Id: I53faff5fe306c1d207741bc93a1e5c15d3eefa4f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale/Win: fix truncation bug in winIso639LangName()Marc Mutz2022-07-201-2/+2
| | | | | | | | | | | | | | | | | The qstrtoull() function returns ulonglong, not int, so we'd be incorrectly detecting 0x1'0000'0814 as NyNorsk. Paranoia? Sure. Fix by using auto to hold the result. As a drive-by, make the QByteArray const so .data() doesn't attempt to detach(), and shorten a long variable name to stay within line-length limitations. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-103531 Change-Id: I740d0c5934e54c9f716688fa9c00de0ac4029936 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocale/Win: replace 0 with nullptr in winLangCodeToIsoName()Marc Mutz2022-07-201-2/+2
| | | | | | | | | | The function returns a pointer, not an integer. Found while working on QTBUG-103721. Change-Id: I18a9987d99c645a5b410c4b11128bfebcc5dcddd Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocale/Win: replace hand-written binary search with a call to lower_bound()Marc Mutz2022-07-201-18/+10
| | | | | | | | | | | | | | | Binary search is notoriously hard to implement, and, while I didn't spend time to prove it, this implementation was probably buggy, too (any implementation which is missing a ±1 in the loop body is suspicious). Replace with a call to std::lower_bound(), which has precise semantics and no bugs. Task-number: QTBUG-103721 Change-Id: Ibe12c7d20b8c01e19a6f294f6c1b564b6b484b07 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QLocale/Win: statically assert that is_sorted(windows_to_iso_list)Marc Mutz2022-07-201-2/+13
| | | | | | | | | | | | | | | | | Consequently, remove the corresponding comment. Need to mark the array as constexpr in order to run q20::is_sorted on it. Instead of overloading op< (which would be wrong, because there's no one natural ordering of these entries), write the idiomatic manual mixed-mode comparator By<FieldName> and use that. A follow-up commit will use the same function object to replace the hand-written binary search with a call to lower_bound(). Task-number: QTBUG-103721 Change-Id: I47743b5620dc3cece73b2e5bae658d5a636554dd Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Port qt_repeatCount() to qsizetypeMarc Mutz2022-07-201-1/+1
| | | | | | | | | | | | | | | | | While it's true that the typical user of the function won't expect more than half a dozen repeats, this function is fed with user-supplied input, so it could be asked to return in excess of INT_MAX matches. The truncation then means we're misreporting the number mod INT_MAX, which is as good as a random number and leads to false positive matches in users of the function. Just return the true result instead of a truncated one. Pick-to: 6.4 6.3 6.2 Task-number: QTBUG-103531 Change-Id: I5e3aa23dec873c6f9af255e90748fb38619d2f5d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-161-39/+3
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Replace uses of _qs with _s in sources and examplesSona Kurazyan2022-04-191-1/+1
| | | | | | Task-number: QTBUG-101408 Change-Id: I48360ba3b23965cd3d90ac243c100a0656a4cde8 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* QtCore: replace QLatin1String/QLatin1Char with _L1/u'' where applicableSona Kurazyan2022-03-251-15/+18
| | | | | | | | | | | As a drive-by, did also minor refactorings/improvements. Task-number: QTBUG-98434 Change-Id: I81964176ae2f07ea63674c96f47f9c6aa046854f Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
* De-pessimize Windows version of QSystemLocalePrivate::measurementSystem()Marc Mutz2022-03-151-3/+1
| | | | | | | | Don't create a QString from a wchar_t array to check that the array contains "1\0". Just do character-by-character comparison. Change-Id: I7e5c2348c24af6a9b046c91423a52f756ceb9eb9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* configure: Check for basic cpp/winrt supportOliver Wolff2022-02-011-5/+4
| | | | | | | | | | | | | | Some configurations (like MSVC2019 with c++20 on Windows 10) fail to compile winrt/cpp headers as these include experimental coroutines unconditionally. In these cases we can fall back to the legacy implementation. Pick-to: 6.2 6.3 Change-Id: Ibd574995f8ca1f865bbcdabede1ffcd0c340022f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Fix formatting of dates before 1601 in MS system localeEdward Welbourne2021-11-181-1/+65
| | | | | | | | | | | | | | | | The relevant MS system calls (say they) don't support date formatting for years < 1601 (but apparently do in fact) and the year field of the data structure is unsigned, so can't support years < 0. As a result, the windows back-end for QSystemLocale failed for negative years. So replace year < 1601 with a place-holder and substitute after formatting. Added new tests (based loosely on one in qtdeclarative that failed) to verify that this actually works. These reveal that macOS also fails to handle negative years; marked as expected failure there pending a fix. Change-Id: I9b63cefd5f0b77a39cf1238549412de3e26ca1bd Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Guard WinRT API code for clang-clPeter Varga2021-10-121-4/+4
| | | | | | | | | | | | | | It is unsupported with clang-cl and breaks the build. This is a fixup for: 51e8d3592a Let QLocale::uiLanguages() use WinRT API when possible Task-number: QTBUG-94341 Pick-to: 6.2 Change-Id: Icf32339e81d67d4c119b7fb8d8d834c744b9ead0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Let QLocale::uiLanguages() use WinRT API when possibleIvan Solovev2021-10-011-1/+26
| | | | | | | | | | | | | | | | | | This patch introduces support for the WinRT UI languages API. We are using the Win32 API to get the list of preferred languages when the system locale is used. However, this API returns an incomplete list. As Qt 6 supports Windows 10 and above, we can make use of the WinRT API, if it's supported by the compiler. This API returns the full list, as reported by the Windows system itself. Note however, that this API can't be used with Clang and MinGW, so we still have to fall back to Win32 API for these compilers. We also do it if WinRT API returns an empty list of languages for some reason. Fixes: QTBUG-94341 Pick-to: 6.2 Change-Id: I1d23c68d2ec298ae7835d0d18718876ff041aede Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Teach QLocale::system() to use narrow formatIvan Solovev2021-09-151-0/+7
| | | | | | | | | | | | | | | | QLocale::system() was not making use of QLocaleFormat::Narrow, always treating it in the same way as QLocaleFormat::Short. This patch fixes the issue for day and month names. The implementation falls back to CLDR if system locale fails to provide some data. Pick-to: 6.2 Task-number: QTBUG-84877 Change-Id: Ia37e59dbf02d7a5e230f2767d294b9ab7de37f33 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Fix QLocale::system() standalone day and month handlingIvan Solovev2021-09-061-0/+4
| | | | | | | | | | | | | | | Some backends were missing support for standalone days and months, also the standaloneDayName() implementation was always using the same codepath as dayName(). This patch fixes the issues. Support for narrow format will be added in the following patch. Task-number: QTBUG-84877 Pick-to: 6.2 Change-Id: I38ee06342cafab544e3c69097bd0e6ae68e85645 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* qlocale_win: Fix non-standalone month namesEdward Welbourne2021-09-011-3/+30
| | | | | | | | | | | | | | | | | | | | We have previously been using the standalong (nominative) month names both when asked for that and when asked for the plain (genitive) month name, probably because there was no LCTYPE value for the latter. However, MS's docs for the standalone values do contain a comment telling us how to get the genitive names. Rename the old monthName() to standaloneMonthName() and add a monthName() that calls GetDateFormat() suitably, as described by the MS doc. Pick-to: 6.2 5.15 Fixes: QTBUG-92018 Fixes: QTBUG-86279 Change-Id: I27f63198c3a15b792683f476d2019078b0860f99 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Convert various callers of strtou?ll() to call strntou?ll()Edward Welbourne2021-08-301-3/+3
| | | | | | | | Where size is known or can readily be determined. Change-Id: I442e7ebb3757fdbf7d021a15e19aeba533b590a5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qlocale_win: Simplify and explain month-name format lookupEdward Welbourne2021-08-271-5/+4
| | | | | | | | | | | | Retain the given month number and simply subtract one from it in the one place it's used (once the two array dereferencs are unified). That makes it clear that the off-by-one numbering is just down to our arrays, not some weired quirk of the MS API. Simplify a condition by inverting it: compare to LongFormat instead of ||-ing comparisons to the other two members of the enum. Change-Id: Ia03486b7869255ecdb1372de62d5c745d35d0a0a Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qlocale_win: return null QVariant on failed look-upsEdward Welbourne2021-08-111-4/+4
| | | | | | | | | | | Various functions were still returning a null QString wrapped as a QVariant; the caller distinguishes these cases, so should get a null QVariant so it knows the backend failed to answer the query and can attempt whatever fall-back it may have at its disposal. Pick-to: 6.2 Change-Id: I0983b9f3b1026f17c3f13ab92b713bee90be466c Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* qlocale_win: Rename a misnamed local variableEdward Welbourne2021-08-101-6/+6
| | | | | | | | | | Although the function is called get{Dat,Tim}eFormat(), the content it's filling the buffer with isn't a format, it's a formatted date or time. So name the variable we transcribe the buffer into text instead of misleadingly calling it format. Change-Id: Ia3a51184963109a50dbc41e205bd8c83d83c04d7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Initialize SYSTEMTIME to {} instead of memset()ingAndreas Buhr2021-05-261-4/+2
| | | | | Change-Id: I7ee02a6bcf5961adce26b635f12722e12c4865d3 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Add the "Territory" enumerated type for QLocaleJiDe Zhang2021-04-151-6/+6
| | | | | | | | | | | | | | | | | | | The use of "Country" is misleading as some entries in the enumeration are not countries (eg, HongKong), for all that most are. The Unicode Consortium's Common Locale Data Repository (CLDR, from which QLocale's data is taken) calls these territories, so introduce territory-based names and prepare to deprecate the country-based ones in due course. [ChangeLog][QtCore][QLocale] QLocale now has Territory as an alias for its Country enumeration, and associated territory-based names to match its country-named methods, to better match the usage in relevant standards. The country-based names shall in due course be deprecated in favor of the territory-based names. Fixes: QTBUG-91686 Change-Id: Ia1ae1ad7323867016186fb775c9600cd5113aa42 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use Core library for qmake instead of the Bootstrap libraryAlexey Edelev2021-02-251-2/+2
| | | | | | | | | | | | | | | | | | | Move the qmake-specific logic of the QLibraryInfo class to qmake internals. 'qconfig.cpp.in' now stores information about the library info entries to keep them consistent between qmake and the Core library. qmake requires specific features enabled in the Core library, so building qmake will be skipped if the features are not enabled. All flags directly related to the qmake have been removed from Core lib. Remove all bootstrap related sections from qmake CMakeLists.txt Task-number: QTBUG-89369 Change-Id: I26de157d3bfd4a5526699296e9d46e1c180b89ae Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
* Clarify what QSystemLocale::fallbackLocale() is used forTor Arne Vestbø2021-02-091-3/+3
| | | | | Change-Id: I8f073f996505ccb42020b32fd76520ecef54e628 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* String-view-ify qt_splitLocaleName() and simplify its callersEdward Welbourne2020-11-171-8/+6
| | | | | | | | | | | Two of its callers didn't even care about the fragments it was returning, one only cared about two of them. The parsing could be more straightforward and less verbose. Parsing into QStringView saves the need to allocate copies of the substrings parsed. Cleaned up around the code that called it. Change-Id: Ie65d2b1b3eb891c20bc82275d7a0da00c30d7b8d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* MinGW: Fix compile error in qlocale_win.cppFriedemann Kleint2020-11-101-3/+3
| | | | | | | | | | | | | Cast enumerations to ushort, fixing: src/corelib/text/qlocale_win.cpp: In member function 'virtual QVariant QSystemLocale::query(QSystemLocale::QueryType, QVariant) const': src/corelib/text/qlocale_win.cpp:765:34: error: enumeral and non-enumeral type in conditional expression [-Werror=extra] As a drive-by, fix deprecation warning about QVariant::type(). Amends 098f43fdd2d46e15c87073aae44c5f2bd0cd8c98. Change-Id: I2adc9833c6d6d9e9d2500f0b92b25cb5d38b583b Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QLocale: use uint lessEdward Welbourne2020-11-081-2/+2
| | | | | | | | | | Various uses of uint were simply redundant, now that Language, Script and Country are ushort-based. Others should in any case have been quint16 or char32_t. Change-Id: Id0d0dc2558e1724907907cde56059f70972e824a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Use QLocaleId in place of language, script, country triplesEdward Welbourne2020-11-081-8/+4
| | | | | | | | | | | | Pass a single argument in place of three; and (prepare to) replace QLocalePrivate::getLangAndCountry(), taking three out parameters, with QLocaleId::fromName(). Removal of getLangAndCountry() must wait for removal of linguist's use of it in qttools, which has to wait for this change to land in qtbase. In the process, change findLocaleIndex()'s return to int. Change-Id: I9f5c44c41f2dd1598c53ed5ccb0abddc6b17d21f Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Deprecate QVariant::TypeLars Knoll2020-10-231-5/+5
| | | | | | | | | It's been obsolete for a long time already. Make sure the compiler now warns about it and remove all remaining uses in qtbase. Change-Id: I0ff80311184dba52d2ba5f4e2fabe0d47fdc59d7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix handling of Suzhou numbering systemEdward Welbourne2020-07-171-7/+9
| | | | | | | | | | | | | | | | This only arises when the system locale tells us to use its zero as our zero digit, since no CLDR locale uses it by default. Adapt an MS-specific QLocale::system() test to use Suzhou numbering, so as to test this. While updating the locale-restoration code to also restore the digits being set in that test, add restore code for the long time format, where previously only the short time format was restored. Add a comment to make it less likely one of those shall be missed in future. Fixes: QTBUG-85409 Change-Id: I343324bb563ee0e455dfe77d4825bf8c3082ca30 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QSystemLocalePrivate::substituteDigits(): change to move semanticsEdward Welbourne2020-07-151-6/+6
| | | | | | | | | | Rather than passing an in-out reference parameter and ignoring the return (of that parameter) use an actual rvalue ref parameter and move the value through the function, to make it easier for compilers to see how to optimize it. Change-Id: Ie239400345da012d8fb8a731394f1687b8b62430 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>