From: Christian Stocker Date: Thu, 13 Jun 2002 10:47:19 +0000 (+0000) Subject: - Added DOMXML_LOAD_DONT_KEEP_BLANKS as possible mode, if one wants really nicely X-Git-Tag: php5_5_0~40 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ff9a003f2686e06f97d5d395fdd0f0bada46befb;p=php - Added DOMXML_LOAD_DONT_KEEP_BLANKS as possible mode, if one wants really nicely formatted XML-Documents (but this can have sideeffects, if you depend on whitespaces..) - bumped up domxml-api-version number. --- diff --git a/ext/domxml/php_domxml.c b/ext/domxml/php_domxml.c index 30bf0ef895..ddcf88baaf 100644 --- a/ext/domxml/php_domxml.c +++ b/ext/domxml/php_domxml.c @@ -137,7 +137,7 @@ #define DOMXML_LOAD_RECOVERING 2 #define DOMXML_LOAD_SUBSTITUTE_ENTITIES 4 #define DOMXML_LOAD_COMPLETE_ATTRS 8 - +#define DOMXML_LOAD_DONT_KEEP_BLANKS 16 static int le_domxmldocp; static int le_domxmldoctypep; static int le_domxmldtdp; @@ -1573,7 +1573,7 @@ PHP_MINIT_FUNCTION(domxml) REGISTER_LONG_CONSTANT("DOMXML_LOAD_RECOVERING", DOMXML_LOAD_RECOVERING, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DOMXML_LOAD_SUBSTITUTE_ENTITIES", DOMXML_LOAD_SUBSTITUTE_ENTITIES, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("DOMXML_LOAD_COMPLETE_ATTRS",DOMXML_LOAD_COMPLETE_ATTRS, CONST_CS | CONST_PERSISTENT); - + REGISTER_LONG_CONSTANT("DOMXML_LOAD_DONT_KEEP_BLANKS",DOMXML_LOAD_DONT_KEEP_BLANKS, CONST_CS | CONST_PERSISTENT); xmlSetGenericErrorFunc(xmlGenericErrorContext, (xmlGenericErrorFunc)domxml_error); #if HAVE_DOMXSLT xsltSetGenericErrorFunc(xsltGenericErrorContext, (xmlGenericErrorFunc)domxml_error); @@ -3538,6 +3538,7 @@ PHP_FUNCTION(xmldoc) int buffer_len; int mode = 0, prevSubstValue; int oldvalue = xmlDoValidityCheckingDefaultValue; + int oldvalue_keepblanks; zval *errors ; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz", &buffer, &buffer_len, &mode, &errors) == FAILURE) { @@ -3550,6 +3551,11 @@ PHP_FUNCTION(xmldoc) zval_dtor(errors); array_init(errors); } + + if (mode & DOMXML_LOAD_DONT_KEEP_BLANKS) + oldvalue_keepblanks = xmlKeepBlanksDefault(0); + else + oldvalue_keepblanks = xmlKeepBlanksDefault(1); if(mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES) prevSubstValue = xmlSubstituteEntitiesDefault (1); @@ -3587,6 +3593,7 @@ PHP_FUNCTION(xmldoc) } xmlSubstituteEntitiesDefault (prevSubstValue); xmlDoValidityCheckingDefaultValue = oldvalue; + xmlKeepBlanksDefault(oldvalue_keepblanks); if (!docp) RETURN_FALSE; @@ -3615,6 +3622,7 @@ PHP_FUNCTION(xmldocfile) char *file; int mode = 0, prevSubstValue; int oldvalue = xmlDoValidityCheckingDefaultValue; + int oldvalue_keepblanks; zval *errors = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|lz", &file, &file_len, &mode, &errors) == FAILURE) { @@ -3626,6 +3634,11 @@ PHP_FUNCTION(xmldocfile) array_init(errors); } + if (mode & DOMXML_LOAD_DONT_KEEP_BLANKS) + oldvalue_keepblanks = xmlKeepBlanksDefault(0); + else + oldvalue_keepblanks = xmlKeepBlanksDefault(1); + if(mode & DOMXML_LOAD_SUBSTITUTE_ENTITIES) prevSubstValue = xmlSubstituteEntitiesDefault (1); else @@ -3662,6 +3675,7 @@ PHP_FUNCTION(xmldocfile) } xmlSubstituteEntitiesDefault (prevSubstValue); xmlDoValidityCheckingDefaultValue = oldvalue; + xmlKeepBlanksDefault(oldvalue_keepblanks); if (!docp) { RETURN_FALSE; diff --git a/ext/domxml/php_domxml.h b/ext/domxml/php_domxml.h index 22432fb4f5..4b01362890 100644 --- a/ext/domxml/php_domxml.h +++ b/ext/domxml/php_domxml.h @@ -51,7 +51,7 @@ therefore it's easier for the script-programmers to check, what's working how Can be checked with phpversion("domxml"); */ -#define DOMXML_API_VERSION "20020607" +#define DOMXML_API_VERSION "20020713" extern zend_module_entry domxml_module_entry; #define domxml_module_ptr &domxml_module_entry