summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlocale_tools.cpp
Commit message (Collapse)AuthorAgeFilesLines
* QLocaleData::longLongToString: clean up sign handlingEdward Welbourne2017-10-031-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | In qlltoa we simply discarded sign, passing absolute value down to qulltoa; given that it had just one caller and did something only that caller is apt to want - violating the principle of least surprise for those who would expect it to handle sign sanely - it is better to just inline it in the one place it was used. That one place, QLocaleData::longLongToString(), handles sign separately and (for reasons I shall argue elsewhere are bogus) ignores sign for bases other than ten. When ignoring sign, it passes negative values directly to qulltoa, which caught the attention of Coverity (CID 22326). This deliberately cast (for the same bogus reasons) negatives to large unsigned. Inlining base ten's call to qlltoa() as a call to qulltoa() could now be unified into a simple (and less obviously perverse) form. Making the (contentious) cast explicit can then calm Coverity and we get a simpler implementation all round. Incorporate also Marc Mutz's fix for unary minus applied to unsigned and handling of the most negative value, suitably adapted. Change-Id: Iea02500a5dd7c6d7ac6e73656e1b11f116ae85c6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix parsing of 0E+1 and 0E-1 (capital 'E')Thiago Macieira2017-07-031-1/+1
| | | | | | | | | | Since the result is an actual zero, this section of code looking for underflows kicks in. But we forgot to take the capital letter into account when parsing the number. Task-number: QTBUG-61350 Change-Id: Ia53158e207a94bf49489fffd14c6abbd21f0bac0 Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* QLocale: Fix wrong assertUlf Hermann2016-08-251-1/+1
| | | | | | | | | | The endptr from reading the exponent of a 'g' form snprintf result should not be past the end of the string we're reading from. It has nothing to do with the 'e' sign. Task-number: QTBUG-54482 Change-Id: I8bdee917b8d21fdc94c255548ad7e008431a07fa Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add qstrntod as qstrtod overload, which takes a len parameterTobias Koenig2016-02-031-2/+12
| | | | | | | | | | Add qstrntod as an overload for qstrtod, which takes a len parameter, so one can pass character arrays which are not null-terminated. Change-Id: I8c1c6c3627043c1d6ec6eb712efa3abc9e5e9e00 Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Milian Wolff <milian.wolff@kdab.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* Update the Intel copyright yearThiago Macieira2016-01-211-1/+1
| | | | | | | | | Not that we require it, but since The Qt Company did it for all files they have copyright, even if they haven't touched the file in years (especially not in 2016), I'm doing the same. Change-Id: I7a9e11d7b64a4cc78e24ffff142b4c9d53039846 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Updated license headersJani Heikkinen2016-01-151-14/+20
| | | | | | | | | | | From Qt 5.7 -> LGPL v2.1 isn't an option anymore, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new LGPL header instead of LGPL21 one (in those files which will be under LGPL v3) Change-Id: I046ec3e47b1876cd7b4b0353a576b352e3a946d9 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QLocale: Accept trailing junk in qstrtod()Ulf Hermann2016-01-051-7/+11
| | | | | | | | | | | qstrtod() used to accept trailing junk until libdouble-conversion was introduced and we need this behavior in order to implement EcmaScript's parseFloat() correctly. The QString and QByteArray methods should not accept trailing junk, though. Task-number: QTBUG-50131 Change-Id: Ide922da0d65b2576be2c9f47f6053057eff77994 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Centralize dropping of trailing zeroes when converting doublesUlf Hermann2015-11-241-4/+2
| | | | | | | | | We're never interested in trailing zeroes, unless the number is exactly 0. qdtoa would return an empty string if the result was exactly '0', which is also fixed by this change. Change-Id: I3ba2f7e835b92d54d9008ad03fdf6ce5fb3af8a4 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Add flags to omit/reject padding in scientific notation exponentsUlf Hermann2015-11-231-2/+3
| | | | | | | | | | | | | | The EcmaScript format for printing doubles in exponent form differs from Qt's format only in this aspect. EcmaScript explicitly prohibits leading zeroes in exponents. It is thus worthwhile to add those flags in order to be able to generate and parse doubles in compliance with EcmaScript. [ChangeLog][QtCore][QLocale] Additional flags in QLocale::NumberOption allow generating and parsing doubles in EcmaScript compliant format. Change-Id: Ia7b82c2e67bb8b80bd890014ff5cd4563faf2a03 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* Interpret precision == -128 as "shortest" double conversionUlf Hermann2015-11-231-11/+19
| | | | | | | | | | | | Also use this for converting doubles with QVariant. We generally want exact results there, rather than adding rounding errors whenever we convert. [ChangeLog][QtCore][QLocale] Added special value for double conversion precision to get shortest accurate representation. Change-Id: I905b8a103f39adf31d24b6ce2c8a283cf271b597 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
* QLocale: Return overflowing numbers from asciiToDouble()Ulf Hermann2015-11-041-8/+28
| | | | | | | | | | | | | | | | | | The behavior from before libdouble-conversion is that in case of an overflow the OK flag is set to false, but the returned number is still infinity, rather than 0. Also, the number of processed characters is always set to the number of characters actually processed, unless garbage is found. There is an important distinction between an overflow and garbage. The client code may accept overflows and infinity may be a valid result. Garbage is most certainly not acceptable. Having an infinity/false result in addition to 0/false allows the client code to distinguish those. One application where this is useful is parsing JavaScript. Change-Id: I4b8581568144b44fca3353c4bd9685c702762af9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Replace qdtoa and qstrtod implementation by a 3rdparty libraryUlf Hermann2015-11-021-2395/+300
| | | | | | | | | | | | | | | | | This also fixes the underlying cause of QTBUG-44039 and QTBUG-43885. You can choose between system, qt, and no libdouble-conversion support. If you choose "no", snprintf_l and sscanf_l will be used. By default, system double conversion is used if the system provides a double-conversion library. Otherwise the bundled libdouble-conversion is built. sscanf_l and snprintf_l are not used by default as the planned "shortest" conversion mode to produce the shortest possible string will give less precise results when implemented with snprintf_l. Change-Id: I8ca08a0fca5c54cf7009e48e771385614f6aa031 Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
* Provide a simpler and safer version of qdtoa()Ulf Hermann2015-10-201-0/+10
| | | | | | | | | | The new version returns a QString instead of a char * that has to be manually free()'d by the user. Also, it does away with most of the parameters so that we can replace the implementation with something saner without mapping all those modes between the implementations. Change-Id: I42ff95648e7955b9e74eb0f459a1fdedc1ad7efb Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update strtoll and strtoull from upstream FreeBSDThiago Macieira2015-03-261-214/+51
| | | | | | | | | | | | | | | There appears to be at least one fix, related to sign- or zero-extension in the call to isspace(). So it's a good idea to update again. This also brings the behavior to match strtoll and strtoull on Linux, including the fact that strtoull will parse negative numbers. For that reason, qstrtoll and qstrtoull are now wrappers that try and keep the behavior that we used to have. This update also changes the code from a 4-clause BSD license (bad) to a 3-clause BSD license (good). Change-Id: I73b01b02ebd1551bf924599d52284ad25cc1def0 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* Remove support for QT_QLOCALE_USES_FCVT.Erik Verbruggen2015-01-281-53/+0
| | | | | | | We expect floating-point math to be IEEE754 compliant. Change-Id: I2b257177f2ef5fce38ac4d8fd76f746dc7b9fc15 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Add ascii_isspace to replace the locale-dependent isspace(3)Thiago Macieira2014-07-311-3/+3
| | | | | Change-Id: Icee42515179e6f3ddefe0692af69e90054449618 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QLocalePrivate: merge removeGroupSeparators into numberToCLocaleThiago Macieira2014-02-141-74/+0
| | | | | | | | This version will parse the string only once and will not do any memmove. This is more efficient. Change-Id: I59026ad0fa61cc3f16146bdcd622fc54cbd8a321 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QLocalePrivate: move the stringToXxx to QLocaleDataThiago Macieira2014-02-141-1/+1
| | | | | | | | | Along with some more helper functions. There are two more functions used in QIntValidator Change-Id: I469ef40426cbb73ab515454bd5ecb12d944f5c0a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QLocalePrivate: move the xxxToString functions to QLocaleDataThiago Macieira2014-02-141-2/+2
| | | | | | | | | | | Those functions do not need any of extra QLocale settings in QLocalePrivate, so we can move them easily, along with their flags. It's also very convenient that we can now bypass completely QLocale when formatting numbers to strings. Change-Id: I8cae64e8e2056a6b2d716758e4be79f746644732 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Remove workarounds to old GCC bugs we had encountered on IRIXThiago Macieira2013-08-311-22/+0
| | | | | | | | | | | | | The check is bogus anyway. It was bogus when it was added. The bug is not because of "GCC on IRIX", it's simply a GCC bug and was probably tied to some GCC versions. It should have been reported and followed up. I don't even remember what GCC versions we had on the IRIX machines (plastkrakk, I can't remember the other two machine names). But I could bet they were GCC 3.4 or 4.0. Change-Id: I84ce4e1ad68bb0520b63c210f841e0c604dbd03a Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* un-confuse lupdate: make #ifdef'd braces symmetricalOswald Buddenhagen2013-08-121-3/+2
| | | | | | | | | as a side effect, this also de-duplicates the code, which is good in its own right. Change-Id: I504cb518276fdf610639c3337e3842570b97815f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: John Layt <jlayt@kde.org>
* Remove use of 'register' from Qt.Stephen Kelly2013-06-171-12/+12
| | | | | | | | | | It is deprecated and clang is starting to warn about it. Patch mostly generated by clang itself, with some careful grep and sed for the platform-specific parts. Change-Id: I8058e6db0f1b41b33a9e8f17a712739159982450 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* MinGW: Add missing constants for float control.Friedemann Kleint2012-11-161-0/+9
| | | | | | | | Change-Id: Ibce64ed1ec2809551b0cd334b53b33ed445f90f7 Reviewed-by: Jonathan Liu <net147@gmail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* QTBUG-26035: Remove positive sign from start of stringTarja Sundqvist2012-06-261-1/+1
| | | | | | | | | | | | Updated removeGroupSeparators(QLocalePrivate::CharBuff *num) so that it removes also positive sign ('+') at the start of the string. Auto test included. Task-number: QTBUG-26035 Change-Id: I8e0e071d6c682d9192a8c6bb2f282510e21b3c48 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Denis Dzyubenko <denis.dzyubenko@nokia.com>
* Remove ARMFPA support and Q_DOUBLE_FORMAT detectionBradley T. Hughes2012-03-011-40/+4
| | | | | | | | | | | | | | | | | Remove the -armfpa option the config.tests/unix/doubleformat* detection. The places where we used QT_ARMFPA and Q_DOUBLE_FORMAT has been removed as well. Rationale: ARM FPA with GCC does not work with EABI. Qt currently does not support compiling without EABI, making ARM FPA an impossibility. It is unknown whether other compilers provide ARM FPA support with EABI. Support for ARM FPA can be re-added in the future should the need arise, but since ARM VFP is available for ARMv5 and up, we should encourage implementors to instead use soft-floats or VFP. Change-Id: I3671aba575118ae3e3e6d769759301c8f2f496f5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Remove Q_CC_MWERKS.Robin Burchell2012-01-191-7/+0
| | | | | | | | This is no longer supported. Change-Id: I3914f5007595fd699fa1e9a565a0a3f59a0e135e Reviewed-by: Jonas Gastal <jgastal@profusion.mobi> Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
* Build fix for WINCE to qlocale_tools.cppJanne Anttila2012-01-131-0/+4
| | | | | | | Task-number: QTBUG-22500 Change-Id: If530799cf8ef971f5caf78d0c6dbeeda719d148f Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
* Update year in Nokia copyright headers.Jason McDonald2012-01-101-1/+1
| | | | | | | | The previous change missed some headers from years prior to 2011, and a few new files were merged after the previous change. Change-Id: Ib7d1a2b7062228c2a5373da64242b2ee1f0981e1 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* Windows: Adapt mkspec for MinGW / gcc 4.6.Friedemann Kleint2011-11-181-0/+7
| | | | | | | | | | | gcc 4.6 becomes the minimum required version in Qt 5. See also d4150975af620e2889cc58bd476bac6b4d101db3 in Qt 4.8. Change-Id: If66ce0be755263c20b0a4371523c6590592d962d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com>
* Update licenseheader text in source files for qtbase Qt moduleJyri Tahtela2011-05-241-17/+17
| | | | | | | Updated version of LGPL and FDL licenseheaders. Apply release phase licenseheaders for all source files. Reviewed-by: Trust Me
* Initial import from the monolithic Qt.Qt by Nokia2011-04-271-0/+2961
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12