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-15 15:06:37 +09:00
2026-05-11 13:49:27 +09:00
2026-05-11 13:49:27 +09:00
2026-05-12 04:15:31 +09:00
2026-05-12 04:15:31 +09:00
2026-05-11 13:49:27 +09:00
2026-05-11 13:49:27 +09:00
2026-05-12 11:35:50 +09:00
2026-05-12 12:45:11 +09:00
2026-05-11 13:49:27 +09:00
2026-05-11 13:49:27 +09:00
2026-05-12 13:44:27 +09:00
2026-05-12 13:37:31 +09:00
2026-05-13 20:06:24 +09:00
2026-05-14 02:44:57 +09:00
2026-05-14 01:58:52 +09:00
2026-05-14 00:36:34 +09:00
2026-05-13 23:45:35 +09:00
2026-05-14 19:12:20 +09:00
2026-05-14 00:21:53 +09:00
2026-05-14 23:45:14 +09:00
2026-05-14 23:26:49 +09:00
2026-05-15 01:08:52 +09:00
2026-05-15 01:39:37 +09:00
2026-05-15 02:14:00 +09:00
2026-05-15 14:16:53 +09:00
2026-05-15 11:24:33 +09:00
2026-05-15 15:19:38 +09:00
2026-05-15 15:06:37 +09:00
2026-05-15 11:34:47 +09:00
2026-05-11 13:49:27 +09:00
2026-05-12 13:50:09 +09:00
2026-05-15 11:34:47 +09:00
2026-05-12 03:14:20 +09:00
2026-05-12 03:49:09 +09:00
2026-05-15 11:34:47 +09:00
2026-05-15 14:05:55 +09:00
2026-05-15 15:11:59 +09:00
2026-05-15 15:48:13 +09:00
2026-05-15 00:26:10 +09:00
2026-05-15 00:27:38 +09:00
2026-05-15 00:28:59 +09:00
2026-05-15 09:00:34 +09:00
2026-05-15 09:00:34 +09:00
2026-05-15 09:00:34 +09:00
2026-05-15 09:00:34 +09:00
2026-05-15 09:00:34 +09:00
2026-05-15 09:00:34 +09:00
2026-05-15 09:00:34 +09:00
2026-05-13 16:07:18 +09:00
2026-05-11 13:49:27 +09:00
2026-05-11 13:49:27 +09:00
2026-05-11 16:48:58 +09:00
2026-05-12 16:21:13 +09:00
2026-05-11 16:48:58 +09:00
2026-05-11 17:52:29 +09:00
2026-05-12 03:58:55 +09:00
2026-05-14 02:51:49 +09:00
2026-05-15 09:00:34 +09:00