Skip to content

pr: implement it - #247

Open
metif12 wants to merge 2 commits into
vlang:mainfrom
metif12:pr-implementation
Open

metif12 wants to merge 2 commits into
vlang:mainfrom
metif12:pr-implementation

Conversation

@metif12

@metif12 metif12 commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

pr paginates and columnates files for printing, with -t, -n, -d, -N, -o, -l, -w, -h, -s, -f, -F, the long -- spellings and multiple file operands.

Line handling and operand parsing live in common/pr; src/pr is a thin main.

The page header is deliberately not emitted. It carries the current date and time, so any test against the default output would be non-deterministic, and there is no way to assert on it that survives a day. The deterministic work underneath it — the line handling — is what this implements and tests.

Ten cases were compared byte-for-byte against GNU 9.4 through WSL: bare passthrough, -n, -n with -d, -o indentation both with and without numbering, -N first line number, the -l and -w error messages, the missing-file diagnostic, and -d alone. Zero diffs.

-d took two attempts, and the reason is worth recording: a blank line follows every line including the last one, not just the ones in between. My first version appended one blank at the end of the file, which passed a casual read and failed the comparison.

Named gaps rather than faked: the multi-column layouts (-2, -3, -a, -m) and page breaks are not implemented. The inter-column padding was not decoded — pr -t -2 -n emits 1\ta\t\t\t \t3 c, where the gap is not a simple multiple of the column width, and guessing would have produced a layout that looks plausible and is wrong.

Paginate and columnate files for printing, with -t, -n, -d, -N, -o, -l, -w, -h, -s, -f, -F, the long -- spellings and multiple file operands. Line handling and operand parsing live in common/pr; src/pr is a thin main. The page header is deliberately not emitted: it carries the current date, so any test against the default output would be non-deterministic, and the deterministic work is the line handling underneath it. Ten cases were compared byte-for-byte against GNU 9.4 through WSL: bare passthrough, -n, -n with -d, -o indentation both with and without numbering, -N first line number, the -l and -w error messages, the missing-file diagnostic, and -d alone. -d was the one that took two attempts, because a blank line follows every line including the last one and not just the ones in between. Named gaps rather than faked: the multi-column layouts (-2, -3, -a, -m) and page breaks are not implemented, since the inter-column padding was not decoded; and --block-size operands take plain decimal only.
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