summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2001-09-10 11:43:40 +0000
committerru <ru@FreeBSD.org>2001-09-10 11:43:40 +0000
commit4f02a0040705046b4fb890b2adad20c977df7876 (patch)
tree6284483cf4d354d477c32076e3f064b1ba09ccfb /usr.bin
parent88f682cd6ba8173bb8d16cd11d9d86dac5fcfa63 (diff)
downloadFreeBSD-src-4f02a0040705046b4fb890b2adad20c977df7876.zip
FreeBSD-src-4f02a0040705046b4fb890b2adad20c977df7876.tar.gz
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.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/rs/rs.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/rs/rs.c b/usr.bin/rs/rs.c
index bd7dc33..ebb4238 100644
--- a/usr.bin/rs/rs.c
+++ b/usr.bin/rs/rs.c
@@ -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;
OpenPOWER on IntegriCloud