home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / patches / 6.0.019 < prev    next >
Encoding:
Internet Message Format  |  2001-10-21  |  2.4 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.019
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. MIME-Version: 1.0
  6. Content-Type: text/plain; charset=ISO-8859-1
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 6.0.019
  11. Problem:    Converting a string with multi-byte characters to a printable
  12.         string, e.g., with strtrans(), may cause a crash. (Tomas Zellerin)
  13. Solution:   Correctly compute the length of the result in transstr().
  14. Files:        src/charset.c
  15.  
  16.  
  17. *** ../vim60.18/src/charset.c    Wed Sep 19 17:28:08 2001
  18. --- src/charset.c    Mon Oct 22 12:43:03 2001
  19. ***************
  20. *** 327,351 ****
  21.       char_u    *s;
  22.   {
  23.       char_u    *res;
  24.   #ifdef FEAT_MBYTE
  25. !     int        l;
  26.   #endif
  27.   
  28. !     res = alloc((unsigned)(vim_strsize(s) + 1));
  29.       if (res != NULL)
  30.       {
  31.       *res = NUL;
  32. !     while (*s != NUL)
  33.       {
  34.   #ifdef FEAT_MBYTE
  35. !         if (has_mbyte && (l = (*mb_ptr2len_check)(s)) > 1)
  36.           {
  37. !         STRNCAT(res, s, l);
  38. !         s += l;
  39.           }
  40.           else
  41.   #endif
  42. !         STRCAT(res, transchar(*s++));
  43.       }
  44.       }
  45.       return res;
  46. --- 327,374 ----
  47.       char_u    *s;
  48.   {
  49.       char_u    *res;
  50. +     char_u    *p;
  51.   #ifdef FEAT_MBYTE
  52. !     int        l, len;
  53.   #endif
  54.   
  55. ! #ifdef FEAT_MBYTE
  56. !     if (has_mbyte)
  57. !     {
  58. !     /* Compute the length of the result, taking into account that
  59. !      * multi-byte characters are copied unchanged. */
  60. !     len = 0;
  61. !     p = s;
  62. !     while (*p != NUL)
  63. !     {
  64. !         if ((l = (*mb_ptr2len_check)(p)) > 1)
  65. !         {
  66. !         len += l;
  67. !         p += l;
  68. !         }
  69. !         else
  70. !         len += byte2cells(*p++);
  71. !     }
  72. !     res = alloc((unsigned)(len + 1));
  73. !     }
  74. !     else
  75. ! #endif
  76. !     res = alloc((unsigned)(vim_strsize(s) + 1));
  77.       if (res != NULL)
  78.       {
  79.       *res = NUL;
  80. !     p = s;
  81. !     while (*p != NUL)
  82.       {
  83.   #ifdef FEAT_MBYTE
  84. !         if (has_mbyte && (l = (*mb_ptr2len_check)(p)) > 1)
  85.           {
  86. !         STRNCAT(res, p, l);
  87. !         p += l;
  88.           }
  89.           else
  90.   #endif
  91. !         STRCAT(res, transchar(*p++));
  92.       }
  93.       }
  94.       return res;
  95. *** ../vim60.18/src/version.c    Mon Oct 22 12:47:09 2001
  96. --- src/version.c    Mon Oct 22 12:46:56 2001
  97. ***************
  98. *** 608,609 ****
  99. --- 608,611 ----
  100.   {   /* Add new patch number below this line */
  101. + /**/
  102. +     19,
  103.   /**/
  104.  
  105. -- 
  106. "Hit any key to continue" is very confusing when you have two keyboards.
  107.  
  108.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  109. (((   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   )))
  110.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  111.