diff options
| author | rsc <devnull@localhost> | 2004-05-15 23:24:00 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2004-05-15 23:24:00 +0000 |
| commit | 5cedca1b69d020c32466f70843a11767773d7e3b (patch) | |
| tree | a15a3d84e92aa262543b0010763a5e6920c9ba24 /src/cmd/tbl/tc.c | |
| parent | 76e6aca867e3e48ea04fbcf7284c45369a69829e (diff) | |
| download | plan9port-5cedca1b69d020c32466f70843a11767773d7e3b.tar.gz plan9port-5cedca1b69d020c32466f70843a11767773d7e3b.zip | |
Let's try this. It's BUGGERED.
Diffstat (limited to 'src/cmd/tbl/tc.c')
| -rw-r--r-- | src/cmd/tbl/tc.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/cmd/tbl/tc.c b/src/cmd/tbl/tc.c new file mode 100644 index 00000000..635dbf8a --- /dev/null +++ b/src/cmd/tbl/tc.c @@ -0,0 +1,65 @@ +/* tc.c: find character not in table to delimit fields */ +# include "t.h" + +void +choochar(void) +{ + /* choose funny characters to delimit fields */ + int had[128], ilin, icol, k; + char *s; + + for (icol = 0; icol < 128; icol++) + had[icol] = 0; + F1 = F2 = 0; + for (ilin = 0; ilin < nlin; ilin++) { + if (instead[ilin]) + continue; + if (fullbot[ilin]) + continue; + for (icol = 0; icol < ncol; icol++) { + k = ctype(ilin, icol); + if (k == 0 || k == '-' || k == '=') + continue; + s = table[ilin][icol].col; + if (point(s)) + while (*s) + had[*s++] = 1; + s = table[ilin][icol].rcol; + if (point(s)) + while (*s) + had[*s++] = 1; + } + } + /* choose first funny character */ + for ( + s = "\002\003\005\006\007!%&#/?,:;<=>@`^~_{}+-*ABCDEFGHIJKMNOPQRSTUVWXYZabcdefgjkoqrstwxyz"; + *s; s++) { + if (had[*s] == 0) { + F1 = *s; + had[F1] = 1; + break; + } + } + /* choose second funny character */ + for ( + s = "\002\003\005\006\007:_~^`@;,<=>#%&!/?{}+-*ABCDEFGHIJKMNOPQRSTUVWXZabcdefgjkoqrstuwxyz"; + *s; s++) { + if (had[*s] == 0) { + F2 = *s; + break; + } + } + if (F1 == 0 || F2 == 0) + error("couldn't find characters to use for delimiters"); + return; +} + + +int +point(char *s) +{ + int ss = (int)s; + return(ss >= 128 || ss < 0); +} + + |
