summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-25 14:22:41 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-03-25 14:22:41 +0000
commite70499732a043ddb673c9775699a7a2c8230c440 (patch)
treed6cdbf9f9af5ae5c1ace76e1f485e2c4dae2fbd4 /file.c
parent9c15f6f822f5d86f2d2cdb8a7d73912b44be7c93 (diff)
* file.c (rb_get_path_check): prefer #to_path over #to_str. a patch
originally written by me, and modified by Nobuyoshi Nakada. [ruby-core:24257] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/file.c b/file.c
index 5a0b16eabe..557085e1aa 100644
--- a/file.c
+++ b/file.c
@@ -129,18 +129,14 @@ rb_get_path_check(VALUE obj, int level)
if (insecure_obj_p(obj, level)) {
rb_insecure_operation();
}
- tmp = rb_check_string_type(obj);
- if (!NIL_P(tmp)) goto exit;
CONST_ID(to_path, "to_path");
- if (rb_respond_to(obj, to_path)) {
- tmp = rb_funcall(obj, to_path, 0, 0);
- }
- else {
+ tmp = rb_check_funcall(obj, to_path, 0, 0);
+ if (tmp == Qundef) {
tmp = obj;
}
StringValue(tmp);
- exit:
+
tmp = file_path_convert(tmp);
StringValueCStr(tmp);
if (obj != tmp && insecure_obj_p(tmp, level)) {