diff --git a/debian/changelog b/debian/changelog
index 1a8ef25..786b8f5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,7 @@ instead (1.0.3) unstable; urgency=low
* autojump to text change
* no cursor flickering
+ * sdl_path (i18n M$ win sdl paths)
-- Peter Kosyh
Tue, 01 Dec 2009 14:12:36 +0300
diff --git a/src/sdl-instead/game.c b/src/sdl-instead/game.c
index ca29aa8..c0d7bf5 100644
--- a/src/sdl-instead/game.c
+++ b/src/sdl-instead/game.c
@@ -1038,7 +1038,7 @@ void game_music_player(void)
instead_eval("return get_music()");
mus = instead_retval(0);
loop = instead_iretval(1);
- unix_path(mus);
+ mus = sdl_path(mus);
instead_clear();
if (mus && loop == -1) { /* disabled, 0 - forever, 1-n - loops */
@@ -1138,7 +1138,7 @@ void game_sound_player(void)
}
instead_eval("set_sound(nil, -1)"); instead_clear();
- unix_path(snd);
+ snd = sdl_path(snd);
w = sound_find(snd);
if (!w)
w = sound_add(snd);
@@ -1261,7 +1261,7 @@ int game_cmd(char *cmd)
pict = instead_retval(0);
instead_clear();
- unix_path(pict);
+ pict = sdl_path(pict);
new_pict = check_new_pict(pict);
diff --git a/src/sdl-instead/graphics.c b/src/sdl-instead/graphics.c
index 7c1a14b..e170108 100644
--- a/src/sdl-instead/graphics.c
+++ b/src/sdl-instead/graphics.c
@@ -647,9 +647,9 @@ img_t gfx_load_image(char *filename)
img_t img = NULL;
if (!filename)
return NULL;
- if (!access(filename, R_OK))
+/* if (!access(filename, R_OK)) */
img = _gfx_load_image(filename);
- else
+ if (!img)
img = _gfx_load_combined_image(filename);
return img;
}
diff --git a/src/sdl-instead/instead.c b/src/sdl-instead/instead.c
index 05de57e..4e09796 100644
--- a/src/sdl-instead/instead.c
+++ b/src/sdl-instead/instead.c
@@ -181,34 +181,6 @@ static char *fromcp = NULL;
#endif
#ifdef _HAVE_ICONV
-#define CHAR_MAX_LEN 4
-static char *decode(iconv_t hiconv, const char *s)
-{
- size_t s_size, chs_size, outsz, insz;
- char *inbuf, *outbuf, *chs_buf;
- if (!s || hiconv == (iconv_t)(-1))
- return NULL;
- s_size = strlen(s) + 1;
- chs_size = s_size * CHAR_MAX_LEN;
- if ((chs_buf = malloc(chs_size + CHAR_MAX_LEN))==NULL)
- goto exitf;
- outsz = chs_size;
- outbuf = chs_buf;
- insz = s_size;
- inbuf = (char*)s;
- while (insz) {
- if (iconv(hiconv, &inbuf, &insz, &outbuf, &outsz)
- == (size_t)(-1))
- goto exitf;
- }
- *outbuf++ = 0;
- return chs_buf;
-exitf:
- if(chs_buf)
- free(chs_buf);
- return NULL;
-}
-
char *fromgame(const char *s)
{
iconv_t han;
diff --git a/src/sdl-instead/unix.c b/src/sdl-instead/unix.c
index 377b870..8ea5a0b 100644
--- a/src/sdl-instead/unix.c
+++ b/src/sdl-instead/unix.c
@@ -9,6 +9,11 @@
#include
#include
+#include
+#include
+#ifdef _HAVE_ICONV
+#include
+#endif
#include "internals.h"
#ifndef PATH_MAX
@@ -110,3 +115,8 @@ void debug_done()
}
+char *sdl_path(char *p)
+{
+ unix_path(p);
+ return p;
+}
diff --git a/src/sdl-instead/util.c b/src/sdl-instead/util.c
index 32bc08d..57b163b 100644
--- a/src/sdl-instead/util.c
+++ b/src/sdl-instead/util.c
@@ -223,7 +223,7 @@ int parse_full_path(const char *v, void *data)
strcpy(*p, cwd);
strcat(*p,"/");
strcat(*p, v);
- unix_path(*p);
+ *p = sdl_path(*p);
return 0;
}
@@ -296,3 +296,32 @@ char *parse_tag(char *line, const char *tag, const char *comm, int *brk)
ns[strcspn(ns, "\n\r")] = 0;
return ns;
}
+#ifdef _HAVE_ICONV
+#define CHAR_MAX_LEN 4
+char *decode(iconv_t hiconv, const char *s)
+{
+ size_t s_size, chs_size, outsz, insz;
+ char *inbuf, *outbuf, *chs_buf;
+ if (!s || hiconv == (iconv_t)(-1))
+ return NULL;
+ s_size = strlen(s) + 1;
+ chs_size = s_size * CHAR_MAX_LEN;
+ if ((chs_buf = malloc(chs_size + CHAR_MAX_LEN))==NULL)
+ goto exitf;
+ outsz = chs_size;
+ outbuf = chs_buf;
+ insz = s_size;
+ inbuf = (char*)s;
+ while (insz) {
+ if (iconv(hiconv, &inbuf, &insz, &outbuf, &outsz)
+ == (size_t)(-1))
+ goto exitf;
+ }
+ *outbuf++ = 0;
+ return chs_buf;
+exitf:
+ if(chs_buf)
+ free(chs_buf);
+ return NULL;
+}
+#endif
diff --git a/src/sdl-instead/util.h b/src/sdl-instead/util.h
index 05c840e..59588af 100644
--- a/src/sdl-instead/util.h
+++ b/src/sdl-instead/util.h
@@ -22,7 +22,13 @@ extern int parse_string(const char *v, void *data);
extern int parse_int(const char *v, void *data);
extern int parse_full_path(const char *v, void *data);
+#ifdef _HAVE_ICONV
+extern char *decode(iconv_t hiconv, const char *s);
+#endif
+
extern void unix_path(char *path);
+extern char *sdl_path(char *path);
+
extern char *parse_tag(char *line, const char *tag, const char *comm, int *brk);
#ifndef PATH_MAX
diff --git a/src/sdl-instead/windows.c b/src/sdl-instead/windows.c
index fcd6a57..f9234c9 100644
--- a/src/sdl-instead/windows.c
+++ b/src/sdl-instead/windows.c
@@ -6,7 +6,9 @@
#include
#include
#include
-
+#ifdef _HAVE_ICONV
+#include
+#endif
#include "internals.h"
extern char *curgame;
@@ -32,6 +34,61 @@ char *game_locale(void)
return strdup(buff);
}
+static char *game_codepage = NULL;
+
+#ifdef _HAVE_ICONV
+static char *game_cp(void)
+{
+ char cpbuff[64];
+ char buff[64];
+ buff[0] = 0;
+ if (!GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IDEFAULTANSICODEPAGE,
+ buff,sizeof(buff) - 1))
+ return NULL;
+ snprintf(cpbuff, sizeof(cpbuff), "WINDOWS-%s", buff);
+ return strdup(cpbuff);
+}
+
+char *mbs2utf8(const char *s)
+{
+ iconv_t han;
+ char *str;
+ if (!game_codepage)
+ game_codepage = game_cp();
+ if (!s)
+ return NULL;
+ if (!game_codepage)
+ goto out0;
+ han = iconv_open("UTF-8", game_codepage);
+ if (han == (iconv_t)-1)
+ goto out0;
+ if (!(str = decode(han, s)))
+ goto out1;
+ iconv_close(han);
+ return str;
+out1:
+ iconv_close(han);
+out0:
+ return strdup(s);
+}
+#else
+char *mbs2utf8(const char *s)
+{
+ return strdup(s);
+}
+#endif
+
+extern void unix_path(char *);
+
+char *sdl_path(char *p)
+{
+ char *r = mbs2utf8(p);
+ if (p)
+ free(p);
+ unix_path(r);
+ return r;
+}
+
char *app_dir( void );
char *game_local_games_path(void)
@@ -46,11 +103,9 @@ char *game_local_themes_path(void)
return local_themes_path;
}
-extern void unix_path(char *);
-
char *app_dir( void )
{
- static char appdir[PATH_MAX];
+ static char appdir[PATH_MAX]="";
SHGetFolderPath( NULL,
CSIDL_FLAG_CREATE | CSIDL_LOCAL_APPDATA,
NULL,