From 1a764a3ee2cb4805031faa5ae2692f91f5573d53 Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Tue, 14 Sep 2010 16:44:13 +0000 Subject: XPath: evaluate_string refactoring (also fixes setjmp warning on MinGW without breaking DMC/SunCC) git-svn-id: http://pugixml.googlecode.com/svn/trunk@733 99668b35-9821-0410-8761-19e4c4f06640 --- src/pugixml.cpp | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index c943f7f..7326dcf 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -9070,37 +9070,34 @@ namespace pugi return _root->eval_number(c, sd.stack); } - -#ifndef PUGIXML_NO_STL - string_t xpath_query::evaluate_string(const xpath_node& n) const + + static xpath_string evaluate_string_impl(xpath_ast_node* root, const xpath_node& n, xpath_stack_data& sd) { - if (!_root) return string_t(); - - xpath_context c(n, 1, 1); - xpath_stack_data sd; + if (!root) return xpath_string(); #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) return string_t(); + if (setjmp(sd.error_handler)) return xpath_string(); #endif - return _root->eval_string(c, sd.stack).c_str(); + xpath_context c(n, 1, 1); + + return root->eval_string(c, sd.stack); } -#endif - size_t xpath_query::evaluate_string(char_t* buffer, volatile size_t capacity, const xpath_node& n) const +#ifndef PUGIXML_NO_STL + string_t xpath_query::evaluate_string(const xpath_node& n) const { - xpath_context c(n, 1, 1); xpath_stack_data sd; - #ifdef PUGIXML_NO_EXCEPTIONS - if (setjmp(sd.error_handler)) - { - if (capacity > 0) *buffer = 0; - return 1; - } - #endif + return evaluate_string_impl(_root, n, sd).c_str(); + } +#endif + + size_t xpath_query::evaluate_string(char_t* buffer, size_t capacity, const xpath_node& n) const + { + xpath_stack_data sd; - xpath_string r = _root ? _root->eval_string(c, sd.stack) : xpath_string(); + xpath_string r = evaluate_string_impl(_root, n, sd); size_t size = r.length() + 1; -- cgit v1.2.3