Fixed SIGFPE (divide by zero) if column's width exceeds display width (-w).

Obtained from:	OpenBSD
This commit is contained in:
ru 2001-09-10 11:56:07 +00:00
parent 8cede4f874
commit ca7cfbacf3

View File

@ -257,9 +257,11 @@ prepfile()
} }
else if (orows == 0 && ocols == 0) { /* decide rows and cols */ else if (orows == 0 && ocols == 0) { /* decide rows and cols */
ocols = owidth / colw; ocols = owidth / colw;
if (ocols == 0) if (ocols == 0) {
warnx("display width %d is less than column width %d", warnx("display width %d is less than column width %d",
owidth, colw); owidth, colw);
ocols = 1;
}
if (ocols > nelem) if (ocols > nelem)
ocols = nelem; ocols = nelem;
orows = nelem / ocols + (nelem % ocols ? 1 : 0); orows = nelem / ocols + (nelem % ocols ? 1 : 0);