summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2013-03-19 16:49:16 +0100
committerBram Moolenaar <bram@vim.org>2013-03-19 16:49:16 +0100
commitc05ef4798c36be54af365aba734701c6674179f8 (patch)
tree21066282b3e55e0933565b52b6d3dd7bbd626fad
parentd7a277266add76d95b54410359decf7e25ef3d1f (diff)
downloadvim-c05ef4798c36be54af365aba734701c6674179f8.tar.gz
updated for version 7.3.872v7.3.872v7-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'.
-rw-r--r--runtime/doc/options.txt12
-rw-r--r--runtime/plugin/matchparen.vim2
-rw-r--r--src/buffer.c7
-rw-r--r--src/edit.c8
-rw-r--r--src/ex_cmds2.c6
-rw-r--r--src/ex_getln.c9
-rw-r--r--src/fileio.c14
-rw-r--r--src/misc1.c34
-rw-r--r--src/misc2.c13
-rw-r--r--src/option.c9
-rw-r--r--src/option.h1
-rw-r--r--src/version.c2
-rw-r--r--src/vim.h14
13 files changed, 55 insertions, 76 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index ac3d394a..fbfad697 100644
--- 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 short description can be found at |Q_op|.
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 short description can be found at |Q_op|.
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
index 32f0a834..c9cf903d 100644
--- a/runtime/plugin/matchparen.vim
+++ b/runtime/plugin/matchparen.vim
@@ -1,6 +1,6 @@
" Vim plugin for showing matching parens
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" 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
index 5c63899c..2a9fe4d1 100644
--- 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(&regmatch, name, (colnr_T)0))
match = name;
else
diff --git a/src/edit.c b/src/edit.c
index 5d609519..65038e43 100644
--- 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
index de190e78..11446efd 100644
--- 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
index 57582e84..d8a4a67f 100644
--- 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
index b5a49b87..6e89b888 100644
--- 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, sfname, tail, allow_dirs)
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
index c1cc89cb..1cad0f53 100644
--- 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);
-}
+#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, flags, didstar)
}
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, flags, didstar)
}
/* 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
index 72a03436..f075639b 100644
--- 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
index 467d578a..39b48dea 100644
--- 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
index 3474d8e7..8b982f58 100644
--- 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
index 1a652acd..072005f9 100644
--- 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
index fa2e075b..db2650ec 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -1627,18 +1627,8 @@ void mch_memmove __ARGS((void *, void *, size_t));
* (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))