]> git.ipfire.org Git - thirdparty/coreutils.git/commit
cut: refactor -f to byte search and character processing
authorPádraig Brady <P@draigBrady.com>
Mon, 16 Mar 2026 22:23:02 +0000 (22:23 +0000)
committerPádraig Brady <P@draigBrady.com>
Sun, 5 Apr 2026 12:15:56 +0000 (13:15 +0100)
commitb3ef6231bd0a6fe3cfbc55002024e6e37fdb97de
tree3b9a076e9841958a71fc5361c1ab796f83b3394e
parent16b1ff40aef7eeab35d98836f5abe99100e0cfd6
cut: refactor -f to byte search and character processing

Not sure about this at all.
Only worthwhile if can also remove cut_fields_line_delim.

Refactored src/cut.c so the old UTF-8 byte-search path is now the
general byte-search field engine for all safe byte-search cases:
ordinary single-byte delimiters and valid UTF-8 delimiters. The old
cut_fields path did not go away completely; it is now
cut_fields_line_delim and is used only when the field delimiter equals
the record delimiter, because -d $'\n' and -z -d '' have different
semantics from normal line-based field splitting.

As part of that, I also folded the duplicated “start selected field”
logic into a shared helper, and renamed the byte-search helpers to match
their broader use. The current dispatcher in src/cut.c is now:
whitespace parser, then line- delimiter field mode, then byte-search
field mode, then the decoded multibyte parser.
src/cut.c