From c3559b24eba76052deb9d4ce79e4704815d902a5 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Mon, 10 Feb 2020 20:58:39 +0200 Subject: staging: rewrite AdblockPlus parser yet again --- staging/adblock/test/parser.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 staging/adblock/test/parser.cpp (limited to 'staging/adblock/test') diff --git a/staging/adblock/test/parser.cpp b/staging/adblock/test/parser.cpp new file mode 100644 index 0000000..0ce1121 --- /dev/null +++ b/staging/adblock/test/parser.cpp @@ -0,0 +1,32 @@ +#include "filterlist.h" +#include +#include + +int main(int argc, char **argv) +{ + if(argc < 2) { + qDebug("usage: %s list1.txt ...", argv[0]); + return 77; + } + + for(int i = 1; i < argc; ++i) { + QFile f(argv[i]); + if(!f.open(QIODevice::ReadOnly | QIODevice::Text)) { + qDebug("could not open %s", argv[i]); + return -1; + } + + AdblockPlus::FilterList list; + QTextStream stream(&f); + const auto result = list.parse(stream); + qDebug("[%s]: %s", argv[i], (result.state == AdblockPlus::FilterList::Ok) ? "okay" : "failed"); + qDebug(" total: %i", result.lines_total); + qDebug("comments: %i", result.lines_comments); + qDebug(" ignored: %i", result.lines_ignored); + qDebug(" parsed: %i", result.lines_parsed); + qDebug(" failed: %i", result.lines_failed); + + f.close(); + } + return 0; +} -- cgit v1.2.1