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


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

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

Modified files:
        src/serialization: binary_or_text.cpp 

Log message:
        Now that we are using streams, we can't afford to go back at the start 
of it in case of wrong detection. So let's detect the format by just peeking 
the first character.

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

Patches:
Index: wesnoth/src/serialization/binary_or_text.cpp
diff -u wesnoth/src/serialization/binary_or_text.cpp:1.4 
wesnoth/src/serialization/binary_or_text.cpp:1.5
--- wesnoth/src/serialization/binary_or_text.cpp:1.4    Fri Mar 25 19:48:48 2005
+++ wesnoth/src/serialization/binary_or_text.cpp        Sat Mar 26 09:06:17 2005
@@ -1,4 +1,4 @@
-/* $Id: binary_or_text.cpp,v 1.4 2005/03/25 19:48:48 silene Exp $ */
+/* $Id: binary_or_text.cpp,v 1.5 2005/03/26 09:06:17 silene Exp $ */
 /*
    Copyright (C) 2003 by David White <address@hidden>
    Copyright (C) 2005 by Guillaume Melquiond <address@hidden>
@@ -21,14 +21,14 @@
 
 bool detect_format_and_read(config &cfg, std::istream &in)
 {
-       try {
+       unsigned char c = in.peek();
+       if (c < 5) {
                read_compressed(cfg, in);
                return true;
-       } catch (config::error &) {
+       } else {
+               read(cfg, in);
+               return false;
        }
-
-       read(cfg, in);
-       return false;
 }
 
 void write_possibly_compressed(std::string const &filename, config &cfg, bool 
compress)




reply via email to

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