diff options
author | Melvyn Sopacua <msopacua@php.net> | 2002-10-25 19:23:15 +0000 |
---|---|---|
committer | Melvyn Sopacua <msopacua@php.net> | 2002-10-25 19:23:15 +0000 |
commit | 7e4beef623c28ec57b7c12432ba1da05cb05fc88 (patch) | |
tree | bca2d1a763754c85e8970157bf99ddf4e0ae310d | |
parent | d2f81e2083b716d8f7e074670442de5276737277 (diff) | |
download | php-git-7e4beef623c28ec57b7c12432ba1da05cb05fc88.tar.gz |
- Add XSLT_REG_ERRMSG macro to register an error on the handle
- Rename constants to a bit more appropreate format
- Add XSLT_ERR_UNSUPPORTED_SCHEME to be returned for scheme handlers.
# Docs on xslt_set_scheme_handlers are in progress.
-rw-r--r-- | ext/xslt/php_sablot.h | 2 | ||||
-rw-r--r-- | ext/xslt/sablot.c | 25 |
2 files changed, 11 insertions, 16 deletions
diff --git a/ext/xslt/php_sablot.h b/ext/xslt/php_sablot.h index ad33f53150..fde066bc0b 100644 --- a/ext/xslt/php_sablot.h +++ b/ext/xslt/php_sablot.h @@ -48,6 +48,8 @@ extern zend_module_entry xslt_module_entry; #define XSLT_LOG(handle) ((handle)->err->log) #define XSLT_FUNCH_FREE(__var) if (__var) zval_ptr_dtor(&(__var)); +#define XSLT_REG_ERRMSG(msg, handle) if (XSLT_ERRSTR(handle)) efree(XSLT_ERRSTR(handle)); \ + XSLT_ERRSTR(handle) = estrdup(msg); PHP_MINIT_FUNCTION(xslt); PHP_MINFO_FUNCTION(xslt); diff --git a/ext/xslt/sablot.c b/ext/xslt/sablot.c index 69e39115e3..4c06b6224c 100644 --- a/ext/xslt/sablot.c +++ b/ext/xslt/sablot.c @@ -158,13 +158,15 @@ PHP_MINIT_FUNCTION(xslt) le_xslt = zend_register_list_destructors_ex(free_processor, NULL, le_xslt_name, module_number); /* Generic options, which can apply to 'all' xslt processors */ - REGISTER_LONG_CONSTANT("XSLT_SILENT", SAB_NO_ERROR_REPORTING, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XSLT_OPT_SILENT", SAB_NO_ERROR_REPORTING, CONST_CS | CONST_PERSISTENT); + /* Error constants, which are useful in userspace. */ + REGISTER_LONG_CONSTANT("XSLT_ERR_UNSUPPORTED_SCHEME", SH_ERR_UNSUPPORTED_SCHEME, CONST_CS | CONST_PERSISTENT); /* Sablotron specific options */ - REGISTER_LONG_CONSTANT("XSLT_SAB_PARSE_PUBLIC_ENTITIES", SAB_PARSE_PUBLIC_ENTITIES, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSLT_SAB_DISABLE_ADDING_META", SAB_DISABLE_ADDING_META, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSLT_SAB_DISABLE_STRIPPING", SAB_DISABLE_STRIPPING, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("XSLT_SAB_IGNORE_DOC_NOT_FOUND", SAB_IGNORE_DOC_NOT_FOUND, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XSLT_SABOPT_PARSE_PUBLIC_ENTITIES", SAB_PARSE_PUBLIC_ENTITIES, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XSLT_SABOPT_DISABLE_ADDING_META", SAB_DISABLE_ADDING_META, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XSLT_SABOPT_DISABLE_STRIPPING", SAB_DISABLE_STRIPPING, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("XSLT_SABOPT_IGNORE_DOC_NOT_FOUND", SAB_IGNORE_DOC_NOT_FOUND, CONST_CS | CONST_PERSISTENT); return SUCCESS; } @@ -1534,10 +1536,7 @@ static MH_ERROR error_log(void *user_data, SablotHandle proc, MH_ERROR code, MH_ if (level == MH_LEVEL_WARN || level == MH_LEVEL_ERROR || level == MH_LEVEL_CRITICAL) { - if (XSLT_ERRSTR(handle)) - efree(XSLT_ERRSTR(handle)); - - XSLT_ERRSTR(handle) = estrdup(errmsg); + XSLT_REG_ERRMSG(errmsg, handle); } /* If we haven't allocated and opened the file yet */ @@ -1722,13 +1721,7 @@ static MH_ERROR error_print(void *user_data, SablotHandle proc, MH_ERROR code, M msgbuf = emalloc((sizeof(msgformat) - 4) + strlen(errmsg) + strlen(errline) + 1); sprintf(msgbuf, msgformat, errline, errmsg); - /* If an old message exists, remove it -> leak */ - if (XSLT_ERRSTR(handle)) - efree(XSLT_ERRSTR(handle)); - - /* Copy the error message onto the handle for use when - the xslt_error function is called */ - XSLT_ERRSTR(handle) = estrdup(errmsg); + XSLT_REG_ERRMSG(errmsg, handle); /* Output a warning */ php_error(E_WARNING, msgbuf); |