Author: sapient
Date: Tue Apr 17 23:49:09 2007
New Revision: 16875

URL: http://svn.gna.org/viewcvs/wesnoth?rev=16875&view=rev
Log:
explicitly construct the vconfig[] return type from t_string& to t_string
and also add const to prevent inadvertant misuse

Modified:
    trunk/src/variable.cpp
    trunk/src/variable.hpp

Modified: trunk/src/variable.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/variable.cpp?rev=16875&r1=16874&r2=16875&view=diff
==============================================================================
--- trunk/src/variable.cpp (original)
+++ trunk/src/variable.cpp Tue Apr 17 23:49:09 2007
@@ -88,16 +88,16 @@
        return (cfg_->child(key) != NULL);
 }
 
-t_string vconfig::expand(const std::string& key) const
+const t_string vconfig::expand(const std::string& key) const
 {
        const t_string& val = (*cfg_)[key];
        if(repos != NULL && !val.str().empty()) {
                std::string interp = 
utils::interpolate_variables_into_string(val.str(), *repos);
                if(val.str() != interp) {
-                       return interp;
+                       return t_string(interp);
                }
        }
-       return val;
+       return t_string(val);
 }
 
 namespace variable

Modified: trunk/src/variable.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/variable.hpp?rev=16875&r1=16874&r2=16875&view=diff
==============================================================================
--- trunk/src/variable.hpp (original)
+++ trunk/src/variable.hpp Tue Apr 17 23:49:09 2007
@@ -44,8 +44,8 @@
        vconfig child(const std::string& key) const;
        bool has_child(const std::string& key) const;
 
-       t_string expand(const std::string&) const; /** < Synonym for operator[] 
*/
-       t_string operator[](const std::string& key) const { return expand(key); 
}
+       const t_string expand(const std::string&) const; /** < Synonym for 
operator[] */
+       const t_string operator[](const std::string& key) const { return 
expand(key); }
        const t_string& get_attribute(const std::string& key) const { return 
(*cfg_)[key]; }
        bool has_attribute(const std::string& key) const {
                return (*cfg_).values.find(key) != (*cfg_).values.end(); 


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to