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

BUG: tr() returns additional junk character

Expand Messages
  • Ingo Karkat
    Hi VIM developers, I found a bug in VIM 7.0 s new tr() function. If the {src} string contains exactly 80 characters, an additional junk character is appended
    Message 1 of 2 , Dec 4, 2006
    • 0 Attachment
      Hi VIM developers,

      I found a bug in VIM 7.0's new tr() function. If the {src} string contains exactly 80 characters, an additional junk character is appended to the tr() result; this happens regardless of whether a character translation has occurred or not.

      How to reproduce:
      vim -u NONE
      :echo tr('12345678901234567890123456789012345678901234567890123456789012345678901234567890', 'x', 'y')

      Note: If {src} contains more or less than 80 characters, the bug does not occur. If it occurs, it usually prints something like:
      12345678901234567890123456789012345678901234567890123456789012345678901234567890^E
      though the last junk character (^E) may differ.

      Affected platforms:
      I could reproduce this in console vim and gvim, on MS Windows XP SP2 and HP-UX 11.0 PA-RISC systems with the official, unpatched version 7.0, e.g.:
      VIM - Vi IMproved 7.0 (2006 May 7, compiled May 7 2006 16:18:30)
      MS-Windows 32 bit console version

      I hope this helps. Keep up the good work, I use VIM daily and couldn't live without it!

      -- regards, ingo

      /^-- Ingo Karkat -- /^-- /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --

      My favorite prime number is 57. Well, it certainly _looks_ prime, doesn't it?
    • Bram Moolenaar
      ... That s a bug. There is no terminating NUL. I ll make a patch. -- ARTHUR: I command you as King of the Britons to stand aside! BLACK KNIGHT: I
      Message 2 of 2 , Dec 5, 2006
      • 0 Attachment
        Ingo Karkat wrote:

        > I found a bug in VIM 7.0's new tr() function. If the {src} string
        > contains exactly 80 characters, an additional junk character is
        > appended to the tr() result; this happens regardless of whether a
        > character translation has occurred or not.
        >
        > How to reproduce:
        > vim -u NONE
        > :echo tr('12345678901234567890123456789012345678901234567890123456789012345678901234567890', 'x', 'y')
        >
        > Note: If {src} contains more or less than 80 characters, the bug does
        > not occur. If it occurs, it usually prints something like:
        > 12345678901234567890123456789012345678901234567890123456789012345678901234567890^E
        > though the last junk character (^E) may differ.
        >
        > Affected platforms:
        > I could reproduce this in console vim and gvim, on MS Windows XP SP2
        > and HP-UX 11.0 PA-RISC systems with the official, unpatched version
        > 7.0, e.g.:
        > VIM - Vi IMproved 7.0 (2006 May 7, compiled May 7 2006 16:18:30)
        > MS-Windows 32 bit console version
        >
        > I hope this helps. Keep up the good work, I use VIM daily and couldn't
        > live without it!

        That's a bug. There is no terminating NUL. I'll make a patch.

        --
        ARTHUR: I command you as King of the Britons to stand aside!
        BLACK KNIGHT: I move for no man.
        The Quest for the Holy Grail (Monty Python)

        /// 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://ICCF-Holland.org ///
      Your message has been successfully submitted and would be delivered to recipients shortly.