diff --git a/binmodules/luasocket/src/mime.c b/binmodules/luasocket/src/mime.c index 84c3e75c60..112c9f95cc 100644 --- a/binmodules/luasocket/src/mime.c +++ b/binmodules/luasocket/src/mime.c @@ -689,6 +689,7 @@ static size_t dot(int c, size_t state, luaL_Buffer *buffer) case '.': if (state == 2) luaL_addchar(buffer, '.'); + /* Falls through. */ default: return 0; } diff --git a/contrib/lua/src/lundump.c b/contrib/lua/src/lundump.c index 7a67d75aaa..a7228aa57f 100644 --- a/contrib/lua/src/lundump.c +++ b/contrib/lua/src/lundump.c @@ -234,7 +234,7 @@ static void fchecksize (LoadState *S, size_t size, const char *tname) { #define checksize(S,t) fchecksize(S,sizeof(t),#t) static void checkHeader (LoadState *S) { - checkliteral(S, LUA_SIGNATURE + 1, "not a"); /* 1st char already checked */ + checkliteral(S, &LUA_SIGNATURE[1], "not a"); /* 1st char already checked */ if (LoadByte(S) != LUAC_VERSION) error(S, "version mismatch in"); if (LoadByte(S) != LUAC_FORMAT) diff --git a/src/host/curl_utils.c b/src/host/curl_utils.c index d1309e8391..3f6b16c910 100644 --- a/src/host/curl_utils.c +++ b/src/host/curl_utils.c @@ -36,10 +36,10 @@ int curlProgressCallback(curl_state* state, double dltotal, double dlnow, double } -size_t curlWriteCallback(char *ptr, size_t size, size_t nmemb, curl_state* state) +size_t curlWriteCallback(char *ptr, size_t size, size_t nmemb, void* state) { size_t length = size * nmemb; - premake_buffer_puts(&state->S, ptr, length); + premake_buffer_puts(&((curl_state*)state)->S, ptr, length); return length; } diff --git a/src/host/curl_utils.h b/src/host/curl_utils.h index 46c14b0c93..bb87041240 100644 --- a/src/host/curl_utils.h +++ b/src/host/curl_utils.h @@ -30,7 +30,7 @@ int curlProgressCallback(curl_state* state, curl_off_t dltotal, curl_off_t dlnow #else int curlProgressCallback(curl_state* state, double dltotal, double dlnow, double ultotal, double ulnow); #endif -size_t curlWriteCallback(char *ptr, size_t size, size_t nmemb, curl_state* state); +size_t curlWriteCallback(char *ptr, size_t size, size_t nmemb, void* state); CURL* curlRequest(lua_State* L, curl_state* state, int optionsIndex, int progressFnIndex, int headersIndex); void curlCleanup(CURL* curl, curl_state* state); diff --git a/src/host/os_getpass.c b/src/host/os_getpass.c index c515b56454..23dc7dba44 100644 --- a/src/host/os_getpass.c +++ b/src/host/os_getpass.c @@ -32,6 +32,7 @@ int os_getpass(lua_State* L) lua_pushstring(L, buffer); return 1; #elif PLATFORM_COSMO + (void)prompt; luaL_error(L, "Not supported by this platform"); return 0; #elif PLATFORM_POSIX diff --git a/src/host/path_join.c b/src/host/path_join.c index f43234183d..a363fa4e30 100644 --- a/src/host/path_join.c +++ b/src/host/path_join.c @@ -138,7 +138,7 @@ int path_deferred_join(lua_State* L) } -int do_path_has_deferred_join(const char* path) +static int do_path_has_deferred_join(const char* path) { return (strchr(path, DEFERRED_JOIN_DELIMITER) != NULL); } diff --git a/src/host/premake.c b/src/host/premake.c index 4804f8e2df..91369fe131 100644 --- a/src/host/premake.c +++ b/src/host/premake.c @@ -404,6 +404,8 @@ int premake_locate_executable(lua_State* L, const char* argv0) } #endif + (void)buffer; + /* As a fallback, search the PATH with argv[0] */ if (!path) { @@ -451,9 +453,9 @@ int premake_locate_executable(lua_State* L, const char* argv0) * specified file. If found, returns the discovered path to the script on * the top of the Lua stack. */ -int premake_test_file(lua_State* L, const char* filename, int searchMask) +int premake_locate_file(lua_State* L, const char* filename, int searchMask) { - if (searchMask & TEST_LOCAL) { + if (searchMask & SEARCH_LOCAL) { if (do_isfile(L, filename)) { lua_pushcfunction(L, path_getabsolute); lua_pushstring(L, filename); @@ -462,17 +464,17 @@ int premake_test_file(lua_State* L, const char* filename, int searchMask) } } - if (scripts_path && (searchMask & TEST_SCRIPTS)) { + if (scripts_path && (searchMask & SEARCH_SCRIPTS)) { if (do_locate(L, filename, scripts_path)) return OKAY; } - if (searchMask & TEST_PATH) { + if (searchMask & SEARCH_PATH) { const char* path = getenv("PREMAKE_PATH"); if (path && do_locate(L, filename, path)) return OKAY; } #if !defined(PREMAKE_NO_BUILTIN_SCRIPTS) - if ((searchMask & TEST_EMBEDDED) != 0) { + if ((searchMask & SEARCH_EMBEDDED) != 0) { /* Try to locate a record matching the filename */ if (premake_find_embedded_script(filename) != NULL) { lua_pushstring(L, "$/"); @@ -614,18 +616,18 @@ static int run_premake_main(lua_State* L, const char* script) * argument allowed as an override. Debug builds will look at the * local file system first, then fall back to embedded. */ #if defined(NDEBUG) - int z = premake_test_file(L, script, - TEST_SCRIPTS | TEST_EMBEDDED); + int z = premake_locate_file(L, script, + SEARCH_SCRIPTS | SEARCH_EMBEDDED); #else - int z = premake_test_file(L, script, - TEST_LOCAL | TEST_SCRIPTS | TEST_PATH | TEST_EMBEDDED); + int z = premake_locate_file(L, script, + SEARCH_LOCAL | SEARCH_SCRIPTS | SEARCH_PATH | SEARCH_EMBEDDED); #endif /* If no embedded script can be found, release builds will then * try to fall back to the local file system, just in case */ #if defined(NDEBUG) if (z != OKAY) { - z = premake_test_file(L, script, TEST_LOCAL | TEST_PATH); + z = premake_locate_file(L, script, SEARCH_LOCAL | SEARCH_PATH); } #endif diff --git a/src/host/premake.h b/src/host/premake.h index 995378626c..b25c269140 100644 --- a/src/host/premake.h +++ b/src/host/premake.h @@ -9,14 +9,13 @@ #include "lauxlib.h" #include "lualib.h" +#include #include #define PREMAKE_VERSION "5.0.0-dev" #define PREMAKE_COPYRIGHT "Copyright (C) 2002-2021 Jess Perkins and the Premake Project" #define PREMAKE_PROJECT_URL "https://github.com/premake/premake-core/wiki" -/* Identify the current platform I'm not sure how to reliably detect - * Windows but since it is the most common I use it as the default */ #if defined(__linux__) #define PLATFORM_LINUX (1) #define PLATFORM_OS "linux" @@ -41,9 +40,11 @@ #elif defined (__COSMOPOLITAN__) #define PLATFORM_COSMO (1) #define PLATFORM_OS "cosmopolitan" -#else +#elif defined(_WIN32) || defined(_WIN64) #define PLATFORM_WINDOWS (1) #define PLATFORM_OS "windows" +#else +#error Unknown platform detected #endif #define PLATFORM_POSIX (PLATFORM_LINUX || PLATFORM_BSD || PLATFORM_MACOSX || PLATFORM_SOLARIS || PLATFORM_HAIKU || PLATFORM_COSMO) @@ -68,7 +69,6 @@ #else #include #endif -#include /* not all platforms define this */ #ifndef FALSE @@ -83,22 +83,21 @@ #define PATH_MAX (4096) #endif - /* A success return code */ #define OKAY (0) - /* Bitmasks for the different script file search locations */ -#define TEST_LOCAL (0x01) -#define TEST_SCRIPTS (0x02) -#define TEST_PATH (0x04) -#define TEST_EMBEDDED (0x08) - +enum FileSearchMask +{ + SEARCH_LOCAL = 0x01, + SEARCH_SCRIPTS = 0x02, + SEARCH_PATH = 0x04, + SEARCH_EMBEDDED = 0x08 +}; /* If a /scripts argument is present, its value */ extern const char* scripts_path; - /* Bootstrapping helper functions */ int do_chdir(lua_State* L, const char* path); uint32_t do_hash(const char* str, int seed); @@ -189,12 +188,6 @@ int http_download(lua_State* L); int zip_extract(lua_State* L); #endif -#ifdef _MSC_VER - #ifndef snprintf - #define snprintf _snprintf - #endif -#endif - /* Engine interface */ typedef struct @@ -210,9 +203,10 @@ extern void registerModules(lua_State* L); int premake_init(lua_State* L); int premake_pcall(lua_State* L, int nargs, int nresults); int premake_execute(lua_State* L, int argc, const char** argv, const char* script); + int premake_load_embedded_script(lua_State* L, const char* filename); const buildin_mapping* premake_find_embedded_script(const char* filename); int premake_locate_executable(lua_State* L, const char* argv0); -int premake_test_file(lua_State* L, const char* filename, int searchMask); +int premake_locate_file(lua_State* L, const char* filename, int searchMask); void premake_handle_lua_error(lua_State* L);