tbl: use \s(NN instead of \sNN
[troff.git] / tbl / tc.c
blob84f244528d517b8037812ed82676a7f85f91ecba
1 /* tc.c: find character not in table to delimit fields */
2 # include "t.h"
4 # define COMMON "\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*" \
5 "ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstwxyz"
7 void
8 choochar(void)
10 /* choose funny characters to delimit fields */
11 int had[128], ilin, icol, k;
12 char *s;
14 for (icol = 0; icol < 128; icol++)
15 had[icol] = 0;
16 F1 = F2 = 0;
17 for (ilin = 0; ilin < nlin; ilin++) {
18 if (instead[ilin] || fullbot[ilin])
19 continue;
20 for (icol = 0; icol < ncol; icol++) {
21 k = ctype(ilin, icol);
22 if (k == 0 || k == '-' || k == '=')
23 continue;
24 s = table[ilin][icol].col;
25 if (point(s))
26 for (; *s; s++)
27 if((unsigned char)*s < 128)
28 had[(unsigned char)*s] = 1;
29 s = table[ilin][icol].rcol;
30 if (point(s))
31 for (; *s; s++)
32 if((unsigned char)*s < 128)
33 had[(unsigned char)*s] = 1;
36 /* choose first funny character */
37 for (s = COMMON "Y"; *s; s++) {
38 if (had[*s] == 0) {
39 F1 = *s;
40 had[F1] = 1;
41 break;
44 /* choose second funny character */
45 for (s = COMMON "u"; *s; s++) {
46 if (had[*s] == 0) {
47 F2 = *s;
48 break;
51 if (F1 == 0 || F2 == 0)
52 error("couldn't find characters to use for delimiters");
55 int
56 point(char *ss)
58 vlong s = (uintptr)ss;
60 return(s >= 128 || s < 0);