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 */
11 * Copyright (c) 1980 Regents of the University of California.
12 * All rights reserved. The Berkeley software License Agreement
13 * specifies the terms and conditions for redistribution.
16 #pragma ident "%Z%%M% %I% %E% SMI"
18 /* t4.c: read table specification */
28 for(icol
=0; icol
<MAXCOL
; icol
++)
33 for(i
=0; i
<MAXHEAD
; i
++)
37 font
[i
][icol
][0] = lefline
[i
][icol
] = 0;
46 fprintf(tabout
, ".rm");
48 fprintf(tabout
, " %02d", 80+i
);
49 fprintf(tabout
, "\n");
55 int icol
, c
, sawchar
, stopc
, i
;
56 char sn
[10], *snp
, *temp
;
64 error(gettext("bad table specification character"));
65 case ' ': /* note this is also case tab */
68 if(sawchar
==0) continue;
70 case '.': /* end of table specification */
71 ncol
= max(ncol
, icol
);
72 if (lefline
[nclin
][ncol
]>0) {ncol
++; rightl
++;};
76 error(gettext("too many lines in specification"));
78 if (ncol
==0 || nclin
==0)
79 error(gettext("no specification"));
82 while ((c
=get1char()) && c
!= '\n')
83 if (c
!= ' ' && c
!= '\t')
84 error(gettext("dot not last character on format line"));
85 /* fix up sep - default is 3 except at edge */
86 for(icol
=0; icol
<ncol
; icol
++)
88 sep
[icol
] = icol
+1<ncol
? 3 : 1;
91 else if (oncol
+2 <ncol
)
92 error(gettext("tried to widen table in T&, not allowed"));
97 case 'C': case 'S': case 'R': case 'N': case 'L': case 'A':
99 case '_': if (c
=='_') c
= '-';
102 case 'c': case 's': case 'n': case 'r': case 'l': case 'a':
103 style
[nclin
][icol
]=c
;
104 if (c
== 's' && icol
<=0)
105 error(gettext("first column can not be S-type"));
106 if (c
=='s' && style
[nclin
][icol
-1] == 'a')
108 fprintf(tabout
, ".tm warning: can't span a-type cols, changed to l\n");
109 style
[nclin
][icol
-1] = 'l';
111 if (c
=='s' && style
[nclin
][icol
-1] == 'n')
113 fprintf(tabout
, ".tm warning: can't span n-type cols, changed to c\n");
114 style
[nclin
][icol
-1] = 'c';
117 if (c
=='^' && nclin
<=0)
118 error(gettext("first row can not contain vertical span"));
120 error(gettext("too many columns in table"));
129 if (icol
==0) continue;
130 snp
=font
[nclin
][icol
-1];
131 snp
[0]= (c
=='I' ? '2' : '3');
139 ctop
[nclin
][icol
-1] = 1;
145 ctop
[nclin
][icol
-1] = -1;
150 if (icol
==0) continue;
151 snp
=font
[nclin
][icol
-1];
152 snp
[0]=snp
[1]=stopc
=0;
162 if (c
==stopc
) {stopc
=0; break;}
163 if (stopc
==0) if (c
==' ' || c
== tab
) break;
164 if (c
=='\n'){un1getc(c
); break;}
166 if (c
>= '0' && c
<= '9') break;
168 if (stopc
) if (get1char()!=stopc
)
169 error(gettext("Nonterminated font name"));
174 if (icol
<=0) continue;
175 temp
= snp
= csize
[nclin
][icol
-1];
176 while (c
= get1char())
178 if (c
== ' ' || c
== tab
|| c
=='\n') break;
179 if (c
=='-' || c
== '+')
189 error(gettext("point size too large"));
193 error(gettext("point size unreasonable"));
199 if (icol
<=0) continue;
200 temp
= snp
= vsize
[nclin
][icol
-1];
201 while (c
= get1char())
203 if (c
== ' ' || c
== tab
|| c
=='\n') break;
204 if (c
=='-' || c
== '+')
215 gettext("vertical spacing value too large")
224 * This should be an error case.
225 * However, for the backward-compatibility,
226 * treat as if 'c' was specified.
228 style
[nclin
][icol
] = 'c';
230 if (icol
>= MAXCOL
) {
232 "too many columns in table"));
238 /* Dale Smith didn't like this check
239 * possible to have two text blocks
240 * of different widths now ....
244 gettext("Ignored second width specification"));
247 * end commented out code ... */
249 while (c
= get1char())
251 if (snp
==cll
[icol
-1] && c
=='(')
256 if ( !stopc
&& (c
>'9' || c
< '0'))
258 if (stopc
&& c
== stopc
)
263 if (snp
-cll
[icol
-1]>CLLEN
)
264 error (gettext("column width too long"));
271 if (icol
<1) continue;
275 case '0': case '1': case '2': case '3': case '4':
276 case '5': case '6': case '7': case '8': case '9':
279 while (digit(*snp
++ = c
= get1char()))
282 sep
[icol
-1] = max(sep
[icol
-1], numb(sn
));
285 lefline
[nclin
][icol
]++;
286 if (icol
==0) left1flg
=1;
290 error(gettext("EOF reading table specification"));