changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: acme: avoid division by zero when resizing col (#189)

changeset 7481: 94daa09298cb
parent 7480: 12d47c29977c
child 7482: d6de6e9ab3d1
author: Ori Bernstein <ori@eigenstate.org>
date: Wed, 04 Dec 2019 12:37:07 -0800
files: sys/src/cmd/acme/cols.c
description: acme: avoid division by zero when resizing col (#189)

To reproduce, create a column with at least two windows and resize
acme to have almost zero height.

(imported from plan9port commit 76b9347a5fa3a0970527c6ee1b97ef1c714f636b)
     1.1--- a/sys/src/cmd/acme/cols.c
     1.2+++ b/sys/src/cmd/acme/cols.c
     1.3@@ -197,8 +197,11 @@ colresize(Column *c, Rectangle r)
     1.4 		w->maxlines = 0;
     1.5 		if(i == c->nw-1)
     1.6 			r1.max.y = r.max.y;
     1.7-		else
     1.8-			r1.max.y = r1.min.y+(Dy(w->r)+Border)*Dy(r)/Dy(c->r);
     1.9+		else {
    1.10+			r1.max.y = r1.min.y;
    1.11+			if(Dy(c->r) != 0)
    1.12+				r1.max.y += (Dy(w->r)+Border)*Dy(r)/Dy(c->r);
    1.13+		}
    1.14 		r2 = r1;
    1.15 		r2.max.y = r2.min.y+Border;
    1.16 		draw(screen, r2, display->black, nil, ZP);