| 8561 | } |
| 8562 | |
| 8563 | template <class Comp> static bool compare_rel(xpath_ast_node* lhs, xpath_ast_node* rhs, const xpath_context& c, const xpath_stack& stack, const Comp& comp) |
| 8564 | { |
| 8565 | xpath_value_type lt = lhs->rettype(), rt = rhs->rettype(); |
| 8566 | |
| 8567 | if (lt != xpath_type_node_set && rt != xpath_type_node_set) |
| 8568 | return comp(lhs->eval_number(c, stack), rhs->eval_number(c, stack)); |
| 8569 | else if (lt == xpath_type_node_set && rt == xpath_type_node_set) |
| 8570 | { |
| 8571 | xpath_allocator_capture cr(stack.result); |
| 8572 | |
| 8573 | xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all); |
| 8574 | xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); |
| 8575 | |
| 8576 | for (const xpath_node* li = ls.begin(); li != ls.end(); ++li) |
| 8577 | { |
| 8578 | xpath_allocator_capture cri(stack.result); |
| 8579 | |
| 8580 | double l = convert_string_to_number(string_value(*li, stack.result).c_str()); |
| 8581 | |
| 8582 | for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) |
| 8583 | { |
| 8584 | xpath_allocator_capture crii(stack.result); |
| 8585 | |
| 8586 | if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str()))) |
| 8587 | return true; |
| 8588 | } |
| 8589 | } |
| 8590 | |
| 8591 | return false; |
| 8592 | } |
| 8593 | else if (lt != xpath_type_node_set && rt == xpath_type_node_set) |
| 8594 | { |
| 8595 | xpath_allocator_capture cr(stack.result); |
| 8596 | |
| 8597 | double l = lhs->eval_number(c, stack); |
| 8598 | xpath_node_set_raw rs = rhs->eval_node_set(c, stack, nodeset_eval_all); |
| 8599 | |
| 8600 | for (const xpath_node* ri = rs.begin(); ri != rs.end(); ++ri) |
| 8601 | { |
| 8602 | xpath_allocator_capture cri(stack.result); |
| 8603 | |
| 8604 | if (comp(l, convert_string_to_number(string_value(*ri, stack.result).c_str()))) |
| 8605 | return true; |
| 8606 | } |
| 8607 | |
| 8608 | return false; |
| 8609 | } |
| 8610 | else if (lt == xpath_type_node_set && rt != xpath_type_node_set) |
| 8611 | { |
| 8612 | xpath_allocator_capture cr(stack.result); |
| 8613 | |
| 8614 | xpath_node_set_raw ls = lhs->eval_node_set(c, stack, nodeset_eval_all); |
| 8615 | double r = rhs->eval_number(c, stack); |
| 8616 | |
| 8617 | for (const xpath_node* li = ls.begin(); li != ls.end(); ++li) |
| 8618 | { |
| 8619 | xpath_allocator_capture cri(stack.result); |
| 8620 |
nothing calls this directly
no test coverage detected