mail[Wesnoth-commits] r27116 - in /trunk/src: dialogs.cpp game.cpp language.cpp


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

Header


Content

Posted by cycholka on June 12, 2008 - 13:22:
Author: cycholka
Date: Thu Jun 12 13:15:58 2008
New Revision: 27116

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27116&view=rev
Log:
Add #ifdef for _WIN32 to replace std::setlocale() calls failing in windows 
with ::setlocale() and include locale.h for the latter.

Modified:
    trunk/src/dialogs.cpp
    trunk/src/game.cpp
    trunk/src/language.cpp

Modified: trunk/src/dialogs.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/dialogs.cpp?rev=27116&r1=27115&r2=27116&view=diff
==============================================================================
--- trunk/src/dialogs.cpp (original)
+++ trunk/src/dialogs.cpp Thu Jun 12 13:15:58 2008
@@ -37,6 +37,10 @@
 
 #include <assert.h>
 #include <clocale>
+
+#ifdef _WIN32
+#include "locale.h"
+#endif
 
 #define LOG_NG LOG_STREAM(info, engine)
 #define LOG_DP LOG_STREAM(info, display)
@@ -481,8 +485,12 @@
                ypos = maximum<int>(ypos,map_rect.y + map_rect.h + 
save_preview_border);
                SDL_BlitSurface(map_surf,NULL,screen,&map_rect);
        }
-
+    
+    #ifndef _WIN32
        char* old_locale = std::setlocale(LC_TIME, 
get_locale().localename.c_str());
+       #else
+       char* old_locale = ::setlocale(LC_TIME, 
get_locale().localename.c_str());       
+       #endif
        char time_buf[256] = {0};
        const save_info& save = (*info_)[index_];
        tm* tm_l = localtime(&save.time_modified);
@@ -496,7 +504,11 @@
        }
 
        if(old_locale) {
+        #ifndef _WIN32           
                std::setlocale(LC_TIME, old_locale);
+               #else
+               ::setlocale(LC_TIME, old_locale);
+               #endif
        }
 
        std::stringstream str;

Modified: trunk/src/game.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=27116&r1=27115&r2=27116&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Thu Jun 12 13:15:58 2008
@@ -61,6 +61,10 @@
 #include "serialization/preprocessor.hpp"
 #include "serialization/string_utils.hpp"
 #include "sha1.hpp"
+
+#ifdef _WIN32
+#include "locale.h"
+#endif
 
 #ifdef HAVE_PYTHON
 #include "ai_python.hpp"
@@ -2457,8 +2461,13 @@
        // initialized to have get_intl_dir() to work.  Note: this
        // setlocale() but this does not take GUI language setting
        // into account.
+#ifndef _WIN32 
        std::setlocale(LC_ALL, "C");
        std::setlocale(LC_MESSAGES, "");
+#else
+     ::setlocale(LC_ALL, "C");
+     ::setlocale(LC_MESSAGES, "");
+#endif
        const std::string& intl_dir = get_intl_dir();
        bindtextdomain (PACKAGE, intl_dir.c_str());
        bind_textdomain_codeset (PACKAGE, "UTF-8");

Modified: trunk/src/language.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/language.cpp?rev=27116&r1=27115&r2=27116&view=diff
==============================================================================
--- trunk/src/language.cpp (original)
+++ trunk/src/language.cpp Thu Jun 12 13:15:58 2008
@@ -1,4 +1,3 @@
-/* $Id$ */
 /* vim:set encoding=utf-8: */
 /*
    Copyright (C) 2003 - 2008 by David White <dave@xxxxxxxxxxxxx>
@@ -39,6 +38,7 @@
 #include <stdexcept>
 
 #ifdef _WIN32
+#include "locale.h"
 #include <windows.h>
 #endif
 
@@ -226,15 +226,27 @@
        std::vector<std::string>::const_iterator i;
        if (alternates) i = alternates->begin();
        while (true) {
+        #ifndef _WIN32  
                res = std::setlocale(category, try_loc);
+               #else
+               res = ::setlocale(category, try_loc);
+               #endif
                if (res) break;
 
                std::string utf8 = std::string(try_loc) + 
std::string(".utf-8");
+               #ifndef _WIN32
                res = std::setlocale(category, utf8.c_str());
+               #else
+               res = ::setlocale(category, try_loc);
+               #endif
                if (res) break;
 
                utf8 = std::string(try_loc) + std::string(".UTF-8");
+               #ifndef _WIN32
                res = std::setlocale(category, utf8.c_str());
+               #else
+               res = ::setlocale(category, utf8.c_str());
+               #endif
                if (res) break;
 
                if (!alternates) break;




Related Messages


Powered by MHonArc, Updated Thu Jun 12 13:41:03 2008