Skip to content

Fix wc -L tab/CJK width and -cm dual output#26

Open
kelp wants to merge 1 commit intomainfrom
fix-wc-integration-tests
Open

Fix wc -L tab/CJK width and -cm dual output#26
kelp wants to merge 1 commit intomainfrom
fix-wc-integration-tests

Conversation

@kelp
Copy link
Copy Markdown
Owner

@kelp kelp commented Mar 31, 2026

Summary

  • Remove -c/-m mutual exclusion: GNU wc shows both char and byte columns when both flags are given. Column order is chars before bytes, matching GNU behavior.
  • Implement tab stop expansion for -L: tabs advance to the next 8-column boundary instead of counting as 1 character.
  • Add CJK display width for -L: wide characters (CJK ideographs, full-width forms) count as display width 2, using the existing common.unicode.codepointWidth function.

Test plan

  • just it-util wc passes all 117 tests (was 95/117, now 117/117)
  • zig build test --summary all passes all unit tests
  • just fmt produces no changes

GNU wc shows both char and byte columns when -c and -m
are given together. The old "last flag wins" logic has
been removed. Column order matches GNU: chars before
bytes.

For -L, tabs now expand to 8-column stops and CJK
characters count as display width 2, matching GNU wc
behavior.
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