libframe: fix _frcanfit() for zero width runes, simplify chopframe()

front
cinap_lenrek 2014-01-07 02:24:16 +01:00
parent ee4ddd77f7
commit 720967f984
2 changed files with 6 additions and 8 deletions

View File

@ -78,11 +78,10 @@ static
void
chopframe(Frame *f, Point pt, ulong p, int bn)
{
Frbox *b;
Frbox *b, *eb;
for(b = &f->box[bn]; ; b++){
if(b >= &f->box[f->nbox])
drawerror(f->display, "endofframe");
eb = &f->box[f->nbox];
for(b = &f->box[bn]; b < eb; b++){
_frcklinewrap(f, &pt, b);
if(pt.y >= f->r.max.y)
break;
@ -91,7 +90,7 @@ chopframe(Frame *f, Point pt, ulong p, int bn)
}
f->nchars = p;
f->nlines = f->maxlines;
if(b<&f->box[f->nbox]) /* BUG */
if(b < eb) /* BUG */
_frdelbox(f, (int)(b-f->box), f->nbox-1);
}

View File

@ -25,10 +25,9 @@ _frcanfit(Frame *f, Point pt, Frbox *b)
w = chartorune(&r, (char*)p);
left -= stringnwidth(f->font, (char*)p, 1);
if(left < 0)
return nr;
break;
}
drawerror(f->display, "_frcanfit can't");
return 0;
return nr;
}
void