Document the fact that fold is POSIX.2 compliant.

Update usage string.
This commit is contained in:
jtc 1993-08-28 04:30:00 +00:00
parent a5102d01b8
commit b1c840c324
2 changed files with 19 additions and 10 deletions

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)fold.1 6.5 (Berkeley) 5/6/91
.\" $Id: fold.1,v 1.3 1993/08/01 07:32:45 mycroft Exp $
.\" $Id: fold.1,v 1.4 1993/08/28 04:30:00 jtc Exp $
.\"
.Dd May 6, 1991
.Dt FOLD 1
@ -40,6 +40,7 @@
.Nd "fold long lines for finite width output device"
.Sh SYNOPSIS
.Nm fold
.Op Fl bs
.Op Fl w Ar width
.Ar
.Sh DESCRIPTION
@ -61,8 +62,17 @@ column positions (or bytes).
.It Fl w
Specifies a line width to use instead of the default 80 characters.
.El
.Pp
The
.Nm fold
utility exits 0 on success, and >0 if an error occurs.
.Sh SEE ALSO
.Xr expand 1
.Sh STANDARDS
The
.Nm fold
utility conforms to
.St -p1003.2-92 .
.Sh BUGS
If underlining is present it may be messed up by folding.
.Pp

View File

@ -42,13 +42,13 @@ char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)fold.c 5.5 (Berkeley) 6/1/90";*/
static char rcsid[] = "$Id: fold.c,v 1.3 1993/08/01 18:15:50 mycroft Exp $";
static char rcsid[] = "$Id: fold.c,v 1.4 1993/08/28 04:30:02 jtc Exp $";
#endif /* not lint */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <err.h>
#define DEFLINEWIDTH 80
@ -67,7 +67,7 @@ main(argc, argv)
char *p;
width = -1;
while ((ch = getopt(argc, argv, "0123456789bsw:")) != EOF)
while ((ch = getopt(argc, argv, "0123456789bsw:")) != -1)
switch (ch) {
case 'b':
count_bytes = 1;
@ -94,7 +94,7 @@ main(argc, argv)
break;
default:
(void)fprintf(stderr,
"usage: fold [-w width] [file ...]\n");
"usage: fold [-bs] [-w width] [file ...]\n");
exit(1);
}
argv += optind;
@ -107,9 +107,8 @@ main(argc, argv)
fold(width);
else for (; *argv; ++argv)
if (!freopen(*argv, "r", stdin)) {
(void)fprintf(stderr,
"fold: %s: %s\n", *argv, strerror(errno));
exit(1);
err (1, "%s", *argv);
/* NOTREACHED */
} else
fold(width);
exit(0);
@ -179,8 +178,8 @@ fold(width)
/* Allocate buffer in LINE_MAX increments */
buf_max += 2048;
if((buf = realloc (buf, buf_max)) == NULL) {
(void)fprintf(stderr, "%s\n", strerror(errno));
exit(1);
err (1, NULL);
/* NOTREACHED */
}
}
buf[indx++] = ch;