formatting
[unix-history] / usr / src / old / tbl / tm.c
CommitLineData
ae4ebdcf
BS
1/* tm.c 4.1 83/02/12 */
2
3 /* tm.c: split numerical fields */
4# include "t..c"
5maknew(str)
6 char *str;
7{
8 /* make two numerical fields */
9 int dpoint, c;
10 char *p, *q, *ba;
11 p = str;
12 for (ba= 0; c = *str; str++)
13 if (c == '\\' && *(str+1)== '&')
14 ba=str;
15 str=p;
16 if (ba==0)
17 {
18 for (dpoint=0; *str; str++)
19 {
20 if (*str=='.' && !ineqn(str,p) &&
21 (str>p && digit(*(str-1)) ||
22 digit(*(str+1))))
23 dpoint=str;
24 }
25 if (dpoint==0)
26 for(; str>p; str--)
27 {
28 if (digit( * (str-1) ) && !ineqn(str, p))
29 break;
30 }
31 if (!dpoint && p==str) /* not numerical, don't split */
32 return(0);
33 if (dpoint) str=dpoint;
34 }
35 else
36 str = ba;
37 p =str;
38 if (exstore ==0 || exstore >exlim)
39 {
40 exstore = chspace();
41 exlim= exstore+MAXCHS;
42 }
43 q = exstore;
44 while (*exstore++ = *str++);
45 *p = 0;
46 return(q);
47 }
48ineqn (s, p)
49 char *s, *p;
50{
51/* true if s is in a eqn within p */
52int ineq = 0, c;
53while (c = *p)
54 {
55 if (s == p)
56 return(ineq);
57 p++;
58 if ((ineq == 0) && (c == delim1))
59 ineq = 1;
60 else
61 if ((ineq == 1) && (c == delim2))
62 ineq = 0;
63 }
64return(0);
65}