1: # include "e.h" 2: 3: paren(leftc, p1, rightc) int p1, leftc, rightc; { 4: int n, m, h1, j, b1, v; 5: h1 = eht[p1]; b1 = ebase[p1]; 6: yyval = p1; 7: n = max(b1+VERT(1), h1-b1-VERT(1)) / VERT(1); 8: if( n<2 ) n = 1; 9: m = n-2; 10: if (leftc=='{' || rightc == '}') { 11: n = n%2 ? n : ++n; 12: if( n<3 ) n=3; 13: m = n-3; 14: } 15: eht[yyval] = VERT(2 * n); 16: ebase[yyval] = (n)/2 * VERT(2); 17: if (n%2 == 0) 18: ebase[yyval] -= VERT(1); 19: v = b1 - h1/2 + VERT(1); 20: printf(".ds %d \\|\\v'%du'", yyval, v); 21: switch( leftc ) { 22: case 'n': /* nothing */ 23: case '\0': 24: break; 25: case 'f': /* floor, modified by jeremy */ 26: if (n <= 1) 27: printf("\\(lf"); 28: else 29: brack(m, "\\(bt", "\\(bv", "\\(lf"); 30: break; 31: case 'c': /* ceiling, modified by jeremy */ 32: if (n <= 1) 33: printf("\\(lc"); 34: else 35: brack(m, "\\(lc", "\\(bv", "\\(bl"); 36: break; 37: case 'i': /* integral, jeremy */ 38: brack(m, "\\(ti", "\\(bv", "\\(bi"); 39: break; 40: case '{': 41: printf("\\b'\\(lt"); 42: for(j = 0; j < m; j += 2) printf("\\(bv"); 43: printf("\\(lk"); 44: for(j = 0; j < m; j += 2) printf("\\(bv"); 45: printf("\\(lb'"); 46: break; 47: case '(': 48: brack(m, "\\(lt", "\\(bv", "\\(lb"); 49: break; 50: case '[': 51: brack(m, "\\(lc", "\\(bv", "\\(lf"); 52: break; 53: case '|': /* bar, modified by jeremy */ 54: brack(m, "\\(bt", "\\(bv", "\\(bl"); 55: break; 56: default: 57: brack(m, (char *) &leftc, (char *) &leftc, (char *) &leftc); 58: break; 59: } 60: printf("\\v'%du'\\*(%d", -v, p1); 61: if( rightc ) { 62: printf("\\|\\v'%du'", v); 63: switch( rightc ) { 64: case 'f': /* floor, modified by jeremy */ 65: if (n <= 1) 66: printf("\\(rf"); 67: else 68: brack(m, "\\(bt", "\\(bv", "\\(rf"); 69: break; 70: case 'c': /* ceiling, modified by jeremy */ 71: if (n <= 1) 72: printf("\\(rc"); 73: else 74: brack(m, "\\(rc", "\\(bv", "\\(bl"); 75: break; 76: case 'i': /* integral, jeremy */ 77: break; 78: case '}': 79: printf("\\b'\\(rt"); 80: for(j = 0; j< m; j += 2)printf("\\(bv"); 81: printf("\\(rk"); 82: for(j = 0; j< m; j += 2) printf("\\(bv"); 83: printf("\\(rb'"); 84: break; 85: case ']': 86: brack(m, "\\(rc", "\\(bv", "\\(rf"); 87: break; 88: case ')': 89: brack(m, "\\(rt", "\\(bv", "\\(rb"); 90: break; 91: case '|': /* bar, modified by jeremy */ 92: brack(m, "\\(bt", "\\(bv", "\\(bl"); 93: break; 94: default: 95: brack(m, (char *) &rightc, (char *) &rightc, (char *) &rightc); 96: break; 97: } 98: printf("\\v'%du'", -v); 99: } 100: printf("\n"); 101: if(dbg)printf(".\tcurly: h=%d b=%d n=%d v=%d l=%c, r=%c\n", 102: eht[yyval], ebase[yyval], n, v, leftc, rightc); 103: } 104: 105: brack(m, t, c, b) int m; char *t, *c, *b; { 106: int j; 107: printf("\\b'%s", t); 108: for( j=0; j<m; j++) 109: printf("%s", c); 110: printf("%s'", b); 111: }