Add bh_strtok_r function (#4790)

This commit is contained in:
linear0211 2026-01-20 10:13:22 +09:00 committed by GitHub
parent 23df0d4e55
commit a7fd6539dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 7 deletions

View File

@ -3909,13 +3909,8 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
goto fail;
}
#ifdef BH_PLATFORM_WINDOWS
address = strtok_s(cp, "/", &nextptr);
mask = strtok_s(NULL, "/", &nextptr);
#else
address = strtok_r(cp, "/", &nextptr);
mask = strtok_r(NULL, "/", &nextptr);
#endif
address = bh_strtok_r(cp, "/", &nextptr);
mask = bh_strtok_r(NULL, "/", &nextptr);
if (!mask) {
snprintf(error_buf, error_buf_size,

View File

@ -166,6 +166,16 @@ wa_strdup(const char *s)
return s1;
}
char *
bh_strtok_r(char *str, const char *delim, char **saveptr)
{
#if !(defined(_WIN32) || defined(_WIN32_))
return strtok_r(str, delim, saveptr);
#else
return strtok_s(str, delim, saveptr);
#endif
}
#if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0
int
bh_system(const char *cmd)

View File

@ -66,6 +66,9 @@ bh_strdup(const char *s);
char *
wa_strdup(const char *s);
char *
bh_strtok_r(char *str, const char *delim, char **saveptr);
#if WASM_ENABLE_WAMR_COMPILER != 0 || WASM_ENABLE_JIT != 0
/* Executes a system command in bash/cmd.exe */
int