Remove FEAT_OSFILETYPE

Feature description from Vim documentation:

NOTE: this code is currently disabled, as the RISC OS implementation was
removed.  In the future this will use the 'filetype' option.

On operating systems which support storing a file type with the file, you can
specify that an autocommand should only be executed if the file is of a
certain type.

The actual type checking depends on which platform you are running Vim
on; see your system's documentation for details.

To use osfiletype checking in an autocommand you should put a list of types to
match in angle brackets in place of a pattern, like this: >

	:au BufRead *.html,<&faf;HTML>  runtime! syntax/html.vim

This will match:

- Any file whose name ends in ".html"
- Any file whose type is "&faf" or "HTML", where the meaning of these types
  depends on which version of Vim you are using.
  Unknown types are considered NOT to match.
This commit is contained in:
Pavel Platto 2014-06-06 10:55:54 +03:00
parent 77cb6551a6
commit b2b920f20e

View File

@ -7185,45 +7185,8 @@ match_file_pat (
{
regmatch_T regmatch;
int result = FALSE;
#ifdef FEAT_OSFILETYPE
int no_pattern = FALSE; /* TRUE if check is filetype only */
char_u *type_start;
char_u c;
int match = FALSE;
#endif
regmatch.rm_ic = p_fic; /* ignore case if 'fileignorecase' is set */
#ifdef FEAT_OSFILETYPE
if (*pattern == '<') {
/* There is a filetype condition specified with this pattern.
* Check the filetype matches first. If not, don't bother with the
* pattern (set regprog to NULL).
* Always use magic for the regexp.
*/
for (type_start = pattern + 1; (c = *pattern); pattern++) {
if ((c == ';' || c == '>') && match == FALSE) {
*pattern = NUL; /* Terminate the string */
/* TODO: match with 'filetype' of buffer that "fname" comes
* from. */
match = mch_check_filetype(fname, type_start);
*pattern = c; /* Restore the terminator */
type_start = pattern + 1;
}
if (c == '>')
break;
}
/* (c should never be NUL, but check anyway) */
if (match == FALSE || c == NUL)
regmatch.regprog = NULL; /* Doesn't match - don't check pat. */
else if (*pattern == NUL) {
regmatch.regprog = NULL; /* Vim will try to free regprog later */
no_pattern = TRUE; /* Always matches - don't check pat. */
} else
regmatch.regprog = vim_regcomp(pattern + 1, RE_MAGIC);
} else
#endif
{
if (prog != NULL)
regmatch.regprog = prog;
@ -7238,12 +7201,6 @@ match_file_pat (
* 3. the tail of the file name, when the pattern has no '/'.
*/
if (
#ifdef FEAT_OSFILETYPE
/* If the check is for a filetype only and we don't care
* about the path then skip all the regexp stuff.
*/
no_pattern ||
#endif
(regmatch.regprog != NULL
&& ((allow_dirs
&& (vim_regexec(&regmatch, fname, (colnr_T)0)
@ -7296,9 +7253,6 @@ int match_file_list(char_u *list, char_u *sfname, char_u *ffname)
* allow_dirs, otherwise FALSE is put there -- webb.
* Handle backslashes before special characters, like "\*" and "\ ".
*
* If FEAT_OSFILETYPE defined then pass initial <type> through unchanged. Eg:
* '<html>myfile' becomes '<html>^myfile$' -- leonard.
*
* Returns NULL on failure.
*/
char_u *
@ -7316,38 +7270,13 @@ file_pat_to_reg_pat (
int i;
int nested = 0;
int add_dollar = TRUE;
#ifdef FEAT_OSFILETYPE
int check_length = 0;
#endif
if (allow_dirs != NULL)
*allow_dirs = FALSE;
if (pat_end == NULL)
pat_end = pat + STRLEN(pat);
#ifdef FEAT_OSFILETYPE
/* Find out how much of the string is the filetype check */
if (*pat == '<') {
/* Count chars until the next '>' */
for (p = pat + 1; p < pat_end && *p != '>'; p++)
;
if (p < pat_end) {
/* Pattern is of the form <.*>.* */
check_length = p - pat + 1;
if (p + 1 >= pat_end) {
/* The 'pattern' is a filetype check ONLY */
reg_pat = xmemdupz(pat, (size_t)check_length);
return reg_pat;
}
}
/* else: there was no closing '>' - assume it was a normal pattern */
}
pat += check_length;
size = 2 + (size_t)check_length;
#else
size = 2; /* '^' at start, '$' at end */
#endif
for (p = pat; p < pat_end; p++) {
switch (*p) {
@ -7376,14 +7305,7 @@ file_pat_to_reg_pat (
}
reg_pat = xmalloc(size + 1);
#ifdef FEAT_OSFILETYPE
/* Copy the type check in to the start. */
if (check_length)
memmove(reg_pat, pat - check_length, (size_t)check_length);
i = check_length;
#else
i = 0;
#endif
if (pat[0] == '*')
while (pat[0] == '*' && pat < pat_end - 1)