xref: /titanic_52/usr/src/cmd/tbl/tc.c (revision b55148877d473978f0b46d593fd6213fa526fcc5)
1*b5514887Smuffin /*
2*b5514887Smuffin  * Copyright 1991 Sun Microsystems, Inc.  All rights reserved.
3*b5514887Smuffin  * Use is subject to license terms.
4*b5514887Smuffin  */
5*b5514887Smuffin 
67c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
77c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
87c478bd9Sstevel@tonic-gate 
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate  * Copyright (c) 1980 Regents of the University of California.
117c478bd9Sstevel@tonic-gate  * All rights reserved. The Berkeley software License Agreement
127c478bd9Sstevel@tonic-gate  * specifies the terms and conditions for redistribution.
137c478bd9Sstevel@tonic-gate  */
147c478bd9Sstevel@tonic-gate 
15*b5514887Smuffin #pragma ident	"%Z%%M%	%I%	%E% SMI"
167c478bd9Sstevel@tonic-gate 
177c478bd9Sstevel@tonic-gate  /* tc.c: find character not in table to delimit fields */
187c478bd9Sstevel@tonic-gate # include "t..c"
19*b5514887Smuffin 
20*b5514887Smuffin void
21*b5514887Smuffin choochar(void)
227c478bd9Sstevel@tonic-gate {
237c478bd9Sstevel@tonic-gate /* choose funny characters to delimit fields */
247c478bd9Sstevel@tonic-gate int had[128], ilin,icol, k;
257c478bd9Sstevel@tonic-gate char *s;
267c478bd9Sstevel@tonic-gate for(icol=0; icol<128; icol++)
277c478bd9Sstevel@tonic-gate 	had[icol]=0;
287c478bd9Sstevel@tonic-gate F1 = F2 = 0;
297c478bd9Sstevel@tonic-gate for(ilin=0;ilin<nlin;ilin++)
307c478bd9Sstevel@tonic-gate 	{
317c478bd9Sstevel@tonic-gate 	if (instead[ilin]) continue;
327c478bd9Sstevel@tonic-gate 	if (fullbot[ilin]) continue;
337c478bd9Sstevel@tonic-gate 	for(icol=0; icol<ncol; icol++)
347c478bd9Sstevel@tonic-gate 		{
357c478bd9Sstevel@tonic-gate 		k = ctype(ilin, icol);
367c478bd9Sstevel@tonic-gate 		if (k==0 || k == '-' || k == '=')
377c478bd9Sstevel@tonic-gate 			continue;
387c478bd9Sstevel@tonic-gate 		s = table[ilin][icol].col;
397c478bd9Sstevel@tonic-gate 		if (point(s))
407c478bd9Sstevel@tonic-gate 		while (*s)
417c478bd9Sstevel@tonic-gate 			{
42*b5514887Smuffin 			if (*s > 0 && (unsigned char)*s <= 127)
437c478bd9Sstevel@tonic-gate 				had[*s++]=1;
447c478bd9Sstevel@tonic-gate 			else
457c478bd9Sstevel@tonic-gate 				s++;
467c478bd9Sstevel@tonic-gate 			}
477c478bd9Sstevel@tonic-gate 		s=table[ilin][icol].rcol;
487c478bd9Sstevel@tonic-gate 		if (point(s))
497c478bd9Sstevel@tonic-gate 		while (*s)
507c478bd9Sstevel@tonic-gate 			{
51*b5514887Smuffin 			if (*s > 0 && (unsigned char)*s <= 127)
527c478bd9Sstevel@tonic-gate 				had[*s++]=1;
537c478bd9Sstevel@tonic-gate 			else
547c478bd9Sstevel@tonic-gate 				s++;
557c478bd9Sstevel@tonic-gate 			}
567c478bd9Sstevel@tonic-gate 		}
577c478bd9Sstevel@tonic-gate 	}
587c478bd9Sstevel@tonic-gate /* choose first funny character */
597c478bd9Sstevel@tonic-gate for(
607c478bd9Sstevel@tonic-gate 	s="\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz";
617c478bd9Sstevel@tonic-gate 		*s; s++)
627c478bd9Sstevel@tonic-gate 	{
637c478bd9Sstevel@tonic-gate 	if (had[*s]==0)
647c478bd9Sstevel@tonic-gate 		{
657c478bd9Sstevel@tonic-gate 		F1= *s;
667c478bd9Sstevel@tonic-gate 		had[F1]=1;
677c478bd9Sstevel@tonic-gate 		break;
687c478bd9Sstevel@tonic-gate 		}
697c478bd9Sstevel@tonic-gate 	}
707c478bd9Sstevel@tonic-gate /* choose second funny character */
717c478bd9Sstevel@tonic-gate for(
727c478bd9Sstevel@tonic-gate 	s="\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz";
737c478bd9Sstevel@tonic-gate 		*s; s++)
747c478bd9Sstevel@tonic-gate 	{
757c478bd9Sstevel@tonic-gate 	if (had[*s]==0)
767c478bd9Sstevel@tonic-gate 		{
777c478bd9Sstevel@tonic-gate 		F2= *s;
787c478bd9Sstevel@tonic-gate 		break;
797c478bd9Sstevel@tonic-gate 		}
807c478bd9Sstevel@tonic-gate 	}
817c478bd9Sstevel@tonic-gate if (F1==0 || F2==0)
827c478bd9Sstevel@tonic-gate 	error(gettext("couldn't find characters to use for delimiters"));
837c478bd9Sstevel@tonic-gate return;
847c478bd9Sstevel@tonic-gate }
85*b5514887Smuffin 
86*b5514887Smuffin int
87*b5514887Smuffin point(int s)
887c478bd9Sstevel@tonic-gate {
897c478bd9Sstevel@tonic-gate return(s>= 128 || s<0);
907c478bd9Sstevel@tonic-gate }
91