From 51b01d625cff44de6a97a743b249b2371181f964 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 26 Feb 2010 19:22:27 +0200 Subject: [PATCH] cyrillic charset support and fix --- filesys.cpp | 15 +++++++++------ include/fsdb.h | 6 +----- od-win32/fsdb_mywin32.cpp | 1 - od-win32/fsdb_win32.cpp | 26 +++++++++++++------------- od-win32/unicode.cpp | 5 +++++ 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/filesys.cpp b/filesys.cpp index 7bef42e7..69eb53b5 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -936,18 +936,21 @@ static TCHAR *bstr (Unit *unit, uaecptr addr) static TCHAR *bstr_cut (Unit *unit, uaecptr addr) { TCHAR *p = unit->tmpbuf3; - int i, colon_seen = 0; + int i, colon_seen = 0, off; int n = get_byte (addr); + uae_char buf[257]; + off = 0; addr++; for (i = 0; i < n; i++, addr++) { uae_u8 c = get_byte (addr); - unit->tmpbuf3[i] = c; + buf[i] = c; if (c == '/' || (c == ':' && colon_seen++ == 0)) - p = unit->tmpbuf3 + i + 1; + off = i + 1; } - unit->tmpbuf3[i] = 0; - return p; + buf[i] = 0; + au_fs_copy (unit->tmpbuf3, sizeof (unit->tmpbuf3) / sizeof (TCHAR), buf); + return &p[off]; } static Unit *units = 0; @@ -1733,7 +1736,7 @@ static TCHAR *get_aname (Unit *unit, a_inode *base, TCHAR *rel) return my_strdup (rel); } -static void init_child_aino_tree(Unit *unit, a_inode *base, a_inode *aino) +static void init_child_aino_tree (Unit *unit, a_inode *base, a_inode *aino) { /* Update tree structure */ aino->parent = base; diff --git a/include/fsdb.h b/include/fsdb.h index 197733b3..87bbf163 100644 --- a/include/fsdb.h +++ b/include/fsdb.h @@ -109,11 +109,7 @@ extern int fsdb_used_as_nname (a_inode *base, const TCHAR *); extern a_inode *fsdb_lookup_aino_aname (a_inode *base, const TCHAR *); extern a_inode *fsdb_lookup_aino_nname (a_inode *base, const TCHAR *); extern int fsdb_exists (TCHAR *nname); - -STATIC_INLINE int same_aname (const TCHAR *an1, const TCHAR *an2) -{ - return strcasecmp (an1, an2) == 0; -} +extern int same_aname (const TCHAR *an1, const TCHAR *an2); /* Filesystem-dependent functions. */ extern int fsdb_name_invalid (const TCHAR *n); diff --git a/od-win32/fsdb_mywin32.cpp b/od-win32/fsdb_mywin32.cpp index 30662da8..1e67e55c 100644 --- a/od-win32/fsdb_mywin32.cpp +++ b/od-win32/fsdb_mywin32.cpp @@ -395,4 +395,3 @@ FILE *my_opentext (const TCHAR *name) } return _tfopen (name, L"r"); } - diff --git a/od-win32/fsdb_win32.cpp b/od-win32/fsdb_win32.cpp index 73d79a10..a8118c8b 100644 --- a/od-win32/fsdb_win32.cpp +++ b/od-win32/fsdb_win32.cpp @@ -91,9 +91,9 @@ static int read_uaefsdb (const TCHAR *dir, const TCHAR *name, uae_u8 *fsdb) if (fsdb_debug) { TCHAR *an, *nn, *co; write_log (L"->ok\n"); - an = aucp ((char*)fsdb + 5, currprefs.win32_fscodepage); - nn = aucp ((char*)fsdb + 262, currprefs.win32_fscodepage); - co = aucp ((char*)fsdb + 519, currprefs.win32_fscodepage); + an = au_fs ((char*)fsdb + 5); + nn = au_fs ((char*)fsdb + 262); + co = au_fs ((char*)fsdb + 519); write_log (L"v=%02x flags=%08x an='%s' nn='%s' c='%s'\n", fsdb[0], ((uae_u32*)(fsdb+1))[0], an, nn, co); xfree (co); @@ -148,9 +148,9 @@ static int write_uaefsdb (const TCHAR *dir, uae_u8 *fsdb) NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if (fsdb_debug) { TCHAR *an, *nn, *co; - an = aucp ((char*)fsdb + 5, currprefs.win32_fscodepage); - nn = aucp ((char*)fsdb + 262, currprefs.win32_fscodepage); - co = aucp ((char*)fsdb + 519, currprefs.win32_fscodepage); + an = au_fs ((char*)fsdb + 5); + nn = au_fs ((char*)fsdb + 262); + co = au_fs ((char*)fsdb + 519); write_log (L"write_uaefsdb '%s' = %x\n", p, h); write_log (L"v=%02x flags=%08x an='%s' nn='%s' c='%s'\n", fsdb[0], ((uae_u32*)(fsdb+1))[0], an, nn, co); @@ -205,16 +205,16 @@ static void create_uaefsdb (a_inode *aino, uae_u8 *buf, int winmode) char *s; buf[0] = 1; do_put_mem_long ((uae_u32 *)(buf + 1), aino->amigaos_mode); - s = uacp (aino->aname, currprefs.win32_fscodepage); + s = ua_fs (aino->aname, -1); strncpy ((char*)buf + 5, s, 256); buf[5 + 256] = '\0'; xfree (s); nn = nname_begin (aino->nname); - s = uacp (nn, currprefs.win32_fscodepage); + s = ua_fs (nn, -1); strncpy ((char*)buf + 5 + 257, s, 256); buf[5 + 257 + 256] = '\0'; xfree (s); - s = uacp (aino->comment ? aino->comment : L"", currprefs.win32_fscodepage); + s = ua_fs (aino->comment ? aino->comment : L"", -1); strncpy ((char*)buf + 5 + 2 * 257, s, 80); buf[5 + 2 * 257 + 80] = '\0'; xfree (s); @@ -237,14 +237,14 @@ static a_inode *aino_from_buf (a_inode *base, uae_u8 *buf, int *winmode) if (buf2[0]) { aino->aname = my_strdup ((TCHAR*)buf2); } else { - aino->aname = aucp ((char*)buf, currprefs.win32_fscodepage); + aino->aname = au_fs ((char*)buf); } buf += 257; buf2 += 257 * 2; if (buf2[0]) { aino->nname = build_nname (base->nname, (TCHAR*)buf2); } else { - s = aucp ((char*)buf, currprefs.win32_fscodepage); + s = au_fs ((char*)buf); aino->nname = build_nname (base->nname, s); xfree (s); } @@ -292,7 +292,7 @@ static int fsdb_name_invalid_2 (const TCHAR *n) if (a == 'C' && b == 'O' && c == 'N') ll = 3; /* CON */ if (a == 'P' && b == 'R' && c == 'N') ll = 3; /* PRN */ if (a == 'N' && b == 'U' && c == 'L') ll = 3; /* NUL */ - if (a == 'L' && b == 'P' && c == 'T' && (d >= '0' && d <= '9')) ll = 4; /* LPT# */ + if (a == 'L' && b == 'P' && c == 'T' && (d >= '0' && d <= '9')) ll = 4; /* LPT# */ if (a == 'C' && b == 'O' && c == 'M' && (d >= '0' && d <= '9')) ll = 4; /* COM# */ /* AUX.anything, CON.anything etc.. are also illegal names */ if (ll && (l == ll || (l > ll && n[ll] == '.'))) @@ -317,7 +317,7 @@ static int fsdb_name_invalid_2 (const TCHAR *n) s2[0] = 0; ua_fs_copy (s1, MAX_DPATH, n, -1); au_fs_copy (s2, MAX_DPATH, s1); - if (_tcsicmp (s2, n) != 0) + if (_tcscmp (s2, n) != 0) return 1; return 0; /* the filename passed all checks, now it should be ok */ diff --git a/od-win32/unicode.cpp b/od-win32/unicode.cpp index e7d643f7..f61940ed 100644 --- a/od-win32/unicode.cpp +++ b/od-win32/unicode.cpp @@ -317,3 +317,8 @@ void unicode_init (void) } write_log (L"End\n"); } + +int same_aname (const TCHAR *an1, const TCHAR *an2) +{ + return CompareString (LOCALE_INVARIANT, NORM_IGNORECASE, an1, -1, an2, -1) == CSTR_EQUAL; +} -- 2.47.3