updated for version 7.3.872

Problem:    On some systems case of file names is always ignored, on others
            never.
Solution:   Add the 'fileignorecase' option to control this at runtime.
            Implies 'wildignorecase'.
This commit is contained in:
Bram Moolenaar
2013-03-19 16:49:16 +01:00
parent db333a5b8d
commit 71afbfe6cd
13 changed files with 55 additions and 76 deletions

View File

@ -1,4 +1,4 @@
*options.txt* For Vim version 7.3. Last change: 2013 Mar 13 *options.txt* For Vim version 7.3. Last change: 2013 Mar 19
VIM REFERENCE MANUAL by Bram Moolenaar VIM REFERENCE MANUAL by Bram Moolenaar
@ -2941,6 +2941,14 @@ A jump table for the options with a short description can be found at |Q_op|.
NOTE: This option is set to the Vi default value when 'compatible' is NOTE: This option is set to the Vi default value when 'compatible' is
set and to the Vim default value when 'compatible' is reset. set and to the Vim default value when 'compatible' is reset.
*'fileignorecase'* *'wic'* *'nofileignorecase'* *'nowic'*
'fileignorecase' 'wic' boolean (default on for systems where case in file
names is normally ignored.
global
{not in Vi}
When set case is ignored when using file names and directories.
See 'wildignorecase' for only ignoring case when doing completion.
*'filetype'* *'ft'* *'filetype'* *'ft'*
'filetype' 'ft' string (default: "") 'filetype' 'ft' string (default: "")
local to buffer local to buffer
@ -7903,7 +7911,7 @@ A jump table for the options with a short description can be found at |Q_op|.
global global
{not in Vi} {not in Vi}
When set case is ignored when completing file names and directories. When set case is ignored when completing file names and directories.
Has no effect on systems where file name case is generally ignored. Has no effect when 'fileignorecase' is set.
Does not apply when the shell is used to expand wildcards, which Does not apply when the shell is used to expand wildcards, which
happens when there are special characters. happens when there are special characters.

View File

@ -1,6 +1,6 @@
" Vim plugin for showing matching parens " Vim plugin for showing matching parens
" Maintainer: Bram Moolenaar <Bram@vim.org> " Maintainer: Bram Moolenaar <Bram@vim.org>
" Last Change: 2011 Aug 27 " Last Change: 2013 Mar 19
" Exit quickly when: " Exit quickly when:
" - this plugin was already loaded (or disabled) " - this plugin was already loaded (or disabled)

View File

@ -2401,12 +2401,7 @@ fname_match(prog, name)
if (name != NULL) if (name != NULL)
{ {
regmatch.regprog = prog; regmatch.regprog = prog;
#ifdef CASE_INSENSITIVE_FILENAME regmatch.rm_ic = p_fic; /* ignore case when 'fileignorecase' is set */
regmatch.rm_ic = TRUE; /* Always ignore case */
#else
regmatch.rm_ic = FALSE; /* Never ignore case */
#endif
if (vim_regexec(&regmatch, name, (colnr_T)0)) if (vim_regexec(&regmatch, name, (colnr_T)0))
match = name; match = name;
else else

View File

@ -4336,13 +4336,7 @@ ins_compl_get_exp(ini)
/* May change home directory back to "~". */ /* May change home directory back to "~". */
tilde_replace(compl_pattern, num_matches, matches); tilde_replace(compl_pattern, num_matches, matches);
ins_compl_add_matches(num_matches, matches, ins_compl_add_matches(num_matches, matches, p_fic || p_wic);
#ifdef CASE_INSENSITIVE_FILENAME
TRUE
#else
FALSE
#endif
);
} }
break; break;

View File

@ -1926,11 +1926,7 @@ do_arglist(str, what, after)
* Delete the items: use each item as a regexp and find a match in the * Delete the items: use each item as a regexp and find a match in the
* argument list. * argument list.
*/ */
#ifdef CASE_INSENSITIVE_FILENAME regmatch.rm_ic = p_fic; /* ignore case when 'fileignorecase' is set */
regmatch.rm_ic = TRUE; /* Always ignore case */
#else
regmatch.rm_ic = FALSE; /* Never ignore case */
#endif
for (i = 0; i < new_ga.ga_len && !got_int; ++i) for (i = 0; i < new_ga.ga_len && !got_int; ++i)
{ {
p = ((char_u **)new_ga.ga_data)[i]; p = ((char_u **)new_ga.ga_data)[i];

View File

@ -3653,19 +3653,16 @@ ExpandOne(xp, str, orig, options, mode)
{ {
for (i = 0; i < xp->xp_numfiles; ++i) for (i = 0; i < xp->xp_numfiles; ++i)
{ {
#ifdef CASE_INSENSITIVE_FILENAME if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES
if (xp->xp_context == EXPAND_DIRECTORIES
|| xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_FILES
|| xp->xp_context == EXPAND_SHELLCMD || xp->xp_context == EXPAND_SHELLCMD
|| xp->xp_context == EXPAND_BUFFERS) || xp->xp_context == EXPAND_BUFFERS))
{ {
if (TOLOWER_LOC(xp->xp_files[i][len]) != if (TOLOWER_LOC(xp->xp_files[i][len]) !=
TOLOWER_LOC(xp->xp_files[0][len])) TOLOWER_LOC(xp->xp_files[0][len]))
break; break;
} }
else else if (xp->xp_files[i][len] != xp->xp_files[0][len])
#endif
if (xp->xp_files[i][len] != xp->xp_files[0][len])
break; break;
} }
if (i < xp->xp_numfiles) if (i < xp->xp_numfiles)

View File

@ -6485,9 +6485,7 @@ vim_rename(from, to)
#ifdef HAVE_ACL #ifdef HAVE_ACL
vim_acl_T acl; /* ACL from original file */ vim_acl_T acl; /* ACL from original file */
#endif #endif
#if defined(UNIX) || defined(CASE_INSENSITIVE_FILENAME)
int use_tmp_file = FALSE; int use_tmp_file = FALSE;
#endif
/* /*
* When the names are identical, there is nothing to do. When they refer * When the names are identical, there is nothing to do. When they refer
@ -6496,11 +6494,9 @@ vim_rename(from, to)
*/ */
if (fnamecmp(from, to) == 0) if (fnamecmp(from, to) == 0)
{ {
#ifdef CASE_INSENSITIVE_FILENAME if (p_fic && STRCMP(gettail(from), gettail(to)) != 0)
if (STRCMP(gettail(from), gettail(to)) != 0)
use_tmp_file = TRUE; use_tmp_file = TRUE;
else else
#endif
return 0; return 0;
} }
@ -6539,7 +6535,6 @@ vim_rename(from, to)
} }
#endif #endif
#if defined(UNIX) || defined(CASE_INSENSITIVE_FILENAME)
if (use_tmp_file) if (use_tmp_file)
{ {
char tempname[MAXPATHL + 1]; char tempname[MAXPATHL + 1];
@ -6572,7 +6567,6 @@ vim_rename(from, to)
} }
return -1; return -1;
} }
#endif
/* /*
* Delete the "to" file, this is required on some systems to make the * Delete the "to" file, this is required on some systems to make the
@ -10007,11 +10001,7 @@ match_file_pat(pattern, prog, fname, sfname, tail, allow_dirs)
int match = FALSE; int match = FALSE;
#endif #endif
#ifdef CASE_INSENSITIVE_FILENAME regmatch.rm_ic = p_fic; /* ignore case if 'fileignorecase' is set */
regmatch.rm_ic = TRUE; /* Always ignore case */
#else
regmatch.rm_ic = FALSE; /* Don't ever ignore case */
#endif
#ifdef FEAT_OSFILETYPE #ifdef FEAT_OSFILETYPE
if (*pattern == '<') if (*pattern == '<')
{ {

View File

@ -5026,16 +5026,21 @@ dir_of_file_exists(fname)
return retval; return retval;
} }
#if (defined(CASE_INSENSITIVE_FILENAME) && defined(BACKSLASH_IN_FILENAME)) \
|| defined(PROTO)
/* /*
* Versions of fnamecmp() and fnamencmp() that handle '/' and '\' equally. * Versions of fnamecmp() and fnamencmp() that handle '/' and '\' equally
* and deal with 'fileignorecase'.
*/ */
int int
vim_fnamecmp(x, y) vim_fnamecmp(x, y)
char_u *x, *y; char_u *x, *y;
{ {
#ifdef BACKSLASH_IN_FILENAME
return vim_fnamencmp(x, y, MAXPATHL); return vim_fnamencmp(x, y, MAXPATHL);
#else
if (p_fic)
return MB_STRICMP(x, y);
return STRCMP(x, y);
#endif
} }
int int
@ -5043,9 +5048,11 @@ vim_fnamencmp(x, y, len)
char_u *x, *y; char_u *x, *y;
size_t len; size_t len;
{ {
#ifdef BACKSLASH_IN_FILENAME
/* TODO: multi-byte characters. */
while (len > 0 && *x && *y) while (len > 0 && *x && *y)
{ {
if (TOLOWER_LOC(*x) != TOLOWER_LOC(*y) if ((p_fic ? TOLOWER_LOC(*x) != TOLOWER_LOC(*y) : *x != *y)
&& !(*x == '/' && *y == '\\') && !(*x == '/' && *y == '\\')
&& !(*x == '\\' && *y == '/')) && !(*x == '\\' && *y == '/'))
break; break;
@ -5056,8 +5063,12 @@ vim_fnamencmp(x, y, len)
if (len == 0) if (len == 0)
return 0; return 0;
return (*x - *y); return (*x - *y);
} #else
if (p_fic)
return MB_STRNICMP(x, y, len);
return STRNCMP(x, y, len);
#endif #endif
}
/* /*
* Concatenate file names fname1 and fname2 into allocated memory. * Concatenate file names fname1 and fname2 into allocated memory.
@ -9835,11 +9846,8 @@ unix_expandpath(gap, path, wildoff, flags, didstar)
} }
else if (path_end >= path + wildoff else if (path_end >= path + wildoff
&& (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL && (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL
#ifndef CASE_INSENSITIVE_FILENAME || (!p_fic && (flags & EW_ICASE)
|| ((flags & EW_ICASE) && isalpha(PTR2CHAR(path_end)))))
&& isalpha(PTR2CHAR(path_end)))
#endif
))
e = p; e = p;
#ifdef FEAT_MBYTE #ifdef FEAT_MBYTE
if (has_mbyte) if (has_mbyte)
@ -9882,14 +9890,10 @@ unix_expandpath(gap, path, wildoff, flags, didstar)
} }
/* compile the regexp into a program */ /* compile the regexp into a program */
#ifdef CASE_INSENSITIVE_FILENAME
regmatch.rm_ic = TRUE; /* Behave like Terminal.app */
#else
if (flags & EW_ICASE) if (flags & EW_ICASE)
regmatch.rm_ic = TRUE; /* 'wildignorecase' set */ regmatch.rm_ic = TRUE; /* 'wildignorecase' set */
else else
regmatch.rm_ic = FALSE; /* Don't ignore case */ regmatch.rm_ic = p_fic; /* ignore case when 'fileignorecase' is set */
#endif
if (flags & (EW_NOERROR | EW_NOTWILD)) if (flags & (EW_NOERROR | EW_NOTWILD))
++emsg_silent; ++emsg_silent;
regmatch.regprog = vim_regcomp(pat, RE_MAGIC); regmatch.regprog = vim_regcomp(pat, RE_MAGIC);

View File

@ -5362,13 +5362,11 @@ ff_wc_equal(s1, s2)
if (STRLEN(s1) != STRLEN(s2)) if (STRLEN(s1) != STRLEN(s2))
return FAIL; return FAIL;
/* TODO: handle multi-byte characters. */
for (i = 0; s1[i] != NUL && s2[i] != NUL; i++) for (i = 0; s1[i] != NUL && s2[i] != NUL; i++)
{ {
if (s1[i] != s2[i] if (s1[i] != s2[i]
#ifdef CASE_INSENSITIVE_FILENAME && (!p_fic || TOUPPER_LOC(s1[i]) != TOUPPER_LOC(s2[i])))
&& TOUPPER_LOC(s1[i]) != TOUPPER_LOC(s2[i])
#endif
)
{ {
if (i >= 2) if (i >= 2)
if (s1[i-1] == '*' && s1[i-2] == '*') if (s1[i-1] == '*' && s1[i-2] == '*')
@ -6123,12 +6121,7 @@ pathcmp(p, q, maxlen)
break; break;
} }
if ( if ((p_fic ? TOUPPER_LOC(p[i]) != TOUPPER_LOC(q[i]) : p[i] != q[i])
#ifdef CASE_INSENSITIVE_FILENAME
TOUPPER_LOC(p[i]) != TOUPPER_LOC(q[i])
#else
p[i] != q[i]
#endif
#ifdef BACKSLASH_IN_FILENAME #ifdef BACKSLASH_IN_FILENAME
/* consider '/' and '\\' to be equal */ /* consider '/' and '\\' to be equal */
&& !((p[i] == '/' && q[i] == '\\') && !((p[i] == '/' && q[i] == '\\')

View File

@ -1108,6 +1108,15 @@ static struct vimoption
(char_u *)&p_ffs, PV_NONE, (char_u *)&p_ffs, PV_NONE,
{(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM} {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM}
SCRIPTID_INIT}, SCRIPTID_INIT},
{"fileignorecase", "fic", P_BOOL|P_VI_DEF,
(char_u *)&p_fic, PV_NONE,
{
#ifdef CASE_INSENSITIVE_FILENAME
(char_u *)TRUE,
#else
(char_u *)FALSE,
#endif
(char_u *)0L} SCRIPTID_INIT},
{"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME, {"filetype", "ft", P_STRING|P_ALLOCED|P_VI_DEF|P_NOGLOB|P_NFNAME,
#ifdef FEAT_AUTOCMD #ifdef FEAT_AUTOCMD
(char_u *)&p_ft, PV_FT, (char_u *)&p_ft, PV_FT,

View File

@ -453,6 +453,7 @@ EXTERN int p_exrc; /* 'exrc' */
EXTERN char_u *p_fencs; /* 'fileencodings' */ EXTERN char_u *p_fencs; /* 'fileencodings' */
#endif #endif
EXTERN char_u *p_ffs; /* 'fileformats' */ EXTERN char_u *p_ffs; /* 'fileformats' */
EXTERN long p_fic; /* 'fileignorecase' */
#ifdef FEAT_FOLDING #ifdef FEAT_FOLDING
EXTERN char_u *p_fcl; /* 'foldclose' */ EXTERN char_u *p_fcl; /* 'foldclose' */
EXTERN long p_fdls; /* 'foldlevelstart' */ EXTERN long p_fdls; /* 'foldlevelstart' */

View File

@ -728,6 +728,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
872,
/**/ /**/
871, 871,
/**/ /**/

View File

@ -1627,18 +1627,8 @@ void mch_memmove __ARGS((void *, void *, size_t));
* (this does not account for maximum name lengths and things like "../dir", * (this does not account for maximum name lengths and things like "../dir",
* thus it is not 100% accurate!) * thus it is not 100% accurate!)
*/ */
#ifdef CASE_INSENSITIVE_FILENAME #define fnamecmp(x, y) vim_fnamecmp((char_u *)(x), (char_u *)(y))
# ifdef BACKSLASH_IN_FILENAME #define fnamencmp(x, y, n) vim_fnamencmp((char_u *)(x), (char_u *)(y), (size_t)(n))
# define fnamecmp(x, y) vim_fnamecmp((x), (y))
# define fnamencmp(x, y, n) vim_fnamencmp((x), (y), (size_t)(n))
# else
# define fnamecmp(x, y) MB_STRICMP((x), (y))
# define fnamencmp(x, y, n) MB_STRNICMP((x), (y), (n))
# endif
#else
# define fnamecmp(x, y) strcmp((char *)(x), (char *)(y))
# define fnamencmp(x, y, n) strncmp((char *)(x), (char *)(y), (size_t)(n))
#endif
#ifdef HAVE_MEMSET #ifdef HAVE_MEMSET
# define vim_memset(ptr, c, size) memset((ptr), (c), (size)) # define vim_memset(ptr, c, size) memset((ptr), (c), (size))