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