2 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 /* t5.c: read data for table */
26 cstore
=cspace
= chspace();
28 for (nlin
=nslin
=0; gets1(cstore
, MAXSTR
); nlin
++)
31 if (prefix(".TE", cstore
))
36 if (prefix(".TC", cstore
) || prefix(".T&", cstore
))
47 if (cstore
[0] == '.' && !isdigit((unsigned char)cstore
[1]))
49 instead
[nlin
] = cstore
;
53 else instead
[nlin
] = 0;
60 instead
[nlin
]=(char *)0;
63 table
[nlin
] = (struct colstr
*) alocv((ncol
+2)*sizeof(table
[0][0]));
67 case '_': fullbot
[nlin
]= '-'; continue;
68 case '=': fullbot
[nlin
]= '='; continue;
71 nslin
= min(nslin
+1, nclin
-1);
72 for (icol
= 0; icol
<ncol
; icol
++)
74 table
[nlin
][icol
].col
= cstore
;
75 table
[nlin
][icol
].rcol
=0;
77 if (match(cstore
, "T{")) /* text follows */
78 /* get_text was originally gettext and was renamed */
79 table
[nlin
][icol
].col
=
80 (char *)get_text(cstore
, nlin
, icol
,
81 font
[stynum
[nlin
]][icol
],
82 csize
[stynum
[nlin
]][icol
]);
85 for(; (ch
= *cstore
) != '\0' && ch
!= tab
; cstore
++)
88 switch(ctype(nlin
,icol
)) /* numerical or alpha, subcol */
91 table
[nlin
][icol
].rcol
=
92 (char *)maknew(table
[nlin
][icol
].col
);
95 table
[nlin
][icol
].rcol
= table
[nlin
][icol
].col
;
96 table
[nlin
][icol
].col
= "";
100 while (ctype(nlin
,icol
+1)== 's') /* spanning */
101 table
[nlin
][++icol
].col
= "";
102 if (ch
== '\0') break;
104 while (++icol
<ncol
+2)
106 table
[nlin
][icol
].col
= "";
107 table
[nlin
][icol
].rcol
=0;
109 while (*cstore
!= '\0')
111 if (cstore
-cspace
> MAXCHS
)
112 cstore
= cspace
= chspace();
116 if (textflg
) untext();
124 for (c
=0; c
<ncol
;c
++)
128 case 'c': case 'n': case 'r': case 'l': case 's': case 'a':
140 for(icol
=1; icol
<ncol
; icol
++)
142 if (k
!= ctype(lin
,icol
))
155 for(jcol
=0; jcol
<ncol
; jcol
++)
157 for(irow
=1; irow
<nlin
; irow
++)
159 if (vspand(irow
,jcol
,0))
163 error(gettext("Vertical spanning in first row not allowed"));
164 start
= table
[is
][jcol
].col
;
165 strig
= table
[is
][jcol
].rcol
;
166 while (irow
<nlin
&&vspand(irow
,jcol
,0))
168 table
[--irow
][jcol
].col
= start
;
169 table
[irow
][jcol
].rcol
= strig
;
172 table
[is
][jcol
].rcol
=0;
173 table
[is
][jcol
].col
= SPAN
;
182 vspand(int ir
, int ij
, int ifform
)
185 if (ir
>=nlin
)return(0);
186 if (instead
[ir
]) return(0);
187 if (ifform
==0 && ctype(ir
,ij
)=='^') return(1);
188 if (table
[ir
]==0) return(0);
189 if (table
[ir
][ij
].rcol
!=0) return(0);
190 if (fullbot
[ir
]) return(0);
191 return(vspen(table
[ir
][ij
].col
));
198 if (!point(s
)) return(0);
199 return(match(s
, SPAN
));