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.1.072 < prev    next >
Encoding:
Internet Message Format  |  2002-05-15  |  5.4 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.1.072
  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.1.072
  11. Problem:    When a file name in a tags file starts with http:// or something
  12.         else for which there is a BufReadCmd autocommand, the file isn't
  13.         opened anyway.
  14. Solution:   Check if there is a matching BufReadCmd autocommand and try to
  15.         open the file.
  16. Files:        src/fileio.c, src/proto/fileio.pro, src/tag.c
  17.  
  18.  
  19. *** ../vim61.071/src/fileio.c    Thu May 16 21:32:05 2002
  20. --- src/fileio.c    Thu May 16 21:59:24 2002
  21. ***************
  22. *** 5767,5772 ****
  23. --- 5767,5794 ----
  24.   static EVENT_T    last_event;
  25.   static int    last_group;
  26.   
  27. + #ifdef BACKSLASH_IN_FILENAME
  28. + static void forward_slash __ARGS((char_u *));
  29. + /*
  30. +  * Convert all backslashes in fname to forward slashes in-place.
  31. +  */
  32. +     static void
  33. + forward_slash(fname)
  34. +     char_u    *fname;
  35. + {
  36. +     for (p = fname; *p != NUL; ++p)
  37. + # ifdef  FEAT_MBYTE
  38. +     /* The Big5 encoding can have '\' in the trail byte. */
  39. +     if (enc_dbcs != 0 && (*mb_ptr2len_check)(p) > 1)
  40. +         ++p;
  41. +     else
  42. + # endif
  43. +     if (*p == '\\')
  44. +         *p = '/';
  45. + }
  46. + #endif
  47.   /*
  48.    * Show the autocommands for one AutoPat.
  49.    */
  50. ***************
  51. *** 6900,6930 ****
  52.       /*
  53.        * Replace all backslashes with forward slashes.  This makes the
  54.        * autocommand patterns portable between Unix and MS-DOS.
  55. -      * Watch out for the Big5 encoding, it has '\' in the trail byte.
  56.        */
  57. !     {
  58. !     char_u        *p;
  59. !     if (sfname != NULL)
  60. !     {
  61. !         for (p = sfname; *p; ++p)
  62. ! # ifdef  FEAT_MBYTE
  63. !         if (enc_dbcs != 0 && (*mb_ptr2len_check)(p) > 1)
  64. !             ++p;
  65. !         else
  66. ! # endif
  67. !         if (*p == '\\')
  68. !             *p = '/';
  69. !     }
  70. !     for (p = fname; *p; ++p)
  71. ! # ifdef  FEAT_MBYTE
  72. !         if (enc_dbcs != 0 && (*mb_ptr2len_check)(p) > 1)
  73. !         ++p;
  74. !         else
  75. ! # endif
  76. !         if (*p == '\\')
  77. !         *p = '/';
  78. !     }
  79.   #endif
  80.   
  81.   #ifdef VMS
  82. --- 6922,6931 ----
  83.       /*
  84.        * Replace all backslashes with forward slashes.  This makes the
  85.        * autocommand patterns portable between Unix and MS-DOS.
  86.        */
  87. !     if (sfname != NULL)
  88. !     forward_slash(sfname);
  89. !     forward_slash(fname);
  90.   #endif
  91.   
  92.   #ifdef VMS
  93. ***************
  94. *** 7179,7184 ****
  95. --- 7180,7230 ----
  96.       acp->nextcmd = NULL;
  97.       else
  98.       acp->nextcmd = ac->next;
  99. +     return retval;
  100. + }
  101. + /*
  102. +  * Return TRUE if there is a matching autocommand for "fname".
  103. +  */
  104. +     int
  105. + has_autocmd(event, sfname)
  106. +     EVENT_T    event;
  107. +     char_u    *sfname;
  108. + {
  109. +     AutoPat    *ap;
  110. +     char_u    *fname;
  111. +     char_u    *tail = gettail(sfname);
  112. +     int        retval = FALSE;
  113. +     fname = FullName_save(sfname, FALSE);
  114. +     if (fname == NULL)
  115. +     return FALSE;
  116. + #ifdef BACKSLASH_IN_FILENAME
  117. +     /*
  118. +      * Replace all backslashes with forward slashes.  This makes the
  119. +      * autocommand patterns portable between Unix and MS-DOS.
  120. +      */
  121. +     sfname = vim_strsave(sfname);
  122. +     if (sfname != NULL)
  123. +     forward_slash(sfname);
  124. +     forward_slash(fname);
  125. + #endif
  126. +     for (ap = first_autopat[(int)event]; ap != NULL; ap = ap->next)
  127. +     if (ap->pat != NULL && ap->cmds != NULL
  128. +         && match_file_pat(ap->reg_pat, fname, sfname, tail,
  129. +                                   ap->allow_dirs))
  130. +     {
  131. +         retval = TRUE;
  132. +         break;
  133. +     }
  134. +     vim_free(fname);
  135. + #ifdef BACKSLASH_IN_FILENAME
  136. +     vim_free(sfname);
  137. + #endif
  138.       return retval;
  139.   }
  140.   
  141. *** ../vim61.071/src/proto/fileio.pro    Fri Mar 22 21:41:09 2002
  142. --- src/proto/fileio.pro    Mon May  6 19:55:39 2002
  143. ***************
  144. *** 25,30 ****
  145. --- 25,31 ----
  146.   void aucmd_restbuf __ARGS((aco_save_T *aco));
  147.   int apply_autocmds __ARGS((EVENT_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf));
  148.   int has_cursorhold __ARGS((void));
  149. + int has_autocmd __ARGS((EVENT_T event, char_u *sfname));
  150.   char_u *get_augroup_name __ARGS((expand_T *xp, int idx));
  151.   char_u *set_context_in_autocmd __ARGS((expand_T *xp, char_u *arg, int doautocmd));
  152.   char_u *get_event_name __ARGS((expand_T *xp, int idx));
  153. *** ../vim61.071/src/tag.c    Mon Apr  8 22:11:31 2002
  154. --- src/tag.c    Mon May  6 19:57:34 2002
  155. ***************
  156. *** 2430,2438 ****
  157.       tofree_fname = fname;    /* free() it later */
  158.   
  159.       /*
  160. !      * check if file for tag exists before abandoning current file
  161.        */
  162. !     if (mch_getperm(fname) < 0)
  163.       {
  164.       retval = NOTAGFILE;
  165.       vim_free(nofile_fname);
  166. --- 2430,2444 ----
  167.       tofree_fname = fname;    /* free() it later */
  168.   
  169.       /*
  170. !      * Check if the file with the tag exists before abandoning the current
  171. !      * file.  Also accept a file name for which there is a matching BufReadCmd
  172. !      * autocommand event (e.g., http://sys/file).
  173.        */
  174. !     if (mch_getperm(fname) < 0
  175. ! #ifdef FEAT_AUTOCMD
  176. !         && !has_autocmd(EVENT_BUFREADCMD, fname)
  177. ! #endif
  178. !        )
  179.       {
  180.       retval = NOTAGFILE;
  181.       vim_free(nofile_fname);
  182. *** ../vim61.071/src/version.c    Thu May 16 21:50:46 2002
  183. --- src/version.c    Thu May 16 21:54:47 2002
  184. ***************
  185. *** 608,609 ****
  186. --- 608,611 ----
  187.   {   /* Add new patch number below this line */
  188. + /**/
  189. +     72,
  190.   /**/
  191.  
  192. -- 
  193. How To Keep A Healthy Level Of Insanity:
  194. 4. Put your garbage can on your desk and label it "in".
  195.  
  196.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  197. ///   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   \\\
  198. \\\           Project leader for A-A-P -- http://www.a-a-p.org           ///
  199.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  200.