]> granicus.if.org Git - php/commitdiff
sync code and tests with PHP_5_2
authorNuno Lopes <nlopess@php.net>
Tue, 5 Sep 2006 15:25:44 +0000 (15:25 +0000)
committerNuno Lopes <nlopess@php.net>
Tue, 5 Sep 2006 15:25:44 +0000 (15:25 +0000)
ext/tidy/php_tidy.h
ext/tidy/tests/007.phpt
ext/tidy/tests/023.phpt [new file with mode: 0644]
ext/tidy/tidy.c

index f321eedd08075aa4769b7872862f31f6c952b0df..dd1aa7b31a2fcd7f9495126b3da0a8c3520839ec 100644 (file)
@@ -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;
index 0b506ac1ddb8142c2dc6edec43ae282cbf2013f9..27b02c557950cef9002b168eddcc3cca80d93a93 100644 (file)
@@ -4,6 +4,7 @@ Verbose  tidy_getopt()
 <?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 @@ tidy.default_config=
                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)
diff --git a/ext/tidy/tests/023.phpt b/ext/tidy/tests/023.phpt
new file mode 100644 (file)
index 0000000..dd33b78
--- /dev/null
@@ -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)
index 1a275daf005082904639b3f74f06de124047a3f9..c62f08558742c700c67d72af58dda9d65f53f794 100644 (file)
@@ -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)