CVS commit: src/usr.bin/nl

2020-12-30 Thread Brian Ginsbach
Module Name:src
Committed By:   ginsbach
Date:   Thu Dec 31 04:07:37 UTC 2020

Modified Files:
src/usr.bin/nl: nl.c

Log Message:
PR/55891 supress displaying separator when numbers supressed

Fix based on patch provided by Kobayashi Takashi. This brings nl(1) further
in to POSIX compliance. Verified behavior with classic SysV nl(1) and GNU
nl(1). There could still be edge cases here not specified by POSIX.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/nl/nl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/nl/nl.c
diff -u src/usr.bin/nl/nl.c:1.14 src/usr.bin/nl/nl.c:1.15
--- src/usr.bin/nl/nl.c:1.14	Wed Dec 30 01:42:31 2020
+++ src/usr.bin/nl/nl.c	Thu Dec 31 04:07:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nl.c,v 1.14 2020/12/30 01:42:31 ginsbach Exp $	*/
+/*	$NetBSD: nl.c,v 1.15 2020/12/31 04:07:37 ginsbach Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1999\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: nl.c,v 1.14 2020/12/30 01:42:31 ginsbach Exp $");
+__RCSID("$NetBSD: nl.c,v 1.15 2020/12/31 04:07:37 ginsbach Exp $");
 #endif
 
 #include 
@@ -332,13 +332,13 @@ filter(void)
 		if (donumber) {
 			consumed = snprintf(intbuffer, intbuffersize, format,
 			width, line);
-			(void)printf("%s",
-			intbuffer + max(0, consumed - width));
+			(void)printf("%s%s",
+			intbuffer + max(0, consumed - width), sep);
 			line += incr;
 		} else {
-			(void)printf("%*s", width, "");
+			(void)printf("%*s%*s", width, "", (int)strlen(sep), "");
 		}
-		(void)printf("%s%s", sep, buffer);
+		(void)printf("%s", buffer);
 
 		if (ferror(stdout))
 			err(EXIT_FAILURE, "output error");



CVS commit: src/usr.bin/nl

2020-12-29 Thread Brian Ginsbach
Module Name:src
Committed By:   ginsbach
Date:   Wed Dec 30 01:42:31 UTC 2020

Modified Files:
src/usr.bin/nl: nl.c

Log Message:
nl: fix -d delim parsing for POSIX

POSIX specifies it is possible to specify a one delimiter character.
Fix the logic so that both one and two character delimiters are accepted.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/nl/nl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/nl/nl.c
diff -u src/usr.bin/nl/nl.c:1.13 src/usr.bin/nl/nl.c:1.14
--- src/usr.bin/nl/nl.c:1.13	Tue Dec 22 17:50:55 2020
+++ src/usr.bin/nl/nl.c	Wed Dec 30 01:42:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nl.c,v 1.13 2020/12/22 17:50:55 ginsbach Exp $	*/
+/*	$NetBSD: nl.c,v 1.14 2020/12/30 01:42:31 ginsbach Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1999\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: nl.c,v 1.13 2020/12/22 17:50:55 ginsbach Exp $");
+__RCSID("$NetBSD: nl.c,v 1.14 2020/12/30 01:42:31 ginsbach Exp $");
 #endif
 
 #include 
@@ -157,14 +157,15 @@ main(int argc, char *argv[])
 		case 'd':
 			if (optarg[0] != '\0')
 delim[0] = optarg[0];
-			if (optarg[1] != '\0')
+			if (optarg[1] != '\0') {
 delim[1] = optarg[1];
-			/* at most two delimiter characters */
-			if (optarg[2] != '\0') {
-errx(EXIT_FAILURE,
-"invalid delim argument -- %s",
-optarg);
-/* NOTREACHED */
+/* at most two delimiter characters */
+if (optarg[2] != '\0') {
+	errx(EXIT_FAILURE,
+	"invalid delim argument -- %s",
+	optarg);
+	/* NOTREACHED */
+}
 			}
 			break;
 		case 'f':



