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