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 / 7.3 / 7.3.397 < prev    next >
Encoding:
Internet Message Format  |  2012-11-20  |  6.0 KB

  1. To: vim_dev@googlegroups.com
  2. Subject: Patch 7.3.397
  3. Fcc: outbox
  4. From: Bram Moolenaar <Bram@moolenaar.net>
  5. Mime-Version: 1.0
  6. Content-Type: text/plain; charset=UTF-8
  7. Content-Transfer-Encoding: 8bit
  8. ------------
  9.  
  10. Patch 7.3.397
  11. Problem:    ":helpgrep" does not work properly when 'encoding' is not utf-8 or
  12.         latin1.
  13. Solution:   Convert non-ascii lines to 'encoding'. (Yasuhiro Matsumoto)
  14. Files:        src/quickfix.c, src/spell.c, src/misc2.c, src/proto/misc2.pro
  15.  
  16.  
  17. *** ../vim-7.3.396/src/quickfix.c    2011-12-30 15:01:55.000000000 +0100
  18. --- src/quickfix.c    2012-01-10 16:18:51.000000000 +0100
  19. ***************
  20. *** 3914,3919 ****
  21. --- 3914,3929 ----
  22.       regmatch.rm_ic = FALSE;
  23.       if (regmatch.regprog != NULL)
  24.       {
  25. + #ifdef FEAT_MBYTE
  26. +     vimconv_T vc;
  27. +     /* Help files are in utf-8 or latin1, convert lines when 'encoding'
  28. +      * differs. */
  29. +     vc.vc_type = CONV_NONE;
  30. +     if (!enc_utf8)
  31. +         convert_setup(&vc, (char_u *)"utf-8", p_enc);
  32. + #endif
  33.       /* create a new quickfix list */
  34.       qf_new_list(qi, *eap->cmdlinep);
  35.   
  36. ***************
  37. *** 3948,3968 ****
  38.               lnum = 1;
  39.               while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
  40.               {
  41. !                 if (vim_regexec(®match, IObuff, (colnr_T)0))
  42.                   {
  43. !                 int    l = (int)STRLEN(IObuff);
  44.   
  45.                   /* remove trailing CR, LF, spaces, etc. */
  46. !                 while (l > 0 && IObuff[l - 1] <= ' ')
  47. !                      IObuff[--l] = NUL;
  48.   
  49.                   if (qf_add_entry(qi, &prevp,
  50.                           NULL,    /* dir */
  51.                           fnames[fi],
  52.                           0,
  53. !                         IObuff,
  54.                           lnum,
  55. !                         (int)(regmatch.startp[0] - IObuff)
  56.                                   + 1, /* col */
  57.                           FALSE,    /* vis_col */
  58.                           NULL,    /* search pattern */
  59. --- 3958,3990 ----
  60.               lnum = 1;
  61.               while (!vim_fgets(IObuff, IOSIZE, fd) && !got_int)
  62.               {
  63. !                 char_u    *line = IObuff;
  64. ! #ifdef FEAT_MBYTE
  65. !                 /* Convert a line if 'encoding' is not utf-8 and
  66. !                  * the line contains a non-ASCII character. */
  67. !                 if (vc.vc_type != CONV_NONE
  68. !                            && has_non_ascii(IObuff)) {
  69. !                 line = string_convert(&vc, IObuff, NULL);
  70. !                 if (line == NULL)
  71. !                     line = IObuff;
  72. !                 }
  73. ! #endif
  74. !                 if (vim_regexec(®match, line, (colnr_T)0))
  75.                   {
  76. !                 int    l = (int)STRLEN(line);
  77.   
  78.                   /* remove trailing CR, LF, spaces, etc. */
  79. !                 while (l > 0 && line[l - 1] <= ' ')
  80. !                      line[--l] = NUL;
  81.   
  82.                   if (qf_add_entry(qi, &prevp,
  83.                           NULL,    /* dir */
  84.                           fnames[fi],
  85.                           0,
  86. !                         line,
  87.                           lnum,
  88. !                         (int)(regmatch.startp[0] - line)
  89.                                   + 1, /* col */
  90.                           FALSE,    /* vis_col */
  91.                           NULL,    /* search pattern */
  92. ***************
  93. *** 3972,3980 ****
  94. --- 3994,4010 ----
  95.                           ) == FAIL)
  96.                   {
  97.                       got_int = TRUE;
  98. + #ifdef FEAT_MBYTE
  99. +                     if (line != IObuff)
  100. +                     vim_free(line);
  101. + #endif
  102.                       break;
  103.                   }
  104.                   }
  105. + #ifdef FEAT_MBYTE
  106. +                 if (line != IObuff)
  107. +                 vim_free(line);
  108. + #endif
  109.                   ++lnum;
  110.                   line_breakcheck();
  111.               }
  112. ***************
  113. *** 3984,3990 ****
  114. --- 4014,4025 ----
  115.           FreeWild(fcount, fnames);
  116.           }
  117.       }
  118.       vim_free(regmatch.regprog);
  119. + #ifdef FEAT_MBYTE
  120. +     if (vc.vc_type != CONV_NONE)
  121. +         convert_setup(&vc, NULL, NULL);
  122. + #endif
  123.   
  124.       qi->qf_lists[qi->qf_curlist].qf_nonevalid = FALSE;
  125.       qi->qf_lists[qi->qf_curlist].qf_ptr =
  126. *** ../vim-7.3.396/src/spell.c    2011-09-02 14:18:14.000000000 +0200
  127. --- src/spell.c    2012-01-10 16:19:33.000000000 +0100
  128. ***************
  129. *** 5020,5026 ****
  130.   static int str_equal __ARGS((char_u *s1, char_u    *s2));
  131.   static void add_fromto __ARGS((spellinfo_T *spin, garray_T *gap, char_u    *from, char_u *to));
  132.   static int sal_to_bool __ARGS((char_u *s));
  133. - static int has_non_ascii __ARGS((char_u *s));
  134.   static void spell_free_aff __ARGS((afffile_T *aff));
  135.   static int spell_read_dic __ARGS((spellinfo_T *spin, char_u *fname, afffile_T *affile));
  136.   static int get_affix_flags __ARGS((afffile_T *affile, char_u *afflist));
  137. --- 5020,5025 ----
  138. ***************
  139. *** 6485,6507 ****
  140.   }
  141.   
  142.   /*
  143. -  * Return TRUE if string "s" contains a non-ASCII character (128 or higher).
  144. -  * When "s" is NULL FALSE is returned.
  145. -  */
  146. -     static int
  147. - has_non_ascii(s)
  148. -     char_u    *s;
  149. - {
  150. -     char_u    *p;
  151. -     if (s != NULL)
  152. -     for (p = s; *p != NUL; ++p)
  153. -         if (*p >= 128)
  154. -         return TRUE;
  155. -     return FALSE;
  156. - }
  157. - /*
  158.    * Free the structure filled by spell_read_aff().
  159.    */
  160.       static void
  161. --- 6484,6489 ----
  162. *** ../vim-7.3.396/src/misc2.c    2011-12-08 17:49:31.000000000 +0100
  163. --- src/misc2.c    2012-01-10 16:25:53.000000000 +0100
  164. ***************
  165. *** 6541,6543 ****
  166. --- 6541,6563 ----
  167.   #endif
  168.   
  169.   #endif
  170. + #if (defined(FEAT_MBYTE) && defined(FEAT_QUICKFIX)) \
  171. +     || defined(FEAT_SPELL) || defined(PROTO)
  172. + /*
  173. +  * Return TRUE if string "s" contains a non-ASCII character (128 or higher).
  174. +  * When "s" is NULL FALSE is returned.
  175. +  */
  176. +     int
  177. + has_non_ascii(s)
  178. +     char_u    *s;
  179. + {
  180. +     char_u    *p;
  181. +     if (s != NULL)
  182. +     for (p = s; *p != NUL; ++p)
  183. +         if (*p >= 128)
  184. +         return TRUE;
  185. +     return FALSE;
  186. + }
  187. + #endif
  188. *** ../vim-7.3.396/src/proto/misc2.pro    2011-07-07 16:20:45.000000000 +0200
  189. --- src/proto/misc2.pro    2012-01-10 16:20:03.000000000 +0100
  190. ***************
  191. *** 116,119 ****
  192. --- 116,120 ----
  193.   char_u *read_string __ARGS((FILE *fd, int cnt));
  194.   int put_bytes __ARGS((FILE *fd, long_u nr, int len));
  195.   void put_time __ARGS((FILE *fd, time_t the_time));
  196. + int has_non_ascii __ARGS((char_u *s));
  197.   /* vim: set ft=c : */
  198. *** ../vim-7.3.396/src/version.c    2012-01-10 13:46:18.000000000 +0100
  199. --- src/version.c    2012-01-10 16:26:32.000000000 +0100
  200. ***************
  201. *** 716,717 ****
  202. --- 716,719 ----
  203.   {   /* Add new patch number below this line */
  204. + /**/
  205. +     397,
  206.   /**/
  207.  
  208. -- 
  209. Biting someone with your natural teeth is "simple assault," while biting
  210. someone with your false teeth is "aggravated assault."
  211.         [real standing law in Louisana, United States of America]
  212.  
  213.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  214. ///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
  215. \\\  an exciting new programming language -- http://www.Zimbu.org        ///
  216.  \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///
  217.