From 4f28ec6c8526d754849bd26c55e4c5faf61f4eb0 Mon Sep 17 00:00:00 2001
From: Fabian Vogt <fabian@ritter-vogt.de>
Date: Thu, 14 Mar 2019 10:32:10 +0100
Subject: [PATCH 2/3] Revert "qtlite: Fix build libs with
 -no-feature-regularexpression"

This reverts commit 3b514f853595c686d4ed8830567c1f27ea533faf.

Adjusted to apply on top of v5.12.7.
---
 src/corelib/kernel/qvariant.cpp                      |  4 ----
 src/corelib/serialization/qcborvalue.cpp             | 12 ------------
 src/corelib/serialization/qcborvalue.h               | 10 +---------
 src/corelib/serialization/qjsoncbor.cpp              |  7 -------
 .../xcb/gl_integrations/xcb_glx/qglxintegration.cpp  |  6 +-----
 src/testlib/qtaptestlogger.cpp                       | 11 +----------
 7 files changed, 4 insertions(+), 50 deletions(-)
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index 090436a3..6541b975 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1052,13 +1052,11 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
         return false;
 
 #ifndef QT_BOOTSTRAPPED
-#if QT_CONFIG(regularexpression)
     case QMetaType::QRegularExpression:
         if (d->type != QMetaType::QCborValue || !v_cast<QCborValue>(d)->isRegularExpression())
             return false;
         *static_cast<QRegularExpression *>(result) = v_cast<QCborValue>(d)->toRegularExpression();
         break;
-#endif
     case QMetaType::QJsonValue:
         switch (d->type) {
         case QMetaType::Nullptr:
@@ -1234,11 +1232,9 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
         case QVariant::Url:
             *static_cast<QCborValue *>(result) = QCborValue(*v_cast<QUrl>(d));
             break;
-#if QT_CONFIG(regularexpression)
         case QVariant::RegularExpression:
             *static_cast<QCborValue *>(result) = QCborValue(*v_cast<QRegularExpression>(d));
             break;
-#endif
         case QVariant::Uuid:
             *static_cast<QCborValue *>(result) = QCborValue(*v_cast<QUuid>(d));
             break;
diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp
index 80ef515f..e53b6a03 100644
--- a/src/corelib/serialization/qcborvalue.cpp
+++ b/src/corelib/serialization/qcborvalue.cpp
@@ -1771,7 +1771,6 @@ QCborValue::QCborValue(const QUrl &url)
     container->elements[1].type = String;
 }
 
