diff options
author | dwmalone <dwmalone@FreeBSD.org> | 2001-04-03 18:03:29 +0000 |
---|---|---|
committer | dwmalone <dwmalone@FreeBSD.org> | 2001-04-03 18:03:29 +0000 |
commit | fc732ffe205b975367149e80a047f95edf555188 (patch) | |
tree | 9af9a0591ffe77d62405e1fce8daf5e92f15e660 /usr.bin/column | |
parent | ba67d5732f2cc78012cd5bbc6e538104e0ba7236 (diff) | |
download | FreeBSD-src-fc732ffe205b975367149e80a047f95edf555188.zip FreeBSD-src-fc732ffe205b975367149e80a047f95edf555188.tar.gz |
Round up before checking if the width is smaller than the widest
column, otherwise we may divide by zero later.
PR: 26283
Reviewed by: roam
Diffstat (limited to 'usr.bin/column')
-rw-r--r-- | usr.bin/column/column.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/usr.bin/column/column.c b/usr.bin/column/column.c index 043ab9d..e0a50fc 100644 --- a/usr.bin/column/column.c +++ b/usr.bin/column/column.c @@ -29,6 +29,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $FreeBSD$ */ #ifndef lint @@ -52,6 +54,8 @@ static const char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95"; #include <string.h> #include <unistd.h> +#define TAB 8 + void c_columnate __P((void)); void *emalloc __P((int)); void input __P((FILE *)); @@ -120,6 +124,7 @@ main(argc, argv) if (!entries) exit(eval); + maxlength = (maxlength + TAB) & ~(TAB - 1); if (tflag) maketbl(); else if (maxlength >= termwidth) @@ -131,14 +136,12 @@ main(argc, argv) exit(eval); } -#define TAB 8 void c_columnate() { int chcnt, col, cnt, endcol, numcols; char **lp; - maxlength = (maxlength + TAB) & ~(TAB - 1); numcols = termwidth / maxlength; endcol = maxlength; for (chcnt = col = 0, lp = list;; ++lp) { @@ -166,7 +169,6 @@ r_columnate() { int base, chcnt, cnt, col, endcol, numcols, numrows, row; - maxlength = (maxlength + TAB) & ~(TAB - 1); numcols = termwidth / maxlength; numrows = entries / numcols; if (entries % numcols) |