]> granicus.if.org Git - php/commitdiff
- Add XSLT_REG_ERRMSG macro to register an error on the handle
authorMelvyn Sopacua <msopacua@php.net>
Fri, 25 Oct 2002 19:23:15 +0000 (19:23 +0000)
committerMelvyn Sopacua <msopacua@php.net>
Fri, 25 Oct 2002 19:23:15 +0000 (19:23 +0000)
- 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.

ext/xslt/php_sablot.h
ext/xslt/sablot.c

index ad33f531501b923d67efd8d377c6508ba304fe3f..fde066bc0bf87552b6a312977f6d95cc83c29d47 100644 (file)
@@ -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);
index 69e39115e3b299ce68e1cdd3761be70d75f8bbd5..4c06b6224c5892fc4a5a02c27a50856a49a2e38e 100644 (file)
@@ -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);