-#if QT_CONFIG(regularexpression)
 /*!
     Creates a QCborValue object of the regular expression pattern extended type
     and containing the value represented by \a rx. The value can later be retrieved
@@ -1790,7 +1789,6 @@ QCborValue::QCborValue(const QRegularExpression &rx)
     // change type
     t = RegularExpression;
 }
-#endif // QT_CONFIG(regularexpression)
 
 /*!
     Creates a QCborValue object of the UUID extended type and containing the
@@ -1944,7 +1942,6 @@ QUrl QCborValue::toUrl(const QUrl &defaultValue) const
     return QUrl::fromEncoded(byteData->asByteArrayView());
 }
 
-#if QT_CONFIG(regularexpression)
 /*!
     Returns the regular expression value stored in this QCborValue, if it is of
     the regular expression pattern extended type. Otherwise, it returns \a
@@ -1963,7 +1960,6 @@ QRegularExpression QCborValue::toRegularExpression(const QRegularExpression &def
     Q_ASSERT(n == -1);
     return QRegularExpression(container->stringAt(1));
 }
-#endif // QT_CONFIG(regularexpression)
 
 /*!
     Returns the UUID value stored in this QCborValue, if it is of the UUID
@@ -2404,16 +2400,12 @@ uint qHash(const QCborValue &value, uint seed)
         return qHash(value.toDateTime(), seed);
     case QCborValue::Url:
         return qHash(value.toUrl(), seed);
-#if QT_CONFIG(regularexpression)
     case QCborValue::RegularExpression:
         return qHash(value.toRegularExpression(), seed);
-#endif
     case QCborValue::Uuid:
         return qHash(value.toUuid(), seed);
     case QCborValue::Invalid:
         return seed;
-    default:
-        break;
     }
 
     Q_ASSERT(value.isSimpleType());
@@ -2458,16 +2450,12 @@ static QDebug debugContents(QDebug &dbg, const QCborValue &v)
         return dbg << v.toDateTime();
     case QCborValue::Url:
         return dbg << v.toUrl();
-#if QT_CONFIG(regularexpression)
     case QCborValue::RegularExpression:
         return dbg << v.toRegularExpression();
-#endif
     case QCborValue::Uuid:
         return dbg << v.toUuid();
     case QCborValue::Invalid:
         return dbg << "<invalid>";
-    default:
-        break;
     }
     if (v.isSimpleType())
         return dbg << v.toSimpleType();
diff --git a/src/corelib/serialization/qcborvalue.h b/src/corelib/serialization/qcborvalue.h
index d6ba4e88..105af1ba 100644
--- a/src/corelib/serialization/qcborvalue.h
+++ b/src/corelib/serialization/qcborvalue.h
@@ -43,9 +43,7 @@
 #include <QtCore/qbytearray.h>
 #include <QtCore/qdatetime.h>
 #include <QtCore/qcborcommon.h>
-#if QT_CONFIG(regularexpression)
-#  include <QtCore/qregularexpression.h>
-#endif
+#include <QtCore/qregularexpression.h>
 #include <QtCore/qstring.h>
 #include <QtCore/qstringview.h>
 #include <QtCore/qurl.h>
@@ -157,9 +155,7 @@ public:
 
     explicit QCborValue(const QDateTime &dt);
     explicit QCborValue(const QUrl &url);
-#if QT_CONFIG(regularexpression)
     explicit QCborValue(const QRegularExpression &rx);
-#endif
     explicit QCborValue(const QUuid &uuid);
 
     ~QCborValue() { if (container) dispose(); }
@@ -237,9 +233,7 @@ public:
     QString toString(const QString &defaultValue = {}) const;
     QDateTime toDateTime(const QDateTime &defaultValue = {}) const;
     QUrl toUrl(const QUrl &defaultValue = {}) const;
-#if QT_CONFIG(regularexpression)
     QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const;
-#endif
     QUuid toUuid(const QUuid &defaultValue = {}) const;
 
 #ifdef Q_QDOC
@@ -386,10 +380,8 @@ public:
     { return concrete().toDateTime(defaultValue); }
     QUrl toUrl(const QUrl &defaultValue = {}) const
     { return concrete().toUrl(defaultValue); }
-#if QT_CONFIG(regularexpression)
     QRegularExpression toRegularExpression(const QRegularExpression &defaultValue = {}) const
     { return concrete().toRegularExpression(defaultValue); }
-#endif
     QUuid toUuid(const QUuid &defaultValue = {}) const
     { return concrete().toUuid(defaultValue); }
 
diff --git a/src/corelib/serialization/qjsoncbor.cpp b/src/corelib/serialization/qjsoncbor.cpp
index 4603750d..aad7c1e5 100644
--- a/src/corelib/serialization/qjsoncbor.cpp
+++ b/src/corelib/serialization/qjsoncbor.cpp
@@ -543,19 +543,14 @@ QVariant QCborValue::toVariant() const
     case Url:
         return toUrl();
 
-#if QT_CONFIG(regularexpression)
     case RegularExpression:
         return toRegularExpression();
-#endif
 
     case Uuid:
         return toUuid();
 
     case Invalid:
         return QVariant();
-
-    default:
-        break;
     }
 
     if (isSimpleType())
@@ -721,10 +716,8 @@ QCborValue QCborValue::fromVariant(const QVariant &variant)
     case QVariant::Hash:
         return QCborMap::fromVariantHash(variant.toHash());
 #ifndef QT_BOOTSTRAPPED
-#if QT_CONFIG(regularexpression)
     case QVariant::RegularExpression:
         return QCborValue(variant.toRegularExpression());
-#endif
     case QMetaType::QJsonValue:
         return fromJsonValue(variant.toJsonValue());
     case QMetaType::QJsonObject:
diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
index cdce77f5..70f83a07 100644
--- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
+++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/qglxintegration.cpp
@@ -48,9 +48,7 @@
 #undef register
 #include <GL/glx.h>
 
-#if QT_CONFIG(regularexpression)
-#  include <QtCore/QRegularExpression>
-#endif
+#include <QtCore/QRegularExpression>
 #include <QtGui/QOpenGLContext>
 #include <QtGui/QOffscreenSurface>
 
@@ -728,7 +726,6 @@ void QGLXContext::queryDummyContext()
             // The issue was fixed in Xcb 1.11, but we can't check for that
             // at runtime, so instead assume it fixed with recent Mesa versions
             // released several years after the Xcb fix.
-#if QT_CONFIG(regularexpression)
             QRegularExpression versionTest(QStringLiteral("Mesa (\\d+)"));
             QRegularExpressionMatch result = versionTest.match(QString::fromLatin1(mesaVersionStr));
             int versionNr = 0;
@@ -738,7 +735,6 @@ void QGLXContext::queryDummyContext()
                 // White-listed
                 m_supportsThreading = true;
             }
-#endif
         }
         if (!m_supportsThreading) {
             qCDebug(lcQpaGl).nospace() << "Multithreaded OpenGL disabled: "
diff --git a/src/testlib/qtaptestlogger.cpp b/src/testlib/qtaptestlogger.cpp
index 540b36e2..e73609de 100644
--- a/src/testlib/qtaptestlogger.cpp
+++ b/src/testlib/qtaptestlogger.cpp
@@ -43,9 +43,7 @@
 #include "qtestresult_p.h"
 #include "qtestassert.h"
 
-#if QT_CONFIG(regularexpression)
-#  include <QtCore/qregularexpression.h>
-#endif
+#include <QtCore/qregularexpression.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -150,7 +148,6 @@ void QTapTestLogger::addIncident(IncidentTypes type, const char *description,
         outputString(YAML_INDENT "---\n");
 
         if (type != XFail) {
-#if QT_CONFIG(regularexpression)
             // This is fragile, but unfortunately testlib doesn't plumb
             // the expected and actual values to the loggers (yet).
             static QRegularExpression verifyRegex(
@@ -211,12 +208,6 @@ void QTapTestLogger::addIncident(IncidentTypes type, const char *description,
                     YAML_INDENT "# %s\n", description);
                 outputString(unparsableDescription.data());
             }
-#else
-            QTestCharBuffer unparsableDescription;
-            QTest::qt_asprintf(&unparsableDescription,
-                YAML_INDENT "# %s\n", description);
-            outputString(unparsableDescription.data());
-#endif
         }
 
         if (file) {
