rrichards Fri Dec 12 08:54:53 2003 EDT Modified files: /php-src/ext/dom document.c Log: use error handling from libxml ext Index: php-src/ext/dom/document.c diff -u php-src/ext/dom/document.c:1.39 php-src/ext/dom/document.c:1.40 --- php-src/ext/dom/document.c:1.39 Mon Dec 1 03:18:35 2003 +++ php-src/ext/dom/document.c Fri Dec 12 08:54:52 2003 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: document.c,v 1.39 2003/12/01 08:18:35 chregu Exp $ */ +/* $Id: document.c,v 1.40 2003/12/12 13:54:52 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -97,85 +97,6 @@ {NULL, NULL, NULL} }; -static void php_dom_validate_error(void *ctx, const char *msg, ...) -{ - char *buf; - va_list ap; - int len; - - va_start(ap, msg); - len = vspprintf(&buf, 0, msg, ap); - va_end(ap); - - /* remove any trailing \n */ - while (len && buf[--len] == '\n') { - buf[len] = '\0'; - } - - php_error(E_WARNING, "%s", buf); - efree(buf); -} - -/* {{{ static void php_dom_ctx_error_level(int level, void *ctx, const char *msg, ...) */ -static void php_dom_ctx_error_level(int level, void *ctx, const char *msg) -{ - xmlParserCtxtPtr parser; - TSRMLS_FETCH(); - - parser = (xmlParserCtxtPtr) ctx; - - if (parser != NULL && parser->input != NULL) { - if (parser->input->filename) { - php_error_docref(NULL TSRMLS_CC, level, "%s in %s, line: %d", msg, parser->input->filename, parser->input->line); - } else { - php_error_docref(NULL TSRMLS_CC, level, "%s in Entity, line: %d", msg, parser->input->line); - } - } -} -/* }}} end php_dom_ctx_error */ - -/* {{{ static void php_dom_ctx_error(void *ctx, const char *msg, ...) */ -static void php_dom_ctx_error(void *ctx, const char *msg, ...) -{ - va_list ap; - char *buf; - int len; - - va_start(ap, msg); - len = vspprintf(&buf, 0, msg, ap); - va_end(ap); - - /* remove any trailing \n */ - while (len && buf[--len] == '\n') { - buf[len] = '\0'; - } - - php_dom_ctx_error_level(E_WARNING, ctx, buf); - efree(buf); -} -/* }}} end php_dom_ctx_error */ - -static void php_dom_ctx_warning(void *ctx, const char *msg, ...) -{ - va_list ap; - char *buf; - int len; - - va_start(ap, msg); - len = vspprintf(&buf, 0, msg, ap); - va_end(ap); - - /* remove any trailing \n */ - while (len && buf[--len] == '\n') { - buf[len] = '\0'; - } - - php_dom_ctx_error_level(E_NOTICE, ctx, buf); - efree(buf); -} -/* }}} end php_dom_ctx_error */ - - /* {{{ proto doctype documenttype readonly=yes URL: http://www.w3.org/TR/2003/WD-DOM-Level-3-Core-20030226/DOM3-Core.html#core-ID-B63ED1A31 @@ -1336,12 +1257,12 @@ ctxt->loadsubset = (resolve_externals * XML_COMPLETE_ATTRS); ctxt->replaceEntities = substitute_ent; - ctxt->vctxt.error = php_dom_ctx_error; - ctxt->vctxt.warning = php_dom_ctx_warning; + ctxt->vctxt.error = php_libxml_ctx_error; + ctxt->vctxt.warning = php_libxml_ctx_warning; if (ctxt->sax != NULL) { - ctxt->sax->error = php_dom_ctx_error; - ctxt->sax->warning = php_dom_ctx_warning; + ctxt->sax->error = php_libxml_ctx_error; + ctxt->sax->warning = php_libxml_ctx_warning; } xmlParseDocument(ctxt); @@ -1559,8 +1480,8 @@ } cvp.userData = NULL; - cvp.error = (xmlValidityErrorFunc) php_dom_validate_error; - cvp.warning = (xmlValidityErrorFunc) php_dom_validate_error; + cvp.error = (xmlValidityErrorFunc) php_libxml_error_handler; + cvp.warning = (xmlValidityErrorFunc) php_libxml_error_handler; if (xmlValidateDocument(&cvp, docp)) { RETVAL_TRUE; @@ -1608,8 +1529,8 @@ } xmlSchemaSetParserErrors(parser, - (xmlSchemaValidityErrorFunc) php_dom_validate_error, - (xmlSchemaValidityWarningFunc) php_dom_validate_error, + (xmlSchemaValidityErrorFunc) php_libxml_error_handler, + (xmlSchemaValidityWarningFunc) php_libxml_error_handler, parser); sptr = xmlSchemaParse(parser); xmlSchemaFreeParserCtxt(parser); @@ -1627,7 +1548,7 @@ RETURN_FALSE; } - xmlSchemaSetValidErrors(vptr, php_dom_validate_error, php_dom_validate_error, vptr); + xmlSchemaSetValidErrors(vptr, php_libxml_error_handler, php_libxml_error_handler, vptr); is_valid = xmlSchemaValidateDoc(vptr, docp); xmlSchemaFree(sptr); xmlSchemaFreeValidCtxt(vptr); @@ -1691,8 +1612,8 @@ } xmlRelaxNGSetParserErrors(parser, - (xmlRelaxNGValidityErrorFunc) php_dom_validate_error, - (xmlRelaxNGValidityWarningFunc) php_dom_validate_error, + (xmlRelaxNGValidityErrorFunc) php_libxml_error_handler, + (xmlRelaxNGValidityWarningFunc) php_libxml_error_handler, parser); sptr = xmlRelaxNGParse(parser); xmlRelaxNGFreeParserCtxt(parser); @@ -1710,7 +1631,7 @@ RETURN_FALSE; } - xmlRelaxNGSetValidErrors(vptr, php_dom_validate_error, php_dom_validate_error, vptr); + xmlRelaxNGSetValidErrors(vptr, php_libxml_error_handler, php_libxml_error_handler, vptr); is_valid = xmlRelaxNGValidateDoc(vptr, docp); xmlRelaxNGFree(sptr); xmlRelaxNGFreeValidCtxt(vptr); @@ -1762,11 +1683,11 @@ source_len = xmlStrlen(source); ctxt = htmlCreateMemoryParserCtxt(source, source_len); } - ctxt->vctxt.error = php_dom_ctx_error; - ctxt->vctxt.warning = php_dom_ctx_warning; + ctxt->vctxt.error = php_libxml_ctx_error; + ctxt->vctxt.warning = php_libxml_ctx_warning; if (ctxt->sax != NULL) { - ctxt->sax->error = php_dom_ctx_error; - ctxt->sax->warning = php_dom_ctx_warning; + ctxt->sax->error = php_libxml_ctx_error; + ctxt->sax->warning = php_libxml_ctx_warning; } htmlParseDocument(ctxt); newdoc = ctxt->myDoc;
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php