summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-09-15 06:00:30 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-09-15 06:00:30 +0000
commitbbf2ad4ed8a142c5fba8b5e56293006b359f9b18 (patch)
tree5cd9ec18d5f68c4092ffb4b29004289bd9fad895
parentf57e5b0dc61aab42d2913029080d7e93cc75f71a (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog30
-rw-r--r--bignum.c2
-rw-r--r--eval.c19
-rw-r--r--intern.h1
-rw-r--r--object.c1
-rw-r--r--parse.y10
-rw-r--r--ruby.h1
-rw-r--r--sample/time.rb2
-rw-r--r--variable.c37
9 files changed, 80 insertions, 23 deletions
diff --git a/ChangeLog b/ChangeLog
index dca259b0d4..3942ac876b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,27 @@
+Wed Sep 13 17:11:19 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * stable version 1.6.0 released.
+
+Thu Sep 14 02:46:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_thread_yield): array strip should be done in this
+ function.
+
+Wed Sep 13 17:01:03 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (rb_big_eq): imcomplete value compare of bignums.
+
+Wed Sep 13 06:39:54 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * variable.c (rb_mod_class_variables): Module#class_variables added.
+
Wed Sep 13 06:09:26 2000 Wakou Aoyama <wakou@fsinet.or.jp>
* lib/cgi.rb: bug fix: CGI::header(): output status header.
-Tue Sep 12 22:34:20 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
+Wed Sep 13 01:09:12 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
- * stable version 1.6.0 released.
+ * parse.y (yylex): allow global variables like '$__a'.
Tue Sep 12 22:28:43 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
@@ -17,8 +34,8 @@ Tue Sep 12 16:01:58 2000 WATANABE Hirofumi <eban@os.rim.or.jp>
Tue Sep 12 15:37:55 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
- * eval.c (rb_yield_0): stripped array too much, should be just for
- proc_call().
+ * eval.c (rb_yield_0): stripped array too much, should remove just
+ for proc_call().
Tue Sep 12 07:05:24 2000 Wakou Aoyama <wakou@fsinet.or.jp>
@@ -98,7 +115,7 @@ Sun Sep 3 23:44:04 2000 Noriaki Harada <tenmei@maoh.office.ne.jp>
Sun Sep 3 11:31:53 2000 Takaaki Tateishi <ttate@jaist.ac.jp>
- * parse.y (rescue): no assignment was done if rescue body as
+ * parse.y (rescue): no assignment was done if rescue body was
empty.
Sat Sep 2 10:52:21 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
@@ -146,8 +163,7 @@ Wed Aug 30 23:21:20 2000 Yukihiro Matsumoto <matz@ruby-lang.org>
* numeric.c (rb_num2long): use rb_Integer() instead of independent
convert routine.
- * eval.c (rb_rescue2): now arbitrary number of exception types can
- be specified.
+ * eval.c (rb_rescue2): now takes arbitrary number of exception types.
* object.c (rb_convert_type): use rb_rescue2 now to handle NameError.
diff --git a/bignum.c b/bignum.c
index cf9128d0b3..3a5fed571c 100644
--- a/bignum.c
+++ b/bignum.c
@@ -562,7 +562,7 @@ rb_big_eq(x, y)
}
if (RBIGNUM(x)->sign != RBIGNUM(y)->sign) return Qfalse;
if (RBIGNUM(x)->len != RBIGNUM(y)->len) return Qfalse;
- if (memcmp(BDIGITS(x),BDIGITS(y),RBIGNUM(y)->len) != 0) return Qfalse;
+ if (MEMCMP(BDIGITS(x),BDIGITS(y),USHORT,RBIGNUM(y)->len) != 0) return Qfalse;
return Qtrue;
}
diff --git a/eval.c b/eval.c
index e7f87051a0..f396638013 100644
--- a/eval.c
+++ b/eval.c
@@ -815,8 +815,8 @@ static rb_thread_t curr_thread = 0;
static VALUE rb_eval _((VALUE,NODE*));
static VALUE eval _((VALUE,VALUE,VALUE,char*,int));
static NODE *compile _((VALUE, char*, int));
-static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int));
+static VALUE rb_yield_0 _((VALUE, VALUE, VALUE, int));
static VALUE rb_call _((VALUE,VALUE,ID,int,VALUE*,int));
static VALUE module_setup _((VALUE,NODE*));
@@ -2226,7 +2226,7 @@ rb_eval(self, n)
else {
result = Qnil;
}
- result = rb_yield_0(result, 0, 0, Qfalse);
+ result = rb_yield_0(result, 0, 0, 0);
break;
case NODE_RESCUE:
@@ -3503,14 +3503,14 @@ VALUE
rb_yield(val)
VALUE val;
{
- return rb_yield_0(val, 0, 0, Qfalse);
+ return rb_yield_0(val, 0, 0, 0);
}
static VALUE
rb_f_loop()
{
for (;;) {
- rb_yield_0(Qnil, 0, 0, Qfalse);
+ rb_yield_0(Qnil, 0, 0, 0);
CHECK_INTS;
}
return Qnil; /* dummy */
@@ -4809,7 +4809,7 @@ yield_under_i(self)
PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) {
- result = rb_yield_0(self, self, ruby_class, Qfalse);
+ result = rb_yield_0(self, self, ruby_class, 0);
}
POP_TAG();
ruby_block = old_block;
@@ -4819,7 +4819,7 @@ yield_under_i(self)
}
/* static block, no need to restore */
ruby_block->frame.cbase = ruby_frame->cbase;
- return rb_yield_0(self, self, ruby_class, Qfalse);
+ return rb_yield_0(self, self, ruby_class, 0);
}
/* block eval under the class/module context */
@@ -5452,9 +5452,6 @@ errat_setter(val, id, var)
set_backtrace(ruby_errinfo, val);
}
-VALUE rb_f_global_variables();
-VALUE f_instance_variables();
-
static VALUE
rb_f_local_variables()
{
@@ -7781,7 +7778,7 @@ rb_thread_yield(arg, th)
rb_thread_t th;
{
scope_dup(ruby_block->scope);
- return rb_yield_0(callargs(arg), 0, 0, Qfalse);
+ return rb_yield_0(callargs(arg), 0, 0, Qtrue);
}
static VALUE
@@ -8335,7 +8332,7 @@ rb_f_catch(dmy, tag)
t = rb_to_id(tag);
PUSH_TAG(t);
if ((state = EXEC_TAG()) == 0) {
- val = rb_yield_0(tag, 0, 0, Qfalse);
+ val = rb_yield_0(tag, 0, 0, 0);
}
else if (state == TAG_THROW && t == prot_tag->dst) {
val = prot_tag->retval;
diff --git a/intern.h b/intern.h
index 5609c3f8d3..d651b408c4 100644
--- a/intern.h
+++ b/intern.h
@@ -372,6 +372,7 @@ VALUE rb_cvar_get _((VALUE, ID));
int rb_cvar_defined_singleton _((VALUE, ID));
void rb_cvar_set_singleton _((VALUE, ID, VALUE));
VALUE rb_cvar_get_singleton _((VALUE, ID));
+VALUE rb_mod_class_variables _((VALUE));
/* version.c */
void ruby_show_version _((void));
void ruby_show_copyright _((void));
diff --git a/object.c b/object.c
index 3db26148e6..fe9f8adbb9 100644
--- a/object.c
+++ b/object.c
@@ -1176,6 +1176,7 @@ Init_Object()
rb_define_method(rb_cModule, "const_defined?", rb_mod_const_defined, 1);
rb_define_private_method(rb_cModule, "remove_const", rb_mod_remove_const, 1);
rb_define_private_method(rb_cModule, "method_added", rb_obj_dummy, 1);
+ rb_define_method(rb_cModule, "class_variables", rb_mod_class_variables, 0);
rb_define_method(rb_cClass, "new", rb_class_new_instance, -1);
rb_define_method(rb_cClass, "superclass", rb_class_superclass, 0);
diff --git a/parse.y b/parse.y
index 0cf9194f36..3a273da94e 100644
--- a/parse.y
+++ b/parse.y
@@ -3397,7 +3397,15 @@ yylex()
case '~': /* $~: match-data */
/* fall through */
case '_': /* $_: last read line string */
- local_cnt(c);
+ c = nextc();
+ if (is_identchar(c)) {
+ tokadd('$');
+ tokadd('_');
+ break;
+ }
+ pushback(c);
+ c = '_';
+ local_cnt('_');
/* fall through */
case '*': /* $*: argv */
case '$': /* $$: pid */
diff --git a/ruby.h b/ruby.h
index 6b65d61632..09fb395ace 100644
--- a/ruby.h
+++ b/ruby.h
@@ -394,6 +394,7 @@ void xfree _((void*));
#define MEMZERO(p,type,n) memset((p), 0, sizeof(type)*(n))
#define MEMCPY(p1,p2,type,n) memcpy((p1), (p2), sizeof(type)*(n))
#define MEMMOVE(p1,p2,type,n) memmove((p1), (p2), sizeof(type)*(n))
+#define MEMCMP(p1,p2,type,n) memcmp((p1), (p2), sizeof(type)*(n))
void rb_glob _((char*,void(*)(),VALUE));
diff --git a/sample/time.rb b/sample/time.rb
index f4f4ec4883..1624fdf992 100644
--- a/sample/time.rb
+++ b/sample/time.rb
@@ -3,6 +3,6 @@ cmd = ARGV.join(" ")
b = Time.now
system(cmd)
e = Time.now
-ut, st, cut, cst = Time.times
+ut, st, cut, cst = Time.times.to_a
total = (e - b).to_f
printf STDERR, "%11.1f real %11.1f user %11.1f sys\n", total, cut, cst
diff --git a/variable.c b/variable.c
index b37c040681..cd9fe0d48e 100644
--- a/variable.c
+++ b/variable.c
@@ -1167,11 +1167,10 @@ rb_mod_const_of(mod, ary)
VALUE mod;
VALUE ary;
{
- rb_mod_const_at(mod, ary);
for (;;) {
+ rb_mod_const_at(mod, ary);
mod = RCLASS(mod)->super;
if (!mod) break;
- rb_mod_const_at(mod, ary);
}
return ary;
}
@@ -1488,6 +1487,40 @@ rb_define_class_variable(klass, name, val)
rb_cvar_declare(klass, id, val);
}
+static int
+cv_i(key, value, ary)
+ ID key;
+ VALUE value;
+ VALUE ary;
+{
+ if (rb_is_class_id(key)) {
+ VALUE kval = rb_str_new2(rb_id2name(key));
+ if (!rb_ary_includes(ary, kval)) {
+ rb_ary_push(ary, kval);
+ }
+ }
+ return ST_CONTINUE;
+}
+
+VALUE
+rb_mod_class_variables(obj)
+ VALUE obj;
+{
+ VALUE ary = rb_ary_new();
+
+ if (!OBJ_TAINTED(obj) && rb_safe_level() >= 4)
+ rb_raise(rb_eSecurityError, "Insecure: can't get metainfo");
+
+ for (;;) {
+ if (RCLASS(obj)->iv_tbl) {
+ st_foreach(RCLASS(obj)->iv_tbl, cv_i, ary);
+ }
+ obj = RCLASS(obj)->super;
+ if (!obj) break;
+ }
+ return ary;
+}
+
VALUE
rb_iv_get(obj, name)
VALUE obj;