t9.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* t9.c: write lines for tables over 200 lines */
  2. # include "t.h"
  3. static useln;
  4. void
  5. yetmore(void)
  6. {
  7. for (useln = 0; useln < MAXLIN && table[useln] == 0; useln++)
  8. ;
  9. if (useln >= MAXLIN)
  10. error("Wierd. No data in table.");
  11. table[0] = table[useln];
  12. for (useln = nlin - 1; useln >= 0 && (fullbot[useln] || instead[useln]); useln--)
  13. ;
  14. if (useln < 0)
  15. error("Wierd. No real lines in table.");
  16. domore(leftover);
  17. while (gets1(cstore = cspace, MAXCHS) && domore(cstore))
  18. ;
  19. last = cstore;
  20. return;
  21. }
  22. int
  23. domore(char *dataln)
  24. {
  25. int icol, ch;
  26. if (prefix(".TE", dataln))
  27. return(0);
  28. if (dataln[0] == '.' && !isdigit(dataln[1])) {
  29. Bprint(&tabout, "%s\n", dataln);
  30. return(1);
  31. }
  32. fullbot[0] = 0;
  33. instead[0] = (char *)0;
  34. if (dataln[1] == 0)
  35. switch (dataln[0]) {
  36. case '_':
  37. fullbot[0] = '-';
  38. putline(useln, 0);
  39. return(1);
  40. case '=':
  41. fullbot[0] = '=';
  42. putline(useln, 0);
  43. return(1);
  44. }
  45. for (icol = 0; icol < ncol; icol++) {
  46. table[0][icol].col = dataln;
  47. table[0][icol].rcol = 0;
  48. for (; (ch = *dataln) != '\0' && ch != tab; dataln++)
  49. ;
  50. *dataln++ = '\0';
  51. switch (ctype(useln, icol)) {
  52. case 'n':
  53. table[0][icol].rcol = maknew(table[0][icol].col);
  54. break;
  55. case 'a':
  56. table[0][icol].rcol = table[0][icol].col;
  57. table[0][icol].col = "";
  58. break;
  59. }
  60. while (ctype(useln, icol + 1) == 's') /* spanning */
  61. table[0][++icol].col = "";
  62. if (ch == '\0')
  63. break;
  64. }
  65. while (++icol < ncol)
  66. table[0][icol].col = "";
  67. putline(useln, 0);
  68. exstore = exspace; /* reuse space for numerical items */
  69. return(1);
  70. }