mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* object.c (rb_class_allocate_instance): singleton class check
moved to rb_obj_alloc(). (ruby-bugs-ja PR#345) * re.c (rb_reg_quote): should escape white space characters, \t, \f, \n, \r. (ruby-bugs-ja PR#231) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ae8463b03c
commit
25fd1d7ff2
4 changed files with 47 additions and 10 deletions
10
ChangeLog
10
ChangeLog
|
@ -9,6 +9,16 @@ Sat May 17 00:18:11 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
returns EINVAL on some platforms, need to check true error
|
returns EINVAL on some platforms, need to check true error
|
||||||
status. [ruby-core:01037]
|
status. [ruby-core:01037]
|
||||||
|
|
||||||
|
Sat May 17 00:21:51 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* object.c (rb_class_allocate_instance): singleton class check
|
||||||
|
moved to rb_obj_alloc(). (ruby-bugs-ja PR#345)
|
||||||
|
|
||||||
|
Fri May 16 23:55:50 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* re.c (rb_reg_quote): should escape white space characters,
|
||||||
|
\t, \f, \n, \r. (ruby-bugs-ja PR#231)
|
||||||
|
|
||||||
Fri May 16 12:40:40 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Fri May 16 12:40:40 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* eval.c (block_pass): chain previous block to the pushing block.
|
* eval.c (block_pass): chain previous block to the pushing block.
|
||||||
|
|
17
object.c
17
object.c
|
@ -730,8 +730,12 @@ VALUE
|
||||||
rb_obj_alloc(klass)
|
rb_obj_alloc(klass)
|
||||||
VALUE klass;
|
VALUE klass;
|
||||||
{
|
{
|
||||||
VALUE obj = rb_funcall(klass, ID_ALLOCATOR, 0, 0);
|
VALUE obj;
|
||||||
|
|
||||||
|
if (FL_TEST(klass, FL_SINGLETON)) {
|
||||||
|
rb_raise(rb_eTypeError, "can't create instance of virtual class");
|
||||||
|
}
|
||||||
|
obj = rb_funcall(klass, ID_ALLOCATOR, 0, 0);
|
||||||
if (rb_obj_class(obj) != rb_class_real(klass)) {
|
if (rb_obj_class(obj) != rb_class_real(klass)) {
|
||||||
rb_raise(rb_eTypeError, "wrong instance allocation");
|
rb_raise(rb_eTypeError, "wrong instance allocation");
|
||||||
}
|
}
|
||||||
|
@ -743,14 +747,9 @@ static VALUE
|
||||||
rb_class_allocate_instance(klass)
|
rb_class_allocate_instance(klass)
|
||||||
VALUE klass;
|
VALUE klass;
|
||||||
{
|
{
|
||||||
if (FL_TEST(klass, FL_SINGLETON)) {
|
NEWOBJ(obj, struct RObject);
|
||||||
rb_raise(rb_eTypeError, "can't create instance of virtual class");
|
OBJSETUP(obj, klass, T_OBJECT);
|
||||||
}
|
return (VALUE)obj;
|
||||||
else {
|
|
||||||
NEWOBJ(obj, struct RObject);
|
|
||||||
OBJSETUP(obj, klass, T_OBJECT);
|
|
||||||
return (VALUE)obj;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
|
23
re.c
23
re.c
|
@ -1349,6 +1349,7 @@ rb_reg_quote(str)
|
||||||
case '*': case '.': case '\\':
|
case '*': case '.': case '\\':
|
||||||
case '?': case '+': case '^': case '$':
|
case '?': case '+': case '^': case '$':
|
||||||
case ' ': case '#':
|
case ' ': case '#':
|
||||||
|
case '\t': case '\f': case '\n': case '\r':
|
||||||
goto meta_found;
|
goto meta_found;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1376,9 +1377,29 @@ rb_reg_quote(str)
|
||||||
case '(': case ')': case '|': case '-':
|
case '(': case ')': case '|': case '-':
|
||||||
case '*': case '.': case '\\':
|
case '*': case '.': case '\\':
|
||||||
case '?': case '+': case '^': case '$':
|
case '?': case '+': case '^': case '$':
|
||||||
case ' ': case '#':
|
case '#':
|
||||||
*t++ = '\\';
|
*t++ = '\\';
|
||||||
break;
|
break;
|
||||||
|
case ' ':
|
||||||
|
*t++ = '\\';
|
||||||
|
*t++ = 's';
|
||||||
|
break;
|
||||||
|
case '\t':
|
||||||
|
*t++ = '\\';
|
||||||
|
*t++ = 't';
|
||||||
|
break;
|
||||||
|
case '\n':
|
||||||
|
*t++ = '\\';
|
||||||
|
*t++ = 'n';
|
||||||
|
break;
|
||||||
|
case '\r':
|
||||||
|
*t++ = '\\';
|
||||||
|
*t++ = 'r';
|
||||||
|
break;
|
||||||
|
case '\f':
|
||||||
|
*t++ = '\\';
|
||||||
|
*t++ = 'f';
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
*t++ = c;
|
*t++ = c;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1194,6 +1194,13 @@ test_ok(-1045307475.to_s(36) == "-hacker")
|
||||||
test_ok("Just_another_Ruby_hacker".to_i(36) == 265419172580680477752431643787347)
|
test_ok("Just_another_Ruby_hacker".to_i(36) == 265419172580680477752431643787347)
|
||||||
test_ok(-265419172580680477752431643787347.to_s(36) == "-justanotherrubyhacker")
|
test_ok(-265419172580680477752431643787347.to_s(36) == "-justanotherrubyhacker")
|
||||||
|
|
||||||
|
a = []
|
||||||
|
(0..255).each {|n|
|
||||||
|
ch = [n].pack("C")
|
||||||
|
a.push ch if /a#{Regexp.quote ch}b/x =~ "ab"
|
||||||
|
}
|
||||||
|
test_ok(a.size == 0)
|
||||||
|
|
||||||
test_check "assignment"
|
test_check "assignment"
|
||||||
a = nil
|
a = nil
|
||||||
test_ok(defined?(a))
|
test_ok(defined?(a))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue