X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=sherlock%2Fxml%2Fxml-test.c;h=f6738c56db4164cd3851dfdd7c7351ebeac88812;hb=d5fdccbecd2acde9a6e067b54fcd69b02f31a820;hp=76c5042bca179721bc70a67c288b5dab538844a6;hpb=ccf64507b45774b007ab6200036827f1597022d8;p=libucw.git diff --git a/sherlock/xml/xml-test.c b/sherlock/xml/xml-test.c index 76c5042b..f6738c56 100644 --- a/sherlock/xml/xml-test.c +++ b/sherlock/xml/xml-test.c @@ -10,8 +10,8 @@ #include "sherlock/sherlock.h" #include "sherlock/xml/xml.h" #include "sherlock/xml/dtd.h" -#include "lib/getopt.h" -#include "lib/fastbuf.h" +#include "ucw/getopt.h" +#include "ucw/fastbuf.h" #include #include @@ -19,25 +19,26 @@ enum { WANT_FIRST = 0x100, - WANT_PARSE_DTD, WANT_HIDE_ERRORS, WANT_IGNORE_COMMENTS, WANT_IGNORE_PIS, WANT_REPORT_BLOCKS, + WANT_REPORT_IGNORABLE, WANT_FILE_ENTITIES, }; -static char *shortopts = "spd" CF_SHORT_OPTS; +static char *shortopts = "spdt" CF_SHORT_OPTS; static struct option longopts[] = { CF_LONG_OPTS { "sax", 0, 0, 's' }, { "pull", 0, 0, 'p' }, - { "dom", 0, 0, 'd' }, - { "dtd", 0, 0, WANT_PARSE_DTD }, + { "dom", 0, 0, 't' }, + { "dtd", 0, 0, 'd' }, { "hide-errors", 0, 0, WANT_HIDE_ERRORS }, { "ignore-comments", 0, 0, WANT_IGNORE_COMMENTS }, { "ignore-pis", 0, 0, WANT_IGNORE_PIS }, - { "reports-blocks", 0, 0, WANT_REPORT_BLOCKS }, + { "report-blocks", 0, 0, WANT_REPORT_BLOCKS }, + { "report-ignorable", 0, 0, WANT_REPORT_IGNORABLE }, { "file-entities", 0, 0, WANT_FILE_ENTITIES }, { NULL, 0, 0, 0 } }; @@ -53,12 +54,13 @@ CF_USAGE "\ -p, --pull Test PULL interface\n\ -s, --sax Test SAX interface\n\ --d, --dom Test DOM interface\n\ - --dtd Enable parsing of DTD\n\ +-t, --dom Test DOM interface\n\ +-d, --dtd Enable parsing of DTD\n\ --hide-errors Hide warnings and error messages\n\ - --ignore-comments Ignore processing instructions\n\ - --ignore-pis Ignore comments\n\ + --ignore-comments Ignore comments\n\ + --ignore-pis Ignore processing instructions\n\ --report-blocks Report blocks or characters and CDATA sections\n\ + --report-ignorable Report ignorable whitespace\n\ --file-entities Resolve file external entities (not fully normative)\n\ \n", stderr); exit(1); @@ -72,6 +74,7 @@ static uns want_hide_errors; static uns want_ignore_comments; static uns want_ignore_pis; static uns want_report_blocks; +static uns want_report_ignorable; static uns want_file_entities; static struct fastbuf *out; @@ -150,7 +153,7 @@ h_document_end(struct xml_context *ctx UNUSED) static void h_xml_decl(struct xml_context *ctx) { - bprintf(out, "SAX: xml_decl version=%s standalone=%d\n", ctx->version_str, ctx->standalone); + bprintf(out, "SAX: xml_decl version=%s standalone=%d fb_encoding=%s\n", ctx->version_str, ctx->standalone, ctx->src->fb_encoding); } static void @@ -207,6 +210,12 @@ h_cdata(struct xml_context *ctx UNUSED, char *text, uns len UNUSED) bprintf(out, "SAX: cdata text='%s'\n", text); } +static void +h_ignorable(struct xml_context *ctx UNUSED, char *text, uns len UNUSED) +{ + bprintf(out, "SAX: ignorable text='%s'\n", text); +} + static void h_dtd_start(struct xml_context *ctx UNUSED) { @@ -240,10 +249,10 @@ main(int argc, char **argv) case 'p': want_pull++; break; - case 'd': + case 't': want_dom++; break; - case WANT_PARSE_DTD: + case 'd': want_parse_dtd++; break; case WANT_HIDE_ERRORS: @@ -258,6 +267,9 @@ main(int argc, char **argv) case WANT_REPORT_BLOCKS: want_report_blocks++; break; + case WANT_REPORT_IGNORABLE: + want_report_ignorable++; + break; case WANT_FILE_ENTITIES: want_file_entities++; break; @@ -288,6 +300,8 @@ main(int argc, char **argv) ctx.h_block = h_block; ctx.h_cdata = h_cdata; } + if (want_report_ignorable) + ctx.h_ignorable = h_ignorable; ctx.h_dtd_start = h_dtd_start; ctx.h_dtd_end = h_dtd_end; }