]> Zhao Yanbai Git Server - minix.git/commitdiff
Importing usr.bin/colcrt 59/1159/1
authorThomas Cort <tcort@minix3.org>
Tue, 19 Nov 2013 11:46:36 +0000 (06:46 -0500)
committerThomas Cort <tcort@minix3.org>
Tue, 19 Nov 2013 12:26:37 +0000 (07:26 -0500)
Replaces colcrt from commands/cawf.
No Minix-specific changes needed.

Change-Id: I0ec6452c879b9a844ad97e89759087d6c3e740a2

commands/cawf/Makefile
distrib/sets/lists/minix/mi
releasetools/nbsd_ports
usr.bin/Makefile
usr.bin/colcrt/Makefile [new file with mode: 0644]
usr.bin/colcrt/colcrt.1 [new file with mode: 0644]
usr.bin/colcrt/colcrt.c [new file with mode: 0644]

index 9b635d6d40c32c46b953fb91c5866f21f963d177..e53217f8006ab76a9f008ae9e9fe4263b0aad903 100644 (file)
@@ -45,7 +45,10 @@ SRCS.cawf= cawf.c device.c error.c expand.c expr.c getopt.c macsup.c nreq.c \
 SRCS.bsfilt= bsfilt.c
 
 LINKS+=        ${BINDIR}/cawf ${BINDIR}/nroff
-LINKS+=        ${BINDIR}/bsfilt ${BINDIR}/colcrt
+
+# replaced by usr.bin/colcrt
+#LINKS+=       ${BINDIR}/bsfilt ${BINDIR}/colcrt
+
 MAN.cawf=
 MAN.bsfilt=
 
index af196006b4fadb22b5c0ce41254558c92853e106..76310708116617963c049800acbb9bbb94d8d471 100644 (file)
 ./usr/bin/cmp                          minix-sys
 ./usr/bin/co                           minix-sys
 ./usr/bin/col                          minix-sys
+./usr/bin/colcrt                       minix-sys
 ./usr/bin/colrm                                minix-sys
 ./usr/bin/column                       minix-sys
-./usr/bin/colcrt                       minix-sys
 ./usr/bin/comm                         minix-sys
 ./usr/bin/compress                     minix-sys
 ./usr/bin/cpio                         minix-sys
 ./usr/man/man1/cmp.1                   minix-sys
 ./usr/man/man1/co.1                    minix-sys
 ./usr/man/man1/col.1                   minix-sys
+./usr/man/man1/colcrt.1                        minix-sys
 ./usr/man/man1/colrm.1                 minix-sys
 ./usr/man/man1/column.1                        minix-sys
 ./usr/man/man1/comm.1                  minix-sys
index e53b937915a550e6d3810532422b6931feedd55d..008db1107a0e6bf8bc2a2fc9a1be7ac19cbbd4a3 100644 (file)
 2009/04/11 12:10:02,usr.bin/chpass
 2012/10/17 12:00:00,usr.bin/cksum
 2012/10/17 12:00:00,usr.bin/col
+2012/10/17 12:00:00,usr.bin/colcrt
 2012/10/17 12:00:00,usr.bin/colrm
 2013/10/16 12:00:00,usr.bin/column
 2012/10/17 12:00:00,usr.bin/comm
index 9dfaf34ab10055c15af5a2caaf281bb6a71db0b1..ae7dc7d1baab9ff355e87bbe836d9104b83d6afa 100644 (file)
@@ -6,7 +6,7 @@
 SUBDIR= asa \
        banner basename bdes \
        bzip2 bzip2recover cal calendar \
-       checknr chpass cksum col colrm \
+       checknr chpass cksum col colcrt colrm \
        column comm csplit ctags cut \
        deroff dirname du \
        env expand \
