diff options
author | Daniel Veillard <veillard@src.gnome.org> | 2000-08-12 21:12:04 +0000 |
---|---|---|
committer | Daniel Veillard <veillard@src.gnome.org> | 2000-08-12 21:12:04 +0000 |
commit | 87b953957305fc1ece066efa60df5c7844183439 (patch) | |
tree | 716014ce7948189e557e890575a369fdfc30b9f2 /testHTML.c | |
parent | 7ebb1eebdac0740d9ad703bd8dabbcb8a79cf679 (diff) | |
download | libxml2-87b953957305fc1ece066efa60df5c7844183439.tar.gz |
Large sync between my W3C base and Gnome's one:
- parser.[ch]: added xmlGetFeaturesList() xmlGetFeature() and xmlAddFeature()
- tree.[ch]: added xmlAddChildList()
- xmllint.c: MAP_FAILED macro test
- parser.h: added xmlParseCtxtExternalEntity()
- valid.c: applied bug fixes removed warning
- tree.c: added CDATA block to elements content
- testSAX.c: cleanup of output
- testHTML.c: added SAX testing
- encoding.c: better error recovery
- SAX.c, parser.c: fixed one of the external entity processing of the OASis testsuite
- Makefile.am: added HTML SAX regression tests
- configure.in: bumped to 2.2.2
- test/HTML/ result/HTML: added a few of HTML tests, and added the SAX results
Daniel
Diffstat (limited to 'testHTML.c')
-rw-r--r-- | testHTML.c | 104 |
1 files changed, 85 insertions, 19 deletions
@@ -403,12 +403,14 @@ endElementDebug(void *ctx, const xmlChar *name) void charactersDebug(void *ctx, const xmlChar *ch, int len) { + char output[40]; int i; - fprintf(stdout, "SAX.characters("); - for (i = 0;(i < len) && (i < 30);i++) - fprintf(stdout, "%c", ch[i]); - fprintf(stdout, ", %d)\n", len); + for (i = 0;(i<len) && (i < 30);i++) + output[i] = ch[i]; + output[i] = 0; + + fprintf(stdout, "SAX.characters(%s, %d)\n", output, len); } /** @@ -437,8 +439,14 @@ referenceDebug(void *ctx, const xmlChar *name) void ignorableWhitespaceDebug(void *ctx, const xmlChar *ch, int len) { - fprintf(stdout, "SAX.ignorableWhitespace(%.30s, %d)\n", - (char *) ch, len); + char output[40]; + int i; + + for (i = 0;(i<len) && (i < 30);i++) + output[i] = ch[i]; + output[i] = 0; + + fprintf(stdout, "SAX.ignorableWhitespace(%s, %d)\n", output, len); } /** @@ -571,21 +579,78 @@ void parseSAXFile(char *filename) { /* * Empty callbacks for checking */ - doc = htmlSAXParseFile(filename, NULL, emptySAXHandler, NULL); - if (doc != NULL) { - fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); - xmlFreeDoc(doc); - } + if (push) { + FILE *f; + + f = fopen(filename, "r"); + if (f != NULL) { + int res, size = 3; + char chars[4096]; + htmlParserCtxtPtr ctxt; - if (!noout) { - /* - * Debug callback - */ - doc = htmlSAXParseFile(filename, NULL, debugSAXHandler, NULL); + /* if (repeat) */ + size = 4096; + res = fread(chars, 1, 4, f); + if (res > 0) { + ctxt = htmlCreatePushParserCtxt(emptySAXHandler, NULL, + chars, res, filename, 0); + while ((res = fread(chars, 1, size, f)) > 0) { + htmlParseChunk(ctxt, chars, res, 0); + } + htmlParseChunk(ctxt, chars, 0, 1); + doc = ctxt->myDoc; + htmlFreeParserCtxt(ctxt); + } + if (doc != NULL) { + fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); + xmlFreeDoc(doc); + } + fclose(f); + } + if (!noout) { + f = fopen(filename, "r"); + if (f != NULL) { + int res, size = 3; + char chars[4096]; + htmlParserCtxtPtr ctxt; + + /* if (repeat) */ + size = 4096; + res = fread(chars, 1, 4, f); + if (res > 0) { + ctxt = htmlCreatePushParserCtxt(debugSAXHandler, NULL, + chars, res, filename, 0); + while ((res = fread(chars, 1, size, f)) > 0) { + htmlParseChunk(ctxt, chars, res, 0); + } + htmlParseChunk(ctxt, chars, 0, 1); + doc = ctxt->myDoc; + htmlFreeParserCtxt(ctxt); + } + if (doc != NULL) { + fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); + xmlFreeDoc(doc); + } + fclose(f); + } + } + } else { + doc = htmlSAXParseFile(filename, NULL, emptySAXHandler, NULL); if (doc != NULL) { fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); xmlFreeDoc(doc); } + + if (!noout) { + /* + * Debug callback + */ + doc = htmlSAXParseFile(filename, NULL, debugSAXHandler, NULL); + if (doc != NULL) { + fprintf(stdout, "htmlSAXParseFile returned non-NULL\n"); + xmlFreeDoc(doc); + } + } } } @@ -601,11 +666,11 @@ void parseAndPrintFile(char *filename) { f = fopen(filename, "r"); if (f != NULL) { int res, size = 3; - char chars[1024]; + char chars[4096]; htmlParserCtxtPtr ctxt; - if (repeat) - size = 1024; + /* if (repeat) */ + size = 4096; res = fread(chars, 1, 4, f); if (res > 0) { ctxt = htmlCreatePushParserCtxt(NULL, NULL, @@ -617,6 +682,7 @@ void parseAndPrintFile(char *filename) { doc = ctxt->myDoc; htmlFreeParserCtxt(ctxt); } + fclose(f); } } else { doc = htmlParseFile(filename, NULL); |