diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-03-18 11:19:19 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-03-25 09:34:37 +0100 |
commit | 53f8f233692b6f9cd622eafbf669c5f8bdb0a25d (patch) | |
tree | cd36fdd81e8bb67d5c860e01d9b47979a0a48e13 | |
parent | a7fe1af609e905f6e5fbf291ec43261a41d9541f (diff) |
Get rid of QRegExp usage in rcc
As a drive-by, enable testing of rcc in the cmake build.
Change-Id: I4150ff3ffe7404bab0cbc72f80b23b47a60cf33d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
-rw-r--r-- | src/tools/rcc/rcc.cpp | 13 | ||||
-rw-r--r-- | tests/auto/tools/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/tools/rcc/CMakeLists.txt | 66 |
3 files changed, 78 insertions, 3 deletions
diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 808208573a..8b1ebad14c 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -37,7 +37,6 @@ #include <qfile.h> #include <qiodevice.h> #include <qlocale.h> -#include <qregexp.h> #include <qstack.h> #include <qxmlstream.h> @@ -1362,7 +1361,17 @@ bool RCCResourceLibrary::writeInitializer() QString initNameStr = m_initName; if (!initNameStr.isEmpty()) { initNameStr.prepend(QLatin1Char('_')); - initNameStr.replace(QRegExp(QLatin1String("[^a-zA-Z0-9_]")), QLatin1String("_")); + auto isAsciiLetterOrNumber = [] (QChar c) -> bool { + ushort ch = c.unicode(); + return (ch >= '0' && ch <= '9') || + (ch >= 'A' && ch <= 'Z') || + (ch >= 'a' && ch <= 'z') || + ch == '_'; + }; + for (QChar &c : initNameStr) { + if (!isAsciiLetterOrNumber(c)) + c = QLatin1Char('_'); + } } QByteArray initName = initNameStr.toLatin1(); diff --git a/tests/auto/tools/CMakeLists.txt b/tests/auto/tools/CMakeLists.txt index aa45587993..048051663d 100644 --- a/tests/auto/tools/CMakeLists.txt +++ b/tests/auto/tools/CMakeLists.txt @@ -7,7 +7,7 @@ if(NOT WIN32) # @todo: this is broken, see QTBUG-78449 endif() # special case end #add_subdirectory(moc) -#add_subdirectory(rcc) +add_subdirectory(rcc) if(TARGET Qt::Widgets) add_subdirectory(uic) endif() diff --git a/tests/auto/tools/rcc/CMakeLists.txt b/tests/auto/tools/rcc/CMakeLists.txt new file mode 100644 index 0000000000..06d62244ff --- /dev/null +++ b/tests/auto/tools/rcc/CMakeLists.txt @@ -0,0 +1,66 @@ +# Generated from rcc.pro. + +##################################################################### +## tst_rcc Test: +##################################################################### + +qt_add_test(tst_rcc + SOURCES + tst_rcc.cpp +) + +# Resources: +set(images_resource_files + "images/circle.png" + "images/square.png" + "images/subdir/triangle.png" +) + +qt_add_resource(tst_rcc "images" + PREFIX + "/" + BASE + "data/images" + FILES + ${images_resource_files} +) +set(size-0_resource_files + "data/data-0.txt" +) + +qt_add_resource(tst_rcc "size-0" + PREFIX + "/" + BASE + "data/sizes" + FILES + ${size-0_resource_files} +) +set(size-2-0-35-1_resource_files + "data/data-0.txt" + "data/data-1.txt" + "data/data-2.txt" + "data/data-35.txt" +) + +qt_add_resource(tst_rcc "size-2-0-35-1" + PREFIX + "/" + BASE + "data/sizes" + FILES + ${size-2-0-35-1_resource_files} +) +set(size-1_resource_files + "data/data-1.txt" +) + +qt_add_resource(tst_rcc "size-1" + PREFIX + "/" + BASE + "data/sizes" + FILES + ${size-1_resource_files} +) + |