home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / PDP-11 / Trees / V7 / usr / src / cmd / tbl / t7.c < prev    next >
Encoding:
C/C++ Source or Header  |  1979-01-10  |  3.0 KB  |  132 lines

  1.  /* t7.c: control to write table entries */
  2. # include "t..c"
  3. # define realsplit ((ct=='a'||ct=='n') && table[ldata][c].rcol)
  4. runout()
  5. {
  6. int i;
  7. if (boxflg || allflg || dboxflg) need();
  8. if (ctrflg)
  9.     {
  10.     fprintf(tabout, ".nr #I \\n(.i\n");
  11.     fprintf(tabout, ".in +(\\n(.lu-\\n(TWu-\\n(.iu)/2u\n");
  12.     }
  13. fprintf(tabout, ".fc %c %c\n", F1, F2);
  14. fprintf(tabout, ".nr #T 0-1\n");
  15. deftail();
  16. for(i=0; i<nlin; i++)
  17.     putline(i,i);
  18. if (leftover)
  19.     yetmore();
  20. fprintf(tabout, ".fc\n");
  21. fprintf(tabout, ".nr T. 1\n");
  22. fprintf(tabout, ".T# 1\n");
  23. if (ctrflg)
  24.     fprintf(tabout, ".in \\n(#Iu\n");
  25. }
  26. runtabs(lform, ldata)
  27. {
  28. int c, ct, vforml, lf;
  29. fprintf(tabout, ".ta ");
  30. for(c=0; c<ncol; c++)
  31.     {
  32.     vforml=lform;
  33.     for(lf=prev(lform); lf>=0 && vspen(table[lf][c].col); lf=prev(lf))
  34.         vforml=lf;
  35.     if (fspan(vforml,c))
  36.         continue;
  37.     switch(ct=ctype(vforml,c))
  38.         {
  39.         case 'n':
  40.         case 'a':
  41.             if (table[ldata][c].rcol)
  42.               if (lused[c]) /*Zero field width*/
  43.                 fprintf(tabout, "\\n(%du ",c+CMID);
  44.         case 'c':
  45.         case 'l':
  46.         case 'r':
  47.             if (realsplit? rused[c]: (used[c]+lused[c]))
  48.             fprintf(tabout, "\\n(%du ",c+CRIGHT);
  49.             continue;
  50.         case 's':
  51.             if (lspan(lform, c))
  52.                 fprintf(tabout, "\\n(%du ", c+CRIGHT);
  53.             continue;
  54.         }
  55.     }
  56. fprintf(tabout, "\n");
  57. }
  58. ifline(s)
  59.     char *s;
  60. {
  61. if (s[0] == '\\') s++;
  62. if (s[1] ) return(0);
  63. if (s[0] == '_') return('-');
  64. if (s[0] == '=') return('=');
  65. return(0);
  66. }
  67. need()
  68. {
  69. int texlin, horlin, i;
  70. for(texlin=horlin=i=0; i<nlin; i++)
  71.     {
  72.     if (fullbot[i]!=0)
  73.         horlin++;
  74.     else
  75.     if (instead[i]!=0)
  76.         continue;
  77.     else
  78.         texlin++;
  79.     }
  80. fprintf(tabout, ".ne %dv+%dp\n",texlin,2*horlin);
  81. }
  82. deftail()
  83. {
  84. int i, c, lf, lwid;
  85. for(i=0; i<MAXHEAD; i++)
  86.     if (linestop[i])
  87.         fprintf(tabout, ".nr #%c 0-1\n", linestop[i]+'a'-1);
  88. fprintf(tabout, ".nr #a 0-1\n");
  89. fprintf(tabout, ".eo\n");
  90. fprintf(tabout, ".de T#\n");
  91. fprintf(tabout, ".ds #d .d\n");
  92. fprintf(tabout, ".if \\(ts\\n(.z\\(ts\\(ts .ds #d nl\n");
  93.     fprintf(tabout, ".mk ##\n");
  94.     fprintf(tabout, ".nr ## -1v\n");
  95.     fprintf(tabout, ".ls 1\n");
  96.     for(i=0; i<MAXHEAD; i++)
  97.         if (linestop[i])
  98.             fprintf(tabout, ".if \\n(#T>=0 .nr #%c \\n(#T\n",linestop[i]+'a'-1);
  99. if (boxflg || allflg || dboxflg) /* bottom of table line */
  100.     if (fullbot[nlin-1]==0)
  101.         {
  102.         if (!pr1403)
  103.             fprintf(tabout, ".if \\n(T. .vs \\n(.vu-\\n(.sp\n");
  104.         fprintf(tabout, ".if \\n(T. ");
  105.         drawline(nlin,0,ncol, dboxflg ? '=' : '-',1,0);
  106.         fprintf(tabout, "\n.if \\n(T. .vs\n");
  107.         /* T. is really an argument to a macro but because of 
  108.            eqn we don't dare pass it as an argument and reference by $1 */
  109.         }
  110.     for(c=0; c<ncol; c++)
  111.         {
  112.         if ((lf=left(nlin-1,c, &lwid))>=0)
  113.             {
  114.             fprintf(tabout, ".if \\n(#%c>=0 .sp -1\n",linestop[lf]+'a'-1);
  115.             fprintf(tabout, ".if \\n(#%c>=0 ", linestop[lf]+'a'-1);
  116.             tohcol(c);
  117.             drawvert(lf, nlin-1, c, lwid);
  118.             fprintf(tabout, "\\h'|\\n(TWu'\n");
  119.             }
  120.         }
  121.     if (boxflg || allflg || dboxflg) /* right hand line */
  122.         {
  123.         fprintf(tabout, ".if \\n(#a>=0 .sp -1\n");
  124.         fprintf(tabout, ".if \\n(#a>=0 \\h'|\\n(TWu'");
  125.         drawvert (0, nlin-1, ncol, dboxflg? 2 : 1);
  126.         fprintf(tabout, "\n");
  127.         }
  128. fprintf(tabout, ".ls\n");
  129. fprintf(tabout, "..\n");
  130. fprintf(tabout, ".ec\n");
  131. }
  132.