Table.c - Makes an Nroff Driver Table

Bruce Townsend bruce at bnr-vpa.UUCP
Tue Feb 26 02:14:51 AEST 1985


	I have received enough requests for this, so now I'm posting it.
Table.c is a program which prepares Nroff Driver tables. It has been
written from information found in the term man page posted recently to
the net (and included here) and from existing tab files on our machine
(HP-9000 running Sys III). Therefore it is not guaranteed to work on
anything else. Since there are a lot of people without source license,
who would still like to hack their own nroff tab files, this may be
useful, even if it doesn't work immediately.

	Let me know of any problems, or post relevant changes to
net.sources.bugs. This is in Shar format, so cut on the line and
run through sh, not csh.

			-Bruce Townsend

			Voice Processing Applications,
			Bell Northern Research,
			Ottawa, Ontario.

Mail path: {utzoo, utcs, bnr-di, bnr-mtl}!bnr-vpa!bruce

--------------------C-U-T--H-E-R-E---------------------------------
#!/bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #!/bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	charlist
#	term.5
#	table.c
#	table.doc
# This archive created: Mon Feb 25 10:58:42 1985
export PATH; PATH=/bin:$PATH
echo shar: extracting "'charlist'" '(1675 characters)'
if test -f 'charlist'
then
	echo shar: over-writing existing file "'charlist'"
