1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* dir.c, win32/win32.c, win32/dir.h, ruby.h, intern.h: Bring

encoding aware globbing support in from trunk.  Dir.[] and
  Dir.glob() can now take many patterns in an array.  Minor fixes
  will follow.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@11748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2007-02-15 02:52:43 +00:00
parent db38fea37f
commit af44ff5ea8
6 changed files with 886 additions and 513 deletions

View file

@ -1,3 +1,10 @@
Thu Feb 15 11:46:05 2007 KIMURA Koichi <hogemuta@gmail.com>
* dir.c, win32/win32.c, win32/dir.h, ruby.h, intern.h: Bring
encoding aware globbing support in from trunk. Dir.[] and
Dir.glob() can now take many patterns in an array. Minor fixes
will follow.
Thu Feb 15 11:00:26 2007 Akinori MUSHA <knu@iDaemons.org>
* lib/uri/generic.rb (URI::Generic::userinfo): should support

1365
dir.c

File diff suppressed because it is too large Load diff

View file

@ -231,6 +231,7 @@ char *rb_path_next _((const char *));
char *rb_path_skip_prefix _((const char *));
char *rb_path_last_separator _((const char *));
char *rb_path_end _((const char *));
VALUE rb_file_directory_p _((VALUE,VALUE));
/* gc.c */
NORETURN(void rb_memerror __((void)));
int ruby_stack_check _((void));

3
ruby.h
View file

@ -488,8 +488,11 @@ struct RBignum {
void rb_obj_infect _((VALUE,VALUE));
typedef int ruby_glob_func(const char*,VALUE);
void rb_glob _((const char*,void(*)(const char*,VALUE),VALUE));
void rb_globi _((const char*,void(*)(const char*,VALUE),VALUE));
int ruby_brace_expand _((const char*,int,ruby_glob_func*,VALUE));
int ruby_brace_glob _((const char*,int,ruby_glob_func*,VALUE));
VALUE rb_define_class _((const char*,VALUE));
VALUE rb_define_module _((const char*));

View file

@ -10,13 +10,17 @@ struct direct
long d_namlen;
ino_t d_ino;
char d_name[256];
char d_isdir; /* directory */
char d_isrep; /* reparse point */
};
typedef struct {
char *start;
char *curr;
long size;
long nfiles;
long loc; /* [0, nfiles) */
struct direct dirstr;
char *bits; /* used for d_isdir and d_isrep */
} DIR;

View file

@ -1106,7 +1106,7 @@ cmdglob(NtCmdLineElement *patt, NtCmdLineElement **tail)
for (p = buf; *p; p = CharNext(p))
if (*p == '\\')
*p = '/';
status = ruby_globi(buf, 0, insert, (VALUE)&tail);
status = ruby_glob(buf, 0, insert, (VALUE)&tail);
if (buf != buffer)
free(buf);
@ -1420,6 +1420,9 @@ rb_w32_cmdvector(const char *cmd, char ***vec)
// return the pointer to the current file name.
//
#define GetBit(bits, i) ((bits)[(i) / 8] & (1 << (i) % 8))
#define SetBit(bits, i) ((bits)[(i) / 8] |= (1 << (i) % 8))
DIR *
rb_w32_opendir(const char *filename)
{
@ -1481,7 +1484,7 @@ rb_w32_opendir(const char *filename)
//
idx = strlen(fd.cFileName)+1;
if (!(p->start = (char *)malloc(idx))) {
if (!(p->start = (char *)malloc(idx)) || !(p->bits = (char *)malloc(1))) {
error:
rb_w32_closedir(p);
FindClose(fh);
@ -1489,6 +1492,11 @@ rb_w32_opendir(const char *filename)
return NULL;
}
strcpy(p->start, fd.cFileName);
p->bits[0] = 0;
if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
SetBit(p->bits, 0);
if (fd.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
SetBit(p->bits, 1);
p->nfiles++;
//
@ -1561,6 +1569,12 @@ rb_w32_readdir(DIR *dirp)
//
dirp->dirstr.d_ino = dummy++;
//
// Attributes
//
dirp->dirstr.d_isdir = GetBit(dirp->bits, dirp->loc * 2);
dirp->dirstr.d_isrep = GetBit(dirp->bits, dirp->loc * 2 + 1);
//
// Now set up for the next call to readdir
//
@ -1623,6 +1637,7 @@ void
rb_w32_closedir(DIR *dirp)
{
free(dirp->start);
free(dirp->bits);
free(dirp);
}