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

Re: SEGV in msg_may_trunc()

Expand Messages
  • Pawel S. Veselov
    ... I m sorry, I get it now. Thanks, Pawel. [ skipped ]
    Message 1 of 5 , Dec 21, 2005
    • 0 Attachment
      >Still, what about the case when the '>' is placed into one of the bytes
      >of a multibyte character ?

      I'm sorry, I get it now.

      Thanks,
      Pawel.

      [ skipped ]
    • Bram Moolenaar
      ... 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
      Message 2 of 5 , Dec 22, 2005
      • 0 Attachment
        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 ///
      Your message has been successfully submitted and would be delivered to recipients shortly.