fi
sed 's/^X//' << \SHAR_EOF > 'charlist'
X_______________
XName	Number
X	(Octal)     
X_______________
X<space> 000
X!	001
X"	002
X#	003
X$	004
X%	005
X&	006
X'	007
X(	010
X)	011
X*	012
X+	013
X,	014
X-	015
X.	016
X/	017
X0	020
X1	021
X2	022
X3	023
X4	024
X5	025
X6	026
X7	027
X8	030
X9	031
X:	032
X;	033
X<	034
X=	035
X>	036
X?	037
X@	040
XA	041
XB	042
XC	043
XD	044
XE	045
XF	046
XG	047
XH	050
XI	051
XJ	052
XK	053
XL	054
XM	055
XN	056
XO	057
XP	060
XQ	061
XR	062
XS	063
XT	064
XU	065
XV	066
XW	067
XX	070
XY	071
XZ	072
X[	073
X\	074
X]	075
X^	076
X_	077
X`	100
Xa	101
Xb	102
Xc	103
Xd	104
Xe	105
Xf	106
Xg	107
Xh	110
Xi	111
Xj	112
Xk	113
Xl	114
Xm	115
Xn	116
Xo	117
Xp	120
Xq	121
Xr	122
Xs	123
Xt	124
Xu	125
Xv	126
Xw	127
Xx	130
Xy	131
Xz	132
X{	133
X|	134
X}	135
X~	136
X????	137
X%!	140
X%(bu	141
X%(sq	142
X%(em	143
X%(ru	144
X%(14	145
X%(12	146
X%(34	147
X%-	150
X%(fi	151
X%(fl	152
X%(ff	153
X%(Fi	154
X%(Fl	155
X%(de	156
X%(dg	157
X%(sc	160
X%(fm	161
X%'	162
X%(aa	162
X%	163
X%(ga	163
X%(ul	164
X%(sl	165
X%	166
X????	167
X%(*a	170
X%(*b	171
X%(*g	172
X%(*d	173
X%(*e	174
X%(*z	175
X%(*y	176
X%(*h	177
X%(*i	200
X%(*k	201
X%(*l	202
X%(*m	203
X%(*n	204
X%(*c	205
X%(*o	206
X%(*p	207
X%(*r	210
X%(*s	211
X%(*t	212
X%(*u	213
X%(*f	214
X%(*x	215
X%(*q	216
X%(*w	217
X%(*G	220
X%(*D	221
X%(*H	222
X%(*L	223
X%(*C	224
X%(*P	225
X%(*S	226
X%(*U	230
X%(*F	231
X%(*Q	232
X%(*W	233
X%(sr	234
X%(ts	235
X%(rn	236
X%(>=	237
X%(<=	240
X%(==	241
X%(mi	242
X%(~=	243
X%(ap	244
X%(!=	245
X%(->	246
X%(<-	247
X%(ua	250
X%(da	251
X%(eq	252
X%(mu	253
X%(di	254
X%(+-	255
X%(cu	256
X%(ca	257
X%(sb	260
X%(sp	261
X%(ib	262
X%(ip	263
X%(if	264
X%(pd	265
X%(gr	266
X%(no	267
X%(is	270
X%(pt	271
X%(es	272
X%(mo	273
X%(pl	274
X%(rg	275
X%(co	276
X%(br	277
X%(ct	300
X%(dd	301
X%(rh	302
X%(lh	303
X%(**	304
X%(bs	305
X%(or	306
X%(ci	307
X%(lt	310
X%(lb	311
X%(rt	312
X%(rb	313
X%(lk	314
X%(rk	315
X%(bv	316
X%(lf	317
X%(rf	320
X%(lc	321
X%(rc	322
SHAR_EOF
if test 1675 -ne "`wc -c 'charlist'`"
then
	echo shar: error transmitting "'charlist'" '(should have been 1675 characters)'
fi
echo shar: extracting "'term.5'" '(5756 characters)'
if test -f 'term.5'
then
	echo shar: over-writing existing file "'term.5'"
fi
sed 's/^X//' << \SHAR_EOF > 'term.5'
X.TH TERM 5
X.SH NAME
Xterm \- terminal driving tables for nroff
X.SH DESCRIPTION
X.IR Nroff (1)
Xuses driving tables to customize its output for various types of
Xoutput devices, such as printing terminals, special word-processing
Xterminals (such as Diablo, Qume, or NEC Spinwriter mechanisms),
Xor special output filter programs.  These driving tables are written
Xas C programs, compiled, and installed in
X\f3/usr/lib/term/tab\f2name\fP ,
Xwhere
X.I name\^
Xis the name for that terminal type as given in
X.IR term (7).
XThe structure of the tables is as follows:
X.PP
X.nf
X.ta 5m 10m 15m 20m 25m 30m 35m 40m 45m 50m 55m 60m
X#define	INCH	240
X
Xstruct {
X	int bset;
X	int breset;
X	int Hor;
X	int Vert;
X	int Newline;
X	int Char;
X	int Em;
X	int Halfline;
X	int Adj;
X	char *twinit;
X	char *twrest;
X	char *twnl;
X	char *hlr;
X	char *hlf;
X	char *flr;
X	char *bdon;
X	char *bdoff;
X	char *iton;
X	char *itoff;
X	char *ploton;
X	char *plotoff;
X	char *up;
X	char *down;
X	char *right;
X	char *left;
X	char *codetab[256\-32];
X	char *zzz;
X} t;
X.fi
X.DT
X.PP
XThe meanings of the various fields are as follows:
X.TP 10
X.I bset\^
Xbits to set in the
X.I c_oflag\^
Xfield of the
X.I termio\^
Xstructure (see
X.IR tty (4))
Xbefore output.
X.TP 10
X.I breset\^
Xbits to reset in the
X.I c_oflag\^
Xfield of the
X.I termio\^
Xstructure
Xbefore output.
X.TP 10
X.I Hor\^
Xhorizontal resolution in fractions of an inch.
X.TP 10
X.I Vert\^
Xvertical resolution in fractions of an inch.
X.TP 10
X.I Newline\^
Xspace moved by a newline (linefeed) character in fractions
Xof an inch.
X.TP 10
X.I Char\^
Xquantum of character sizes, in fractions of an inch.
X(i.e., a character is a multiple of Char units wide)
X.TP 10
X.I Em\^
Xsize of an em in fractions of an inch.
X.TP 10
X.I Halfline\^
Xspace moved by a half-linefeed (or half-reverse-linefeed)
Xcharacter in fractions of an inch.
X.TP 10
X.I Adj\^
Xquantum of white space, in fractions of an inch.
X(i.e., white spaces are a multiple of Adj units wide)
X.IP
XNote: if this is less than the size of the space
Xcharacter (in units of Char; see below for how the
Xsizes of characters are defined),
X.I nroff\^
Xwill output
Xfractional spaces using plot mode.  Also, if the
X.B \-e
Xswitch to
X.I nroff\^
Xis used, Adj is set equal to Hor by
X.IR nroff .
X.TP 10
X.I twinit\^
Xset of characters used to initialize the terminal
Xin a mode suitable for
X.IR nroff .
X.TP 10
X.I twrest\^
Xset of characters used to restore the terminal to
Xnormal mode.
X.TP 10
X.I twnl\^
Xset of characters used to move down one line.
X.TP 10
X.I hlr\^
Xset of characters used to move up one-half line.
X.TP 10
X.I hlf\^
Xset of characters used to move down one-half line.
X.TP 10
X.I flr\^
Xset of characters used to move up one line.
X.TP 10
X.I bdon\^
Xset of characters used to turn on hardware boldface mode,
Xif any.
X.I Nroff\^
Xassumes that boldface mode is reset automatically by the
X.I twnl\^
Xstring, because many letter-quality printers reset the boldface
Xmode when they receive a carriage return;
Xthe
X.I twnl\^
Xstring should include whatever characters are necessary to
Xreset the boldface mode.
X.TP 10
X.I bdoff\^
Xset of characters used to turn off hardware boldface mode,
Xif any.
X.TP 10
X.I iton\^
Xset of characters used to turn on hardware italics mode,
Xif any.
X.TP 10
X.I itoff\^
Xset of characters used to turn off hardware italics mode,
Xif any.
X.TP 10
X.I ploton\^
Xset of characters used to turn on hardware plot mode
X(for Diablo type mechanisms), if any.
X.TP 10
X.I plotoff\^
Xset of characters used to turn off hardware plot mode
X(for Diablo type mechanisms), if any.
X.TP 10
X.I up\^
Xset of characters used to move up one resolution unit
X(Vert) in plot mode, if any.
X.TP 10
X.I down\^
Xset of characters used to move down one resolution unit
X(Vert) in plot mode, if any.
X.TP 10
X.I right\^
Xset of characters used to move right one resolution unit
X(Hor) in plot mode, if any.
X.TP 10
X.I left\^
Xset of characters used to move left one resolution unit
X(Hor) in plot mode, if any.
X.TP 10
X.I codetab\^
Xdefinition of characters needed to print an
X.I nroff\^
Xcharacter
Xon the terminal.
XThe first byte is the number of character units (Char) needed to hold the
Xcharacter; i.e., ``\\001'' is one unit wide, ``\\002'' is two
Xunits wide, etc.  The high-order bit (0200) is on if
Xthe character is to be underlined in underline mode
X(.ul).
XThe rest of the bytes are the characters used to produce the character in
Xquestion.  If the character has the sign (0200) bit on,
Xit is a code to move the terminal in plot mode.  It is
Xencoded as:
X.RS
X.IP "0100 bit on" 15
Xvertical motion.
X.IP "0100 bit off" 15
Xhorizontal motion.
X.IP "040 bit on" 15
Xnegative (up or left) motion.
X.IP "040 bit off" 15
Xpositive (down or right) motion.
X.IP "037 bits" 15
Xnumber of such motions to make.
X.RE
X.TP 10
X.I zzz\^
Xa zero terminator at the end.
X.PP
XAll quantities which are in units of fractions of an inch should
Xbe expressed as
X.RI INCH* num / denom ,
Xwhere
X.I num\^
Xand
X.I denom\^
Xare respectively the numerator and denominator of the fraction; i.e.,
X1/48 of an inch would be written as ``INCH/48''.
X.PP
XIf any sequence of characters does not pertain to the output device,
Xthat sequence should be given as a null string.
X.PP
XThe source code for the terminal
X.I name\^
Xis in
X.BI /usr/src/cmd/text/roff.d/terms.d/tab name .c.
XWhen a new terminal type is added, the file
X.I maketerms.c\^
Xshould be updated to `#include' the source to that driving table;
Xnote that the various terminal types are grouped into ``parts'' labelled
X.BR PART1 ,
X.BR PART2 ,
Xand
X.BR PART3 .
XIf necessary, more parts can be added.  Other changes necessary to
X.I maketerms.c\^
Xare left as an exercise to the reader.
XThe makefile
X.I terms.mk\^
Xin that directory should then be updated.
X.SH FILES
X/usr/lib/term/tab\f2name\fP	driving tables
X.br
Xtab\f2name\fP.c	source for driving tables
X.SH SEE ALSO
Xtroff(1), term(7)
SHAR_EOF
if test 5756 -ne "`wc -c 'term.5'`"
then
	echo shar: error transmitting "'term.5'" '(should have been 5756 characters)'
