On Sun, Apr 03, 2011 at 11:21:35PM +0100, Nicholas Marriott wrote:
> > -   if (x + len - 1 <= win->_maxx) {
> > +   if (len >= 0 && x + len - 1 <= win->_maxx) {
> 
> Not sure this is required, astr is a cchar_t * which will come from
> setcchar.
 
Right. That already makes sure the string cannot contain non-printable
characters.

> > @@ -91,9 +92,12 @@ slk_set(int i, const char *astr, int for
> >     mbrtowc(&wc, p, need, &state);
> >     if (!iswprint((wint_t) wc))
> >         break;
> > -   if (wcwidth(wc) + numcols > limit)
> > +   w = wcwidth(wc);
> > +   if (w >= 0) {
> > +     if (w + numcols > limit)
> >         break;
> > -   numcols += wcwidth(wc);
> > +     numcols += w;
> > +   }
> 
> Doesn't iswprint() make this unnecessary?

Doh! :)

> >     for (i = 1; i < len; ++i) {
> > -       if (wcwidth(wch[i]) != 0) {
> > +       if (wcwidth(wch[i]) >= 1) {
> 
> This seems sane although the comment at the top of the function says "we
> assume" this cannot happen.

Then let's shelve this diff until we find a serious problem.
Thanks for the review!

Reply via email to