summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-03 23:26:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-03 23:26:02 +0000
commit252168ed1b78534af4d4cec3a1f0ba8f3348f9f3 (patch)
tree8ae5b39198bcc2aab67fe2cfea071fd95c7ecbff /dir.c
parent22ec8c664a04bbb851731ff8144b9f7d11d9b8da (diff)
downloadruby-252168ed1b78534af4d4cec3a1f0ba8f3348f9f3.tar.gz
* dir.c (dir_check): moved other checks from GetDIR.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25639 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/dir.c b/dir.c
index 228d4b2453..e49e9bdc75 100644
--- a/dir.c
+++ b/dir.c
@@ -447,19 +447,19 @@ dir_closed(void)
rb_raise(rb_eIOError, "closed directory");
}
-static void
+static struct dir_data *
dir_check(VALUE dir)
{
+ struct dir_data *dirp;
if (!OBJ_UNTRUSTED(dir) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: operation on trusted Dir");
rb_check_frozen(dir);
+ dirp = rb_check_typeddata(dir, &dir_data_type);
+ if (!dirp->dir) dir_closed();
+ return dirp;
}
-#define GetDIR(obj, dirp) do {\
- dir_check(obj); \
- TypedData_Get_Struct(obj, struct dir_data, &dir_data_type, dirp); \
- if (dirp->dir == NULL) dir_closed();\
-} while (0)
+#define GetDIR(obj, dirp) (dirp = dir_check(obj))
/*