fi
echo shar: extracting "'table.c'" '(9208 characters)'
if test -f 'table.c'
then
	echo shar: over-writing existing file "'table.c'"
fi
sed 's/^X//' << \SHAR_EOF > 'table.c'
X/***********************************************************************
X*                                                                      *
X*     TABLE - A PROGRAM TO PREPARE NROFF DRIVER TABLES                 *
X*     copyright (c) 1985 by Bruce Townsend and Bell Northern Research  *
X*     Permission hereby granted to use, distribute, modify, or copy    *
X*     except for profit, providing this disclaimer is included.        *
X*                                                                      *
X*                                                                      *
X*     Please send bug reports to Bruce Townsend (utcs!bnr-vpa!bruce)   *
X*                                                                      *
X*     Usage: 1) Modify this source to initialize the "t" structure.    *
X*            2) If the amount of char data that the structure          *
X*               references is very large, you may want to redefine     *
X*               C_SIZE                                                 *
X*            3) check to see whether <sgtty.h> or <termio.h> should    *
X*               be #included. One of these include files may be        *
X*               necessary to provide settings for t.bset, t.breset     *
X*            4) Compile this source:                                   *
X*                   cc -O table -o table.c                             *
X*            5) Run the program as "table filename", where filename    *
X*               is of the form "tab*", as in: "tab450"                 *
X*            6) Locate the tabfile in the proper place (on our system  *
X*               the directory is /usr/lib/term                         *
X*                                                                      *
X*	Date: Mon Feb 25 1985                                          *
X***********************************************************************/
X#include	<stdio.h>
X#include	<termio.h>	/* ... or use <sgtty.h> */
X/* #include	<sgtty.h>	/* ... or use <termio.h> */
X
X#define C_SIZE	10000	/* The maximum amount of character data allowed
X			   in the initialized structure t - increase if
X			   necessary */
X
X#define	INCH	240
Xstruct {			/* Initialize this structure */
X	int bset;
X	int breset;
X	int Hor;
X	int Vert;
X	int Newline;
X	int Char;
X	int Em;
X	int Halfline;
X	int Adj;
X	char *twinit;
X	char *twrest;
X	char *twnl;
X	char *hlr;
X	char *hlf;
X	char *flr;
X	char *bdon;
X	char *bdoff;
X	char *iton;
X	char *itoff;
X	char *ploton;
X	char *plotoff;
X	char *up;
X	char *down;
X	char *right;
X	char *left;
X	char *codetab[256-32];
X	char *zzz;
X} t = {
X	/*****************************************************************
X	*                                                                *
X	*   The following is a partial initialization for a Diablo 630   *
X	*   in proportional mode using a Bold Roman printwheel. It is    *
X	*   included as an example only, as is not guaranteed to work    *
X	*   properly.                                                    *
X	*                                                                *
X	*****************************************************************/
X	NULL, ONLCR | OCRNL | ONLRET,
X	INCH / 60, INCH / 48, INCH / 6, INCH / 60,
X	INCH / 12, INCH / 12, INCH / 60,
X	"\0334\033\\", "\0334\033/", "\r\n", "\033D", "\033U", "\033\n",
X	"\033W", "\033&", "", "", "\0333", "\0334", "\033\n", "\n", " ", "\b",
X
X	"\005 ", "\205}", "\204\"", "\206#", "\205$", "\210%", "\207&", "\202'",
X	"\203(", "\203)", "\205*", "\205+", "\203,", "\204-", "\203.", "\204/",
X
X	"\2050", "\2051", "\2052", "\2053", "\2054", "\2055", "\2056", "\2057",
X	"\2058", "\2059", "\203:", "\203;", "\205[", "\205=", "\206~", "\205?",
X
X	"\206 ", "\207A", "\206B", "\207C", "\207D", "\206E", "\206F", "\207G",
X	"\207H", "\203I", "\205J", "\207K", "\206L", "\210M", "\207N", "\207O",
X
X	"\206P", "\207Q", "\207R", "\205S", "\206T", "\207U", "\206V", "\210W",
X	"\207X", "\207Y", "\206Z", "\203`", "\206 ", "\203}", "\206 ", "\205_",
X
X	"\206 ", "\205a", "\205b", "\205c", "\205d", "\205e", "\204f", "\205g",
X	"\205h", "\203i", "\203j", "\205k", "\203l", "\210m", "\205n", "\205o",
X
X	"\205p", "\205q", "\204r", "\204s", "\204t", "\205u", "\205v", "\207w",
X	"\205x", "\205y", "\205z", "\206 ", "\203!", "\206 ", "\206 ", "",
X
X	"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
X	"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
X	"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
X	"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
X	"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
X	"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
X	"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
X	"", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",
X
X	NULL
X	};
X
X/************* DO NOT ALTER ANYTHING AFTER THIS POINT ***************/
X
Xstruct {		/* This structure will be stored in the tab file */
X	int bset;
X	int breset;
X	int Hor;
X	int Vert;
X	int Newline;
X	int Char;
X	int Em;
X	int Halfline;
X	int Adj;
X	int twinit;
X	int twrest;
X	int twnl;
X	int hlr;
X	int hlf;
X	int flr;
X	int bdon;
X	int bdoff;
X	int iton;
X	int itoff;
X	int ploton;
X	int plotoff;
X	int up;
X	int down;
X	int right;
X	int left;
X	int codetab[256-32];
X	int zzz;
X} t_stor;
X
Xchar	c_data[C_SIZE];
Xchar	*c_pointer[256];
Xchar	*c_end = c_data;
Xint	n_strings, c_size;
X
Xmain (argc, argv)
Xint	argc;
Xchar	*argv[];
X{
X	FILE	*table;
X	int	i, j, i_len, j_len;
X	char	*tail, *strcpy();
X
X	if (argc != 2) {	/* Need a file name argument */
X	    fprintf (stderr, "Usage: table \"file\"\n");
X	    exit (1);
X	    }
X
X	/* Open the file */
X	if ((table = fopen (argv[1], "w")) == NULL) {
X	    fprintf (stderr, "File %s not opened for writing\n", argv[1]);
X	    exit (1);
X	    }
X
X	/* Copy the integer values from the initialized structure
X	   to the storage structure */
X	t_stor.bset = t.bset;
X	t_stor.breset = t.breset;
X	t_stor.Hor = t.Hor;
X	t_stor.Vert = t.Vert;
X	t_stor.Newline = t.Newline;
X	t_stor.Char = t.Char;
X	t_stor.Em = t.Em;
X	t_stor.Halfline = t.Halfline;
X	t_stor.Adj = t.Adj;
X
X	/* Add the character strings into a character array */
X	addstring (t.twinit);
X	addstring (t.twrest);
X	addstring (t.twnl);
X	addstring (t.hlr);
X	addstring (t.hlf);
X	addstring (t.flr);
X	addstring (t.bdon);
X	addstring (t.bdoff);
X	addstring (t.iton);
X	addstring (t.itoff);
X	addstring (t.ploton);
X	addstring (t.plotoff);
X	addstring (t.up);
X	addstring (t.down);
X	addstring (t.right);
X	addstring (t.left);
X	for (i = 0; i < 256 - 32; i++) addstring (t.codetab[i]);
X
X	/* eliminate strings which are tails of other strings */
X	for (i = 0; i < n_strings; i++) {
X	    i_len = strlen (c_pointer[i]);
X	    for (j = 0; j < n_strings; j++) {
X		if (i == j) continue;
X		j_len = strlen (c_pointer[j]);
X		if (i_len <= j_len) {	/* string i could be tail of string j */
X		    tail = c_pointer[j] + j_len - i_len;
X		    if (! strcmp (c_pointer[i], tail)) {
X			clearstring (c_pointer[i]);
X			break;
X			}
X		    }
X		}
X	    }
X
X	/* Compress the c_data array to eliminate strings of nulls */
X	for (i = j = 0; i < n_strings; i++) {
X	    if (! *c_pointer[i]) continue;
X	    tail = strlen (strcpy (c_pointer[j], c_pointer[i])) +
X		    c_pointer[j] + 1;
X	    c_pointer[++j] = tail;
X	    }
X
X	c_size = c_pointer[j] - c_data;	/* The amount of data to be stored */
X
X	/* Now find each string in this table and provide an index to it */
X	t_stor.twinit = findstring (t.twinit);
X	t_stor.twrest = findstring (t.twrest);
X	t_stor.twnl = findstring (t.twnl);
X	t_stor.hlr = findstring (t.hlr);
X	t_stor.hlf = findstring (t.hlf);
X	t_stor.flr = findstring (t.flr);
X	t_stor.bdon = findstring (t.bdon);
X	t_stor.bdoff = findstring (t.bdoff);
X	t_stor.iton = findstring (t.iton);
X	t_stor.itoff = findstring (t.itoff);
X	t_stor.ploton = findstring (t.ploton);
X	t_stor.plotoff = findstring (t.plotoff);
X	t_stor.up = findstring (t.up);
X	t_stor.down = findstring (t.down);
X	t_stor.right = findstring (t.right);
X	t_stor.left = findstring (t.left);
X	for (i = 0; i < 256 - 32; i++) {
X	    t_stor.codetab[i] = findstring (t.codetab[i]);
X	    }
X	t_stor.zzz = 0;
X
X	/* Write the character storage block size */
X	if (fwrite (&c_size, sizeof (c_size), 1, table) != 1)
X	    write_err ();
X
X	if (fwrite (&t_stor, sizeof (t_stor), 1, table) != 1)
X	    write_err ();
X
X	if (fwrite (c_data, sizeof (*c_data), c_size, table) != c_size)
X	    write_err ();
X
X	if (fclose (table)) {
X	    fprintf (stderr, "File %s not closed properly\n", argv[1]);
X	    exit (1);
X	    }
X	}
X
Xaddstring (string)
Xchar	*string;
X{
X	c_pointer[n_strings] = c_end;
X	c_end += strlen (string) + 1;
X	if (c_end >= c_data + C_SIZE) {
X	    fprintf (stderr, "Table size too small, increase it!/n");
X	    exit(1);
X	    }
X	strcpy (c_pointer[n_strings++], string);
X}
X
Xclearstring (string)
Xchar	*string;
X{
X	while (*string) *string++ = 0;
X}
X
Xfindstring (string)
Xchar	*string;
X{
X	int	c_len, s_len, i;
X
X	for (i = 0; c_pointer[i]; i++) {
X	    if ((c_len = strlen (c_pointer[i])) >= (s_len = strlen (string))) {
X		if (!strcmp (string, c_pointer[i] + c_len - s_len))
X		    return (c_pointer[i] + c_len - s_len - c_data);
X		}
X	    }
X	fprintf (stderr, "Serious bug! string not found in table\n");
X	exit(1);
X	/* NOT REACHED */
X	}
X
X
X
Xwrite_err () {
X	fprintf (stderr, "Write to file failed\n");
X	exit (1);
X	}
SHAR_EOF
if test 9208 -ne "`wc -c 'table.c'`"
then
	echo shar: error transmitting "'table.c'" '(should have been 9208 characters)'
