mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-10-10 01:28:44 +02:00
feat(libc): add independent guest strtok state
This commit is contained in:
@@ -36,6 +36,7 @@ std::size_t APS5_VABI strlcat_nid_postfix(char* destination, const char* source,
|
||||
|
||||
char* APS5_VABI strtok_r_nid_postfix(char* text, const char* delimiters, char** state) {
|
||||
if (text == nullptr) text = *state;
|
||||
if (text == nullptr) return nullptr;
|
||||
text += std::strspn(text, delimiters);
|
||||
if (*text == '\0') {
|
||||
*state = text;
|
||||
@@ -47,4 +48,9 @@ char* APS5_VABI strtok_r_nid_postfix(char* text, const char* delimiters, char**
|
||||
return text;
|
||||
}
|
||||
|
||||
char* APS5_VABI strtok_nid_postfix(char* text, const char* delimiters) {
|
||||
thread_local char* state = nullptr;
|
||||
return strtok_r_nid_postfix(text, delimiters, &state);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ char* APS5_VABI strpbrk_nid_postfix(const char*, const char*);
|
||||
std::size_t APS5_VABI strcspn_nid_postfix(const char*, const char*);
|
||||
std::size_t APS5_VABI strlcat_nid_postfix(char*, const char*, std::size_t);
|
||||
char* APS5_VABI strtok_r_nid_postfix(char*, const char*, char**);
|
||||
char* APS5_VABI strtok_nid_postfix(char*, const char*);
|
||||
char* APS5_VABI strcasestr_nid_postfix(const char*, const char*);
|
||||
}
|
||||
|
||||
@@ -49,6 +50,15 @@ int main() {
|
||||
Require(strtok_r_nid_postfix(nullptr, ",", &firstState) == nullptr);
|
||||
Require(strtok_r_nid_postfix(nullptr, ",", &firstState) == nullptr);
|
||||
Require(std::strcmp(strtok_r_nid_postfix(nullptr, "", &secondState), "y") == 0);
|
||||
char hostTokens[] = "host:next";
|
||||
Require(std::strcmp(std::strtok(hostTokens, ":"), "host") == 0);
|
||||
char guestTokens[] = ",one,,two:three";
|
||||
Require(std::strcmp(strtok_nid_postfix(guestTokens, ","), "one") == 0);
|
||||
Require(std::strcmp(strtok_nid_postfix(nullptr, ":,"), "two") == 0);
|
||||
Require(std::strcmp(strtok_nid_postfix(nullptr, ""), "three") == 0);
|
||||
Require(strtok_nid_postfix(nullptr, ",") == nullptr);
|
||||
Require(strtok_nid_postfix(nullptr, ",") == nullptr);
|
||||
Require(std::strcmp(std::strtok(nullptr, ":"), "next") == 0);
|
||||
const char text[] = "aABAbC";
|
||||
Require(strcasestr_nid_postfix(text, "ababc") == text + 1);
|
||||
Require(strcasestr_nid_postfix(text, "") == text);
|
||||
|
||||
@@ -329,3 +329,10 @@ missing/non-directory failures, unchanged host cwd, short-buffer handling, and
|
||||
getcwd allocation freed through the guest heap. All nineteen suites pass.
|
||||
Latest unchanged-game startup resolves getcwd and stops at `oVkZ8W8-Q8A`
|
||||
(`strtok`). Guest execution and rendered output remain unverified.
|
||||
|
||||
Added strtok using the existing strtok_r scanner with independent thread-local
|
||||
guest state. Tests exercise repeated delimiters, changing delimiter sets, empty
|
||||
delimiter sets, repeated end-of-input calls, and independence from host strtok.
|
||||
All nineteen suites pass after rebuilding the libraries. Latest unchanged-game
|
||||
startup resolves strtok and stops at `88Vv-AzHVj8` (`fmodf`). The game has still
|
||||
not reached its entry point or produced a rendered frame.
|
||||
|
||||
Reference in New Issue
Block a user