diff --git a/ChangeLog b/ChangeLog index b7ed1c5f..50139f66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Mon Oct 22 11:32:36 CEST 2001 Daniel Veillard + + * test/threads/*: added entities testing to the Thread test + * testThreads.c: make the test reasonable + * DOCBparser.c: fix the DTD public and system ID + * xmllint.c: added --sgml for SGML DocBook importing + * Makefile.am: added Docbtests target + Fri Oct 19 11:47:13 CEST 2001 Daniel Veillard * nanoftp.c: use only "anonymous@" string for anonymous passwds diff --git a/DOCBparser.c b/DOCBparser.c index 5ea8b0a1..013e819b 100644 --- a/DOCBparser.c +++ b/DOCBparser.c @@ -47,6 +47,15 @@ #include #include +/* + * DocBook XML current versions + */ + +#define XML_DOCBOOK_XML_PUBLIC (const xmlChar *) \ + "-//OASIS//DTD DocBook XML V4.1.2//EN" +#define XML_DOCBOOK_XML_SYSTEM (const xmlChar *) \ + "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" + /* * Internal description of an SGML entity */ @@ -3554,17 +3563,20 @@ docbParseDocTypeDecl(docbParserCtxtPtr ctxt) { /* * Create or update the document accordingly to the DOCTYPE + * But use the predefined PUBLIC and SYSTEM ID of DocBook XML */ if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) && (!ctxt->disableSAX)) - ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI); + ctxt->sax->internalSubset(ctxt->userData, name, + XML_DOCBOOK_XML_PUBLIC, + XML_DOCBOOK_XML_SYSTEM); - /* - * Is there any internal subset declarations ? - * they are handled separately in docbParseInternalSubset() - */ - if (RAW != '[') { - return; + if (RAW != '>') { + if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL)) + ctxt->sax->error(ctxt->userData, + "docbParseDocTypeDecl : internal subset not handled\n"); + } else { + NEXT; } /* diff --git a/Makefile.am b/Makefile.am index c87ca993..36dcce5d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,5 @@ ## Process this file with automake to produce Makefile.in -# Dependancies are fucked in make distcheck could not find why :-( -AUTOMAKE_OPTIONS=no-dependencies - SUBDIRS = include . doc example INCLUDES = -I@srcdir@/include -I$(top_builddir)/include @THREAD_CFLAGS@ @Z_CFLAGS@ @@ -226,6 +223,26 @@ XMLtests : xmllint rm result.$$name result2.$$name ; \ fi ; fi ; done) +Docbtests : xmllint + @(echo > .memdump) + @echo "##" + @echo "## SGML DocBook regression tests" + @echo "##" + @(for i in $(srcdir)/test/DocBook/*.sgm ; do \ + name=`basename $$i .sgm`; \ + if [ ! -d $$i ] ; then \ + if [ ! -f $(srcdir)/result/DocBook/$$name.xml ] ; then \ + echo New test file $$name ; \ + $(top_builddir)/xmllint --sgml $$i > $(srcdir)/result/DocBook/$$name.xml ; \ + $(top_builddir)/xmllint --valid --noout $(srcdir)/result/DocBook/$$name.xml ; \ + else \ + echo Testing $$name ; \ + $(top_builddir)/xmllint --sgml $$i > result.$$name ; \ + diff $(srcdir)/result/DocBook/$$name.xml result.$$name ; \ + $(top_builddir)/xmllint --valid --noout result.$$name ; \ + rm result.$$name ; \ + fi ; fi ; done) + XMLenttests : xmllint @(echo > .memdump) @echo "##" diff --git a/test/threads/a/a.dtd b/test/threads/a/a.dtd index 7699a22f..b2980859 100644 --- a/test/threads/a/a.dtd +++ b/test/threads/a/a.dtd @@ -1 +1 @@ - + diff --git a/test/threads/abc.xml b/test/threads/abc.xml index 1c3bb962..ee98144d 100644 --- a/test/threads/abc.xml +++ b/test/threads/abc.xml @@ -1,7 +1,7 @@ - - + Let's use predefined entites & < > + Let's use a DTD defined entity &bent; diff --git a/test/threads/acb.xml b/test/threads/acb.xml index af2030e3..a14e362b 100644 --- a/test/threads/acb.xml +++ b/test/threads/acb.xml @@ -1,7 +1,7 @@ - + Let's use predefined entites & < > - + Let's use a DTD defined entity &bent; diff --git a/test/threads/b/b.dtd b/test/threads/b/b.dtd index c1435a8b..59de88ee 100644 --- a/test/threads/b/b.dtd +++ b/test/threads/b/b.dtd @@ -1 +1,2 @@ - + + diff --git a/test/threads/bac.xml b/test/threads/bac.xml index 51799e44..63d6efc5 100644 --- a/test/threads/bac.xml +++ b/test/threads/bac.xml @@ -1,7 +1,7 @@ - - + Let's use a DTD defined entity &bent; + Let's use predefined entites & < > diff --git a/test/threads/bca.xml b/test/threads/bca.xml index 4f4f8bba..ce60d016 100644 --- a/test/threads/bca.xml +++ b/test/threads/bca.xml @@ -1,7 +1,7 @@ - + Let's use a DTD defined entity &bent; - + Let's use predefined entites & < > diff --git a/test/threads/cab.xml b/test/threads/cab.xml index 81f45d07..a1631d0c 100644 --- a/test/threads/cab.xml +++ b/test/threads/cab.xml @@ -1,7 +1,7 @@ - - + Let's use predefined entites & < > + Let's use a DTD defined entity &bent; diff --git a/test/threads/cba.xml b/test/threads/cba.xml index 5bbd570f..78708e4d 100644 --- a/test/threads/cba.xml +++ b/test/threads/cba.xml @@ -1,7 +1,7 @@ - - + Let's use a DTD defined entity &bent; + Let's use predefined entites & < > diff --git a/testThreads.c b/testThreads.c index 310a2392..8424d31d 100644 --- a/testThreads.c +++ b/testThreads.c @@ -90,7 +90,7 @@ main() int ret; xmlInitParser(); - for (repeat = 0;repeat < 10000;repeat++) { + for (repeat = 0;repeat < 500;repeat++) { xmlLoadCatalog(catalog); for (i = 0; i < num_threads; i++) { diff --git a/xmllint.c b/xmllint.c index 7725c43c..9958d0a4 100644 --- a/xmllint.c +++ b/xmllint.c @@ -68,6 +68,9 @@ #ifdef LIBXML_CATALOG_ENABLED #include #endif +#ifdef LIBXML_DOCB_ENABLED +#include +#endif #include #ifdef LIBXML_DEBUG_ENABLED @@ -86,6 +89,9 @@ static char * dtdvalid = NULL; static int repeat = 0; static int insert = 0; static int compress = 0; +#ifdef LIBXML_DOCB_ENABLED +static int sgml = 0; +#endif static int html = 0; static int htmlout = 0; static int push = 0; @@ -412,6 +418,38 @@ static void parseAndPrintFile(char *filename) { xmlDocSetRootElement(doc, n); } } +#ifdef LIBXML_DOCB_ENABLED + /* + * build an SGML tree from a string; + */ + else if ((sgml) && (push)) { + FILE *f; + + f = fopen(filename, "r"); + if (f != NULL) { + int res, size = 3; + char chars[4096]; + docbParserCtxtPtr ctxt; + + /* if (repeat) */ + size = 4096; + res = fread(chars, 1, 4, f); + if (res > 0) { + ctxt = docbCreatePushParserCtxt(NULL, NULL, + chars, res, filename, 0); + while ((res = fread(chars, 1, size, f)) > 0) { + docbParseChunk(ctxt, chars, res, 0); + } + docbParseChunk(ctxt, chars, 0, 1); + doc = ctxt->myDoc; + docbFreeParserCtxt(ctxt); + } + fclose(f); + } + } else if (sgml) { + doc = docbParseFile(filename, NULL); + } +#endif #ifdef LIBXML_HTML_ENABLED else if (html) { doc = htmlParseFile(filename, NULL); @@ -789,6 +827,9 @@ static void usage(const char *name) { printf("\t--repeat : repeat 100 times, for timing or profiling\n"); printf("\t--insert : ad-hoc test for valid insertions\n"); printf("\t--compress : turn on gzip compression of output\n"); +#ifdef LIBXML_DOCB_ENABLED + printf("\t--sgml : use the DocBook SGML parser\n"); +#endif #ifdef LIBXML_HTML_ENABLED printf("\t--html : use the HTML parser\n"); #endif @@ -856,6 +897,12 @@ main(int argc, char **argv) { else if ((!strcmp(argv[i], "-htmlout")) || (!strcmp(argv[i], "--htmlout"))) htmlout++; +#ifdef LIBXML_DOCB_ENABLED + else if ((!strcmp(argv[i], "-sgml")) || + (!strcmp(argv[i], "--sgml"))) { + sgml++; + } +#endif #ifdef LIBXML_HTML_ENABLED else if ((!strcmp(argv[i], "-html")) || (!strcmp(argv[i], "--html"))) {