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