diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-23 14:18:30 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-03-23 14:18:30 +0000 |
commit | 78a73a538d6779eddbaac947c3d50361b2082a3b (patch) | |
tree | 946fe8d31084d30f6dcd24e9e056afe7f63b380f /dir.c | |
parent | 2ffb87995a33cdc7ba609a4b867f03f18da0c3b3 (diff) | |
download | ruby-78a73a538d6779eddbaac947c3d50361b2082a3b.tar.gz |
dir.c: don't raise after close
* dir.c (dir_close): don't raise on dobule close for consistent to
IO#close.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -543,11 +543,16 @@ dir_closed(void) } static struct dir_data * -dir_check(VALUE dir) +dir_get(VALUE dir) { - struct dir_data *dirp; rb_check_frozen(dir); - dirp = rb_check_typeddata(dir, &dir_data_type); + return rb_check_typeddata(dir, &dir_data_type); +} + +static struct dir_data * +dir_check(VALUE dir) +{ + struct dir_data *dirp = dir_get(dir); if (!dirp->dir) dir_closed(); return dirp; } @@ -831,7 +836,8 @@ dir_close(VALUE dir) { struct dir_data *dirp; - GetDIR(dir, dirp); + dirp = dir_get(dir); + if (!dirp->dir) return Qnil; closedir(dirp->dir); dirp->dir = NULL; |