Fix integer overflow (1 << (' ' - 1))
On platforms where integer by default is int32(max is 2147483647) and
(1 << (' ' - 1)) will be 2147483648
Change-Id: I790d33bd4e473925d6897dd87cbffdfe8dd7938f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
parent
4160315fb5
commit
28f9b35b35
|
|
@ -419,15 +419,15 @@ QString qt_readEscapedFormatString(QStringView format, int *idx);
|
|||
bool qt_splitLocaleName(const QString &name, QString &lang, QString &script, QString &cntry);
|
||||
int qt_repeatCount(QStringView s);
|
||||
|
||||
enum { AsciiSpaceMask = (1 << (' ' - 1)) |
|
||||
(1 << ('\t' - 1)) | // 9: HT - horizontal tab
|
||||
(1 << ('\n' - 1)) | // 10: LF - line feed
|
||||
(1 << ('\v' - 1)) | // 11: VT - vertical tab
|
||||
(1 << ('\f' - 1)) | // 12: FF - form feed
|
||||
(1 << ('\r' - 1)) }; // 13: CR - carriage return
|
||||
enum { AsciiSpaceMask = (1u << (' ' - 1)) |
|
||||
(1u << ('\t' - 1)) | // 9: HT - horizontal tab
|
||||
(1u << ('\n' - 1)) | // 10: LF - line feed
|
||||
(1u << ('\v' - 1)) | // 11: VT - vertical tab
|
||||
(1u << ('\f' - 1)) | // 12: FF - form feed
|
||||
(1u << ('\r' - 1)) }; // 13: CR - carriage return
|
||||
Q_DECL_CONSTEXPR inline bool ascii_isspace(uchar c)
|
||||
{
|
||||
return c >= 1U && c <= 32U && (uint(AsciiSpaceMask) >> uint(c - 1)) & 1U;
|
||||
return c >= 1u && c <= 32u && (AsciiSpaceMask >> uint(c - 1)) & 1u;
|
||||
}
|
||||
|
||||
#if defined(Q_COMPILER_CONSTEXPR)
|
||||
|
|
|
|||
Loading…
Reference in New Issue