Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/usr.bin/nl Pull up following revision(s) (requested by gi...
details: https://anonhg.NetBSD.org/src/rev/e1fa9d330831
branches: netbsd-9
changeset: 951984:e1fa9d330831
user: martin <martin%NetBSD.org@localhost>
date: Wed Feb 10 16:54:52 2021 +0000
description:
Pull up following revision(s) (requested by ginsbach in ticket #1202):
usr.bin/nl/nl.c: revision 1.13
usr.bin/nl/nl.c: revision 1.14
usr.bin/nl/nl.c: revision 1.15
nl(1): remove superfluous exit
Remove exit(3) call missed when errors were converted to errx(3).
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.
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.
diffstat:
usr.bin/nl/nl.c | 28 ++++++++++++++--------------
1 files changed, 14 insertions(+), 14 deletions(-)
diffs (67 lines):
diff -r 28b4184718fd -r e1fa9d330831 usr.bin/nl/nl.c
--- a/usr.bin/nl/nl.c Sun Feb 07 17:42:35 2021 +0000
+++ b/usr.bin/nl/nl.c Wed Feb 10 16:54:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nl.c,v 1.12 2013/09/17 20:00:50 wiz Exp $ */
+/* $NetBSD: nl.c,v 1.12.28.1 2021/02/10 16:54:52 martin 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.12.28.1 2021/02/10 16:54:52 martin Exp $");
#endif
#include <errno.h>
@@ -157,14 +157,15 @@
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':
@@ -331,13 +332,13 @@
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");
@@ -392,7 +393,6 @@
errx(EXIT_FAILURE,
"illegal %s line numbering type -- %s",
numbering_properties[section].name, argstr);
- exit(EXIT_FAILURE);
}
}
Home |
Main Index |
Thread Index |
Old Index