jani                                     Tue, 29 Dec 2009 12:46:48 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=292756

Log:
- WS + CS

Changed paths:
    U   php/php-src/trunk/ext/tidy/tidy.c

Modified: php/php-src/trunk/ext/tidy/tidy.c
===================================================================
--- php/php-src/trunk/ext/tidy/tidy.c	2009-12-29 12:45:51 UTC (rev 292755)
+++ php/php-src/trunk/ext/tidy/tidy.c	2009-12-29 12:46:48 UTC (rev 292756)
@@ -45,7 +45,7 @@
 #define FIX_BUFFER(bptr) do { if ((bptr)->size) { (bptr)->bp[(bptr)->size-1] = '\0'; } } while(0)

 #define TIDY_SET_CONTEXT \
-    zval *object = getThis();
+	zval *object = getThis();

 #define TIDY_FETCH_OBJECT	\
 	PHPTidyObj *obj;	\
@@ -70,22 +70,22 @@
 	obj = (PHPTidyObj *) zend_object_store_get_object(object TSRMLS_CC);	\

 #define TIDY_APPLY_CONFIG_ZVAL(_doc, _val) \
-    if(_val) { \
-        if(Z_TYPE_PP(_val) == IS_ARRAY) { \
-            _php_tidy_apply_config_array(_doc, HASH_OF(*_val) TSRMLS_CC); \
-        } else if (Z_TYPE_PP(_val) != IS_NULL) { \
-            convert_to_string_ex(_val); \
-            TIDY_OPEN_BASEDIR_CHECK(Z_STRVAL_PP(_val)); \
-            switch (tidyLoadConfig(_doc, Z_STRVAL_PP(_val))) { \
-              case -1: \
-                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not load configuration file '%s'", Z_STRVAL_PP(_val)); \
-                break; \
-              case 1: \
-                php_error_docref(NULL TSRMLS_CC, E_NOTICE, "There were errors while parsing the configuration file '%s'", Z_STRVAL_PP(_val)); \
-                break; \
-            } \
-        } \
-    }
+	if (_val) { \
+		if (Z_TYPE_PP(_val) == IS_ARRAY) { \
+			_php_tidy_apply_config_array(_doc, HASH_OF(*_val) TSRMLS_CC); \
+		} else if (Z_TYPE_PP(_val) != IS_NULL) { \
+			convert_to_string_ex(_val); \
+			TIDY_OPEN_BASEDIR_CHECK(Z_STRVAL_PP(_val)); \
+			switch (tidyLoadConfig(_doc, Z_STRVAL_PP(_val))) { \
+				case -1: \
+					php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not load configuration file '%s'", Z_STRVAL_PP(_val)); \
+				break; \
+				case 1: \
+					php_error_docref(NULL TSRMLS_CC, E_NOTICE, "There were errors while parsing the configuration file '%s'", Z_STRVAL_PP(_val)); \
+				break; \
+			} \
+		} \
+	}

 #define REGISTER_TIDY_CLASS(classname, name, parent, __flags) \
 	{ \
@@ -122,16 +122,16 @@
 	}

 #define ADD_PROPERTY_STRINGL(_conv, _table, _key, _string, _len) \
-   { \
-       zval *tmp; \
-       MAKE_STD_ZVAL(tmp); \
-       if (_string) { \
-           ZVAL_U_STRINGL(_conv, tmp, (char *)_string, _len, 1); \
-       } else { \
-           ZVAL_EMPTY_STRING(tmp); \
-       } \
-       zend_ascii_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \
-   }
+	{ \
+		zval *tmp; \
+		MAKE_STD_ZVAL(tmp); \
+		if (_string) { \
+			ZVAL_U_STRINGL(_conv, tmp, (char *)_string, _len, 1); \
+		} else { \
+			ZVAL_EMPTY_STRING(tmp); \
+		} \
+		zend_ascii_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \
+}

 #define ADD_PROPERTY_LONG(_table, _key, _long) \
 	{ \
@@ -150,11 +150,11 @@
 	}

 #define ADD_PROPERTY_BOOL(_table, _key, _bool) \
-    { \
-       zval *tmp; \
-       MAKE_STD_ZVAL(tmp); \
-       ZVAL_BOOL(tmp, _bool); \
-       zend_ascii_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \
+	{ \
+		zval *tmp; \
+		MAKE_STD_ZVAL(tmp); \
+		ZVAL_BOOL(tmp, _bool); \
+		zend_ascii_hash_update(_table, #_key, sizeof(#_key), (void *)&tmp, sizeof(zval *), NULL); \
    }

 #define TIDY_OPEN_BASEDIR_CHECK(filename) \
@@ -170,7 +170,7 @@
 	}
 /* }}} */

-/* {{{ ext/tidy structs
+/* {{{ ext/tidy structs
 */
 typedef struct _PHPTidyDoc PHPTidyDoc;
 typedef struct _PHPTidyObj PHPTidyObj;
@@ -188,22 +188,22 @@
 } tidy_base_nodetypes;

 struct _PHPTidyDoc {
-	TidyDoc     doc;
-	TidyBuffer  *errbuf;
-	unsigned int ref_count;
+	TidyDoc			doc;
+	TidyBuffer		*errbuf;
+	unsigned int	ref_count;
 };

 typedef struct _PHPTidyConv {
-	UConverter *conv;
-	unsigned long ref_count;
+	UConverter		*conv;
+	unsigned long	ref_count;
 } PHPTidyConv;

 struct _PHPTidyObj {
-	zend_object         std;
-	TidyNode            node;
-	tidy_obj_type       type;
-	PHPTidyDoc          *ptdoc;
-	PHPTidyConv         *converter;
+	zend_object		std;
+	TidyNode		node;
+	tidy_obj_type	type;
+	PHPTidyDoc		*ptdoc;
+	PHPTidyConv		*converter;
 };
 /* }}} */

@@ -384,7 +384,7 @@
 	PHP_FE(tidy_parse_string,       arginfo_tidy_parse_string)
 	PHP_FE(tidy_parse_file,         arginfo_tidy_parse_file)
 	PHP_FE(tidy_get_output,         arginfo_tidy_get_output)
-	PHP_FE(tidy_get_error_buffer,   arginfo_tidy_get_error_buffer)
+	PHP_FE(tidy_get_error_buffer,   arginfo_tidy_get_error_buffer)
 	PHP_FE(tidy_clean_repair,       arginfo_tidy_clean_repair)
 	PHP_FE(tidy_repair_string,	arginfo_tidy_repair_string)
 	PHP_FE(tidy_repair_file,	arginfo_tidy_repair_file)
@@ -398,7 +398,7 @@
 	PHP_FE(tidy_error_count,	arginfo_tidy_error_count)
 	PHP_FE(tidy_warning_count,	arginfo_tidy_warning_count)
 	PHP_FE(tidy_access_count,	arginfo_tidy_access_count)
-	PHP_FE(tidy_config_count,	arginfo_tidy_config_count)
+	PHP_FE(tidy_config_count,	arginfo_tidy_config_count)
 #if HAVE_TIDYOPTGETDOC
 	PHP_FE(tidy_get_opt_doc,	arginfo_tidy_get_opt_doc)
 #endif
@@ -504,7 +504,7 @@
 		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Unknown Tidy Configuration Option '%s'", optname);
 		return FAILURE;
 	}
-
+
 	if (tidyOptIsReadOnly(opt)) {
 		php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Attempting to set read-only option '%s'", optname);
 		return FAILURE;
@@ -550,7 +550,7 @@
 		default:
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to determine type of configuration option");
 			break;
-	}
+	}

 	return FAILURE;
 }
@@ -567,7 +567,7 @@
 	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zsb", &arg1, &arg1_len, &config, &enc, &enc_len, &use_include_path) == FAILURE) {
 		RETURN_FALSE;
 	}
-
+
 	if (is_file) {
 		if (!(data = php_tidy_file_to_mem(arg1, use_include_path, &data_len TSRMLS_CC))) {
 			RETURN_FALSE;
@@ -580,36 +580,36 @@
 	doc = tidyCreate();
 	errbuf = emalloc(sizeof(TidyBuffer));
 	tidyBufInit(errbuf);
-
+
 	if (tidySetErrorBuffer(doc, errbuf) != 0) {
 		tidyBufFree(errbuf);
 		efree(errbuf);
 		tidyRelease(doc);
 		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Could not set Tidy error buffer");
 	}
-
+
 	tidyOptSetBool(doc, TidyForceOutput, yes);
 	tidyOptSetBool(doc, TidyMark, no);
-
+
 	TIDY_SET_DEFAULT_CONFIG(doc);

 	if (config) {
 		TIDY_APPLY_CONFIG_ZVAL(doc, config);
 	}

-	if(enc_len) {
+	if (enc_len) {
 		if (tidySetCharEncoding(doc, enc) < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not set encoding '%s'", enc);
 			RETVAL_FALSE;
 		}
 	}
-
+
 	if (data) {
 		TidyBuffer buf;

 		tidyBufInit(&buf);
 		tidyBufAttach(&buf, (byte *) data, data_len);
-
+
 		if (tidyParseBuffer(doc, &buf) < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", errbuf->bp);
 			RETVAL_FALSE;
@@ -631,7 +631,7 @@
 	if (is_file) {
 		efree(data);
 	}
-
+
 	tidyBufFree(errbuf);
 	efree(errbuf);
 	tidyRelease(doc);
@@ -679,8 +679,7 @@
 	efree(object);
 }

-static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers *handlers,
-							zend_object_value *retval, tidy_obj_type objtype TSRMLS_DC)
+static void tidy_object_new(zend_class_entry *class_type, zend_object_handlers *handlers, zend_object_value *retval, tidy_obj_type objtype TSRMLS_DC)
 {
 	PHPTidyObj *intern;
 	zval *tmp;
@@ -894,7 +893,7 @@
 				case TidyNode_Text:
 				case TidyNode_Comment:
 					break;
-
+
 				default:
 					ADD_PROPERTY_LONG(obj->std.properties, id, tidyNodeGetId(obj->node));
 			}
@@ -1033,7 +1032,7 @@
 	for (zend_hash_internal_pointer_reset(ht_options);
 		 zend_hash_get_current_data(ht_options, (void *) &opt_val) == SUCCESS;
 		 zend_hash_move_forward(ht_options)) {
-
+
 		switch (zend_hash_get_current_key_ex(ht_options, &opt_name, &opt_name_len, &opt_indx, FALSE, NULL)) {
 			case HASH_KEY_IS_STRING:
 			clear_str = 0;
@@ -1070,7 +1069,7 @@
 	TidyBuffer buf;
 	UErrorCode Uerror = U_ZERO_ERROR;

-	if(enc) {
+	if (enc) {
 		if (tidySetCharEncoding(obj->ptdoc->doc, enc) < 0) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not set encoding '%s'", enc);
 			return FAILURE;
@@ -1110,19 +1109,19 @@
 	_php_tidy_register_nodetypes(INIT_FUNC_ARGS_PASSTHRU);

 	PHP_OUTPUT_ALIAS_REGISTER("ob_tidyhandler", php_tidy_output_handler_init);
-
+
 	return SUCCESS;
 }

 static PHP_RINIT_FUNCTION(tidy)
 {
 	zval *name;
-
+
 	MAKE_STD_ZVAL(name);
 	ZVAL_ASCII_STRING(name, "ob_tidyhandler", ZSTR_DUPLICATE);
 	php_tidy_clean_output_start(name TSRMLS_CC);
 	zval_ptr_dtor(&name);
-
+
 	return SUCCESS;
 }

@@ -1147,7 +1146,7 @@
 {
 	int status;
 	zend_bool value;
-
+
 	if (new_value_length==2 && strcasecmp("on", new_value)==0) {
 		value = (zend_bool) 1;
 	} else if (new_value_length==3 && strcasecmp("yes", new_value)==0) {
@@ -1157,10 +1156,10 @@
 	} else {
 		value = (zend_bool) atoi(new_value);
 	}
-
+
 	if (stage == PHP_INI_STAGE_RUNTIME) {
 		status = php_output_get_status(TSRMLS_C);
-
+
 		if (value && (status & PHP_OUTPUT_WRITTEN)) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot enable tidy.clean_output - there has already been output");
 			return FAILURE;
@@ -1170,12 +1169,12 @@
 			return FAILURE;
 		}
 	}
-
+
 	status = OnUpdateBool(entry, new_value, new_value_length, mh_arg1, mh_arg2, mh_arg3, stage TSRMLS_CC);
-
+
 	if (stage == PHP_INI_STAGE_RUNTIME && value) {
 		zval *tmp;
-
+
 		MAKE_STD_ZVAL(tmp);
 		ZVAL_ASCII_STRING(tmp, "ob_tidyhandler", ZSTR_DUPLICATE);
 		if (!php_output_handler_started(tmp TSRMLS_CC)) {
@@ -1183,7 +1182,7 @@
 		}
 		zval_ptr_dtor(&tmp);
 	}
-
+
 	return status;
 }

@@ -1194,7 +1193,7 @@
 static void php_tidy_clean_output_start(zval *name TSRMLS_DC)
 {
 	php_output_handler *h;
-
+
 	if (TG(clean_output) && (h = php_tidy_output_handler_init(name, 0, PHP_OUTPUT_HANDLER_STDFLAGS TSRMLS_CC))) {
 		php_output_handler_start(h TSRMLS_CC);
 	}
@@ -1218,20 +1217,20 @@
 	TidyDoc doc;
 	TidyBuffer inbuf, outbuf, errbuf;
 	PHP_OUTPUT_TSRMLS(output_context);
-
+
 	if (TG(clean_output) && (output_context->op & PHP_OUTPUT_HANDLER_START) && (output_context->op & PHP_OUTPUT_HANDLER_FINAL)) {
 		doc = tidyCreate();
 		tidyBufInit(&errbuf);
-
+
 		if (0 == tidySetErrorBuffer(doc, &errbuf)) {
 			tidyOptSetBool(doc, TidyForceOutput, yes);
 			tidyOptSetBool(doc, TidyMark, no);
-
+
 			TIDY_SET_DEFAULT_CONFIG(doc);
-
+
 			tidyBufInit(&inbuf);
 			tidyBufAttach(&inbuf, (byte *) output_context->in.data, output_context->in.used);
-
+
 			if (0 <= tidyParseBuffer(doc, &inbuf) && 0 <= tidyCleanAndRepair(doc)) {
 				tidyBufInit(&outbuf);
 				tidySaveBuffer(doc, &outbuf);
@@ -1242,11 +1241,11 @@
 				status = SUCCESS;
 			}
 		}
-
+
 		tidyRelease(doc);
 		tidyBufFree(&errbuf);
 	}
-
+
 	return status;
 }

@@ -1316,11 +1315,10 @@
 	zend_bool use_include_path = 0;
 	char *contents;
 	zval **options = NULL;
-
+
 	PHPTidyObj *obj;

-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zsb", &inputfile, &input_len,
-							  &options, &enc, &enc_len, &use_include_path) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zsb", &inputfile, &input_len, &options, &enc, &enc_len, &use_include_path) == FAILURE) {
 		RETURN_FALSE;
 	}

@@ -1334,7 +1332,7 @@

 	TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);

-	if(php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) {
+	if (php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) {
 		zval_dtor(return_value);
 		INIT_ZVAL(*return_value);
 		RETVAL_FALSE;
@@ -1566,7 +1564,7 @@
 /* {{{ proto mixed tidy_getopt(string option) U
    Returns the value of the specified configuration option for the tidy document. */
 static PHP_FUNCTION(tidy_getopt)
-{
+{
 	PHPTidyObj *obj;
 	void *optval, *optname;
 	int optname_len;
@@ -1628,17 +1626,16 @@
 	zend_bool use_include_path = 0;
 	char *contents;
 	zval **options = NULL;
-
+
 	PHPTidyObj *obj;
-	TIDY_SET_CONTEXT;
-
-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sZsb", &inputfile, &input_len,
-							  &options, &enc, &enc_len, &use_include_path) == FAILURE) {
+	TIDY_SET_CONTEXT;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sZsb", &inputfile, &input_len, &options, &enc, &enc_len, &use_include_path) == FAILURE) {
 		RETURN_FALSE;
 	}
-
+
 	obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC);
-
+
 	if (inputfile) {
 		if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) {
 			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile, (use_include_path) ? " (Using include path)" : "");
@@ -1666,11 +1663,10 @@

 	obj = (PHPTidyObj *)zend_object_store_get_object(object TSRMLS_CC);

-	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zsb", &inputfile, &input_len,
-							  &options, &enc, &enc_len, &use_include_path) == FAILURE) {
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|Zsb", &inputfile, &input_len, &options, &enc, &enc_len, &use_include_path) == FAILURE) {
 		RETURN_FALSE;
 	}
-
+
 	if (!(contents = php_tidy_file_to_mem(inputfile, use_include_path, &contents_len TSRMLS_CC))) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot Load '%s' into memory%s", inputfile, (use_include_path) ? " (Using include path)" : "");
 		RETURN_FALSE;
@@ -1678,7 +1674,7 @@

 	TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);

-	if(php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) {
+	if (php_tidy_parse_string(obj, contents, contents_len, enc TSRMLS_CC) == FAILURE) {
 		RETVAL_FALSE;
 	} else {
 		RETVAL_TRUE;
@@ -1704,10 +1700,10 @@

 	TIDY_APPLY_CONFIG_ZVAL(obj->ptdoc->doc, options);

-	if(php_tidy_parse_string(obj, input, input_len, enc TSRMLS_CC) == SUCCESS) {
+	if (php_tidy_parse_string(obj, input, input_len, enc TSRMLS_CC) == SUCCESS) {
 		RETURN_TRUE;
 	}
-
+
 	RETURN_FALSE;
 }

@@ -1865,7 +1861,7 @@
 	TIDY_FETCH_ONLY_OBJECT;

 	parent_node = tidyGetParent(obj->node);
-	if(parent_node) {
+	if (parent_node) {
 		tidy_instanciate(tidy_ce_node, return_value TSRMLS_CC);
 		newobj = (PHPTidyObj *) zend_object_store_get_object(return_value TSRMLS_CC);
 		newobj->node = parent_node;
@@ -1883,11 +1879,11 @@


 /* {{{ proto void tidyNode::__construct()
-         __constructor for tidyNode. */
+   __constructor for tidyNode. */
 static TIDY_NODE_METHOD(__construct)
 {
 	php_error_docref(NULL TSRMLS_CC, E_ERROR, "You should not create a tidyNode manually");
-}
+}
 /* }}} */

 static void _php_tidy_register_nodetypes(INIT_FUNC_ARGS)
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to