Finish up wc(1)

Use size_t for all counts, fix the manpage and refactor the code.
Here's yet another place where GNU coreutils fail:

sbase:
$ echo "GNU/Turd sucks" | wc -cm
    15

coreutils:
$ echo "GNU/Turd sucks" | wc -cm
     15      15

Take a bloody guess which behaviour is correct[0].

[0]: http://pubs.opengroup.org/onlinepubs/009604499/utilities/wc.html
This commit is contained in:
FRIGN
2015-02-01 03:01:11 +01:00
parent d75cc2e556
commit 8ab096d2a4
3 changed files with 66 additions and 68 deletions

35
wc.1
View File

@@ -1,4 +1,4 @@
.Dd January 30, 2015
.Dd February 1, 2015
.Dt WC 1
.Os sbase
.Sh NAME
@@ -6,26 +6,27 @@
.Nd word count
.Sh SYNOPSIS
.Nm
.Op Fl clmw
.Op Fl c | Fl m
.Op Fl lw
.Op Ar file ...
.Sh DESCRIPTION
.Nm
prints the number of lines, words, and bytes in each file. If any flags are
given,
prints the number of lines, words and bytes in each
.Ar file ,
unless set differently with flags.
If no
.Ar file
is given
.Nm
will print only the requested information. If no
.Ar files
are given,
.Nm
reads stdin.
reads from stdin.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl c
print the number of bytes.
.It Fl l
print the number of lines.
.It Fl m
print the number of characters, not bytes.
.It Fl w
print the number of words.
.It Fl c | Fl l | Fl m | Fl w
Print the number of bytes | lines | characters | words.
.El
.Sh STANDARDS
The
.Nm
utility is compliant with the
.St -p1003.1-2008
specification.