Fixed the -z option handling:

-Wuninitialized if used without -t.

PR:		bin/30467

Null pointer dereference if used with -t.

Maximum column width computation was wrong.
This commit is contained in:
Ruslan Ermilov 2001-09-10 11:43:40 +00:00
parent 45ae719fd9
commit c4c981072b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=83296

View File

@ -244,7 +244,7 @@ prepfile()
register int j;
char **lp;
int colw;
int max = 0;
int max;
int n;
if (!nelem)
@ -281,15 +281,18 @@ prepfile()
if (!(colwidths = (short *) malloc(ocols * sizeof(short))))
errx(1, "malloc");
if (flags & SQUEEZE) {
ep = elem;
if (flags & TRANSPOSE)
for (ep = elem, i = 0; i < ocols; i++) {
for (j = 0; j < orows; j++)
for (i = 0; i < ocols; i++) {
max = 0;
for (j = 0; *ep != NULL && j < orows; j++)
if ((n = strlen(*ep++)) > max)
max = n;
colwidths[i] = max + gutter;
}
else
for (i = 0; i < ocols; i++) {
max = 0;
for (j = i; j < nelem; j += ocols)
if ((n = strlen(ep[j])) > max)
max = n;