# HG changeset patch # User Bram Moolenaar # Date 1363708156 -3600 # Node ID edd0bc1f26bd019cfd328a0dc2c9a854607e4a41 # Parent bd0fbce6a988282b3ab0310cabfc2147afe92dad 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'. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -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 @@ -2941,6 +2941,14 @@ A jump table for the options with a shor NOTE: This option is set to the Vi default value when 'compatible' is 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' string (default: "") local to buffer @@ -7903,7 +7911,7 @@ A jump table for the options with a shor global {not in Vi} 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 happens when there are special characters. diff --git a/runtime/plugin/matchparen.vim b/runtime/plugin/matchparen.vim --- a/runtime/plugin/matchparen.vim +++ b/runtime/plugin/matchparen.vim @@ -1,6 +1,6 @@ " Vim plugin for showing matching parens " Maintainer: Bram Moolenaar -" Last Change: 2011 Aug 27 +" Last Change: 2013 Mar 19 " Exit quickly when: " - this plugin was already loaded (or disabled) diff --git a/src/buffer.c b/src/buffer.c --- a/src/buffer.c +++ b/src/buffer.c @@ -2401,12 +2401,7 @@ fname_match(prog, name) if (name != NULL) { regmatch.regprog = prog; -#ifdef CASE_INSENSITIVE_FILENAME - regmatch.rm_ic = TRUE; /* Always ignore case */ -#else - regmatch.rm_ic = FALSE; /* Never ignore case */ -#endif - + regmatch.rm_ic = p_fic; /* ignore case when 'fileignorecase' is set */ if (vim_regexec(®match, name, (colnr_T)0)) match = name; else diff --git a/src/edit.c b/src/edit.c --- a/src/edit.c +++ b/src/edit.c @@ -4336,13 +4336,7 @@ ins_compl_get_exp(ini) /* May change home directory back to "~". */ tilde_replace(compl_pattern, num_matches, matches); - ins_compl_add_matches(num_matches, matches, -#ifdef CASE_INSENSITIVE_FILENAME - TRUE -#else - FALSE -#endif - ); + ins_compl_add_matches(num_matches, matches, p_fic || p_wic); } break; diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1926,11 +1926,7 @@ do_arglist(str, what, after) * Delete the items: use each item as a regexp and find a match in the * argument list. */ -#ifdef CASE_INSENSITIVE_FILENAME - regmatch.rm_ic = TRUE; /* Always ignore case */ -#else - regmatch.rm_ic = FALSE; /* Never ignore case */ -#endif + regmatch.rm_ic = p_fic; /* ignore case when 'fileignorecase' is set */ for (i = 0; i < new_ga.ga_len && !got_int; ++i) { p = ((char_u **)new_ga.ga_data)[i]; diff --git a/src/ex_getln.c b/src/ex_getln.c --- a/src/ex_getln.c +++ b/src/ex_getln.c @@ -3653,19 +3653,16 @@ ExpandOne(xp, str, orig, options, mode) { for (i = 0; i < xp->xp_numfiles; ++i) { -#ifdef CASE_INSENSITIVE_FILENAME - if (xp->xp_context == EXPAND_DIRECTORIES + if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES || xp->xp_context == EXPAND_FILES || xp->xp_context == EXPAND_SHELLCMD - || xp->xp_context == EXPAND_BUFFERS) + || xp->xp_context == EXPAND_BUFFERS)) { if (TOLOWER_LOC(xp->xp_files[i][len]) != TOLOWER_LOC(xp->xp_files[0][len])) break; } - else -#endif - if (xp->xp_files[i][len] != xp->xp_files[0][len]) + else if (xp->xp_files[i][len] != xp->xp_files[0][len]) break; } if (i < xp->xp_numfiles) diff --git a/src/fileio.c b/src/fileio.c --- a/src/fileio.c +++ b/src/fileio.c @@ -6485,9 +6485,7 @@ vim_rename(from, to) #ifdef HAVE_ACL vim_acl_T acl; /* ACL from original file */ #endif -#if defined(UNIX) || defined(CASE_INSENSITIVE_FILENAME) int use_tmp_file = FALSE; -#endif /* * 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) { -#ifdef CASE_INSENSITIVE_FILENAME - if (STRCMP(gettail(from), gettail(to)) != 0) + if (p_fic && STRCMP(gettail(from), gettail(to)) != 0) use_tmp_file = TRUE; else -#endif return 0; } @@ -6539,7 +6535,6 @@ vim_rename(from, to) } #endif -#if defined(UNIX) || defined(CASE_INSENSITIVE_FILENAME) if (use_tmp_file) { char tempname[MAXPATHL + 1]; @@ -6572,7 +6567,6 @@ vim_rename(from, to) } return -1; } -#endif /* * Delete the "to" file, this is required on some systems to make the @@ -10007,11 +10001,7 @@ match_file_pat(pattern, prog, fname, sfn int match = FALSE; #endif -#ifdef CASE_INSENSITIVE_FILENAME - regmatch.rm_ic = TRUE; /* Always ignore case */ -#else - regmatch.rm_ic = FALSE; /* Don't ever ignore case */ -#endif + regmatch.rm_ic = p_fic; /* ignore case if 'fileignorecase' is set */ #ifdef FEAT_OSFILETYPE if (*pattern == '<') { diff --git a/src/misc1.c b/src/misc1.c --- a/src/misc1.c +++ b/src/misc1.c @@ -5026,16 +5026,21 @@ dir_of_file_exists(fname) 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 vim_fnamecmp(x, y) char_u *x, *y; { +#ifdef BACKSLASH_IN_FILENAME return vim_fnamencmp(x, y, MAXPATHL); +#else + if (p_fic) + return MB_STRICMP(x, y); + return STRCMP(x, y); +#endif } int @@ -5043,9 +5048,11 @@ vim_fnamencmp(x, y, len) char_u *x, *y; size_t len; { +#ifdef BACKSLASH_IN_FILENAME + /* TODO: multi-byte characters. */ 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 == '/')) break; @@ -5056,8 +5063,12 @@ vim_fnamencmp(x, y, len) if (len == 0) return 0; return (*x - *y); -} -#endif +#else + if (p_fic) + return MB_STRNICMP(x, y, len); + return STRNCMP(x, y, len); +#endif +} /* * Concatenate file names fname1 and fname2 into allocated memory. @@ -9835,11 +9846,8 @@ unix_expandpath(gap, path, wildoff, flag } else if (path_end >= path + wildoff && (vim_strchr((char_u *)"*?[{~$", *path_end) != NULL -#ifndef CASE_INSENSITIVE_FILENAME - || ((flags & EW_ICASE) - && isalpha(PTR2CHAR(path_end))) -#endif - )) + || (!p_fic && (flags & EW_ICASE) + && isalpha(PTR2CHAR(path_end))))) e = p; #ifdef FEAT_MBYTE if (has_mbyte) @@ -9882,14 +9890,10 @@ unix_expandpath(gap, path, wildoff, flag } /* compile the regexp into a program */ -#ifdef CASE_INSENSITIVE_FILENAME - regmatch.rm_ic = TRUE; /* Behave like Terminal.app */ -#else if (flags & EW_ICASE) regmatch.rm_ic = TRUE; /* 'wildignorecase' set */ else - regmatch.rm_ic = FALSE; /* Don't ignore case */ -#endif + regmatch.rm_ic = p_fic; /* ignore case when 'fileignorecase' is set */ if (flags & (EW_NOERROR | EW_NOTWILD)) ++emsg_silent; regmatch.regprog = vim_regcomp(pat, RE_MAGIC); diff --git a/src/misc2.c b/src/misc2.c --- a/src/misc2.c +++ b/src/misc2.c @@ -5362,13 +5362,11 @@ ff_wc_equal(s1, s2) if (STRLEN(s1) != STRLEN(s2)) return FAIL; + /* TODO: handle multi-byte characters. */ for (i = 0; s1[i] != NUL && s2[i] != NUL; i++) { if (s1[i] != s2[i] -#ifdef CASE_INSENSITIVE_FILENAME - && TOUPPER_LOC(s1[i]) != TOUPPER_LOC(s2[i]) -#endif - ) + && (!p_fic || TOUPPER_LOC(s1[i]) != TOUPPER_LOC(s2[i]))) { if (i >= 2) if (s1[i-1] == '*' && s1[i-2] == '*') @@ -6123,12 +6121,7 @@ pathcmp(p, q, maxlen) break; } - if ( -#ifdef CASE_INSENSITIVE_FILENAME - TOUPPER_LOC(p[i]) != TOUPPER_LOC(q[i]) -#else - p[i] != q[i] -#endif + if ((p_fic ? TOUPPER_LOC(p[i]) != TOUPPER_LOC(q[i]) : p[i] != q[i]) #ifdef BACKSLASH_IN_FILENAME /* consider '/' and '\\' to be equal */ && !((p[i] == '/' && q[i] == '\\') diff --git a/src/option.c b/src/option.c --- a/src/option.c +++ b/src/option.c @@ -1108,6 +1108,15 @@ static struct vimoption (char_u *)&p_ffs, PV_NONE, {(char_u *)DFLT_FFS_VI, (char_u *)DFLT_FFS_VIM} 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, #ifdef FEAT_AUTOCMD (char_u *)&p_ft, PV_FT, diff --git a/src/option.h b/src/option.h --- a/src/option.h +++ b/src/option.h @@ -453,6 +453,7 @@ EXTERN int p_exrc; /* 'exrc' */ EXTERN char_u *p_fencs; /* 'fileencodings' */ #endif EXTERN char_u *p_ffs; /* 'fileformats' */ +EXTERN long p_fic; /* 'fileignorecase' */ #ifdef FEAT_FOLDING EXTERN char_u *p_fcl; /* 'foldclose' */ EXTERN long p_fdls; /* 'foldlevelstart' */ diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 872, +/**/ 871, /**/ 870, diff --git a/src/vim.h b/src/vim.h --- a/src/vim.h +++ b/src/vim.h @@ -1627,18 +1627,8 @@ void mch_memmove __ARGS((void *, void *, * (this does not account for maximum name lengths and things like "../dir", * thus it is not 100% accurate!) */ -#ifdef CASE_INSENSITIVE_FILENAME -# ifdef BACKSLASH_IN_FILENAME -# 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 +#define fnamecmp(x, y) vim_fnamecmp((char_u *)(x), (char_u *)(y)) +#define fnamencmp(x, y, n) vim_fnamencmp((char_u *)(x), (char_u *)(y), (size_t)(n)) #ifdef HAVE_MEMSET # define vim_memset(ptr, c, size) memset((ptr), (c), (size))