diff options
| author | christos <christos@NetBSD.org> | 2018-12-17 20:10:51 +0000 |
|---|---|---|
| committer | christos <christos@NetBSD.org> | 2018-12-17 20:10:51 +0000 |
| commit | 4ccdf2cb0221d654f3e4704ab83f34dfdb6545ed (patch) | |
| tree | 602d7f79b8a8c85743a1a004a42939c5f13c9d76 /usr.bin/seq | |
| parent | 7c0190ebc89e5b8a870916f7569ae2f5b5c505de (diff) | |
- Default terminator to \n
- Don't print a trailing separator
Behavior now matches GNU seq (from Aram at tech-userlevel)
Diffstat (limited to 'usr.bin/seq')
| -rw-r--r-- | usr.bin/seq/seq.1 | 7 | ||||
| -rw-r--r-- | usr.bin/seq/seq.c | 14 |
2 files changed, 11 insertions, 10 deletions
diff --git a/usr.bin/seq/seq.1 b/usr.bin/seq/seq.1 index 6eac9d9bda2..bd960c139f4 100644 --- a/usr.bin/seq/seq.1 +++ b/usr.bin/seq/seq.1 @@ -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. diff --git a/usr.bin/seq/seq.c b/usr.bin/seq/seq.c index 2cbf20c577a..6ee77ebeba0 100644 --- a/usr.bin/seq/seq.c +++ b/usr.bin/seq/seq.c @@ -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) |
