Skip to content

read: byte-domain unit accounting across the read serves - #3302

Merged
caomengxuan666 merged 3 commits into
masterfrom
fix/read-wave-3191
Nov 10, 2026
Merged

caomengxuan666 merged 3 commits into
masterfrom
fix/read-wave-3191

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Summary

One wave over the read family's serve paths, four faces:

  • read -r -a in a single-byte locale dropped empty fields when the IFS delimiter was a multibyte character: the array splitter sliced the original line by byte ranges that can fall inside a character. The -r -a producer now works at value level in the byte domain (the existing read_byte_domain family), keeping empty fields; the scalar, non--r array, and ordinary word-splitting paths are untouched.
  • fd_table multibyte serves matched a -d delimiter as a whole UTF-8 sequence; GNU compares the delimiter's first byte at character starts (read.def:385, read.def:834). The three fd_table readers now share one incremental scan replay: read_mbchar units with the delimiter compared as its first stream byte at unit starts in multibyte locales, the historical sequence match in byte locales, post-escape unit counting at unit completion.
  • The byte-domain serve of function stdin returned before the -t timed judge, so a slow producer's second read returned data instead of timing out, and its mirror rewrite silently desynchronized the arrival schedule for later reads. The serve is now judged like the character scan's records (a timeout serves only the in-time prefix), and a rewrite re-bases the schedule into the rewritten mirror's coordinates.
  • read -n/-N unit accounting counted each byte of an invalid UTF-8 sequence separately on the text serves, byte-stopped at the lead byte on the file serve, and truncated even valid characters there. All serves now count one read_mbchar unit per consumption — nominal width first, continuation validation deferred to completion, the invalidating byte joining the unit unless it is the delimiter byte.

Refs #3191
Refs #3291
Refs #3293
Refs #3294

What this PR deletes

  • fd_table's ReadEscapeTracker and utf8_first_byte_len helpers: the fd-table readers' ad-hoc escape tracker and whole-sequence delimiter stepping are replaced by the shared FdRecordScan replay. The escape tracker itself survives in read_io.rs, where the coproc loop still drives it.
  • The byte serve's exemption from the timed judge (the old "record is complete by construction" early return).

Tests

Four new pin stems, one per face, each with fail-first evidence on the base and all cells green on this head; the joined-delimiter stem of the previous wave stays 14/14, 26 read-family neighbour stems stay green, lib tallies match the base (1233 passed / 0 failed / 4 ignored), and the warnings-denied check, fmt check, marker lint, UTF-8 boundary hygiene, and test-target check all pass. No new libc FFI call sites.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant