xref: /original-bsd/old/tbl/tc.c (revision b366b3c1)
1 /*-
2  * %sccs.include.proprietary.c%
3  */
4 
5 #ifndef lint
6 static char sccsid[] = "@(#)tc.c	4.3 (Berkeley) 04/18/91";
7 #endif /* not lint */
8 
9  /* tc.c: find character not in table to delimit fields */
10 # include "t..c"
11 choochar()
12 {
13 /* choose funny characters to delimit fields */
14 int had[128], ilin,icol, k;
15 char *s;
16 for(icol=0; icol<128; icol++)
17 	had[icol]=0;
18 F1 = F2 = 0;
19 for(ilin=0;ilin<nlin;ilin++)
20 	{
21 	if (instead[ilin]) continue;
22 	if (fullbot[ilin]) continue;
23 	for(icol=0; icol<ncol; icol++)
24 		{
25 		k = ctype(ilin, icol);
26 		if (k==0 || k == '-' || k == '=')
27 			continue;
28 		s = table[ilin][icol].col;
29 		if (point(s))
30 		while (*s)
31 			had[*s++]=1;
32 		s=table[ilin][icol].rcol;
33 		if (point(s))
34 		while (*s)
35 			had[*s++]=1;
36 		}
37 	}
38 /* choose first funny character */
39 for(
40 	s="\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz";
41 		*s; s++)
42 	{
43 	if (had[*s]==0)
44 		{
45 		F1= *s;
46 		had[F1]=1;
47 		break;
48 		}
49 	}
50 /* choose second funny character */
51 for(
52 	s="\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz";
53 		*s; s++)
54 	{
55 	if (had[*s]==0)
56 		{
57 		F2= *s;
58 		break;
59 		}
60 	}
61 if (F1==0 || F2==0)
62 	error("couldn't find characters to use for delimiters");
63 return;
64 }
65 point(s)
66 {
67 return(s>= 128 || s<0);
68 }
69