diff options
author | bapt <bapt@FreeBSD.org> | 2015-05-10 11:41:38 +0000 |
---|---|---|
committer | bapt <bapt@FreeBSD.org> | 2015-05-10 11:41:38 +0000 |
commit | 8bdd3598387027b0475b5c4db7872fae37f418b8 (patch) | |
tree | 9b1226d08a6e0a525c79bf70236a4bbbe4192c50 | |
parent | 0659e9b5d281463a01e9802cee2cb2da4dafe403 (diff) | |
download | FreeBSD-src-8bdd3598387027b0475b5c4db7872fae37f418b8.zip FreeBSD-src-8bdd3598387027b0475b5c4db7872fae37f418b8.tar.gz |
For half and reverse line feeds, recognize both SUSv2-style escape-digit
and BSD-style escape-control-char sequences in the input stream.
Submitted by: schwarze at OpenBSD
Discussed with: schwarze at OpenBSD
Obtained from: OpenBSD
-rw-r--r-- | usr.bin/col/col.1 | 29 | ||||
-rw-r--r-- | usr.bin/col/col.c | 11 |
2 files changed, 33 insertions, 7 deletions
diff --git a/usr.bin/col/col.1 b/usr.bin/col/col.1 index 9419fe3..fc02ca4 100644 --- a/usr.bin/col/col.1 +++ b/usr.bin/col/col.1 @@ -31,7 +31,7 @@ .\" @(#)col.1 8.1 (Berkeley) 6/29/93 .\" $FreeBSD$ .\" -.Dd August 4, 2004 +.Dd May 10, 2015 .Dt COL 1 .Os .Sh NAME @@ -82,18 +82,33 @@ recognized and interpreted by itself, which are listed below. Output multiple spaces instead of tabs. .El .Pp -The control sequences for carriage motion that +In the input stream, .Nm -understands and their decimal values are listed in the following -table: +understands both the escape sequences of the form escape-digit +mandated by +.St -susv2 +and the traditional +.Bx +format escape-control-character. +The control sequences for carriage motion and their ASCII values +are as follows: .Pp .Bl -tag -width "carriage return" -compact +.It ESC\-BELL +reverse line feed (escape then bell). .It ESC\-7 -reverse line feed (escape then 7) +reverse line feed (escape then 7). +.It ESC\-BACKSPACE +half reverse line feed (escape then backspace). .It ESC\-8 -half reverse line feed (escape then 8) +half reverse line feed (escape then 8). +.It ESC\-TAB +half forward line feed (escape than tab). .It ESC\-9 -half forward line feed (escape then 9) +half forward line feed (escape then 9). +In +.Fl f +mode, this sequence may also occur in the output stream. .It backspace moves back one column (8); ignored in the first column .It carriage return diff --git a/usr.bin/col/col.c b/usr.bin/col/col.c index c620bcb..13df126 100644 --- a/usr.bin/col/col.c +++ b/usr.bin/col/col.c @@ -205,12 +205,23 @@ main(int argc, char **argv) continue; case ESC: /* just ignore EOF */ switch(getwchar()) { + /* + * In the input stream, accept both the + * XPG5 sequences ESC-digit and the + * traditional BSD sequences ESC-ctrl. + */ + case '\007': + /* FALLTHROUGH */ case RLF: addto_lineno(&cur_line, -2); break; + case '\010': + /* FALLTHROUGH */ case RHLF: addto_lineno(&cur_line, -1); break; + case '\011': + /* FALLTHROUGH */ case FHLF: addto_lineno(&cur_line, 1); if (cur_line > max_line) |