summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2019-02-26 11:33:13 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2019-03-01 13:26:46 +0000
commitf9421f0968b8067ca79d83dc75e35092ac4a4948 (patch)
tree7cf0325f4aa6b6f6e0d62d003ead41bc7bcab29d /util
parent55b464196297afc11cb9836f61f737e6fdaf04dc (diff)
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 <peter-qt@hartmann.tk>
Diffstat (limited to 'util')
-rw-r--r--util/corelib/qurl-generateTLDs/main.cpp5
1 files changed, 3 insertions, 2 deletions
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");