* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
* This code is derived from software contributed to Berkeley by
* %sccs.include.redist.c%
static char copyright
[] =
"@(#) Copyright (c) 1990, 1993\n\
The Regents of the University of California. All rights reserved.\n";
static char sccsid
[] = "@(#)fold.c 8.1 (Berkeley) %G%";
extern int errno
, optind
;
while ((ch
= getopt(argc
, argv
, "0123456789w:")) != EOF
)
if ((width
= atoi(optarg
)) <= 0) {
"fold: illegal width value.\n");
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
if (p
[0] == '-' && p
[1] == ch
&& !p
[2])
width
= atoi(argv
[optind
] + 1);
"usage: fold [-w width] [file ...]\n");
else for (; *argv
; ++argv
)
if (!freopen(*argv
, "r", stdin
)) {
"fold: %s: %s\n", *argv
, strerror(errno
));
register int ch
, col
, new;
switch (ch
= getchar()) {