tc.c 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /* tc.c: find character not in table to delimit fields */
  2. # include "t.h"
  3. # define COMMON "\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*" \
  4. "ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstwxyz"
  5. void
  6. choochar(void)
  7. {
  8. /* choose funny characters to delimit fields */
  9. int had[128], ilin, icol, k;
  10. char *s;
  11. for (icol = 0; icol < 128; icol++)
  12. had[icol] = 0;
  13. F1 = F2 = 0;
  14. for (ilin = 0; ilin < nlin; ilin++) {
  15. if (instead[ilin] || 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. for (; *s; s++)
  24. if((unsigned char)*s < 128)
  25. had[(unsigned char)*s] = 1;
  26. s = table[ilin][icol].rcol;
  27. if (point(s))
  28. for (; *s; s++)
  29. if((unsigned char)*s < 128)
  30. had[(unsigned char)*s] = 1;
  31. }
  32. }
  33. /* choose first funny character */
  34. for (s = COMMON "Y"; *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 (s = COMMON "u"; *s; s++) {
  43. if (had[*s] == 0) {
  44. F2 = *s;
  45. break;
  46. }
  47. }
  48. if (F1 == 0 || F2 == 0)
  49. error("couldn't find characters to use for delimiters");
  50. }
  51. int
  52. point(char *ss)
  53. {
  54. vlong s = (uintptr)ss;
  55. return(s >= 128 || s < 0);
  56. }