Skip to content

Commit

Permalink
Fix broken Unicode overrides
Browse files Browse the repository at this point in the history
  • Loading branch information
gocha committed Jun 12, 2019
1 parent df3a9ea commit c7578b4
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 131 deletions.
18 changes: 0 additions & 18 deletions lua-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
59 changes: 1 addition & 58 deletions win32/_tfwopen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
55 changes: 0 additions & 55 deletions win32/_tfwopen.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@
#ifdef UNICODE

#include <stdio.h>
#include <stdlib.h>
#include <io.h>
#include <string.h>
#include <direct.h>
#include <tchar.h>

#ifdef __cplusplus
extern "C" {
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

0 comments on commit c7578b4

Please sign in to comment.