nlopess Tue Sep 5 15:25:44 2006 UTC Modified files: /php-src/ext/tidy php_tidy.h tidy.c /php-src/ext/tidy/tests 023.phpt 007.phpt Log: sync code and tests with PHP_5_2
http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/php_tidy.h?r1=1.31&r2=1.32&diff_format=u Index: php-src/ext/tidy/php_tidy.h diff -u php-src/ext/tidy/php_tidy.h:1.31 php-src/ext/tidy/php_tidy.h:1.32 --- php-src/ext/tidy/php_tidy.h:1.31 Wed Aug 30 22:53:42 2006 +++ php-src/ext/tidy/php_tidy.h Tue Sep 5 15:25:44 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_tidy.h,v 1.31 2006/08/30 22:53:42 tony2001 Exp $ */ +/* $Id: php_tidy.h,v 1.32 2006/09/05 15:25:44 nlopess Exp $ */ #ifndef PHP_TIDY_H #define PHP_TIDY_H @@ -39,58 +39,6 @@ #define TIDY_ATTR_METHOD(name) PHP_FUNCTION(tam_ ##name) #define TIDY_ATTR_ME(name, param) TIDY_METHOD_MAP(name, tam_ ##name, param) -static PHP_MINIT_FUNCTION(tidy); -static PHP_MSHUTDOWN_FUNCTION(tidy); -static PHP_RINIT_FUNCTION(tidy); -static PHP_MINFO_FUNCTION(tidy); - -static PHP_FUNCTION(tidy_getopt); -static PHP_FUNCTION(tidy_parse_string); -static PHP_FUNCTION(tidy_parse_file); -static PHP_FUNCTION(tidy_clean_repair); -static PHP_FUNCTION(tidy_repair_string); -static PHP_FUNCTION(tidy_repair_file); -static PHP_FUNCTION(tidy_diagnose); -static PHP_FUNCTION(tidy_get_output); -static PHP_FUNCTION(tidy_get_error_buffer); -static PHP_FUNCTION(tidy_get_release); -static PHP_FUNCTION(tidy_get_config); -static PHP_FUNCTION(tidy_get_status); -static PHP_FUNCTION(tidy_get_html_ver); -#if HAVE_TIDYOPTGETDOC -static PHP_FUNCTION(tidy_get_opt_doc); -#endif -static PHP_FUNCTION(tidy_is_xhtml); -static PHP_FUNCTION(tidy_is_xml); -static PHP_FUNCTION(tidy_error_count); -static PHP_FUNCTION(tidy_warning_count); -static PHP_FUNCTION(tidy_access_count); -static PHP_FUNCTION(tidy_config_count); - -static PHP_FUNCTION(ob_tidyhandler); - -static PHP_FUNCTION(tidy_get_root); -static PHP_FUNCTION(tidy_get_html); -static PHP_FUNCTION(tidy_get_head); -static PHP_FUNCTION(tidy_get_body); - -static TIDY_DOC_METHOD(__construct); -static TIDY_DOC_METHOD(parseFile); -static TIDY_DOC_METHOD(parseString); - -static TIDY_NODE_METHOD(__construct); -static TIDY_NODE_METHOD(hasChildren); -static TIDY_NODE_METHOD(hasSiblings); -static TIDY_NODE_METHOD(isComment); -static TIDY_NODE_METHOD(isHtml); -static TIDY_NODE_METHOD(isXhtml); -static TIDY_NODE_METHOD(isXml); -static TIDY_NODE_METHOD(isText); -static TIDY_NODE_METHOD(isJste); -static TIDY_NODE_METHOD(isAsp); -static TIDY_NODE_METHOD(isPhp); -static TIDY_NODE_METHOD(getParent); - ZEND_BEGIN_MODULE_GLOBALS(tidy) char *default_config; zval *inst; http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/tidy.c?r1=1.96&r2=1.97&diff_format=u Index: php-src/ext/tidy/tidy.c diff -u php-src/ext/tidy/tidy.c:1.96 php-src/ext/tidy/tidy.c:1.97 --- php-src/ext/tidy/tidy.c:1.96 Thu Aug 31 13:58:07 2006 +++ php-src/ext/tidy/tidy.c Tue Sep 5 15:25:44 2006 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: tidy.c,v 1.96 2006/08/31 13:58:07 tony2001 Exp $ */ +/* $Id: tidy.c,v 1.97 2006/09/05 15:25:44 nlopess Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -30,9 +30,6 @@ #include "php_ini.h" #include "ext/standard/info.h" -#include "Zend/zend_exceptions.h" -#include "Zend/zend_object_handlers.h" - #include "tidy.h" #include "buffio.h" @@ -223,7 +220,6 @@ static void tidy_object_free_storage(void * TSRMLS_DC); static zend_object_value tidy_object_new_node(zend_class_entry * TSRMLS_DC); static zend_object_value tidy_object_new_doc(zend_class_entry * TSRMLS_DC); -static zend_object_value tidy_object_new_exception(zend_class_entry * TSRMLS_DC); static zend_class_entry *tidy_get_ce_node(zval * TSRMLS_DC); static zend_class_entry *tidy_get_ce_doc(zval * TSRMLS_DC); static zval * tidy_instanciate(zend_class_entry *, zval * TSRMLS_DC); @@ -237,6 +233,56 @@ static int _php_tidy_apply_config_array(TidyDoc doc, HashTable *ht_options TSRMLS_DC); static void _php_tidy_register_nodetypes(INIT_FUNC_ARGS); static void _php_tidy_register_tags(INIT_FUNC_ARGS); + +static PHP_MINIT_FUNCTION(tidy); +static PHP_MSHUTDOWN_FUNCTION(tidy); +static PHP_RINIT_FUNCTION(tidy); +static PHP_MINFO_FUNCTION(tidy); + +static PHP_FUNCTION(tidy_getopt); +static PHP_FUNCTION(tidy_parse_string); +static PHP_FUNCTION(tidy_parse_file); +static PHP_FUNCTION(tidy_clean_repair); +static PHP_FUNCTION(tidy_repair_string); +static PHP_FUNCTION(tidy_repair_file); +static PHP_FUNCTION(tidy_diagnose); +static PHP_FUNCTION(tidy_get_output); +static PHP_FUNCTION(tidy_get_error_buffer); +static PHP_FUNCTION(tidy_get_release); +static PHP_FUNCTION(tidy_reset_config); +static PHP_FUNCTION(tidy_get_config); +static PHP_FUNCTION(tidy_get_status); +static PHP_FUNCTION(tidy_get_html_ver); +#if HAVE_TIDYOPTGETDOC +static PHP_FUNCTION(tidy_get_opt_doc); +#endif +static PHP_FUNCTION(tidy_is_xhtml); +static PHP_FUNCTION(tidy_is_xml); +static PHP_FUNCTION(tidy_error_count); +static PHP_FUNCTION(tidy_warning_count); +static PHP_FUNCTION(tidy_access_count); +static PHP_FUNCTION(tidy_config_count); + +static PHP_FUNCTION(ob_tidyhandler); + +static PHP_FUNCTION(tidy_get_root); +static PHP_FUNCTION(tidy_get_html); +static PHP_FUNCTION(tidy_get_head); +static PHP_FUNCTION(tidy_get_body); + +static TIDY_DOC_METHOD(__construct); +static TIDY_DOC_METHOD(parseFile); +static TIDY_DOC_METHOD(parseString); + +static TIDY_NODE_METHOD(hasChildren); +static TIDY_NODE_METHOD(hasSiblings); +static TIDY_NODE_METHOD(isComment); +static TIDY_NODE_METHOD(isHtml); +static TIDY_NODE_METHOD(isText); +static TIDY_NODE_METHOD(isJste); +static TIDY_NODE_METHOD(isAsp); +static TIDY_NODE_METHOD(isPhp); +static TIDY_NODE_METHOD(getParent); /* }}} */ ZEND_DECLARE_MODULE_GLOBALS(tidy) @@ -303,7 +349,6 @@ }; static zend_function_entry tidy_funcs_node[] = { - TIDY_NODE_ME(__construct, NULL) TIDY_NODE_ME(hasChildren, NULL) TIDY_NODE_ME(hasSiblings, NULL) TIDY_NODE_ME(isComment, NULL) @@ -316,11 +361,10 @@ {NULL, NULL, NULL} }; -zend_class_entry *tidy_ce_doc, *tidy_ce_node, *tidy_ce_exception; +static zend_class_entry *tidy_ce_doc, *tidy_ce_node; static zend_object_handlers tidy_object_handlers_doc; static zend_object_handlers tidy_object_handlers_node; -static zend_object_handlers tidy_object_handlers_exception; zend_module_entry tidy_module_entry = { STANDARD_MODULE_HEADER, @@ -611,13 +655,6 @@ return retval; } -static zend_object_value tidy_object_new_exception(zend_class_entry *class_type TSRMLS_DC) -{ - zend_object_value retval; - tidy_object_new(class_type, &tidy_object_handlers_exception, &retval, is_exception TSRMLS_CC); - return retval; -} - static zend_class_entry *tidy_get_ce_node(zval *object TSRMLS_DC) { return tidy_ce_node; @@ -991,7 +1028,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.96 2006/08/31 13:58:07 tony2001 Exp $)"); + php_info_print_table_row(2, "Extension Version", PHP_TIDY_MODULE_VERSION " ($Id: tidy.c,v 1.97 2006/09/05 15:25:44 nlopess Exp $)"); php_info_print_table_end(); DISPLAY_INI_ENTRIES(); @@ -1555,13 +1592,6 @@ } /* }}} */ -/* {{{ proto tidyNode::tidyNode() - Constructor. */ -static TIDY_NODE_METHOD(__construct) -{ -} -/* }}} */ - /* {{{ proto bool tidyNode::hasChildren() U Returns true if this node has children */ static TIDY_NODE_METHOD(hasChildren) @@ -1618,34 +1648,6 @@ } /* }}} */ -/* {{{ proto bool tidyNode::isXhtml() U - Returns true if this node is part of a XHTML document */ -static TIDY_NODE_METHOD(isXhtml) -{ - TIDY_FETCH_ONLY_OBJECT; - - if (tidyDetectedXhtml(obj->ptdoc->doc)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto bool tidyNode::isXml() U - Returns true if this node is part of a XML document */ -static TIDY_NODE_METHOD(isXml) -{ - TIDY_FETCH_ONLY_OBJECT; - - if (tidyDetectedGenericXml(obj->ptdoc->doc)) { - RETURN_TRUE; - } else { - RETURN_FALSE; - } -} -/* }}} */ - /* {{{ proto bool tidyNode::isText() U Returns true if this node represents text (no markup) */ static TIDY_NODE_METHOD(isText) http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/tests/023.phpt?r1=1.1&r2=1.2&diff_format=u Index: php-src/ext/tidy/tests/023.phpt diff -u /dev/null php-src/ext/tidy/tests/023.phpt:1.2 --- /dev/null Tue Sep 5 15:25:44 2006 +++ php-src/ext/tidy/tests/023.phpt Tue Sep 5 15:25:44 2006 @@ -0,0 +1,67 @@ +--TEST-- +tidy and tidyNode OO +--SKIPIF-- +<?php if (!extension_loaded('tidy')) echo 'skip'; ?> +--FILE-- +<?php + +//test leaks here: +new tidyNode(); +var_dump(new tidyNode()); +new tidy(); +var_dump(new tidy()); + +echo "-------\n"; + +$x = new tidyNode(); +var_dump($x->isHtml()); + +$tidy = new tidy(); +$tidy->parseString('<html><?php echo "xpto;" ?></html>'); + +var_dump(tidy_get_root($tidy)->child[0]->isHtml()); +var_dump(tidy_get_root($tidy)->child[0]->child[0]->isPHP()); +var_dump(tidy_get_root($tidy)->child[0]->child[0]->isAsp()); +var_dump(tidy_get_root($tidy)->child[0]->child[0]->isJste()); +var_dump(tidy_get_root($tidy)->child[0]->child[0]->type === TIDY_NODETYPE_PHP); + +var_dump(tidy_get_root($tidy)->child[0]->hasChildren()); +var_dump(tidy_get_root($tidy)->child[0]->child[0]->hasChildren()); + +?> +--EXPECT-- +object(tidyNode)#1 (0) { +} +object(tidy)#1 (2) { + ["errorBuffer"]=> + NULL + ["value"]=> + NULL +} +------- +bool(false) +bool(true) +bool(true) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) +--UEXPECT-- +object(tidyNode)#1 (0) { +} +object(tidy)#1 (2) { + [u"errorBuffer"]=> + NULL + [u"value"]=> + NULL +} +------- +bool(false) +bool(true) +bool(true) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) http://cvs.php.net/viewvc.cgi/php-src/ext/tidy/tests/007.phpt?r1=1.10&r2=1.11&diff_format=u Index: php-src/ext/tidy/tests/007.phpt diff -u php-src/ext/tidy/tests/007.phpt:1.10 php-src/ext/tidy/tests/007.phpt:1.11 --- php-src/ext/tidy/tests/007.phpt:1.10 Sun May 7 18:11:40 2006 +++ php-src/ext/tidy/tests/007.phpt Tue Sep 5 15:25:44 2006 @@ -4,6 +4,7 @@ <?php if (!extension_loaded("tidy")) print "skip"; ?> --INI-- tidy.default_config= +unicode.script_encoding=latin1 --FILE-- <?php $a = new tidy(dirname(__FILE__)."/007.html"); @@ -13,13 +14,27 @@ var_dump($a->getopt("error-file")); echo "Current Value of 'tab-size': "; var_dump($a->getopt("tab-size")); - + + var_dump($a->getopt('bogus-opt')); + var_dump(tidy_getopt($a, 'non-ASCII string àáç')); ?> ---EXPECT-- +--EXPECTF-- Current Value of 'tidy-mark': bool(false) Current Value of 'error-file': string(0) "" Current Value of 'tab-size': int(8) ---UEXPECT-- + +Warning: tidy::getOpt(): Unknown Tidy Configuration Option 'bogus-opt' in %s007.php on line 10 +bool(false) + +Warning: tidy_getopt(): Unknown Tidy Configuration Option 'non-ASCII string àáç' in %s007.php on line 11 +bool(false) +--UEXPECTF-- Current Value of 'tidy-mark': bool(false) Current Value of 'error-file': unicode(0) "" Current Value of 'tab-size': int(8) + +Warning: tidy::getOpt(): Unknown Tidy Configuration Option 'bogus-opt' in %s007.php on line 10 +bool(false) + +Warning: tidy_getopt(): Unknown Tidy Configuration Option 'non-ASCII string àáç' in %s007.php on line 11 +bool(false)
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php