merged with 4.4Lite
This commit is contained in:
parent
4c5b39eb10
commit
282052c7a8
@ -1,5 +1,5 @@
|
|||||||
# from: @(#)Makefile 5.2 (Berkeley) 5/11/90
|
# $NetBSD: Makefile,v 1.3 1995/03/26 05:25:51 glass Exp $
|
||||||
# $Id: Makefile,v 1.2 1993/07/31 15:24:50 mycroft Exp $
|
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||||
|
|
||||||
PROG= col
|
PROG= col
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
.\" Copyright (c) 1990 The Regents of the University of California.
|
.\" $NetBSD: col.1,v 1.4 1995/03/26 05:25:52 glass Exp $
|
||||||
.\" All rights reserved.
|
.\"
|
||||||
|
.\" Copyright (c) 1990, 1993
|
||||||
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" This code is derived from software contributed to Berkeley by
|
.\" This code is derived from software contributed to Berkeley by
|
||||||
.\" Michael Rendell.
|
.\" Michael Rendell.
|
||||||
@ -32,10 +34,9 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" from: @(#)col.1 6.8 (Berkeley) 6/17/91
|
.\" @(#)col.1 8.1 (Berkeley) 6/29/93
|
||||||
.\" $Id: col.1,v 1.3 1993/11/30 00:19:51 jtc Exp $
|
|
||||||
.\"
|
.\"
|
||||||
.Dd June 17, 1991
|
.Dd June 29, 1993
|
||||||
.Dt COL 1
|
.Dt COL 1
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -47,7 +48,7 @@
|
|||||||
.Op Fl l Ar num
|
.Op Fl l Ar num
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
.Nm Col
|
.Nm Col
|
||||||
filters out reverse (and half reverse) line feeds so the output is
|
filters out reverse (and half reverse) line feeds so that the output is
|
||||||
in the correct order with only forward and half forward line
|
in the correct order with only forward and half forward line
|
||||||
feeds, and replaces white-space characters with tabs where possible.
|
feeds, and replaces white-space characters with tabs where possible.
|
||||||
This can be useful in processing the output of
|
This can be useful in processing the output of
|
||||||
@ -56,10 +57,10 @@ and
|
|||||||
.Xr tbl 1 .
|
.Xr tbl 1 .
|
||||||
.Pp
|
.Pp
|
||||||
.Nm Col
|
.Nm Col
|
||||||
reads from standard input and writes to standard output.
|
reads from the standard input and writes to the standard output.
|
||||||
.Pp
|
.Pp
|
||||||
The options are as follows:
|
The options are as follows:
|
||||||
.Bl -tag -width "-lnum"
|
.Bl -tag -width "-l num "
|
||||||
.It Fl b
|
.It Fl b
|
||||||
Do not output any backspaces, printing only the last character
|
Do not output any backspaces, printing only the last character
|
||||||
written to each column position.
|
written to each column position.
|
||||||
@ -69,7 +70,7 @@ Normally characters printed on a half line boundary are printed
|
|||||||
on the following line.
|
on the following line.
|
||||||
.It Fl x
|
.It Fl x
|
||||||
Output multiple spaces instead of tabs.
|
Output multiple spaces instead of tabs.
|
||||||
.It Fl l Ns Ar num
|
.It Fl l Ar num
|
||||||
Buffer at least
|
Buffer at least
|
||||||
.Ar num
|
.Ar num
|
||||||
lines in memory.
|
lines in memory.
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
/* $NetBSD: col.c,v 1.6 1995/03/26 05:25:53 glass Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1990 The Regents of the University of California.
|
* Copyright (c) 1990, 1993, 1994
|
||||||
* All rights reserved.
|
* The Regents of the University of California. All rights reserved.
|
||||||
*
|
*
|
||||||
* This code is derived from software contributed to Berkeley by
|
* This code is derived from software contributed to Berkeley by
|
||||||
* Michael Rendell of the Memorial University of Newfoundland.
|
* Michael Rendell of the Memorial University of Newfoundland.
|
||||||
@ -35,18 +37,21 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
char copyright[] =
|
static char copyright[] =
|
||||||
"@(#) Copyright (c) 1990 The Regents of the University of California.\n\
|
"@(#) Copyright (c) 1990, 1993, 1994\n\
|
||||||
All rights reserved.\n";
|
The Regents of the University of California. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
/*static char sccsid[] = "from: @(#)col.c 5.3 (Berkeley) 2/2/91";*/
|
#if 0
|
||||||
static char rcsid[] = "$Id: col.c,v 1.5 1994/12/24 16:24:32 cgd Exp $";
|
static char sccsid[] = "@(#)col.c 8.3 (Berkeley) 4/2/94";
|
||||||
|
#else
|
||||||
|
static char rcsid[] = "$NetBSD: col.c,v 1.6 1995/03/26 05:25:53 glass Exp $";
|
||||||
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <err.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -88,28 +93,34 @@ struct line_str {
|
|||||||
int l_max_col; /* max column in the line */
|
int l_max_col; /* max column in the line */
|
||||||
};
|
};
|
||||||
|
|
||||||
LINE *alloc_line();
|
LINE *alloc_line __P((void));
|
||||||
void *xmalloc();
|
void dowarn __P((int));
|
||||||
|
void flush_line __P((LINE *));
|
||||||
|
void flush_lines __P((int));
|
||||||
|
void flush_blanks __P((void));
|
||||||
|
void free_line __P((LINE *));
|
||||||
|
void usage __P((void));
|
||||||
|
void wrerr __P((void));
|
||||||
|
void *xmalloc __P((void *, size_t));
|
||||||
|
|
||||||
CSET last_set; /* char_set of last char printed */
|
CSET last_set; /* char_set of last char printed */
|
||||||
LINE *lines;
|
LINE *lines;
|
||||||
int compress_spaces; /* if doing space -> tab conversion */
|
int compress_spaces; /* if doing space -> tab conversion */
|
||||||
int fine; /* if `fine' resolution (half lines) */
|
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 */
|
||||||
|
|
||||||
#define PUTC(ch) \
|
#define PUTC(ch) \
|
||||||
if (putchar(ch) == EOF) \
|
if (putchar(ch) == EOF) \
|
||||||
wrerr();
|
wrerr();
|
||||||
|
|
||||||
|
int
|
||||||
main(argc, argv)
|
main(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
{
|
{
|
||||||
extern int optind;
|
int ch;
|
||||||
extern char *optarg;
|
|
||||||
register int ch;
|
|
||||||
CHAR *c;
|
CHAR *c;
|
||||||
CSET cur_set; /* current character set */
|
CSET cur_set; /* current character set */
|
||||||
LINE *l; /* current line */
|
LINE *l; /* current line */
|
||||||
@ -244,7 +255,7 @@ main(argc, argv)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!warned++)
|
if (!warned++)
|
||||||
warn(cur_line);
|
dowarn(cur_line);
|
||||||
cur_line -= nmove;
|
cur_line -= nmove;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -309,6 +320,7 @@ main(argc, argv)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
flush_lines(nflush)
|
flush_lines(nflush)
|
||||||
int nflush;
|
int nflush;
|
||||||
{
|
{
|
||||||
@ -335,6 +347,7 @@ flush_lines(nflush)
|
|||||||
* is the number of half line feeds, otherwise it is the number of whole line
|
* is the number of half line feeds, otherwise it is the number of whole line
|
||||||
* feeds.
|
* feeds.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
flush_blanks()
|
flush_blanks()
|
||||||
{
|
{
|
||||||
int half, i, nb;
|
int half, i, nb;
|
||||||
@ -363,6 +376,7 @@ flush_blanks()
|
|||||||
* Write a line to stdout taking care of space to tab conversion (-h flag)
|
* Write a line to stdout taking care of space to tab conversion (-h flag)
|
||||||
* and character set shifts.
|
* and character set shifts.
|
||||||
*/
|
*/
|
||||||
|
void
|
||||||
flush_line(l)
|
flush_line(l)
|
||||||
LINE *l;
|
LINE *l;
|
||||||
{
|
{
|
||||||
@ -390,7 +404,7 @@ flush_line(l)
|
|||||||
count = (int *)xmalloc((void *)count,
|
count = (int *)xmalloc((void *)count,
|
||||||
(unsigned)sizeof(int) * count_size);
|
(unsigned)sizeof(int) * count_size);
|
||||||
}
|
}
|
||||||
bzero((char *)count, sizeof(int) * l->l_max_col + 1);
|
memset((char *)count, 0, sizeof(int) * l->l_max_col + 1);
|
||||||
for (i = nchars, c = l->l_line; --i >= 0; c++)
|
for (i = nchars, c = l->l_line; --i >= 0; c++)
|
||||||
count[c->c_column]++;
|
count[c->c_column]++;
|
||||||
|
|
||||||
@ -478,13 +492,15 @@ alloc_line()
|
|||||||
l = line_freelist;
|
l = line_freelist;
|
||||||
line_freelist = l->l_next;
|
line_freelist = l->l_next;
|
||||||
|
|
||||||
bzero(l, sizeof(LINE));
|
memset(l, 0, sizeof(LINE));
|
||||||
return(l);
|
return (l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
free_line(l)
|
free_line(l)
|
||||||
LINE *l;
|
LINE *l;
|
||||||
{
|
{
|
||||||
|
|
||||||
l->l_next = line_freelist;
|
l->l_next = line_freelist;
|
||||||
line_freelist = l;
|
line_freelist = l;
|
||||||
}
|
}
|
||||||
@ -494,29 +510,33 @@ xmalloc(p, size)
|
|||||||
void *p;
|
void *p;
|
||||||
size_t size;
|
size_t size;
|
||||||
{
|
{
|
||||||
if (!(p = (void *)realloc(p, size))) {
|
|
||||||
(void)fprintf(stderr, "col: %s.\n", strerror(ENOMEM));
|
if (!(p = (void *)realloc(p, size)))
|
||||||
exit(1);
|
err(1, NULL);
|
||||||
}
|
return (p);
|
||||||
return(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
usage()
|
usage()
|
||||||
{
|
{
|
||||||
|
|
||||||
(void)fprintf(stderr, "usage: col [-bfx] [-l nline]\n");
|
(void)fprintf(stderr, "usage: col [-bfx] [-l nline]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
wrerr()
|
wrerr()
|
||||||
{
|
{
|
||||||
|
|
||||||
(void)fprintf(stderr, "col: write error.\n");
|
(void)fprintf(stderr, "col: write error.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
warn(line)
|
void
|
||||||
|
dowarn(line)
|
||||||
int line;
|
int line;
|
||||||
{
|
{
|
||||||
(void)fprintf(stderr,
|
|
||||||
"col: warning: can't back up %s.\n", line < 0 ?
|
warnx("warning: can't back up %s",
|
||||||
"past first line" : "-- line already flushed");
|
line < 0 ? "past first line" : "-- line already flushed");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# from: @(#)Makefile 5.3 (Berkeley) 5/11/90
|
# $NetBSD: Makefile,v 1.3 1995/03/26 05:30:58 glass Exp $
|
||||||
# $Id: Makefile,v 1.2 1993/07/31 15:24:44 mycroft Exp $
|
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||||
|
|
||||||
PROG= colcrt
|
PROG= colcrt
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
.\" Copyright (c) 1980, 1990 The Regents of the University of California.
|
.\" $NetBSD: colcrt.1,v 1.3 1995/03/26 05:30:59 glass Exp $
|
||||||
.\" All rights reserved.
|
.\"
|
||||||
|
.\" Copyright (c) 1980, 1990, 1993
|
||||||
|
.\" The Regents of the University of California. All rights reserved.
|
||||||
.\"
|
.\"
|
||||||
.\" Redistribution and use in source and binary forms, with or without
|
.\" Redistribution and use in source and binary forms, with or without
|
||||||
.\" modification, are permitted provided that the following conditions
|
.\" modification, are permitted provided that the following conditions
|
||||||
@ -29,10 +31,9 @@
|
|||||||
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
.\" SUCH DAMAGE.
|
.\" SUCH DAMAGE.
|
||||||
.\"
|
.\"
|
||||||
.\" from: @(#)colcrt.1 6.7 (Berkeley) 3/14/91
|
.\" @(#)colcrt.1 8.1 (Berkeley) 6/30/93
|
||||||
.\" $Id: colcrt.1,v 1.2 1993/08/01 07:33:43 mycroft Exp $
|
|
||||||
.\"
|
.\"
|
||||||
.Dd March 14, 1991
|
.Dd June 30, 1993
|
||||||
.Dt COLCRT 1
|
.Dt COLCRT 1
|
||||||
.Os BSD 3
|
.Os BSD 3
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -55,7 +56,7 @@ Available options:
|
|||||||
.Bl -tag -width Ds
|
.Bl -tag -width Ds
|
||||||
.It Fl
|
.It Fl
|
||||||
Suppress all underlining.
|
Suppress all underlining.
|
||||||
It is especially useful for previewing
|
This option is especially useful for previewing
|
||||||
.Em allboxed
|
.Em allboxed
|
||||||
tables from
|
tables from
|
||||||
.Xr tbl 1 .
|
.Xr tbl 1 .
|
||||||
@ -86,12 +87,7 @@ tbl exum2.n \&| nroff \-ms \&| colcrt \- \&| more
|
|||||||
Should fold underlines onto blanks even with the
|
Should fold underlines onto blanks even with the
|
||||||
.Ql Fl
|
.Ql Fl
|
||||||
option so that
|
option so that
|
||||||
a true underline character would show; if we did this, however,
|
a true underline character would show.
|
||||||
.Nm colcrt
|
|
||||||
wouldn't get rid of
|
|
||||||
.Ar cu Ns 'd
|
|
||||||
underlining
|
|
||||||
completely.
|
|
||||||
.Pp
|
.Pp
|
||||||
Can't back up more than 102 lines.
|
Can't back up more than 102 lines.
|
||||||
.Pp
|
.Pp
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
|
/* $NetBSD: colcrt.c,v 1.3 1995/03/26 05:31:00 glass Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1980 The Regents of the University of California.
|
* Copyright (c) 1980, 1993
|
||||||
* All rights reserved.
|
* The Regents of the University of California. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -32,14 +34,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
char copyright[] =
|
static char copyright[] =
|
||||||
"@(#) Copyright (c) 1980 The Regents of the University of California.\n\
|
"@(#) Copyright (c) 1980, 1993\n\
|
||||||
All rights reserved.\n";
|
The Regents of the University of California. All rights reserved.\n";
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
/*static char sccsid[] = "from: @(#)colcrt.c 5.4 (Berkeley) 6/1/90";*/
|
#if 0
|
||||||
static char rcsid[] = "$Id: colcrt.c,v 1.2 1993/08/01 18:17:31 mycroft Exp $";
|
static char sccsid[] = "@(#)colcrt.c 8.1 (Berkeley) 6/6/93";
|
||||||
|
#else
|
||||||
|
static char rcsid[] = "$NetBSD: colcrt.c,v 1.3 1995/03/26 05:31:00 glass Exp $";
|
||||||
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
Loading…
Reference in New Issue
Block a user