Hojun-Cho
714d089e31
lib+test: add shlex (POSIX split/quote) + strings.freeall
Surface mirrors ref/hare/shlex/{split,escape}.ha:
shlex.syntaxerr !void
shlex.strerror(syntaxerr) str
shlex.split(str) ([]str | syntaxerr)
shlex.quote(*io.stream, s) (i32 | io.closed)
shlex.quotestr(s) str
strings.freeall([]str) added as the natural disposer (placed next
to strings.dup, the natural creator). Skips empty {nil,0} elements
and the header free when cap==0.
POSIX rules:
- whitespace separators ' '/'\t'/'\n' (collapse runs).
- single-quote: literal until closing "'" (no escapes inside).
- double-quote: '\<c>' processed inside, any <c> (Hare-faithful;
more permissive than POSIX strict). Unterminated → syntaxerr.
- outside quotes: '\<c>' → literal <c>; '\<newline>' deleted
(line continuation); trailing bare '\' → syntaxerr.
- "" / '' preserve a literal empty-string token (dirty flag).
Divergences from Hare (all documented in shlex.ww header):
- drop nomem (os.alloc aborts on OOM, same precedent as
strings.dup, getopt.appendoption).
- byte-wise cursor instead of strings::iterator (no UTF-8 rune
iteration in the language stack yet; same precedent as fnmatch).
- *io.stream (not io::handle); (i32 | io.closed) (lib/io's
stream vtable doesn't model wider io::error yet).
- appendstr / dupstr workarounds graduate when task #17
(cgen mod-mangles fn labels) lands.
Test: 4 @test fns (test_split / test_quote / test_quotestr /
test_strerror), table-driven via check1/check2/check3/checkerr/
checkquote helpers. 12 split rows + 4 quote rows ported verbatim
from ref/hare/shlex/+test.ha; empty-input ([]) and empty-quote
('') edges added per documented behaviour. @test fns prefixed
test_* to avoid the use-shlex flat-concat namespace collision
on bare split / quote / quotestr / strerror names.
2026-05-15 15:48:13 +09:00
..
2026-05-13 04:03:55 +09:00
2026-05-15 14:16:53 +09:00
2026-05-13 08:05:01 +09:00
2026-05-11 02:17:47 +09:00
2026-05-13 14:58:36 +09:00
2026-05-13 04:03:55 +09:00
2026-05-13 20:19:03 +09:00
2026-05-15 11:34:47 +09:00
2026-05-15 15:11:59 +09:00
2026-05-13 19:21:43 +09:00
2026-05-13 14:58:36 +09:00
2026-05-13 20:19:03 +09:00
2026-05-15 14:16:53 +09:00
2026-05-13 14:58:36 +09:00
2026-05-13 16:07:18 +09:00
2026-05-12 00:45:18 +09:00
2026-05-13 17:18:59 +09:00
2026-05-13 04:03:55 +09:00
2026-05-15 15:48:13 +09:00
2026-05-11 02:17:47 +09:00
2026-05-13 08:05:01 +09:00
2026-05-15 15:48:13 +09:00
2026-05-13 17:18:59 +09:00
2026-05-11 02:17:47 +09:00
2026-05-12 00:45:18 +09:00
2026-05-15 11:24:33 +09:00
2026-05-15 11:34:47 +09:00