From: Nuno Lopes Date: Tue, 5 Sep 2006 15:25:44 +0000 (+0000) Subject: sync code and tests with PHP_5_2 X-Git-Tag: RELEASE_1_0_0RC1~1765 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb07c93c04224bdf88d3a8862667454da5051e95;p=php sync code and tests with PHP_5_2 --- diff --git a/ext/tidy/php_tidy.h b/ext/tidy/php_tidy.h index f321eedd08..dd1aa7b31a 100644 --- a/ext/tidy/php_tidy.h +++ b/ext/tidy/php_tidy.h @@ -39,58 +39,6 @@ extern zend_module_entry tidy_module_entry; #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; diff --git a/ext/tidy/tests/007.phpt b/ext/tidy/tests/007.phpt index 0b506ac1dd..27b02c5579 100644 --- a/ext/tidy/tests/007.phpt +++ b/ext/tidy/tests/007.phpt @@ -4,6 +4,7 @@ Verbose tidy_getopt() --INI-- tidy.default_config= +unicode.script_encoding=latin1 --FILE-- 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) diff --git a/ext/tidy/tests/023.phpt b/ext/tidy/tests/023.phpt new file mode 100644 index 0000000000..dd33b78368 --- /dev/null +++ b/ext/tidy/tests/023.phpt @@ -0,0 +1,67 @@ +--TEST-- +tidy and tidyNode OO +--SKIPIF-- + +--FILE-- +isHtml()); + +$tidy = new tidy(); +$tidy->parseString(''); + +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) diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c index 1a275daf00..c62f085587 100644 --- a/ext/tidy/tidy.c +++ b/ext/tidy/tidy.c @@ -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 char *php_tidy_file_to_mem(char *, zend_bool, int * TSRMLS_DC); 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_set_tidy_opt(TidyDoc, char *, zval * TSRMLS_DC); 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_doc[] = { }; 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 @@ static zend_function_entry tidy_funcs_node[] = { {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 @@ static zend_object_value tidy_object_new_doc(zend_class_entry *class_type TSRMLS 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; @@ -1555,13 +1592,6 @@ static PHP_FUNCTION(tidy_get_body) } /* }}} */ -/* {{{ 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 @@ static TIDY_NODE_METHOD(isHtml) } /* }}} */ -/* {{{ 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)