* 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
This commit is contained in:
nobu 2005-12-14 14:40:14 +00:00
Родитель 6e23e595cd
Коммит 8e4090f4b5
2 изменённых файлов: 32 добавлений и 7 удалений

Просмотреть файл

@ -1,3 +1,11 @@
Wed Dec 14 23:39:53 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* 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]
Wed Dec 14 12:01:26 2005 Tanaka Akira <akr@m17n.org>
* marshal.c (r_object0): fix a GC problem for reading a bignum on
@ -47,10 +55,10 @@ Sun Dec 11 22:07:58 2005 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
objects are protected against GC. [ruby-dev:27911]
Sat Dec 10 01:06:06 2005 Keiju Ishitsuka <keiju@ruby-lang.org>
* lib/matrix.rb: add Matrix#determinant_e, Matrix#rank_e.
[ruby-dev:27820] and related thread.
Sat Dec 10 00:31:42 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (calling_scope_t): gave names to magic numbers for rb_call().

27
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));
}