summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
11 files changed, 44 insertions, 73 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 5c63899c8..2a9fe4d12 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 5d609519a..65038e437 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 de190e78c..11446efd4 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 57582e84d..d8a4a67f4 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 b5a49b874..6e89b888c 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 c1cc89cb6..1cad0f53b 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 72a034362..f075639b0 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 467d578a6..39b48dea8 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 3474d8e7b..8b982f580 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 1a652acdf..072005f97 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 fa2e075b3..db2650ecd 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))