CVS commit: src/usr.bin/nl

2020-12-22 Thread Brian Ginsbach
Module Name:src
Committed By:   ginsbach
Date:   Tue Dec 22 17:50:56 UTC 2020

Modified Files:
src/usr.bin/nl: nl.c

Log Message:
nl(1): remove superfluous exit

Remove exit(3) call missed when errors were converted to errx(3).


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/nl/nl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/nl/nl.c
diff -u src/usr.bin/nl/nl.c:1.12 src/usr.bin/nl/nl.c:1.13
--- src/usr.bin/nl/nl.c:1.12	Tue Sep 17 20:00:50 2013
+++ src/usr.bin/nl/nl.c	Tue Dec 22 17:50:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: nl.c,v 1.12 2013/09/17 20:00:50 wiz Exp $	*/
+/*	$NetBSD: nl.c,v 1.13 2020/12/22 17:50:55 ginsbach Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT("@(#) Copyright (c) 1999\
  The NetBSD Foundation, Inc.  All rights reserved.");
-__RCSID("$NetBSD: nl.c,v 1.12 2013/09/17 20:00:50 wiz Exp $");
+__RCSID("$NetBSD: nl.c,v 1.13 2020/12/22 17:50:55 ginsbach Exp $");
 #endif
 
 #include 
@@ -392,7 +392,6 @@ parse_numbering(const char *argstr, int 
 		errx(EXIT_FAILURE,
 		"illegal %s line numbering type -- %s",
 		numbering_properties[section].name, argstr);
-		exit(EXIT_FAILURE);
 	}
 }
 



CVS commit: src/usr.bin/nl

2013-09-24 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Sep 24 22:08:06 UTC 2013

Modified Files:
src/usr.bin/nl: nl.1

Log Message:
Improve description.
From Jérémie Courrèges-Anglas j...@wxcvbn.org.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/nl/nl.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/nl/nl.1
diff -u src/usr.bin/nl/nl.1:1.15 src/usr.bin/nl/nl.1:1.16
--- src/usr.bin/nl/nl.1:1.15	Thu Sep 12 07:26:13 2013
+++ src/usr.bin/nl/nl.1	Tue Sep 24 22:08:06 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: nl.1,v 1.15 2013/09/12 07:26:13 wiz Exp $
+.\	$NetBSD: nl.1,v 1.16 2013/09/24 22:08:06 wiz Exp $
 .\
 .\ Copyright (c) 1999 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -51,12 +51,16 @@
 The
 .Nm
 utility reads lines from the named
-.Ar file
-or the standard input if the
-.Ar file
-argument is omitted,
+.Ar file ,
 applies a configurable line numbering filter operation,
 and writes the result to the standard output.
+If
+.Ar file
+is a single dash
+.Pq Sq \-
+or absent,
+.Nm
+reads from the standard input.
 .Pp
 The
 .Nm



CVS commit: src/usr.bin/nl

2013-09-17 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Sep 17 20:00:50 UTC 2013

Modified Files:
src/usr.bin/nl: nl.c

Log Message:
If file argument is '-', read from stdin.
From Jérémie Courrèges-Anglas j...@wxcvbn.org.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/nl/nl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/nl/nl.c
diff -u src/usr.bin/nl/nl.c:1.11 src/usr.bin/nl/nl.c:1.12
--- src/usr.bin/nl/nl.c:1.11	Tue Aug 16 12:00:46 2011
+++ src/usr.bin/nl/nl.c	Tue Sep 17 20:00:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: nl.c,v 1.11 2011/08/16 12:00:46 christos Exp $	*/
+/*	$NetBSD: nl.c,v 1.12 2013/09/17 20:00:50 wiz Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1999\
  The NetBSD Foundation, Inc.  All rights reserved.);
-__RCSID($NetBSD: nl.c,v 1.11 2011/08/16 12:00:46 christos Exp $);
+__RCSID($NetBSD: nl.c,v 1.12 2013/09/17 20:00:50 wiz Exp $);
 #endif
 
 #include errno.h
@@ -240,7 +240,8 @@ main(int argc, char *argv[])
 	case 0:
 		break;
 	case 1:
-		if (freopen(argv[0], r, stdin) == NULL)
+		if (strcmp(argv[0], -) != 0 
+		freopen(argv[0], r, stdin) == NULL)
 			err(EXIT_FAILURE, Cannot open `%s', argv[0]);
 		break;
 	default:



CVS commit: src/usr.bin/nl

2013-09-12 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Sep 12 07:26:13 UTC 2013

Modified Files:
src/usr.bin/nl: nl.1

Log Message:
Update standards conformance. From jmc@openbsd.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/nl/nl.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/nl/nl.1
diff -u src/usr.bin/nl/nl.1:1.14 src/usr.bin/nl/nl.1:1.15
--- src/usr.bin/nl/nl.1:1.14	Mon Sep  9 09:02:25 2013
+++ src/usr.bin/nl/nl.1	Thu Sep 12 07:26:13 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: nl.1,v 1.14 2013/09/09 09:02:25 wiz Exp $
+.\	$NetBSD: nl.1,v 1.15 2013/09/12 07:26:13 wiz Exp $
 .\
 .\ Copyright (c) 1999 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -200,12 +200,9 @@ is 6.
 .Sh STANDARDS
 The
 .Nm
-utility conforms to
+utility is compliant with the
 .St -xpg4.2
-with the exception of not supporting the intermingling of the
-.Ar file
-operand with the options, which the standard considers an obsolescent feature
-to be removed from a further issue.
+specification.
 .Sh HISTORY
 The
 .Nm



CVS commit: src/usr.bin/nl

2013-09-09 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Sep  9 09:02:26 UTC 2013

Modified Files:
src/usr.bin/nl: nl.1

Log Message:
Improvements from jmc@openbsd.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/nl/nl.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/nl/nl.1
diff -u src/usr.bin/nl/nl.1:1.13 src/usr.bin/nl/nl.1:1.14
--- src/usr.bin/nl/nl.1:1.13	Wed May  1 20:53:59 2013
+++ src/usr.bin/nl/nl.1	Mon Sep  9 09:02:25 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: nl.1,v 1.13 2013/05/01 20:53:59 christos Exp $
+.\	$NetBSD: nl.1,v 1.14 2013/09/09 09:02:25 wiz Exp $
 .\
 .\ Copyright (c) 1999 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -55,8 +55,8 @@ utility reads lines from the named
 or the standard input if the
 .Ar file
 argument is omitted,
-applies a configurable line numbering filter operation and writes the result
-to the standard output.
+applies a configurable line numbering filter operation,
+and writes the result to the standard output.
 .Pp
 The
 .Nm
@@ -70,14 +70,12 @@ body and footer sections.
 .Pp
 The starts of logical page sections are signaled by input lines containing
 nothing but one of the following sequences of delimiter characters:
-.Bd -unfilled -offset indent
-.Bl -column \e:\e:\e:  header 
-.It Em Line	Start of
+.Bl -column \e:\e:\e:  header  -offset indent
+.It Em Line Ta Em Start of
 .It \e:\e:\e:	header
 .It \e:\e:	body
 .It \e:	footer
 .El
-.Ed
 .Pp
 If the input does not contain any logical page section signaling directives,
 the text being read is assumed to consist of a single logical page body.
@@ -155,7 +153,8 @@ Specify the line numbering output format
 Recognized
 .Ar format
 arguments are:
-.Bl -tag -width lnXX -compact
+.Pp
+.Bl -tag -width lnXX -compact -offset indent
 .It ln
 Left justified.
 .It rn
@@ -185,7 +184,7 @@ The default
 value is 1.
 .It Fl w Ar width
 Specify the number of characters to be occupied by the line number;
-in case the
+if the
 .Ar width
 is insufficient to hold the line number, it will be truncated to its
 .Ar width



CVS commit: src/usr.bin/nl

2013-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed May  1 20:54:00 UTC 2013

Modified Files:
src/usr.bin/nl: nl.1

Log Message:
PR/47789: Eitan Adler: small nits


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/nl/nl.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/nl/nl.1
diff -u src/usr.bin/nl/nl.1:1.12 src/usr.bin/nl/nl.1:1.13
--- src/usr.bin/nl/nl.1:1.12	Sun Apr  8 18:00:39 2012
+++ src/usr.bin/nl/nl.1	Wed May  1 16:53:59 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: nl.1,v 1.12 2012/04/08 22:00:39 wiz Exp $
+.\	$NetBSD: nl.1,v 1.13 2013/05/01 20:53:59 christos Exp $
 .\
 .\ Copyright (c) 1999 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -27,7 +27,7 @@
 .\ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\ POSSIBILITY OF SUCH DAMAGE.
 .\
-.Dd February 15, 1999
+.Dd May 1, 2013
 .Dt NL 1
 .Os
 .Sh NAME
@@ -70,7 +70,6 @@ body and footer sections.
 .Pp
 The starts of logical page sections are signaled by input lines containing
 nothing but one of the following sequences of delimiter characters:
-.Pp
 .Bd -unfilled -offset indent
 .Bl -column \e:\e:\e:  header 
 .It Em Line	Start of
@@ -196,9 +195,7 @@ The default
 is 6.
 .El
 .Sh EXIT STATUS
-The
-.Nm
-utility exits 0 on success, and \*[Gt]0 if an error occurs.
+.Ex -std
 .Sh SEE ALSO
 .Xr pr 1
 .Sh STANDARDS



CVS commit: src/usr.bin/nl

2012-01-01 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Jan  2 00:36:41 UTC 2012

Modified Files:
src/usr.bin/nl: nl.1

Log Message:
Remove unnecessary quoting. From Abhinav Upadhyay.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/nl/nl.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/nl/nl.1
diff -u src/usr.bin/nl/nl.1:1.10 src/usr.bin/nl/nl.1:1.11
--- src/usr.bin/nl/nl.1:1.10	Wed Mar 11 13:56:26 2009
+++ src/usr.bin/nl/nl.1	Mon Jan  2 00:36:41 2012
@@ -1,4 +1,4 @@
-.\	$NetBSD: nl.1,v 1.10 2009/03/11 13:56:26 joerg Exp $
+.\	$NetBSD: nl.1,v 1.11 2012/01/02 00:36:41 wiz Exp $
 .\
 .\ Copyright (c) 1999 The NetBSD Foundation, Inc.
 .\ All rights reserved.
@@ -31,7 +31,7 @@
 .Dt NL 1
 .Os
 .Sh NAME
-.Nm \nl
+.Nm nl
 .Nd line numbering filter
 .Sh SYNOPSIS
 .Nm



CVS commit: src/usr.bin/nl

2011-08-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Aug 16 12:00:46 UTC 2011

Modified Files:
src/usr.bin/nl: Makefile nl.c

Log Message:
- document non-literal format string
- use err/errx
- prototypes


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/nl/Makefile
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/nl/nl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/nl/Makefile
diff -u src/usr.bin/nl/Makefile:1.3 src/usr.bin/nl/Makefile:1.4
--- src/usr.bin/nl/Makefile:1.3	Sun Oct  8 13:52:29 2006
+++ src/usr.bin/nl/Makefile	Tue Aug 16 08:00:46 2011
@@ -1,5 +1,7 @@
-#	$NetBSD: Makefile,v 1.3 2006/10/08 17:52:29 peter Exp $
+#	$NetBSD: Makefile,v 1.4 2011/08/16 12:00:46 christos Exp $
 
 PROG=	nl
 
+COPTS.nl.c += -Wno-format-nonliteral
+
 .include bsd.prog.mk

Index: src/usr.bin/nl/nl.c
diff -u src/usr.bin/nl/nl.c:1.10 src/usr.bin/nl/nl.c:1.11
--- src/usr.bin/nl/nl.c:1.10	Sun Apr 12 19:37:12 2009
+++ src/usr.bin/nl/nl.c	Tue Aug 16 08:00:46 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: nl.c,v 1.10 2009/04/12 23:37:12 lukem Exp $	*/
+/*	$NetBSD: nl.c,v 1.11 2011/08/16 12:00:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1999\
  The NetBSD Foundation, Inc.  All rights reserved.);
-__RCSID($NetBSD: nl.c,v 1.10 2009/04/12 23:37:12 lukem Exp $);
+__RCSID($NetBSD: nl.c,v 1.11 2011/08/16 12:00:46 christos Exp $);
 #endif
 
 #include errno.h
@@ -44,6 +44,7 @@
 #include stdlib.h
 #include string.h
 #include unistd.h
+#include err.h
 
 typedef enum {
 	number_all,		/* number all lines */
