forked from qt-creator/qt-creator
Update mime database from Qt
qtbase/27db859c6a36738d5074f59584ba7d2b289d1ae4 Use QtMiscUtils hex/oct-related helpers Change-Id: I9c3a1c7ffb119bc0799553c0506f3e76a5439089 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -18,6 +18,13 @@ static bool isOctalDigit(char32_t c) noexcept
|
||||
{
|
||||
return c >= '0' && c <= '7';
|
||||
}
|
||||
static int fromHex(char32_t c) noexcept
|
||||
{
|
||||
return ((c >= '0') && (c <= '9')) ? int(c - '0') :
|
||||
((c >= 'A') && (c <= 'F')) ? int(c - 'A' + 10) :
|
||||
((c >= 'a') && (c <= 'f')) ? int(c - 'a' + 10) :
|
||||
/* otherwise */ -1;
|
||||
}
|
||||
|
||||
// in the same order as Type!
|
||||
static const char magicRuleTypes_string[] =
|
||||
@@ -153,12 +160,8 @@ static inline QByteArray makePattern(const QByteArray &value)
|
||||
char c = 0;
|
||||
for (int i = 0; i < 2 && p + 1 < e; ++i) {
|
||||
++p;
|
||||
if (*p >= '0' && *p <= '9')
|
||||
c = (c << 4) + *p - '0';
|
||||
else if (*p >= 'a' && *p <= 'f')
|
||||
c = (c << 4) + *p - 'a' + 10;
|
||||
else if (*p >= 'A' && *p <= 'F')
|
||||
c = (c << 4) + *p - 'A' + 10;
|
||||
if (const int h = fromHex(*p); h != -1)
|
||||
c = (c << 4) + h;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
Reference in New Issue
Block a user