From eafad93c3da9fae0e0445393a5a8d90348ae2e13 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Wed, 31 Oct 2018 15:15:02 +0100 Subject: Make util/lexgen/ mention itself in its auto-gen line In the process, update the README's e-mail address for Simon and mention all recognized command-line options in the usage message. The generated CSS scanner was also out of sync with our source, so update it. Also fixed handling of FileHeader to cope with running from a shadow build by handling paths relative to __FILE__; and revised the CSS3 config to use the same copyright header as was already in use by the existing generated file. Change-Id: I918ff84dbdc95d0478fd6aa4ea74e9a221d1a476 Reviewed-by: Simon Hausmann --- util/lexgen/README | 3 +-- util/lexgen/css3-simplified.lexgen | 2 +- util/lexgen/generator.cpp | 15 +++++++++------ util/lexgen/main.cpp | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) (limited to 'util') diff --git a/util/lexgen/README b/util/lexgen/README index 435c7f31ee..005b77b81c 100644 --- a/util/lexgen/README +++ b/util/lexgen/README @@ -11,6 +11,5 @@ you want. But I like that it generates code that operates on QChar and friends. Use at your own risk ;-) - -- -Simon Hausmann +Simon Hausmann diff --git a/util/lexgen/css3-simplified.lexgen b/util/lexgen/css3-simplified.lexgen index 99463d524e..d86a4786be 100644 --- a/util/lexgen/css3-simplified.lexgen +++ b/util/lexgen/css3-simplified.lexgen @@ -5,7 +5,7 @@ classname = QCssScanner_Generated [Code Generator Options] MapToCode[a-z] = (ch.unicode() >= 'a' && ch.unicode() <= 'z') || (ch.unicode() >= 'A' && ch.unicode() <= 'Z') || ch.unicode() >= 256 TokenPrefix = QCss:: -FileHeader = ../../src/tools/moc/util/licenseheader.txt +FileHeader = ../../header.LGPL [Macros] escape = \\[^\r\n\f0-9a-f] diff --git a/util/lexgen/generator.cpp b/util/lexgen/generator.cpp index edd2b603e7..481d586e73 100644 --- a/util/lexgen/generator.cpp +++ b/util/lexgen/generator.cpp @@ -29,6 +29,7 @@ #include "generator.h" #include +#include void Function::printDeclaration(CodeBlock &block, const QString &funcNamePrefix) const { @@ -505,14 +506,16 @@ QString Generator::generate() klass.addMember(Class::PublicMember, lexFunc); QString header; - QFile headerFile(headerFileName); - if (!headerFileName.isEmpty() - && headerFile.exists() - && headerFile.open(QIODevice::ReadOnly)) { - header = QString::fromUtf8(headerFile.readAll()); + if (!headerFileName.isEmpty()) { + QString self(QDir::fromNativeSeparators(QStringLiteral(__FILE__))); + int lastSep = self.lastIndexOf(QChar('/')); + QDir here(lastSep < 0 ? QStringLiteral(".") : self.left(lastSep)); + QFile headerFile(QDir::cleanPath(here.filePath(headerFileName))); + if (headerFile.exists() && headerFile.open(QIODevice::ReadOnly)) + header = QString::fromUtf8(headerFile.readAll()); } - header += QLatin1String("// auto generated. DO NOT EDIT.\n"); + header += QLatin1String("// auto generated by qtbase/util/lexgen/. DO NOT EDIT.\n"); return header + klass.declaration() + klass.definition(); } diff --git a/util/lexgen/main.cpp b/util/lexgen/main.cpp index 22b99b633c..517629f4c1 100644 --- a/util/lexgen/main.cpp +++ b/util/lexgen/main.cpp @@ -256,7 +256,7 @@ int main(int argc, char **argv) } if (ruleFile.isEmpty()) { - qWarning("usage: lexgen [-test rulefile"); + qWarning("usage: lexgen [-debug] [-cache] [-test] rulefile"); qWarning(" "); qWarning(" the -test option will cause lexgen to interpret standard input"); qWarning(" according to the specified rules and print out pairs of token and"); -- cgit v1.2.3 From d38f635355dded964ce14de6160fb897e5d6b40d Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 19 Oct 2018 15:33:34 +0200 Subject: Clean up and update Unicode character data 3rd-party infrastructure Document how to do an update, fix the bit-rot that had crept into main.cpp since last it was compiled, correct the qt_attribution.json to use the actual version number of UCD (its Revision number) instead of the (admittedly correlated) Unicode release number. Updated to Release 22 (which came with Unicode 11.0.0) in the process; but this doesn't change our actual qunicodetables.cpp (so is incidental). Task-number: QTBUG-71281 Change-Id: Ieb7a6e1a4d49f639993f76ff82c8f12a572db3c3 Reviewed-by: Thiago Macieira Reviewed-by: Lars Knoll --- util/unicode/README | 31 +++++++++++++++++++++++++++++++ util/unicode/main.cpp | 11 ++++------- 2 files changed, 35 insertions(+), 7 deletions(-) (limited to 'util') diff --git a/util/unicode/README b/util/unicode/README index ca34266a36..e52f26175a 100644 --- a/util/unicode/README +++ b/util/unicode/README @@ -1 +1,32 @@ Unicode is used to generate the unicode data in src/corelib/tools. + +To update: +* Find the data (UAX #44, UCD; not the XML version) at + ftp://www.unicode.org/Public/zipped/$Version/ +* Unpack the zip file; for each file in data/, replace with the new + version; find the *BreakProperty.txt in auxiliary/. (These last are + only in the zip, not in the web-space's unpacked versions.) +* If needed, add an entry to enum QChar::UnicodeVersion for the new + Unicode version +* In that case, also update main.cpp's initAgeMap and DATA_VERSION_S* + to match +* Build this project. Its binary, unicode, ignores command-line + options and assumes it is being run from this directory. When run, + it produces lots of output. Hopefully that doesn't matter. +* Assertions may trigger: if so, study code and understand what's more + complicated about this update; talk to folk named in the git logs, + maybe push a WIP to gerrit to solicit advice. Some bit-field may + need to be expanded, for example. In some cases QChar may need + additions to some of its enums. +* Build with the modified code, fix any compilation issues. +* That may have updated qtbase/src/corelib/tools/qunicodetables.cpp; + if so the update matters; be sure to commit the changes to data/ at + the same time and update tools/qt_attribution.json to match; use the + UCD Revision number, rather than the Unicode standard number, as the + Version, for all that qunicodetables.cpp uses the latter. + +The script writingSystems.sh generates a list of writing systems, +ostensibly as a the basis for updating QFontDatabase::WritingSystem +enum; however, the Release 20 output of it contains many more writing +systems than are present in that enum, suggesting it has not been run +in a very long time. Further research needed. diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 0c3c0b2ee1..00c69de008 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -78,7 +78,6 @@ static void initAgeMap() } } - static QHash categoryMap; static void initCategoryMap() @@ -778,7 +777,6 @@ static void initScriptMap() { QChar::Script_Soyombo, "Soyombo" }, { QChar::Script_ZanabazarSquare, "ZanabazarSquare" }, - // unhandled { QChar::Script_Unknown, 0 } }; @@ -789,7 +787,6 @@ static void initScriptMap() } } - // Keep this one in sync with the code in createPropertyInfo static const char *property_string = "struct Properties {\n" @@ -2473,9 +2470,9 @@ static QByteArray createPropertyInfo() out += ", "; out += QByteArray::number( p.lowerCaseDiff ); out += ", "; - out += "#ifdef Q_OS_WASM \n" + out += "#ifdef Q_OS_WASM \n"; // " unsigned char : 0; //wasm 64 packing trick QTBUG-65259\n" - out += "#endif \n" + out += "#endif \n"; out += ", "; // " ushort upperCaseSpecial : 1;\n" // " signed short upperCaseDiff : 15;\n" @@ -2501,9 +2498,9 @@ static QByteArray createPropertyInfo() // " ushort nfQuickCheck : 8;\n" out += QByteArray::number( p.nfQuickCheck ); out += ", "; - out += "#ifdef Q_OS_WASM \n" + out += "#ifdef Q_OS_WASM \n"; // " unsigned char : 0; //wasm 64 packing trick QTBUG-65259\n" - out += "#endif \n" + out += "#endif \n"; out += ", "; // " ushort graphemeBreakClass : 5; /* 5 used */\n" // " ushort wordBreakClass : 5; /* 5 used */\n" -- cgit v1.2.3 From 8fe36801930872ef4a57e2ff7d7f935de12a33e9 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 1 Feb 2019 15:16:00 +0100 Subject: Add cmdline feature to qmake [ChangeLog][qmake] A new feature "cmdline" was added that implies "CONFIG += console" and "CONFIG -= app_bundle". Task-number: QTBUG-27079 Change-Id: I6e52b07c9341c904bb1424fc717057432f9360e1 Reviewed-by: Oswald Buddenhagen --- util/glgen/glgen.pro | 3 +-- util/gradientgen/tobinaryjson.pro | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'util') diff --git a/util/glgen/glgen.pro b/util/glgen/glgen.pro index 11018e942d..22c377e5f1 100644 --- a/util/glgen/glgen.pro +++ b/util/glgen/glgen.pro @@ -1,6 +1,5 @@ QT -= gui -CONFIG += console -CONFIG -= app_bundle +CONFIG += cmdline # Uncomment following to enable debug output #DEFINES += SPECPARSER_DEBUG diff --git a/util/gradientgen/tobinaryjson.pro b/util/gradientgen/tobinaryjson.pro index 8ed3509278..8aa9d0d008 100644 --- a/util/gradientgen/tobinaryjson.pro +++ b/util/gradientgen/tobinaryjson.pro @@ -1,4 +1,3 @@ SOURCES += tobinaryjson.cpp QT = core -CONFIG += console -CONFIG -= app_bundle +CONFIG += cmdline -- cgit v1.2.3 From 85b0ce8ca36d52db71b519ee8d2a1ce369c53a81 Mon Sep 17 00:00:00 2001 From: Robert Loehning Date: Mon, 25 Feb 2019 13:54:26 +0100 Subject: Fix can not -> cannot Change-Id: Ie9992f67ca59aff662a4be046ace08640e7c2714 Reviewed-by: Paul Wicking --- util/local_database/xpathlite.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'util') diff --git a/util/local_database/xpathlite.py b/util/local_database/xpathlite.py index b3f8325569..218135d7a7 100644 --- a/util/local_database/xpathlite.py +++ b/util/local_database/xpathlite.py @@ -257,7 +257,7 @@ def findEntry(base, path, draft=None, attribute=None): if result: return result if not aliaspath: - raise Error("findEntry: fatal error: %s: can not find key %s" % (filename, path)) + raise Error("findEntry: fatal error: %s: cannot find key %s" % (filename, path)) path = aliaspath return result -- cgit v1.2.3 From f9421f0968b8067ca79d83dc75e35092ac4a4948 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 26 Feb 2019 11:33:13 +0100 Subject: Adjust chunk-size in TLD-suffix list to placate MSVC 2015 MSVC 2015 has a size limit on strings; sizeof (including the terminating '\0') must not exceed 0xffff. The generator for the suffix-list data worked round this by breaking its data into chunks of at most 0xffff bytes; however, it was limiting on the strlen, not the sizeof, so was off by one. It checked for this before adding each suffix, so has (until now) always happened to break early enough; but the latest update gave an exactly 0xffff chunk, whose terminating '\0' took it over MSVC's limit. So adjust the cutoff to effectively include the terminating '\0'. Task-number: QTBUG-72623 Change-Id: I76ea40060d9fc13c0f7002c5ba22e71b8d0af787 Reviewed-by: Peter Hartmann --- util/corelib/qurl-generateTLDs/main.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'util') diff --git a/util/corelib/qurl-generateTLDs/main.cpp b/util/corelib/qurl-generateTLDs/main.cpp index 006eaf92b1..7268fb077a 100644 --- a/util/corelib/qurl-generateTLDs/main.cpp +++ b/util/corelib/qurl-generateTLDs/main.cpp @@ -113,7 +113,7 @@ int main(int argc, char **argv) { outIndicesBuffer.write("] = {\n"); int totalUtf8Size = 0; - int chunkSize = 0; + int chunkSize = 0; // strlen of the current chunk (sizeof is bigger by 1) int stringUtf8Size = 0; QStringList chunks; for (int a = 0; a < lineCount; a++) { @@ -127,7 +127,8 @@ int main(int argc, char **argv) { int quoteCount = strings.at(a).count('"'); stringUtf8Size = strings.at(a).count() - (zeroCount + quoteCount + utf8CharsCount * 3); chunkSize += stringUtf8Size; - if (chunkSize > 65535) { + // MSVC 2015 chokes if sizeof(a single string) > 0xffff + if (chunkSize >= 0xffff) { static int chunkCount = 0; qWarning() << "chunk" << ++chunkCount << "has length" << chunkSize - stringUtf8Size; outDataBuffer.write(",\n\n"); -- cgit v1.2.3 From e59ba35f1b1954062266164f7b802076dc152c7b Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 18 Mar 2019 08:27:22 +0100 Subject: Wasm: Add workaround for Emscripten compiler again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This work around was added directly to the generated files at some point, and never to the generator it seems. So to avoid removing the workaround again when we regenerate the next time, we need to add it. Task-number: QTBUG-74511 Change-Id: Ided1bd949234ba82df61c55891646823e7f72e80 Reviewed-by: Morten Johan Sørvig --- util/unicode/main.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'util') diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 00c69de008..1dbfa2cef0 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -798,6 +798,9 @@ static const char *property_string = " signed short mirrorDiff : 16;\n" " ushort lowerCaseSpecial : 1;\n" " signed short lowerCaseDiff : 15;\n" + "#ifdef Q_OS_WASM\n" + " unsigned char : 0; //wasm 64 packing trick\n" + "#endif\n" " ushort upperCaseSpecial : 1;\n" " signed short upperCaseDiff : 15;\n" " ushort titleCaseSpecial : 1;\n" @@ -806,6 +809,9 @@ static const char *property_string = " signed short caseFoldDiff : 15;\n" " ushort unicodeVersion : 8; /* 5 used */\n" " ushort nfQuickCheck : 8;\n" // could be narrowed + "#ifdef Q_OS_WASM\n" + " unsigned char : 0; //wasm 64 packing trick\n" + "#endif\n" " ushort graphemeBreakClass : 5; /* 5 used */\n" " ushort wordBreakClass : 5; /* 5 used */\n" " ushort sentenceBreakClass : 8; /* 4 used */\n" -- cgit v1.2.3 From 01380dc2673d1aecc3e216fff84da76223e447d7 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 15 Mar 2019 13:04:22 +0100 Subject: Remove broken code from unicode generator The current state produces uncompilable code. Change-Id: I9a68b61866a4a416335ed4d7204c58122803fb1c Reviewed-by: Eskil Abrahamsen Blomfeldt --- util/unicode/main.cpp | 8 -------- 1 file changed, 8 deletions(-) (limited to 'util') diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 1dbfa2cef0..22a4405ca9 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -2476,10 +2476,6 @@ static QByteArray createPropertyInfo() out += ", "; out += QByteArray::number( p.lowerCaseDiff ); out += ", "; - out += "#ifdef Q_OS_WASM \n"; -// " unsigned char : 0; //wasm 64 packing trick QTBUG-65259\n" - out += "#endif \n"; - out += ", "; // " ushort upperCaseSpecial : 1;\n" // " signed short upperCaseDiff : 15;\n" out += QByteArray::number( p.upperCaseSpecial ); @@ -2504,10 +2500,6 @@ static QByteArray createPropertyInfo() // " ushort nfQuickCheck : 8;\n" out += QByteArray::number( p.nfQuickCheck ); out += ", "; - out += "#ifdef Q_OS_WASM \n"; -// " unsigned char : 0; //wasm 64 packing trick QTBUG-65259\n" - out += "#endif \n"; - out += ", "; // " ushort graphemeBreakClass : 5; /* 5 used */\n" // " ushort wordBreakClass : 5; /* 5 used */\n" // " ushort sentenceBreakClass : 8; /* 4 used */\n" -- cgit v1.2.3 From c0ab2ad98f5c3907be032dc4de938ba5d88e697d Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 22 Feb 2019 17:49:45 +0100 Subject: Clean up and document the generator for qurltld_p.h This scans the public suffix list and emits suitable content for the header. Made some modest efficiency gains while hopefully making the code easier to understand. Check for success when opening files. Change-Id: If6b25c5c85f86209b33d9188743e820690e7dc05 Reviewed-by: Timur Pocheptsov --- util/corelib/qurl-generateTLDs/main.cpp | 163 +++++++++++++++++++------------- 1 file changed, 96 insertions(+), 67 deletions(-) (limited to 'util') diff --git a/util/corelib/qurl-generateTLDs/main.cpp b/util/corelib/qurl-generateTLDs/main.cpp index 7268fb077a..6fde287049 100644 --- a/util/corelib/qurl-generateTLDs/main.cpp +++ b/util/corelib/qurl-generateTLDs/main.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2016 The Qt Company Ltd. +** Copyright (C) 2019 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the utils of the Qt Toolkit. @@ -28,33 +28,66 @@ #include +const QString quadQuote = QStringLiteral("\"\""); // Closes one string, opens a new one. + static QString utf8encode(const QByteArray &array) // turns e.g. tranøy.no to tran\xc3\xb8y.no { QString result; result.reserve(array.length() + array.length() / 3); + bool wasHex = false; for (int i = 0; i < array.length(); ++i) { char c = array.at(i); // if char is non-ascii, escape it if (c < 0x20 || uchar(c) >= 0x7f) { result += "\\x" + QString::number(uchar(c), 16); + wasHex = true; } else { // if previous char was escaped, we need to make sure the next char is not // interpreted as part of the hex value, e.g. "äc.com" -> "\xabc.com"; this // should be "\xab""c.com" - QRegExp hexEscape("\\\\x[a-fA-F0-9][a-fA-F0-9]$"); bool isHexChar = ((c >= '0' && c <= '9') || - (c >= 'a' && c <= 'f') || - (c >= 'A' && c <= 'F')); - if (result.contains(hexEscape) && isHexChar) - result += "\"\""; + (c >= 'a' && c <= 'f') || + (c >= 'A' && c <= 'F')); + if (wasHex && isHexChar) + result += quadQuote; result += c; + wasHex = false; } } return result; } -int main(int argc, char **argv) { +/* + Digest public suffix data into efficiently-searchable form. + + Takes the public suffix list (see usage message), a list of DNS domains + whose child domains should not be presumed to trust one another, and + converts it to a form that lets qtbase/src/corelib/io/qtldurl.cpp's query + functions find entries efficiently. + + Each line of the suffix file (aside from comments and blanks) gives a suffix + (starting with a dot) with an optional prefix of '*' (to include every + immediate child) or of '!' (to exclude the suffix, e.g. from a '*' line for + a tail of it). A line with neither of these prefixes is an exact match. + + Each line is hashed and the hash is reduced modulo the number of lines + (tldCount); lines are grouped by reduced hash and separated by '\0' bytes + within each group. Conceptually, the groups are then emitted to a single + huge string, along with a table (tldIndices[tldCount]) of indices into that + string of the starts of the the various groups. + + However, that huge string would exceed the 64k limit at least one compiler + imposes on a single string literal, so we actually split up the huge string + into an array of chunks, each less than 64k in size. Each group is written + to a single chunk (so we start a new chunk if the next group would take the + present chunk over the limit). There are tldChunkCount chunks; their lengths + are saved in tldChunks[tldChunkCount]; the chunks themselves in + tldData[tldChunkCount]. See qtldurl.cpp's containsTLDEntry() for how to + search for a string in the resulting data. +*/ +int main(int argc, char **argv) +{ QCoreApplication app(argc, argv); if (argc < 3) { printf("\nusage: %s inputFile outputFile\n\n", argv[0]); @@ -68,14 +101,20 @@ int main(int argc, char **argv) { exit(1); } QFile file(argv[1]); - QFile outFile(argv[2]); - file.open(QIODevice::ReadOnly); - outFile.open(QIODevice::WriteOnly); + if (!file.open(QIODevice::ReadOnly)) { + fprintf("Failed to open input file (%s); see %s -usage", argv[1], argv[0]); + return 1; + } - QByteArray outIndicesBufferBA; - QBuffer outIndicesBuffer(&outIndicesBufferBA); - outIndicesBuffer.open(QIODevice::WriteOnly); + QFile outFile(argv[2]); + if (!outFile.open(QIODevice::WriteOnly)) { + file.close() + fprintf("Failed to open output file (%s); see %s -usage", argv[2], argv[0]); + return 1; + } + // Write tldData[] and tldIndices[] in one scan of the (input) file, but + // buffer tldData[] so we don'te interleave them in the outFile. QByteArray outDataBufferBA; QBuffer outDataBuffer(&outDataBufferBA); outDataBuffer.open(QIODevice::WriteOnly); @@ -85,75 +124,65 @@ int main(int argc, char **argv) { file.readLine(); lineCount++; } + outFile.write("static const quint16 tldCount = "); + outFile.write(QByteArray::number(lineCount)); + outFile.write(";\n"); + file.reset(); QVector strings(lineCount); while (!file.atEnd()) { - QString s = QString::fromUtf8(file.readLine()); - QString st = s.trimmed(); + QString st = QString::fromUtf8(file.readLine()).trimmed(); int num = qt_hash(st) % lineCount; + QString &entry = strings[num]; + st = utf8encode(st.toUtf8()); - QString utf8String = utf8encode(st.toUtf8()); + // For domain 1.com, we could get something like a.com\01.com, which + // would be misinterpreted as octal 01, so we need to separate such + // strings with quotes: + if (!entry.isEmpty() && st.at(0).isDigit()) + entry.append(quadQuote); - // for domain 1.com, we could get something like - // a.com\01.com, which would be interpreted as octal 01, - // so we need to separate those strings with quotes - QRegExp regexpOctalEscape(QLatin1String("^[0-9]")); - if (!strings.at(num).isEmpty() && st.contains(regexpOctalEscape)) - strings[num].append("\"\""); - - strings[num].append(utf8String); - strings[num].append("\\0"); + entry.append(st); + entry.append("\\0"); } - - outIndicesBuffer.write("static const quint16 tldCount = "); - outIndicesBuffer.write(QByteArray::number(lineCount)); - outIndicesBuffer.write(";\n"); - outIndicesBuffer.write("static const quint32 tldIndices["); -// outIndicesBuffer.write(QByteArray::number(lineCount+1)); // not needed - outIndicesBuffer.write("] = {\n"); + outFile.write("static const quint32 tldIndices[] = {\n"); + outDataBuffer.write("\nstatic const char *tldData[] = {\n"); int totalUtf8Size = 0; int chunkSize = 0; // strlen of the current chunk (sizeof is bigger by 1) - int stringUtf8Size = 0; QStringList chunks; for (int a = 0; a < lineCount; a++) { - bool lineIsEmpty = strings.at(a).isEmpty(); - if (!lineIsEmpty) { - strings[a].prepend("\""); - strings[a].append("\""); - } - int zeroCount = strings.at(a).count(QLatin1String("\\0")); - int utf8CharsCount = strings.at(a).count(QLatin1String("\\x")); - int quoteCount = strings.at(a).count('"'); - stringUtf8Size = strings.at(a).count() - (zeroCount + quoteCount + utf8CharsCount * 3); - chunkSize += stringUtf8Size; - // MSVC 2015 chokes if sizeof(a single string) > 0xffff - if (chunkSize >= 0xffff) { - static int chunkCount = 0; - qWarning() << "chunk" << ++chunkCount << "has length" << chunkSize - stringUtf8Size; - outDataBuffer.write(",\n\n"); - chunks.append(QByteArray::number(totalUtf8Size)); - chunkSize = 0; + outFile.write(QByteArray::number(totalUtf8Size)); + outFile.write(",\n"); + const QString &entry = strings.at(a); + if (!entry.isEmpty()) { + const int zeroCount = entry.count(QLatin1String("\\0")); + const int utf8CharsCount = entry.count(QLatin1String("\\x")); + const int quoteCount = entry.count('"'); + const int stringUtf8Size = entry.count() - (zeroCount + quoteCount + utf8CharsCount * 3); + chunkSize += stringUtf8Size; + // MSVC 2015 chokes if sizeof(a single string) > 0xffff + if (chunkSize >= 0xffff) { + static int chunkCount = 0; + qWarning() << "chunk" << ++chunkCount << "has length" << chunkSize - stringUtf8Size; + outDataBuffer.write(",\n\n"); + chunks.append(QString::number(totalUtf8Size)); + chunkSize = 0; + } + totalUtf8Size += stringUtf8Size; + + outDataBuffer.write("\""); + outDataBuffer.write(entry.toUtf8()); + outDataBuffer.write("\"\n"); } - outDataBuffer.write(strings.at(a).toUtf8()); - if (!lineIsEmpty) - outDataBuffer.write("\n"); - outIndicesBuffer.write(QByteArray::number(totalUtf8Size)); - outIndicesBuffer.write(",\n"); - totalUtf8Size += stringUtf8Size; } - chunks.append(QByteArray::number(totalUtf8Size)); - outIndicesBuffer.write(QByteArray::number(totalUtf8Size)); - outIndicesBuffer.write("};\n"); - outIndicesBuffer.close(); - outFile.write(outIndicesBufferBA); + chunks.append(QString::number(totalUtf8Size)); + outFile.write(QByteArray::number(totalUtf8Size)); + outFile.write("};\n"); + outDataBuffer.write("};\n"); outDataBuffer.close(); - outFile.write("\nstatic const char *tldData["); -// outFile.write(QByteArray::number(charSize)); // not needed - outFile.write("] = {\n"); outFile.write(outDataBufferBA); - outFile.write("};\n"); // write chunk information outFile.write("\nstatic const quint16 tldChunkCount = "); @@ -162,6 +191,6 @@ int main(int argc, char **argv) { outFile.write(chunks.join(", ").toLatin1()); outFile.write("};\n"); outFile.close(); - printf("data generated to %s . Now copy the data from this file to src/corelib/io/qurltlds_p.h in your Qt repo\n", argv[2]); - exit(0); + printf("Data generated to %s - now revise qtbase/src/corelib/io/qurltlds_p.h to use this data.\n", argv[2]); + return 0; } -- cgit v1.2.3 From 95f787bfdc890c259e8b347bdad9123d534efe0f Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Tue, 9 Apr 2019 13:33:15 +0200 Subject: Replace Q_DECL_NOTHROW with noexcept the remaining places The first replacement had missed objective-C++ code some places ourside the src dir. In C-files Q_DECL_NOTHROW is replaced with Q_DECL_NOEXCEPT as we still need to turn it off when compiled in C mode, but can get rid of the old NOTHROW moniker. Change-Id: I6370f57066679c5120d0265a69e7e378e09d4759 Reviewed-by: Thiago Macieira --- util/unicode/main.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'util') diff --git a/util/unicode/main.cpp b/util/unicode/main.cpp index 22a4405ca9..8576f00e35 100644 --- a/util/unicode/main.cpp +++ b/util/unicode/main.cpp @@ -818,8 +818,8 @@ static const char *property_string = " ushort lineBreakClass : 6; /* 6 used */\n" " ushort script : 8;\n" "};\n\n" - "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW;\n" - "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW;\n" + "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) noexcept;\n" + "Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) noexcept;\n" "\n" "struct LowercaseTraits\n" "{\n" @@ -855,20 +855,20 @@ static const char *property_string = "\n"; static const char *methods = - "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) Q_DECL_NOTHROW;\n" - "inline GraphemeBreakClass graphemeBreakClass(QChar ch) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) noexcept;\n" + "inline GraphemeBreakClass graphemeBreakClass(QChar ch) noexcept\n" "{ return graphemeBreakClass(ch.unicode()); }\n" "\n" - "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) Q_DECL_NOTHROW;\n" - "inline WordBreakClass wordBreakClass(QChar ch) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) noexcept;\n" + "inline WordBreakClass wordBreakClass(QChar ch) noexcept\n" "{ return wordBreakClass(ch.unicode()); }\n" "\n" - "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) Q_DECL_NOTHROW;\n" - "inline SentenceBreakClass sentenceBreakClass(QChar ch) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) noexcept;\n" + "inline SentenceBreakClass sentenceBreakClass(QChar ch) noexcept\n" "{ return sentenceBreakClass(ch.unicode()); }\n" "\n" - "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) Q_DECL_NOTHROW;\n" - "inline LineBreakClass lineBreakClass(QChar ch) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) noexcept;\n" + "inline LineBreakClass lineBreakClass(QChar ch) noexcept\n" "{ return lineBreakClass(ch.unicode()); }\n" "\n"; @@ -2521,42 +2521,42 @@ static QByteArray createPropertyInfo() out += "\n};\n\n"; - out += "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(uint ucs4) Q_DECL_NOTHROW\n" + out += "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(uint ucs4) noexcept\n" "{\n" " return uc_properties + GET_PROP_INDEX(ucs4);\n" "}\n" "\n" - "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(ushort ucs2) Q_DECL_NOTHROW\n" + "Q_DECL_CONST_FUNCTION static inline const Properties *qGetProp(ushort ucs2) noexcept\n" "{\n" " return uc_properties + GET_PROP_INDEX_UCS2(ucs2);\n" "}\n" "\n" - "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) Q_DECL_NOTHROW\n" + "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(uint ucs4) noexcept\n" "{\n" " return qGetProp(ucs4);\n" "}\n" "\n" - "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) Q_DECL_NOTHROW\n" + "Q_DECL_CONST_FUNCTION Q_CORE_EXPORT const Properties * QT_FASTCALL properties(ushort ucs2) noexcept\n" "{\n" " return qGetProp(ucs2);\n" "}\n\n"; - out += "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) Q_DECL_NOTHROW\n" + out += "Q_CORE_EXPORT GraphemeBreakClass QT_FASTCALL graphemeBreakClass(uint ucs4) noexcept\n" "{\n" " return static_cast(qGetProp(ucs4)->graphemeBreakClass);\n" "}\n" "\n" - "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT WordBreakClass QT_FASTCALL wordBreakClass(uint ucs4) noexcept\n" "{\n" " return static_cast(qGetProp(ucs4)->wordBreakClass);\n" "}\n" "\n" - "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT SentenceBreakClass QT_FASTCALL sentenceBreakClass(uint ucs4) noexcept\n" "{\n" " return static_cast(qGetProp(ucs4)->sentenceBreakClass);\n" "}\n" "\n" - "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) Q_DECL_NOTHROW\n" + "Q_CORE_EXPORT LineBreakClass QT_FASTCALL lineBreakClass(uint ucs4) noexcept\n" "{\n" " return static_cast(qGetProp(ucs4)->lineBreakClass);\n" "}\n" -- cgit v1.2.3