tc.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. if((unsigned char)*s < 128)
  25. had[(unsigned char)*s] = 1;
  26. s++;
  27. }
  28. s = table[ilin][icol].rcol;
  29. if (point(s))
  30. while (*s) {
  31. if((unsigned char)*s < 128)
  32. had[(unsigned char)*s] = 1;
  33. s++;
  34. }
  35. }
  36. }
  37. /* choose first funny character */
  38. for (
  39. s = "\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz";
  40. *s; s++) {
  41. if (had[*s] == 0) {
  42. F1 = *s;
  43. had[F1] = 1;
  44. break;
  45. }
  46. }
  47. /* choose second funny character */
  48. for (
  49. s = "\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz";
  50. *s; s++) {
  51. if (had[*s] == 0) {
  52. F2 = *s;
  53. break;
  54. }
  55. }
  56. if (F1 == 0 || F2 == 0)
  57. error("couldn't find characters to use for delimiters");
  58. return;
  59. }
  60. int
  61. point(char *ss)
  62. {
  63. int s = (int)(uintptr)ss;
  64. return(s >= 128 || s < 0);
  65. }