Additional small fixes for windows as part of the process API move to lua.

This commit is contained in:
Adam Harrison 2024-10-22 11:38:43 -04:00
parent 56b7d8abef
commit e8a4ed2a21
1 changed files with 3 additions and 3 deletions

View File

@ -397,7 +397,7 @@ static int process_start(lua_State* L) {
lua_newtable(L); lua_newtable(L);
LPWCH system_env = GetEnvironmentStringsW(), envp = system_env; LPWCH system_env = GetEnvironmentStringsW(), envp = system_env;
while (wcslen(envp) > 0) { while (wcslen(envp) > 0) {
const char *env = utfconv_fromwstr(&A, envp), *eq = env ? strchr(env, '=') : NULL; const char *env = utfconv_fromwstr(A, envp), *eq = env ? strchr(env, '=') : NULL;
if (!env) return (FreeEnvironmentStringsW(system_env), luaL_error(L, "%s", UTFCONV_ERROR_INVALID_CONVERSION)); if (!env) return (FreeEnvironmentStringsW(system_env), luaL_error(L, "%s", UTFCONV_ERROR_INVALID_CONVERSION));
if (!eq) return (FreeEnvironmentStringsW(system_env), luaL_error(L, "invalid environment variable")); if (!eq) return (FreeEnvironmentStringsW(system_env), luaL_error(L, "invalid environment variable"));
lua_pushlstring(L, env, eq - env); lua_pushstring(L, eq+1); lua_pushlstring(L, env, eq - env); lua_pushstring(L, eq+1);
@ -408,11 +408,11 @@ static int process_start(lua_State* L) {
FreeEnvironmentStringsW(system_env); FreeEnvironmentStringsW(system_env);
lua_call(L, 1, 1); lua_call(L, 1, 1);
size_t len = 0; const char *env_mb = luaL_checklstring(L, -1, &len); size_t len = 0; const char *env_mb = luaL_checklstring(L, -1, &len);
if (!(env = utfconv_fromlutf8(&A, env_mb, len))) if (!(env = utfconv_fromlutf8(A, env_mb, len)))
return luaL_error(L, "%s", UTFCONV_ERROR_INVALID_CONVERSION); return luaL_error(L, "%s", UTFCONV_ERROR_INVALID_CONVERSION);
} }
if (lua_getfield(L, 2, "cwd"), luaL_optstring(L, -1, NULL)) { if (lua_getfield(L, 2, "cwd"), luaL_optstring(L, -1, NULL)) {
if ( !(cwd = utfconv_fromutf8(&A, lua_tostring(L, -1))) ) if ( !(cwd = utfconv_fromutf8(A, lua_tostring(L, -1))) )
return luaL_error(L, UTFCONV_ERROR_INVALID_CONVERSION); return luaL_error(L, UTFCONV_ERROR_INVALID_CONVERSION);
} }
lua_pop(L, 2); lua_pop(L, 2);