Audit cols(1)

1) Refactor manpage.
2) De-globalize local values.
3) update usage().
4) sort local variable declarations.
5) fix wrong argument in strtonum (3 -> 1).
6) argc-argv style, boolean style.
7) check bytes > 0 before accessing b.lines[i][bytes - 1]
   relying on len only makes sense but let's not push it.
7) don't break on maxlen > (chars - 1) / 2. This didn't even
   make sense.
8) _correctly_ calculate cols and rows in a readable way.
9) Rewrite loop over rows and cols in a readable way and
   using putchar in a loop instead of printf-magic or fputs
   where not necessary.
This commit is contained in:
FRIGN
2015-03-08 19:33:46 +01:00
parent 78187474cf
commit f140403fca
3 changed files with 43 additions and 52 deletions

19
cols.1
View File

@@ -1,4 +1,4 @@
.Dd February 19, 2015
.Dd March 8, 2015
.Dt COLS 1
.Os sbase
.Sh NAME
@@ -15,7 +15,8 @@ reads each
in sequence and writes them to stdout, in as many vertical
columns as will fit in
.Ar num
character columns. If no
character columns.
If no
.Ar file
is given,
.Nm
@@ -27,17 +28,15 @@ tries to figure out the width of the output
device. If that fails, it defaults to 65 chars.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl c Ar chars
Set the maximum number of character columns to use
(unless the input contains lines longer than
.Ar num
characters).
.It Fl c Ar num
Set maximum number of character columns to
.Ar num ,
unless input lines exceed this limit.
.El
.Sh ENVIRONMENT
.Bl -tag -width COLUMNS
.Bl -tag -width Ds
.It COLUMNS
If this variable is set, the value is used as the
width of the output device.
The width of the output device.
.El
.Sh HISTORY
.Nm