64-bit safe

This commit is contained in:
rsc 2006-04-20 21:00:21 +00:00
parent 71e936d716
commit a5f3a00bcd
5 changed files with 62 additions and 50 deletions

View file

@ -9,8 +9,8 @@
void void
maktab(void) /* define the tab stops of the table */ maktab(void) /* define the tab stops of the table */
{ {
int icol, ilin, tsep, k, ik, vforml, il, text; int icol, ilin, tsep, k, ik, vforml, il, s, text;
char *s; char *ss;
for (icol = 0; icol < ncol; icol++) { for (icol = 0; icol < ncol; icol++) {
doubled[icol] = acase[icol] = 0; doubled[icol] = acase[icol] = 0;
@ -34,14 +34,15 @@ maktab(void) /* define the tab stops of the table */
switch (ctype(vforml, icol)) { switch (ctype(vforml, icol)) {
case 'a': case 'a':
acase[icol] = 1; acase[icol] = 1;
s = table[ilin][icol].col; ss = table[ilin][icol].col;
if ((int)s > 0 && (int)s < 128 && text) { s = (int)(uintptr)ss;
if (s > 0 && s < 128 && text) {
if (doubled[icol] == 0) if (doubled[icol] == 0)
Bprint(&tabout, ".nr %d 0\n.nr %d 0\n", Bprint(&tabout, ".nr %d 0\n.nr %d 0\n",
S1, S2); S1, S2);
doubled[icol] = 1; doubled[icol] = 1;
Bprint(&tabout, ".if \\n(%c->\\n(%d .nr %d \\n(%c-\n", Bprint(&tabout, ".if \\n(%c->\\n(%d .nr %d \\n(%c-\n",
(int)s, S2, S2, (int)s); s, S2, S2, s);
} }
case 'n': case 'n':
if (table[ilin][icol].rcol != 0) { 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", Bprint(&tabout, ".nr %d 0\n.nr %d 0\n",
S1, S2); S1, S2);
doubled[icol] = 1; doubled[icol] = 1;
if (real(s = table[ilin][icol].col) && !vspen(s)) { if (real(ss = table[ilin][icol].col) && !vspen(ss)) {
if (tx((int)s) != text) s = (int)(uintptr)ss;
if (tx(s) != text)
continue; continue;
Bprint(&tabout, ".nr %d ", TMP); 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, "\n");
Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n",
S1, TMP, S1, TMP); 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", 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, Bprint(&tabout, ".if \\n(%d<\\n(%d .nr %d \\n(%d\n", S2, TMP, S2,
TMP); TMP);
} }
@ -69,11 +71,12 @@ maktab(void) /* define the tab stops of the table */
case 'r': case 'r':
case 'c': case 'c':
case 'l': case 'l':
if (real(s = table[ilin][icol].col) && !vspen(s)) { if (real(ss = table[ilin][icol].col) && !vspen(ss)) {
if (tx((int)s) != text) s = (int)(uintptr)ss;
if (tx(s) != text)
continue; continue;
Bprint(&tabout, ".nr %d ", TMP); 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, "\n");
Bprint(&tabout, ".if \\n(%2s<\\n(%d .nr %2s \\n(%d\n", Bprint(&tabout, ".if \\n(%2s<\\n(%d .nr %2s \\n(%d\n",
reg(icol, CRIGHT), TMP, reg(icol, CRIGHT), TMP); 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++) for (ilin = 0; ilin < nlin; ilin++)
if (k = lspan(ilin, icol)) { if (k = lspan(ilin, icol)) {
s = table[ilin][icol-k].col; ss = table[ilin][icol-k].col;
if (!real(s) || barent(s) || vspen(s) ) if (!real(ss) || barent(ss) || vspen(ss) )
continue; continue;
Bprint(&tabout, ".nr %d ", TMP); Bprint(&tabout, ".nr %d ", TMP);
wide(table[ilin][icol-k].col, FN(ilin, icol - k), SZ(ilin, icol - k)); 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"); putsize("0");
Bprint(&tabout, "%c", F1); Bprint(&tabout, "%c", F1);
} else } else
Bprint(&tabout, "\\n(%c-", (int)s); Bprint(&tabout, "\\n(%c-", (int)(uintptr)s);
} }

View file

@ -9,9 +9,9 @@ putline(int i, int nl)
/* i is line number for deciding format */ /* i is line number for deciding format */
/* nl is line number for finding data usually identical */ /* 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; int vct, chfont, uphalf;
char *s, *size, *fn, *rct; char *ss, *size, *fn, *rct;
cmidx = watchout = vspf = exvspen = 0; cmidx = watchout = vspf = exvspen = 0;
if (i == 0) if (i == 0)
@ -20,20 +20,22 @@ putline(int i, int nl)
fullwide(0, dboxflg ? '=' : '-'); fullwide(0, dboxflg ? '=' : '-');
if (instead[nl] == 0 && fullbot[nl] == 0) if (instead[nl] == 0 && fullbot[nl] == 0)
for (c = 0; c < ncol; c++) { for (c = 0; c < ncol; c++) {
s = table[nl][c].col; ss = table[nl][c].col;
if (s == 0) if (ss == 0)
continue; continue;
if (vspen(s)) { if (vspen(ss)) {
for (ip = nl; ip < nlin; ip = next(ip)) for (ip = nl; ip < nlin; ip = next(ip))
if (!vspen(s = table[ip][c].col)) if (!vspen(ss = table[ip][c].col))
break; 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); Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", (int)s);
continue; continue;
} }
if (point(s)) if (point(ss))
continue; 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; watchout = 1;
} }
if (linestop[nl]) if (linestop[nl])
@ -66,17 +68,19 @@ putline(int i, int nl)
vspf = 0; vspf = 0;
chfont = 0; chfont = 0;
for (c = 0; c < ncol; c++) { for (c = 0; c < ncol; c++) {
s = table[nl][c].col; ss = table[nl][c].col;
if (s == 0) if (ss == 0)
continue; continue;
chfont |= (int)(font[c][stynum[nl]]); if(font[c][stynum[nl]])
if (point(s) ) chfont = 1;
if (point(ss) )
continue; continue;
s = (int)(uintptr)ss;
lf = prev(nl); lf = prev(nl);
if (lf >= 0 && vspen(table[lf][c].col)) if (lf >= 0 && vspen(table[lf][c].col))
Bprint(&tabout, Bprint(&tabout,
".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n", ".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 else
Bprint(&tabout, Bprint(&tabout,
".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n", ".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); rct = reg(c, CMID);
Bprint(&tabout, "\\h'|\\n(%2su'", rct); Bprint(&tabout, "\\h'|\\n(%2su'", rct);
} }
s = table[nl][c].col; ss = table[nl][c].col;
fn = font[c][stynum[vforml]]; fn = font[c][stynum[vforml]];
size = csize[c][stynum[vforml]]; size = csize[c][stynum[vforml]];
if (*size == 0) if (*size == 0)
@ -150,12 +154,12 @@ putline(int i, int nl)
Bprint(&tabout, "%c%c", F1, F2); Bprint(&tabout, "%c%c", F1, F2);
if (uphalf) if (uphalf)
Bprint(&tabout, "\\u"); Bprint(&tabout, "\\u");
puttext(s, fn, size); puttext(ss, fn, size);
if (uphalf) if (uphalf)
Bprint(&tabout, "\\d"); Bprint(&tabout, "\\d");
Bprint(&tabout, "%c", F1); Bprint(&tabout, "%c", F1);
} }
s = table[nl][c].rcol; ss = table[nl][c].rcol;
form = 1; form = 1;
break; break;
} }
@ -179,12 +183,12 @@ putline(int i, int nl)
} }
if (realsplit ? rused[c] : used[c]) /*Zero field width*/ { if (realsplit ? rused[c] : used[c]) /*Zero field width*/ {
/* form: 1 left, 2 right, 3 center adjust */ /* form: 1 left, 2 right, 3 center adjust */
if (ifline(s)) { if (ifline(ss)) {
makeline(i, c, ifline(s)); makeline(i, c, ifline(ss));
continue; continue;
} }
if (filler(s)) { if (filler(ss)) {
Bprint(&tabout, "\\l'|\\n(%2su\\&%s'", reg(c, CRIGHT), s + 2); Bprint(&tabout, "\\l'|\\n(%2su\\&%s'", reg(c, CRIGHT), ss + 2);
continue; continue;
} }
ip = prev(nl); ip = prev(nl);
@ -204,13 +208,13 @@ putline(int i, int nl)
Bprint(&tabout, "%c", F1); Bprint(&tabout, "%c", F1);
if (form != 1) if (form != 1)
Bprint(&tabout, "%c", F2); Bprint(&tabout, "%c", F2);
if (vspen(s)) if (vspen(ss))
vspf = 1; vspf = 1;
else else
{ {
if (uphalf) if (uphalf)
Bprint(&tabout, "\\u"); Bprint(&tabout, "\\u");
puttext(s, fn, size); puttext(ss, fn, size);
if (uphalf) if (uphalf)
Bprint(&tabout, "\\d"); Bprint(&tabout, "\\d");
} }
@ -289,7 +293,7 @@ funnies(int stl, int lin)
continue; continue;
if (ss == 0) if (ss == 0)
continue; continue;
s = (int)ss; s = (int)(uintptr)ss;
Bprint(&tabout, ".sp |\\n(##u-1v\n"); Bprint(&tabout, ".sp |\\n(##u-1v\n");
Bprint(&tabout, ".nr %d ", SIND); Bprint(&tabout, ".nr %d ", SIND);
ct = 0; ct = 0;

View file

@ -5,7 +5,7 @@ void
choochar(void) choochar(void)
{ {
/* choose funny characters to delimit fields */ /* choose funny characters to delimit fields */
int had[128], ilin, icol, k; int had[256], ilin, icol, k;
char *s; char *s;
for (icol = 0; icol < 128; icol++) for (icol = 0; icol < 128; icol++)
@ -56,10 +56,10 @@ choochar(void)
int int
point(char *s) point(char *ss)
{ {
int ss = (int)s; int s = (int)(uintptr)ss;
return(ss >= 128 || ss < 0); return(s >= 128 || s < 0);
} }

View file

@ -6,9 +6,10 @@ gettext(char *sp, int ilin, int icol, char *fn, char *sz)
{ {
/* get a section of text */ /* get a section of text */
char line[4096]; char line[4096];
int oname; int oname, startline;
char *vs; char *vs;
startline = iline;
if (texname == 0) if (texname == 0)
error("Too many text block diversions"); error("Too many text block diversions");
if (textflg == 0) { if (textflg == 0) {
@ -42,7 +43,11 @@ gettext(char *sp, int ilin, int icol, char *fn, char *sz)
if (ctype(ilin, icol) == 'a') if (ctype(ilin, icol) == 'a')
Bprint(&tabout, ".ll -2n\n"); Bprint(&tabout, ".ll -2n\n");
Bprint(&tabout, ".in 0\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) if (line[0] == 'T' && line[1] == '}' && line[2] == tab)
break; break;
if (match("T}", line)) if (match("T}", line))

View file

@ -5,8 +5,8 @@ char *
maknew(char *str) maknew(char *str)
{ {
/* make two numerical fields */ /* make two numerical fields */
int dpoint, c; int c;
char *p, *q, *ba; char *p, *q, *ba, *dpoint;
p = str; p = str;
for (ba = 0; c = *str; str++) for (ba = 0; c = *str; str++)
@ -18,7 +18,7 @@ maknew(char *str)
if (*str == '.' && !ineqn(str, p) && if (*str == '.' && !ineqn(str, p) &&
(str > p && digit(*(str - 1)) || (str > p && digit(*(str - 1)) ||
digit(*(str + 1)))) digit(*(str + 1))))
dpoint = (int)str; dpoint = str;
} }
if (dpoint == 0) if (dpoint == 0)
for (; str > p; str--) { for (; str > p; str--) {
@ -28,7 +28,7 @@ maknew(char *str)
if (!dpoint && p == str) /* not numerical, don't split */ if (!dpoint && p == str) /* not numerical, don't split */
return(0); return(0);
if (dpoint) if (dpoint)
str = (char *)dpoint; str = dpoint;
} else } else
str = ba; str = ba;
p = str; p = str;