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