Loading ...
Sorry, an error occurred while loading the content.

2092Re: SEGV in msg_may_trunc()

Expand Messages
  • Bram Moolenaar
    Dec 22, 2005
      Pawel S. Veselov wrote:

      > this will work, but it will still count the length of the string twice
      > which I tried to avoid...

      The first time it's counted with strlen(), which is really fast. If it
      fits in the room when counting bytes, then it will also fit when
      counting characters (there may be more bytes than characters, but not
      the other way around). That avoids calling the slow vim_strsize() for
      every string.

      I do notice that the change I made does put in a ">" when the string
      just fits. I'll change that.

      > Still, what about the case when the '>' is placed into one of the bytes
      > of a multibyte character ?

      It is placed in the last byte of a multibyte character and then the
      pointer is adjusted to start displaying the '>'. That will always work.
      For example, if the message has "aaa123bbbb", where "123" is a multibyte
      character, then it may become "aaa12>bbbb" and ">bbbb" is displayed.

      "I've been teaching myself to play the piano for about 5 years and now write
      most of my songs on it, mainly because I can never find any paper."
      Jeff Lynne, ELO's greatest hits

      /// Bram Moolenaar -- Bram@... -- 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://www.ICCF.nl ///
    • Show all 5 messages in this topic