diff options
author | Edward Welbourne <edward.welbourne@qt.io> | 2021-01-21 13:36:14 +0100 |
---|---|---|
committer | Edward Welbourne <edward.welbourne@qt.io> | 2021-01-25 18:03:00 +0100 |
commit | 56f12656f59910d6a762725818a1f255e2df086d (patch) | |
tree | ebbf2ece6d13c71bc5957aa46bf6ceab61701713 /util | |
parent | fdc7eb80dd5753bc1fc145dc9bd0689cd65e251d (diff) |
Eliminate the need to preprocess the public suffix list
The program to digest the public suffix list required the user to
initially grep away the comments and blank lines. Filtering those
lines out in the code to read the file is trivial, so save the user
one step in the process.
Change-Id: I08f2594fc4236a689c849d42b5446efa9ec2ef7a
Reviewed-by: Dimitrios Apostolou <jimis@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'util')
-rw-r--r-- | util/publicSuffix/main.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/util/publicSuffix/main.cpp b/util/publicSuffix/main.cpp index ba2bcdbebd..412f42684d 100644 --- a/util/publicSuffix/main.cpp +++ b/util/publicSuffix/main.cpp @@ -94,10 +94,10 @@ int main(int argc, char **argv) printf("'inputFile' should be a list of effective TLDs, one per line,\n"); printf("as obtained from http://publicsuffix.org/. To create indices and data\n"); printf("file, do the following:\n\n"); - printf(" wget https://publicsuffix.org/list/public_suffix_list.dat -O public_suffix_list.dat\n"); - printf(" grep -v '^//' public_suffix_list.dat | grep . > public_suffix_list.dat.trimmed\n"); - printf(" ./%s public_suffix_list.dat.trimmed public_suffix_list.cpp\n\n", argv[0]); - printf("Now replace the code in qtbase/src/network/kernel/qurltlds_p.h with public_suffix_list.cpp's contents\n\n"); + printf(" wget https://publicsuffix.org/list/public_suffix_list.dat -O suffixes.dat\n"); + printf(" ./%s suffixes.dat public_suffix_list.cpp\n\n", argv[0]); + printf("Then replace the code in qtbase/src/network/kernel/qurltlds_p.h\n" + "with public_suffix_list.cpp's contents\n\n"); return 1; } QFile file(argv[1]); @@ -121,7 +121,9 @@ int main(int argc, char **argv) int lineCount = 0; while (!file.atEnd()) { - file.readLine(); + QString st = QString::fromUtf8(file.readLine()).trimmed(); + if (st.isEmpty() || st.startsWith(u"//")) + continue; lineCount++; } outFile.write("static const quint16 tldCount = "); @@ -132,6 +134,8 @@ int main(int argc, char **argv) QStringList strings(lineCount); while (!file.atEnd()) { QString st = QString::fromUtf8(file.readLine()).trimmed(); + if (st.isEmpty() || st.startsWith(u"//")) + continue; int num = qt_hash(st) % lineCount; QString &entry = strings[num]; st = utf8encode(st.toUtf8()); |