t9.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. }
  21. int
  22. domore(char *dataln)
  23. {
  24. int icol, ch;
  25. if (prefix(".TE", dataln))
  26. return(0);
  27. if (dataln[0] == '.' && !isdigit(dataln[1])) {
  28. Bprint(&tabout, "%s\n", dataln);
  29. return(1);
  30. }
  31. fullbot[0] = 0;
  32. instead[0] = (char *)0;
  33. if (dataln[1] == 0)
  34. switch (dataln[0]) {
  35. case '_':
  36. fullbot[0] = '-';
  37. putline(useln, 0);
  38. return(1);
  39. case '=':
  40. fullbot[0] = '=';
  41. putline(useln, 0);
  42. return(1);
  43. }
  44. for (icol = 0; icol < ncol; icol++) {
  45. table[0][icol].col = dataln;
  46. table[0][icol].rcol = 0;
  47. for (; (ch = *dataln) != '\0' && ch != tab; dataln++)
  48. ;
  49. *dataln++ = '\0';
  50. switch (ctype(useln, icol)) {
  51. case 'n':
  52. table[0][icol].rcol = maknew(table[0][icol].col);
  53. break;
  54. case 'a':
  55. table[0][icol].rcol = table[0][icol].col;
  56. table[0][icol].col = "";
  57. break;
  58. }
  59. while (ctype(useln, icol + 1) == 's') /* spanning */
  60. table[0][++icol].col = "";
  61. if (ch == '\0')
  62. break;
  63. }
  64. while (++icol < ncol)
  65. table[0][icol].col = "";
  66. putline(useln, 0);
  67. exstore = exspace; /* reuse space for numerical items */
  68. return(1);
  69. }