[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot/game coord.cpp encoding.cpp encoding.h hi... [multibyt
From: |
eliot-dev |
Subject: |
[Eliot-dev] eliot/game coord.cpp encoding.cpp encoding.h hi... [multibyte] |
Date: |
Sun, 08 Jan 2006 18:05:45 +0000 |
CVSROOT: /sources/eliot
Module name: eliot
Branch: multibyte
Changes by: Olivier Teulière <address@hidden> 06/01/08 18:05:45
Modified files:
game : coord.cpp encoding.cpp encoding.h history.cpp
player.cpp round.cpp
Log message:
New _swprintf function in encoding.h, to workaround the different
prototypes
of swprintf on linux and mingw32
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/coord.cpp.diff?only_with_tag=multibyte&tr1=1.7.2.3&tr2=1.7.2.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/encoding.cpp.diff?only_with_tag=multibyte&tr1=1.1.2.1&tr2=1.1.2.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/encoding.h.diff?only_with_tag=multibyte&tr1=1.1.2.1&tr2=1.1.2.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/history.cpp.diff?only_with_tag=multibyte&tr1=1.8.2.3&tr2=1.8.2.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/player.cpp.diff?only_with_tag=multibyte&tr1=1.12.2.3&tr2=1.12.2.4&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/round.cpp.diff?only_with_tag=multibyte&tr1=1.8.2.3&tr2=1.8.2.4&r1=text&r2=text
Patches:
Index: eliot/game/coord.cpp
diff -u eliot/game/coord.cpp:1.7.2.3 eliot/game/coord.cpp:1.7.2.4
--- eliot/game/coord.cpp:1.7.2.3 Tue Jan 3 20:42:13 2006
+++ eliot/game/coord.cpp Sun Jan 8 18:05:44 2006
@@ -100,22 +100,22 @@
wchar_t srow[3];
wchar_t scol[3];
- swprintf(scol, 3, L"%d", m_col);
- swprintf(srow, 3, L"%c", m_row + 'A' - 1);
+ _swprintf(scol, 3, L"%d", m_col);
+ _swprintf(srow, 3, L"%c", m_row + 'A' - 1);
switch (mode)
{
case COORD_MODE_COMPACT:
if (getDir() == HORIZONTAL)
- swprintf(res, 7, L"%ls%ls", srow, scol);
+ _swprintf(res, 7, L"%ls%ls", srow, scol);
else
- swprintf(res, 7, L"%ls%ls", scol, srow);
+ _swprintf(res, 7, L"%ls%ls", scol, srow);
break;
case COORD_MODE_LONG:
if (getDir() == HORIZONTAL)
- swprintf(res, 7, L"%2ls %2ls", srow, scol);
+ _swprintf(res, 7, L"%2ls %2ls", srow, scol);
else
- swprintf(res, 7, L"%2ls %2ls", scol, srow);
+ _swprintf(res, 7, L"%2ls %2ls", scol, srow);
break;
}
Index: eliot/game/encoding.cpp
diff -u eliot/game/encoding.cpp:1.1.2.1 eliot/game/encoding.cpp:1.1.2.2
--- eliot/game/encoding.cpp:1.1.2.1 Wed Dec 28 16:47:35 2005
+++ eliot/game/encoding.cpp Sun Jan 8 18:05:45 2006
@@ -25,6 +25,8 @@
*/
#include <stdlib.h>
+#include <stdarg.h>
+#include <wchar.h>
#include <wctype.h>
#include "encoding.h"
@@ -41,6 +43,22 @@
}
+int _swprintf(wchar_t *wcs, size_t maxlen, const wchar_t *format, ...)
+{
+ int res;
+ va_list argp;
+ va_start(argp, format);
+#ifdef WIN32
+ // Mingw32 does not take the maxlen argument
+ res = vswprintf(wcs, format, argp);
+#else
+ res = vswprintf(wcs, maxlen, format, argp);
+#endif
+ va_end(argp);
+ return res;
+}
+
+
wstring convertToWc(const string& iStr)
{
// Get the needed length (we _can't_ use string::size())
Index: eliot/game/encoding.h
diff -u eliot/game/encoding.h:1.1.2.1 eliot/game/encoding.h:1.1.2.2
--- eliot/game/encoding.h:1.1.2.1 Wed Dec 28 16:47:35 2005
+++ eliot/game/encoding.h Sun Jan 8 18:05:45 2006
@@ -33,16 +33,19 @@
using std::wstring;
-// Equivalent of atoi for wide-caracter strings
+/// Equivalent of atoi for wide-caracter strings
int _wtoi(const wchar_t *iWStr);
-// Convert a multi-byte string into a wide-character string
+/// Equivalent of swprintf, but working also with mingw32
+int _swprintf(wchar_t *wcs, size_t maxlen, const wchar_t *format, ...);
+
+/// Convert a multi-byte string into a wide-character string
wstring convertToWc(const string& iStr);
-// Convert a wide-character string into a multi-byte string
+/// Convert a wide-character string into a multi-byte string
string convertToMb(const wstring& iWStr);
-// Convert a wide character into a multi-byte string
+/// Convert a wide character into a multi-byte string
string convertToMb(wchar_t iWChar);
#endif
Index: eliot/game/history.cpp
diff -u eliot/game/history.cpp:1.8.2.3 eliot/game/history.cpp:1.8.2.4
--- eliot/game/history.cpp:1.8.2.3 Tue Jan 3 20:42:13 2006
+++ eliot/game/history.cpp Sun Jan 8 18:05:45 2006
@@ -29,8 +29,10 @@
#include "pldrack.h"
#include "round.h"
#include "turn.h"
-#include "debug.h"
#include "history.h"
+#include "encoding.h"
+#include "debug.h"
+
/* ******************************************************** */
/* ******************************************************** */
@@ -159,11 +161,7 @@
wstring rs;
#ifdef DEBUG
wchar_t buff[5];
-#ifdef WIN32
- swprintf(buff, L"%ld", m_history.size());
-#else
- swprintf(buff, 4, L"%ld", m_history.size());
-#endif
+ _swprintf(buff, 4, L"%ld", m_history.size());
rs = L"history size = " + wstring(buff) + L"\n\n";
#endif
for (unsigned int i = 0; i < m_history.size(); i++)
Index: eliot/game/player.cpp
diff -u eliot/game/player.cpp:1.12.2.3 eliot/game/player.cpp:1.12.2.4
--- eliot/game/player.cpp:1.12.2.3 Tue Jan 3 20:42:13 2006
+++ eliot/game/player.cpp Sun Jan 8 18:05:45 2006
@@ -26,6 +26,7 @@
#include "player.h"
#include "turn.h"
#include "history.h"
+#include "encoding.h"
#include "debug.h"
@@ -81,18 +82,10 @@
wstring res;
wchar_t buff[6];
-#ifdef WIN32
- swprintf(buff, L"Player %d\n", m_id);
-#else
- swprintf(buff, 5, L"Player %d\n", m_id);
-#endif
+ _swprintf(buff, 5, L"Player %d\n", m_id);
res = wstring(buff);
res += m_history.toString() + L"\n";
-#ifdef WIN32
- swprintf(buff, L"score %d\n", m_score);
-#else
- swprintf(buff, 5, L"score %d\n", m_score);
-#endif
+ _swprintf(buff, 5, L"score %d\n", m_score);
res += wstring(buff);
return res;
}
Index: eliot/game/round.cpp
diff -u eliot/game/round.cpp:1.8.2.3 eliot/game/round.cpp:1.8.2.4
--- eliot/game/round.cpp:1.8.2.3 Tue Jan 3 20:42:13 2006
+++ eliot/game/round.cpp Sun Jan 8 18:05:45 2006
@@ -20,9 +20,9 @@
#include <string>
#include <wctype.h>
-#include <wchar.h>
#include "tile.h"
#include "round.h"
+#include "encoding.h"
#define FROMBOARD 0x1
@@ -168,11 +168,7 @@
rs += wstring(16 - getWord().size(), ' ');
rs += getBonus() ? L'*' : L' ';
wchar_t buff[5];
-#ifdef WIN32
- swprintf(buff, L"%d", getPoints());
-#else
- swprintf(buff, 4, L"%d", getPoints());
-#endif
+ _swprintf(buff, 4, L"%d", getPoints());
rs += buff;
rs += L" " + getCoord().toString();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Eliot-dev] eliot/game coord.cpp encoding.cpp encoding.h hi... [multibyte],
eliot-dev <=