diff --git a/usr.bin/colcrt/Makefile b/usr.bin/colcrt/Makefile
new file mode 100644 (file)
index 0000000..fc229b9
--- /dev/null
@@ -0,0 +1,6 @@
+#      $NetBSD: Makefile,v 1.5 2009/04/14 22:15:18 lukem Exp $
+#      @(#)Makefile    8.1 (Berkeley) 6/6/93
+
+PROG=  colcrt
+
+.include <bsd.prog.mk>
diff --git a/usr.bin/colcrt/colcrt.1 b/usr.bin/colcrt/colcrt.1
new file mode 100644 (file)
index 0000000..75185f9
--- /dev/null
@@ -0,0 +1,106 @@
+.\"    $NetBSD: colcrt.1,v 1.9 2012/05/12 14:52:57 reed 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
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"     @(#)colcrt.1   8.1 (Berkeley) 6/30/93
+.\"
+.Dd June 30, 1993
+.Dt COLCRT 1
+.Os
+.Sh NAME
+.Nm colcrt
+.Nd filter nroff output for CRT previewing
+.Sh SYNOPSIS
+.Nm
+.Op Fl
+.Op Fl \&2
+.Op Ar
+.Sh DESCRIPTION
+.Nm
+provides virtual half-line and reverse line feed sequences
+for terminals without such capability, and on which overstriking
+is destructive.
+Half-line characters and underlining (changed to dashing `\-')
+are placed on new lines in between the normal output lines.
+.Pp
+Available options:
+.Bl -tag -width Ds
+.It Fl
+Suppress all underlining.
+This option is especially useful for previewing
+.Em allboxed
+tables from
+.Xr tbl 1 .
+.It Fl 2
+Causes all half-lines to be printed, effectively double spacing the output.
+Normally, a minimal space output format is used which will suppress empty
+lines.
+The program never suppresses two consecutive empty lines, however.
+The
+.Fl 2
+option is useful for sending output to the line printer when the output
+contains superscripts and subscripts which would otherwise be invisible.
+.El
+.Sh EXAMPLES
+A typical use of
+.Nm
+would be
+.Bd -literal
+tbl exum2.n \&| nroff \-ms \&| colcrt \- \&| more
+.Ed
+.Sh SEE ALSO
+.Xr col 1 ,
+.Xr more 1 ,
+.Xr nroff 1 ,
+.Xr troff 1 ,
+.Xr ul 1
+.Sh HISTORY
+The
+.Nm
+command appeared in
+.Bx 1 .
+.Sh BUGS
+Should fold underlines onto blanks even with the
+.Ql Fl
+option so that
+a true underline character would show.
+.Pp
+Can't back up more than 102 lines.
+.Pp
+General overstriking is lost;
+as a special case
+.Ql \&|
+overstruck with
+.Ql \-
+or underline becomes
+.Ql \&+ .
+.Pp
+Lines are trimmed to 132 characters.
+.Pp
+Some provision should be made for processing superscripts and subscripts
+in documents which are already double-spaced.
diff --git a/usr.bin/colcrt/colcrt.c b/usr.bin/colcrt/colcrt.c
new file mode 100644 (file)
index 0000000..be7030e
--- /dev/null
@@ -0,0 +1,260 @@
+/*     $NetBSD: colcrt.c,v 1.8 2008/07/21 14:19:21 lukem Exp $ */
+
+/*
+ * 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
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__COPYRIGHT("@(#) Copyright (c) 1980, 1993\
+ The Regents of the University of California.  All rights reserved.");
+#endif /* not lint */
+
+#ifndef lint
+#if 0
+static char sccsid[] = "@(#)colcrt.c   8.1 (Berkeley) 6/6/93";
+#else
+__RCSID("$NetBSD: colcrt.c,v 1.8 2008/07/21 14:19:21 lukem Exp $");
+#endif
+#endif /* not lint */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+/*
+ * colcrt - replaces col for crts with new nroff esp. when using tbl.
+ * Bill Joy UCB July 14, 1977
+ *
+ * This filter uses a screen buffer, 267 half-lines by 132 columns.
+ * It interprets the up and down sequences generated by the new
+ * nroff when used with tbl and by \u \d and \r.
+ * General overstriking doesn't work correctly.
+ * Underlining is split onto multiple lines, etc.
+ *
+ * Option - suppresses all underlining.
+ * Option -2 forces printing of all half lines.
+ */
+
+char   page[267][132];
+
+int    outline = 1;
+int    outcol;
+
+char   suppresul;
+char   printall;
+
+char   *progname;
+FILE   *f;
+
+void   move(int, int);
+void   pflush(int);
+int    plus(char, char);
+
+int
+main(int argc, char *argv[])
+{
+       int c;
+       char *cp, *dp;
+
+       argc--;
+       progname = *argv++;
+       while (argc > 0 && argv[0][0] == '-') {
+               switch (argv[0][1]) {
+                       case 0:
+                               suppresul = 1;
+                               break;
+                       case '2':
+                               printall = 1;
+                               break;
+                       default:
+                               printf("usage: %s [ - ] [ -2 ] [ file ... ]\n", progname);
+                               fflush(stdout);
+                               exit(1);
+               }
+               argc--;
+               argv++;
+       }
+       do {
+               if (argc > 0) {
+                       close(0);
+                       if (!(f = fopen(argv[0], "r"))) {
+                               fflush(stdout);
+                               perror(argv[0]);
+                               exit (1);
+                       }
+                       argc--;
+                       argv++;
+               }
+               for (;;) {
+                       c = getc(stdin);
+                       if (c == -1) {
+                               pflush(outline);
+                               fflush(stdout);
+                               break;
+                       }
+                       switch (c) {
+                               case '\n':
+                                       if (outline >= 265)
+                                               pflush(62);
+                                       outline += 2;
+                                       outcol = 0;
+                                       continue;
+                               case '\016':
+                                       case '\017':
+                                       continue;
+                               case 033:
+                                       c = getc(stdin);
+                                       switch (c) {
+                                               case '9':
+                                                       if (outline >= 266)
+                                                               pflush(62);
+                                                       outline++;
+                                                       continue;
+                                               case '8':
+                                                       if (outline >= 1)
+                                                               outline--;
+                                                       continue;
+                                               case '7':
+                                                       outline -= 2;
+                                                       if (outline < 0)
+                                                               outline = 0;
+                                                       continue;
+                                               default:
+                                                       continue;
+                                       }
+                               case '\b':
+                                       if (outcol)
+                                               outcol--;
+                                       continue;
+                               case '\t':
+                                       outcol += 8;
+                                       outcol &= ~7;
+                                       outcol--;
+                                       c = ' ';
+                               default:
+                                       if (outcol >= 132) {
+                                               outcol++;
+                                               continue;
+                                       }
+                                       cp = &page[outline][outcol];
+                                       outcol++;
+                                       if (c == '_') {
+                                               if (suppresul)
+                                                       continue;
+                                               cp += 132;
+                                               c = '-';
+                                       }
+                                       if (*cp == 0) {
+                                               *cp = c;
+                                               dp = cp - outcol;
+                                               for (cp--; cp >= dp && *cp == 0; cp--)
+                                                       *cp = ' ';
+                                       } else
+                                               if (plus(c, *cp) || plus(*cp, c))
+                                                       *cp = '+';
+                                               else if (*cp == ' ' || *cp == 0)
+                                                       *cp = c;
+                                       continue;
+                       }
+               }
+       } while (argc > 0);
+       fflush(stdout);
+       exit(0);
+}
+
+int
+plus(char c, char d)
+{
+
+       return ((c == '|' && d == '-') || d == '_');
+}
+
+int first;
+
+void
+pflush(int ol)
+{
+       int i;
+       char *cp;
+       char lastomit;
+       int l;
+
+       l = ol;
+       lastomit = 0;
+       if (l > 266)
+               l = 266;
+       else
+               l |= 1;
+       for (i = first | 1; i < l; i++) {
+               move(i, i - 1);
+               move(i, i + 1);
+       }
+       for (i = first; i < l; i++) {
+               cp = page[i];
+               if (printall == 0 && lastomit == 0 && *cp == 0) {
+                       lastomit = 1;
+                       continue;
+               }
+               lastomit = 0;
+               printf("%s\n", cp);
+       }
+       memmove(page, page[ol], (267 - ol) * 132);
+       memset(page[267- ol], 0, ol * 132);
+       outline -= ol;
+       outcol = 0;
+       first = 1;
+}
+
+void
+move(int l, int m)
+{
+       char *cp, *dp;
+
+       for (cp = page[l], dp = page[m]; *cp; cp++, dp++) {
+               switch (*cp) {
+                       case '|':
+                               if (*dp != ' ' && *dp != '|' && *dp != 0)
+                                       return;
+                               break;
+                       case ' ':
+                               break;
+                       default:
+                               return;
+               }
+       }
+       if (*cp == 0) {
+               for (cp = page[l], dp = page[m]; *cp; cp++, dp++)
+                       if (*cp == '|')
+                               *dp = '|';
+                       else if (*dp == 0)
+                               *dp = ' ';
+               page[l][0] = 0;
+       }
+}