proh14 / canoutils

coreutils but cano! public domain 💖
The Unlicense
17 stars 9 forks source link

Implemented cksum #40

Closed cospplredman closed 2 months ago

cospplredman commented 2 months ago

cksum is one of the posix utilities of all time.

Sigmanificient commented 2 months ago

The core logic is a bit cryptic (mostly bit manipulation) so I couldn't tell what happening there Hopefully you can provide some screenshot to show that this is working properly

proh14 commented 2 months ago

hello @cospplredman. thanks for your pr. please test this before we merge it. Also, be sure to provide. if you tasted all the edge cases, mention me so I can merge it. ;)

cospplredman commented 2 months ago

My testing methodology is as follows: run both my implementation and the gnu implementation on every file in the cksum directory.

$ ./cksum *
175369053 16296 cksum
1855786587 7 cksum.1
4088649404 2179 cksum.c
1192622583 51 Makefile
197436690 157 test.sh
$ cksum *
175369053 16296 cksum
1855786587 7 cksum.1
4088649404 2179 cksum.c
1192622583 51 Makefile
197436690 157 test.sh

the results match as far as i can tell.

One notable difference between this implementation and the gnu implementation is that I do not handle directories, I opt to instead just return EXIT_FAILURE. The reason I prefer to fail is that there isn't a standard C way of checking if something is a directory, so any method of doing so would break me from my (very tasteful) c99 compliance, and cksum is only defined on files anyways.

proh14 commented 2 months ago

do you handle flags?

proh14 commented 2 months ago

also pull the latest changes