load_xml was returning a single term instead of a list of nodes
This commit is contained in:
@@ -8450,7 +8450,12 @@ impl Machine {
|
||||
match roxmltree::Document::parse(&string.as_str()) {
|
||||
Ok(doc) => {
|
||||
let result = self.xml_node_to_term(doc.root_element())?;
|
||||
unify!(self.machine_st, self.machine_st.registers[2], result);
|
||||
let list = sized_iter_to_heap_list(
|
||||
&mut self.machine_st.heap,
|
||||
1, // just one root element
|
||||
std::iter::once(result),
|
||||
)?;
|
||||
unify!(self.machine_st, self.machine_st.registers[2], list);
|
||||
}
|
||||
_ => {
|
||||
self.machine_st.fail = true;
|
||||
|
||||
5
tests-pl/issue3256.pl
Normal file
5
tests-pl/issue3256.pl
Normal file
@@ -0,0 +1,5 @@
|
||||
:- use_module(library(sgml)).
|
||||
|
||||
test :- load_xml("<foo><bar>hello</bar></foo>", Es, []), write(Es).
|
||||
|
||||
:- initialization(test).
|
||||
@@ -20,6 +20,15 @@ fn issue2588_load_html() {
|
||||
load_module_test("tests-pl/issue2588.pl", "[element(html,[],[element(head,[],[element(title,[],[[H,e,l,l,o,!]])]),element(body,[],[])])]");
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(miri, ignore = "unsupported operation when isolation is enabled")]
|
||||
fn issue3256_load_xml_returns_list() {
|
||||
load_module_test(
|
||||
"tests-pl/issue3256.pl",
|
||||
"[element(foo,[],[element(bar,[],[[h,e,l,l,o]])])]",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(miri, ignore = "unsupported operation when isolation is enabled")]
|
||||
fn issue2949_load_html() {
|
||||
|
||||
Reference in New Issue
Block a user