From c7578b442519b8893cb23cf681073cd002e1d85e Mon Sep 17 00:00:00 2001 From: gocha Date: Wed, 12 Jun 2019 21:40:55 +0900 Subject: [PATCH] Fix broken Unicode overrides --- lua-engine.cpp | 18 -------------- win32/_tfwopen.cpp | 59 +--------------------------------------------- win32/_tfwopen.h | 55 ------------------------------------------ 3 files changed, 1 insertion(+), 131 deletions(-) diff --git a/lua-engine.cpp b/lua-engine.cpp index 3df668717..aa8466741 100644 --- a/lua-engine.cpp +++ b/lua-engine.cpp @@ -31,24 +31,6 @@ #define fopen fopenA #undef open #define open openA -#undef _access -#define _access _accessA -#undef rename -#define rename renameA -#undef _unlink -#define _unlink _unlinkA -#undef _chdir -#define _chdir _chdirA -#undef _mkdir -#define _mkdir _mkdirA -#undef _rmdir -#define _rmdir _rmdirA -#undef _splitpath -#define _splitpath _splitpathA -#undef _makepath -#define _makepath _makepathA -//#undef strrchr -//#define strrchr strrchrA #endif #endif diff --git a/win32/_tfwopen.cpp b/win32/_tfwopen.cpp index 8ad302e3a..67f559236 100644 --- a/win32/_tfwopen.cpp +++ b/win32/_tfwopen.cpp @@ -45,64 +45,7 @@ extern "C" int _twremove(const char *filename ) { } extern "C" int _twopen(const char *filename, int oflag, int pmode) { - return _wopen(Utf8ToWide(filename), oflag, pmode); -} - -extern "C" int _twaccess(const char *_Filename, int _AccessMode) { - return _waccess(Utf8ToWide(_Filename), _AccessMode); -} - -extern "C" int _twrename(const char *_OldFilename, const char *_NewFilename) { - return _wrename(Utf8ToWide(_OldFilename), Utf8ToWide(_NewFilename)); -} - -extern "C" int _twunlink(const char *_Filename) { - return _wunlink(Utf8ToWide(_Filename)); -} - -extern "C" int _twchdir(const char *_Path) { - return _wchdir(Utf8ToWide(_Path)); -} - -extern "C" int _twmkdir(const char *_Path) { - return _wmkdir(Utf8ToWide(_Path)); -} - -extern "C" int _twrmdir(const char *_Path) { - return _wrmdir(Utf8ToWide(_Path)); -} - -extern "C" void _twsplitpath(const char *_FullPath, char *_Drive, char *_Dir, char *_Filename, char *_Ext) { - wchar_t _wDrive[_MAX_PATH]; - wchar_t _wDir[_MAX_PATH]; - wchar_t _wFilename[_MAX_PATH]; - wchar_t _wExt[_MAX_PATH]; - _wsplitpath(Utf8ToWide(_FullPath), _wDrive, _wDir, _wFilename, _wExt); - strcpy(_Drive, WideToUtf8(_wDrive)); - strcpy(_Dir, WideToUtf8(_wDir)); - strcpy(_Filename, WideToUtf8(_wFilename)); - strcpy(_Ext, WideToUtf8(_wExt)); -} - -extern "C" void _twmakepath(char *_Path, const char *_Drive, const char *_Dir, const char *_Filename, const char *_Ext) { - wchar_t wResultPath[_MAX_PATH]; - wcscpy(wResultPath, L""); - _wmakepath(wResultPath, Utf8ToWide(_Drive), Utf8ToWide(_Dir), Utf8ToWide(_Filename), Utf8ToWide(_Ext)); - strcpy(_Path, WideToUtf8(wResultPath)); -} - -extern "C" char *_twcsrchr(const char *_Str, int _Ch) { - wchar_t *wStr = Utf8ToWide(_Str); - wchar_t *wResult = wcsrchr(wStr, (wchar_t) _Ch); - if (wResult != NULL) - { - wResult[0] = L'\0'; - return (char*) &_Str[strlen(WideToUtf8(wResult))]; - } - else - { - return NULL; - } + return _wopen(Utf8ToWide(filename), oflag, pmode); } extern "C" char *_twfullpath(char* dst, const char* src, int len) { diff --git a/win32/_tfwopen.h b/win32/_tfwopen.h index a5caab517..d2943e74e 100644 --- a/win32/_tfwopen.h +++ b/win32/_tfwopen.h @@ -10,11 +10,6 @@ #ifdef UNICODE #include -#include -#include -#include -#include -#include #ifdef __cplusplus extern "C" { @@ -25,16 +20,6 @@ int _twremove(const char *filename ); int _twopen(const char *filename, int oflag, int pmode); char *_twfullpath(char* dst, const char* src, int len); -int _twaccess(const char *_Filename, int _AccessMode); -int _twrename(const char *_OldFilename, const char *_NewFilename); -int _twunlink(const char *_Filename); -int _twchdir(const char *_Path); -int _twmkdir(const char *_Path); -int _twrmdir(const char *_Path); -void _twsplitpath(const char *_FullPath, char *_Drive, char *_Dir, char *_Filename, char *_Ext); -void _twmakepath(char *_Path, const char *_Drive, const char *_Dir, const char *_Filename, const char *_Ext); -char *_twcsrchr(const char *_Str, int _Ch); - #ifdef __cplusplus } #endif @@ -132,36 +117,6 @@ __forceinline static FILE *fopenA(const char *filename, const char *mode) { __forceinline static int removeA(const char *filename) { return remove(filename); } -__forceinline static int openA(const char *filename, int oflag, int pmode) { - return open(filename, oflag, pmode); -} -__forceinline static int _accessA(const char *path, int mode) { - return _access(path, mode); -} -__forceinline static int renameA(const char *oldname, const char *newname) { - return rename(oldname, newname); -} -__forceinline static int _unlinkA(const char *filename) { - return _unlink(filename); -} -__forceinline static int _chdirA(const char *dirname) { - return _chdir(dirname); -} -__forceinline static int _mkdirA(const char *dirname) { - return _mkdir(dirname); -} -__forceinline static int _rmdirA(const char *dirname) { - return _rmdir(dirname); -} -__forceinline static void _splitpathA(const char *path, char *drive, char *dir, char *fname, char *ext) { - _splitpath(path, drive, dir, fname, ext); -} -__forceinline static void _makepathA(char *path, const char *drive, const char *dir, const char *fname, const char *ext) { - _makepath(path, drive, dir, fname, ext); -} -//__forceinline static char *strrchrA(const char *str, int c) { -// return strrchr(str, c); -//} #define fopen _tfwopen #undef remove @@ -173,16 +128,6 @@ __forceinline static int open(const char *filename, int oflag, int pmode) { return _twopen(filename, oflag, pmode); } -#define _access _twaccess -#define rename _twrename -#define _unlink _twunlink -#define _chdir _twchdir -#define _mkdir _twmkdir -#define _rmdir _twrmdir -#define _splitpath _twsplitpath -#define _makepath _twmakepath -//#define strrchr _twcsrchr - #endif // UNICODE #endif // _TFWOPEN_H