Fixed various issues with compiling with VS2012
This commit is contained in:
parent
74b2f4680e
commit
8ac4955b22
@ -56,9 +56,10 @@ void buffer_puts(Buffer* b, const void* ptr, size_t len)
|
||||
void buffer_printf(Buffer* b, const char *fmt, ...)
|
||||
{
|
||||
char text[2048];
|
||||
int len;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int len = vsnprintf(text, sizeof(text) - 1, fmt, args);
|
||||
len = vsnprintf(text, sizeof(text) - 1, fmt, args);
|
||||
va_end(args);
|
||||
buffer_puts(b, text, len);
|
||||
}
|
||||
|
@ -11,8 +11,6 @@ int do_chdir(lua_State* L, const char* path)
|
||||
{
|
||||
int z;
|
||||
|
||||
(void)(L); /* warning: unused parameter */
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
wchar_t wide_buffer[PATH_MAX];
|
||||
if (MultiByteToWideChar(CP_UTF8, 0, path, -1, wide_buffer, PATH_MAX) == 0)
|
||||
@ -23,6 +21,8 @@ int do_chdir(lua_State* L, const char* path)
|
||||
|
||||
z = SetCurrentDirectoryW(wide_buffer);
|
||||
#else
|
||||
(void)(L); /* warning: unused parameter */
|
||||
|
||||
z = !chdir(path);
|
||||
#endif
|
||||
|
||||
|
@ -82,10 +82,10 @@ int getKernelVersion(struct OsVersionInfo* info)
|
||||
|
||||
int getversion(struct OsVersionInfo* info)
|
||||
{
|
||||
HKEY key;
|
||||
info->description = "Windows";
|
||||
|
||||
// First get a friendly product name from the registry.
|
||||
HKEY key;
|
||||
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_READ, &key) == ERROR_SUCCESS)
|
||||
{
|
||||
char value[512];
|
||||
|
@ -18,10 +18,9 @@ int os_isfile(lua_State* L)
|
||||
|
||||
int do_isfile(lua_State* L, const char* filename)
|
||||
{
|
||||
(void)(L); /* warning: unused parameter */
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
wchar_t wide_path[PATH_MAX];
|
||||
DWORD attrib;
|
||||
|
||||
if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, wide_path, PATH_MAX) == 0)
|
||||
{
|
||||
@ -29,13 +28,16 @@ int do_isfile(lua_State* L, const char* filename)
|
||||
return lua_error(L);
|
||||
}
|
||||
|
||||
DWORD attrib = GetFileAttributesW(wide_path);
|
||||
attrib = GetFileAttributesW(wide_path);
|
||||
if (attrib != INVALID_FILE_ATTRIBUTES)
|
||||
{
|
||||
return (attrib & FILE_ATTRIBUTE_DIRECTORY) == 0;
|
||||
}
|
||||
#else
|
||||
struct stat buf;
|
||||
|
||||
(void)(L); /* warning: unused parameter */
|
||||
|
||||
if (stat(filename, &buf) == 0)
|
||||
{
|
||||
return ((buf.st_mode & S_IFDIR) == 0);
|
||||
|
@ -15,13 +15,14 @@ int os_islink(lua_State* L)
|
||||
#if PLATFORM_WINDOWS
|
||||
{
|
||||
wchar_t wide_path[PATH_MAX];
|
||||
DWORD attr;
|
||||
if (MultiByteToWideChar(CP_UTF8, 0, path, -1, wide_path, PATH_MAX) == 0)
|
||||
{
|
||||
lua_pushstring(L, "unable to encode path");
|
||||
return lua_error(L);
|
||||
}
|
||||
|
||||
DWORD attr = GetFileAttributesW(wide_path);
|
||||
attr = GetFileAttributesW(wide_path);
|
||||
if (attr != INVALID_FILE_ATTRIBUTES) {
|
||||
lua_pushboolean(L, (attr & FILE_ATTRIBUTE_REPARSE_POINT) != 0);
|
||||
return 1;
|
||||
|
@ -21,6 +21,7 @@ typedef struct struct_MatchInfo
|
||||
int os_matchstart(lua_State* L)
|
||||
{
|
||||
const char* mask = luaL_checkstring(L, 1);
|
||||
MatchInfo* m;
|
||||
|
||||
wchar_t wide_mask[PATH_MAX];
|
||||
if (MultiByteToWideChar(CP_UTF8, 0, mask, -1, wide_mask, PATH_MAX) == 0)
|
||||
@ -29,7 +30,7 @@ int os_matchstart(lua_State* L)
|
||||
return lua_error(L);
|
||||
}
|
||||
|
||||
MatchInfo* m = (MatchInfo*)malloc(sizeof(MatchInfo));
|
||||
m = (MatchInfo*)malloc(sizeof(MatchInfo));
|
||||
|
||||
m->handle = FindFirstFileW(wide_mask, &m->entry);
|
||||
m->is_first = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user