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:
Eike Ziller
2024-08-27 12:52:02 +02:00
parent 9bd1789e2f
commit cfb6653854

View File

@@ -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;
}