blob: a89fc0f0415ac4d31b5b9c357981bf666e139a31 [file] [log] [blame]
rsc5cedca12004-05-15 23:24:00 +00001/* tc.c: find character not in table to delimit fields */
2# include "t.h"
3
4void
5choochar(void)
6{
wkj8a3cbc12004-05-17 02:23:43 +00007 /* choose funny characters to delimit fields */
rsca5f3a002006-04-20 21:00:21 +00008 int had[256], ilin, icol, k;
rsccb98c6f2005-01-14 18:46:35 +00009 char *s;
rsc5cedca12004-05-15 23:24:00 +000010
11 for (icol = 0; icol < 128; icol++)
12 had[icol] = 0;
13 F1 = F2 = 0;
14 for (ilin = 0; ilin < nlin; ilin++) {
15 if (instead[ilin])
16 continue;
17 if (fullbot[ilin])
18 continue;
19 for (icol = 0; icol < ncol; icol++) {
20 k = ctype(ilin, icol);
21 if (k == 0 || k == '-' || k == '=')
22 continue;
23 s = table[ilin][icol].col;
24 if (point(s))
25 while (*s)
rsccb98c6f2005-01-14 18:46:35 +000026 had[(unsigned char)*s++] = 1;
rsc5cedca12004-05-15 23:24:00 +000027 s = table[ilin][icol].rcol;
28 if (point(s))
29 while (*s)
rsccb98c6f2005-01-14 18:46:35 +000030 had[(unsigned char)*s++] = 1;
rsc5cedca12004-05-15 23:24:00 +000031 }
32 }
33 /* choose first funny character */
34 for (
35 s = "\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz";
36 *s; s++) {
rsccb98c6f2005-01-14 18:46:35 +000037 if (had[(unsigned char)*s] == 0) {
38 F1 = (unsigned char)*s;
rsc5cedca12004-05-15 23:24:00 +000039 had[F1] = 1;
40 break;
41 }
42 }
43 /* choose second funny character */
44 for (
45 s = "\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz";
46 *s; s++) {
rsccb98c6f2005-01-14 18:46:35 +000047 if (had[(unsigned char)*s] == 0) {
48 F2 = (unsigned char)*s;
rsc5cedca12004-05-15 23:24:00 +000049 break;
50 }
51 }
52 if (F1 == 0 || F2 == 0)
53 error("couldn't find characters to use for delimiters");
54 return;
55}
56
57
58int
rsca5f3a002006-04-20 21:00:21 +000059point(char *ss)
rsc5cedca12004-05-15 23:24:00 +000060{
rsca5f3a002006-04-20 21:00:21 +000061 int s = (int)(uintptr)ss;
62 return(s >= 128 || s < 0);
rsc5cedca12004-05-15 23:24:00 +000063}
64
65