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.
This commit is contained in:
parent
64e104d6f9
commit
05e6749c39
@ -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.
|
* Copyright (c) 1999 The NetBSD Foundation, Inc.
|
||||||
@ -33,7 +33,7 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
__COPYRIGHT("@(#) Copyright (c) 1999\
|
__COPYRIGHT("@(#) Copyright (c) 1999\
|
||||||
The NetBSD Foundation, Inc. All rights reserved.");
|
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
|
#endif
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -157,7 +157,7 @@ main(int argc, char *argv[])
|
|||||||
case 'd':
|
case 'd':
|
||||||
if (optarg[0] != '\0')
|
if (optarg[0] != '\0')
|
||||||
delim[0] = optarg[0];
|
delim[0] = optarg[0];
|
||||||
if (optarg[1] != '\0')
|
if (optarg[1] != '\0') {
|
||||||
delim[1] = optarg[1];
|
delim[1] = optarg[1];
|
||||||
/* at most two delimiter characters */
|
/* at most two delimiter characters */
|
||||||
if (optarg[2] != '\0') {
|
if (optarg[2] != '\0') {
|
||||||
@ -166,6 +166,7 @@ main(int argc, char *argv[])
|
|||||||
optarg);
|
optarg);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
parse_numbering(optarg, FOOTER);
|
parse_numbering(optarg, FOOTER);
|
||||||
|
Loading…
Reference in New Issue
Block a user