msopacua                Fri Oct 25 15:23:14 2002 EDT

  Modified files:              
    /php4/ext/xslt      php_sablot.h sablot.c 
  Log:
  - 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.
  
  
Index: php4/ext/xslt/php_sablot.h
diff -u php4/ext/xslt/php_sablot.h:1.14 php4/ext/xslt/php_sablot.h:1.15
--- php4/ext/xslt/php_sablot.h:1.14     Tue Oct 15 12:41:38 2002
+++ php4/ext/xslt/php_sablot.h  Fri Oct 25 15:23:13 2002
@@ -48,6 +48,8 @@
 #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: php4/ext/xslt/sablot.c
diff -u php4/ext/xslt/sablot.c:1.58 php4/ext/xslt/sablot.c:1.59
--- php4/ext/xslt/sablot.c:1.58 Tue Oct 15 12:41:38 2002
+++ php4/ext/xslt/sablot.c      Fri Oct 25 15:23:13 2002
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: sablot.c,v 1.58 2002/10/15 16:41:38 sterling Exp $ */
+/* $Id: sablot.c,v 1.59 2002/10/25 19:23:13 msopacua Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -158,13 +158,15 @@
        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 @@
        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 @@
                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);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to