summaryrefslogtreecommitdiff
path: root/ext/tidy/tidy.c
diff options
context:
space:
mode:
Diffstat (limited to 'ext/tidy/tidy.c')
-rw-r--r--ext/tidy/tidy.c62
1 files changed, 25 insertions, 37 deletions
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c
index 856a8a2f23..561ece618b 100644
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -89,28 +89,10 @@
} \
}
-#define REGISTER_TIDY_CLASS(classname, name, parent, __flags) \
- { \
- zend_class_entry ce; \
- INIT_CLASS_ENTRY(ce, # classname, class_ ## classname ## _methods); \
- ce.create_object = tidy_object_new_ ## name; \
- tidy_ce_ ## name = zend_register_internal_class_ex(&ce, parent); \
- tidy_ce_ ## name->ce_flags |= __flags; \
- memcpy(&tidy_object_handlers_ ## name, &std_object_handlers, sizeof(zend_object_handlers)); \
- tidy_object_handlers_ ## name.clone_obj = NULL; \
- }
#define TIDY_TAG_CONST(tag) REGISTER_LONG_CONSTANT("TIDY_TAG_" #tag, TidyTag_##tag, CONST_CS | CONST_PERSISTENT)
#define TIDY_NODE_CONST(name, type) REGISTER_LONG_CONSTANT("TIDY_NODETYPE_" #name, TidyNode_##type, CONST_CS | CONST_PERSISTENT)
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef FALSE
-#define FALSE 0
-#endif
-
#define ADD_PROPERTY_STRING(_table, _key, _string) \
{ \
zval tmp; \
@@ -205,7 +187,7 @@ static inline PHPTidyObj *php_tidy_fetch_object(zend_object *obj) {
/* }}} */
/* {{{ ext/tidy prototypes */
-static zend_string *php_tidy_file_to_mem(char *, zend_bool);
+static zend_string *php_tidy_file_to_mem(char *, bool);
static void tidy_object_free_storage(zend_object *);
static zend_object *tidy_object_new_node(zend_class_entry *);
static zend_object *tidy_object_new_doc(zend_class_entry *);
@@ -335,7 +317,7 @@ static int _php_tidy_set_tidy_opt(TidyDoc doc, char *optname, zval *value)
return FAILURE;
}
-static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_file)
+static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, bool is_file)
{
char *enc = NULL;
size_t enc_len = 0;
@@ -345,7 +327,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil
HashTable *config_ht = NULL;
if (is_file) {
- zend_bool use_include_path = 0;
+ bool use_include_path = 0;
ZEND_PARSE_PARAMETERS_START(1, 4)
Z_PARAM_PATH_STR(arg1)
@@ -432,7 +414,7 @@ static void php_tidy_quick_repair(INTERNAL_FUNCTION_PARAMETERS, zend_bool is_fil
tidyRelease(doc);
}
-static zend_string *php_tidy_file_to_mem(char *filename, zend_bool use_include_path)
+static zend_string *php_tidy_file_to_mem(char *filename, bool use_include_path)
{
php_stream *stream;
zend_string *data = NULL;
@@ -770,9 +752,7 @@ static void php_tidy_create_node(INTERNAL_FUNCTION_PARAMETERS, tidy_base_nodetyp
node = tidyGetBody(obj->ptdoc->doc);
break;
- default:
- RETURN_NULL();
- break;
+ EMPTY_SWITCH_DEFAULT_CASE()
}
if (!node) {
@@ -836,8 +816,16 @@ static PHP_MINIT_FUNCTION(tidy)
tidySetPanicCall(php_tidy_panic);
REGISTER_INI_ENTRIES();
- REGISTER_TIDY_CLASS(tidy, doc, NULL, 0);
- REGISTER_TIDY_CLASS(tidyNode, node, NULL, ZEND_ACC_FINAL);
+
+ tidy_ce_doc = register_class_tidy();
+ tidy_ce_doc->create_object = tidy_object_new_doc;
+ memcpy(&tidy_object_handlers_doc, &std_object_handlers, sizeof(zend_object_handlers));
+ tidy_object_handlers_doc.clone_obj = NULL;
+
+ tidy_ce_node = register_class_tidyNode();
+ tidy_ce_node->create_object = tidy_object_new_node;
+ memcpy(&tidy_object_handlers_node, &std_object_handlers, sizeof(zend_object_handlers));
+ tidy_object_handlers_node.clone_obj = NULL;
tidy_object_handlers_doc.cast_object = tidy_doc_cast_handler;
tidy_object_handlers_node.cast_object = tidy_node_cast_handler;
@@ -897,16 +885,16 @@ static PHP_MINFO_FUNCTION(tidy)
static PHP_INI_MH(php_tidy_set_clean_output)
{
int status;
- zend_bool value;
+ bool value;
if (ZSTR_LEN(new_value)==2 && strcasecmp("on", ZSTR_VAL(new_value))==0) {
- value = (zend_bool) 1;
+ value = (bool) 1;
} else if (ZSTR_LEN(new_value)==3 && strcasecmp("yes", ZSTR_VAL(new_value))==0) {
- value = (zend_bool) 1;
+ value = (bool) 1;
} else if (ZSTR_LEN(new_value)==4 && strcasecmp("true", ZSTR_VAL(new_value))==0) {
- value = (zend_bool) 1;
+ value = (bool) 1;
} else {
- value = (zend_bool) atoi(ZSTR_VAL(new_value));
+ value = (bool) atoi(ZSTR_VAL(new_value));
}
if (stage == PHP_INI_STAGE_RUNTIME) {
@@ -1065,7 +1053,7 @@ PHP_FUNCTION(tidy_parse_file)
{
char *enc = NULL;
size_t enc_len = 0;
- zend_bool use_include_path = 0;
+ bool use_include_path = 0;
zend_string *inputfile, *contents, *options_str = NULL;
HashTable *options_ht = NULL;
@@ -1120,14 +1108,14 @@ PHP_FUNCTION(tidy_clean_repair)
/* {{{ Repair a string using an optionally provided configuration file */
PHP_FUNCTION(tidy_repair_string)
{
- php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, FALSE);
+ php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, false);
}
/* }}} */
/* {{{ Repair a file using an optionally provided configuration file */
PHP_FUNCTION(tidy_repair_file)
{
- php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, TRUE);
+ php_tidy_quick_repair(INTERNAL_FUNCTION_PARAM_PASSTHRU, true);
}
/* }}} */
@@ -1359,7 +1347,7 @@ PHP_METHOD(tidy, __construct)
{
char *enc = NULL;
size_t enc_len = 0;
- zend_bool use_include_path = 0;
+ bool use_include_path = 0;
HashTable *options_ht = NULL;
zend_string *contents, *inputfile = NULL, *options_str = NULL;
PHPTidyObj *obj;
@@ -1398,7 +1386,7 @@ PHP_METHOD(tidy, parseFile)
{
char *enc = NULL;
size_t enc_len = 0;
- zend_bool use_include_path = 0;
+ bool use_include_path = 0;
HashTable *options_ht = NULL;
zend_string *inputfile, *contents, *options_str = NULL;
PHPTidyObj *obj;