summaryrefslogtreecommitdiffstats
path: root/util/corelib/qurl-generateTLDs
diff options
context:
space:
mode:
authorDimitrios Apostolou <jimis@qt.io>2020-05-19 18:05:53 +0200
committerDimitrios Apostolou <jimis@qt.io>2020-05-28 10:48:57 +0200
commit5b3c3ff97e1aeb76f8dc6abe0b4f9a6fd64f9fa5 (patch)
treebf3b7eafd61ec175d92adf5d8c0df23d30d0a436 /util/corelib/qurl-generateTLDs
parentcfbb30decda13fb630127246af5bea32c5f4da57 (diff)
Improve readability of the autogenerated arrays in qurltlds_p.h
The next time qurltlds_p.h is generated, array sizes shall be explicit. Also added some helpful comments. And updated copyright date. Change-Id: I2bc9a78bcc2982845fce75a413e2048b0bfd12a0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'util/corelib/qurl-generateTLDs')
-rw-r--r--util/corelib/qurl-generateTLDs/main.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/util/corelib/qurl-generateTLDs/main.cpp b/util/corelib/qurl-generateTLDs/main.cpp
index 1e104e99c2..1f54299017 100644
--- a/util/corelib/qurl-generateTLDs/main.cpp
+++ b/util/corelib/qurl-generateTLDs/main.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2019 The Qt Company Ltd.
+** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the utils of the Qt Toolkit.
@@ -145,8 +145,12 @@ int main(int argc, char **argv)
entry.append(st);
entry.append("\\0");
}
- outFile.write("static const quint32 tldIndices[] = {\n");
- outDataBuffer.write("\nstatic const char *tldData[] = {");
+
+ outFile.write("// After the tldCount \"real\" entries in tldIndices, include a final entry\n");
+ outFile.write("// that records the sum of the lengths of all the chunks, i.e. the index\n");
+ outFile.write("// just past the end of tldChunks.\n");
+ outFile.write("static const quint32 tldIndices[tldCount + 1] = {\n");
+ outDataBuffer.write("static const char *tldData[tldChunkCount] = {");
int totalUtf8Size = 0;
int chunkSize = 0; // strlen of the current chunk (sizeof is bigger by 1)
@@ -177,17 +181,23 @@ int main(int argc, char **argv)
}
}
chunks.append(QString::number(totalUtf8Size));
+
+ // Write one extra entry, at tldIndices[tldCount], that contains the total size.
outFile.write(QByteArray::number(totalUtf8Size));
outFile.write("\n};\n");
outDataBuffer.write("\n};\n");
outDataBuffer.close();
- outFile.write(outDataBufferBA);
- // write chunk information
+ // First we have to define tldChunkCount.
outFile.write("\nstatic const quint16 tldChunkCount = ");
outFile.write(QByteArray::number(chunks.count()));
- outFile.write(";\nstatic const quint32 tldChunks[] = {");
+ outFile.write(";\n");
+
+ // Write tldData[tldChunkCount] = {...}.
+ outFile.write(outDataBufferBA);
+
+ outFile.write("static const quint32 tldChunks[tldChunkCount] = {");
outFile.write(chunks.join(", ").toLatin1());
outFile.write("};\n");
outFile.close();