@@ -83,10 +84,9 @@
 #define INT_STRLEN_MAXIMUM \
 	((sizeof (int) * CHAR_BIT - 1) * 302 / 1000 + 2)
 
-static void	filter __P((void));
-int		main __P((int, char *[]));
-static void	parse_numbering __P((const char *, int));
-static void	usage __P((void));
+static void	filter(void);
+static void	parse_numbering(const char *, int);
+static void	usage(void) __attribute__((__noreturn__));
 
 /*
  * Pointer to dynamically allocated input line buffer, and its size.
@@ -98,6 +98,7 @@
  * Dynamically allocated buffer suitable for string representation of ints.
  */
 static char *intbuffer;
+static size_t intbuffersize;
 
 /*
  * Configurable parameters.
@@ -129,15 +130,12 @@
 
 
 int
-main(argc, argv)
-	int argc;
-	char *argv[];
+main(int argc, char *argv[])
 {
 	int c;
 	long val;
 	unsigned long uval;
 	char *ep;
-	size_t intbuffersize;
 
 	(void)setlocale(LC_ALL, );
 
@@ -163,10 +161,9 @@
 delim[1] = optarg[1];
 			/* at most two delimiter characters */
 			if (optarg[2] != '\0') {
-(void)fprintf(stderr,
-nl: invalid delim argument -- %s\n,
+errx(EXIT_FAILURE,
+invalid delim argument -- %s,
 optarg);
-exit(EXIT_FAILURE);
 /* NOTREACHED */
 			}
 			break;
@@ -180,22 +177,18 @@
 			errno = 0;
 			val = strtol(optarg, ep, 10);
 			if ((ep != NULL  *ep != '\0') ||
-			 ((val == LONG_MIN || val == LONG_MAX)  errno != 0)) {
-(void)fprintf(stderr,
-invalid incr argument -- %s\n, optarg);
-exit(EXIT_FAILURE);
-			}
+			 ((val == LONG_MIN || val == LONG_MAX)  errno != 0))
+errx(EXIT_FAILURE,
+invalid incr argument -- %s, optarg);
 			incr = (int)val;
 			break;
 		case 'l':
 			errno = 0;
 			uval = strtoul(optarg, ep, 10);
 			if ((ep != NULL  *ep != '\0') ||
-			(uval == ULONG_MAX  errno != 0)) {
-(void)fprintf(stderr,
-invalid num argument -- %s\n, optarg);
-exit(EXIT_FAILURE);
-			}
+			(uval == ULONG_MAX  errno != 0))
+errx(EXIT_FAILURE,
+invalid num argument -- %s, optarg);
 			nblank = (unsigned int)uval;
 			break;
 		case 'n':
@@ -205,11 +198,9 @@
 format = FORMAT_RN;
 			} else if (strcmp(optarg, rz) == 0) {
 format = FORMAT_RZ;
-			} else {
-(void)fprintf(stderr,
-nl: illegal format -- %s\n, optarg);
-exit(EXIT_FAILURE);
-			}
+			} else
+errx(EXIT_FAILURE,
+illegal format -- %s, optarg);
 			break;
 		case 's':
 			sep = optarg;
@@ -218,29 +209,23 @@
 			errno = 0;
 			val = strtol(optarg, ep, 10);
 			if ((ep != NULL  *ep != '\0') ||
-			 ((val == LONG_MIN || val == LONG_MAX)  errno != 0)) {
-(void)fprintf(stderr,
-invalid startnum value -- %s\n, optarg);
-exit(EXIT_FAILURE);
-			}
+			 ((val == LONG_MIN || val == LONG_MAX)  errno != 0))
+errx(EXIT_FAILURE,
+invalid startnum value -- %s, optarg);
 			startnum = (int)val;
 			break;
 		case 'w':
 			errno = 0;
 			val = strtol(optarg, ep, 10);
 			if ((ep != NULL  *ep != '\0') ||
-			 ((val == LONG_MIN || val == LONG_MAX)  errno != 0)) {
-(void)fprintf(stderr,
-invalid width value -- %s\n, optarg);
-exit(EXIT_FAILURE);
-			}
+			 ((val == LONG_MIN || val == LONG_MAX)  errno != 0))
+errx(EXIT_FAILURE,
+invalid width value -- %s, optarg);
 			width = (int)val;
-			if 

CVS commit: src/usr.bin/nl

2009-04-12 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sun Apr 12 23:37:12 UTC 2009

Modified Files:
src/usr.bin/nl: nl.c

Log Message:
Fix -Wextra and -Wsign-compare issues


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/nl/nl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/nl/nl.c
diff -u src/usr.bin/nl/nl.c:1.9 src/usr.bin/nl/nl.c:1.10
--- src/usr.bin/nl/nl.c:1.9	Mon Jul 21 14:19:24 2008
+++ src/usr.bin/nl/nl.c	Sun Apr 12 23:37:12 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: nl.c,v 1.9 2008/07/21 14:19:24 lukem Exp $	*/
+/*	$NetBSD: nl.c,v 1.10 2009/04/12 23:37:12 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #ifndef lint
 __COPYRIGHT(@(#) Copyright (c) 1999\
  The NetBSD Foundation, Inc.  All rights reserved.);
-__RCSID($NetBSD: nl.c,v 1.9 2008/07/21 14:19:24 lukem Exp $);
+__RCSID($NetBSD: nl.c,v 1.10 2009/04/12 23:37:12 lukem Exp $);
 #endif
 
 #include errno.h
@@ -69,9 +69,9 @@
 #define NP_LAST		HEADER
 
 static struct numbering_property numbering_properties[NP_LAST + 1] = {
-	{ footer,	number_none	},
-	{ body,	number_nonempty	},
-	{ header,	number_none	}
+	{ footer,	number_none,	{ 0, 0, 0, 0 } },
+	{ body,	number_nonempty, { 0, 0, 0, 0 } },
+	{ header,	number_none,	{ 0, 0, 0, 0 } },
 };
 
 #define max(a, b)	((a)  (b) ? (a) : (b))
@@ -276,7 +276,7 @@
 	}
 
 	/* Allocate a buffer suitable for preformatting line number. */
-	intbuffersize = max(INT_STRLEN_MAXIMUM, width) + 1;	/* NUL */
+	intbuffersize = max((int)INT_STRLEN_MAXIMUM, width) + 1; /* NUL */
 	if ((intbuffer = malloc(intbuffersize)) == NULL) {
 		perror(cannot allocate preformatting buffer);
 		exit(EXIT_FAILURE);