1 /* $MirOS: src/usr.bin/oldroff/tbl/tc.c,v 1.3 2008/11/08 23:04:54 tg Exp $ */
2
3 /*-
4 * Copyright (c) 1979, 1980, 1981, 1986, 1988, 1990, 1991, 1992
5 * The Regents of the University of California.
6 * Copyright (C) Caldera International Inc. 2001-2002.
7 * Copyright (c) 2003, 2004
8 * Thorsten "mirabilos" Glaser <tg@mirbsd.org>
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms,
12 * with or without modification, are permitted provided
13 * that the following conditions are met:
14 *
15 * Redistributions of source code and documentation must retain
16 * the above copyright notice, this list of conditions and the
17 * following disclaimer. Redistributions in binary form must
18 * reproduce the above copyright notice, this list of conditions
19 * and the following disclaimer in the documentation and/or other
20 * materials provided with the distribution.
21 *
22 * All advertising materials mentioning features or use of this
23 * software must display the following acknowledgement:
24 * This product includes software developed or owned by
25 * Caldera International, Inc.
26 *
27 * Neither the name of Caldera International, Inc. nor the names
28 * of other contributors may be used to endorse or promote products
29 * derived from this software without specific prior written permission.
30 *
31 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
32 * INTERNATIONAL, INC. AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
33 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE
36 * LIABLE FOR ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR
37 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
38 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
39 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
40 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
41 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
42 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 */
44
45 /* tc.c: find character not in table to delimit fields */
46
47 # include "t..c"
48 __SCCSID("@(#)tc.c 4.3 (Berkeley) 4/18/91");
49 __RCSID("$MirOS: src/usr.bin/oldroff/tbl/tc.c,v 1.3 2008/11/08 23:04:54 tg Exp $");
50
choochar()51 choochar()
52 {
53 /* choose funny characters to delimit fields */
54 int had[128], ilin,icol, k;
55 char *s;
56 for(icol=0; icol<128; icol++)
57 had[icol]=0;
58 F1 = F2 = 0;
59 for(ilin=0;ilin<nlin;ilin++)
60 {
61 if (instead[ilin]) continue;
62 if (fullbot[ilin]) continue;
63 for(icol=0; icol<ncol; icol++)
64 {
65 k = ctype(ilin, icol);
66 if (k==0 || k == '-' || k == '=')
67 continue;
68 s = table[ilin][icol].col;
69 if (point(s))
70 while (*s)
71 had[*s++]=1;
72 s=table[ilin][icol].rcol;
73 if (point(s))
74 while (*s)
75 had[*s++]=1;
76 }
77 }
78 /* choose first funny character */
79 for(
80 s="\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz";
81 *s; s++)
82 {
83 if (had[*s]==0)
84 {
85 F1= *s;
86 had[F1]=1;
87 break;
88 }
89 }
90 /* choose second funny character */
91 for(
92 s="\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz";
93 *s; s++)
94 {
95 if (had[*s]==0)
96 {
97 F2= *s;
98 break;
99 }
100 }
101 if (F1==0 || F2==0)
102 error("couldn't find characters to use for delimiters");
103 return;
104 }
point(s)105 point(s)
106 {
107 return(s>= 128 || s<0);
108 }
109