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.134 < prev    next >
Encoding:
Internet Message Format  |  2002-01-14  |  7.8 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.0.134
  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.134
  11. Problem:    When completing ":set tags=" a path with an embedded space causes
  12.         the completion to stop. (Sektor van Skijlen)
  13. Solution:   Escape spaces with backslashes, like for ":set path=".  Also take
  14.         backslashes into account when searching for the start of the path
  15.         to complete (e.g., for 'backupdir' and 'cscopeprg').
  16. Files:        src/ex_docmd.c, src/ex_getln.c, src/option.c, src/structs.h
  17.  
  18.  
  19. *** ../vim60.133/src/ex_docmd.c    Mon Dec 31 17:47:49 2001
  20. --- src/ex_docmd.c    Wed Jan  2 13:08:49 2002
  21. ***************
  22. *** 2153,2159 ****
  23.   
  24.       xp->xp_pattern = buff;
  25.       xp->xp_context = EXPAND_COMMANDS;    /* Default until we get past command */
  26. !     xp->xp_set_path = FALSE;
  27.   
  28.   /*
  29.    * 2. skip comment lines and leading space, colons or bars
  30. --- 2153,2159 ----
  31.   
  32.       xp->xp_pattern = buff;
  33.       xp->xp_context = EXPAND_COMMANDS;    /* Default until we get past command */
  34. !     xp->xp_backslash = XP_BS_NONE;
  35.   
  36.   /*
  37.    * 2. skip comment lines and leading space, colons or bars
  38. *** ../vim60.133/src/ex_getln.c    Wed Oct 31 20:51:33 2001
  39. --- src/ex_getln.c    Wed Jan  2 13:22:16 2002
  40. ***************
  41. *** 2605,2611 ****
  42.           for (i = 0; i < numfiles; ++i)
  43.           {
  44.           /* for ":set path=" we need to escape spaces twice */
  45. !         if (xp->xp_set_path)
  46.           {
  47.               p = vim_strsave_escaped(files[i], (char_u *)" ");
  48.               if (p != NULL)
  49. --- 2605,2611 ----
  50.           for (i = 0; i < numfiles; ++i)
  51.           {
  52.           /* for ":set path=" we need to escape spaces twice */
  53. !         if (xp->xp_backslash == XP_BS_THREE)
  54.           {
  55.               p = vim_strsave_escaped(files[i], (char_u *)" ");
  56.               if (p != NULL)
  57. ***************
  58. *** 2643,2649 ****
  59.               }
  60.           }
  61.           }
  62. !         xp->xp_set_path = FALSE;
  63.       }
  64.       else if (xp->xp_context == EXPAND_TAGS)
  65.       {
  66. --- 2643,2649 ----
  67.               }
  68.           }
  69.           }
  70. !         xp->xp_backslash = XP_BS_NONE;
  71.       }
  72.       else if (xp->xp_context == EXPAND_TAGS)
  73.       {
  74. ***************
  75. *** 3103,3138 ****
  76.       if (options & WILD_SILENT)
  77.       flags |= EW_SILENT;
  78.   
  79. !     if (xp->xp_context == EXPAND_FILES)
  80.       {
  81.       /*
  82. !      * Expand file names.
  83. !      */
  84. !     return expand_wildcards(1, &pat, num_file, file, flags|EW_FILE);
  85. !     }
  86. !     else if (xp->xp_context == EXPAND_DIRECTORIES)
  87. !     {
  88. !     /*
  89. !      * Expand directory names.
  90.        */
  91.       int    free_pat = FALSE;
  92.       int    i;
  93.   
  94. !     /* for ":set path=" we need to remove backslashes for escaped space */
  95. !     if (xp->xp_set_path)
  96.       {
  97.           free_pat = TRUE;
  98.           pat = vim_strsave(pat);
  99.           for (i = 0; pat[i]; ++i)
  100. !         if (pat[i] == '\\'
  101. !             && pat[i + 1] == '\\'
  102. !             && pat[i + 2] == '\\'
  103. !             && pat[i + 3] == ' ')
  104. !             STRCPY(pat + i, pat + i + 3);
  105.       }
  106.   
  107. !     ret = expand_wildcards(1, &pat, num_file, file,
  108. !                          (flags | EW_DIR) & ~EW_FILE);
  109.       if (free_pat)
  110.           vim_free(pat);
  111.       return ret;
  112. --- 3103,3141 ----
  113.       if (options & WILD_SILENT)
  114.       flags |= EW_SILENT;
  115.   
  116. !     if (xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_DIRECTORIES)
  117.       {
  118.       /*
  119. !      * Expand file or directory names.
  120.        */
  121.       int    free_pat = FALSE;
  122.       int    i;
  123.   
  124. !     /* for ":set path=" and ":set tags=" halve backslashes for escaped
  125. !      * space */
  126. !     if (xp->xp_backslash != XP_BS_NONE)
  127.       {
  128.           free_pat = TRUE;
  129.           pat = vim_strsave(pat);
  130.           for (i = 0; pat[i]; ++i)
  131. !         if (pat[i] == '\\')
  132. !         {
  133. !             if (xp->xp_backslash == XP_BS_THREE
  134. !                 && pat[i + 1] == '\\'
  135. !                 && pat[i + 2] == '\\'
  136. !                 && pat[i + 3] == ' ')
  137. !             STRCPY(pat + i, pat + i + 3);
  138. !             if (xp->xp_backslash == XP_BS_ONE
  139. !                 && pat[i + 1] == ' ')
  140. !             STRCPY(pat + i, pat + i + 1);
  141. !         }
  142.       }
  143.   
  144. !     if (xp->xp_context == EXPAND_FILES)
  145. !         flags |= EW_FILE;
  146. !     else
  147. !         flags = (flags | EW_DIR) & ~EW_FILE;
  148. !     ret = expand_wildcards(1, &pat, num_file, file, flags);
  149.       if (free_pat)
  150.           vim_free(pat);
  151.       return ret;
  152. *** ../vim60.133/src/option.c    Tue Jan 15 14:28:35 2002
  153. --- src/option.c    Tue Jan 15 14:24:07 2002
  154. ***************
  155. *** 7603,7609 ****
  156.       int        opt_idx = 0;    /* init for GCC */
  157.       char_u    *p;
  158.       char_u    *s;
  159. -     char_u    *after_blank = NULL;
  160.       int        is_term_option = FALSE;
  161.       int        key;
  162.   
  163. --- 7603,7608 ----
  164. ***************
  165. *** 7636,7646 ****
  166.           ++p;
  167.           break;
  168.       }
  169. -     /* remember possible start of file name to expand */
  170. -     if (after_blank == NULL
  171. -         && ((*p == ' ' && (p - s) < 2)
  172. -             || (*p == ',' && p == s)))
  173. -         after_blank = p + 1;
  174.       --p;
  175.       }
  176.       if (STRNCMP(p, "no", 2) == 0)
  177. --- 7635,7640 ----
  178. ***************
  179. *** 7733,7742 ****
  180.       xp->xp_context = EXPAND_NOTHING;
  181.       if (is_term_option || (flags & P_NUM))
  182.       return;
  183. !     if (after_blank != NULL)
  184. !     xp->xp_pattern = after_blank;
  185. !     else
  186. !     xp->xp_pattern = p + 1;
  187.       if (flags & P_EXPAND)
  188.       {
  189.       p = options[opt_idx].var;
  190. --- 7727,7735 ----
  191.       xp->xp_context = EXPAND_NOTHING;
  192.       if (is_term_option || (flags & P_NUM))
  193.       return;
  194. !     xp->xp_pattern = p + 1;
  195.       if (flags & P_EXPAND)
  196.       {
  197.       p = options[opt_idx].var;
  198. ***************
  199. *** 7758,7768 ****
  200.               || p == (char_u *)&p_cdpath
  201.   #endif
  202.              )
  203. !         xp->xp_set_path = TRUE;
  204.       }
  205.       else
  206.           xp->xp_context = EXPAND_FILES;
  207.       }
  208.       return;
  209.   }
  210.   
  211. --- 7751,7790 ----
  212.               || p == (char_u *)&p_cdpath
  213.   #endif
  214.              )
  215. !         xp->xp_backslash = XP_BS_THREE;
  216. !         else
  217. !         xp->xp_backslash = XP_BS_ONE;
  218.       }
  219.       else
  220. +     {
  221.           xp->xp_context = EXPAND_FILES;
  222. +         /* for 'tags' need three backslashes for a space */
  223. +         if (p == (char_u *)&p_tags)
  224. +         xp->xp_backslash = XP_BS_THREE;
  225. +         else
  226. +         xp->xp_backslash = XP_BS_ONE;
  227. +     }
  228. +     }
  229. +     /* For an option that is a list of file names, find the start of the
  230. +      * last file name. */
  231. +     for (p = arg + STRLEN(arg) - 1; p > xp->xp_pattern; --p)
  232. +     {
  233. +     /* count number of backslashes before ' ' or ',' */
  234. +     if (*p == ' ' || *p == ',')
  235. +     {
  236. +         s = p;
  237. +         while (s > xp->xp_pattern && *(s - 1) == '\\')
  238. +         --s;
  239. +         if ((*p == ' ' && (xp->xp_backslash == XP_BS_THREE && (p - s) < 3))
  240. +             || (*p == ',' && (flags & P_COMMA) && ((p - s) & 1) == 0))
  241. +         {
  242. +         xp->xp_pattern = p + 1;
  243. +         break;
  244. +         }
  245. +     }
  246.       }
  247.       return;
  248.   }
  249.   
  250. *** ../vim60.133/src/structs.h    Fri Nov  2 16:29:44 2001
  251. --- src/structs.h    Wed Jan  2 13:16:36 2002
  252. ***************
  253. *** 364,371 ****
  254.   {
  255.       int        xp_context;        /* type of expansion */
  256.       char_u    *xp_pattern;        /* start of item to expand */
  257. !     int        xp_set_path;        /* ":set path=/dir/<Tab>" */
  258.   } expand_T;
  259.   
  260.   /*
  261.    * Command modifiers ":vertical", ":browse", ":confirm" and ":hide" set a flag.
  262. --- 364,376 ----
  263.   {
  264.       int        xp_context;        /* type of expansion */
  265.       char_u    *xp_pattern;        /* start of item to expand */
  266. !     int        xp_backslash;        /* one of the XP_BS_ values */
  267.   } expand_T;
  268. + /* values for xp_backslash */
  269. + #define XP_BS_NONE    0    /* nothing special for backslashes */
  270. + #define XP_BS_ONE    1    /* uses one backslash before a space */
  271. + #define XP_BS_THREE    2    /* uses three backslashes before a space */
  272.   
  273.   /*
  274.    * Command modifiers ":vertical", ":browse", ":confirm" and ":hide" set a flag.
  275. *** ../vim60.133/src/version.c    Tue Jan 15 14:28:35 2002
  276. --- src/version.c    Tue Jan 15 14:30:42 2002
  277. ***************
  278. *** 608,609 ****
  279. --- 608,611 ----
  280.   {   /* Add new patch number below this line */
  281. + /**/
  282. +     134,
  283.   /**/
  284.  
  285. -- 
  286. Every engineer dreams about saving the universe and having sex with aliens.
  287. This is much more glamorous than the real life of an engineer, which consists
  288. of hiding from the universe and having sex without the participation of other
  289. life forms.
  290.                 (Scott Adams - The Dilbert principle)
  291.  
  292.  ///  Bram Moolenaar -- Bram@moolenaar.net -- http://www.moolenaar.net  \\\
  293. (((   Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim   )))
  294.  \\\  Help me helping AIDS orphans in Uganda - http://iccf-holland.org  ///
  295.