From 60e40675c82efd17aa6bf31bc66c3f8f3f918360 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 28 Sep 2026 10:26:47 -0300 Subject: Addresses search a line at a time as sam does, say why they fail, and a failed addr leaves no address addr's regexps ran mvzr over text[from..hi]: ^ and $ anchored only at the slice's ends, . matched newlines, the search never wrapped, and every failure read as bad address syntax. The regexps stay mvzr's, called the way sam searches (editors/acme/regx.c): one line per haystack, so ^ and $ fall at line boundaries and . never crosses a newline; a pattern naming \\n runs over the whole text with its . made [^\\n]; /re/ wraps unless limit is set, and ?re? takes the last match before the range. The ceiling (mvzr's first alternative, not sam's longest) is documented. A failed address says why (no match for regexp, address out of range, bad regular expression), and a failed write to addr leaves no address, so data and xdata refuse until the next good one instead of writing at the old range. Co-Authored-By: Claude Opus 5.5 --- test/fs.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'test') diff --git a/test/fs.py b/test/fs.py index ca1ca70e..a6d24e0b 100644 --- a/test/fs.py +++ b/test/fs.py @@ -344,6 +344,18 @@ def discovery(binary, embedded=False): client.write(f'/pane/{scratch}/addr', b'#0,#5') client.write(f'/pane/{scratch}/data', b'HOWDY', truncate=True) assert client.read(f'/pane/{scratch}/body') == b'HOWDY world\nsecond line\n' + # sam's regexps: ^ at any line; a miss says so and leaves no + # address, so the data write after it refuses. + client.write(f'/pane/{scratch}/addr', b'/^second/') + assert client.read(f'/pane/{scratch}/addr') == b' 12 18 ' + for path, data, why in ((f'/pane/{scratch}/addr', b'/nowhere/', 'no match for regexp'), + (f'/pane/{scratch}/data', b'LOST', 'no address')): + try: + client.write(path, data) + raise AssertionError(f'{path} took {data!r}') + except OSError as refused: + assert why in str(refused), refused + assert client.read(f'/pane/{scratch}/body') == b'HOWDY world\nsecond line\n' client.remove(f'/pane/{scratch}') print('9P discovery: listing/stat/find are inert; new, remove, look, exec, name, sel, log, ctl lock, focus, the ctl split and commands behave') -- cgit v1.3