Author: silene
Date: Mon Apr 13 17:02:18 2009
New Revision: 34871

URL: http://svn.gna.org/viewcvs/wesnoth?rev=34871&view=rev
Log:
Fixed two other occurrences of the ternary bug from hell. (My fault.) Factored 
the code a bit.

Modified:
    trunk/src/serialization/parser.cpp
    trunk/src/serialization/preprocessor.cpp
    trunk/src/serialization/preprocessor.hpp

Modified: trunk/src/serialization/parser.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/serialization/parser.cpp?rev=34871&r1=34870&r2=34871&view=diff
==============================================================================
--- trunk/src/serialization/parser.cpp (original)
+++ trunk/src/serialization/parser.cpp Mon Apr 13 17:02:18 2009
@@ -27,6 +27,7 @@
 #include "gettext.hpp"
 #include "loadscreen.hpp"
 #include "wesconfig.h"
+#include "serialization/preprocessor.hpp"
 #include "serialization/tokenizer.hpp"
 #include "foreach.hpp"
 
@@ -324,19 +325,7 @@
 std::string parser::lineno_string(utils::string_map &i18n_symbols, std::string 
const &lineno,
                                  std::string const &error_string)
 {
-       std::vector< std::string > pos = utils::quoted_split(lineno, ' ');
-       std::vector< std::string >::const_iterator i = pos.begin(), end = 
pos.end();
-       std::string included_from = _(" included from ");
-       std::string res;
-       while (i != end) {
-               std::string const &line = *(i++);
-               std::string const &file = i != end ? *(i++) : "<unknown>";
-               if (!res.empty())
-                       res += included_from;
-               res += file + ':' + line;
-       }
-       if (res.empty()) res = "???";
-       i18n_symbols["pos"] = res;
+       i18n_symbols["pos"] = ::lineno_string(lineno);
        std::string result = _(error_string.c_str());
        foreach(utils::string_map::value_type& var, i18n_symbols)
                boost::algorithm::replace_all(result, std::string("$") + 
var.first, std::string(var.second));

Modified: trunk/src/serialization/preprocessor.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/serialization/preprocessor.cpp?rev=34871&r1=34870&r2=34871&view=diff
==============================================================================
--- trunk/src/serialization/preprocessor.cpp (original)
+++ trunk/src/serialization/preprocessor.cpp Mon Apr 13 17:02:18 2009
@@ -164,7 +164,6 @@
        preprocessor_streambuf(preprocessor_streambuf const &);
 public:
        preprocessor_streambuf(preproc_map *, std::string *);
-       std::string lineno_string(std::string const &);
        void error(const std::string &, const std::string &);
 };
 
@@ -249,7 +248,7 @@
        return static_cast<unsigned char>(*(begin + sz));
 }
 
-std::string preprocessor_streambuf::lineno_string(std::string const &lineno)
+std::string lineno_string(const std::string &lineno)
 {
        std::vector< std::string > pos = utils::quoted_split(lineno, ' ');
        std::vector< std::string >::const_iterator i = pos.begin(), end = 
pos.end();
@@ -257,10 +256,13 @@
        std::string res;
        while (i != end) {
                std::string const &line = *(i++);
-               std::string const &file = i != end ? *(i++) : "<unknown>";
                if (!res.empty())
                        res += included_from;
-               res += file + ':' + line;
+               if (i != end)
+                       res += *(i++);
+               else
+                       res += "<unknown>";
+               res += ':' + line;
        }
        if (res.empty()) res = "???";
        return res;

Modified: trunk/src/serialization/preprocessor.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/serialization/preprocessor.hpp?rev=34871&r1=34870&r2=34871&view=diff
==============================================================================
--- trunk/src/serialization/preprocessor.hpp (original)
+++ trunk/src/serialization/preprocessor.hpp Mon Apr 13 17:02:18 2009
@@ -61,6 +61,7 @@
        };
 };
 
+std::string lineno_string(const std::string &lineno);
 
 std::ostream& operator<<(std::ostream& stream, const preproc_map::value_type& 
def);
 


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

Reply via email to