No description
Find a file
Stephen Dennis f244d3a776 fix(functions): wordpos() indexes by grapheme cluster, not byte offset
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>
2026-07-20 11:38:47 -06:00
client fix(console): clip input line and cursor to console width in redraw_input() (#895) 2026-07-12 20:40:29 -06:00
color Color: Add CIELAB nearest-neighbor tool and YUV comparison 2026-03-16 11:20:08 -06:00
debian Retire ISSUES.md trackers; migrate open items to GitHub issues 2026-06-04 20:14:00 -05:00
docker Retire ISSUES.md trackers; migrate open items to GitHub issues 2026-06-04 20:14:00 -05:00
docs fix(functions): wordpos() indexes by grapheme cluster, not byte offset 2026-07-20 11:38:47 -06:00
hooks Make pre-commit hook bash 3.2 compatible 2026-04-25 19:51:41 -06:00
mux fix(functions): wordpos() indexes by grapheme cluster, not byte offset 2026-07-20 11:38:47 -06:00
parser Retire ISSUES.md trackers; migrate open items to GitHub issues 2026-06-04 20:14:00 -05:00
ragel Unify Ragel color_ops build with production source 2026-03-18 06:32:39 -06:00
sgp Remove hardtabs. 2012-05-18 13:29:49 -07:00
specs Add clean target to specs Makefile. 2010-06-02 20:34:17 -07:00
testcases fix(functions): wordpos() indexes by grapheme cluster, not byte offset 2026-07-20 11:38:47 -06:00
tests netaddr: canonicalize IPv4-mapped IPv6 in compare_to(MUX_SOCKADDR*) (#800) 2026-06-10 19:27:36 -06:00
tools/worldbuilder Retire ISSUES.md trackers; migrate open items to GitHub issues 2026-06-04 20:14:00 -05:00
unix build: finish the telnet_protocol_handler removal (#793 follow-up) 2026-06-12 02:29:22 -05:00
utf Regenerate UTF-8 DFA tables; fix table-gen toolchain on macOS 2026-06-04 12:32:08 -05:00
win32 build: finish the telnet_protocol_handler removal (#793 follow-up) 2026-06-12 02:29:22 -05:00
.gitattributes Add .gitattributes to enforce LF endings for shell scripts and TOC files. 2026-03-04 08:05:14 -07:00
.gitignore chore: gitignore SQLite runtime files in game/data 2026-07-20 08:38:54 -06:00
AGENTS.md docs: correct AGENTS.md build to the 2.14 workflow 2026-07-12 16:27:54 -06:00
CLAUDE.md Add generated-file safeguards: pre-commit hook, read-only Ragel output, docs 2026-04-03 18:18:19 -06:00
CONTRIBUTING.md docs: add CONTRIBUTING.md — contribution workflow and standards 2026-07-12 16:26:54 -06:00
dounix.sh harden: deliver binary blobs out-of-band in the Unix distribution 2026-07-14 17:40:08 -06:00
dowin32.sh Prepare 2.14.0.9 ALPHA release 2026-07-14 13:43:24 -06:00
GEMINI.md Add AGENTS.md, GEMINI.md and clean up .gitignore 2026-03-08 20:33:27 -06:00
LICENSE Add top-level LICENSE file (Artistic-1.0 + revised TinyMUD notice) 2026-06-30 07:26:10 -08:00
Makefile Wire iOS Titan tests into top-level make test on Darwin 2026-04-25 21:53:09 -06:00