114632Sslatteng # include "e.h"
214632Sslatteng
paren(leftc,p1,rightc)314632Sslatteng paren(leftc, p1, rightc) int p1, leftc, rightc; {
414632Sslatteng int n, m, h1, j, b1, v;
514632Sslatteng h1 = eht[p1]; b1 = ebase[p1];
614632Sslatteng yyval = p1;
714632Sslatteng lfont[yyval] = rfont[yyval] = 0;
814632Sslatteng n = (h1 + EM(1.0, EFFPS(ps)) - 1) / EM(1.0, EFFPS(ps));
914632Sslatteng if( n<2 ) n = 1;
1014632Sslatteng m = n-2;
1114632Sslatteng if (leftc=='{' || rightc == '}') {
1214632Sslatteng n = n%2 ? n : ++n;
1314632Sslatteng if( n<3 ) n=3;
1414632Sslatteng m = n-3;
1514632Sslatteng }
1614632Sslatteng eht[yyval] = VERT( EM(n, ps) );
1714632Sslatteng ebase[yyval] = b1 + (eht[yyval]-h1)/2;
1814632Sslatteng v = b1 - h1/2 + VERT( EM(0.4, ps) );
1914632Sslatteng v = 0; /* BUG??? */
2014632Sslatteng printf(".ds %d \\|\\v'%du'", yyval, v);
2114632Sslatteng switch( leftc ) {
2214632Sslatteng case 'n': /* nothing */
2314632Sslatteng case '\0':
2414632Sslatteng break;
2514632Sslatteng case 'f': /* floor */
2614632Sslatteng if (n <= 1)
2714632Sslatteng printf("\\(lf");
2814632Sslatteng else
2914632Sslatteng brack(m, "\\(bv", "\\(bv", "\\(lf");
3014632Sslatteng break;
3114632Sslatteng case 'c': /* ceiling */
3214632Sslatteng if (n <= 1)
3314632Sslatteng printf("\\(lc");
3414632Sslatteng else
3514632Sslatteng brack(m, "\\(lc", "\\(bv", "\\(bv");
3614632Sslatteng break;
3714632Sslatteng case '{':
3814632Sslatteng printf("\\b'\\(lt");
3914632Sslatteng for(j = 0; j < m; j += 2) printf("\\(bv");
4014632Sslatteng printf("\\(lk");
4114632Sslatteng for(j = 0; j < m; j += 2) printf("\\(bv");
4214632Sslatteng printf("\\(lb'");
4314632Sslatteng break;
4414632Sslatteng case '(':
4514632Sslatteng brack(m, "\\(lt", "\\(bv", "\\(lb");
4614632Sslatteng break;
4714632Sslatteng case '[':
4814632Sslatteng brack(m, "\\(lc", "\\(bv", "\\(lf");
4914632Sslatteng break;
5014632Sslatteng case '|':
5114632Sslatteng brack(m, "|", "|", "|");
5214632Sslatteng break;
5314632Sslatteng default:
5414632Sslatteng brack(m, (char *) &leftc, (char *) &leftc, (char *) &leftc);
5514632Sslatteng break;
5614632Sslatteng }
5714632Sslatteng printf("\\v'%du'\\*(%d", -v, p1);
5814632Sslatteng if( rightc ) {
59*14642Sslatteng printf("\\|\\v'%du'", v);
6014632Sslatteng switch( rightc ) {
6114632Sslatteng case 'f': /* floor */
6214632Sslatteng if (n <= 1)
6314632Sslatteng printf("\\(rf");
6414632Sslatteng else
6514632Sslatteng brack(m, "\\(bv", "\\(bv", "\\(rf");
6614632Sslatteng break;
6714632Sslatteng case 'c': /* ceiling */
6814632Sslatteng if (n <= 1)
6914632Sslatteng printf("\\(rc");
7014632Sslatteng else
7114632Sslatteng brack(m, "\\(rc", "\\(bv", "\\(bv");
7214632Sslatteng break;
7314632Sslatteng case '}':
7414632Sslatteng printf("\\b'\\(rt");
7514632Sslatteng for(j = 0; j< m; j += 2)printf("\\(bv");
7614632Sslatteng printf("\\(rk");
7714632Sslatteng for(j = 0; j< m; j += 2) printf("\\(bv");
7814632Sslatteng printf("\\(rb'");
7914632Sslatteng break;
8014632Sslatteng case ']':
8114632Sslatteng brack(m, "\\(rc", "\\(bv", "\\(rf");
8214632Sslatteng break;
8314632Sslatteng case ')':
8414632Sslatteng brack(m, "\\(rt", "\\(bv", "\\(rb");
8514632Sslatteng break;
8614632Sslatteng case '|':
8714632Sslatteng brack(m, "|", "|", "|");
8814632Sslatteng break;
8914632Sslatteng default:
9014632Sslatteng brack(m, (char *) &rightc, (char *) &rightc, (char *) &rightc);
9114632Sslatteng break;
9214632Sslatteng }
9314632Sslatteng printf("\\v'%du'", -v);
9414632Sslatteng }
9514632Sslatteng printf("\n");
9614632Sslatteng if(dbg)printf(".\tcurly: h=%d b=%d n=%d v=%d l=%c, r=%c\n",
9714632Sslatteng eht[yyval], ebase[yyval], n, v, leftc, rightc);
9814632Sslatteng }
9914632Sslatteng
brack(m,t,c,b)10014632Sslatteng brack(m, t, c, b) int m; char *t, *c, *b; {
10114632Sslatteng int j;
10214632Sslatteng printf("\\b'%s", t);
10314632Sslatteng for( j=0; j<m; j++)
10414632Sslatteng printf("%s", c);
10514632Sslatteng printf("%s'", b);
10614632Sslatteng }
107