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.2.063 < prev    next >
Encoding:
Internet Message Format  |  2003-08-09  |  21.2 KB

  1. To: vim-dev@vim.org
  2. Subject: Patch 6.2.063
  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.2.063
  11. Problem:    When using custom completion end up with no matches.
  12. Solution:   Make cmd_numfiles and cmd_files local to completion to avoid that
  13.         they are overwritten when ExpandOne() is called recursively by
  14.         f_glob().
  15. Files:        src/eval.c, src/ex_docmd.c, src/ex_getln.c, src/proto/ex_getln.pro,
  16.         src/misc1.c, src/structs.h, src/tag.c
  17.  
  18.  
  19. *** ../vim-6.2.062/src/eval.c    Sun Jul 27 15:01:56 2003
  20. --- src/eval.c    Thu Jul 31 19:47:34 2003
  21. ***************
  22. *** 3933,3941 ****
  23.        * for 'suffixes' and 'wildignore' */
  24.       if (argvars[1].var_type != VAR_UNKNOWN && get_var_number(&argvars[1]))
  25.           flags |= WILD_KEEP_ALL;
  26.       xpc.xp_context = EXPAND_FILES;
  27. -     xpc.xp_backslash = XP_BS_NONE;
  28.       retvar->var_val.var_string = ExpandOne(&xpc, s, NULL, flags, WILD_ALL);
  29.       }
  30.   }
  31.   
  32. --- 3935,3944 ----
  33.        * for 'suffixes' and 'wildignore' */
  34.       if (argvars[1].var_type != VAR_UNKNOWN && get_var_number(&argvars[1]))
  35.           flags |= WILD_KEEP_ALL;
  36. +     ExpandInit(&xpc);
  37.       xpc.xp_context = EXPAND_FILES;
  38.       retvar->var_val.var_string = ExpandOne(&xpc, s, NULL, flags, WILD_ALL);
  39. +     ExpandCleanup(&xpc);
  40.       }
  41.   }
  42.   
  43. ***************
  44. *** 4543,4553 ****
  45.   {
  46.       expand_T    xpc;
  47.   
  48.       xpc.xp_context = EXPAND_FILES;
  49. -     xpc.xp_backslash = XP_BS_NONE;
  50.       retvar->var_type = VAR_STRING;
  51.       retvar->var_val.var_string = ExpandOne(&xpc, get_var_string(&argvars[0]),
  52.                        NULL, WILD_USE_NL|WILD_SILENT, WILD_ALL);
  53.   }
  54.   
  55.   /*
  56. --- 4546,4557 ----
  57.   {
  58.       expand_T    xpc;
  59.   
  60. +     ExpandInit(&xpc);
  61.       xpc.xp_context = EXPAND_FILES;
  62.       retvar->var_type = VAR_STRING;
  63.       retvar->var_val.var_string = ExpandOne(&xpc, get_var_string(&argvars[0]),
  64.                        NULL, WILD_USE_NL|WILD_SILENT, WILD_ALL);
  65. +     ExpandCleanup(&xpc);
  66.   }
  67.   
  68.   /*
  69. *** ../vim-6.2.062/src/ex_docmd.c    Sun Jul 27 14:35:27 2003
  70. --- src/ex_docmd.c    Sat Jul 26 18:36:31 2003
  71. ***************
  72. *** 3694,3704 ****
  73.           {
  74.               expand_T    xpc;
  75.   
  76.               xpc.xp_context = EXPAND_FILES;
  77. !             xpc.xp_backslash = XP_BS_NONE;
  78. !             if ((p = ExpandOne(&xpc, eap->arg, NULL,
  79.                           WILD_LIST_NOTFOUND|WILD_ADD_SLASH,
  80. !                            WILD_EXPAND_FREE)) == NULL)
  81.               return FAIL;
  82.           }
  83.           if (p != NULL)
  84. --- 3694,3706 ----
  85.           {
  86.               expand_T    xpc;
  87.   
  88. +             ExpandInit(&xpc);
  89.               xpc.xp_context = EXPAND_FILES;
  90. !             p = ExpandOne(&xpc, eap->arg, NULL,
  91.                           WILD_LIST_NOTFOUND|WILD_ADD_SLASH,
  92. !                            WILD_EXPAND_FREE);
  93. !             ExpandCleanup(&xpc);
  94. !             if (p == NULL)
  95.               return FAIL;
  96.           }
  97.           if (p != NULL)
  98. *** ../vim-6.2.062/src/ex_getln.c    Thu May 29 22:45:46 2003
  99. --- src/ex_getln.c    Sat Jul 26 18:57:18 2003
  100. ***************
  101. *** 35,43 ****
  102.   
  103.   static struct cmdline_info ccline;    /* current cmdline_info */
  104.   
  105. - static int    cmd_numfiles = -1;    /* number of files found by
  106. -                             file name completion */
  107. - static char_u    **cmd_files = NULL;    /* list of files */
  108.   static int    cmd_showtail;        /* Only show path tail in lists ? */
  109.   
  110.   
  111. --- 35,40 ----
  112. ***************
  113. *** 207,212 ****
  114. --- 204,211 ----
  115.       ccline.cmdlen = ccline.cmdpos = 0;
  116.       ccline.cmdbuff[0] = NUL;
  117.   
  118. +     ExpandInit(&xpc);
  119.   #ifdef FEAT_RIGHTLEFT
  120.       if (curwin->w_p_rl && *curwin->w_p_rlc == 's'
  121.                         && (firstc == '/' || firstc == '?'))
  122. ***************
  123. *** 339,345 ****
  124.           && c != K_PAGEDOWN && c != K_PAGEUP
  125.           && c != K_KPAGEDOWN && c != K_KPAGEUP
  126.           && c != K_LEFT && c != K_RIGHT
  127. !         && (cmd_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N)))
  128.       {
  129.           vim_free(lookfor);
  130.           lookfor = NULL;
  131. --- 338,344 ----
  132.           && c != K_PAGEDOWN && c != K_PAGEUP
  133.           && c != K_KPAGEDOWN && c != K_KPAGEUP
  134.           && c != K_LEFT && c != K_RIGHT
  135. !         && (xpc.xp_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N)))
  136.       {
  137.           vim_free(lookfor);
  138.           lookfor = NULL;
  139. ***************
  140. *** 349,355 ****
  141.       /*
  142.        * <S-Tab> works like CTRL-P (unless 'wc' is <S-Tab>).
  143.        */
  144. !     if (c != p_wc && c == K_S_TAB && cmd_numfiles != -1)
  145.           c = Ctrl_P;
  146.   
  147.   #ifdef FEAT_WILDMENU
  148. --- 348,354 ----
  149.       /*
  150.        * <S-Tab> works like CTRL-P (unless 'wc' is <S-Tab>).
  151.        */
  152. !     if (c != p_wc && c == K_S_TAB && xpc.xp_numfiles != -1)
  153.           c = Ctrl_P;
  154.   
  155.   #ifdef FEAT_WILDMENU
  156. ***************
  157. *** 371,377 ****
  158.   #endif
  159.   
  160.       /* free expanded names when finished walking through matches */
  161. !     if (cmd_numfiles != -1
  162.           && !(c == p_wc && KeyTyped) && c != p_wcm
  163.           && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A
  164.           && c != Ctrl_L)
  165. --- 370,376 ----
  166.   #endif
  167.   
  168.       /* free expanded names when finished walking through matches */
  169. !     if (xpc.xp_numfiles != -1
  170.           && !(c == p_wc && KeyTyped) && c != p_wcm
  171.           && c != Ctrl_N && c != Ctrl_P && c != Ctrl_A
  172.           && c != Ctrl_L)
  173. ***************
  174. *** 629,638 ****
  175.        */
  176.       if ((c == p_wc && !gotesc && KeyTyped) || c == p_wcm)
  177.       {
  178. !         if (cmd_numfiles > 0)   /* typed p_wc at least twice */
  179.           {
  180.           /* if 'wildmode' contains "list" may still need to list */
  181. !         if (cmd_numfiles > 1
  182.               && !did_wild_list
  183.               && (wim_flags[wim_index] & WIM_LIST))
  184.           {
  185. --- 628,637 ----
  186.        */
  187.       if ((c == p_wc && !gotesc && KeyTyped) || c == p_wcm)
  188.       {
  189. !         if (xpc.xp_numfiles > 0)   /* typed p_wc at least twice */
  190.           {
  191.           /* if 'wildmode' contains "list" may still need to list */
  192. !         if (xpc.xp_numfiles > 1
  193.               && !did_wild_list
  194.               && (wim_flags[wim_index] & WIM_LIST))
  195.           {
  196. ***************
  197. *** 673,679 ****
  198.           /* when more than one match, and 'wildmode' first contains
  199.            * "list", or no change and 'wildmode' contains "longest,list",
  200.            * list all matches */
  201. !         if (res == OK && cmd_numfiles > 1)
  202.           {
  203.               /* a "longest" that didn't do anything is skipped (but not
  204.                * "list:longest") */
  205. --- 672,678 ----
  206.           /* when more than one match, and 'wildmode' first contains
  207.            * "list", or no change and 'wildmode' contains "longest,list",
  208.            * list all matches */
  209. !         if (res == OK && xpc.xp_numfiles > 1)
  210.           {
  211.               /* a "longest" that didn't do anything is skipped (but not
  212.                * "list:longest") */
  213. ***************
  214. *** 713,719 ****
  215.               vim_beep();
  216.           }
  217.   #ifdef FEAT_WILDMENU
  218. !         else if (cmd_numfiles == -1)
  219.               xpc.xp_context = EXPAND_NOTHING;
  220.   #endif
  221.           }
  222. --- 712,718 ----
  223.               vim_beep();
  224.           }
  225.   #ifdef FEAT_WILDMENU
  226. !         else if (xpc.xp_numfiles == -1)
  227.               xpc.xp_context = EXPAND_NOTHING;
  228.   #endif
  229.           }
  230. ***************
  231. *** 1207,1213 ****
  232.   
  233.       case Ctrl_N:        /* next match */
  234.       case Ctrl_P:        /* previous match */
  235. !         if (cmd_numfiles > 0)
  236.           {
  237.               if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT, 0)
  238.                                         == FAIL)
  239. --- 1206,1212 ----
  240.   
  241.       case Ctrl_N:        /* next match */
  242.       case Ctrl_P:        /* previous match */
  243. !         if (xpc.xp_numfiles > 0)
  244.           {
  245.               if (nextwild(&xpc, (c == Ctrl_P) ? WILD_PREV : WILD_NEXT, 0)
  246.                                         == FAIL)
  247. ***************
  248. *** 1529,1534 ****
  249. --- 1528,1535 ----
  250.       cmd_fkmap = 0;
  251.   #endif
  252.   
  253. +     ExpandCleanup(&xpc);
  254.   #ifdef FEAT_SEARCH_EXTRA
  255.       if (did_incsearch)
  256.       {
  257. ***************
  258. *** 2590,2596 ****
  259.       int        difflen;
  260.       int        v;
  261.   
  262. !     if (cmd_numfiles == -1)
  263.       {
  264.       set_expand_context(xp);
  265.       cmd_showtail = !glob_in_path_prefix(xp);
  266. --- 2591,2597 ----
  267.       int        difflen;
  268.       int        v;
  269.   
  270. !     if (xp->xp_numfiles == -1)
  271.       {
  272.       set_expand_context(xp);
  273.       cmd_showtail = !glob_in_path_prefix(xp);
  274. ***************
  275. *** 2678,2686 ****
  276.       if (xp->xp_context == EXPAND_MAPPINGS && p2 == NULL)
  277.       return FAIL;
  278.   
  279. !     if (cmd_numfiles <= 0 && p2 == NULL)
  280.       beep_flush();
  281. !     else if (cmd_numfiles == 1)
  282.       /* free expanded pattern */
  283.       (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE);
  284.   
  285. --- 2679,2687 ----
  286.       if (xp->xp_context == EXPAND_MAPPINGS && p2 == NULL)
  287.       return FAIL;
  288.   
  289. !     if (xp->xp_numfiles <= 0 && p2 == NULL)
  290.       beep_flush();
  291. !     else if (xp->xp_numfiles == 1)
  292.       /* free expanded pattern */
  293.       (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE);
  294.   
  295. ***************
  296. *** 2693,2699 ****
  297.    * Return a pointer to alloced memory containing the new string.
  298.    * Return NULL for failure.
  299.    *
  300. !  * Results are cached in cmd_files and cmd_numfiles.
  301.    *
  302.    * mode = WILD_FREE:        just free previously expanded matches
  303.    * mode = WILD_EXPAND_FREE: normal expansion, do not keep matches
  304. --- 2694,2700 ----
  305.    * Return a pointer to alloced memory containing the new string.
  306.    * Return NULL for failure.
  307.    *
  308. !  * Results are cached in xp->xp_files and xp->xp_numfiles.
  309.    *
  310.    * mode = WILD_FREE:        just free previously expanded matches
  311.    * mode = WILD_EXPAND_FREE: normal expansion, do not keep matches
  312. ***************
  313. *** 2734,2745 ****
  314.        */
  315.       if (mode == WILD_NEXT || mode == WILD_PREV)
  316.       {
  317. !     if (cmd_numfiles > 0)
  318.       {
  319.           if (mode == WILD_PREV)
  320.           {
  321.           if (findex == -1)
  322. !             findex = cmd_numfiles;
  323.           --findex;
  324.           }
  325.           else    /* mode == WILD_NEXT */
  326. --- 2735,2746 ----
  327.        */
  328.       if (mode == WILD_NEXT || mode == WILD_PREV)
  329.       {
  330. !     if (xp->xp_numfiles > 0)
  331.       {
  332.           if (mode == WILD_PREV)
  333.           {
  334.           if (findex == -1)
  335. !             findex = xp->xp_numfiles;
  336.           --findex;
  337.           }
  338.           else    /* mode == WILD_NEXT */
  339. ***************
  340. *** 2752,2762 ****
  341.           if (findex < 0)
  342.           {
  343.           if (orig_save == NULL)
  344. !             findex = cmd_numfiles - 1;
  345.           else
  346.               findex = -1;
  347.           }
  348. !         if (findex >= cmd_numfiles)
  349.           {
  350.           if (orig_save == NULL)
  351.               findex = 0;
  352. --- 2753,2763 ----
  353.           if (findex < 0)
  354.           {
  355.           if (orig_save == NULL)
  356. !             findex = xp->xp_numfiles - 1;
  357.           else
  358.               findex = -1;
  359.           }
  360. !         if (findex >= xp->xp_numfiles)
  361.           {
  362.           if (orig_save == NULL)
  363.               findex = 0;
  364. ***************
  365. *** 2765,2786 ****
  366.           }
  367.   #ifdef FEAT_WILDMENU
  368.           if (p_wmnu)
  369. !         win_redr_status_matches(xp, cmd_numfiles, cmd_files, findex,
  370. !                     cmd_showtail);
  371.   #endif
  372.           if (findex == -1)
  373.           return vim_strsave(orig_save);
  374. !         return vim_strsave(cmd_files[findex]);
  375.       }
  376.       else
  377.           return NULL;
  378.       }
  379.   
  380.   /* free old names */
  381. !     if (cmd_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST)
  382.       {
  383. !     FreeWild(cmd_numfiles, cmd_files);
  384. !     cmd_numfiles = -1;
  385.       vim_free(orig_save);
  386.       orig_save = NULL;
  387.       }
  388. --- 2766,2787 ----
  389.           }
  390.   #ifdef FEAT_WILDMENU
  391.           if (p_wmnu)
  392. !         win_redr_status_matches(xp, xp->xp_numfiles, xp->xp_files,
  393. !                             findex, cmd_showtail);
  394.   #endif
  395.           if (findex == -1)
  396.           return vim_strsave(orig_save);
  397. !         return vim_strsave(xp->xp_files[findex]);
  398.       }
  399.       else
  400.           return NULL;
  401.       }
  402.   
  403.   /* free old names */
  404. !     if (xp->xp_numfiles != -1 && mode != WILD_ALL && mode != WILD_LONGEST)
  405.       {
  406. !     FreeWild(xp->xp_numfiles, xp->xp_files);
  407. !     xp->xp_numfiles = -1;
  408.       vim_free(orig_save);
  409.       orig_save = NULL;
  410.       }
  411. ***************
  412. *** 2789,2795 ****
  413.       if (mode == WILD_FREE)    /* only release file name */
  414.       return NULL;
  415.   
  416. !     if (cmd_numfiles == -1)
  417.       {
  418.       vim_free(orig_save);
  419.       orig_save = orig;
  420. --- 2790,2796 ----
  421.       if (mode == WILD_FREE)    /* only release file name */
  422.       return NULL;
  423.   
  424. !     if (xp->xp_numfiles == -1)
  425.       {
  426.       vim_free(orig_save);
  427.       orig_save = orig;
  428. ***************
  429. *** 2797,2803 ****
  430.       /*
  431.        * Do the expansion.
  432.        */
  433. !     if (ExpandFromContext(xp, str, &cmd_numfiles, &cmd_files,
  434.                                    options) == FAIL)
  435.       {
  436.   #ifdef FNAME_ILLEGAL
  437. --- 2798,2804 ----
  438.       /*
  439.        * Do the expansion.
  440.        */
  441. !     if (ExpandFromContext(xp, str, &xp->xp_numfiles, &xp->xp_files,
  442.                                    options) == FAIL)
  443.       {
  444.   #ifdef FNAME_ILLEGAL
  445. ***************
  446. *** 2809,2815 ****
  447.           EMSG2(_(e_nomatch2), str);
  448.   #endif
  449.       }
  450. !     else if (cmd_numfiles == 0)
  451.       {
  452.           if (!(options & WILD_SILENT))
  453.           EMSG2(_(e_nomatch2), str);
  454. --- 2810,2816 ----
  455.           EMSG2(_(e_nomatch2), str);
  456.   #endif
  457.       }
  458. !     else if (xp->xp_numfiles == 0)
  459.       {
  460.           if (!(options & WILD_SILENT))
  461.           EMSG2(_(e_nomatch2), str);
  462. ***************
  463. *** 2817,2836 ****
  464.       else
  465.       {
  466.           /* Escape the matches for use on the command line. */
  467. !         ExpandEscape(xp, str, cmd_numfiles, cmd_files, options);
  468.   
  469.           /*
  470.            * Check for matching suffixes in file names.
  471.            */
  472.           if (mode != WILD_ALL && mode != WILD_LONGEST)
  473.           {
  474. !         if (cmd_numfiles)
  475. !             non_suf_match = cmd_numfiles;
  476.           else
  477.               non_suf_match = 1;
  478.           if ((xp->xp_context == EXPAND_FILES
  479.                   || xp->xp_context == EXPAND_DIRECTORIES)
  480. !             && cmd_numfiles > 1)
  481.           {
  482.               /*
  483.                * More than one match; check suffix.
  484. --- 2818,2837 ----
  485.       else
  486.       {
  487.           /* Escape the matches for use on the command line. */
  488. !         ExpandEscape(xp, str, xp->xp_numfiles, xp->xp_files, options);
  489.   
  490.           /*
  491.            * Check for matching suffixes in file names.
  492.            */
  493.           if (mode != WILD_ALL && mode != WILD_LONGEST)
  494.           {
  495. !         if (xp->xp_numfiles)
  496. !             non_suf_match = xp->xp_numfiles;
  497.           else
  498.               non_suf_match = 1;
  499.           if ((xp->xp_context == EXPAND_FILES
  500.                   || xp->xp_context == EXPAND_DIRECTORIES)
  501. !             && xp->xp_numfiles > 1)
  502.           {
  503.               /*
  504.                * More than one match; check suffix.
  505. ***************
  506. *** 2839,2845 ****
  507.                */
  508.               non_suf_match = 0;
  509.               for (i = 0; i < 2; ++i)
  510. !             if (match_suffix(cmd_files[i]))
  511.                   ++non_suf_match;
  512.           }
  513.           if (non_suf_match != 1)
  514. --- 2840,2846 ----
  515.                */
  516.               non_suf_match = 0;
  517.               for (i = 0; i < 2; ++i)
  518. !             if (match_suffix(xp->xp_files[i]))
  519.                   ++non_suf_match;
  520.           }
  521.           if (non_suf_match != 1)
  522. ***************
  523. *** 2855,2887 ****
  524.               beep_flush();
  525.           }
  526.           if (!(non_suf_match != 1 && mode == WILD_EXPAND_FREE))
  527. !             ss = vim_strsave(cmd_files[0]);
  528.           }
  529.       }
  530.       }
  531.   
  532.       /* Find longest common part */
  533. !     if (mode == WILD_LONGEST && cmd_numfiles > 0)
  534.       {
  535. !     for (len = 0; cmd_files[0][len]; ++len)
  536.       {
  537. !         for (i = 0; i < cmd_numfiles; ++i)
  538.           {
  539.   #ifdef CASE_INSENSITIVE_FILENAME
  540.           if (xp->xp_context == EXPAND_DIRECTORIES
  541.               || xp->xp_context == EXPAND_FILES
  542.               || xp->xp_context == EXPAND_BUFFERS)
  543.           {
  544. !             if (TOLOWER_LOC(cmd_files[i][len]) !=
  545. !                            TOLOWER_LOC(cmd_files[0][len]))
  546.               break;
  547.           }
  548.           else
  549.   #endif
  550. !              if (cmd_files[i][len] != cmd_files[0][len])
  551.               break;
  552.           }
  553. !         if (i < cmd_numfiles)
  554.           {
  555.           if (!(options & WILD_NO_BEEP))
  556.               vim_beep();
  557. --- 2856,2888 ----
  558.               beep_flush();
  559.           }
  560.           if (!(non_suf_match != 1 && mode == WILD_EXPAND_FREE))
  561. !             ss = vim_strsave(xp->xp_files[0]);
  562.           }
  563.       }
  564.       }
  565.   
  566.       /* Find longest common part */
  567. !     if (mode == WILD_LONGEST && xp->xp_numfiles > 0)
  568.       {
  569. !     for (len = 0; xp->xp_files[0][len]; ++len)
  570.       {
  571. !         for (i = 0; i < xp->xp_numfiles; ++i)
  572.           {
  573.   #ifdef CASE_INSENSITIVE_FILENAME
  574.           if (xp->xp_context == EXPAND_DIRECTORIES
  575.               || xp->xp_context == EXPAND_FILES
  576.               || xp->xp_context == EXPAND_BUFFERS)
  577.           {
  578. !             if (TOLOWER_LOC(xp->xp_files[i][len]) !=
  579. !                         TOLOWER_LOC(xp->xp_files[0][len]))
  580.               break;
  581.           }
  582.           else
  583.   #endif
  584. !              if (xp->xp_files[i][len] != xp->xp_files[0][len])
  585.               break;
  586.           }
  587. !         if (i < xp->xp_numfiles)
  588.           {
  589.           if (!(options & WILD_NO_BEEP))
  590.               vim_beep();
  591. ***************
  592. *** 2891,2930 ****
  593.       ss = alloc((unsigned)len + 1);
  594.       if (ss)
  595.       {
  596. !         STRNCPY(ss, cmd_files[0], len);
  597.           ss[len] = NUL;
  598.       }
  599.       findex = -1;                /* next p_wc gets first one */
  600.       }
  601.   
  602.       /* Concatenate all matching names */
  603. !     if (mode == WILD_ALL && cmd_numfiles > 0)
  604.       {
  605.       len = 0;
  606. !     for (i = 0; i < cmd_numfiles; ++i)
  607. !         len += (long_u)STRLEN(cmd_files[i]) + 1;
  608.       ss = lalloc(len, TRUE);
  609.       if (ss != NULL)
  610.       {
  611.           *ss = NUL;
  612. !         for (i = 0; i < cmd_numfiles; ++i)
  613.           {
  614. !         STRCAT(ss, cmd_files[i]);
  615. !         if (i != cmd_numfiles - 1)
  616.               STRCAT(ss, (options & WILD_USE_NL) ? "\n" : " ");
  617.           }
  618.       }
  619.       }
  620.   
  621.       if (mode == WILD_EXPAND_FREE || mode == WILD_ALL)
  622. !     {
  623. !     FreeWild(cmd_numfiles, cmd_files);
  624. !     cmd_numfiles = -1;
  625. !     }
  626.   
  627.       return ss;
  628.   }
  629.   
  630.       void
  631.   ExpandEscape(xp, str, numfiles, files, options)
  632.       expand_T    *xp;
  633. --- 2892,2954 ----
  634.       ss = alloc((unsigned)len + 1);
  635.       if (ss)
  636.       {
  637. !         STRNCPY(ss, xp->xp_files[0], len);
  638.           ss[len] = NUL;
  639.       }
  640.       findex = -1;                /* next p_wc gets first one */
  641.       }
  642.   
  643.       /* Concatenate all matching names */
  644. !     if (mode == WILD_ALL && xp->xp_numfiles > 0)
  645.       {
  646.       len = 0;
  647. !     for (i = 0; i < xp->xp_numfiles; ++i)
  648. !         len += (long_u)STRLEN(xp->xp_files[i]) + 1;
  649.       ss = lalloc(len, TRUE);
  650.       if (ss != NULL)
  651.       {
  652.           *ss = NUL;
  653. !         for (i = 0; i < xp->xp_numfiles; ++i)
  654.           {
  655. !         STRCAT(ss, xp->xp_files[i]);
  656. !         if (i != xp->xp_numfiles - 1)
  657.               STRCAT(ss, (options & WILD_USE_NL) ? "\n" : " ");
  658.           }
  659.       }
  660.       }
  661.   
  662.       if (mode == WILD_EXPAND_FREE || mode == WILD_ALL)
  663. !     ExpandCleanup(xp);
  664.   
  665.       return ss;
  666.   }
  667.   
  668. + /*
  669. +  * Prepare an expand structure for use.
  670. +  */
  671. +     void
  672. + ExpandInit(xp)
  673. +     expand_T    *xp;
  674. + {
  675. +     xp->xp_backslash = XP_BS_NONE;
  676. +     xp->xp_numfiles = -1;
  677. +     xp->xp_files = NULL;
  678. + }
  679. + /*
  680. +  * Cleanup an expand structure after use.
  681. +  */
  682. +     void
  683. + ExpandCleanup(xp)
  684. +     expand_T    *xp;
  685. + {
  686. +     if (xp->xp_numfiles >= 0)
  687. +     {
  688. +     FreeWild(xp->xp_numfiles, xp->xp_files);
  689. +     xp->xp_numfiles = -1;
  690. +     }
  691. + }
  692.       void
  693.   ExpandEscape(xp, str, numfiles, files, options)
  694.       expand_T    *xp;
  695. ***************
  696. *** 3078,3084 ****
  697.       int        attr;
  698.       int        showtail;
  699.   
  700. !     if (cmd_numfiles == -1)
  701.       {
  702.       set_expand_context(xp);
  703.       i = expand_cmdline(xp, ccline.cmdbuff, ccline.cmdpos,
  704. --- 3102,3108 ----
  705.       int        attr;
  706.       int        showtail;
  707.   
  708. !     if (xp->xp_numfiles == -1)
  709.       {
  710.       set_expand_context(xp);
  711.       i = expand_cmdline(xp, ccline.cmdbuff, ccline.cmdpos,
  712. ***************
  713. *** 3090,3097 ****
  714.       }
  715.       else
  716.       {
  717. !     num_files = cmd_numfiles;
  718. !     files_found = cmd_files;
  719.       showtail = cmd_showtail;
  720.       }
  721.   
  722. --- 3114,3121 ----
  723.       }
  724.       else
  725.       {
  726. !     num_files = xp->xp_numfiles;
  727. !     files_found = xp->xp_files;
  728.       showtail = cmd_showtail;
  729.       }
  730.   
  731. ***************
  732. *** 3215,3221 ****
  733.       cmdline_row = msg_row;    /* will put it back later */
  734.       }
  735.   
  736. !     if (cmd_numfiles == -1)
  737.       FreeWild(num_files, files_found);
  738.   
  739.       return EXPAND_OK;
  740. --- 3239,3245 ----
  741.       cmdline_row = msg_row;    /* will put it back later */
  742.       }
  743.   
  744. !     if (xp->xp_numfiles == -1)
  745.       FreeWild(num_files, files_found);
  746.   
  747.       return EXPAND_OK;
  748. *** ../vim-6.2.062/src/proto/ex_getln.pro    Sun Jun  1 12:26:09 2003
  749. --- src/proto/ex_getln.pro    Sat Jul 26 18:38:51 2003
  750. ***************
  751. *** 14,19 ****
  752. --- 14,21 ----
  753.   void compute_cmdrow __ARGS((void));
  754.   void gotocmdline __ARGS((int clr));
  755.   char_u *ExpandOne __ARGS((expand_T *xp, char_u *str, char_u *orig, int options, int mode));
  756. + void ExpandInit __ARGS((expand_T *xp));
  757. + void ExpandCleanup __ARGS((expand_T *xp));
  758.   void ExpandEscape __ARGS((expand_T *xp, char_u *str, int numfiles, char_u **files, int options));
  759.   void tilde_replace __ARGS((char_u *orig_pat, int num_files, char_u **files));
  760.   char_u *sm_gettail __ARGS((char_u *s));
  761. *** ../vim-6.2.062/src/misc1.c    Thu May 29 20:32:05 2003
  762. --- src/misc1.c    Sat Jul 26 18:37:24 2003
  763. ***************
  764. *** 3212,3221 ****
  765.           {
  766.               expand_T    xpc;
  767.   
  768.               xpc.xp_context = EXPAND_FILES;
  769. -             xpc.xp_backslash = XP_BS_NONE;
  770.               var = ExpandOne(&xpc, dst, NULL,
  771.                   WILD_ADD_SLASH|WILD_SILENT, WILD_EXPAND_FREE);
  772.               mustfree = TRUE;
  773.           }
  774.   
  775. --- 3212,3222 ----
  776.           {
  777.               expand_T    xpc;
  778.   
  779. +             ExpandInit(&xpc);
  780.               xpc.xp_context = EXPAND_FILES;
  781.               var = ExpandOne(&xpc, dst, NULL,
  782.                   WILD_ADD_SLASH|WILD_SILENT, WILD_EXPAND_FREE);
  783. +             ExpandCleanup(&xpc);
  784.               mustfree = TRUE;
  785.           }
  786.   
  787. *** ../vim-6.2.062/src/structs.h    Mon May 26 21:08:40 2003
  788. --- src/structs.h    Sat Jul 26 18:30:51 2003
  789. ***************
  790. *** 376,381 ****
  791. --- 376,384 ----
  792.       char_u    *xp_pattern;        /* start of item to expand */
  793.       char_u    *xp_arg;        /* generic expansion argument */
  794.       int        xp_backslash;        /* one of the XP_BS_ values */
  795. +     int        xp_numfiles;        /* number of files found by
  796. +                             file name completion */
  797. +     char_u    **xp_files;        /* list of files */
  798.   } expand_T;
  799.   
  800.   /* values for xp_backslash */
  801. *** ../vim-6.2.062/src/tag.c    Sun Jun  1 14:41:25 2003
  802. --- src/tag.c    Thu Jul 31 18:27:34 2003
  803. ***************
  804. *** 2811,2820 ****
  805.        */
  806.       if (expand && mch_has_wildcard(fname))
  807.       {
  808.       xpc.xp_context = EXPAND_FILES;
  809. -     xpc.xp_backslash = XP_BS_NONE;
  810.       expanded_fname = ExpandOne(&xpc, (char_u *)fname, NULL,
  811.                   WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE);
  812.       if (expanded_fname != NULL)
  813.           fname = expanded_fname;
  814.       }
  815. --- 2811,2821 ----
  816.        */
  817.       if (expand && mch_has_wildcard(fname))
  818.       {
  819. +     ExpandInit(&xpc);
  820.       xpc.xp_context = EXPAND_FILES;
  821.       expanded_fname = ExpandOne(&xpc, (char_u *)fname, NULL,
  822.                   WILD_LIST_NOTFOUND|WILD_SILENT, WILD_EXPAND_FREE);
  823. +     ExpandCleanup(&xpc);
  824.       if (expanded_fname != NULL)
  825.           fname = expanded_fname;
  826.       }
  827. *** ../vim-6.2.062/src/version.c    Sun Aug 10 14:52:30 2003
  828. --- src/version.c    Sun Aug 10 22:14:52 2003
  829. ***************
  830. *** 632,633 ****
  831. --- 632,635 ----
  832.   {   /* Add new patch number below this line */
  833. + /**/
  834. +     63,
  835.   /**/
  836.  
  837. -- 
  838. From "know your smileys":
  839.  ...---...   SOS
  840.  
  841.  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
  842. ///          Creator of Vim - Vi IMproved -- http://www.Vim.org          \\\
  843. \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
  844.  \\\  Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html  ///
  845.