diff options
Diffstat (limited to 'devel/kyua/files/patch-utils-config-tree.ipp')
-rw-r--r-- | devel/kyua/files/patch-utils-config-tree.ipp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/devel/kyua/files/patch-utils-config-tree.ipp b/devel/kyua/files/patch-utils-config-tree.ipp new file mode 100644 index 000000000000..5977ced6f561 --- /dev/null +++ b/devel/kyua/files/patch-utils-config-tree.ipp @@ -0,0 +1,55 @@ +--- utils/config/tree.ipp.old ++++ utils/config/tree.ipp +@@ -79,13 +79,13 @@ config::tree::lookup(const std::string& dotted_key) const + { + const detail::tree_key key = detail::parse_key(dotted_key); + const detail::base_node* raw_node = _root->lookup_ro(key, 0); +- try { +- const LeafType& child = dynamic_cast< const LeafType& >(*raw_node); +- if (child.is_set()) +- return child.value(); ++ const LeafType* child = dynamic_cast< const LeafType* >(raw_node); ++ if (child != NULL) { ++ if (child->is_set()) ++ return child->value(); + else + throw unknown_key_error(key); +- } catch (const std::bad_cast& unused_error) { ++ } else { + throw unknown_key_error(key); + } + } +@@ -107,13 +107,13 @@ config::tree::lookup_rw(const std::string& dotted_key) + const detail::tree_key key = detail::parse_key(dotted_key); + detail::base_node* raw_node = _root->lookup_rw( + key, 0, detail::new_node< LeafType >); +- try { +- LeafType& child = dynamic_cast< LeafType& >(*raw_node); +- if (child.is_set()) +- return child.value(); ++ LeafType* child = dynamic_cast< LeafType* >(raw_node); ++ if (child != NULL) { ++ if (child->is_set()) ++ return child->value(); + else + throw unknown_key_error(key); +- } catch (const std::bad_cast& unused_error) { ++ } else { + throw unknown_key_error(key); + } + } +@@ -136,10 +136,10 @@ config::tree::set(const std::string& dotted_key, + const detail::tree_key key = detail::parse_key(dotted_key); + leaf_node* raw_node = _root->lookup_rw(key, 0, + detail::new_node< LeafType >); +- try { +- LeafType& child = dynamic_cast< LeafType& >(*raw_node); +- child.set(value); +- } catch (const std::bad_cast& unused_error) { ++ LeafType* child = dynamic_cast< LeafType* >(raw_node); ++ if (child != NULL) { ++ child->set(value); ++ } else { + throw value_error(F("Invalid value for key '%s'") % + detail::flatten_key(key)); + } |