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>
This commit is contained in:
parent
fdc7eb80dd
commit
56f12656f5
@ -94,10 +94,10 @@ int main(int argc, char **argv)
|
|||||||
printf("'inputFile' should be a list of effective TLDs, one per line,\n");
|
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("as obtained from http://publicsuffix.org/. To create indices and data\n");
|
||||||
printf("file, do the following:\n\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(" wget https://publicsuffix.org/list/public_suffix_list.dat -O suffixes.dat\n");
|
||||||
printf(" grep -v '^//' public_suffix_list.dat | grep . > public_suffix_list.dat.trimmed\n");
|
printf(" ./%s suffixes.dat public_suffix_list.cpp\n\n", argv[0]);
|
||||||
printf(" ./%s public_suffix_list.dat.trimmed public_suffix_list.cpp\n\n", argv[0]);
|
printf("Then replace the code in qtbase/src/network/kernel/qurltlds_p.h\n"
|
||||||
printf("Now replace the code in qtbase/src/network/kernel/qurltlds_p.h with public_suffix_list.cpp's contents\n\n");
|
"with public_suffix_list.cpp's contents\n\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
QFile file(argv[1]);
|
QFile file(argv[1]);
|
||||||
@ -121,7 +121,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
int lineCount = 0;
|
int lineCount = 0;
|
||||||
while (!file.atEnd()) {
|
while (!file.atEnd()) {
|
||||||
file.readLine();
|
QString st = QString::fromUtf8(file.readLine()).trimmed();
|
||||||
|
if (st.isEmpty() || st.startsWith(u"//"))
|
||||||
|
continue;
|
||||||
lineCount++;
|
lineCount++;
|
||||||
}
|
}
|
||||||
outFile.write("static const quint16 tldCount = ");
|
outFile.write("static const quint16 tldCount = ");
|
||||||
@ -132,6 +134,8 @@ int main(int argc, char **argv)
|
|||||||
QStringList strings(lineCount);
|
QStringList strings(lineCount);
|
||||||
while (!file.atEnd()) {
|
while (!file.atEnd()) {
|
||||||
QString st = QString::fromUtf8(file.readLine()).trimmed();
|
QString st = QString::fromUtf8(file.readLine()).trimmed();
|
||||||
|
if (st.isEmpty() || st.startsWith(u"//"))
|
||||||
|
continue;
|
||||||
int num = qt_hash(st) % lineCount;
|
int num = qt_hash(st) % lineCount;
|
||||||
QString &entry = strings[num];
|
QString &entry = strings[num];
|
||||||
st = utf8encode(st.toUtf8());
|
st = utf8encode(st.toUtf8());
|
||||||
|
Loading…
Reference in New Issue
Block a user