Commit 7ec4d478 authored by John Schmidt's avatar John Schmidt Committed by Thiago de Arruda

Move match_suffix from misc1.c

parent 35e737e6
......@@ -3485,39 +3485,6 @@ void fast_breakcheck(void)
}
}
/*
* Return TRUE if "fname" matches with an entry in 'suffixes'.
*/
int match_suffix(char_u *fname)
{
int fnamelen, setsuflen;
char_u *setsuf;
#define MAXSUFLEN 30 /* maximum length of a file suffix */
char_u suf_buf[MAXSUFLEN];
fnamelen = (int)STRLEN(fname);
setsuflen = 0;
for (setsuf = p_su; *setsuf; ) {
setsuflen = copy_option_part(&setsuf, suf_buf, MAXSUFLEN, ".,");
if (setsuflen == 0) {
char_u *tail = gettail(fname);
/* empty entry: match name without a '.' */
if (vim_strchr(tail, '.') == NULL) {
setsuflen = 1;
break;
}
} else {
if (fnamelen >= setsuflen
&& fnamencmp(suf_buf, fname + fnamelen - setsuflen,
(size_t)setsuflen) == 0)
break;
setsuflen = 0;
}
}
return setsuflen != 0;
}
#ifndef SEEK_SET
# define SEEK_SET 0
#endif
......
......@@ -67,7 +67,6 @@ void prepare_to_exit(void);
void preserve_exit(void);
void line_breakcheck(void);
void fast_breakcheck(void);
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);
int goto_im(void);
......
......@@ -4,6 +4,7 @@
#include "path.h"
#include "charset.h"
#include "eval.h"
#include "ex_docmd.h"
#include "ex_getln.h"
#include "fileio.h"
#include "file_search.h"
......@@ -2012,3 +2013,35 @@ expand_wildcards (
return retval;
}
/*
* Return TRUE if "fname" matches with an entry in 'suffixes'.
*/
int match_suffix(char_u *fname)
{
int fnamelen, setsuflen;
char_u *setsuf;
#define MAXSUFLEN 30 /* maximum length of a file suffix */
char_u suf_buf[MAXSUFLEN];
fnamelen = (int)STRLEN(fname);
setsuflen = 0;
for (setsuf = p_su; *setsuf; ) {
setsuflen = copy_option_part(&setsuf, suf_buf, MAXSUFLEN, ".,");
if (setsuflen == 0) {
char_u *tail = gettail(fname);
/* empty entry: match name without a '.' */
if (vim_strchr(tail, '.') == NULL) {
setsuflen = 1;
break;
}
} else {
if (fnamelen >= setsuflen
&& fnamencmp(suf_buf, fname + fnamelen - setsuflen,
(size_t)setsuflen) == 0)
break;
setsuflen = 0;
}
}
return setsuflen != 0;
}
......@@ -44,4 +44,5 @@ int expand_wildcards_eval(char_u **pat, int *num_file, char_u ***file,
int expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u *
**file,
int flags);
int match_suffix(char_u *fname);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment