Add the -p flag to force unknown control sequences to be passed

through unchanged.

Reviewed by:	silence on -audit
Obtained from:	NetBSD
MFC after:	3 weeks
This commit is contained in:
mikeh 2001-06-17 04:24:16 +00:00
parent 007412b870
commit 6dd95f67c9
3 changed files with 18 additions and 7 deletions

View File

@ -1,4 +1,6 @@
# @(#)README 8.1 (Berkeley) 6/6/93 # @(#)README 8.1 (Berkeley) 6/6/93
#
# $FreeBSD$
col - filter out reverse line feeds. col - filter out reverse line feeds.
@ -6,6 +8,7 @@ Options are:
-b do not print any backspaces (last character written is printed) -b do not print any backspaces (last character written is printed)
-f allow half line feeds in output, by default characters between -f allow half line feeds in output, by default characters between
lines are pushed to the line below lines are pushed to the line below
-p force unknown control sequences to be passed through unchanged
-x do not compress spaces into tabs. -x do not compress spaces into tabs.
-l num keep (at least) num lines in memory, 128 are kept by default -l num keep (at least) num lines in memory, 128 are kept by default
@ -20,9 +23,6 @@ page to reflect the way the code worked. Suspecting that this was probably
the wrong way to go, this version adopts the SVID defaults, and no longer the wrong way to go, this version adopts the SVID defaults, and no longer
documents the -h option. documents the -h option.
The S5 -p flag is not supported because it isn't clear what it does (looks
like a kludge introduced for a particular printer).
Known differences between AT&T's col and this one (# is delimiter): Known differences between AT&T's col and this one (# is delimiter):
Input AT&T col this col Input AT&T col this col
#\nabc\E7def\n# # def\nabc\r# # def\nabc\n# #\nabc\E7def\n# # def\nabc\r# # def\nabc\n#

View File

@ -43,7 +43,7 @@
.Nd filter reverse line feeds from input .Nd filter reverse line feeds from input
.Sh SYNOPSIS .Sh SYNOPSIS
.Nm .Nm
.Op Fl bfhx .Op Fl bfhpx
.Op Fl l Ar num .Op Fl l Ar num
.Sh DESCRIPTION .Sh DESCRIPTION
.Nm Col .Nm Col
@ -69,6 +69,12 @@ Normally characters printed on a half line boundary are printed
on the following line. on the following line.
.It Fl h .It Fl h
Don't output multiple spaces instead of tabs (default). Don't output multiple spaces instead of tabs (default).
.It Fl p
Force unknown control sequences to be passed through unchanged.
Normally,
.Nm
will filter out any control sequences from the input other than those
recognized and interpreted by itself, which are listed below.
.It Fl x .It Fl x
Output multiple spaces instead of tabs. Output multiple spaces instead of tabs.
.It Fl l Ar num .It Fl l Ar num

View File

@ -110,6 +110,7 @@ int fine; /* if `fine' resolution (half lines) */
int max_bufd_lines; /* max # lines to keep in memory */ int max_bufd_lines; /* max # lines to keep in memory */
int nblank_lines; /* # blanks after last flushed line */ int nblank_lines; /* # blanks after last flushed line */
int no_backspaces; /* if not to output any backspaces */ int no_backspaces; /* if not to output any backspaces */
int pass_unknown_seqs; /* pass unknown control sequences */
#define PUTC(ch) \ #define PUTC(ch) \
do { \ do { \
@ -138,7 +139,7 @@ main(argc, argv)
max_bufd_lines = 128; max_bufd_lines = 128;
compress_spaces = 1; /* compress spaces into tabs */ compress_spaces = 1; /* compress spaces into tabs */
while ((opt = getopt(argc, argv, "bfhl:x")) != -1) while ((opt = getopt(argc, argv, "bfhl:px")) != -1)
switch (opt) { switch (opt) {
case 'b': /* do not output backspaces */ case 'b': /* do not output backspaces */
no_backspaces = 1; no_backspaces = 1;
@ -153,6 +154,9 @@ main(argc, argv)
if ((max_bufd_lines = atoi(optarg)) <= 0) if ((max_bufd_lines = atoi(optarg)) <= 0)
errx(1, "bad -l argument %s", optarg); errx(1, "bad -l argument %s", optarg);
break; break;
case 'p': /* pass unknown control sequences */
pass_unknown_seqs = 1;
break;
case 'x': /* do not compress spaces into tabs */ case 'x': /* do not compress spaces into tabs */
compress_spaces = 0; compress_spaces = 0;
break; break;
@ -220,7 +224,8 @@ main(argc, argv)
cur_line -= 2; cur_line -= 2;
continue; continue;
} }
continue; if (!pass_unknown_seqs)
continue;
} }
/* Must stuff ch in a line - are we at the right one? */ /* Must stuff ch in a line - are we at the right one? */
@ -530,7 +535,7 @@ void
usage() usage()
{ {
(void)fprintf(stderr, "usage: col [-bfhx] [-l nline]\n"); (void)fprintf(stderr, "usage: col [-bfhpx] [-l nline]\n");
exit(1); exit(1);
} }