* io.c (appendline): forget to terminate with nul.

* eval.c (ruby_run): should set toplevel visibility again here.

* eval.c (rb_eval): should not rely on ruby_class == rb_cObject
  check.   Besides allow implicit publicity for attribute set
  methods.

* parse.y (primary): need not to check class_nest, just set
  whether method is an attrset or not.

* string.c (rb_str_each_line): p might be at the top of the
  string.

* class.c (rb_make_metaclass): class of metaclass should be
  metaclass of superclass, unless class itself is a metaclass;
  class of metaclass of metaclass should point back to self.
  eh, confusing, isn't it.

* class.c (rb_singleton_class): check if its class is singleton
  AND attached to self.

* eval.c (rb_eval): should define class/module under ruby_cbase.

* eval.c (rb_eval): should set class/module path based on
  ruby_cbase, not ruby_class.

* eval.c (module_setup): use ruby_cbase instead of ruby_class.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-09-25 07:03:05 +00:00
Родитель 8a1e574cdb
Коммит 4b9a7eac05
10 изменённых файлов: 83 добавлений и 36 удалений

Просмотреть файл

@ -20,6 +20,21 @@ Mon Sep 23 19:57:52 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* lib/mkmf.rb: refactoring. * lib/mkmf.rb: refactoring.
Mon Sep 23 08:27:11 2002 Tanaka Akira <akr@m17n.org>
* io.c (appendline): forget to terminate with nul.
Mon Sep 23 02:46:29 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (ruby_run): should set toplevel visibility again here.
* eval.c (rb_eval): should not rely on ruby_class == rb_cObject
check. Besides allow implicit publicity for attribute set
methods.
* parse.y (primary): need not to check class_nest, just set
whether method is an attrset or not.
Sun Sep 22 21:49:42 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> Sun Sep 22 21:49:42 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (call_trace_func): should not call trace function while * eval.c (call_trace_func): should not call trace function while
@ -32,6 +47,21 @@ Sun Sep 22 21:49:42 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* ruby.c (require_libraries): preserve source file/line for each * ruby.c (require_libraries): preserve source file/line for each
require. require.
Sun Sep 22 17:08:11 2002 Tanaka Akira <akr@m17n.org>
* string.c (rb_str_each_line): p might be at the top of the
string.
Sat Sep 21 23:28:28 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* class.c (rb_make_metaclass): class of metaclass should be
metaclass of superclass, unless class itself is a metaclass;
class of metaclass of metaclass should point back to self.
eh, confusing, isn't it.
* class.c (rb_singleton_class): check if its class is singleton
AND attached to self.
Sat Sep 21 22:23:41 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> Sat Sep 21 22:23:41 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (rb_thread_raise): no need to save dead thread context. * eval.c (rb_thread_raise): no need to save dead thread context.
@ -46,6 +76,15 @@ Fri Sep 20 19:43:40 2002 Akinori MUSHA <knu@iDaemons.org>
* lib/set.rb: Merge rough/lib/set.rb rev.1.5-1.15. * lib/set.rb: Merge rough/lib/set.rb rev.1.5-1.15.
Wed Sep 18 12:41:16 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_eval): should define class/module under ruby_cbase.
* eval.c (rb_eval): should set class/module path based on
ruby_cbase, not ruby_class.
* eval.c (module_setup): use ruby_cbase instead of ruby_class.
Tue Sep 17 21:06:04 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> Tue Sep 17 21:06:04 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (rb_thread_die): put thread dead state. * eval.c (rb_thread_die): put thread dead state.

12
class.c
Просмотреть файл

