xref: /onnv-gate/usr/src/cmd/tbl/tc.c (revision 381:1a7f0e46092a)
1*381Smuffin /*
2*381Smuffin  * Copyright 1991 Sun Microsystems, Inc.  All rights reserved.
3*381Smuffin  * Use is subject to license terms.
4*381Smuffin  */
5*381Smuffin 
60Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
70Sstevel@tonic-gate /*	  All Rights Reserved  	*/
80Sstevel@tonic-gate 
90Sstevel@tonic-gate /*
100Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
110Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
120Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
130Sstevel@tonic-gate  */
140Sstevel@tonic-gate 
15*381Smuffin #pragma ident	"%Z%%M%	%I%	%E% SMI"
160Sstevel@tonic-gate 
170Sstevel@tonic-gate  /* tc.c: find character not in table to delimit fields */
180Sstevel@tonic-gate # include "t..c"
19*381Smuffin 
20*381Smuffin void
choochar(void)21*381Smuffin choochar(void)
220Sstevel@tonic-gate {
230Sstevel@tonic-gate /* choose funny characters to delimit fields */
240Sstevel@tonic-gate int had[128], ilin,icol, k;
250Sstevel@tonic-gate char *s;
260Sstevel@tonic-gate for(icol=0; icol<128; icol++)
270Sstevel@tonic-gate 	had[icol]=0;
280Sstevel@tonic-gate F1 = F2 = 0;
290Sstevel@tonic-gate for(ilin=0;ilin<nlin;ilin++)
300Sstevel@tonic-gate 	{
310Sstevel@tonic-gate 	if (instead[ilin]) continue;
320Sstevel@tonic-gate 	if (fullbot[ilin]) continue;
330Sstevel@tonic-gate 	for(icol=0; icol<ncol; icol++)
340Sstevel@tonic-gate 		{
350Sstevel@tonic-gate 		k = ctype(ilin, icol);
360Sstevel@tonic-gate 		if (k==0 || k == '-' || k == '=')
370Sstevel@tonic-gate 			continue;
380Sstevel@tonic-gate 		s = table[ilin][icol].col;
390Sstevel@tonic-gate 		if (point(s))
400Sstevel@tonic-gate 		while (*s)
410Sstevel@tonic-gate 			{
42*381Smuffin 			if (*s > 0 && (unsigned char)*s <= 127)
430Sstevel@tonic-gate 				had[*s++]=1;
440Sstevel@tonic-gate 			else
450Sstevel@tonic-gate 				s++;
460Sstevel@tonic-gate 			}
470Sstevel@tonic-gate 		s=table[ilin][icol].rcol;
480Sstevel@tonic-gate 		if (point(s))
490Sstevel@tonic-gate 		while (*s)
500Sstevel@tonic-gate 			{
51*381Smuffin 			if (*s > 0 && (unsigned char)*s <= 127)
520Sstevel@tonic-gate 				had[*s++]=1;
530Sstevel@tonic-gate 			else
540Sstevel@tonic-gate 				s++;
550Sstevel@tonic-gate 			}
560Sstevel@tonic-gate 		}
570Sstevel@tonic-gate 	}
580Sstevel@tonic-gate /* choose first funny character */
590Sstevel@tonic-gate for(
600Sstevel@tonic-gate 	s="\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz";
610Sstevel@tonic-gate 		*s; s++)
620Sstevel@tonic-gate 	{
630Sstevel@tonic-gate 	if (had[*s]==0)
640Sstevel@tonic-gate 		{
650Sstevel@tonic-gate 		F1= *s;
660Sstevel@tonic-gate 		had[F1]=1;
670Sstevel@tonic-gate 		break;
680Sstevel@tonic-gate 		}
690Sstevel@tonic-gate 	}
700Sstevel@tonic-gate /* choose second funny character */
710Sstevel@tonic-gate for(
720Sstevel@tonic-gate 	s="\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz";
730Sstevel@tonic-gate 		*s; s++)
740Sstevel@tonic-gate 	{
750Sstevel@tonic-gate 	if (had[*s]==0)
760Sstevel@tonic-gate 		{
770Sstevel@tonic-gate 		F2= *s;
780Sstevel@tonic-gate 		break;
790Sstevel@tonic-gate 		}
800Sstevel@tonic-gate 	}
810Sstevel@tonic-gate if (F1==0 || F2==0)
820Sstevel@tonic-gate 	error(gettext("couldn't find characters to use for delimiters"));
830Sstevel@tonic-gate return;
840Sstevel@tonic-gate }
85*381Smuffin 
86*381Smuffin int
point(int s)87*381Smuffin point(int s)
880Sstevel@tonic-gate {
890Sstevel@tonic-gate return(s>= 128 || s<0);
900Sstevel@tonic-gate }
91