xref: /illumos-gate/usr/src/cmd/tbl/tc.c (revision b55148877d473978f0b46d593fd6213fa526fcc5)
1 /*
2  * Copyright 1991 Sun Microsystems, Inc.  All rights reserved.
3  * Use is subject to license terms.
4  */
5 
6 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
7 /*	  All Rights Reserved  	*/
8 
9 /*
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.
13  */
14 
15 #pragma ident	"%Z%%M%	%I%	%E% SMI"
16 
17  /* tc.c: find character not in table to delimit fields */
18 # include "t..c"
19 
20 void
21 choochar(void)
22 {
23 /* choose funny characters to delimit fields */
24 int had[128], ilin,icol, k;
25 char *s;
26 for(icol=0; icol<128; icol++)
27 	had[icol]=0;
28 F1 = F2 = 0;
29 for(ilin=0;ilin<nlin;ilin++)
30 	{
31 	if (instead[ilin]) continue;
32 	if (fullbot[ilin]) continue;
33 	for(icol=0; icol<ncol; icol++)
34 		{
35 		k = ctype(ilin, icol);
36 		if (k==0 || k == '-' || k == '=')
37 			continue;
38 		s = table[ilin][icol].col;
39 		if (point(s))
40 		while (*s)
41 			{
42 			if (*s > 0 && (unsigned char)*s <= 127)
43 				had[*s++]=1;
44 			else
45 				s++;
46 			}
47 		s=table[ilin][icol].rcol;
48 		if (point(s))
49 		while (*s)
50 			{
51 			if (*s > 0 && (unsigned char)*s <= 127)
52 				had[*s++]=1;
53 			else
54 				s++;
55 			}
56 		}
57 	}
58 /* choose first funny character */
59 for(
60 	s="\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz";
61 		*s; s++)
62 	{
63 	if (had[*s]==0)
64 		{
65 		F1= *s;
66 		had[F1]=1;
67 		break;
68 		}
69 	}
70 /* choose second funny character */
71 for(
72 	s="\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz";
73 		*s; s++)
74 	{
75 	if (had[*s]==0)
76 		{
77 		F2= *s;
78 		break;
79 		}
80 	}
81 if (F1==0 || F2==0)
82 	error(gettext("couldn't find characters to use for delimiters"));
83 return;
84 }
85 
86 int
87 point(int s)
88 {
89 return(s>= 128 || s<0);
90 }
91