]> granicus.if.org Git - php/commitdiff
Add support for getting SKIP_TAGSTART and SKIP_WHITE options
authorChristoph M. Becker <cmbecker69@gmx.de>
Tue, 16 Oct 2018 16:47:31 +0000 (18:47 +0200)
committerChristoph M. Becker <cmbecker69@gmx.de>
Tue, 16 Oct 2018 16:47:31 +0000 (18:47 +0200)
When `XML_OPTION_SKIP_TAGSTART` and `XML_OPTION_SKIP_WHITE` had been
introduced[1], it had been overlooked to also support them for
`xml_parser_get_option()`.  We catch up on that.

[1] <http://git.php.net/?p=php-src.git;a=commit;h=b57dc275950b228f2399990471c4f22b7d154c6c>

NEWS
ext/xml/tests/xml_parser_get_option_variation3.phpt [new file with mode: 0644]
ext/xml/xml.c

diff --git a/NEWS b/NEWS
index 3da21a1c5c8c4a83d74cc1679d7fb42af310d8a9..4652c6657f590cfcf6d84c5b04f3494e1fccea0e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,7 @@ PHP                                                                        NEWS
 
 - XML:
   . Fixed bug #30875 (xml_parse_into_struct() does not resolve entities). (cmb)
+  . Add support for getting SKIP_TAGSTART and SKIP_WHITE options. (cmb)
 
 11 Oct 2018, PHP 7.1.23
 
diff --git a/ext/xml/tests/xml_parser_get_option_variation3.phpt b/ext/xml/tests/xml_parser_get_option_variation3.phpt
new file mode 100644 (file)
index 0000000..839daa9
--- /dev/null
@@ -0,0 +1,29 @@
+--TEST--
+xml_parser_get_option() with XML_OPTION_SKIP_TAGSTART and XML_OPTION_SKIP_WHITE
+--SKIPIF--
+<?php
+if (!extension_loaded('xml')) die('skip xml extension not available');
+?>
+--FILE--
+<?php
+$parser = xml_parser_create();
+echo "defaults:\n";
+var_dump(xml_parser_get_option($parser, XML_OPTION_SKIP_TAGSTART));
+var_dump(xml_parser_get_option($parser, XML_OPTION_SKIP_WHITE));
+echo "setting:\n";
+var_dump(xml_parser_set_option($parser, XML_OPTION_SKIP_TAGSTART, 7));
+var_dump(xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1));
+echo "getting:\n";
+var_dump(xml_parser_get_option($parser, XML_OPTION_SKIP_TAGSTART));
+var_dump(xml_parser_get_option($parser, XML_OPTION_SKIP_WHITE));
+?>
+--EXPECT--
+defaults:
+int(0)
+int(0)
+setting:
+bool(true)
+bool(true)
+getting:
+int(7)
+int(1)
index b1f8cc5bd9c19c7dd8702bd56758250ffc493ca3..373330f035b5ef915c34e661aa159dc9437270ff 100644 (file)
@@ -1653,6 +1653,12 @@ PHP_FUNCTION(xml_parser_get_option)
                case PHP_XML_OPTION_CASE_FOLDING:
                        RETURN_LONG(parser->case_folding);
                        break;
+               case PHP_XML_OPTION_SKIP_TAGSTART:
+                       RETURN_LONG(parser->toffset);
+                       break;
+               case PHP_XML_OPTION_SKIP_WHITE:
+                       RETURN_LONG(parser->skipwhite);
+                       break;
                case PHP_XML_OPTION_TARGET_ENCODING:
                        RETURN_STRING((char *)parser->target_encoding);
                        break;