diff options
author | Dimitri van Heesch <dimitri@stack.nl> | 2015-07-19 10:12:39 (GMT) |
---|---|---|
committer | Dimitri van Heesch <dimitri@stack.nl> | 2015-07-19 10:12:39 (GMT) |
commit | b31266c1076c6284116f17241d9e8aa048f88e60 (patch) | |
tree | 3504af4c401a616449931bdbd820a7ab5eb98931 /qtools/qstring.cpp | |
parent | 4116648d3c62aee54c385644a4fe754ee7a4261d (diff) | |
download | Doxygen-b31266c1076c6284116f17241d9e8aa048f88e60.zip Doxygen-b31266c1076c6284116f17241d9e8aa048f88e60.tar.gz Doxygen-b31266c1076c6284116f17241d9e8aa048f88e60.tar.bz2 |
Bug 751984 - PATCH: Honour SOURCE_DATE_EPOCH environment variable for reproducible output
Diffstat (limited to 'qtools/qstring.cpp')
-rw-r--r-- | qtools/qstring.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/qtools/qstring.cpp b/qtools/qstring.cpp index f51c0d4..458fd53 100644 --- a/qtools/qstring.cpp +++ b/qtools/qstring.cpp @@ -13935,6 +13935,60 @@ bye: } /*! + Returns the string converted to an <code>unsigned long</code> + value. + + If \a ok is non-null, \a *ok is set to TRUE if there are no + conceivable errors, and FALSE if the string is not a number at all, + or if it has trailing garbage. +*/ + +uint64 QString::toUInt64( bool *ok, int base ) const +{ + const QChar *p = unicode(); + uint64 val=0; + int l = length(); + const uint64 max_mult = 1844674407370955161ULL; // ULLONG_MAX/10, rounded down + bool is_ok = FALSE; + if ( !p ) + goto bye; + while ( l && p->isSpace() ) // skip leading space + l--,p++; + if ( *p == '+' ) + l--,p++; + + // NOTE: toULong() code is similar + if ( !l || !ok_in_base(*p,base) ) + goto bye; + while ( l && ok_in_base(*p,base) ) { + l--; + uint dv; + if ( p->isDigit() ) { + dv = p->digitValue(); + } else { + if ( *p >= 'a' && *p <= 'z' ) + dv = *p - 'a' + 10; + else + dv = *p - 'A' + 10; + } + if ( val > max_mult || (val == max_mult && dv > (ULLONG_MAX%base)) ) + goto bye; + val = base*val + dv; + p++; + } + + while ( l && p->isSpace() ) // skip trailing space + l--,p++; + if ( !l ) + is_ok = TRUE; +bye: + if ( ok ) + *ok = is_ok; + return is_ok ? val : 0; +} + + +/*! Returns the string converted to a <code>short</code> value. If \a ok is non-null, \a *ok is set to TRUE if there are no |