wc in 44 lines of C
Go to file
2023-09-09 00:02:31 +02:00
makefile add usage, start looking into gnu utils 2023-09-09 00:02:31 +02:00
README.md add usage, start looking into gnu utils 2023-09-09 00:02:31 +02:00
wc add usage, start looking into gnu utils 2023-09-09 00:02:31 +02:00
wc.c add usage, start looking into gnu utils 2023-09-09 00:02:31 +02:00

Desiderata

  • Simple: Simple operation in terms of counting spaces and \n.
  • Avoid "off by one" errors; make sure an empty file is reported as such.
    • Words as space or enter, followed by nonspace, followed by space? Make sure two spaces aren't two words?
  • Keep Linux only.
  • No flags. Only count words, not lines.
  • Allow piping, as well as reading files.
    • Wonder how normal utilities handle this.
  • Could use zig? => Not for now

Steps:

  • Look into how C utilities both read from stdin and from files.
  • Program first version of the utility
  • Compare with other implementations, see how they do it, after I've read my own version
    • Compare with gnu utils,
    • Compare with musl/busybox implementations,
    • Maybe make some pull requests, if I'm doing something better?
  • Install to ww, but check that ww is empty (installing to wc2 or smth would mean that you don't save that many keypresses vs wc -w)
  • ...