]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.1297 v7.3.1297
authorBram Moolenaar <Bram@vim.org>
Wed, 3 Jul 2013 15:14:00 +0000 (17:14 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 3 Jul 2013 15:14:00 +0000 (17:14 +0200)
Problem:    findfile() directory matching does not work when a star follows
            text. (Markus Braun)
Solution:   Make a wildcard work properly. (Christian Brabandt)

src/misc2.c
src/testdir/test89.in
src/testdir/test89.ok
src/version.c

index 196641fade262118fec82736fecb3e155092fc29..c63344f0da63ee948c50881fac395ac46fab8f98 100644 (file)
@@ -4679,8 +4679,58 @@ vim_findfile_init(path, filename, stopdirs, level, free_visited, find_what,
     }
     STRCPY(ff_expand_buffer, search_ctx->ffsc_start_dir);
     add_pathsep(ff_expand_buffer);
-    STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path);
-    add_pathsep(ff_expand_buffer);
+    {
+       char_u *buf = alloc(STRLEN(ff_expand_buffer)
+                                        + STRLEN(search_ctx->ffsc_fix_path));
+
+       STRCPY(buf, ff_expand_buffer);
+       STRCAT(buf, search_ctx->ffsc_fix_path);
+       if (mch_isdir(buf))
+       {
+           STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path);
+           add_pathsep(ff_expand_buffer);
+       }
+#ifdef FEAT_PATH_EXTRA
+       else
+       {
+           char_u *p =  vim_strrchr(search_ctx->ffsc_fix_path, PATHSEP);
+           char_u *wc_path = NUL;
+           char_u *temp = NUL;
+           int    len = 0;
+
+           if (p != NULL)
+           {
+               len = p - search_ctx->ffsc_fix_path;
+               STRNCAT(ff_expand_buffer, search_ctx->ffsc_fix_path, len);
+               add_pathsep(ff_expand_buffer);
+           }
+           else
+               len = STRLEN(search_ctx->ffsc_fix_path);
+
+           if (search_ctx->ffsc_wc_path != NULL)
+           {
+               wc_path = vim_strsave(search_ctx->ffsc_wc_path);
+               temp = alloc(STRLEN(search_ctx->ffsc_wc_path)
+                                + (STRLEN(search_ctx->ffsc_fix_path) - len));
+           }
+
+           if (temp == NULL || wc_path == NULL)
+           {
+               vim_free(buf);
+               vim_free(temp);
+               vim_free(wc_path);
+               goto error_return;
+           }
+
+           STRCPY(temp, search_ctx->ffsc_fix_path + len);
+           STRCAT(temp, search_ctx->ffsc_wc_path);
+           vim_free(search_ctx->ffsc_wc_path);
+           vim_free(wc_path);
+           search_ctx->ffsc_wc_path = temp;
+       }
+#endif
+       vim_free(buf);
+    }
 
     sptr = ff_create_stack_element(ff_expand_buffer,
 #ifdef FEAT_PATH_EXTRA
index 8e53c917650bcd1dee38df324e2b87e7ed33004b..fc3a9a29b50ec1c7d6a2a00d4547af24abd1a23b 100644 (file)
@@ -1,6 +1,7 @@
-Some tests for setting 'number' and 'relativenumber'
-This is not all that useful now that the options are no longer reset when
-setting the other.
+- Some tests for setting 'number' and 'relativenumber'
+  This is not all that useful now that the options are no longer reset when
+  setting the other.
+- Some tests for findfile() function
 
 STARTTEST
 :so small.vim
@@ -49,6 +50,17 @@ STARTTEST
 :$put g
 :$put h
 :"
+:let cwd=getcwd()
+:cd ../..
+:$put =''
+:$put ='Testing findfile'
+:$put =''
+:$put =findfile('test19.in','src/test*')
+:exe "cd" cwd
+:cd ..
+:$put =findfile('test19.in','test*')
+:$put =findfile('test19.in','testdir')
+:exe "cd" cwd
 :/^results/,$w! test.out
 :q!
 ENDTEST
index 17bb5d764a549b71853f406658a1e3a03533cfb9..90034758d915853fe064f542b0ef10b3db728992 100644 (file)
@@ -20,3 +20,9 @@ results:
   number
 
   relativenumber
+
+Testing findfile
+
+src/testdir/test19.in
+testdir/test19.in
+testdir/test19.in
index e06aa6a62376f73ed5940e12c7195e9d1f5d7169..ea51c18479a710dfb439fad59c40c99fd442d69f 100644 (file)
@@ -728,6 +728,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1297,
 /**/
     1296,
 /**/