mirror of
https://github.com/neovim/neovim.git
synced 2025-09-24 20:18:32 +00:00
Move match_suffix from misc1.c
This commit is contained in:

committed by
Thiago de Arruda

parent
35e737e63c
commit
7ec4d478eb
33
src/path.c
33
src/path.c
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user