From 6e2de675650869645ac191b80876a24f78a90fbb Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 14 Jul 2006 16:27:51 +0000 Subject: * dir.c (has_magic): glob names contain alphabets to enable case fold search also for directories. fixed: [ruby-talk:201917] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@10534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 11 ++++++++--- dir.c | 26 ++++++++++++++++++++++++-- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index b3ae8bfa14..77d14775f0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sat Jul 15 01:27:13 2006 Nobuyoshi Nakada + + * dir.c (has_magic): glob names contain alphabets to enable case fold + search also for directories. fixed: [ruby-talk:201917] + Fri Jul 14 13:08:13 2006 Hidetoshi NAGAI * ext/tk/lib/tk.rb: add methods for new features of latest Tcl/Tk8.5. @@ -21,7 +26,7 @@ Fri Jul 14 00:10:15 2006 Yukihiro Matsumoto Thu Jul 13 22:23:56 2006 Hidetoshi NAGAI - * ext/tk/lib/tk/composite.rb: improve handling of the classname on the + * ext/tk/lib/tk/composite.rb: improve handling of the classname on the option database for the widget class which includes TkComposite. Thu Jul 13 20:32:19 2006 Kouhei Sutou @@ -40,7 +45,7 @@ Tue Jul 11 20:58:18 2006 Yukihiro Matsumoto Tue Jul 11 19:13:33 2006 Hidetoshi NAGAI - * ext/tk/lib/multi-tk.rb: remove restriction on the class of + * ext/tk/lib/multi-tk.rb: remove restriction on the class of pseudo-toplevel. Tue Jul 11 18:00:57 2006 Hidetoshi NAGAI @@ -98,7 +103,7 @@ Mon Jul 10 13:58:40 2006 Hidetoshi NAGAI * signal.c (ruby_nativethread_signal, posix_nativethread_signal, sigsend_to_ruby_thread, install_nativethread_sighandler): - nativethread-support on signal handler. RE-backport from 1.9. + nativethread-support on signal handler. RE-backport from 1.9. * ruby.h (HAVE_NATIVETHREAD_KILL): ditto. diff --git a/dir.c b/dir.c index 266c4ece0d..fd677c898d 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 @@ -806,7 +819,7 @@ sys_warning_1(mesg) rb_sys_warning("%s", mesg); } -#define GLOB_VERBOSE (1 << (sizeof(int) * CHAR_BIT - 1)) +#define GLOB_VERBOSE (1U << (sizeof(int) * CHAR_BIT - 1)) #define sys_warning(val) \ ((flags & GLOB_VERBOSE) && rb_protect((VALUE (*)_((VALUE)))sys_warning_1, (VALUE)(val), 0)) @@ -819,7 +832,8 @@ has_magic(s, send, flags) register const char *p = s; register char c; int open = 0; - int escape = !(flags & FNM_NOESCAPE); + const int escape = !(flags & FNM_NOESCAPE); + const int nocase = flags & FNM_CASEFOLD; while ((c = *p++) != '\0') { switch (c) { @@ -838,6 +852,11 @@ has_magic(s, send, flags) case '\\': if (escape && *p++ == '\0') return Qfalse; + break; + + default: + if (!FNM_SYSCASE && ISALPHA(c) && nocase) + return Qtrue; } if (send && p >= send) break; @@ -1103,6 +1122,7 @@ ruby_glob(path, flags, func, arg) int (*func) _((const char *, VALUE)); VALUE arg; { + flags |= FNM_SYSCASE; return glob_helper(path, 0, flags & ~GLOB_VERBOSE, func, arg); } @@ -1143,6 +1163,7 @@ rb_glob2(path, flags, func, arg) args.func = func; args.v = arg; + flags |= FNM_SYSCASE; return glob_helper(path, 0, flags | GLOB_VERBOSE, rb_glob_caller, (VALUE)&args); } @@ -1582,4 +1603,5 @@ Init_Dir() 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)); } -- cgit v1.2.3