1 #ifndef lint
2 static char sccsid[] = "@(#)delimfields.c	1.2 (CWI) 85/10/02";
3 #endif lint
4 
5 
6 /*
7  * find character not in table to delimit fields
8  */
9 
10 #include "defs.h"
11 #include "ext.h"
12 
13 /*
14  * choose funny characters to delimit fields
15  */
16 
17 /*
18  * strings to pick the characters from
19  */
20 static char *funny1 = {"\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz"};
21 static char *funny2 = {"\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz"};
22 
23 choochar(){
24 	int had[128], ilin, icol, k;
25 	char *s;
26 
27 	for(icol = 0; icol < 128; icol++)
28 		had[icol] = 0;
29 	F1 = F2 = 0;
30 	for(ilin = 0; ilin < nlin; ilin++){
31 		if(instead[ilin])
32 			continue;
33 		if(fullbot[ilin])
34 			continue;
35 		for(icol = 0; icol < ncol; icol++){
36 			k = ctype(ilin, icol);
37 			if(k == 0 || k == '-' || k == '=')
38 				continue;
39 			s = table[ilin][icol].col;
40 			if(point(s))
41 				while(*s)
42 					had[*s++] = 1;
43 			s = table[ilin][icol].rcol;
44 			if(point(s))
45 				while(*s)
46 					had[*s++] = 1;
47 		}
48 	}
49 	/*
50 	 * choose first funny character
51 	 */
52 	for(s = funny1; *s; s++){
53 		if(had[*s] == 0){
54 			F1 = *s;
55 			had[F1] = 1;
56 			break;
57 		}
58 	}
59 	/*
60 	 * choose second funny character
61 	 */
62 	for(s = funny2; *s; s++){
63 		if(had[*s] == 0){
64 			F2 = *s;
65 			break;
66 		}
67 	}
68 	if(F1 == 0 || F2 == 0)
69 		error("couldn't find characters to use for delimiters");
70 	return;
71 }
72 
73 /*
74  * Very Ugly!!
75  * if s is not a character, we decide it is a pointer, so return true
76  *
77  * (Need to check or we can replace it with
78 #define point	((s) >= 128 || (s) < 0)
79  * or even isascii)
80  */
81 point(s){
82 	return(s >= 128 || s < 0);
83 }
84