mail[Wesnoth-commits] r20590 - in /trunk/src: serialization/preprocessor.cpp unit.cpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by patrick_X99 on September 19, 2007 - 06:40:
Author: sapient
Date: Wed Sep 19 06:39:47 2007
New Revision: 20590

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20590&view=rev
Log:
fix bug #8506: WML commenting bug(s)

Modified:
    trunk/src/serialization/preprocessor.cpp
    trunk/src/unit.cpp

Modified: trunk/src/serialization/preprocessor.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/serialization/preprocessor.cpp?rev=20590&r1=20589&r2=20590&view=diff
==============================================================================
--- trunk/src/serialization/preprocessor.cpp (original)
+++ trunk/src/serialization/preprocessor.cpp Wed Sep 19 06:39:47 2007
@@ -613,17 +613,22 @@
                                std::string::const_iterator i_bra = 
val.value.end();
                                int macro_num = val.linenum;
                                std::string macro_textdomain = val.textdomain;
+                               bool quoting = false;
                                for(std::string::const_iterator i = 
val.value.begin(),
                                    i_end = val.value.end(); i != i_end; ++i) 
{
                                        char c = *i;
-                                       if (c == '\n')
+                                       if (c == '\n') {
                                                ++macro_num;
+                                       } else if (c == '"') {
+                                               quoting = !quoting;
+                                       }
+
                                        if (c == '{') {
                                                if (i_bra != i_end)
                                                        buffer->write(&*i_bra 
- 1, i - i_bra + 1);
                                                i_bra = i + 1;
                                        } else if (i_bra == i_end) {
-                                               if (c == '#') {
+                                               if (c == '#' && !quoting) {
                                                        // keep track of 
textdomain changes in the body of the
                                                        // macro so they can 
be restored after each substitution
                                                        // of a macro argument
@@ -636,6 +641,15 @@
                                                                        
++i_beg;
                                                                
macro_textdomain = std::string(i_beg, i);
                                                                *buffer << 
"#textdomain " << macro_textdomain;
+                                                               ++macro_num;
+                                                               c = '\n';
+                                                       } else if((i_end - 
i_beg < 6 || !std::equal(i_beg, i_beg + 6, "define"))
+                                                       && (i_end - i_beg < 5 
|| (!std::equal(i_beg, i_beg + 5, "ifdef") 
+                                                       && !std::equal(i_beg, 
i_beg + 5, "endif") && !std::equal(i_beg, i_beg + 5, "undef")))
+                                                       && (i_end - i_beg < 4 
|| !std::equal(i_beg, i_beg + 4, "else"))) {
+                                                               //check for 
define, ifdef, endif, undef, else
+                                                               //otherwise, 
this is a comment and should be skipped
+                                                               i = 
std::find(i_beg, i_end, '\n');
                                                                ++macro_num;
                                                                c = '\n';
                                                        }

Modified: trunk/src/unit.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/unit.cpp?rev=20590&r1=20589&r2=20590&view=diff
==============================================================================
--- trunk/src/unit.cpp (original)
+++ trunk/src/unit.cpp Wed Sep 19 06:39:47 2007
@@ -518,7 +518,7 @@
        }
 
 
-       if(cfg_["random_traits"].empty() || 
utils::string_bool(cfg_["random_traits"])) {
+       if(utils::string_bool(cfg_["random_traits"], true)) {
                generate_traits(!use_traits);
        } else {
                // This will add any "musthave" traits to the new unit that 
it doesn't already have.
@@ -1272,7 +1272,7 @@
        }
        if(!type_set) {
                backup_state();
-               if(cfg["random_traits"].empty() || 
utils::string_bool(cfg["random_traits"])) {
+               if(utils::string_bool(cfg_["random_traits"], true)) {
                        generate_traits(!use_traits);
                }
                apply_modifications();




Related Messages


Powered by MHonArc, Updated Wed Sep 19 12:01:28 2007