factory.c: remove #include <windows.h>
This commit is contained in:
parent
857ae29be8
commit
7caddaee89
@ -62,9 +62,6 @@ char * Bound_script[10];
|
|||||||
#include <limits.h> //for INT_MIN
|
#include <limits.h> //for INT_MIN
|
||||||
#include <string.h> // strncpy()
|
#include <string.h> // strncpy()
|
||||||
#include <stdlib.h> // for atof()
|
#include <stdlib.h> // for atof()
|
||||||
#if defined(WIN32)
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#define strdup _strdup
|
#define strdup _strdup
|
||||||
#define putenv _putenv
|
#define putenv _putenv
|
||||||
@ -2002,30 +1999,16 @@ int L_GetFileName(lua_State* L)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// convert Filename_unicode to UTF8 (Lua strings are 8bits)
|
// convert Filename_unicode to UTF8 (Lua strings are 8bits)
|
||||||
size_t unicode_len = Unicode_strlen(Main.backups->Pages->Filename_unicode);
|
size_t len = 0;
|
||||||
int len = WideCharToMultiByte(CP_UTF8, 0, Main.backups->Pages->Filename_unicode, unicode_len, NULL, 0, NULL, NULL);
|
char * utf8name = Unicode_to_utf8(Main.backups->Pages->Filename_unicode, &len);
|
||||||
if (len <= 0)
|
if (utf8name == NULL)
|
||||||
{
|
{
|
||||||
GFX2_Log(GFX2_WARNING, "WideCharToMultiByte() failed\n");
|
|
||||||
lua_pushstring(L, Main.backups->Pages->Filename);
|
lua_pushstring(L, Main.backups->Pages->Filename);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char * utf8name = (char *)GFX2_malloc(len);
|
lua_pushlstring(L, utf8name, len);
|
||||||
if (utf8name == NULL)
|
free(utf8name);
|
||||||
lua_pushstring(L, Main.backups->Pages->Filename);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (WideCharToMultiByte(CP_UTF8, 0, Main.backups->Pages->Filename_unicode, unicode_len, utf8name, len, NULL, NULL) > 0)
|
|
||||||
lua_pushlstring(L, utf8name, len);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DWORD error = GetLastError();
|
|
||||||
GFX2_Log(GFX2_WARNING, "WideCharToMultiByte() failed error=%u\n", error);
|
|
||||||
lua_pushstring(L, Main.backups->Pages->Filename);
|
|
||||||
}
|
|
||||||
free(utf8name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// still using the "short name" directory path at the moment
|
// still using the "short name" directory path at the moment
|
||||||
|
|||||||
43
src/osdep.c
43
src/osdep.c
@ -22,6 +22,11 @@
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
|
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
///@file osdep.c
|
||||||
|
/// OS Dependend code
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#if defined(USE_SDL) || defined(USE_SDL2)
|
#if defined(USE_SDL) || defined(USE_SDL2)
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#elif !defined(WIN32)
|
#elif !defined(WIN32)
|
||||||
@ -59,7 +64,9 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "struct.h"
|
#include "struct.h"
|
||||||
|
#include "unicode.h"
|
||||||
#include "gfx2log.h"
|
#include "gfx2log.h"
|
||||||
|
#include "gfx2mem.h"
|
||||||
|
|
||||||
dword GFX2_GetTicks(void)
|
dword GFX2_GetTicks(void)
|
||||||
{
|
{
|
||||||
@ -253,3 +260,39 @@ unsigned long Memory_free(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
|
/**
|
||||||
|
* Converts an unicode string to UTF8
|
||||||
|
* @param str the unicode string
|
||||||
|
* @param utf8len pointer to receive the utf8 string length (excluding null terminator)
|
||||||
|
* @return malloc'ed UTF8 string
|
||||||
|
*/
|
||||||
|
char * Unicode_to_utf8(const word * str, size_t * utf8len)
|
||||||
|
{
|
||||||
|
size_t unicode_len = Unicode_strlen(str);
|
||||||
|
int len = WideCharToMultiByte(CP_UTF8, 0, str, unicode_len, NULL, 0, NULL, NULL);
|
||||||
|
if (len <= 0)
|
||||||
|
{
|
||||||
|
GFX2_Log(GFX2_WARNING, "WideCharToMultiByte() failed\n");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char * utf8 = (char *)GFX2_malloc(len+1);
|
||||||
|
if (utf8 == NULL)
|
||||||
|
return NULL;
|
||||||
|
if (WideCharToMultiByte(CP_UTF8, 0, str, unicode_len, utf8, len, NULL, NULL) <= 0)
|
||||||
|
{
|
||||||
|
DWORD error = GetLastError();
|
||||||
|
GFX2_Log(GFX2_WARNING, "WideCharToMultiByte() failed error=%u\n", error);
|
||||||
|
free(utf8);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (utf8len != NULL)
|
||||||
|
*utf8len = (size_t)len;
|
||||||
|
utf8[len] = '\0';
|
||||||
|
return utf8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@ -54,4 +54,8 @@ void Atari_Memory_free(unsigned long *stRam, unsigned long *ttRam);
|
|||||||
unsigned long Memory_free(void);
|
unsigned long Memory_free(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WIN32)
|
||||||
|
char * Unicode_to_utf8(const word * str, size_t * utf8len);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user