diff --git a/ChangeLog b/ChangeLog index c74de4dacb..05e115af8b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Fri Aug 22 11:30:38 2008 NARUSE, Yui + + * 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 * common.mk: remove config.h dependency. diff --git a/dir.c b/dir.c index ea13490b21..34c4024fd8 100644 --- a/dir.c +++ b/dir.c @@ -424,10 +424,11 @@ dir_check(VALUE dir) } while (0) 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); - return str; + VALUE path = rb_tainted_str_new(p, len); + rb_enc_associate(path, enc); + return path; } /* @@ -490,7 +491,7 @@ dir_read(VALUE dir) errno = 0; dp = readdir(dirp->dir); 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 */ return Qnil; @@ -528,7 +529,7 @@ dir_each(VALUE dir) GetDIR(dir, dirp); rewinddir(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(); } return dir; @@ -1432,9 +1433,7 @@ rb_glob(const char *path, void (*func)(const char *, VALUE, void *), VALUE arg) static void push_pattern(const char *path, VALUE ary, void *enc) { - VALUE vpath = rb_tainted_str_new2(path); - rb_enc_associate(vpath, enc); - rb_ary_push(ary, vpath); + rb_ary_push(ary, dir_enc_str_new(path, strlen(path), enc)); } static int