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

committed by
Thiago de Arruda

parent
35e737e63c
commit
7ec4d478eb
33
src/misc1.c
33
src/misc1.c
@@ -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
|
#ifndef SEEK_SET
|
||||||
# define SEEK_SET 0
|
# define SEEK_SET 0
|
||||||
#endif
|
#endif
|
||||||
|
@@ -67,7 +67,6 @@ void prepare_to_exit(void);
|
|||||||
void preserve_exit(void);
|
void preserve_exit(void);
|
||||||
void line_breakcheck(void);
|
void line_breakcheck(void);
|
||||||
void fast_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);
|
char_u *get_cmd_output(char_u *cmd, char_u *infile, int flags);
|
||||||
void FreeWild(int count, char_u **files);
|
void FreeWild(int count, char_u **files);
|
||||||
int goto_im(void);
|
int goto_im(void);
|
||||||
|
33
src/path.c
33
src/path.c
@@ -4,6 +4,7 @@
|
|||||||
#include "path.h"
|
#include "path.h"
|
||||||
#include "charset.h"
|
#include "charset.h"
|
||||||
#include "eval.h"
|
#include "eval.h"
|
||||||
|
#include "ex_docmd.h"
|
||||||
#include "ex_getln.h"
|
#include "ex_getln.h"
|
||||||
#include "fileio.h"
|
#include "fileio.h"
|
||||||
#include "file_search.h"
|
#include "file_search.h"
|
||||||
@@ -2012,3 +2013,35 @@ expand_wildcards (
|
|||||||
return retval;
|
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 *
|
int expand_wildcards(int num_pat, char_u **pat, int *num_file, char_u *
|
||||||
**file,
|
**file,
|
||||||
int flags);
|
int flags);
|
||||||
|
int match_suffix(char_u *fname);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user