1 /*- 2 * %sccs.include.proprietary.c% 3 */ 4 5 #ifndef lint 6 static char sccsid[] = "@(#)tm.c 4.3 (Berkeley) 04/18/91"; 7 #endif /* not lint */ 8 9 /* tm.c: split numerical fields */ 10 # include "t..c" 11 maknew(str) 12 char *str; 13 { 14 /* make two numerical fields */ 15 int dpoint, c; 16 char *p, *q, *ba; 17 p = str; 18 for (ba= 0; c = *str; str++) 19 if (c == '\\' && *(str+1)== '&') 20 ba=str; 21 str=p; 22 if (ba==0) 23 { 24 for (dpoint=0; *str; str++) 25 { 26 if (*str=='.' && !ineqn(str,p) && 27 (str>p && digit(*(str-1)) || 28 digit(*(str+1)))) 29 dpoint=str; 30 } 31 if (dpoint==0) 32 for(; str>p; str--) 33 { 34 if (digit( * (str-1) ) && !ineqn(str, p)) 35 break; 36 } 37 if (!dpoint && p==str) /* not numerical, don't split */ 38 return(0); 39 if (dpoint) str=dpoint; 40 } 41 else 42 str = ba; 43 p =str; 44 if (exstore ==0 || exstore >exlim) 45 { 46 exstore = chspace(); 47 exlim= exstore+MAXCHS; 48 } 49 q = exstore; 50 while (*exstore++ = *str++); 51 *p = 0; 52 return(q); 53 } 54 ineqn (s, p) 55 char *s, *p; 56 { 57 /* true if s is in a eqn within p */ 58 int ineq = 0, c; 59 while (c = *p) 60 { 61 if (s == p) 62 return(ineq); 63 p++; 64 if ((ineq == 0) && (c == delim1)) 65 ineq = 1; 66 else 67 if ((ineq == 1) && (c == delim2)) 68 ineq = 0; 69 } 70 return(0); 71 } 72