aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/tbl/tc.c
blob: 6323c267b090ab0e2b4237ee3c8f2fcc2b0c5515 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* tc.c: find character not in table to delimit fields */
# include "t.h"

void
choochar(void)
{
				/* choose funny characters to delimit fields */
	int	had[128], ilin, icol, k;
	char	*s;

	for (icol = 0; icol < 128; icol++)
		had[icol] = 0;
	F1 = F2 = 0;
	for (ilin = 0; ilin < nlin; ilin++) {
		if (instead[ilin]) 
			continue;
		if (fullbot[ilin]) 
			continue;
		for (icol = 0; icol < ncol; icol++) {
			k = ctype(ilin, icol);
			if (k == 0 || k == '-' || k == '=')
				continue;
			s = table[ilin][icol].col;
			if (point(s))
				while (*s)
					had[(unsigned char)*s++] = 1;
			s = table[ilin][icol].rcol;
			if (point(s))
				while (*s)
					had[(unsigned char)*s++] = 1;
		}
	}
				/* choose first funny character */
	for (
	    s = "\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz"; 
	    *s; s++) {
		if (had[(unsigned char)*s] == 0) {
			F1 = (unsigned char)*s;
			had[F1] = 1;
			break;
		}
	}
				/* choose second funny character */
	for (
	    s = "\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz"; 
	    *s; s++) {
		if (had[(unsigned char)*s] == 0) {
			F2 = (unsigned char)*s;
			break;
		}
	}
	if (F1 == 0 || F2 == 0)
		error("couldn't find characters to use for delimiters");
	return;
}


int
point(char *s)
{
	int	ss = (int)s;
	return(ss >= 128 || ss < 0);
}