eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] eliot dic/encoding.cpp game/game_io.cpp wxwin/m... [cppdic]


From: eliot-dev
Subject: [Eliot-dev] eliot dic/encoding.cpp game/game_io.cpp wxwin/m... [cppdic]
Date: Thu, 06 Dec 2007 15:06:06 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Branch:         cppdic
Changes by:     Olivier Teulière <ipkiss>      07/12/06 15:06:06

Modified files:
        dic            : encoding.cpp 
        game           : game_io.cpp 
        wxwin          : main.cc 

Log message:
         - game/game_io.cpp: Fixed a bug when saving old format games with 
multibyte characters
         - wxwin/main.cc: Commented out a locale-related line causing a weird 
bug (see comment)
         - dic/encoding.cpp: Do not throw an exception in case of non printable 
character, rather log the error to stderr. But it might be better to be more 
stricct and throw an exception, I don't know

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/dic/encoding.cpp?cvsroot=eliot&only_with_tag=cppdic&r1=1.1.2.6&r2=1.1.2.7
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game_io.cpp?cvsroot=eliot&only_with_tag=cppdic&r1=1.4.2.2&r2=1.4.2.3
http://cvs.savannah.gnu.org/viewcvs/eliot/wxwin/main.cc?cvsroot=eliot&only_with_tag=cppdic&r1=1.10&r2=1.10.2.1

Patches:
Index: dic/encoding.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/dic/Attic/encoding.cpp,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -b -r1.1.2.6 -r1.1.2.7
--- dic/encoding.cpp    6 Dec 2007 13:24:48 -0000       1.1.2.6
+++ dic/encoding.cpp    6 Dec 2007 15:06:05 -0000       1.1.2.7
@@ -26,6 +26,8 @@
 
 #include "config.h"
 
+#include <iostream>
+#include <sstream>
 #include <stdlib.h>
 #include <stdarg.h>
 #include <wchar.h>
@@ -34,6 +36,8 @@
 #include "encoding.h"
 #include "dic_exception.h"
 
+using namespace std;
+
 
 #if !HAVE_WCWIDTH
 // wcwidth replacement (for win32 in particular)
@@ -145,7 +149,6 @@
 }
 
 
-
 string padAndConvert(const wstring &iWstr, unsigned int iLength,
                      bool iLeftPad, char c)
 {
@@ -154,7 +157,13 @@
     {
         int n = wcwidth(iWstr[i]);
         if (n == -1)
-            throw DicException("padAndConvert: non printable character");
+        {
+            ostringstream ss;
+            ss << "padAndConvert: non printable character: " << iWstr[i];
+            // XXX: Should we throw an exception instead? Just ignore the 
problem?
+            cerr << ss.str() << endl;;
+            //throw DicException(ss.str());
+        }
         width += n;
     }
 

Index: game/game_io.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game_io.cpp,v
retrieving revision 1.4.2.2
retrieving revision 1.4.2.3
diff -u -b -r1.4.2.2 -r1.4.2.3
--- game/game_io.cpp    4 Dec 2007 11:09:59 -0000       1.4.2.2
+++ game/game_io.cpp    6 Dec 2007 15:06:06 -0000       1.4.2.3
@@ -494,16 +494,14 @@
     for (int i = 0; i < m_history.getSize(); i++)
     {
         const Turn& turn = m_history.getTurn(i);
-        string rack = 
convertToMb(turn.getPlayedRack().toString(PlayedRack::RACK_EXTRA));
-        string word = convertToMb(turn.getRound().getWord());
+        wstring rack = turn.getPlayedRack().toString(PlayedRack::RACK_EXTRA);
+        wstring word = turn.getRound().getWord();
         string coord = 
convertToMb(turn.getRound().getCoord().toString(Coord::COORD_MODE_LONG));
 
         // rack [space] word [space] bonus points coord
-        sprintf(line,"%s%s%s%s%c%4d %s",
-                rack.c_str(),
-                string(12 - rack.size(), ' ').c_str(),
-                word.c_str(),
-                string(16 - word.size(), ' ').c_str(),
+        sprintf(line,"%s%s%c%4d %s",
+                padAndConvert(rack, 12, false).c_str(),
+                padAndConvert(word, 16, false).c_str(),
                 turn.getRound().getBonus() ? '*' : ' ',
                 turn.getRound().getPoints(),
                 coord.c_str()
@@ -514,7 +512,7 @@
 
     out << endl;
     out << decal << "total" << string(24,' ');
-    sprintf(line,"%4d", getCurrentPlayer().getPoints());
+    sprintf(line, "%4d", getCurrentPlayer().getPoints());
     out << line << endl;
 }
 

Index: wxwin/main.cc
===================================================================
RCS file: /cvsroot/eliot/eliot/wxwin/main.cc,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -b -r1.10 -r1.10.2.1
--- wxwin/main.cc       11 Aug 2006 22:18:33 -0000      1.10
+++ wxwin/main.cc       6 Dec 2007 15:06:06 -0000       1.10.2.1
@@ -67,8 +67,11 @@
     wxConfigBase* config = wxConfigBase::Get();
     config = NULL;
 #ifdef ENABLE_LOCALE
-    locale.Init(wxLocale::GetSystemLanguage(),
-                wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
+// XXX: This line seems to create problems with the display of the game history
+// (in GameFrame::Refresh()). As usual, wxWidgets does some black magic behind
+// our back...
+//    locale.Init(wxLocale::GetSystemLanguage(),
+//                wxLOCALE_LOAD_DEFAULT | wxLOCALE_CONV_ENCODING);
 
     wxLocale::AddCatalogLookupPathPrefix(wxT("."));
     wxLocale::AddCatalogLookupPathPrefix(wxT(".."));




reply via email to

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