'getmode' renamed to 'getMode'

The name 'getmode' conficts with a function from BSD, defined
in <unistd.h>. Although 'lbaselib.c' cannot include that header,
'onelua.c' can.
This commit is contained in:
Roberto Ierusalimschy
2024-04-08 14:28:26 -03:00
parent 5edacafcfa
commit 0897c0a428

View File

@@ -336,7 +336,7 @@ static int load_aux (lua_State *L, int status, int envidx) {
} }
static const char *getmode (lua_State *L, int idx) { static const char *getMode (lua_State *L, int idx) {
const char *mode = luaL_optstring(L, idx, "bt"); const char *mode = luaL_optstring(L, idx, "bt");
if (strchr(mode, 'B') != NULL) /* Lua code cannot use fixed buffers */ if (strchr(mode, 'B') != NULL) /* Lua code cannot use fixed buffers */
luaL_argerror(L, idx, "invalid mode"); luaL_argerror(L, idx, "invalid mode");
@@ -346,7 +346,7 @@ static const char *getmode (lua_State *L, int idx) {
static int luaB_loadfile (lua_State *L) { static int luaB_loadfile (lua_State *L) {
const char *fname = luaL_optstring(L, 1, NULL); const char *fname = luaL_optstring(L, 1, NULL);
const char *mode = getmode(L, 2); const char *mode = getMode(L, 2);
int env = (!lua_isnone(L, 3) ? 3 : 0); /* 'env' index or 0 if no 'env' */ int env = (!lua_isnone(L, 3) ? 3 : 0); /* 'env' index or 0 if no 'env' */
int status = luaL_loadfilex(L, fname, mode); int status = luaL_loadfilex(L, fname, mode);
return load_aux(L, status, env); return load_aux(L, status, env);
@@ -395,7 +395,7 @@ static int luaB_load (lua_State *L) {
int status; int status;
size_t l; size_t l;
const char *s = lua_tolstring(L, 1, &l); const char *s = lua_tolstring(L, 1, &l);
const char *mode = getmode(L, 3); const char *mode = getMode(L, 3);
int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */ int env = (!lua_isnone(L, 4) ? 4 : 0); /* 'env' index or 0 if no 'env' */
if (s != NULL) { /* loading a string? */ if (s != NULL) { /* loading a string? */
const char *chunkname = luaL_optstring(L, 2, s); const char *chunkname = luaL_optstring(L, 2, s);