summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-09-14 16:44:13 +0000
committerarseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640>2010-09-14 16:44:13 +0000
commit1a764a3ee2cb4805031faa5ae2692f91f5573d53 (patch)
tree1f3a34b409c06b9a04bf2474bd21631c0e48b066
parent39ee42f907f9cb7481969db29ca4c78985d65a5a (diff)
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
-rw-r--r--src/pugixml.cpp37
1 files changed, 17 insertions, 20 deletions
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;