mail[Wesnoth-commits] r28843 - in /trunk/src: addon_checks.cpp addon_checks.hpp addon_management.cpp campaign_server/campaign_server.cpp


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

Header


Content

Posted by paniemin on August 22, 2008 - 18:53:
Author: suokko
Date: Fri Aug 22 18:53:33 2008
New Revision: 28843

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28843&view=rev
Log:
Code to fix campaign server stored data to correct encoding

Modified:
    trunk/src/addon_checks.cpp
    trunk/src/addon_checks.hpp
    trunk/src/addon_management.cpp
    trunk/src/campaign_server/campaign_server.cpp

Modified: trunk/src/addon_checks.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/addon_checks.cpp?rev=28843&r1=28842&r2=28843&view=diff
==============================================================================
--- trunk/src/addon_checks.cpp (original)
+++ trunk/src/addon_checks.cpp Fri Aug 22 18:53:33 2008
@@ -105,3 +105,58 @@
        }
        return python_scripts;
 }
+
+namespace {
+       const char escape_char = '\x01'; //!< Binary escape char.
+} // end unnamed namespace 2
+
+bool needs_escaping(char c) {
+       switch(c) {
+               case '\x00':
+               case escape_char:
+               case '\x0D': //Windows -- carriage return
+               case '\xFE': //Parser code -- textdomain or 
linenumber&filename
+                       return true;
+               default:
+                       return false;
+       }
+}
+
+std::string encode_binary(const std::string& str)
+{
+       std::string res;
+       res.resize(str.size());
+       size_t n = 0;
+       for(std::string::const_iterator j = str.begin(); j != str.end(); ++j) 
{
+               if(needs_escaping(*j)) {
+                       res.resize(res.size()+1);
+                       res[n++] = escape_char;
+                       res[n++] = *j + 1;
+               } else {
+                       res[n++] = *j;
+               }
+       }
+
+       return res;
+}
+
+std::string unencode_binary(const std::string& str)
+{
+       std::string res;
+       res.resize(str.size());
+
+       size_t n = 0;
+       for(std::string::const_iterator j = str.begin(); j != str.end(); ++j) 
{
+               if(*j == escape_char && j+1 != str.end()) {
+                       ++j;
+                       res[n++] = *j - 1;
+                       res.resize(res.size()-1);
+               } else {
+                       res[n++] = *j;
+               }
+       }
+
+       return res;
+}
+
+

Modified: trunk/src/addon_checks.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/addon_checks.hpp?rev=28843&r1=28842&r2=28843&view=diff
==============================================================================
--- trunk/src/addon_checks.hpp (original)
+++ trunk/src/addon_checks.hpp Fri Aug 22 18:53:33 2008
@@ -67,4 +67,8 @@
 /** Return a vector of detected scripts. */
 std::vector<config *> find_scripts(const config &cfg, std::string extension);
 
+std::string encode_binary(const std::string& str);
+std::string unencode_binary(const std::string& str);
+bool needs_escaping(char c);
+
 #endif /* !ADDON_CHECKS_HPP_INCLUDED */

Modified: trunk/src/addon_management.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/addon_management.cpp?rev=28843&r1=28842&r2=28843&view=diff
==============================================================================
--- trunk/src/addon_management.cpp (original)
+++ trunk/src/addon_management.cpp Fri Aug 22 18:53:33 2008
@@ -130,22 +130,6 @@
        return res;
 }
 
-namespace {
-       const char escape_char = '\x01'; //!< Binary escape char.
-} // end unnamed namespace 2
-
-static bool needs_escaping(char c) {
-       switch(c) {
-               case '\x00':
-               case escape_char:
-               case '\x0D': //Windows -- carriage return
-               case '\xFE': //Parser code -- textdomain or 
linenumber&filename
-                       return true;
-               default:
-                       return false;
-       }
-}
-
 static inline bool IsCR(const char& c)
 {
        return c == '\x0D';
@@ -158,43 +142,6 @@
        std::string::iterator new_end = std::remove_if(str.begin(), 
str.end(), IsCR);
        str.erase(new_end, str.end());
        return str;
-}
-
-static std::string encode_binary(const std::string& str)
-{
-       std::string res;
-       res.resize(str.size());
-       size_t n = 0;
-       for(std::string::const_iterator j = str.begin(); j != str.end(); ++j) 
{
-               if(needs_escaping(*j)) {
-                       res.resize(res.size()+1);
-                       res[n++] = escape_char;
-                       res[n++] = *j + 1;
-               } else {
-                       res[n++] = *j;
-               }
-       }
-
-       return res;
-}
-
-static std::string unencode_binary(const std::string& str)
-{
-       std::string res;
-       res.resize(str.size());
-
-       size_t n = 0;
-       for(std::string::const_iterator j = str.begin(); j != str.end(); ++j) 
{
-               if(*j == escape_char && j+1 != str.end()) {
-                       ++j;
-                       res[n++] = *j - 1;
-                       res.resize(res.size()-1);
-               } else {
-                       res[n++] = *j;
-               }
-       }
-
-       return res;
 }
 
 namespace {

Modified: trunk/src/campaign_server/campaign_server.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/campaign_server/campaign_server.cpp?rev=28843&r1=28842&r2=28843&view=diff
==============================================================================
--- trunk/src/campaign_server/campaign_server.cpp (original)
+++ trunk/src/campaign_server/campaign_server.cpp Fri Aug 22 18:53:33 2008
@@ -292,7 +292,7 @@
                        
                        cfg_["converted_to_gzipped_data"] = "yes";
                }
-               if (cfg_["cr_encoded"] != "yes")
+               if (cfg_["encoded"] != "yes")
                {
                        // Convert all addons to gzip
                        config::child_list camps = 
campaigns().get_children("campaign");
@@ -316,7 +316,7 @@
                                        unsigned char c = in_filter.get();
                                        while( in_filter.good())
                                        {
-                                               if (c == '\r')
+                                               if (needs_escaping(c))
                                                {
                                                        
out_filter.put('\x01');
                                                        out_filter.put(c+1);




Related Messages


Powered by MHonArc, Updated Fri Aug 22 19:02:05 2008