From f9421f0968b8067ca79d83dc75e35092ac4a4948 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 26 Feb 2019 11:33:13 +0100 Subject: [PATCH] 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(-) 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");