Dominique Pelle wrote:

> Attached patch fixes incorrect cell computation
> introduced my previous patch "fix2-invalid-utf8-seq.patch"
> while still correcting the original bug (read overflow).
> 
> I tested it, but please review it.
> 
> I'm not too pleased about the hard-coded 4 cells
> for illegal utf-8 sequence, but attached patch minimizes
> changes.  More elegant perhaps would be to add a safe
> function utf_ptr2cells_len(p, maxlen) which guarantees
> to read no more than maxlen bytes.

Yes, the hard-coding is not that nice.  How about using this instead:

*** ../vim-7.2a.010/src/message.c       Sun Jun 29 16:15:20 2008
--- src/message.c       Mon Jun 30 22:50:32 2008
***************
*** 1390,1397 ****
                                                                        attr);
                plain_start = str + 1;
                msg_puts_attr(s, attr == 0 ? hl_attr(HLF_8) : attr);
            }
!           retval += char2cells(*str);
            ++str;
        }
      }
--- 1390,1399 ----
                                                                        attr);
                plain_start = str + 1;
                msg_puts_attr(s, attr == 0 ? hl_attr(HLF_8) : attr);
+               retval += STRLEN(s);
            }
!           else
!               ++retval;
            ++str;
        }
      }

I'm wondering if STRLEN() is always right.  I can't think of a situation
where it's not.

-- 
Birthdays are healthy.  The more you have them, the longer you live.

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui