aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Schmidt <john.schmidt.h@gmail.com>2014-03-31 16:23:01 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-01 08:08:07 -0300
commit35e737e63c5c57a0ec0b52f86a81cbf94fd32bcd (patch)
tree094ad5b632e0407567cec83b0ccff97fe2940a12
parentd31e5988959c116db7130799f692750f08ae8d9b (diff)
downloadrneovim-35e737e63c5c57a0ec0b52f86a81cbf94fd32bcd.tar.gz
rneovim-35e737e63c5c57a0ec0b52f86a81cbf94fd32bcd.tar.bz2
rneovim-35e737e63c5c57a0ec0b52f86a81cbf94fd32bcd.zip
Move expand_wildcards{,_eval} from misc1.c
-rw-r--r--src/misc1.c109
-rw-r--r--src/misc1.h5
-rw-r--r--src/path.c109
-rw-r--r--src/path.h5
4 files changed, 114 insertions, 114 deletions
diff --git a/src/misc1.c b/src/misc1.c
index 1fbc14885d..ea3564e469 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -3486,115 +3486,6 @@ void fast_breakcheck(void)
}
/*
- * Invoke expand_wildcards() for one pattern.
- * Expand items like "%:h" before the expansion.
- * Returns OK or FAIL.
- */
-int
-expand_wildcards_eval (
- char_u **pat, /* pointer to input pattern */
- int *num_file, /* resulting number of files */
- char_u ***file, /* array of resulting files */
- int flags /* EW_DIR, etc. */
-)
-{
- int ret = FAIL;
- char_u *eval_pat = NULL;
- char_u *exp_pat = *pat;
- char_u *ignored_msg;
- int usedlen;
-
- if (*exp_pat == '%' || *exp_pat == '#' || *exp_pat == '<') {
- ++emsg_off;
- eval_pat = eval_vars(exp_pat, exp_pat, &usedlen,
- NULL, &ignored_msg, NULL);
- --emsg_off;
- if (eval_pat != NULL)
- exp_pat = concat_str(eval_pat, exp_pat + usedlen);
- }
-
- if (exp_pat != NULL)
- ret = expand_wildcards(1, &exp_pat, num_file, file, flags);
-
- if (eval_pat != NULL) {
- vim_free(exp_pat);
- vim_free(eval_pat);
- }
-
- return ret;
-}
-
-/*
- * Expand wildcards. Calls gen_expand_wildcards() and removes files matching
- * 'wildignore'.
- * Returns OK or FAIL. When FAIL then "num_file" won't be set.
- */
-int
-expand_wildcards (
- int num_pat, /* number of input patterns */
- char_u **pat, /* array of input patterns */
- int *num_file, /* resulting number of files */
- char_u ***file, /* array of resulting files */
- int flags /* EW_DIR, etc. */
-)
-{
- int retval;
- int i, j;
- char_u *p;
- int non_suf_match; /* number without matching suffix */
-
- retval = gen_expand_wildcards(num_pat, pat, num_file, file, flags);
-
- /* When keeping all matches, return here */
- if ((flags & EW_KEEPALL) || retval == FAIL)
- return retval;
-
- /*
- * Remove names that match 'wildignore'.
- */
- if (*p_wig) {
- char_u *ffname;
-
- /* check all files in (*file)[] */
- for (i = 0; i < *num_file; ++i) {
- ffname = FullName_save((*file)[i], FALSE);
- if (ffname == NULL) /* out of memory */
- break;
- if (match_file_list(p_wig, (*file)[i], ffname)) {
- /* remove this matching file from the list */
- vim_free((*file)[i]);
- for (j = i; j + 1 < *num_file; ++j)
- (*file)[j] = (*file)[j + 1];
- --*num_file;
- --i;
- }
- vim_free(ffname);
- }
- }
-
- /*
- * Move the names where 'suffixes' match to the end.
- */
- if (*num_file > 1) {
- non_suf_match = 0;
- for (i = 0; i < *num_file; ++i) {
- if (!match_suffix((*file)[i])) {
- /*
- * Move the name without matching suffix to the front
- * of the list.
- */
- p = (*file)[i];
- for (j = i; j > non_suf_match; --j)
- (*file)[j] = (*file)[j - 1];
- (*file)[non_suf_match++] = p;
- }
- }
- }
-
- return retval;
-}
-
-/*
* Return TRUE if "fname" matches with an entry in 'suffixes'.
*/
int match_suffix(char_u *fname)
diff --git a/src/misc1.h b/src/misc1.h
index ab793082c9..b037b64bc7 100644
--- a/src/misc1.h
+++ b/src/misc1.h
@@ -67,11 +67,6 @@ void prepare_to_exit(void);
void preserve_exit(void);
void line_breakcheck(void);
void fast_breakcheck(void);
-int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file,
- int flags);
-int expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u *
- **file,
- int flags);
int match_suffix(char_u *fname);
char_u *get_cmd_output(char_u *cmd, char_u *infile, int flags);
void FreeWild(int count, char_u **files);
diff --git a/src/path.c b/src/path.c
index 0d7685031b..17a9d0fe7e 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1903,3 +1903,112 @@ void shorten_filenames(char_u **fnames, int count)
}
#endif
+/*
+ * Invoke expand_wildcards() for one pattern.
+ * Expand items like "%:h" before the expansion.
+ * Returns OK or FAIL.
+ */
+int
+expand_wildcards_eval (
+ char_u **pat, /* pointer to input pattern */
+ int *num_file, /* resulting number of files */
+ char_u ***file, /* array of resulting files */
+ int flags /* EW_DIR, etc. */
+)
+{
+ int ret = FAIL;
+ char_u *eval_pat = NULL;
+ char_u *exp_pat = *pat;
+ char_u *ignored_msg;
+ int usedlen;
+
+ if (*exp_pat == '%' || *exp_pat == '#' || *exp_pat == '<') {
+ ++emsg_off;
+ eval_pat = eval_vars(exp_pat, exp_pat, &usedlen,
+ NULL, &ignored_msg, NULL);
+ --emsg_off;
+ if (eval_pat != NULL)
+ exp_pat = concat_str(eval_pat, exp_pat + usedlen);
+ }
+
+ if (exp_pat != NULL)
+ ret = expand_wildcards(1, &exp_pat, num_file, file, flags);
+
+ if (eval_pat != NULL) {
+ vim_free(exp_pat);
+ vim_free(eval_pat);
+ }
+
+ return ret;
+}
+
+/*
+ * Expand wildcards. Calls gen_expand_wildcards() and removes files matching
+ * 'wildignore'.
+ * Returns OK or FAIL. When FAIL then "num_file" won't be set.
+ */
+int
+expand_wildcards (
+ int num_pat, /* number of input patterns */
+ char_u **pat, /* array of input patterns */
+ int *num_file, /* resulting number of files */
+ char_u ***file, /* array of resulting files */
+ int flags /* EW_DIR, etc. */
+)
+{
+ int retval;
+ int i, j;
+ char_u *p;
+ int non_suf_match; /* number without matching suffix */
+
+ retval = gen_expand_wildcards(num_pat, pat, num_file, file, flags);
+
+ /* When keeping all matches, return here */
+ if ((flags & EW_KEEPALL) || retval == FAIL)
+ return retval;
+
+ /*
+ * Remove names that match 'wildignore'.
+ */
+ if (*p_wig) {
+ char_u *ffname;
+
+ /* check all files in (*file)[] */
+ for (i = 0; i < *num_file; ++i) {
+ ffname = FullName_save((*file)[i], FALSE);
+ if (ffname == NULL) /* out of memory */
+ break;
+ if (match_file_list(p_wig, (*file)[i], ffname)) {
+ /* remove this matching file from the list */
+ vim_free((*file)[i]);
+ for (j = i; j + 1 < *num_file; ++j)
+ (*file)[j] = (*file)[j + 1];
+ --*num_file;
+ --i;
+ }
+ vim_free(ffname);
+ }
+ }
+
+ /*
+ * Move the names where 'suffixes' match to the end.
+ */
+ if (*num_file > 1) {
+ non_suf_match = 0;
+ for (i = 0; i < *num_file; ++i) {
+ if (!match_suffix((*file)[i])) {
+ /*
+ * Move the name without matching suffix to the front
+ * of the list.
+ */
+ p = (*file)[i];
+ for (j = i; j > non_suf_match; --j)
+ (*file)[j] = (*file)[j - 1];
+ (*file)[non_suf_match++] = p;
+ }
+ }
+ }
+
+ return retval;
+}
+
diff --git a/src/path.h b/src/path.h
index 8304741d2b..a872d7a413 100644
--- a/src/path.h
+++ b/src/path.h
@@ -39,4 +39,9 @@ char_u *shorten_fname1(char_u *full_path);
char_u *shorten_fname(char_u *full_path, char_u *dir_name);
void shorten_fnames(int force);
void shorten_filenames(char_u **fnames, int count);
+int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file,
+ int flags);
+int expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u *
+ **file,
+ int flags);
#endif