Skip to content

Stdlib: strtok() — VM + JIT + AOT (#3201) - #3333

Merged
PurHur merged 2 commits into
masterfrom
agent/stdlib-strtok
May 29, 2026
Merged

Stdlib: strtok() — VM + JIT + AOT (#3201)#3333
PurHur merged 2 commits into
masterfrom
agent/stdlib-strtok

Conversation

@PurHur

@PurHur PurHur commented May 29, 2026

Copy link
Copy Markdown
Owner

Summary

  • Implements strtok() with php-src ext/standard/string.c semantics (two-arg init + one-arg continuation).
  • VM: VmString::strtok() with per-request static state; registered in ext/standard/Module.php.
  • Native path: lib/AOT/runtime/phpc_strtok.c (phpc_strtok) linked for JIT/AOT via StringStrtok + JitStrtok.
  • Tests: test/compliance/cases/stdlib/strtok.phpt, strtok_jit.phpt, test/fixtures/aot/cases/strtok.phpt.

php-src reference

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "
\$s=\"a,b,c\"; echo strtok(\$s,\",\"); echo strtok(\",\"); echo strtok(\",\"); echo strtok(\",\")===false?\"end\":\"bad\";
"'
# => abcend

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && ./vendor/bin/phpunit --filter "VMTest.*strtok|AotTest.*strtok"'
# VM + AOT green

php bin/compile.php -l test/fixtures/aot/cases/strtok.phpt  # AOT lint (with script/php-env.sh in Docker)
php script/capability-matrix.php  # row: strtok | yes | yes | yes

Closes #3201

Made with Cursor

PurHur and others added 2 commits May 29, 2026 20:05
Implement strtok() with php-src ext/standard/string.c semantics: per-request
static continuation state in VmString, phpc_strtok.c for native lowering, and
compliance/AOT probes (abcend repro).

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@PurHur
PurHur merged commit 15f0b8c into master May 29, 2026
@PurHur
PurHur deleted the agent/stdlib-strtok branch June 22, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stdlib: strtok() — tokenize strings (ext/standard/string.c parity)

1 participant