forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnamespace_compat.c
54 lines (47 loc) · 1.95 KB
/
namespace_compat.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Niels Dossche <[email protected]> |
+----------------------------------------------------------------------+
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php.h"
#if defined(HAVE_LIBXML) && defined(HAVE_DOM)
#include "php_dom.h"
#include "namespace_compat.h"
bool dom_ns_is_also_an_attribute(const xmlNs *ns) {
return ns->_private != NULL;
}
void dom_ns_compat_mark_attribute(xmlNsPtr ns) {
ns->_private = (void *) 1;
}
void dom_ns_compat_mark_attribute_list(xmlNsPtr ns) {
while (ns != NULL) {
dom_ns_compat_mark_attribute(ns);
ns = ns->next;
}
}
void dom_ns_compat_copy_attribute_list_mark(xmlNsPtr copy, const xmlNs *original) {
/* It's possible that the original list is shorter than the copy list
* because of additional namespace copies from within a fragment. */
while (original != NULL) {
ZEND_ASSERT(copy != NULL);
if (dom_ns_is_also_an_attribute(original)) {
dom_ns_compat_mark_attribute(copy);
}
copy = copy->next;
original = original->next;
}
}
#endif /* HAVE_LIBXML && HAVE_DOM */