comparison src/filepath.c @ 29853:31c598083364 v9.0.0265

patch 9.0.0265: no good reason why the "gf" command isn't in the tiny version Commit: https://github.com/vim/vim/commit/f80f40a55ccff0a4331c5fbd1ac446511f622ed0 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Aug 25 16:02:23 2022 +0100 patch 9.0.0265: no good reason why the "gf" command isn't in the tiny version Problem: No good reason why the "gf" command is not in the tiny version. Solution: Graduate the file_in_path feature.
author Bram Moolenaar <Bram@vim.org>
date Thu, 25 Aug 2022 17:15:03 +0200
parents 86c203dbf12b
children 77141226eb2e
comparison
equal deleted inserted replaced
29852:8568b72caa9a 29853:31c598083364
940 findfilendir( 940 findfilendir(
941 typval_T *argvars UNUSED, 941 typval_T *argvars UNUSED,
942 typval_T *rettv, 942 typval_T *rettv,
943 int find_what UNUSED) 943 int find_what UNUSED)
944 { 944 {
945 #ifdef FEAT_SEARCHPATH
946 char_u *fname; 945 char_u *fname;
947 char_u *fresult = NULL; 946 char_u *fresult = NULL;
948 char_u *path = *curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path; 947 char_u *path = *curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path;
949 char_u *p; 948 char_u *p;
950 char_u pathbuf[NUMBUFLEN]; 949 char_u pathbuf[NUMBUFLEN];
951 int count = 1; 950 int count = 1;
952 int first = TRUE; 951 int first = TRUE;
953 int error = FALSE; 952 int error = FALSE;
954 #endif
955 953
956 rettv->vval.v_string = NULL; 954 rettv->vval.v_string = NULL;
957 rettv->v_type = VAR_STRING; 955 rettv->v_type = VAR_STRING;
958 if (in_vim9script() 956 if (in_vim9script()
959 && (check_for_nonempty_string_arg(argvars, 0) == FAIL 957 && (check_for_nonempty_string_arg(argvars, 0) == FAIL
960 || check_for_opt_string_arg(argvars, 1) == FAIL 958 || check_for_opt_string_arg(argvars, 1) == FAIL
961 || (argvars[1].v_type != VAR_UNKNOWN 959 || (argvars[1].v_type != VAR_UNKNOWN
962 && check_for_opt_number_arg(argvars, 2) == FAIL))) 960 && check_for_opt_number_arg(argvars, 2) == FAIL)))
963 return; 961 return;
964 962
965 #ifdef FEAT_SEARCHPATH
966 fname = tv_get_string(&argvars[0]); 963 fname = tv_get_string(&argvars[0]);
967 964
968 if (argvars[1].v_type != VAR_UNKNOWN) 965 if (argvars[1].v_type != VAR_UNKNOWN)
969 { 966 {
970 p = tv_get_string_buf_chk(&argvars[1], pathbuf); 967 p = tv_get_string_buf_chk(&argvars[1], pathbuf);
1004 } while ((rettv->v_type == VAR_LIST || --count > 0) && fresult != NULL); 1001 } while ((rettv->v_type == VAR_LIST || --count > 0) && fresult != NULL);
1005 } 1002 }
1006 1003
1007 if (rettv->v_type == VAR_STRING) 1004 if (rettv->v_type == VAR_STRING)
1008 rettv->vval.v_string = fresult; 1005 rettv->vval.v_string = fresult;
1009 #endif
1010 } 1006 }
1011 1007
1012 /* 1008 /*
1013 * "finddir({fname}[, {path}[, {count}]])" function 1009 * "finddir({fname}[, {path}[, {count}]])" function
1014 */ 1010 */
3877 garray_T ga; 3873 garray_T ga;
3878 char_u *p; 3874 char_u *p;
3879 static int recursive = FALSE; 3875 static int recursive = FALSE;
3880 int add_pat; 3876 int add_pat;
3881 int retval = OK; 3877 int retval = OK;
3882 #if defined(FEAT_SEARCHPATH)
3883 int did_expand_in_path = FALSE; 3878 int did_expand_in_path = FALSE;
3884 #endif
3885 3879
3886 /* 3880 /*
3887 * expand_env() is called to expand things like "~user". If this fails, 3881 * expand_env() is called to expand things like "~user". If this fails,
3888 * it calls ExpandOne(), which brings us back here. In this case, always 3882 * it calls ExpandOne(), which brings us back here. In this case, always
3889 * call the machine specific expansion function, if possible. Otherwise, 3883 * call the machine specific expansion function, if possible. Otherwise,
3969 * Otherwise: Add the file name if it exists or when EW_NOTFOUND is 3963 * Otherwise: Add the file name if it exists or when EW_NOTFOUND is
3970 * given. 3964 * given.
3971 */ 3965 */
3972 if (mch_has_exp_wildcard(p) || (flags & EW_ICASE)) 3966 if (mch_has_exp_wildcard(p) || (flags & EW_ICASE))
3973 { 3967 {
3974 #if defined(FEAT_SEARCHPATH)
3975 if ((flags & EW_PATH) 3968 if ((flags & EW_PATH)
3976 && !mch_isFullName(p) 3969 && !mch_isFullName(p)
3977 && !(p[0] == '.' 3970 && !(p[0] == '.'
3978 && (vim_ispathsep(p[1]) 3971 && (vim_ispathsep(p[1])
3979 || (p[1] == '.' && vim_ispathsep(p[2])))) 3972 || (p[1] == '.' && vim_ispathsep(p[2]))))
3985 add_pat = expand_in_path(&ga, p, flags); 3978 add_pat = expand_in_path(&ga, p, flags);
3986 recursive = TRUE; 3979 recursive = TRUE;
3987 did_expand_in_path = TRUE; 3980 did_expand_in_path = TRUE;
3988 } 3981 }
3989 else 3982 else
3990 #endif
3991 add_pat = mch_expandpath(&ga, p, flags); 3983 add_pat = mch_expandpath(&ga, p, flags);
3992 } 3984 }
3993 } 3985 }
3994 3986
3995 if (add_pat == -1 || (add_pat == 0 && (flags & EW_NOTFOUND))) 3987 if (add_pat == -1 || (add_pat == 0 && (flags & EW_NOTFOUND)))
4005 3997
4006 if (t != p) 3998 if (t != p)
4007 vim_free(t); 3999 vim_free(t);
4008 } 4000 }
4009 4001
4010 #if defined(FEAT_SEARCHPATH)
4011 if (did_expand_in_path && ga.ga_len > 0 && (flags & EW_PATH)) 4002 if (did_expand_in_path && ga.ga_len > 0 && (flags & EW_PATH))
4012 uniquefy_paths(&ga, p); 4003 uniquefy_paths(&ga, p);
4013 #endif
4014 if (p != pat[i]) 4004 if (p != pat[i])
4015 vim_free(p); 4005 vim_free(p);
4016 } 4006 }
4017 4007
4018 // When returning FAIL the array must be freed here. 4008 // When returning FAIL the array must be freed here.