From 263324f188d2df20e66f817f6743a16eafbc2135 Mon Sep 17 00:00:00 2001 From: lukem Date: Sat, 18 Oct 1997 13:21:28 +0000 Subject: [PATCH] WARNSify, fix .Nm usage, getopt returns -1 not EOF, deprecate register --- usr.bin/cut/cut.1 | 14 +++++++------- usr.bin/cut/cut.c | 27 +++++++++++++++------------ 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/usr.bin/cut/cut.1 b/usr.bin/cut/cut.1 index 4ea43e4300d7..766ec7c1f4a9 100644 --- a/usr.bin/cut/cut.1 +++ b/usr.bin/cut/cut.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: cut.1,v 1.6 1995/10/02 20:19:26 jtc Exp $ +.\" $NetBSD: cut.1,v 1.7 1997/10/18 13:21:28 lukem Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -43,21 +43,21 @@ .Nm cut .Nd select portions of each line of a file .Sh SYNOPSIS -.Nm cut +.Nm .Fl b Ar list .Op Fl n .Op Ar -.Nm cut +.Nm "' .Fl c Ar list .Op Ar -.Nm cut +.Nm "" .Fl f Ar list .Op Fl d Ar delim .Op Fl s .Op Ar .Sh DESCRIPTION The -.Nm cut +.Nm utility selects portions of each line (as specified by .Ar list ) from each @@ -111,12 +111,12 @@ Suppresses lines with no field delimiter characters. Unless specified, lines with no delimiters are passed through unmodified. .El .Pp -.Nm Cut +.Nm exits 0 on success, 1 if an error occurred. .Sh SEE ALSO .Xr paste 1 .Sh STANDARDS The -.Nm cut +.Nm utility conforms to .St -p1003.2-92 . diff --git a/usr.bin/cut/cut.c b/usr.bin/cut/cut.c index 5455fcbd5363..dc3c0fcf1460 100644 --- a/usr.bin/cut/cut.c +++ b/usr.bin/cut/cut.c @@ -1,4 +1,4 @@ -/* $NetBSD: cut.c,v 1.10 1997/02/11 09:41:45 mrg Exp $ */ +/* $NetBSD: cut.c,v 1.11 1997/10/18 13:21:39 lukem Exp $ */ /* * Copyright (c) 1989, 1993 @@ -36,17 +36,17 @@ * SUCH DAMAGE. */ +#include #ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1989, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; +__COPYRIGHT("@(#) Copyright (c) 1989, 1993\n\ + The Regents of the University of California. All rights reserved.\n"); #endif /* not lint */ #ifndef lint #if 0 static char sccsid[] = "@(#)cut.c 8.3 (Berkeley) 5/4/95"; #endif -static char rcsid[] = "$NetBSD: cut.c,v 1.10 1997/02/11 09:41:45 mrg Exp $"; +__RCSID("$NetBSD: cut.c,v 1.11 1997/10/18 13:21:39 lukem Exp $"); #endif /* not lint */ #include @@ -68,6 +68,7 @@ int sflag; void c_cut __P((FILE *, char *)); void f_cut __P((FILE *, char *)); void get_list __P((char *)); +int main __P((int, char **)); void usage __P((void)); int @@ -79,6 +80,7 @@ main(argc, argv) void (*fcn) __P((FILE *, char *)); int ch; + fcn = NULL; setlocale (LC_ALL, ""); dchar = '\t'; /* default delimiter is \t */ @@ -140,8 +142,8 @@ void get_list(list) char *list; { - register int setautostart, start, stop; - register char *pos; + int setautostart, start, stop; + char *pos; char *p; /* @@ -152,7 +154,7 @@ get_list(list) * overlapping lists. We also handle "-3-5" although there's no * real reason too. */ - for (; p = strtok(list, ", \t"); list = NULL) { + for (; (p = strtok(list, ", \t")) != NULL; list = NULL) { setautostart = start = stop = 0; if (*p == '-') { ++p; @@ -199,9 +201,10 @@ c_cut(fp, fname) FILE *fp; char *fname; { - register int ch, col; - register char *pos; + int ch, col; + char *pos; + ch = 0; for (;;) { pos = positions + 1; for (col = maxval; col; --col) { @@ -227,8 +230,8 @@ f_cut(fp, fname) FILE *fp; char *fname; { - register int ch, field, isdelim; - register char *pos, *p, sep; + int ch, field, isdelim; + char *pos, *p, sep; int output; char lbuf[_POSIX2_LINE_MAX + 1];