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 binary_wml.cpp


From: Guillaume Melquiond
Subject: [Wesnoth-cvs-commits] wesnoth/src/serialization binary_wml.cpp
Date: Sat, 26 Mar 2005 04:48:26 -0500

CVSROOT:        /cvsroot/wesnoth
Module name:    wesnoth
Branch:         
Changes by:     Guillaume Melquiond <address@hidden>    05/03/26 09:48:26

Modified files:
        src/serialization: binary_wml.cpp 

Log message:
        Workaround the case of the empty literal word (NUL right on start) that 
would prevent some binary savefile to load. Remove endline from the config 
error messages. Switch from fail to not good.

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

Patches:
Index: wesnoth/src/serialization/binary_wml.cpp
diff -u wesnoth/src/serialization/binary_wml.cpp:1.6 
wesnoth/src/serialization/binary_wml.cpp:1.7
--- wesnoth/src/serialization/binary_wml.cpp:1.6        Fri Mar 25 20:10:39 2005
+++ wesnoth/src/serialization/binary_wml.cpp    Sat Mar 26 09:48:25 2005
@@ -1,4 +1,4 @@
-/* $Id: binary_wml.cpp,v 1.6 2005/03/25 20:10:39 silene Exp $ */
+/* $Id: binary_wml.cpp,v 1.7 2005/03/26 09:48:25 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -114,16 +114,17 @@
 static std::string compress_read_literal_word(std::istream &in)
 {
        std::stringstream stream;
-       in.get(*stream.rdbuf(), 0);
-       if (in.get() || in.fail())
-               throw config::error("Unexpected end of data in compressed 
config read\n");
+       if (in.peek()) // this conditional works around the failure of the 
empty word
+               in.get(*stream.rdbuf(), 0);
+       if (in.get() || !in.good())
+               throw config::error("Unexpected end of data in compressed 
config read");
        return stream.str();
 }
 
 static void write_compressed_internal(std::ostream &out, config const &cfg, 
compression_schema &schema, int level)
 {
        if (level > max_recursion_levels)
-               throw config::error("Too many recursion levels in compressed 
config write\n");
+               throw config::error("Too many recursion levels in compressed 
config write");
 
        for (string_map::const_iterator i = cfg.values.begin(), i_end = 
cfg.values.end(); i != i_end; ++i) {
                if (i->second.empty() == false) {
@@ -155,12 +156,12 @@
 static void read_compressed_internal(config &cfg, std::istream &in, 
compression_schema &schema, int level)
 {
        if (level >= max_recursion_levels)
-               throw config::error("Too many recursion levels in compressed 
config read\n");
+               throw config::error("Too many recursion levels in compressed 
config read");
        
        bool in_open_element = false;
        for(;;) {
                unsigned char const c = in.get();
-               if (in.fail())
+               if (!in.good())
                        return;
                switch (c) {
                case compress_open_element:
@@ -183,7 +184,7 @@
                                        = schema.char_to_word.find(code);
                                if (itor == schema.char_to_word.end()) {
                                        ERR_CF << "illegal word code: " << code 
<< "\n";
-                                       throw config::error("Illegal character 
in compression input\n");
+                                       throw config::error("Illegal character 
in compression input");
                                }
 
                                word = itor->second;




reply via email to

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