diff options
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 16 |
1 files changed, 3 insertions, 13 deletions
@@ -423,16 +423,6 @@ dir_check(VALUE dir) if (dirp->dir == NULL) dir_closed();\ } while (0) -static VALUE -dir_enc_str_new(const char *p, long len, rb_encoding *enc) -{ - VALUE path = rb_tainted_str_new(p, len); - if (rb_enc_asciicompat(enc) && rb_enc_str_asciionly_p(path)) { - enc = rb_usascii_encoding(); - } - rb_enc_associate(path, enc); - return path; -} /* * call-seq: @@ -494,7 +484,7 @@ dir_read(VALUE dir) errno = 0; dp = readdir(dirp->dir); if (dp) { - return dir_enc_str_new(dp->d_name, NAMLEN(dp), dirp->enc); + return rb_external_str_new_with_enc(dp->d_name, NAMLEN(dp), dirp->enc); } else if (errno == 0) { /* end of stream */ return Qnil; @@ -532,7 +522,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_new(dp->d_name, NAMLEN(dp), dirp->enc)); + rb_yield(rb_external_str_new_with_enc(dp->d_name, NAMLEN(dp), dirp->enc)); if (dirp->dir == NULL) dir_closed(); } return dir; @@ -1436,7 +1426,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) { - rb_ary_push(ary, dir_enc_str_new(path, strlen(path), enc)); + rb_ary_push(ary, rb_external_str_new_with_enc(path, strlen(path), enc)); } static int |