wesnoth-cvs-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Wesnoth-cvs-commits] wesnoth/src/serialization preprocessor.cpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src/serialization preprocessor.cpp
Date: Sat, 21 May 2005 03:50:49 -0400

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    05/05/21 07:50:49

Modified files:
        src/serialization: preprocessor.cpp 

Log message:
        A few cleanup and a bit of cornercase fixing.

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/serialization/preprocessor.cpp.diff?tr1=1.18&tr2=1.19&r1=text&r2=text

Patches:
Index: wesnoth/src/serialization/preprocessor.cpp
diff -u wesnoth/src/serialization/preprocessor.cpp:1.18 
wesnoth/src/serialization/preprocessor.cpp:1.19
--- wesnoth/src/serialization/preprocessor.cpp:1.18     Sat May 14 12:14:41 2005
+++ wesnoth/src/serialization/preprocessor.cpp  Sat May 21 07:50:48 2005
@@ -1,4 +1,4 @@
-/* $Id: preprocessor.cpp,v 1.18 2005/05/14 12:14:41 ott Exp $ */
+/* $Id: preprocessor.cpp,v 1.19 2005/05/21 07:50:48 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -383,11 +383,10 @@
                                strings_.back() += tmp;
                        } else
                                pop_token();
-                       char &t = tokens_.back().type;
-                       if (t == '{')
-                               t = '[';
                } else if (!target_.quoted_) {
                        target_.quoted_ = true;
+                       if (token.type == '{')
+                               token.type = '[';
                        push_token('"');
                        put(c);
                } else {
@@ -398,6 +397,8 @@
                        throw config::error(error.str());
                }
        } else if (c == '{') {
+               if (token.type == '{')
+                       token.type = '[';
                push_token('{');
                ++slowpath_;
        } else if (c == ')' && token.type == '(') {
@@ -454,7 +455,7 @@
                        }
                } else if (command == "ifdef") {
                        skip_spaces();
-                       std::string symbol = read_word();
+                       std::string const &symbol = read_word();
                        bool skip = target_.defines_->count(symbol) == 0;
                        LOG_CF << "testing for macro " << symbol << ": " << 
(skip ? "not defined" : "defined") << '\n';
                        if (skip)
@@ -492,7 +493,7 @@
                        pop_token();
                } else if (command == "textdomain") {
                        skip_spaces();
-                       std::string s = read_word();
+                       std::string const &s = read_word();
                        put("#textdomain ");
                        put(s);
                        target_.textdomain_ = s;
@@ -532,11 +533,10 @@
                        }
 
                        std::string symbol = strings_[token.stack_pos];
-                       std::string::size_type pos = symbol.find('\376');
-                       while (pos != std::string::npos) {
-                               std::string::iterator b = symbol.begin();
+                       std::string::size_type pos;
+                       while ((pos = symbol.find('\376')) != 
std::string::npos) {
+                               std::string::iterator b = symbol.begin(); // 
invalidated at each iteration
                                symbol.erase(b + pos, b + symbol.find('\n', pos 
+ 1) + 1);
-                               pos = symbol.find('\376', pos);
                        }
                        //if this is a known pre-processing symbol, then we 
insert
                        //it, otherwise we assume it's a file name to load
@@ -610,10 +610,7 @@
                                }
 
                                pop_token();
-                               std::string dir;
-                               std::string::size_type pos = 
val.location.find(' ');
-                               if (pos != std::string::npos)
-                                       dir = val.location.substr(0, pos);
+                               std::string const &dir = 
directory_name(val.location.substr(0, val.location.find(' ')));
                                if (!slowpath_) {
                                        LOG_CF << "substituting macro " << 
symbol << '\n';
                                        new preprocessor_data(target_, buffer, 
val.location,




reply via email to

[Prev in Thread] Current Thread [Next in Thread]