mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* dir.c (dir_enc_str_new): renamed from dir_enc_str.
* dir.c (dir_read): use dir_enc_str_new. * dir.c (dir_each): ditto. * dir.c (push_pattern): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18769 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d914071bba
commit
cc17cad920
2 changed files with 17 additions and 8 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Fri Aug 22 11:30:38 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* dir.c (dir_enc_str_new): renamed from dir_enc_str.
|
||||||
|
|
||||||
|
* dir.c (dir_read): use dir_enc_str_new.
|
||||||
|
|
||||||
|
* dir.c (dir_each): ditto.
|
||||||
|
|
||||||
|
* dir.c (push_pattern): ditto.
|
||||||
|
|
||||||
Fri Aug 22 11:29:10 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
Fri Aug 22 11:29:10 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* common.mk: remove config.h dependency.
|
* common.mk: remove config.h dependency.
|
||||||
|
|
15
dir.c
15
dir.c
|
@ -424,10 +424,11 @@ dir_check(VALUE dir)
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
dir_enc_str(VALUE str, struct dir_data *dirp)
|
dir_enc_str_new(const char *p, long len, rb_encoding *enc)
|
||||||
{
|
{
|
||||||
rb_enc_associate(str, dirp->extenc);
|
VALUE path = rb_tainted_str_new(p, len);
|
||||||
return str;
|
rb_enc_associate(path, enc);
|
||||||
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -490,7 +491,7 @@ dir_read(VALUE dir)
|
||||||
errno = 0;
|
errno = 0;
|
||||||
dp = readdir(dirp->dir);
|
dp = readdir(dirp->dir);
|
||||||
if (dp) {
|
if (dp) {
|
||||||
return dir_enc_str(rb_tainted_str_new(dp->d_name, NAMLEN(dp)), dirp);
|
return dir_enc_str_new(dp->d_name, NAMLEN(dp), dirp->extenc);
|
||||||
}
|
}
|
||||||
else if (errno == 0) { /* end of stream */
|
else if (errno == 0) { /* end of stream */
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
@ -528,7 +529,7 @@ dir_each(VALUE dir)
|
||||||
GetDIR(dir, dirp);
|
GetDIR(dir, dirp);
|
||||||
rewinddir(dirp->dir);
|
rewinddir(dirp->dir);
|
||||||
for (dp = readdir(dirp->dir); dp != NULL; dp = readdir(dirp->dir)) {
|
for (dp = readdir(dirp->dir); dp != NULL; dp = readdir(dirp->dir)) {
|
||||||
rb_yield(dir_enc_str(rb_tainted_str_new(dp->d_name, NAMLEN(dp)), dirp));
|
rb_yield(dir_enc_str_new(dp->d_name, NAMLEN(dp), dirp->extenc));
|
||||||
if (dirp->dir == NULL) dir_closed();
|
if (dirp->dir == NULL) dir_closed();
|
||||||
}
|
}
|
||||||
return dir;
|
return dir;
|
||||||
|
@ -1432,9 +1433,7 @@ rb_glob(const char *path, void (*func)(const char *, VALUE, void *), VALUE arg)
|
||||||
static void
|
static void
|
||||||
push_pattern(const char *path, VALUE ary, void *enc)
|
push_pattern(const char *path, VALUE ary, void *enc)
|
||||||
{
|
{
|
||||||
VALUE vpath = rb_tainted_str_new2(path);
|
rb_ary_push(ary, dir_enc_str_new(path, strlen(path), enc));
|
||||||
rb_enc_associate(vpath, enc);
|
|
||||||
rb_ary_push(ary, vpath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Reference in a new issue