feat: gnu wc 9.11-compatible CLI, byte-identical output
Adds -L/--max-line-length (display width, tab stops every 8), the long options --lines/--words/--chars/--bytes/--max-line-length, --files0-from (NUL-delimited name lists), --total=auto|always|only|never, --debug (acceleration diagnostics), and POSIXLY_CORRECT handling. Ports GNU's column width rule (digits of the sum of regular file sizes, floor 7 for non-regular inputs), its multibyte word/line-length semantics (-w/-m/-L decode per character under a multibyte locale), the -c sizing heuristic (page-aligned st_size reads a tail block), and its error texts, quoting and exit codes. Verified byte-identical stdout, exit codes and (normalized) stderr against coreutils wc 9.11: 125-case parity suite and 552-case fuzz across C, C.UTF-8, en_US.UTF-8 and POSIX locales. The benchmark contract holds: words, lines (incl. the 100M monster) and stdin all pass with fastwc never slower than GNU wc.
This commit is contained in:
@@ -60,11 +60,22 @@ stopped being a challenge and started being a participation trophy.
|
|||||||
## What it does
|
## What it does
|
||||||
|
|
||||||
```
|
```
|
||||||
fastwc [-lwc] [-m] [file...]
|
fastwc [OPTION]... [FILE]...
|
||||||
|
fastwc [OPTION]... --files0-from=F
|
||||||
```
|
```
|
||||||
|
|
||||||
- `-l` lines, `-w` words, `-c` bytes, `-m` characters (multibyte)
|
- `-l` lines, `-w` words, `-c` bytes, `-m` characters (multibyte),
|
||||||
|
`-L` maximum line length (display width, tab stops every 8)
|
||||||
|
- `--files0-from=F` NUL-terminated file lists from F (or stdin when F is `-`)
|
||||||
|
- `--total=auto|always|only|never` control over the total row
|
||||||
|
- `--debug` report which line-counting acceleration is in use
|
||||||
- stdin, `-`, multiple files, `total` rows, GNU-compatible counts
|
- stdin, `-`, multiple files, `total` rows, GNU-compatible counts
|
||||||
|
- A CLI surface modeled on GNU coreutils `wc` 9.11: same options, same
|
||||||
|
column alignment rule (counts are right-justified to the widest sum
|
||||||
|
of regular file sizes), same multibyte word semantics, same error
|
||||||
|
text. Swap it in and scripts keep working.
|
||||||
|
- POSIXLY_CORRECT is honored: the no-break space stops being a word
|
||||||
|
separator, exactly like GNU wc.
|
||||||
- no `--help` in fourteen languages. One `--help`, in English, the
|
- no `--help` in fourteen languages. One `--help`, in English, the
|
||||||
language of people who ship software
|
language of people who ship software
|
||||||
|
|
||||||
|
|||||||
+973
-219
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user