fi
echo shar: extracting "'table.doc'" '(6059 characters)'
if test -f 'table.doc'
then
	echo shar: over-writing existing file "'table.doc'"
fi
sed 's/^X//' << \SHAR_EOF > 'table.doc'
X	This file contains some documentation for the table program.
XThis program makes printer and terminal driver tables suitable for
Xnroff. The development of this program was motivated by the lack of
Xany other means to prepare custom nroff driver tables, for those
Xsystems which do not have the original source that prepared the driver
Xtables (usually found in /usr/lib/term).
X	The format for the tables imbodied in this program was deduced
Xfrom a "term" manual page, and by examining the contents of several
Xexisting tab files. Therefore, this program is not definitive in
Xany sense, but is intended as a help for those who (like myself) do
Xnot have access to any formal tools that make these tab files.
X	Also it is possible that this program will require modification
Xfor systems where the size of an integer is not 32 bits. The system
Xthat this program was developed on is an HP9000 (System III) and the
Xdata sizes are:
X		long	32
X		int	32
X		short	16
X		char	 8
XAs I have not had access to different machines, I do not know whether
Xcertain data in the tab file is of int or long type, since that type
Xis the same on our machine. I have assumed int type.
X
XIf your luck is really bad, I suppose it is possible that the format
Xof the tab file is different across various implementations.
X
XThe format of the tab file is:
XType	Name		Size on HP9000		Description
X----	----		--------------		-----------
Xint	c_size		4 bytes	- The amount of character data in bytes
X				that follows the t_stor structure. In fact
X				the size of the file in bytes should be:
X				c_size + sizeof (c_size) + sizeof (t_stor)
X				(On our machine: c_size + 1004)
X
Xstruct {		1000 bytes - This is the storage for the "t"
X	int bset;		structure with one change. All the elements
X	int breset;		of the t structure which were pointers to
X	int Hor;		strings are now integer indexes to one
X	int Vert;		large character array.
X	int Newline;
X	int Char;
X	int Em;
X	int Halfline;
X	int Adj;
X	int twinit;
X	int twrest;
X	int twnl;
X	int hlr;
X	int hlf;
X	int flr;
X	int bdon;
X	int bdoff;
X	int iton;
X	int itoff;
X	int ploton;
X	int plotoff;
X	int up;
X	int down;
X	int right;
X	int left;
X	int codetab[256-32];
X	int zzz;
X} t_stor;
X
Xchar	array[c_size]	(variable size)- This is the storage for the strings
X					pointed to by the indexes.
X
X		How to Use the Table Program
X		----------------------------
XExamine the "term" manual page which explains the purpose of each of
Xthe items in the "t" structure. Make a copy of the table.c program
Xand edit it. Initialize the t structure (not the t_stor structure!)
Xto the integer or character string values that are necessary for the
Xterminal or printer in question. You have a high degree of flexibility
Xhere, and variable width characters, overstrike combinations, etc are
Xeasy to implement.
X
XThe only catch here is determining which index of the t.codetab[] array
Xcorresponds to which nroff printable character. This information is not
Xin the manual page. After some experimentation, I have made a table
Xwhich list the characters I know about. The table has some holes in it,
Xbut is as complete as I can make it. If anyone has additions or
Xcorrections, please let me know. The table is found in the file
Xcharlist.
X
XIf the amount of char data is very large, you may need to increase the
Xdefinition of C_SIZE. It is now set at 10000 characters.
X
XThe t.bset and t.breset flags will need definitions from either
X<termio.h> or <sgtty.h>. Include whichever is appropriate for your
Xsystem.
X
XAfter the table.c file has been edited, compile it with:
X	cc -O table.c -o table
X
XRun it as:
X	table filename
Xwhere filename is of the form: tab*
Xfor example, tab630P, possibly for a Diablo 630 (proportional space)
X
XPlace this file in the proper directory (/usr/lib/term on our system)
Xand run nroff as (for example):
X	nroff -T630P ...
X
XDebugging is not easy.
X
X
X		Some Notes and Observations
X		---------------------------
X
X	1) One curious feature seems to be that, unlike the other
Xcharacter strings in t.codetab, the space string does not require
Xany output characters other than the first byte (which defines the
Xwidth). The output is apparently defined by the width only, and the
Xinformation given in t.Em (width of an actual space char), t.Adj,
Xt.right, etc.
X
X	2) The table.c program supplied with this package contains
Xa partial example of the initialization for a Diablo 630 in
Xproportional mode. It may be of help.
X
XAny other observations on the behaviour of nroff vis a vis the tab
Xfiles would be appreciated.
X
X
X		The Table Program
X		-----------------
X
XAs mentioned before, this program is not to be considered a
Xdefinitive one. It works for HP9000's as far as I can tell.
X
XHowever, it does have the feature of compressing the supplied
Xcharacter data as much as possible. If one string is the tail of
Xanother (e.g. the strings abcdef and def), than only the largest
Xstring is stored. The smaller is indexed into the middle of the
Xlarger. Repeated strings (including the null string) are only stored
Xonce.
X
XThe program has not been extensively tested. There may be bugs or
Xmisinformation. Let me know of any problems.
X
XIf the tab files produced by this program do not work at all on your
Xsystem, then it may be that the data types for c_size, and
Xt_stor.whatever are incorrect. (Long instead of int?) You can get an
Xindication by looking at the first word (int or long?) of an
Xexisting tab file. This is the amount of char data stored in the
Xfile. Subtract it from the size of the file in bytes. The result
Xwill be the size of the t_stor structure plus the size of the c_size
Xvariable. The t_stor structure has 250 elements in it. If each is
X4 bytes, as on our system, and the c_size variable is 4 bytes also,
Xthen the result of the previous subtraction should be 1004. If
Xthe sizeof(int) on your system is 16 bits, then the difference
Xshould be 502. If it is not, then perhaps the types (some or all)
Xof c_size, and the elements in t_stor should be changed to reflect
Xthis.
X
X			Good luck!
X
XI can be reached at:
X
X		utcs!bnr-vpa!bruce			(UUCP)
Xor		(613) 726 - 3008			(Phone)
X		(Ottawa, Canada)
X
SHAR_EOF
if test 6059 -ne "`wc -c 'table.doc'`"
then
	echo shar: error transmitting "'table.doc'" '(should have been 6059 characters)'
fi
#	End of shell archive
exit 0
-- 
			-Bruce Townsend

			Voice Processing Applications,
			Bell Northern Research,
			Ottawa, Ontario.

Mail path: {utzoo, utcs, bnr-di, bnr-mtl}!bnr-vpa!bruce



More information about the Comp.sources.unix mailing list