- Default terminator to \n

- Don't print a trailing separator
Behavior now matches GNU seq (from Aram at tech-userlevel)
This commit is contained in:
christos 2018-12-17 20:10:51 +00:00
parent f8773a049d
commit 07ed41e72f
2 changed files with 11 additions and 10 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: seq.1,v 1.9 2016/08/18 22:55:28 sevan Exp $
.\" $NetBSD: seq.1,v 1.10 2018/12/17 20:10:51 christos Exp $
.\"
.\" Copyright (c) 2005 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -28,7 +28,7 @@
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.\"
.Dd August 18, 2016
.Dd December 17, 2018
.Dt SEQ 1
.Os
.Sh NAME
@ -117,8 +117,7 @@ The
can contain character escape sequences in backslash notation as
defined in
.St -ansiC .
This option is useful when the default separator
does not contain a
The default is
.Cm \en .
.It Fl w
Equalize the widths of all numbers by padding with zeros as necessary.

View File

@ -31,7 +31,7 @@
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 2005\
The NetBSD Foundation, Inc. All rights reserved.");
__RCSID("$NetBSD: seq.c,v 1.10 2017/10/29 01:28:46 ginsbach Exp $");
__RCSID("$NetBSD: seq.c,v 1.11 2018/12/17 20:10:51 christos Exp $");
#endif /* not lint */
#include <ctype.h>
@ -85,7 +85,7 @@ main(int argc, char *argv[])
struct lconv *locale;
char *fmt = NULL;
const char *sep = "\n";
const char *term = NULL;
const char *term = "\n";
char pad = ZERO;
/* Determine the locale's decimal point. */
@ -171,14 +171,16 @@ main(int argc, char *argv[])
fmt = generate_format(first, incr, last, equalize, pad);
if (incr > 0) {
for (; first <= last; first += incr) {
printf(fmt, first);
printf(fmt, first);
for (first += incr; first <= last; first += incr) {
fputs(sep, stdout);
printf(fmt, first);
}
} else {
for (; first >= last; first += incr) {
printf(fmt, first);
printf(fmt, first);
for (first += incr; first >= last; first += incr) {
fputs(sep, stdout);
printf(fmt, first);
}
}
if (term != NULL)