john Sun Apr 11 23:14:19 2004 EDT Modified files: /php-src/ext/tidy php_tidy.h tidy.c Log: - Removed things related to attribute classes / consts which no longer exist in Tidy - Changed protos in comment blocks to studlyCaps - Fixed problem where Tidy would throw exceptions if called from a procedural context. Tidy will now cause E_ERRORs if called from procedural form. http://cvs.php.net/diff.php/php-src/ext/tidy/php_tidy.h?r1=1.21&r2=1.22&ty=u Index: php-src/ext/tidy/php_tidy.h diff -u php-src/ext/tidy/php_tidy.h:1.21 php-src/ext/tidy/php_tidy.h:1.22 --- php-src/ext/tidy/php_tidy.h:1.21 Sun Feb 22 19:59:29 2004 +++ php-src/ext/tidy/php_tidy.h Sun Apr 11 23:14:19 2004 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_tidy.h,v 1.21 2004/02/23 00:59:29 sniper Exp $ */ +/* $Id: php_tidy.h,v 1.22 2004/04/12 03:14:19 john Exp $ */ #ifndef PHP_TIDY_H #define PHP_TIDY_H @@ -91,6 +91,7 @@ ZEND_BEGIN_MODULE_GLOBALS(tidy) char *default_config; + zval *inst; ZEND_END_MODULE_GLOBALS(tidy) #ifdef ZTS http://cvs.php.net/diff.php/php-src/ext/tidy/tidy.c?r1=1.41&r2=1.42&ty=u Index: php-src/ext/tidy/tidy.c diff -u php-src/ext/tidy/tidy.c:1.41 php-src/ext/tidy/tidy.c:1.42 --- php-src/ext/tidy/tidy.c:1.41 Thu Feb 26 08:22:11 2004 +++ php-src/ext/tidy/tidy.c Sun Apr 11 23:14:19 2004 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tidy.c,v 1.41 2004/02/26 13:22:11 sniper Exp $ */ +/* $Id: tidy.c,v 1.42 2004/04/12 03:14:19 john Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -49,8 +49,13 @@ tdoc = obj->ptdoc; \ } +#define TIDY_SET_CONTEXT \ + zval *object; \ + TG(inst) = getThis(); \ + object = TG(inst) + #define TIDY_FETCH_OBJECT \ - zval *object = getThis(); \ + TIDY_SET_CONTEXT; \ PHPTidyObj *obj; \ if (object) { \ if (ZEND_NUM_ARGS()) { \ @@ -64,7 +69,7 @@ obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC); \ #define TIDY_FETCH_ONLY_OBJECT \ - zval *object = getThis(); \ + TIDY_SET_CONTEXT; \ PHPTidyObj *obj; \ if (ZEND_NUM_ARGS()) { \ WRONG_PARAM_COUNT; \ @@ -88,14 +93,7 @@ } \ } -/* This is necessary, as apparently some Win32 compilers aren't C99 - compliant. When that isn't the case we can't use variable arg preprocessor - macros and need to instead call a wrapper function */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L -#define TIDY_THROW(...) zend_throw_exception_ex(tidy_ce_exception, 0 TSRMLS_CC, __VA_ARGS__) -#else #define TIDY_THROW _php_tidy_throw_exception -#endif #define REGISTER_TIDY_CLASS(classname, name, parent) \ { \ @@ -109,7 +107,6 @@ } #define TIDY_TAG_CONST(tag) REGISTER_LONG_CONSTANT("TIDY_TAG_" #tag, TidyTag_##tag, CONST_CS | CONST_PERSISTENT) -#define TIDY_ATTR_CONST(attr) REGISTER_LONG_CONSTANT("TIDY_ATTR_" #attr, TidyAttr_##attr, CONST_CS | CONST_PERSISTENT) #define TIDY_NODE_CONST(name, type) REGISTER_LONG_CONSTANT("TIDY_NODETYPE_" #name, TidyNode_##type, CONST_CS | CONST_PERSISTENT) #ifndef TRUE @@ -168,7 +165,6 @@ typedef enum { is_node, - is_attr, is_doc, is_exception } tidy_obj_type; @@ -337,18 +333,23 @@ zend_error(E_ERROR, "Could not allocate memory for tidy! (Reason: %s)", (char *)msg); } -/* Workaround for compilers that are not C99 complaint */ static void _php_tidy_throw_exception(char *message, ...) { char *msg; va_list ap; TSRMLS_FETCH(); - + va_start(ap, message); vspprintf(&msg, 0, message, ap); - zend_throw_exception(tidy_ce_exception, msg, 0 TSRMLS_CC); - va_end(ap); + + if(TG(inst)) { + zend_throw_exception(tidy_ce_exception, msg, 0 TSRMLS_CC); + } else { + php_error_docref(NULL TSRMLS_CC, E_ERROR, msg); + } + + va_end(ap); efree(msg); } @@ -408,7 +409,6 @@ TidyBuffer *errbuf; zval *config; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|zsb", &arg1, &arg1_len, &config, &enc, &enc_len, &use_include_path) == FAILURE) { RETURN_FALSE; } @@ -602,6 +602,7 @@ if (!object) { ALLOC_ZVAL(object); } + Z_TYPE_P(object) = IS_OBJECT; object_init_ex(object, pce); object->refcount = 1; @@ -894,10 +895,12 @@ static void tidy_globals_ctor(void *global TSRMLS_DC) { + } static void tidy_globals_dtor(void *global TSRMLS_DC) { + } PHP_MINIT_FUNCTION(tidy) @@ -948,7 +951,7 @@ php_info_print_table_start(); php_info_print_table_header(2, "Tidy support", "enabled"); php_info_print_table_row(2, "libTidy Release", (char *)tidyReleaseDate()); - php_info_print_table_row(2, "Extension Version", PHP_TIDY_MODULE_VERSION " ($Id: tidy.c,v 1.41 2004/02/26 13:22:11 sniper Exp $)"); + php_info_print_table_row(2, "Extension Version", PHP_TIDY_MODULE_VERSION " ($Id: tidy.c,v 1.42 2004/04/12 03:14:19 john Exp $)"); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); @@ -1272,7 +1275,8 @@ Returns the value of the specified configuration option for the tidy document. */ PHP_FUNCTION(tidy_getopt) { - zval *object = getThis(); + TIDY_SET_CONTEXT; + PHPTidyObj *obj; char *optname; void *optval; @@ -1333,7 +1337,8 @@ char *contents; zval *options = NULL; - zval *object = getThis(); + TIDY_SET_CONTEXT; + PHPTidyObj *obj; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|szsb", &inputfile, &input_len, @@ -1363,9 +1368,10 @@ zend_bool use_include_path = 0; char *contents; zval *options = NULL; - zval *object = getThis(); - PHPTidyObj *obj; - + PHPTidyObj *obj; + + TIDY_SET_CONTEXT; + obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC); if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|zsb", &inputfile, &input_len, @@ -1394,9 +1400,9 @@ char *input, *enc = NULL; int input_len, enc_len = 0; zval *options = NULL; - - zval *object = getThis(); PHPTidyObj *obj; + + TIDY_SET_CONTEXT; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|zs", &input, &input_len, &options, &enc, &enc_len) == FAILURE) { RETURN_FALSE; @@ -1453,7 +1459,7 @@ } /* }}} */ -/* {{{ proto boolean tidy_node::has_children() +/* {{{ proto boolean tidy_node::hasChildren() Returns true if this node has children */ TIDY_NODE_METHOD(hasChildren) { @@ -1467,7 +1473,7 @@ } /* }}} */ -/* {{{ proto boolean tidy_node::has_siblings() +/* {{{ proto boolean tidy_node::hasSiblings() Returns true if this node has siblings */ TIDY_NODE_METHOD(hasSiblings) { @@ -1481,7 +1487,7 @@ } /* }}} */ -/* {{{ proto boolean tidy_node::is_comment() +/* {{{ proto boolean tidy_node::isComment() Returns true if this node represents a comment */ TIDY_NODE_METHOD(isComment) { @@ -1495,7 +1501,7 @@ } /* }}} */ -/* {{{ proto boolean tidy_node::is_html() +/* {{{ proto boolean tidy_node::isHtml() Returns true if this node is part of a HTML document */ TIDY_NODE_METHOD(isHtml) { @@ -1509,7 +1515,7 @@ } /* }}} */ -/* {{{ proto boolean tidy_node::is_xhtml() +/* {{{ proto boolean tidy_node::isXhtml() Returns true if this node is part of a XHTML document */ TIDY_NODE_METHOD(isXhtml) { @@ -1523,7 +1529,7 @@ } /* }}} */ -/* {{{ proto boolean tidy_node::is_xml() +/* {{{ proto boolean tidy_node::isXml() Returns true if this node is part of a XML document */ TIDY_NODE_METHOD(isXml) { @@ -1537,7 +1543,7 @@ } /* }}} */ -/* {{{ proto boolean tidy_node::is_text() +/* {{{ proto boolean tidy_node::isText() Returns true if this node represents text (no markup) */ TIDY_NODE_METHOD(isText) { @@ -1551,7 +1557,7 @@ } /* }}} */ -/* {{{ proto boolean tidy_node::is_jste() +/* {{{ proto boolean tidy_node::isJste() Returns true if this node is JSTE */ TIDY_NODE_METHOD(isJste) { @@ -1565,7 +1571,7 @@ } /* }}} */ -/* {{{ proto boolean tidy_node::is_asp() +/* {{{ proto boolean tidy_node::isAsp() Returns true if this node is ASP */ TIDY_NODE_METHOD(isAsp) { @@ -1579,7 +1585,7 @@ } /* }}} */ -/* {{{ proto boolean tidy_node::is_php() +/* {{{ proto boolean tidy_node::isPhp() Returns true if this node is PHP */ TIDY_NODE_METHOD(isPhp) {
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php