tc.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* tc.c: find character not in table to delimit fields */
  2. # include "t.h"
  3. void
  4. choochar(void)
  5. {
  6. /* choose funny characters to delimit fields */
  7. int had[128], ilin, icol, k;
  8. char *s;
  9. for (icol = 0; icol < 128; icol++)
  10. had[icol] = 0;
  11. F1 = F2 = 0;
  12. for (ilin = 0; ilin < nlin; ilin++) {
  13. if (instead[ilin])
  14. continue;
  15. if (fullbot[ilin])
  16. continue;
  17. for (icol = 0; icol < ncol; icol++) {
  18. k = ctype(ilin, icol);
  19. if (k == 0 || k == '-' || k == '=')
  20. continue;
  21. s = table[ilin][icol].col;
  22. if (point(s))
  23. while (*s)
  24. had[*s++] = 1;
  25. s = table[ilin][icol].rcol;
  26. if (point(s))
  27. while (*s)
  28. had[*s++] = 1;
  29. }
  30. }
  31. /* choose first funny character */
  32. for (
  33. s = "\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz";
  34. *s; s++) {
  35. if (had[*s] == 0) {
  36. F1 = *s;
  37. had[F1] = 1;
  38. break;
  39. }
  40. }
  41. /* choose second funny character */
  42. for (
  43. s = "\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz";
  44. *s; s++) {
  45. if (had[*s] == 0) {
  46. F2 = *s;
  47. break;
  48. }
  49. }
  50. if (F1 == 0 || F2 == 0)
  51. error("couldn't find characters to use for delimiters");
  52. return;
  53. }
  54. int
  55. point(char *s)
  56. {
  57. int ss = (int)s;
  58. return(ss >= 128 || ss < 0);
  59. }