fromto.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. # include "e.h"
  10. void fromto(int p1, int p2, int p3)
  11. {
  12. double b, h1, b1, t;
  13. int subps;
  14. yyval = salloc();
  15. lfont[yyval] = rfont[yyval] = 0;
  16. h1 = eht[yyval] = eht[p1];
  17. b1 = ebase[p1];
  18. b = 0;
  19. subps = ps;
  20. ps += deltaps;
  21. nrwid(p1, ps, p1);
  22. printf(".nr %d \\n(%d\n", yyval, p1);
  23. if (p2 > 0) {
  24. nrwid(p2, subps, p2);
  25. printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p2, yyval, yyval, p2);
  26. eht[yyval] += eht[p2];
  27. b = eht[p2];
  28. }
  29. if (p3 > 0) {
  30. nrwid(p3, subps, p3);
  31. printf(".if \\n(%d>\\n(%d .nr %d \\n(%d\n", p3, yyval, yyval, p3);
  32. eht[yyval] += eht[p3];
  33. }
  34. printf(".ds %d ", yyval); /* bottom of middle box */
  35. if (p2 > 0) {
  36. t = eht[p2]-ebase[p2]+b1;
  37. printf("\\v'%gm'\\h'\\n(%du-\\n(%du/2u'%s\\*(%d%s",
  38. REL(t,ps), yyval, p2, DPS(ps,subps), p2, DPS(subps,ps));
  39. printf("\\h'-\\n(%du-\\n(%du/2u'\\v'%gm'\\\n",
  40. yyval, p2, REL(-t,ps));
  41. }
  42. printf("\\h'\\n(%du-\\n(%du/2u'\\*(%d\\h'\\n(%du-\\n(%du/2u'\\\n",
  43. yyval, p1, p1, yyval, p1);
  44. if (p3 >0) {
  45. t = h1-b1+ebase[p3];
  46. printf("\\v'%gm'\\h'-\\n(%du-\\n(%du/2u'%s\\*(%d%s\\h'\\n(%du-\\n(%du/2u'\\v'%gm'\\\n",
  47. REL(-t,ps), yyval, p3, DPS(ps,subps), p3, DPS(subps,ps), yyval, p3, REL(t,ps));
  48. }
  49. printf("\n");
  50. ebase[yyval] = b + b1;
  51. dprintf(".\tS%d <- %d from %d to %d; h=%g b=%g\n",
  52. yyval, p1, p2, p3, eht[yyval], ebase[yyval]);
  53. sfree(p1);
  54. if (p2 > 0)
  55. sfree(p2);
  56. if (p3 > 0)
  57. sfree(p3);
  58. }