merged with 4.4Lite

This commit is contained in:
glass 1995-03-26 05:25:51 +00:00
parent 4c5b39eb10
commit 282052c7a8
6 changed files with 87 additions and 65 deletions

View File

@ -1,5 +1,5 @@
# from: @(#)Makefile 5.2 (Berkeley) 5/11/90
# $Id: Makefile,v 1.2 1993/07/31 15:24:50 mycroft Exp $
# $NetBSD: Makefile,v 1.3 1995/03/26 05:25:51 glass Exp $
# @(#)Makefile 8.1 (Berkeley) 6/6/93
PROG= col

View File

@ -1,5 +1,7 @@
.\" Copyright (c) 1990 The Regents of the University of California.
.\" All rights reserved.
.\" $NetBSD: col.1,v 1.4 1995/03/26 05:25:52 glass Exp $
.\"
.\" Copyright (c) 1990, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" This code is derived from software contributed to Berkeley by
.\" Michael Rendell.
@ -32,10 +34,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" from: @(#)col.1 6.8 (Berkeley) 6/17/91
.\" $Id: col.1,v 1.3 1993/11/30 00:19:51 jtc Exp $
.\" @(#)col.1 8.1 (Berkeley) 6/29/93
.\"
.Dd June 17, 1991
.Dd June 29, 1993
.Dt COL 1
.Os
.Sh NAME
@ -47,7 +48,7 @@
.Op Fl l Ar num
.Sh DESCRIPTION
.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
feeds, and replaces white-space characters with tabs where possible.
This can be useful in processing the output of
@ -56,7 +57,7 @@ and
.Xr tbl 1 .
.Pp
.Nm Col
reads from standard input and writes to standard output.
reads from the standard input and writes to the standard output.
.Pp
The options are as follows:
.Bl -tag -width "-l num "
@ -69,7 +70,7 @@ Normally characters printed on a half line boundary are printed
on the following line.
.It Fl x
Output multiple spaces instead of tabs.
.It Fl l Ns Ar num
.It Fl l Ar num
Buffer at least
.Ar num
lines in memory.

View File

@ -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.
* All rights reserved.
* Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Michael Rendell of the Memorial University of Newfoundland.
@ -35,18 +37,21 @@
*/
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1990 The Regents of the University of California.\n\
All rights reserved.\n";
static char copyright[] =
"@(#) Copyright (c) 1990, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
/*static char sccsid[] = "from: @(#)col.c 5.3 (Berkeley) 2/2/91";*/
static char rcsid[] = "$Id: col.c,v 1.5 1994/12/24 16:24:32 cgd Exp $";
#if 0
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 */
#include <errno.h>
#include <ctype.h>
#include <err.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
@ -88,8 +93,15 @@ struct line_str {
int l_max_col; /* max column in the line */
};
LINE *alloc_line();
void *xmalloc();
LINE *alloc_line __P((void));
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 */
LINE *lines;
@ -103,13 +115,12 @@ int no_backspaces; /* if not to output any backspaces */
if (putchar(ch) == EOF) \
wrerr();
int
main(argc, argv)
int argc;
char **argv;
{
extern int optind;
extern char *optarg;
register int ch;
int ch;
CHAR *c;
CSET cur_set; /* current character set */
LINE *l; /* current line */
@ -244,7 +255,7 @@ main(argc, argv)
}
} else {
if (!warned++)
warn(cur_line);
dowarn(cur_line);
cur_line -= nmove;
}
}
@ -309,6 +320,7 @@ main(argc, argv)
exit(0);
}
void
flush_lines(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
* feeds.
*/
void
flush_blanks()
{
int half, i, nb;
@ -363,6 +376,7 @@ flush_blanks()
* Write a line to stdout taking care of space to tab conversion (-h flag)
* and character set shifts.
*/
void
flush_line(l)
LINE *l;
{
@ -390,7 +404,7 @@ flush_line(l)
count = (int *)xmalloc((void *)count,
(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++)
count[c->c_column]++;
@ -478,13 +492,15 @@ alloc_line()
l = line_freelist;
line_freelist = l->l_next;
bzero(l, sizeof(LINE));
memset(l, 0, sizeof(LINE));
return (l);
}
void
free_line(l)
LINE *l;
{
l->l_next = line_freelist;
line_freelist = l;
}
@ -494,29 +510,33 @@ xmalloc(p, size)
void *p;
size_t size;
{
if (!(p = (void *)realloc(p, size))) {
(void)fprintf(stderr, "col: %s.\n", strerror(ENOMEM));
exit(1);
}
if (!(p = (void *)realloc(p, size)))
err(1, NULL);
return (p);
}
void
usage()
{
(void)fprintf(stderr, "usage: col [-bfx] [-l nline]\n");
exit(1);
}
void
wrerr()
{
(void)fprintf(stderr, "col: write error.\n");
exit(1);
}
warn(line)
void
dowarn(line)
int line;
{
(void)fprintf(stderr,
"col: warning: can't back up %s.\n", line < 0 ?
"past first line" : "-- line already flushed");
warnx("warning: can't back up %s",
line < 0 ? "past first line" : "-- line already flushed");
}

View File

@ -1,5 +1,5 @@
# from: @(#)Makefile 5.3 (Berkeley) 5/11/90
# $Id: Makefile,v 1.2 1993/07/31 15:24:44 mycroft Exp $
# $NetBSD: Makefile,v 1.3 1995/03/26 05:30:58 glass Exp $
# @(#)Makefile 8.1 (Berkeley) 6/6/93
PROG= colcrt

View File

@ -1,5 +1,7 @@
.\" Copyright (c) 1980, 1990 The Regents of the University of California.
.\" All rights reserved.
.\" $NetBSD: colcrt.1,v 1.3 1995/03/26 05:30:59 glass Exp $
.\"
.\" 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
.\" 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
.\" SUCH DAMAGE.
.\"
.\" from: @(#)colcrt.1 6.7 (Berkeley) 3/14/91
.\" $Id: colcrt.1,v 1.2 1993/08/01 07:33:43 mycroft Exp $
.\" @(#)colcrt.1 8.1 (Berkeley) 6/30/93
.\"
.Dd March 14, 1991
.Dd June 30, 1993
.Dt COLCRT 1
.Os BSD 3
.Sh NAME
@ -55,7 +56,7 @@ Available options:
.Bl -tag -width Ds
.It Fl
Suppress all underlining.
It is especially useful for previewing
This option is especially useful for previewing
.Em allboxed
tables from
.Xr tbl 1 .
@ -86,12 +87,7 @@ tbl exum2.n \&| nroff \-ms \&| colcrt \- \&| more
Should fold underlines onto blanks even with the
.Ql Fl
option so that
a true underline character would show; if we did this, however,
.Nm colcrt
wouldn't get rid of
.Ar cu Ns 'd
underlining
completely.
a true underline character would show.
.Pp
Can't back up more than 102 lines.
.Pp

View File

@ -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.
* All rights reserved.
* Copyright (c) 1980, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -32,14 +34,17 @@
*/
#ifndef lint
char copyright[] =
"@(#) Copyright (c) 1980 The Regents of the University of California.\n\
All rights reserved.\n";
static char copyright[] =
"@(#) Copyright (c) 1980, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
/*static char sccsid[] = "from: @(#)colcrt.c 5.4 (Berkeley) 6/1/90";*/
static char rcsid[] = "$Id: colcrt.c,v 1.2 1993/08/01 18:17:31 mycroft Exp $";
#if 0
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 */
#include <stdio.h>