diff options
author | rsc <devnull@localhost> | 2006-04-20 21:00:21 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-04-20 21:00:21 +0000 |
commit | a5f3a00bcd0452d78afc5d8064da611d4b448093 (patch) | |
tree | f037f35d470d699c90cbf78888620a9155d7cfbd /src/cmd/tbl | |
parent | 71e936d7166b088aa3e2ec55d14b53cb2a3ac5ec (diff) | |
download | plan9port-a5f3a00bcd0452d78afc5d8064da611d4b448093.tar.gz plan9port-a5f3a00bcd0452d78afc5d8064da611d4b448093.tar.bz2 plan9port-a5f3a00bcd0452d78afc5d8064da611d4b448093.zip |
64-bit safe
Diffstat (limited to 'src/cmd/tbl')
-rw-r--r-- | src/cmd/tbl/t6.c | 35 | ||||
-rw-r--r-- | src/cmd/tbl/t8.c | 52 | ||||
-rw-r--r-- | src/cmd/tbl/tc.c | 8 | ||||
-rw-r--r-- | src/cmd/tbl/tg.c | 9 | ||||
-rw-r--r-- | src/cmd/tbl/tm.c | 8 |
5 files changed, 62 insertions, 50 deletions
diff --git a/src/cmd/tbl/t6.c b/src/cmd/tbl/t6.c index a78368fc..463bfa10 100644 --- a/src/cmd/tbl/t6.c +++ b/src/cmd/tbl/t6.c @@ -9,8 +9,8 @@ void maktab(void) /* define the tab stops of the table */ { - int icol, ilin, tsep, k, ik, vforml, il, text; - char *s; + int icol, ilin, tsep, k, ik, vforml, il, s, text; + char *ss; for (icol = 0; icol < ncol; icol++) { doubled[icol] = acase[icol] = 0; @@ -34,14 +34,15 @@ maktab(void) /* define the tab stops of the table */ switch (ctype(vforml, icol)) { case 'a': acase[icol] = 1; - s = table[ilin][icol].col; - if ((int)s > 0 && (int)s < 128 && text) { + ss = table[ilin][icol].col; + s = (int)(uintptr)ss; + if (s > 0 && s < 128 && text) { if (doubled[icol] == 0) Bprint(&tabout, ".nr %d 0\n.nr %d 0\n", S1, S2); doubled[icol] = 1; Bprint(&tabout, ".if \\n(%c->\\n(%d .nr %d \\n(%c-\n", - (int)s, S2, S2, (int)s); + s, S2, S2, s); } case 'n': if (table[ilin][icol].rcol != 0) { @@ -49,18 +50,19 @@ maktab(void) /* define the tab stops of the table */ Bprint(&tabout, ".nr %d 0\n.nr %d 0\n", S1, S2); doubled[icol] = 1; - if (real(s = table[ilin][icol].col) && !vspen(s)) { - if (tx((int)s) != text) + if (real(ss = table[ilin][icol].col) && !vspen(ss)) { + s = (int)(uintptr)ss; + if (tx(s) != text) continue; Bprint(&tabout, ".nr %d ", TMP); - wide(s, FN(vforml, icol), SZ(vforml, icol)); + wide(ss, FN(vforml, icol), SZ(vforml, icol)); Bprint(&tabout, "\n"); Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S1, TMP, S1, TMP); } - if (text == 0 && real(s = table[ilin][icol].rcol) && !vspen(s) && !barent(s)) { + if (text == 0 && real(ss = table[ilin][icol].rcol) && !vspen(ss) && !barent(ss)) { Bprint(&tabout, ".nr %d \\w%c%s%c\n", - TMP, F1, s, F1); + TMP, F1, ss, F1); Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S2, TMP, S2, TMP); } @@ -69,11 +71,12 @@ maktab(void) /* define the tab stops of the table */ case 'r': case 'c': case 'l': - if (real(s = table[ilin][icol].col) && !vspen(s)) { - if (tx((int)s) != text) + if (real(ss = table[ilin][icol].col) && !vspen(ss)) { + s = (int)(uintptr)ss; + if (tx(s) != text) continue; Bprint(&tabout, ".nr %d ", TMP); - wide(s, FN(vforml, icol), SZ(vforml, icol)); + wide(ss, FN(vforml, icol), SZ(vforml, icol)); Bprint(&tabout, "\n"); Bprint(&tabout, ".if \\n(%2s<\\n(%d .nr %2s \\n(%d\n", reg(icol, CRIGHT), TMP, reg(icol, CRIGHT), TMP); @@ -100,8 +103,8 @@ maktab(void) /* define the tab stops of the table */ } for (ilin = 0; ilin < nlin; ilin++) if (k = lspan(ilin, icol)) { - s = table[ilin][icol-k].col; - if (!real(s) || barent(s) || vspen(s) ) + ss = table[ilin][icol-k].col; + if (!real(ss) || barent(ss) || vspen(ss) ) continue; Bprint(&tabout, ".nr %d ", TMP); wide(table[ilin][icol-k].col, FN(ilin, icol - k), SZ(ilin, icol - k)); @@ -210,7 +213,7 @@ wide(char *s, char *fn, char *size) putsize("0"); Bprint(&tabout, "%c", F1); } else - Bprint(&tabout, "\\n(%c-", (int)s); + Bprint(&tabout, "\\n(%c-", (int)(uintptr)s); } diff --git a/src/cmd/tbl/t8.c b/src/cmd/tbl/t8.c index 92277e2a..bfa21ecf 100644 --- a/src/cmd/tbl/t8.c +++ b/src/cmd/tbl/t8.c @@ -9,9 +9,9 @@ putline(int i, int nl) /* i is line number for deciding format */ /* nl is line number for finding data usually identical */ { - int c, lf, ct, form, lwid, vspf, ip, cmidx, exvspen, vforml; + int c, s, lf, ct, form, lwid, vspf, ip, cmidx, exvspen, vforml; int vct, chfont, uphalf; - char *s, *size, *fn, *rct; + char *ss, *size, *fn, *rct; cmidx = watchout = vspf = exvspen = 0; if (i == 0) @@ -20,20 +20,22 @@ putline(int i, int nl) fullwide(0, dboxflg ? '=' : '-'); if (instead[nl] == 0 && fullbot[nl] == 0) for (c = 0; c < ncol; c++) { - s = table[nl][c].col; - if (s == 0) + ss = table[nl][c].col; + if (ss == 0) continue; - if (vspen(s)) { + if (vspen(ss)) { for (ip = nl; ip < nlin; ip = next(ip)) - if (!vspen(s = table[ip][c].col)) + if (!vspen(ss = table[ip][c].col)) break; - if ((int)s > 0 && (int)s < 128) + s = (int)(uintptr)ss; + if (s > 0 && s < 128) Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", (int)s); continue; } - if (point(s)) + if (point(ss)) continue; - Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", (int)s); + s = (int)(uintptr)ss; + Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", s); watchout = 1; } if (linestop[nl]) @@ -66,17 +68,19 @@ putline(int i, int nl) vspf = 0; chfont = 0; for (c = 0; c < ncol; c++) { - s = table[nl][c].col; - if (s == 0) + ss = table[nl][c].col; + if (ss == 0) continue; - chfont |= (int)(font[c][stynum[nl]]); - if (point(s) ) + if(font[c][stynum[nl]]) + chfont = 1; + if (point(ss) ) continue; + s = (int)(uintptr)ss; lf = prev(nl); if (lf >= 0 && vspen(table[lf][c].col)) Bprint(&tabout, ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n", - (int)s, 'a' + c, (int)s, 'a' + c); + s, 'a' + c, s, 'a' + c); else Bprint(&tabout, ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n", @@ -117,7 +121,7 @@ putline(int i, int nl) rct = reg(c, CMID); Bprint(&tabout, "\\h'|\\n(%2su'", rct); } - s = table[nl][c].col; + ss = table[nl][c].col; fn = font[c][stynum[vforml]]; size = csize[c][stynum[vforml]]; if (*size == 0) @@ -150,12 +154,12 @@ putline(int i, int nl) Bprint(&tabout, "%c%c", F1, F2); if (uphalf) Bprint(&tabout, "\\u"); - puttext(s, fn, size); + puttext(ss, fn, size); if (uphalf) Bprint(&tabout, "\\d"); Bprint(&tabout, "%c", F1); } - s = table[nl][c].rcol; + ss = table[nl][c].rcol; form = 1; break; } @@ -179,12 +183,12 @@ putline(int i, int nl) } if (realsplit ? rused[c] : used[c]) /*Zero field width*/ { /* form: 1 left, 2 right, 3 center adjust */ - if (ifline(s)) { - makeline(i, c, ifline(s)); + if (ifline(ss)) { + makeline(i, c, ifline(ss)); continue; } - if (filler(s)) { - Bprint(&tabout, "\\l'|\\n(%2su\\&%s'", reg(c, CRIGHT), s + 2); + if (filler(ss)) { + Bprint(&tabout, "\\l'|\\n(%2su\\&%s'", reg(c, CRIGHT), ss + 2); continue; } ip = prev(nl); @@ -204,13 +208,13 @@ putline(int i, int nl) Bprint(&tabout, "%c", F1); if (form != 1) Bprint(&tabout, "%c", F2); - if (vspen(s)) + if (vspen(ss)) vspf = 1; else { if (uphalf) Bprint(&tabout, "\\u"); - puttext(s, fn, size); + puttext(ss, fn, size); if (uphalf) Bprint(&tabout, "\\d"); } @@ -289,7 +293,7 @@ funnies(int stl, int lin) continue; if (ss == 0) continue; - s = (int)ss; + s = (int)(uintptr)ss; Bprint(&tabout, ".sp |\\n(##u-1v\n"); Bprint(&tabout, ".nr %d ", SIND); ct = 0; diff --git a/src/cmd/tbl/tc.c b/src/cmd/tbl/tc.c index 6323c267..a89fc0f0 100644 --- a/src/cmd/tbl/tc.c +++ b/src/cmd/tbl/tc.c @@ -5,7 +5,7 @@ void choochar(void) { /* choose funny characters to delimit fields */ - int had[128], ilin, icol, k; + int had[256], ilin, icol, k; char *s; for (icol = 0; icol < 128; icol++) @@ -56,10 +56,10 @@ choochar(void) int -point(char *s) +point(char *ss) { - int ss = (int)s; - return(ss >= 128 || ss < 0); + int s = (int)(uintptr)ss; + return(s >= 128 || s < 0); } diff --git a/src/cmd/tbl/tg.c b/src/cmd/tbl/tg.c index 6abb1490..3afc88c6 100644 --- a/src/cmd/tbl/tg.c +++ b/src/cmd/tbl/tg.c @@ -6,9 +6,10 @@ gettext(char *sp, int ilin, int icol, char *fn, char *sz) { /* get a section of text */ char line[4096]; - int oname; + int oname, startline; char *vs; + startline = iline; if (texname == 0) error("Too many text block diversions"); if (textflg == 0) { @@ -42,7 +43,11 @@ gettext(char *sp, int ilin, int icol, char *fn, char *sz) if (ctype(ilin, icol) == 'a') Bprint(&tabout, ".ll -2n\n"); Bprint(&tabout, ".in 0\n"); - while (gets1(line, sizeof(line))) { + for (;;) { + if (gets1(line, sizeof(line)) == nil) { + iline = startline; + error("missing closing T}"); + } if (line[0] == 'T' && line[1] == '}' && line[2] == tab) break; if (match("T}", line)) diff --git a/src/cmd/tbl/tm.c b/src/cmd/tbl/tm.c index 8fa4e497..5b58f0d1 100644 --- a/src/cmd/tbl/tm.c +++ b/src/cmd/tbl/tm.c @@ -5,8 +5,8 @@ char * maknew(char *str) { /* make two numerical fields */ - int dpoint, c; - char *p, *q, *ba; + int c; + char *p, *q, *ba, *dpoint; p = str; for (ba = 0; c = *str; str++) @@ -18,7 +18,7 @@ maknew(char *str) if (*str == '.' && !ineqn(str, p) && (str > p && digit(*(str - 1)) || digit(*(str + 1)))) - dpoint = (int)str; + dpoint = str; } if (dpoint == 0) for (; str > p; str--) { @@ -28,7 +28,7 @@ maknew(char *str) if (!dpoint && p == str) /* not numerical, don't split */ return(0); if (dpoint) - str = (char *)dpoint; + str = dpoint; } else str = ba; p = str; |