# # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # # Copyright (c) 1989 by Sun Microsystems, Inc. # # Copyright (c) 2018, Joyent, Inc. include ../Makefile.cmd PROG = tbl SRCS = t0.c t1.c t2.c t3.c t4.c t5.c t6.c t7.c \ t8.c t9.c tb.c tc.c te.c tf.c tg.c ti.c \ tm.c ts.c tt.c tu.c tv.c OBJS = $(SRCS:%.c=%.o) POFILES= $(OBJS:%.o=%.po) POFILE= tbl.po CERRWARN += -Wno-implicit-function-declaration CERRWARN += -Wno-parentheses CERRWARN += $(CNOWARN_UNINIT) CERRWARN += -Wno-char-subscripts # Hammerhead: Suppress pointer/int cast warnings in legacy tbl code CERRWARN += -Wno-pointer-to-int-cast CERRWARN += -Wno-int-to-pointer-cast # not linted SMATCH=off .KEEP_STATE : all : $(PROG) $(PROG): $(OBJS) $(LINK.c) -o $@ $(OBJS) $(LDLIBS) $(POST_PROCESS) $(POFILE): $(POFILES) $(RM) $@ cat $(POFILES) > $@ install : all $(ROOTPROG) clean : $(RM) $(OBJS) lint: lint_SRCS strip : $(STRIP) $(PROG) include ../Makefile.targ Copyright (c) 1980 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. All advertising materials mentioning features or use of this software must display the following acknowledgement: This product includes software developed by the University of California, Berkeley and its contributors. 4. 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 COPYRIGHT OWNER 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. PORTIONS OF TBL COMMAND FUNCTIONALITY /* * Copyright 1998 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* t..c : external declarations */ # include "stdio.h" # include "ctype.h" # define MAXLIN 200 # define MAXHEAD 100 # define MAXCOL 20 # define MAXCHS 2000 # define MAXSTR 1024 # define MAXRPT 100 # define CLLEN 10 # define SHORTLINE 4 # define BIGBUF 8192 extern char *gets1(char *, int); extern int nlin, ncol, iline, nclin, nslin; extern int style[MAXHEAD][MAXCOL]; extern int ctop[MAXHEAD][MAXCOL]; extern char font[MAXHEAD][MAXCOL][2]; extern char csize[MAXHEAD][MAXCOL][4]; extern char vsize[MAXHEAD][MAXCOL][4]; extern char cll[MAXCOL][CLLEN]; extern int stynum[]; extern int F1, F2; extern int lefline[MAXHEAD][MAXCOL]; extern int fullbot[]; extern char *instead[]; extern int expflg; extern int ctrflg; extern int evenflg; extern int evenup[]; extern int boxflg; extern int dboxflg; extern int linsize; extern int tab; extern int pr1403; extern int linsize, delim1, delim2; extern int allflg; extern int textflg; extern int left1flg; extern int rightl; struct colstr {char *col, *rcol;}; extern struct colstr *table[]; extern int *alocv(int); extern char *cspace, *cstore; extern char *chspace(void); extern char *maknew(char *); extern char *exstore, *exlim; extern int sep[]; extern int used[], lused[], rused[]; extern int linestop[]; extern char *leftover; extern char *last, *ifile; extern int texname; extern int texct; extern char texstr[]; extern int linstart; extern FILE *tabin, *tabout; # define CRIGHT 80 # define CLEFT 40 # define CMID 60 # define S1 31 # define S2 32 # define TMP 38 # define SF 35 # define SL 34 # define LSIZE 33 # define SIND 37 # define SVS 36 /* this refers to the relative position of lines */ # define LEFT 1 # define RIGHT 2 # define THRU 3 # define TOP 1 # define BOT 2 /* * Copyright 1990 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* t0.c: storage allocation */ # # include "t..c" int expflg = 0; int ctrflg = 0; int boxflg = 0; int dboxflg = 0; int tab = '\t'; int linsize; int pr1403; int delim1, delim2; int evenup[MAXCOL], evenflg; int F1 = 0; int F2 = 0; int allflg = 0; char *leftover = 0; int textflg = 0; int left1flg = 0; int rightl = 0; char *cstore, *cspace; char *last; struct colstr *table[MAXLIN]; int style[MAXHEAD][MAXCOL]; int ctop[MAXHEAD][MAXCOL]; char font[MAXHEAD][MAXCOL][2]; char csize[MAXHEAD][MAXCOL][4]; char vsize[MAXHEAD][MAXCOL][4]; int lefline[MAXHEAD][MAXCOL]; char cll[MAXCOL][CLLEN]; /*char *rpt[MAXHEAD][MAXCOL];*/ /*char rpttx[MAXRPT];*/ int stynum[MAXLIN+1]; int nslin, nclin; int sep[MAXCOL]; int fullbot[MAXLIN]; char *instead[MAXLIN]; int used[MAXCOL], lused[MAXCOL], rused[MAXCOL]; int linestop[MAXLIN]; int nlin, ncol; int iline = 1; char *ifile = "Input"; int texname = 'a'; int texct = 0; char texstr[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYXZ0123456789"; int linstart; char *exstore, *exlim; FILE *tabin /*= stdin */; FILE *tabout /* = stdout */; /* * Copyright 1998 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* t1.c: main control and input switching */ # #include # include "t..c" #include #include # ifdef gcos /* required by GCOS because file is passed to "tbl" by troff preprocessor */ # define _f1 _f extern FILE *_f[]; # endif # ifdef unix # define MACROS "/usr/doctools/tmac/tmac.s" # define MACROSS "/usr/share/lib/tmac/s" # define PYMACS "/usr/doctools/tmac/tmac.m" # define PYMACSS "/usr/share/lib/tmac/m" # define MEMACSS "/usr/share/lib/tmac/e" # endif # ifdef gcos # define MACROS "cc/troff/smac" # define PYMACS "cc/troff/mmac" # endif # define ever (;;) void setinp(int, char **); int main(int argc, char **argv) { # ifdef unix void badsig(); # endif (void) setlocale(LC_ALL, ""); #if !defined(TEXT_DOMAIN) #define TEXT_DOMAIN "SYS_TEST" #endif (void) textdomain(TEXT_DOMAIN); # ifdef unix signal(SIGPIPE, badsig); # endif # ifdef gcos if(!intss()) tabout = fopen("qq", "w"); /* default media code is type 5 */ # endif exit(tbl(argc,argv)); } int tbl(int argc, char **argv) { char line[BIGBUF]; /* required by GCOS because "stdout" is set by troff preprocessor */ tabin=stdin; tabout=stdout; setinp(argc,argv); while (gets1(line, sizeof line)) { fprintf(tabout, "%s\n",line); if (prefix(".TS", line)) tableput(); } fclose(tabin); return(0); } int sargc; char **sargv; void setinp(int argc, char **argv) { sargc = argc; sargv = argv; sargc--; sargv++; if (sargc>0) swapin(); } int swapin(void) { while (sargc>0 && **sargv=='-') /* Mem fault if no test on sargc */ { if (sargc<=0) return(0); if (match("-me", *sargv)) { *sargv = MEMACSS; break; } if (match("-ms", *sargv)) { *sargv = MACROSS; break; } if (match("-mm", *sargv)) { *sargv = PYMACSS; break; } if (match("-TX", *sargv)) pr1403=1; else { (void) fprintf(stderr, gettext("tbl: Invalid option " "(%s).\n"), *sargv); (void) fprintf(stderr, gettext("Usage: tbl [ -me ] " "[ -mm ] [ -ms ] [ filename ] ...\n")); exit(1); } sargc--; sargv++; } if (sargc<=0) return(0); # ifdef unix /* file closing is done by GCOS troff preprocessor */ if (tabin!=stdin) fclose(tabin); # endif tabin = fopen(ifile= *sargv, "r"); iline=1; # ifdef unix /* file names are all put into f. by the GCOS troff preprocessor */ fprintf(tabout, ".ds f. %s\n",ifile); # endif if (tabin==NULL) error(gettext("Can't open file")); sargc--; sargv++; return(1); } # ifdef unix void badsig(void) { signal(SIGPIPE, SIG_IGN); exit(0); } # endif /* * Copyright 1990 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* t2.c: subroutine sequencing for one table */ # include "t..c" void tableput(void) { saveline(); savefill(); ifdivert(); cleanfc(); getcomm(); getspec(); gettbl(); getstop(); checkuse(); choochar(); maktab(); runout(); release(); rstofill(); endoff(); restline(); } /* * Copyright 1991 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* t3.c: interpret commands affecting whole table */ # include "t..c" #include struct optstr {char *optnam; int *optadd;} options [] = { "expand", &expflg, "EXPAND", &expflg, "center", &ctrflg, "CENTER", &ctrflg, "box", &boxflg, "BOX", &boxflg, "allbox", &allflg, "ALLBOX", &allflg, "doublebox", &dboxflg, "DOUBLEBOX", &dboxflg, "frame", &boxflg, "FRAME", &boxflg, "doubleframe", &dboxflg, "DOUBLEFRAME", &dboxflg, "tab", &tab, "TAB", &tab, "linesize", &linsize, "LINESIZE", &linsize, "delim", &delim1, "DELIM", &delim1, 0,0}; void backrest(char *); void getcomm(void) { char line[200], *cp, nb[25], *t; struct optstr *lp; int c, ci, found; for(lp= options; lp->optnam; lp++) *(lp->optadd) = 0; texname = texstr[texct=0]; tab = '\t'; printf(".nr %d \\n(.s\n", LSIZE); gets1(line, sizeof line); /* see if this is a command line */ if (strchr(line,';') == NULL) { backrest(line); return; } for(cp=line; (c = *cp) != ';'; cp++) { if (!letter(c)) continue; found=0; for(lp= options; lp->optadd; lp++) { if (prefix(lp->optnam, cp)) { *(lp->optadd) = 1; cp += strlen(lp->optnam); if (letter(*cp)) error(gettext("Misspelled global option")); while (*cp==' ')cp++; t=nb; if ( *cp == '(') while ((ci= *++cp) != ')') *t++ = ci; else cp--; *t++ = 0; *t=0; if (lp->optadd == &tab) { if (nb[0]) *(lp->optadd) = nb[0]; } if (lp->optadd == &linsize) printf(".nr %d %s\n", LSIZE, nb); if (lp->optadd == &delim1) { delim1 = nb[0]; delim2 = nb[1]; } found=1; break; } } if (!found) error(gettext("Illegal option")); } cp++; backrest(cp); return; } void backrest(char *cp) { char *s; for(s=cp; *s; s++); un1getc('\n'); while (s>cp) un1getc(*--s); return; } /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* t4.c: read table specification */ # include "t..c" int oncol; void readspec(void); void getspec(void) { int icol, i; for(icol=0; icol0) {ncol++; rightl++;}; if(sawchar) nclin++; if (nclin>=MAXHEAD) error(gettext("too many lines in specification")); icol=0; if (ncol==0 || nclin==0) error(gettext("no specification")); if (c== '.') { while ((c=get1char()) && c != '\n') if (c != ' ' && c != '\t') error(gettext("dot not last character on format line")); /* fix up sep - default is 3 except at edge */ for(icol=0; icol=MAXCOL) error(gettext("too many columns in table")); sawchar=1; continue; case 'b': case 'i': c += 'A'-'a'; /* FALLTHRU */ case 'B': case 'I': if (sawchar == 0) continue; if (icol==0) continue; snp=font[nclin][icol-1]; snp[0]= (c=='I' ? '2' : '3'); snp[1]=0; continue; case 't': case 'T': if (sawchar == 0) { continue; } if (icol>0) ctop[nclin][icol-1] = 1; continue; case 'd': case 'D': if (sawchar == 0) continue; if (icol>0) ctop[nclin][icol-1] = -1; continue; case 'f': case 'F': if (sawchar == 0) continue; if (icol==0) continue; snp=font[nclin][icol-1]; snp[0]=snp[1]=stopc=0; for(i=0; i<2; i++) { c = get1char(); if (i==0 && c=='(') { stopc=')'; c = get1char(); } if (c==0) break; if (c==stopc) {stopc=0; break;} if (stopc==0) if (c==' ' || c== tab ) break; if (c=='\n'){un1getc(c); break;} snp[i] = c; if (c>= '0' && c<= '9') break; } if (stopc) if (get1char()!=stopc) error(gettext("Nonterminated font name")); continue; case 'P': case 'p': if (sawchar == 0) continue; if (icol<=0) continue; temp = snp = csize[nclin][icol-1]; while (c = get1char()) { if (c== ' ' || c== tab || c=='\n') break; if (c=='-' || c == '+') if (snp>temp) break; else *snp++=c; else if (digit(c)) *snp++ = c; else break; if (snp-temp>4) error(gettext("point size too large")); } *snp = 0; if (atoi(temp)>36) error(gettext("point size unreasonable")); un1getc (c); continue; case 'V': case 'v': if (sawchar == 0) continue; if (icol<=0) continue; temp = snp = vsize[nclin][icol-1]; while (c = get1char()) { if (c== ' ' || c== tab || c=='\n') break; if (c=='-' || c == '+') if (snp>temp) break; else *snp++=c; else if (digit(c)) *snp++ = c; else break; if (snp-temp>4) error( gettext("vertical spacing value too large") ); } *snp=0; un1getc(c); continue; case 'w': case 'W': if (sawchar == 0) { /* * This should be an error case. * However, for the backward-compatibility, * treat as if 'c' was specified. */ style[nclin][icol] = 'c'; icol++; if (icol >= MAXCOL) { error(gettext( "too many columns in table")); } sawchar = 1; } snp = cll [icol-1]; /* Dale Smith didn't like this check * possible to have two text blocks * of different widths now .... if (*snp) { fprintf(tabout, gettext("Ignored second width specification")); continue; } * end commented out code ... */ stopc=0; while (c = get1char()) { if (snp==cll[icol-1] && c=='(') { stopc = ')'; continue; } if ( !stopc && (c>'9' || c< '0')) break; if (stopc && c== stopc) break; *snp++ =c; } *snp=0; if (snp-cll[icol-1]>CLLEN) error (gettext("column width too long")); if (!stopc) un1getc(c); continue; case 'e': case 'E': if (sawchar == 0) continue; if (icol<1) continue; evenup[icol-1]=1; evenflg=1; continue; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': sn[0] = c; snp=sn+1; while (digit(*snp++ = c = get1char())) ; un1getc(c); sep[icol-1] = max(sep[icol-1], numb(sn)); continue; case '|': lefline[nclin][icol]++; if (icol==0) left1flg=1; continue; } } error(gettext("EOF reading table specification")); } /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* t5.c: read data for table */ # include "t..c" void permute(void); void gettbl(void) { int icol, ch; cstore=cspace= chspace(); textflg=0; for (nlin=nslin=0; gets1(cstore, MAXSTR); nlin++) { stynum[nlin]=nslin; if (prefix(".TE", cstore)) { leftover=0; break; } if (prefix(".TC", cstore) || prefix(".T&", cstore)) { readspec(); nslin++; } if (nlin>=MAXLIN) { leftover=cstore; break; } fullbot[nlin]=0; if (cstore[0] == '.' && !isdigit((unsigned char)cstore[1])) { instead[nlin] = cstore; while (*cstore++); continue; } else instead[nlin] = 0; if (nodata(nlin)) { if (ch = oneh(nlin)) fullbot[nlin]= ch; nlin++; nslin++; instead[nlin]=(char *)0; fullbot[nlin]=0; } table[nlin] = (struct colstr *) alocv((ncol+2)*sizeof(table[0][0])); if (cstore[1]==0) switch(cstore[0]) { case '_': fullbot[nlin]= '-'; continue; case '=': fullbot[nlin]= '='; continue; } stynum[nlin] = nslin; nslin = min(nslin+1, nclin-1); for (icol = 0; icol MAXCHS) cstore = cspace = chspace(); } last = cstore; permute(); if (textflg) untext(); return; } int nodata(int il) { int c; for (c=0; c=nlin)return(0); if (instead[ir]) return(0); if (ifform==0 && ctype(ir,ij)=='^') return(1); if (table[ir]==0) return(0); if (table[ir][ij].rcol!=0) return(0); if (fullbot[ir]) return(0); return(vspen(table[ir][ij].col)); } int vspen(char *s) { if (s==0) return(0); if (!point(s)) return(0); return(match(s, SPAN)); } /* * Copyright 1990 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* t6.c: compute tab stops */ # define tx(a) (a>(char *)0 && a<(char *)128) # include "t..c" void wide(char *, char *, char *); void maktab(void) { # define FN(i,c) font[stynum[i]][c] # define SZ(i,c) csize[stynum[i]][c] /* define the tab stops of the table */ int icol, ilin, tsep, k, ik, vforml, il, text; int doubled[MAXCOL], acase[MAXCOL]; char *s; for(icol=0; icol =0 && vspen(table[il][icol].col); il=prev(il)) vforml=il; if (fspan(vforml,icol)) continue; if (filler(table[ilin][icol].col)) continue; switch(ctype(vforml,icol)) { case 'a': acase[icol]=1; s = table[ilin][icol].col; if (s>(char *)0 && s<(char *)128 && text) { if (doubled[icol]==0) fprintf(tabout, ".nr %d 0\n.nr %d 0\n",S1,S2); doubled[icol]=1; fprintf(tabout, ".if \\n(%c->\\n(%d .nr %d \\n(%c-\n",s,S2,S2,s); } /* FALLTHROUGH */ case 'n': if (table[ilin][icol].rcol!=0) { if (doubled[icol]==0 && text==0) fprintf(tabout, ".nr %d 0\n.nr %d 0\n", S1, S2); doubled[icol]=1; if (real(s=table[ilin][icol].col) && !vspen(s)) { if (tx(s) != text) continue; fprintf(tabout, ".nr %d ", TMP); wide(s, FN(vforml,icol), SZ(vforml,icol)); fprintf(tabout, "\n"); fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S1, TMP, S1, TMP); } if (text==0 && real(s=table[ilin][icol].rcol) && !vspen(s) && !barent(s)) { fprintf(tabout, ".nr %d \\w%c%s%c\n",TMP, F1, s, F1); fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n",S2,TMP,S2,TMP); } continue; } /* FALLTHROUGH */ case 'r': case 'c': case 'l': if (real(s=table[ilin][icol].col) && !vspen(s)) { if (tx(s) != text) continue; fprintf(tabout, ".nr %d ", TMP); wide(s, FN(vforml,icol), SZ(vforml,icol)); fprintf(tabout, "\n"); fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", icol+CRIGHT, TMP, icol+CRIGHT, TMP); } } } } if (acase[icol]) { fprintf(tabout, ".if \\n(%d>=\\n(%d .nr %d \\n(%du+2n\n",S2,icol+CRIGHT,icol+CRIGHT,S2); } if (doubled[icol]) { fprintf(tabout, ".nr %d \\n(%d\n", icol+CMID, S1); fprintf(tabout, ".nr %d \\n(%d+\\n(%d\n",TMP,icol+CMID,S2); fprintf(tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n",TMP,icol+CRIGHT,icol+CRIGHT,TMP); fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d +(\\n(%d-\\n(%d)/2\n",TMP,icol+CRIGHT,icol+CMID,icol+CRIGHT,TMP); } if (cll[icol][0]) { fprintf(tabout, ".nr %d %sn\n", TMP, cll[icol]); fprintf(tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n",icol+CRIGHT, TMP, icol+CRIGHT, TMP); } for(ilin=0; ilin=0; ik--) { fprintf(tabout, "-\\n(%d",CRIGHT+icol-ik); if (!expflg && ik>0) fprintf(tabout, "-%dn", sep[icol-ik]); } fprintf(tabout, "\n"); fprintf(tabout, ".if \\n(%d>0 .nr %d \\n(%d/%d\n", TMP, TMP, TMP, k); fprintf(tabout, ".if \\n(%d<0 .nr %d 0\n", TMP, TMP); for(ik=0; ik\\n(%d .nr %d \\n(%d\n", icol+CRIGHT, TMP, TMP, icol+CRIGHT); } for(icol=0; icol0 .nr %d +12u\n",icol+CMID, icol+CMID); */ } tsep=sep[icol]; } if (rightl) fprintf(tabout, ".nr %d (\\n(%d+\\n(%d)/2\n",ncol+CRIGHT-1, ncol+CLEFT-1, ncol+CRIGHT-2); fprintf(tabout, ".nr TW \\n(%d\n", ncol+CRIGHT-1); if (boxflg || allflg || dboxflg) fprintf(tabout, ".nr TW +%d*\\n(%d\n", sep[ncol-1], TMP); fprintf(tabout, ".if t .if \\n(TW>\\n(.li .tm Table at line %d file %s is too wide - \\n(TW units\n", iline-1, ifile); return; } void wide(char *s, char *fn, char *size) { if (point(s)) { fprintf(tabout, "\\w%c", F1); if (*fn>0) putfont(fn); if (*size) putsize(size); fprintf(tabout, "%s", s); if (*fn>0) putfont("P"); if (*size) putsize("0"); fprintf(tabout, "%c",F1); } else fprintf(tabout, "\\n(%c-", s); } int filler(char *s) { return (point(s) && s[0]=='\\' && s[1] == 'R'); } /* * Copyright 1998 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* t7.c: control to write table entries */ # include "t..c" # define realsplit ((ct=='a'||ct=='n') && table[ldata][c].rcol) void need(void); void deftail(void); void runout(void) { int i; if (boxflg || allflg || dboxflg) need(); if (ctrflg) { fprintf(tabout, ".nr #I \\n(.i\n"); fprintf(tabout, ".in +(\\n(.lu-\\n(TWu-\\n(.iu)/2u\n"); } fprintf(tabout, ".fc %c %c\n", F1, F2); fprintf(tabout, ".nr #T 0-1\n"); deftail(); for(i=0; i=0 && vspen(table[lf][c].col); lf=prev(lf)) vforml=lf; if (fspan(vforml,c)) continue; switch(ct=ctype(vforml,c)) { case 'n': case 'a': if (table[ldata][c].rcol) if (lused[c]) /*Zero field width*/ fprintf(tabout, "\\n(%du ",c+CMID); /* FALLTHROUGH */ case 'c': case 'l': case 'r': if (realsplit? rused[c]: (used[c]+lused[c])) fprintf(tabout, "\\n(%du ",c+CRIGHT); continue; case 's': if (lspan(lform, c)) fprintf(tabout, "\\n(%du ", c+CRIGHT); continue; } } fprintf(tabout, "\n"); } int ifline(char *s) { if (!point(s)) return(0); if (s[0] == '\\') s++; if (s[1] ) return(0); if (s[0] == '_') return('-'); if (s[0] == '=') return('='); return(0); } void need(void) { int texlin, horlin, i; for(texlin = horlin = i = 0; i < nlin; i++) { if (allh(i)) horlin++; else if (instead[i] != 0) continue; else texlin++; } (void) fprintf(tabout, ".ne %dv+%dp\n", texlin, 2 * horlin); /* * For nroff runs, we need to reserve space for the full height of the * horizontal rules. If we don't reserve sufficient height, we'll have * problems trying to draw the vertical lines across the page boundary. */ (void) fprintf(tabout, ".if n .ne %dv\n", 2 * texlin + 2 * horlin + 2); } void deftail(void) { int i, c, lf, lwid; for(i=0; i=0 .nr #%c \\n(#T\n",linestop[i]+'a'-1); if (boxflg || allflg || dboxflg) { /* bottom of table line */ if (!pr1403) fprintf(tabout, ".if \\n(T. .vs \\n(.vu-\\n(.sp\n"); fprintf(tabout, ".if \\n(T. "); drawline(nlin,0,ncol, dboxflg ? '=' : '-',1,0); fprintf(tabout, "\n.if \\n(T. .vs\n"); /* T. is really an argument to a macro but because of eqn we don't dare pass it as an argument and reference by $1 */ } for(c=0; c=0) { fprintf(tabout, ".if \\n(#%c>=0 .sp -1\n",linestop[lf]+'a'-1); fprintf(tabout, ".if \\n(#%c>=0 ", linestop[lf]+'a'-1); tohcol(c); drawvert(lf, nlin-1, c, lwid); fprintf(tabout, "\\h'|\\n(TWu'\n"); } } if (boxflg || allflg || dboxflg) /* right hand line */ { fprintf(tabout, ".if \\n(#a>=0 .sp -1\n"); fprintf(tabout, ".if \\n(#a>=0 \\h'|\\n(TWu'"); drawvert (0, nlin-1, ncol, dboxflg? 2 : 1); fprintf(tabout, "\n"); } fprintf(tabout, ".ls\n"); fprintf(tabout, "..\n"); fprintf(tabout, ".ec\n"); } /* * Copyright 1996 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* t8.c: write out one line of output table */ # include "t..c" # include # define realsplit ((ct=='a'||ct=='n') && table[nl][c].rcol) int watchout; int once; int topat[MAXCOL]; void puttext(char *, char *, char *); void funnies(int, int); void putfont(char *); void putsize(char *); /* * parameters * * i: line number for deciding format * nl: line number for finding data usually identical */ void putline(int i, int nl) { int c, lf, ct, form, lwid, vspf, ip = -1, cmidx, exvspen, vforml; int vct, chfont; char *s, *size, *fn; watchout=vspf=exvspen=0; if (i==0) once=0; if (i==0 && ( allflg || boxflg || dboxflg)) fullwide(0, dboxflg? '=' : '-'); if (instead[nl]==0 && fullbot[nl] ==0) for(c=0; c(char *)0 && s<(char *)128) fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s); continue; } if (point(s)) continue; fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s); watchout=1; } if (linestop[nl]) fprintf(tabout, ".mk #%c\n", linestop[nl]+'a'-1); lf = prev(nl); if (instead[nl]) { puts(instead[nl]); return; } if (fullbot[nl]) { switch (ct=fullbot[nl]) { case '=': case '-': fullwide(nl,ct); } return; } for(c=0; c=0) if (vspen(table[lf][c].col)) vspf=1; } if (vspf) { fprintf(tabout, ".nr #^ \\n(\\*(#du\n"); fprintf(tabout, ".nr #- \\n(#^\n"); /* current line position relative to bottom */ } vspf=0; chfont=0; for(c=0; c=0 && vspen(table[lf][c].col)) fprintf(tabout, ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",s,'a'+c,s,'a'+c); else fprintf(tabout, ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",s,s); } if (allflg && once>0 ) fullwide(i,'-'); once=1; runtabs(i, nl); if (allh(nl) && !pr1403) { fprintf(tabout, ".nr %d \\n(.v\n", SVS); fprintf(tabout, ".vs \\n(.vu-\\n(.sp\n"); } if (chfont) fprintf(tabout, ".nr %2d \\n(.f\n", S1); fprintf(tabout, ".nr 35 1m\n"); fprintf(tabout, "\\&"); vct = 0; for(c=0; c=0) { tohcol(c); drawvert(lf, i, c, lwid); vct += 2; } if (rightl && c+1==ncol) continue; vforml=i; for(lf=prev(nl); lf>=0 && vspen(table[lf][c].col); lf=prev(lf)) vforml= lf; form= ctype(vforml,c); if (form != 's') { ct = c+CLEFT; if (form=='a') ct = c+CMID; if (form=='n' && table[nl][c].rcol && lused[c]==0) ct= c+CMID; fprintf(tabout, "\\h'|\\n(%du'", ct); } s= table[nl][c].col; fn = font[stynum[vforml]][c]; size = csize[stynum[vforml]][c]; if (*size==0)size=0; switch(ct=ctype(vforml, c)) { case 'n': case 'a': if (table[nl][c].rcol) { if (lused[c]) /*Zero field width*/ { ip = prev(nl); if (ip>=0) if (vspen(table[ip][c].col)) { if (exvspen==0) { fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a'); if (cmidx) fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a'); vct++; fprintf(tabout, "'"); exvspen=1; } } fprintf(tabout, "%c%c",F1,F2); puttext(s,fn,size); fprintf(tabout, "%c",F1); } s= table[nl][c].rcol; form=1; break; } /* FALLTHROUGH */ case 'c': form=3; break; case 'r': form=2; break; case 'l': form=1; break; case '-': case '=': if (real(table[nl][c].col)) fprintf(stderr,gettext("%s: line %d: Data ignored on table line %d\n"), ifile, iline-1, i+1); makeline(i,c,ct); continue; default: continue; } if (realsplit ? rused[c]: used[c]) /*Zero field width*/ { /* form: 1 left, 2 right, 3 center adjust */ if (ifline(s)) { makeline(i,c,ifline(s)); continue; } if (filler(s)) { printf("\\l'|\\n(%du\\&%s'", c+CRIGHT, s+2); continue; } ip = prev(nl); cmidx = ctop[stynum[nl]][c]==0; if (ip>=0) if (vspen(table[ip][c].col)) { if (exvspen==0) { fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a'); if (cmidx) fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a'); vct++; fprintf(tabout, "'"); } } fprintf(tabout, "%c", F1); if (form!= 1) fprintf(tabout, "%c", F2); if (vspen(s)) vspf=1; else puttext(s, fn, size); if (form !=2) fprintf(tabout, "%c", F2); fprintf(tabout, "%c", F1); } if (ip>=0) if (vspen(table[ip][c].col)) { exvspen = (c+1 < ncol) && vspen(table[ip][c+1].col) && (topat[c] == topat[c+1]) && (cmidx == (ctop [stynum[nl]][c+1]==0)) && (left(i,c+1,&lwid)<0); if (exvspen==0) { fprintf(tabout, "\\v'(\\n(\\*(#du-\\n(^%cu", c+'a'); if (cmidx) fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a'); vct++; fprintf(tabout, "'"); } } else exvspen=0; /* if lines need to be split for gcos here is the place for a backslash */ if (vct > 7 && c < ncol) { fprintf(tabout, "\n.sp-1\n\\&"); vct=0; } } fprintf(tabout, "\n"); if (allh(nl) && !pr1403) fprintf(tabout, ".vs \\n(%du\n", SVS); if (watchout) funnies(i,nl); if (vspf) { for(c=0; c0) fprintf(tabout, "\\f\\n(%2d", S1); if (size!=0) putsize("0"); } } void funnies(int stl, int lin) { /* write out funny diverted things */ int c, s, pl, lwid, dv, lf, ct; char *fn; fprintf(tabout, ".mk ##\n"); /* rmember current vertical position */ fprintf(tabout, ".nr %d \\n(##\n", S1); /* bottom position */ for(c=0; c=0 && !isalpha(ct=ctype(pl,c)); pl=prev(pl)) ; switch (ct) { case 'n': case 'c': fprintf(tabout, "(\\n(%du+\\n(%du-\\n(%c-u)/2u\n",c+CLEFT,c-1+ctspan(lin,c)+CRIGHT, s); break; case 'l': fprintf(tabout, "\\n(%du\n",c+CLEFT); break; case 'a': fprintf(tabout, "\\n(%du\n",c+CMID); break; case 'r': fprintf(tabout, "\\n(%du-\\n(%c-u\n", c+CRIGHT, s); break; } fprintf(tabout, ".in +\\n(%du\n", SIND); fn=font[stynum[stl]][c]; putfont(fn); pl = prev(stl); if (stl>0 && pl>=0 && vspen(table[pl][c].col)) { fprintf(tabout, ".sp |\\n(^%cu\n", 'a'+c); if (ctop[stynum[stl]][c]==0) { fprintf(tabout, ".nr %d \\n(#-u-\\n(^%c-\\n(%c|+1v\n",TMP, 'a'+c, s); fprintf(tabout, ".if \\n(%d>0 .sp \\n(%du/2u\n", TMP, TMP); } } fprintf(tabout, ".%c+\n",s); fprintf(tabout, ".in -\\n(%du\n", SIND); if (*fn>0) putfont("P"); fprintf(tabout, ".mk %d\n", S2); fprintf(tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2, S1, S1, S2); } fprintf(tabout, ".sp |\\n(%du\n", S1); for(c=dv=0; c=0) { if (dv++ == 0) fprintf(tabout, ".sp -1\n"); tohcol(c); dv++; drawvert(lf, stl, c, lwid); } } if (dv) fprintf(tabout,"\n"); } void putfont(char *fn) { if (fn && *fn) fprintf(tabout, fn[1] ? "\\f(%.2s" : "\\f%.2s", fn); } void putsize(char *s) { if (s && *s) fprintf(tabout, "\\s%s",s); } /* * Copyright 2003 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* t9.c: write lines for tables over 200 lines */ # include "t..c" static int useln; void yetmore(void) { for(useln=0; useln=MAXLIN) error(gettext("Weird. No data in table.")); table[0]=table[useln]; for(useln=nlin-1; useln>=0 && (fullbot[useln] || instead[useln]); useln--); if (useln<0) error(gettext("Weird. No real lines in table.")); domore(leftover); while (gets1(cstore=cspace, MAXSTR) && domore(cstore)) ; last =cstore; return; } int domore(char *dataln) { int icol, ch; if (prefix(".TE", dataln)) return(0); if (dataln[0] == '.' && !isdigit((unsigned char)dataln[1])) { puts(dataln); return(1); } instead[0]=0; fullbot[0]=0; if (dataln[1]==0) switch(dataln[0]) { case '_': fullbot[0]= '-'; putline(useln,0); return(1); case '=': fullbot[0]= '='; putline(useln, 0); return(1); } for (icol = 0; icol void checkuse(void) { int i,c, k; for(c=0; c=MAXVEC) error(gettext("Too many characters in table")); spvecs[spcount++]= pp = calloc(MAXCHS+MAXSTR,1); if (pp == 0) error(gettext("no space for characters")); return(pp); } # define MAXPC 50 char *thisvec; int tpcount = -1; char *tpvecs[MAXPC]; int * alocv(int n) { int *tp, *q; if (tpcount<0 || thisvec+n > tpvecs[tpcount]+MAXCHS) { tpcount++; if (tpvecs[tpcount]==0) { tpvecs[tpcount] = calloc(MAXCHS,1); } thisvec = tpvecs[tpcount]; if (thisvec == 0) error(gettext("no space for vectors")); } tp=(int *)thisvec; thisvec+=n; for(q=tp; q<(int *)thisvec; q++) *q=0; return(tp); } void release(void) { extern char *exstore; /* give back unwanted space in some vectors */ spcount=0; tpcount= -1; exstore=0; } /* * Copyright 1991 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* tc.c: find character not in table to delimit fields */ # include "t..c" void choochar(void) { /* choose funny characters to delimit fields */ int had[128], ilin,icol, k; char *s; for(icol=0; icol<128; icol++) had[icol]=0; F1 = F2 = 0; for(ilin=0;ilin= 128 || s<0); } /* * Copyright 2005 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* te.c: error message control, input line count */ #include "t..c" #include #include #include #include void error(char *s) { (void) fprintf(stderr, gettext("\n%s: line %d: %s\n"), ifile, iline, s); (void) fprintf(stderr, gettext("tbl quits\n")); exit(1); } char * gets1(char *s, int len) { char *p; int nbl; while(len > 0) { iline++; while ((p = fgets(s,len,tabin))==0) { if (swapin()==0) return((char *)0); } while (*s) s++; s--; if (*s == '\n') { *s-- = '\0'; } else { if (!feof(tabin)) { if (ferror(tabin)) error(strerror(errno)); else error(gettext("Line too long")); } } for(nbl=0; *s == '\\' && s>p; s--) nbl++; if (linstart && nbl % 2) /* fold escaped nl if in table */ { s++; len -= s - p; continue; } break; } return(p); } # define BACKMAX 500 char backup[BACKMAX]; char *backp = backup; void un1getc(int c) { if (c=='\n') iline--; *backp++ = c; if (backp >= backup+BACKMAX) error(gettext("too much backup")); } int get1char(void) { int c; if (backp>backup) c = *--backp; else c=getc(tabin); if (c== EOF) /* EOF */ { if (swapin() ==0) error(gettext("unexpected EOF")); c = getc(tabin); } if (c== '\n') iline++; return(c); } /* * Copyright 1990 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* tf.c: save and restore fill mode around table */ # include "t..c" void savefill(void) { /* remembers various things: fill mode, vs, ps in mac 35 (SF) */ fprintf(tabout, ".de %d\n",SF); fprintf(tabout, ".ps \\n(.s\n"); fprintf(tabout, ".vs \\n(.vu\n"); fprintf(tabout, ".in \\n(.iu\n"); fprintf(tabout, ".if \\n(.u .fi\n"); fprintf(tabout, ".if \\n(.j .ad\n"); fprintf(tabout, ".if \\n(.j=0 .na\n"); fprintf(tabout, "..\n"); fprintf(tabout, ".nf\n"); /* set obx offset if useful */ fprintf(tabout, ".nr #~ 0\n"); fprintf(tabout, ".if n .nr #~ 0.6n\n"); } void rstofill(void) { fprintf(tabout, ".%d\n",SF); } void endoff(void) { int i; for(i=0; i\\n(.vu .sp \\n(%du-\\n(.vu\n", S2,S2); } if (cll[icol][0]) fprintf(tabout, ".ll %sn\n", cll[icol]); else fprintf(tabout, ".ll \\n(%du*%du/%du\n",SL,ctspan(ilin,icol),ncol+1); fprintf(tabout,".if \\n(.l<\\n(%d .ll \\n(%du\n", icol+CRIGHT, icol+CRIGHT); if (ctype(ilin,icol)=='a') fprintf(tabout, ".ll -2n\n"); fprintf(tabout, ".in 0\n"); while (gets1(line, sizeof line)) { if (line[0]=='T' && line[1]=='}' && line[2]== tab) break; if (match("T}", line)) break; fprintf(tabout, "%s\n", line); } if (fn && *fn) fprintf(tabout, ".ft \\n(%d\n", S1); if (sz && *sz) fprintf(tabout, ".br\n.ps\n.vs\n"); fprintf(tabout, ".br\n"); fprintf(tabout, ".di\n"); fprintf(tabout, ".nr %c| \\n(dn\n", texname); fprintf(tabout, ".nr %c- \\n(dl\n", texname); fprintf(tabout, "..\n"); fprintf(tabout, ".ec \\\n"); /* copy remainder of line */ if (line[2]) tcopy (sp, line+3); else *sp=0; oname=texname; texname = texstr[++texct]; return(oname); } void untext(void) { rstofill(); fprintf(tabout, ".nf\n"); fprintf(tabout, ".ll \\n(%du\n", SL); } /* * Copyright 1990 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* ti.c: classify line intersections */ # include "t..c" /* determine local environment for intersections */ int interv(int i, int c) { int ku, kl; if (c>=ncol || c == 0) { if (dboxflg) { if (i==0) return(BOT); if (i>=nlin) return(TOP); return(THRU); } if (c>=ncol) return(0); } ku = i>0 ? lefdata(i-1,c) : 0; if (i+1 >= nlin) kl=0; else kl = lefdata(allh(i) ? i+1 : i, c); if (ku==2 && kl==2) return(THRU); if (ku ==2) return(TOP); if (kl==BOT) return(2); return(0); } int interh(int i, int c) { int kl, kr; if (fullbot[i]== '=' || (dboxflg && (i==0 || i>= nlin-1))) { if (c==ncol) return(LEFT); if (c==0) return(RIGHT); return(THRU); } if (i>=nlin) return(0); kl = c>0 ? thish (i,c-1) : 0; if (kl<=1 && i>0 && allh(up1(i))) kl = c>0 ? thish(up1(i),c-1) : 0; kr = thish(i,c); if (kr<=1 && i>0 && allh(up1(i))) kr = c>0 ? thish(up1(i), c) : 0; if (kl== '=' && kr == '=') return(THRU); if (kl== '=') return(LEFT); if (kr== '=') return(RIGHT); return(0); } int up1(int i) { i--; while (instead[i] && i>0) i--; return(i); } /* * Copyright 1991 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* tm.c: split numerical fields */ # include "t..c" char * maknew(char *str) { /* make two numerical fields */ int c; char *dpoint, *p, *q, *ba; p = str; for (ba= 0; c = *str; str++) if (c == '\\' && *(str+1)== '&') ba=str; str=p; if (ba==0) { for (dpoint=0; *str; str++) { if (*str=='.' && !ineqn(str,p) && (str>p && digit(*(str-1)) || digit(*(str+1)))) dpoint=str; } if (dpoint==0) for(; str>p; str--) { if (digit( * (str-1) ) && !ineqn(str, p)) break; } if (!dpoint && p==str) /* not numerical, don't split */ return(0); if (dpoint) str=dpoint; } else str = ba; p =str; if (exstore ==0 || exstore >exlim) { exstore = chspace(); exlim= exstore+MAXCHS; } q = exstore; ba = exstore + MAXSTR; do { if (exstore > ba) error(gettext("numeric field too big")); } while (*exstore++ = *str++); *p = 0; return(q); } int ineqn (char *s, char *p) { /* true if s is in a eqn within p */ int ineq = 0, c; while (c = *p) { if (s == p) return(ineq); p++; if ((ineq == 0) && (c == delim1)) ineq = 1; else if ((ineq == 1) && (c == delim2)) ineq = 0; } return(0); } /* * Copyright 1990 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* ts.c: minor string processing subroutines */ int match(char *s1, char *s2) { while (*s1 == *s2) if (*s1++ == '\0') return(1); else s2++; return(0); } int prefix(char *small, char *big) { int c; while ((c= *small++) == *big++) if (c==0) return(1); return(c==0); } int letter(int ch) { if (ch >= 'a' && ch <= 'z') return(1); if (ch >= 'A' && ch <= 'Z') return(1); return(0); } int numb(char *str) { /* convert to integer */ int k; for (k=0; *str >= '0' && *str <= '9'; str++) k = k*10 + *str - '0'; return(k); } int digit(int x) { return(x>= '0' && x<= '9'); } int max(int a, int b) { return( a>b ? a : b); } void tcopy(char *s, char *t) { while (*s++ = *t++); } /* * Copyright 1990 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* tt.c: subroutines for drawing horizontal lines */ # include "t..c" int ctype(int il, int ic) { if (instead[il]) return(0); if (fullbot[il]) return(0); il = stynum[il]; return(style[il][ic]); } int min(int a, int b) { return(arcol : pc->col); if (s==0 || (point(s) && *s==0)) return(1); if (vspen(s)) return(1); if (t=barent( s)) return(t); return(0); } /* * Copyright 1990 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* tu.c: draws horizontal lines */ # include "t..c" void drawline(int, int, int, int, int, int); void makeline(int i, int c, int lintype) { int cr, type, shortl; type = thish(i,c); if (type==0) return; cr=c; shortl = (table[i][c].col[0]=='\\'); if (c>0 && !shortl && thish(i,c-1) == type)return; if (shortl==0) for(cr=c; cr < ncol && (ctype(i,cr)=='s'||type==thish(i,cr)); cr++); else for(cr=c+1; cr0 && vspand(prev(i),cl,1)) cl++; for(cr=cl; cr0 && vspand(prev(i),cr,1)) break; if (cl1) { switch(interv(i,cl)) { case TOP: exhl = ln==0 ? "1p" : "-1p"; break; case BOT: exhl = ln==1 ? "1p" : "-1p"; break; case THRU: exhl = "1p"; break; } if (exhl[0]) fprintf(tabout, "\\h'%s'", exhl); } else if (lcount==1) { switch(interv(i,cl)) { case TOP: case BOT: exhl = "-1p"; break; case THRU: exhl = "1p"; break; } if (exhl[0]) fprintf(tabout, "\\h'%s'", exhl); } if (lcount>1) { switch(interv(i,cr+1)) { case TOP: exhr = ln==0 ? "-1p" : "+1p"; break; case BOT: exhr = ln==1 ? "-1p" : "+1p"; break; case THRU: exhr = "-1p"; break; } } else if (lcount==1) { switch(interv(i,cr+1)) { case TOP: case BOT: exhr = "+1p"; break; case THRU: exhr = "-1p"; break; } } } else fprintf(tabout, "\\h'|\\n(%du'", cl+CLEFT); fprintf(tabout, "\\s\\n(%d",LSIZE); if (linsize) fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE); if (shortl) fprintf(tabout, "\\l'|\\n(%du'", cr+CRIGHT); else { lnch = "\\(ul"; if (pr1403) lnch = lintype==2 ? "=" : "\\(ru"; if (cr+1>=ncol) fprintf(tabout, "\\l'|\\n(TWu%s%s'", exhr,lnch); else fprintf(tabout, "\\l'(|\\n(%du+|\\n(%du)/2u%s%s'", cr+CRIGHT, cr+1+CLEFT, exhr, lnch); } if (linsize) fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE); fprintf(tabout, "\\s0"); } if (oldpos!=0) fprintf(tabout, "\\v'%dp'", -oldpos); if (!nodata) fprintf(tabout, "\\v'+.5m'"); } void getstop(void) { int i,c,k,junk, stopp; stopp=1; for(i=0; i=0 && linestop[k]==0) linestop[k]= ++stopp; } if (boxflg || allflg || dboxflg) linestop[0]=1; } int left(int i, int c, int *lwidp) { int kind, li, lj; /* returns -1 if no line to left */ /* returns number of line where it starts */ /* stores into lwid the kind of line */ *lwidp=0; kind = lefdata(i,c); if (kind==0) return(-1); if (i+1=0 && lefdata(i,c)==kind) i=prev(li=i); if (prev(li)== -1) li=0; *lwidp=kind; for(lj= i+1; lj=nlin) i=nlin-1; if (ctype(i,c) == 's') { for(ck=c; ctype(i,ck)=='s'; ck--); if (thish(i,ck)==0) return(0); } i =stynum[i]; i = lefline[i][c]; if (i>0) return(i); if (dboxflg && c==0) return(2); if (allflg)return(1); if (boxflg && c==0) return(1); return(0); } int next(int i) { while (i+1 =0 && (fullbot[i] || instead[i])) ; return(i); } /* * Copyright 1990 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ /* * Copyright (c) 1980 Regents of the University of California. * All rights reserved. The Berkeley software License Agreement * specifies the terms and conditions for redistribution. */ /* tv.c: draw vertical lines */ # include "t..c" void drawvert(int start, int end, int c, int lwid) { char *exb=0, *ext=0; int tp=0, sl, ln, pos, epb, ept, vm; end++; vm='v'; /* note: nr 35 has value of 1m outside of linesize */ while (instead[end]) end++; for(ln=0; ln1) switch(interh(start,c)) { case THRU: ept += 1; break; case LEFT: ept += (ln==0 ? 1 : -1); break; case RIGHT: ept += (ln==1 ? 1 : -1); break; } else if (lwid==1) switch(interh(start,c)) { case THRU: ept += 1; break; case LEFT: case RIGHT: ept -= 1; break; } if (exb) fprintf(tabout, "\\v'%s'", exb); if (epb) fprintf(tabout, "\\v'%dp'", epb); fprintf(tabout, "\\s\\n(%d",LSIZE); if (linsize) fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE); fprintf(tabout, "\\h'-\\n(#~u'"); /* adjustment for T450 nroff boxes */ fprintf(tabout, "\\L'|\\n(#%cu-%s", linestop[start]+'a'-1, vm=='v'? "1v" : "\\n(35u"); if (ext) fprintf(tabout, "-(%s)",ext); if (exb) fprintf(tabout, "-(%s)", exb); pos = ept-epb; if (pos) fprintf(tabout, "%s%dp", pos>=0? "+" : "", pos); /* the string #d is either "nl" or ".d" depending on diversions; on GCOS not the same */ fprintf(tabout, "'\\s0\\v'\\n(\\*(#du-\\n(#%cu+%s", linestop[start]+'a'-1,vm=='v' ? "1v" : "\\n(35u"); if (ext) fprintf(tabout, "+%s",ext); if (ept) fprintf(tabout, "%s%dp", (-ept)>0 ? "+" : "", (-ept)); fprintf(tabout, "'"); if (linsize) fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE); } } int midbar(int i, int c) { int k; k = midbcol(i,c); if (k==0 && c>0) k = midbcol(i, c-1); return(k); } int midbcol(int i, int c) { int ct; while ( (ct=ctype(i,c)) == 's') c--; if (ct=='-' || ct == '=') return(ct); if (ct=barent(table[i][c].col)) return(ct); return(0); } int barent(char *s) { if (s==0) return (1); if (!point(s)) return(1); if (s[0]== '\\') s++; if (s[1]!= 0) return(0); switch(s[0]) { case '_': return('-'); case '=': return('='); } return(0); }