mirror of
https://github.com/brazilofmux/tinymux
synced 2026-08-13 00:23:11 -04:00
No description
wordpos(str, charpos, sep) documents charpos as a 1-based character
position and its siblings wordstart()/wordend() are grapheme-correct, but
the implementation used charpos as a raw byte offset (cp[charpos-1]) while
bounding it against strip_color()'s code-point count. For any multi-byte
UTF-8 string it returned the wrong word (e.g. wordpos("héllo world", 6)
gave 1 instead of 2 — byte 6 is the 'o', but grapheme 6 is the space).
Bound charpos against the grapheme-cluster count (utf8_cluster_count over
the byte length) and resolve it to a byte pointer by walking clusters
(utf8_next_grapheme), mirroring wordstart()/wordend(). Also passes the
byte length (not the code-point count) to trim_space_sep_LEN(), fixing a
latent length mismatch. Behaviour is identical for pure-ASCII input
(one cluster == one byte == one code point).
Adds testcases/wordpos_fn.mux TC003: accented 'é' (2-byte, proves
byte->character) and a skin-tone wave grapheme cluster (2 code points,
proves cluster- not code-point-indexing), plus a register-fed runtime
case. Expected values derived from this tree's muxscript. Updates the
survey-function-matrix.md entry. Full smoke 1307/1307.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
||
|---|---|---|
| client | ||
| color | ||
| debian | ||
| docker | ||
| docs | ||
| hooks | ||
| mux | ||
| parser | ||
| ragel | ||
| sgp | ||
| specs | ||
| testcases | ||
| tests | ||
| tools/worldbuilder | ||
| unix | ||
| utf | ||
| win32 | ||
| .gitattributes | ||
| .gitignore | ||
| AGENTS.md | ||
| CLAUDE.md | ||
| CONTRIBUTING.md | ||
| dounix.sh | ||
| dowin32.sh | ||
| GEMINI.md | ||
| LICENSE | ||
| Makefile | ||