summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-14 14:40:14 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-14 14:40:14 +0000
commit8e4090f4b5ad8363120df6853b47e1231666a26c (patch)
tree307adfa34d90a054ca653450c4fc221171b21285 /dir.c
parent6e23e595cd9f71781f8c0be4a0da5211eb5e2529 (diff)
* dir.c (has_magic): glob names contain alphabets to enable case fold
search. [ruby-dev:27735] * dir.c (Init_Dir): FNM_SYSCASE which is default case fold flag. [ruby-dev:23296] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/dir.c b/dir.c
index 4ae4f5dafa..f6779a84c2 100644
--- a/dir.c
+++ b/dir.c
@@ -67,10 +67,23 @@ char *strchr(char*,char);
#define lstat stat
#endif
+#ifndef CASEFOLD_FILESYSTEM
+# if defined DOSISH || defined __VMS
+# define CASEFOLD_FILESYSTEM 1
+# else
+# define CASEFOLD_FILESYSTEM 0
+# endif
+#endif
+
#define FNM_NOESCAPE 0x01
#define FNM_PATHNAME 0x02
#define FNM_DOTMATCH 0x04
#define FNM_CASEFOLD 0x08
+#if CASEFOLD_FILESYSTEM
+#define FNM_SYSCASE FNM_CASEFOLD
+#else
+#define FNM_SYSCASE 0
+#endif
#define FNM_NOMATCH 1
#define FNM_ERROR 2
@@ -931,6 +944,7 @@ static int
has_magic(const char *s, int flags)
{
const int escape = !(flags & FNM_NOESCAPE);
+ const int nocase = flags & FNM_CASEFOLD;
register const char *p = s;
register char c;
@@ -946,6 +960,10 @@ has_magic(const char *s, int flags)
if (escape && !(c = *p++))
return 0;
continue;
+
+ default:
+ if (!FNM_SYSCASE && ISALPHA(c) && nocase)
+ return 1;
}
p = Next(p-1);
@@ -1295,11 +1313,9 @@ ruby_glob0(const char *path, int flags, ruby_glob_func *func, VALUE arg)
int status;
start = root = path;
+ flags |= FNM_SYSCASE;
#if defined DOSISH
- flags |= FNM_CASEFOLD;
root = rb_path_skip_prefix(root);
-#else
- flags &= ~FNM_CASEFOLD;
#endif
if (root && *root == '/') root++;
@@ -1342,8 +1358,8 @@ rb_glob2(const char *path, int flags, void (*func)(const char *, VALUE), VALUE a
args.func = func;
args.value = arg;
- if (flags & FNM_CASEFOLD) {
- rb_warn("Dir.glob() ignores File::FNM_CASEFOLD");
+ if (flags & FNM_SYSCASE) {
+ rb_warning("Dir.glob() ignores File::FNM_CASEFOLD");
}
return ruby_glob0(path, flags | GLOB_VERBOSE, rb_glob_caller, (VALUE)&args);
@@ -1822,4 +1838,5 @@ Init_Dir(void)
rb_file_const("FNM_PATHNAME", INT2FIX(FNM_PATHNAME));
rb_file_const("FNM_DOTMATCH", INT2FIX(FNM_DOTMATCH));
rb_file_const("FNM_CASEFOLD", INT2FIX(FNM_CASEFOLD));
+ rb_file_const("FNM_SYSCASE", INT2FIX(FNM_SYSCASE));
}