@ -147,11 +147,12 @@ rb_make_metaclass(obj, super)
FL_SET(klass, FL_SINGLETON); FL_SET(klass, FL_SINGLETON);
RBASIC(obj)->klass = klass; RBASIC(obj)->klass = klass;
rb_singleton_class_attached(klass, obj); rb_singleton_class_attached(klass, obj);
if (BUILTIN_TYPE(obj) == T_CLASS) { if (BUILTIN_TYPE(obj) == T_CLASS && FL_TEST(obj, FL_SINGLETON)) {
RBASIC(klass)->klass = klass; RBASIC(klass)->klass = klass;
if (FL_TEST(obj, FL_SINGLETON)) { RCLASS(klass)->super = RBASIC(rb_class_real(RCLASS(obj)->super))->klass;
RCLASS(klass)->super = RBASIC(rb_class_real(RCLASS(obj)->super))->klass; }
} else {
RBASIC(klass)->klass = RBASIC(rb_class_real(super))->klass;
} }
return klass; return klass;
@ -699,8 +700,7 @@ rb_singleton_class(obj)
DEFER_INTS; DEFER_INTS;
if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON) && if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON) &&
(BUILTIN_TYPE(obj) == T_CLASS || /* metaclass (or metaclass of metaclass) */ rb_iv_get(RBASIC(obj)->klass, "__attached__") == obj) {
rb_iv_get(RBASIC(obj)->klass, "__attached__") == obj)) {
klass = RBASIC(obj)->klass; klass = RBASIC(obj)->klass;
} }
else { else {

Просмотреть файл

@ -915,6 +915,9 @@ rb_cv_missing_fconvert=yes, rb_cv_missing_fconvert=no, rb_cv_missing_fconvert=no
*djgpp*) *djgpp*)
setup=Setup.dj setup=Setup.dj
;; ;;
atheos*)
setup=Setup.atheos
;;
*) *)
setup=Setup setup=Setup
;; ;;

38
eval.c
Просмотреть файл

