1 #ifndef lint 2 static char sccsid[] = "@(#)subr.c 1.2 (CWI) 85/10/02"; 3 #endif lint 4 5 6 /* 7 * variuos subroutines for f.i drawing horizontal lines 8 * 9 * We could stuff more routines in this file which are used in various modules 10 * of tbl, like reg in misc.c etc. We leave this for later. 11 */ 12 13 #include "defs.h" 14 #include "ext.h" 15 16 ctype(il, ic) 17 { 18 19 if(instead[il]) 20 return(0); 21 if(fullbot[il]) 22 return(0); 23 il = stynum[il]; 24 return(style[il][ic]); 25 } 26 27 fspan(i, c) 28 { 29 30 c++; 31 return(c < ncol && ctype (i, c) == 's'); 32 } 33 34 lspan(i, c) 35 { 36 register int k; 37 38 if(ctype(i, c) != 's') 39 return(0); 40 c++; 41 if(c < ncol && ctype(i, c) == 's') 42 return(0); 43 for(k = 0; ctype(i, --c) == 's'; k++) 44 ; 45 return(k); 46 } 47 48 ctspan(i, c) 49 { 50 register int k; 51 52 c++; 53 for(k = 1; c < ncol && ctype(i, c) == 's'; k++) 54 c++; 55 return(k); 56 } 57 58 tohcol(ic) 59 { 60 if(ic == 0) 61 printf("\\h'|0'"); 62 else 63 printf("\\h'(|\\n(%2su+|\\n(%2su)/2u'", reg(ic, CLEFT), 64 reg(ic - 1, CRIGHT)); 65 } 66 67 /* 68 * Return true if every element in line i is horizontal 69 * Also at least one must be horizontal 70 */ 71 allh(i) 72 { 73 register int c, one, k; 74 75 if(fullbot[i]) 76 return(1); 77 for(one = c = 0; c < ncol; c++){ 78 k = thish(i, c); 79 if(k == 0) 80 return(0); 81 if(k == 1) 82 continue; 83 one = 1; 84 } 85 return(one); 86 } 87 88 thish(i, c) 89 { 90 register int t; 91 register char *s; 92 register struct colstr *pc; 93 94 if(c < 0) 95 return(0); 96 if(i < 0) 97 return(0); 98 t = ctype(i, c); 99 if(t == '_' || t == '-') 100 return('-'); 101 if(t == '=') 102 return('='); 103 if(t == '^') 104 return(1); 105 if(fullbot[i]) 106 return(fullbot[i]); 107 if(t == 's') 108 return(thish (i, c - 1)); 109 if(t == 0) 110 return(1); 111 pc = &table[i][c]; 112 s = (t == 'a' ? pc -> rcol : pc -> col); 113 if(s == 0 || (point(s) && *s == 0)) 114 return(1); 115 if(vspen(s)) 116 return(1); 117 if(t = barent(s)) 118 return(t); 119 return(0); 120 } 121 122 123 prefix(small, big) 124 char *small, *big; 125 { 126 register int c; 127 while ((c= *small++) == *big++) 128 if (c==0) return(1); 129 return(c==0); 130 } 131