Audit seq(1)

Mostly manpage-stuff and style-changes in the code.
This commit is contained in:
FRIGN 2015-03-20 16:04:23 +01:00
parent f3224add37
commit 7e7d15b7a5
3 changed files with 23 additions and 20 deletions

2
README
View File

@ -60,7 +60,7 @@ The following tools are implemented ('*' == finished, '#' == UTF-8 support,
=*| rm yes none (-i) =*| rm yes none (-i)
=*| rmdir yes none =*| rmdir yes none
# sed yes none # sed yes none
= seq non-posix none =*| seq non-posix none
=*| setsid non-posix none =*| setsid non-posix none
=*| sha1sum non-posix none =*| sha1sum non-posix none
=*| sha256sum non-posix none =*| sha256sum non-posix none

33
seq.1
View File

@ -1,4 +1,4 @@
.Dd January 30, 2015 .Dd March 20, 2015
.Dt SEQ 1 .Dt SEQ 1
.Os sbase .Os sbase
.Sh NAME .Sh NAME
@ -8,29 +8,32 @@
.Nm .Nm
.Op Fl w .Op Fl w
.Op Fl f Ar fmt .Op Fl f Ar fmt
.Op Fl s Ar separator .Op Fl s Ar sep
.Op Ar start Op Ar step .Op Ar startnum Op Ar step
.Ar end .Ar endnum
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm .Nm
will print a sequence of numbers from writes a sequence of numbers from
.Ar start .Ar startnum
(default: 1) to (default: 1) to
.Ar end , .Ar endnum
in in
.Ar step .Ar step
intervals (default: 1). intervals (default: 1)
to stdout.
.Sh OPTIONS .Sh OPTIONS
.Bl -tag -width Ds .Bl -tag -width Ds
.It Fl f Ar format .It Fl f Ar fmt
Specifies the format used for output lines, as per Use
.Ar fmt
as the output line format according to
.Xr printf 3 . .Xr printf 3 .
.It Fl s Ar separator .It Fl s Ar sep
Specifies the separator to print between output lines. Print
.Ar sep
between output lines. The default is "\en".
.It Fl w .It Fl w
Tells Print out lines in equal width.
.Nm
to print out lines in equal width.
.El .El
.Sh SEE ALSO .Sh SEE ALSO
.Xr printf 3 .Xr printf 3

8
seq.c
View File

@ -14,7 +14,7 @@ digitsleft(const char *d)
if (*d == '+') if (*d == '+')
d++; d++;
exp = strpbrk(d, "eE"); exp = strpbrk(d, "eE");
shift = exp ? estrtonum(&exp[1], INT_MIN, INT_MAX) : 0; shift = exp ? estrtonum(exp + 1, INT_MIN, INT_MAX) : 0;
return MAX(0, strspn(d, "-0123456789") + shift); return MAX(0, strspn(d, "-0123456789") + shift);
} }
@ -72,8 +72,8 @@ format:
static void static void
usage(void) usage(void)
{ {
eprintf("usage: %s [-f fmt] [-s separator] [-w width] [start" eprintf("usage: %s [-f fmt] [-s sep] [-w] [startnum"
" [step]] end\n", argv0); " [step]] endnum\n", argv0);
} }
int int
@ -142,7 +142,7 @@ main(int argc, char *argv[])
fputs(sep, stdout); fputs(sep, stdout);
printf(fmt, out); printf(fmt, out);
} }
printf("\n"); putchar('\n');
return 0; return 0;
} }