@ -1255,6 +1255,8 @@ ruby_run()
Init_stack((void*)&tmp); Init_stack((void*)&tmp);
PUSH_TAG(PROT_NONE); PUSH_TAG(PROT_NONE);
PUSH_ITER(ITER_NOT); PUSH_ITER(ITER_NOT);
/* default visibility is private at toplevel */
SCOPE_SET(SCOPE_PRIVATE);
if ((state = EXEC_TAG()) == 0) { if ((state = EXEC_TAG()) == 0) {
eval_node(ruby_top_self, ruby_eval_tree); eval_node(ruby_top_self, ruby_eval_tree);
} }
@ -2923,7 +2925,7 @@ rb_eval(self, n)
break; break;
case NODE_CDECL: case NODE_CDECL:
if (NIL_P(ruby_class)) { if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no class/module to define constant"); rb_raise(rb_eTypeError, "no class/module to define constant");
} }
result = rb_eval(self, node->nd_value); result = rb_eval(self, node->nd_value);
@ -3166,15 +3168,15 @@ rb_eval(self, n)
} }
} }
if (SCOPE_TEST(SCOPE_PRIVATE) || node->nd_mid == init) { if (node->nd_noex == NOEX_PUBLIC) {
noex = NOEX_PUBLIC; /* means is is an attrset */
}
else if (SCOPE_TEST(SCOPE_PRIVATE) || node->nd_mid == init) {
noex = NOEX_PRIVATE; noex = NOEX_PRIVATE;
} }
else if (SCOPE_TEST(SCOPE_PROTECTED)) { else if (SCOPE_TEST(SCOPE_PROTECTED)) {
noex = NOEX_PROTECTED; noex = NOEX_PROTECTED;
} }
else if (ruby_class == rb_cObject) {
noex = node->nd_noex;
}
else { else {
noex = NOEX_PUBLIC; noex = NOEX_PUBLIC;
} }
@ -3260,7 +3262,7 @@ rb_eval(self, n)
{ {
VALUE super, klass, tmp; VALUE super, klass, tmp;
if (NIL_P(ruby_class)) { if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no outer class/module"); rb_raise(rb_eTypeError, "no outer class/module");
} }
if (node->nd_super) { if (node->nd_super) {
@ -3270,11 +3272,11 @@ rb_eval(self, n)
super = 0; super = 0;
} }
if ((ruby_class == rb_cObject) && rb_autoload_defined(node->nd_cname)) { if ((ruby_cbase == rb_cObject) && rb_autoload_defined(node->nd_cname)) {
rb_autoload_load(node->nd_cname); rb_autoload_load(node->nd_cname);
} }
if (rb_const_defined_at(ruby_class, node->nd_cname)) { if (rb_const_defined_at(ruby_cbase, node->nd_cname)) {
klass = rb_const_get(ruby_class, node->nd_cname); klass = rb_const_get(ruby_cbase, node->nd_cname);
if (TYPE(klass) != T_CLASS) { if (TYPE(klass) != T_CLASS) {
rb_raise(rb_eTypeError, "%s is not a class", rb_raise(rb_eTypeError, "%s is not a class",
rb_id2name(node->nd_cname)); rb_id2name(node->nd_cname));
@ -3293,7 +3295,7 @@ rb_eval(self, n)
override_class: override_class:
if (!super) super = rb_cObject; if (!super) super = rb_cObject;
klass = rb_define_class_id(node->nd_cname, super); klass = rb_define_class_id(node->nd_cname, super);
rb_set_class_path(klass,ruby_class,rb_id2name(node->nd_cname)); rb_set_class_path(klass,ruby_cbase,rb_id2name(node->nd_cname));
rb_class_inherited(super, klass); rb_class_inherited(super, klass);
rb_const_set(ruby_cbase, node->nd_cname, klass); rb_const_set(ruby_cbase, node->nd_cname, klass);
} }
@ -3310,14 +3312,14 @@ rb_eval(self, n)
{ {
VALUE module; VALUE module;
if (NIL_P(ruby_class)) { if (NIL_P(ruby_cbase)) {
rb_raise(rb_eTypeError, "no outer class/module"); rb_raise(rb_eTypeError, "no outer class/module");
} }
if ((ruby_class == rb_cObject) && rb_autoload_defined(node->nd_cname)) { if ((ruby_cbase == rb_cObject) && rb_autoload_defined(node->nd_cname)) {
rb_autoload_load(node->nd_cname); rb_autoload_load(node->nd_cname);
} }
if (rb_const_defined_at(ruby_class, node->nd_cname)) { if (rb_const_defined_at(ruby_cbase, node->nd_cname)) {
module = rb_const_get(ruby_class, node->nd_cname); module = rb_const_get(ruby_cbase, node->nd_cname);
if (TYPE(module) != T_MODULE) { if (TYPE(module) != T_MODULE) {
rb_raise(rb_eTypeError, "%s is not a module", rb_raise(rb_eTypeError, "%s is not a module",
rb_id2name(node->nd_cname)); rb_id2name(node->nd_cname));
@ -3328,8 +3330,8 @@ rb_eval(self, n)
} }
else { else {
module = rb_define_module_id(node->nd_cname); module = rb_define_module_id(node->nd_cname);
rb_set_class_path(module,ruby_cbase,rb_id2name(node->nd_cname));
rb_const_set(ruby_cbase, node->nd_cname, module); rb_const_set(ruby_cbase, node->nd_cname, module);
rb_set_class_path(module,ruby_class,rb_id2name(node->nd_cname));
} }
if (ruby_wrapper) { if (ruby_wrapper) {
rb_extend_object(module, ruby_wrapper); rb_extend_object(module, ruby_wrapper);
@ -3429,11 +3431,11 @@ module_setup(module, n)
PUSH_TAG(PROT_NONE); PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) { if ((state = EXEC_TAG()) == 0) {
if (trace_func) { if (trace_func) {
call_trace_func("class", ruby_current_node, ruby_class, call_trace_func("class", ruby_current_node, ruby_cbase,
ruby_frame->last_func, ruby_frame->last_func,
ruby_frame->last_class); ruby_frame->last_class);
} }
result = rb_eval(ruby_class, node->nd_next); result = rb_eval(ruby_cbase, node->nd_next);
} }
POP_TAG(); POP_TAG();
POP_CREF(); POP_CREF();
@ -7279,7 +7281,7 @@ struct thread {
VALUE result; VALUE result;
int stk_len; int stk_len;
int stk_max; int stk_max;
VALUE*stk_ptr; VALUE*stk_ptr;
VALUE*stk_pos; VALUE*stk_pos;

Просмотреть файл

@ -693,8 +693,9 @@ ip_invoke_real(argc, argv, obj)
else else
#endif #endif
{ {
ptr->return_value = (*info.proc)(info.clientData, TRAP_BEG;
ptr->ip, argc, av); ptr->return_value = (*info.proc)(info.clientData, ptr->ip, argc, av);
TRAP_END;
} }
if (ptr->return_value == TCL_ERROR) { if (ptr->return_value == TCL_ERROR) {

1
io.c
Просмотреть файл

@ -792,6 +792,7 @@ appendline(fptr, delim, strp)
else { else {
*strp = str = rb_str_buf_new(len); *strp = str = rb_str_buf_new(len);
RSTRING(str)->len = len; RSTRING(str)->len = len;
RSTRING(str)->ptr[len] = '\0';
} }
if (c != EOF) { if (c != EOF) {
RSTRING(str)->ptr[last++] = c; RSTRING(str)->ptr[last++] = c;

Просмотреть файл

@ -46,20 +46,22 @@ module URI
# hname = *urlc # hname = *urlc
# hvalue = *urlc # hvalue = *urlc
# header = hname "=" hvalue # header = hname "=" hvalue
HEADER_REGEXP = "(?:[^?=&]*=[^?=&]*)".freeze header_pattern = "(?:[^?=&]*=[^?=&]*)"
HEADER_REGEXP = /#{header_pattern}/
# headers = "?" header *( "&" header ) # headers = "?" header *( "&" header )
# to = #mailbox # to = #mailbox
# mailtoURL = "mailto:" [ to ] [ headers ] # mailtoURL = "mailto:" [ to ] [ headers ]
MAILBOX_REGEXP = "(?:[^(),%?=&]|#{PATTERN::ESCAPED})".freeze mailbox_pattern = "(?:[^(),%?=&]|#{PATTERN::ESCAPED})"
MAILBOX_REGEXP = /#{mailbox_pattern}/
MAILTO_REGEXP = Regexp.new(" MAILTO_REGEXP = Regexp.new("
\\A \\A
(#{MAILBOX_REGEXP}*?) (?# 1: to) (#{mailbox_pattern}*?) (?# 1: to)
(?: (?:
\\? \\?
(#{HEADER_REGEXP}(?:\\&#{HEADER_REGEXP})*) (?# 2: headers) (#{header_pattern}(?:\\&#{header_pattern})*) (?# 2: headers)
)? )?
\\z \\z
", Regexp::EXTENDED, 'N').freeze ", Regexp::EXTENDED, 'N')
=begin =begin

Просмотреть файл

@ -1488,8 +1488,7 @@ primary : literal
bodystmt bodystmt
kEND kEND
{ {
/* NOEX_PRIVATE for toplevel */ $$ = NEW_DEFN($2, $4, $5, NOEX_PRIVATE);
$$ = NEW_DEFN($2, $4, $5, class_nest?NOEX_PUBLIC:NOEX_PRIVATE);
if (is_attrset_id($2)) $$->nd_noex = NOEX_PUBLIC; if (is_attrset_id($2)) $$->nd_noex = NOEX_PUBLIC;
fixpos($$, $4); fixpos($$, $4);
local_pop(); local_pop();

Просмотреть файл

@ -2631,7 +2631,7 @@ rb_str_each_line(argc, argv, str)
if (*++p != '\n') continue; if (*++p != '\n') continue;
while (*p == '\n') p++; while (*p == '\n') p++;
} }
if (p[-1] == newline && if (RSTRING(str)->ptr < p && p[-1] == newline &&
(rslen <= 1 || (rslen <= 1 ||
rb_memcmp(RSTRING(rs)->ptr, p-rslen, rslen) == 0)) { rb_memcmp(RSTRING(rs)->ptr, p-rslen, rslen) == 0)) {
line = rb_str_new5(str, s, p - s); line = rb_str_new5(str, s, p - s);

Просмотреть файл

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.3" #define RUBY_VERSION "1.7.3"
#define RUBY_RELEASE_DATE "2002-09-23" #define RUBY_RELEASE_DATE "2002-09-25"
#define RUBY_VERSION_CODE 173 #define RUBY_VERSION_CODE 173
#define RUBY_RELEASE_CODE 20020923 #define RUBY_RELEASE_CODE 20020925