* ext/pathname/pathname.c (get_strpath): check the type.
(path_initialize): bypass to_path call for T_STRING. (path_freeze): implemented. * ext/pathname/lib/pathname.rb (Pathname#freeze): removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28683 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
79dfc605ff
commit
a0d5258df0
@ -1,3 +1,11 @@
|
|||||||
|
Mon Jul 19 18:34:12 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* ext/pathname/pathname.c (get_strpath): check the type.
|
||||||
|
(path_initialize): bypass to_path call for T_STRING.
|
||||||
|
(path_freeze): implemented.
|
||||||
|
|
||||||
|
* ext/pathname/lib/pathname.rb (Pathname#freeze): removed.
|
||||||
|
|
||||||
Mon Jul 19 12:33:29 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Mon Jul 19 12:33:29 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* array.c (rb_ary_clear): should not unshare embedded array, and
|
* array.c (rb_ary_clear): should not unshare embedded array, and
|
||||||
|
@ -208,7 +208,6 @@ class Pathname
|
|||||||
|
|
||||||
# :startdoc:
|
# :startdoc:
|
||||||
|
|
||||||
def freeze() super; @path.freeze; self end
|
|
||||||
def taint() super; @path.taint; self end
|
def taint() super; @path.taint; self end
|
||||||
def untaint() super; @path.untaint; self end
|
def untaint() super; @path.untaint; self end
|
||||||
|
|
||||||
|
@ -6,7 +6,11 @@ static ID id_at_path, id_to_path;
|
|||||||
static VALUE
|
static VALUE
|
||||||
get_strpath(VALUE obj)
|
get_strpath(VALUE obj)
|
||||||
{
|
{
|
||||||
return rb_ivar_get(obj, id_at_path);
|
VALUE strpath;
|
||||||
|
strpath = rb_ivar_get(obj, id_at_path);
|
||||||
|
if (TYPE(strpath) != T_STRING)
|
||||||
|
rb_raise(rb_eTypeError, "unexpected @path");
|
||||||
|
return strpath;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -23,10 +27,15 @@ static VALUE
|
|||||||
path_initialize(VALUE self, VALUE arg)
|
path_initialize(VALUE self, VALUE arg)
|
||||||
{
|
{
|
||||||
VALUE str;
|
VALUE str;
|
||||||
str = rb_check_funcall(arg, id_to_path, 0, NULL);
|
if (TYPE(arg) == T_STRING) {
|
||||||
if (str == Qundef)
|
|
||||||
str = arg;
|
str = arg;
|
||||||
StringValue(str);
|
}
|
||||||
|
else {
|
||||||
|
str = rb_check_funcall(arg, id_to_path, 0, NULL);
|
||||||
|
if (str == Qundef)
|
||||||
|
str = arg;
|
||||||
|
StringValue(str);
|
||||||
|
}
|
||||||
if (memchr(RSTRING_PTR(str), '\0', RSTRING_LEN(str)))
|
if (memchr(RSTRING_PTR(str), '\0', RSTRING_LEN(str)))
|
||||||
rb_raise(rb_eArgError, "pathname contains null byte");
|
rb_raise(rb_eArgError, "pathname contains null byte");
|
||||||
str = rb_obj_dup(str);
|
str = rb_obj_dup(str);
|
||||||
@ -36,6 +45,14 @@ path_initialize(VALUE self, VALUE arg)
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
path_freeze(VALUE self)
|
||||||
|
{
|
||||||
|
rb_call_super(0, 0);
|
||||||
|
rb_str_freeze(get_strpath(self));
|
||||||
|
return self;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Init_pathname()
|
Init_pathname()
|
||||||
{
|
{
|
||||||
@ -44,4 +61,5 @@ Init_pathname()
|
|||||||
|
|
||||||
rb_cPathname = rb_define_class("Pathname", rb_cObject);
|
rb_cPathname = rb_define_class("Pathname", rb_cObject);
|
||||||
rb_define_method(rb_cPathname, "initialize", path_initialize, 1);
|
rb_define_method(rb_cPathname, "initialize", path_initialize, 1);
|
||||||
|
rb_define_method(rb_cPathname, "freeze", path_freeze, 0);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user