cvs: php-src(PHP_5_1) /ext/dom document.c
| From: | Rob Richards | Date: | Thu, 08 Sep 2005 10:39:32 +0000 |
| Subject: | cvs: php-src(PHP_5_1) /ext/dom document.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-33856@lists.php.net to get a copy of this message | ||
rrichards Thu Sep 8 06:39:32 2005 EDT
Modified files: (Branch: PHP_5_1)
/php-src/ext/dom document.c
Log:
MFH: add save options parameter
http://cvs.php.net/diff.php/php-src/ext/dom/document.c?r1=1.68.2.1&r2=1.68.2.2&ty=u
Index: php-src/ext/dom/document.c
diff -u php-src/ext/dom/document.c:1.68.2.1 php-src/ext/dom/document.c:1.68.2.2
--- php-src/ext/dom/document.c:1.68.2.1 Mon Aug 15 13:13:57 2005
+++ php-src/ext/dom/document.c Thu Sep 8 06:39:30 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: document.c,v 1.68.2.1 2005/08/15 17:13:57 rrichards Exp $ */
+/* $Id: document.c,v 1.68.2.2 2005/09/08 10:39:30 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1624,12 +1624,13 @@
{
zval *id;
xmlDoc *docp;
- int file_len = 0, bytes, format;
+ int file_len = 0, bytes, format, saveempty;
dom_object *intern;
dom_doc_props *doc_props;
char *file;
+ long options = 0;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id,
dom_document_class_entry, &file, &file_len) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|l", &id,
dom_document_class_entry, &file, &file_len, &options) == FAILURE) {
return;
}
@@ -1644,8 +1645,14 @@
doc_props = dom_get_doc_props(intern->document);
format = doc_props->formatoutput;
+ if (options & LIBXML_SAVE_NOEMPTYTAG) {
+ saveempty = xmlSaveNoEmptyTags;
+ xmlSaveNoEmptyTags = 1;
+ }
bytes = xmlSaveFormatFileEnc(file, docp, NULL, format);
-
+ if (options & LIBXML_SAVE_NOEMPTYTAG) {
+ xmlSaveNoEmptyTags = saveempty;
+ }
if (bytes == -1) {
RETURN_FALSE;
}
@@ -1666,9 +1673,10 @@
xmlChar *mem;
dom_object *intern, *nodeobj;
dom_doc_props *doc_props;
- int size, format;
+ int size, format, saveempty;
+ long options = 0;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|O", &id,
dom_document_class_entry, &nodep, dom_node_class_entry) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "O|O!l", &id,
dom_document_class_entry, &nodep, dom_node_class_entry, &options) == FAILURE) {
return;
}
@@ -1689,8 +1697,14 @@
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not fetch buffer");
RETURN_FALSE;
}
-
+ if (options & LIBXML_SAVE_NOEMPTYTAG) {
+ saveempty = xmlSaveNoEmptyTags;
+ xmlSaveNoEmptyTags = 1;
+ }
xmlNodeDump(buf, docp, node, 0, format);
+ if (options & LIBXML_SAVE_NOEMPTYTAG) {
+ xmlSaveNoEmptyTags = saveempty;
+ }
mem = (xmlChar*) xmlBufferContent(buf);
if (!mem) {
xmlBufferFree(buf);
@@ -1699,8 +1713,15 @@
RETVAL_STRING(mem, 1);
xmlBufferFree(buf);
} else {
+ if (options & LIBXML_SAVE_NOEMPTYTAG) {
+ saveempty = xmlSaveNoEmptyTags;
+ xmlSaveNoEmptyTags = 1;
+ }
/* Encoding is handled from the encoding property set on the document */
xmlDocDumpFormatMemory(docp, &mem, &size, format);
+ if (options & LIBXML_SAVE_NOEMPTYTAG) {
+ xmlSaveNoEmptyTags = saveempty;
+ }
if (!size) {
RETURN_FALSE;
}