summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYukihiro Matsumoto <matz@ruby-lang.org>1995-02-24 04:15:43 (GMT)
committerTakashi Kokubun <takashikkbn@gmail.com>2019-08-17 13:09:31 (GMT)
commit881c5a9c320c637ee0f6526b40cf70c1379ab656 (patch)
tree3c0327fc9bdef8f056563ceee400226ac572535b
parent2f106ab85c4f4e171374aee261f5a12bdd923c41 (diff)
version 0.68v0_68
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.67-0.68.diff.gz Fri Feb 24 13:15:43 1995 Yukihiro Matsumoto (matz@ix-02) * version 0.68 Thu Feb 23 11:19:19 1995 Yukihiro Matsumoto (matz@ix-02) * eval.c: resque節のselfの値が間違っていた. * eval.c(rb_clear_cache): キャッシュのクリアし忘れがあった. * eval.c: 定数のスコープをクラス内の静的スコープに変更した.これに よって,特異メソッドからは参照される定数は,レシーバのクラスでは なく,定義されたスコープのクラスの定数となる. Wed Feb 22 00:51:38 1995 Yukihiro Matsumoto (matz@dyna) * regex.c: ignorecaseを正規表現のコンパイル前に指定しないと正しく 動作しない.修正. * string.c(toupper,tolower): bug fix. * ENV,VERSION: readonly変数から定数へ.
-rw-r--r--ChangeLog36
-rw-r--r--array.c2
-rw-r--r--class.c22
-rw-r--r--compar.c2
-rw-r--r--cons.c2
-rw-r--r--dbm.c2
-rw-r--r--dict.c7
-rw-r--r--dir.c2
-rw-r--r--dln.c2
-rw-r--r--enum.c2
-rw-r--r--env.h2
-rw-r--r--error.c2
-rw-r--r--eval.c138
-rw-r--r--file.c2
-rw-r--r--gc.c4
-rw-r--r--ident.h2
-rw-r--r--inits.c2
-rw-r--r--io.c33
-rw-r--r--io.h2
-rw-r--r--math.c2
-rw-r--r--node.h99
-rw-r--r--numeric.c2
-rw-r--r--object.c2
-rw-r--r--pack.c2
-rw-r--r--parse.y134
-rw-r--r--process.c2
-rw-r--r--random.c2
-rw-r--r--range.c2
-rw-r--r--re.c50
-rw-r--r--re.h2
-rw-r--r--regex.c10
-rw-r--r--ruby.c4
-rw-r--r--ruby.h2
-rw-r--r--sample/MANIFEST1
-rw-r--r--sample/biorhythm.rb24
-rw-r--r--sample/cbreak.rb4
-rw-r--r--sample/clnt.rb2
-rw-r--r--sample/from.rb100
-rw-r--r--sample/io.rb2
-rw-r--r--sample/ruby-mode.el6
-rw-r--r--sample/svr.rb8
-rwxr-xr-xsample/time.rb2
-rw-r--r--sample/trojan.rb2
-rw-r--r--spec170
-rw-r--r--sprintf.c2
-rw-r--r--string.c17
-rw-r--r--struct.c2
-rw-r--r--time.c2
-rw-r--r--variable.c15
-rw-r--r--version.c11
-rw-r--r--version.h4
51 files changed, 587 insertions, 368 deletions
diff --git a/ChangeLog b/ChangeLog
index f66a446..78d6488 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+Fri Feb 24 13:15:43 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * version 0.68
+
+Thu Feb 23 11:19:19 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * eval.c: resqueselfְͤäƤ
+
+ * eval.c(rb_clear_cache): åΥꥢ˺줬ä
+
+ * eval.c: Υפ򥯥饹Ūפѹ
+ äơðۥ᥽åɤϻȤϡ쥷ФΥ饹Ǥ
+ ʤ줿פΥ饹Ȥʤ롥
+
+Wed Feb 22 00:51:38 1995 Yukihiro Matsumoto (matz@dyna)
+
+ * regex.c: ignorecaseɽΥѥ˻ꤷʤ
+ ưʤ
+
+ * string.c(toupper,tolower): bug fix.
+
+ * ENV,VERSION: readonlyѿء
+
+Tue Feb 21 18:56:56 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * io.c(STDIN, STDOUT, STDERR): ȤޤǤ$stdinʤ
+ Ͼʤʤ뤫Τʤ
+
+ * io.c(select): bug fix.
+
+ * version 0.67
+
Mon Feb 20 16:10:14 1995 Yukihiro Matsumoto (matz@ix-02)
* parse.y(yylex): `%̻'顤1ʸʸμ̻Ҥ
@@ -38,11 +70,15 @@ Fri Feb 10 16:30:00 1995 Yukihiro Matsumoto (matz@ix-02)
Thu Feb 9 16:18:37 1995 Yukihiro Matsumoto (matz@ix-02)
+ * version 0.66
+
* parse.y: protectbeginѹbegin..end㳰Ǥʤ
ʸ̤ȤƤƯȤˤʤä
Wed Feb 1 19:48:24 1995 Yukihiro Matsumoto (matz@ix-02)
+ * version 0.65
+
* string.c(str_replace): ֤ʸĹꥳ
ԡ򤷤ʤ
diff --git a/array.c b/array.c
index 895a679..120fd13 100644
--- a/array.c
+++ b/array.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:18 $
created at: Fri Aug 6 09:46:12 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/class.c b/class.c
index 2d05183..a7fbf7a 100644
--- a/class.c
+++ b/class.c
@@ -6,7 +6,7 @@
$Date: 1995/01/12 08:54:44 $
created at: Tue Aug 10 15:05:44 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
@@ -203,7 +203,7 @@ rb_include_module(class, module)
Check_Type(module, T_MODULE);
if (BUILTIN_TYPE(class) == T_CLASS) {
- rb_clear_cache2(class);
+ rb_clear_cache(class);
}
while (module) {
@@ -224,24 +224,6 @@ rb_include_module(class, module)
}
void
-rb_add_method(class, mid, node, noex)
- struct RClass *class;
- ID mid;
- NODE *node;
- int noex;
-{
- NODE *body;
-
- if (class == Qnil) class = (struct RClass*)C_Object;
- if (st_lookup(class->m_tbl, mid, &body)) {
- Warning("redefine %s", rb_id2name(mid));
- rb_clear_cache(body);
- }
- body = NEW_METHOD(node, noex);
- st_insert(class->m_tbl, mid, body);
-}
-
-void
rb_define_method(class, name, func, argc)
struct RClass *class;
char *name;
diff --git a/compar.c b/compar.c
index e3861b7..dee8f3f 100644
--- a/compar.c
+++ b/compar.c
@@ -6,7 +6,7 @@
$Date: 1994/10/14 06:19:05 $
created at: Thu Aug 26 14:39:48 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/cons.c b/cons.c
index bf75586..42df8cb 100644
--- a/cons.c
+++ b/cons.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:30:37 $
created at: Fri Jan 6 10:10:36 JST 1995
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/dbm.c b/dbm.c
index ed60561..dfe0a8b 100644
--- a/dbm.c
+++ b/dbm.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:24 $
created at: Mon Jan 24 15:59:52 JST 1994
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/dict.c b/dict.c
index b973fb7..364a1ac 100644
--- a/dict.c
+++ b/dict.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:26 $
created at: Mon Nov 22 18:51:18 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
@@ -614,7 +614,6 @@ Init_Dict()
rb_define_method(C_Dict,"has_key", Fdic_has_key, 1);
rb_define_method(C_Dict,"has_value", Fdic_has_value, 1);
-
envtbl = obj_alloc(C_Object);
rb_define_single_method(envtbl,"[]", Fgetenv, 1);
rb_define_single_method(envtbl,"[]=", Fsetenv, 2);
@@ -624,7 +623,5 @@ Init_Dict()
rb_include_module(CLASS_OF(envtbl), M_Enumerable);
rb_define_variable("$ENV", &envtbl, Qnil, rb_readonly_hook, 0);
-
- rb_define_private_method(C_Kernel, "getenv", Fgetenv, 1);
- rb_define_private_method(C_Kernel, "setenv", Fsetenv, 2);
+ rb_define_const(C_Kernel, "ENV", envtbl);
}
diff --git a/dir.c b/dir.c
index 73478a7..f20e555 100644
--- a/dir.c
+++ b/dir.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:28 $
created at: Wed Jan 5 09:51:01 JST 1994
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/dln.c b/dln.c
index 2e1ff5a..e0be180 100644
--- a/dln.c
+++ b/dln.c
@@ -6,7 +6,7 @@
$Date: 1994/12/09 01:28:23 $
created at: Tue Jan 18 17:05:06 JST 1994
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/enum.c b/enum.c
index a27c986..4296014 100644
--- a/enum.c
+++ b/enum.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:29 $
created at: Fri Oct 1 15:15:19 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/env.h b/env.h
index b13b5f0..2076c25 100644
--- a/env.h
+++ b/env.h
@@ -30,4 +30,6 @@ struct SCOPE {
extern int rb_in_eval;
+extern struct RClass *the_class;
+
#endif /* ENV_H */
diff --git a/error.c b/error.c
index dad7c5f..d9dcbe0 100644
--- a/error.c
+++ b/error.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:31 $
created at: Mon Aug 9 16:11:34 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/eval.c b/eval.c
index 0287e9f..b0d8022 100644
--- a/eval.c
+++ b/eval.c
@@ -6,7 +6,7 @@
$Date: 1995/01/12 08:54:45 $
created at: Thu Jun 10 14:22:17 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
@@ -19,7 +19,8 @@
#include <setjmp.h>
#include "st.h"
-void rb_clear_cache();
+static void rb_clear_cache_body();
+static void rb_clear_cache_entry();
/* #define TEST /* prints cache miss */
#ifdef TEST
@@ -40,6 +41,27 @@ struct cache_entry { /* method hash table. */
static struct cache_entry cache[CACHE_SIZE];
+void
+rb_add_method(class, mid, node, noex)
+ struct RClass *class;
+ ID mid;
+ NODE *node;
+ int noex;
+{
+ NODE *body;
+
+ if (class == Qnil) class = (struct RClass*)C_Object;
+ if (st_lookup(class->m_tbl, mid, &body)) {
+ Warning("redefine %s", rb_id2name(mid));
+ rb_clear_cache_body(body);
+ }
+ else {
+ rb_clear_cache_entry(class, mid);
+ }
+ body = NEW_METHOD(node, noex);
+ st_insert(class->m_tbl, mid, body);
+}
+
static NODE*
search_method(class, id, origin)
struct RClass *class, **origin;
@@ -116,7 +138,10 @@ rb_alias(class, name, def)
if (st_lookup(class->m_tbl, name, &old)) {
Warning("redefine %s", rb_id2name(name));
- rb_clear_cache(old->nd_body);
+ rb_clear_cache_body(body);
+ }
+ else {
+ rb_clear_cache_entry(class, name);
}
st_insert(class->m_tbl, name,
@@ -158,8 +183,8 @@ rb_method_boundp(class, id)
return FALSE;
}
-void
-rb_clear_cache(body)
+static void
+rb_clear_cache_body(body)
NODE *body;
{
struct cache_entry *ent, *end;
@@ -174,8 +199,23 @@ rb_clear_cache(body)
}
}
+static void
+rb_clear_cache_entry(class, mid)
+ struct RClass *class;
+ ID mid;
+{
+ struct cache_entry *ent;
+
+ /* is it in the method cache? */
+ ent = cache + EXPR1(class, mid);
+ if (ent->mid == mid && ent->class == class) {
+ ent->class = Qnil;
+ ent->mid = Qnil;
+ }
+}
+
void
-rb_clear_cache2(class)
+rb_clear_cache(class)
struct RClass *class;
{
struct cache_entry *ent, *end;
@@ -285,6 +325,7 @@ static struct tag {
#define EXEC_TAG() (setjmp(prot_tag->buf))
#define JUMP_TAG(val) { \
+ Qself = prot_tag->self; \
the_env = prot_tag->env; \
iter = prot_tag->iter; \
longjmp(prot_tag->buf,(val)); \
@@ -305,7 +346,7 @@ static struct tag {
#define IN_BLOCK 0x08
-static struct RClass *the_class;
+struct RClass *the_class;
struct class_link {
struct RClass *class;
struct class_link *prev;
@@ -338,6 +379,8 @@ VALUE rb_apply();
VALUE rb_xstring();
void rb_fail();
+static void module_setup();
+
static VALUE masign();
static void asign();
@@ -396,6 +439,8 @@ ruby_init(argc, argv, envp)
PUSH_TAG();
PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
+ rb_call_inits();
+ the_class = (struct RClass*)C_Object;
ruby_init0(argc, argv, envp);
}
POP_ITER();
@@ -448,7 +493,6 @@ ruby_run()
PUSH_TAG();
PUSH_ITER(ITER_NOT);
if ((state = EXEC_TAG()) == 0) {
- the_class = (struct RClass*)C_Object;
Eval();
}
POP_ITER();
@@ -1038,8 +1082,9 @@ rb_eval(node)
case NODE_CVAR:
{
- VALUE val = rb_const_get(node->nd_vid);
+ VALUE val;
+ val = rb_const_get(node->nd_rval->nd_clss, node->nd_vid);
nd_set_type(node, NODE_CONST);
node->nd_cval = val;
return val;
@@ -1114,7 +1159,9 @@ rb_eval(node)
list = list->nd_next;
}
if (nd_type(node) == NODE_DREGX) {
- return regexp_new(RSTRING(str)->ptr, RSTRING(str)->len);
+ VALUE re = regexp_new(RSTRING(str)->ptr, RSTRING(str)->len,
+ node->nd_cflag);
+ return re;
}
if (nd_type(node) == NODE_XSTR2) {
return rb_xstring(str);
@@ -1195,17 +1242,8 @@ rb_eval(node)
class = rb_define_class_id(node->nd_cname, super);
rb_const_set(the_class, node->nd_cname, class);
- PUSH_CLASS();
- the_class = (struct RClass*)class;
- PUSH_SELF((VALUE)the_class);
- PUSH_TAG();
- if ((state = EXEC_TAG()) == 0) {
- rb_eval(node->nd_body);
- }
- POP_TAG();
- POP_SELF();
- POP_CLASS();
- if (state) JUMP_TAG(state);
+
+ module_setup(class, node->nd_body);
return class;
}
@@ -1219,17 +1257,8 @@ rb_eval(node)
module = rb_define_module_id(node->nd_cname);
rb_const_set(the_class, node->nd_cname, module);
- PUSH_CLASS();
- the_class = (struct RClass*)module;
- PUSH_SELF((VALUE)the_class);
- PUSH_TAG();
- if ((state = EXEC_TAG()) == 0) {
- rb_eval(node->nd_body);
- }
- POP_TAG();
- POP_SELF();
- POP_CLASS();
- if (state) JUMP_TAG(state);
+
+ module_setup(module, node->nd_body);
return module;
}
@@ -1237,7 +1266,7 @@ rb_eval(node)
{
struct RClass *module;
- module = (struct RClass*)rb_const_get(node->nd_modl);
+ module = (struct RClass*)rb_const_get(CLASS_OF(Qself), node->nd_modl);
if (module == Qnil) {
Fail("undefined module %s", rb_id2name(node->nd_modl));
}
@@ -1251,6 +1280,49 @@ rb_eval(node)
return Qnil; /* not reached */
}
+static void
+module_setup(module, node)
+ VALUE module;
+ NODE *node;
+{
+ int state;
+
+ /* fill c-ref */
+ node->nd_clss = module;
+ node = node->nd_body;
+
+ PUSH_CLASS();
+ the_class = (struct RClass*)module;
+ PUSH_SELF((VALUE)the_class);
+ PUSH_SCOPE();
+ PUSH_TAG();
+
+ if (node->nd_cnt > 0) {
+ the_scope->local_vars = ALLOCA_N(VALUE, node->nd_cnt);
+ MEMZERO(the_scope->local_vars, VALUE, node->nd_cnt);
+ the_scope->local_tbl = node->nd_tbl;
+ }
+ else {
+ the_scope->local_vars = Qnil;
+ the_scope->local_tbl = Qnil;
+ }
+
+ if ((state = EXEC_TAG()) == 0) {
+ rb_eval(node->nd_body);
+ }
+
+ POP_TAG();
+ if (!(the_scope->flags & SCOPE_MALLOCED)) {
+ the_scope->local_vars = Qnil;
+ the_scope->local_tbl = Qnil;
+ }
+ if (state != 0) JUMP_TAG(state);
+ POP_SCOPE();
+ POP_SELF();
+ POP_CLASS();
+ if (state) JUMP_TAG(state);
+}
+
VALUE
obj_responds_to(obj, msg)
VALUE obj;
diff --git a/file.c b/file.c
index 6f10099..a1729de 100644
--- a/file.c
+++ b/file.c
@@ -7,7 +7,7 @@
$Date: 1995/01/10 10:42:36 $
created at: Mon Nov 15 12:24:34 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/gc.c b/gc.c
index ec07c0f..9c9a2a2 100644
--- a/gc.c
+++ b/gc.c
@@ -6,7 +6,7 @@
$Date: 1995/01/12 08:54:47 $
created at: Tue Oct 5 09:44:46 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
@@ -513,7 +513,7 @@ obj_free(obj)
break;
case T_MODULE:
case T_CLASS:
- rb_clear_cache2(obj);
+ rb_clear_cache(obj);
st_free_table(obj->as.class.m_tbl);
if (obj->as.object.iv_tbl) st_free_table(obj->as.object.iv_tbl);
break;
diff --git a/ident.h b/ident.h
index d1b46c8..acf738b 100644
--- a/ident.h
+++ b/ident.h
@@ -7,7 +7,7 @@
$Date: 1994/08/12 04:47:29 $
created at: Mon Jan 31 16:23:19 JST 1994
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/inits.c b/inits.c
index 45475e1..271fa7d 100644
--- a/inits.c
+++ b/inits.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:38 $
created at: Tue Dec 28 16:01:58 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/io.c b/io.c
index 288e86d..ac94f9e 100644
--- a/io.c
+++ b/io.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:39 $
created at: Fri Oct 15 18:08:59 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
@@ -334,9 +334,8 @@ Fio_gets(obj)
if (str) {
fptr->lineno++;
lineno = INT2FIX(fptr->lineno);
- return rb_lastline = (VALUE)str;
}
- return Qnil;
+ return rb_lastline = (VALUE)str;
}
static VALUE
@@ -936,22 +935,18 @@ rb_xstring(str)
struct timeval *time_timeval();
-#ifdef STDSTDIO
-# define READ_PENDING(fp) ((fp)->_cnt != 0)
-#else
-# ifdef __SLBF
-# define READ_PENDING(fp) ((fp)->_r > 0)
-# else
-# ifdef __linux__
+#ifdef _STDIO_USES_IOSTREAM /* GNU libc */
# ifdef _other_gbase
-# define READ_PENDING(fp) ((fp)->_IO_read_ptr < (fp)->_IO_read_end)
+# define READ_DATA_PENDING(fp) ((fp)->_IO_read_ptr < (fp)->_IO_read_end)
# else
-# define READ_PENDING(fp) ((fp)->_gptr < (fp)->_egptr)
+# define READ_DATA_PENDING(fp) ((fp)->_gptr < (fp)->_egptr)
# endif
-# else
+#elif __SLBF
+# define READ_DATA_PENDING(fp) (fp->_r > 0)
+#elif STDSTDIO
+# define READ_DATA_PENDING(fp) (fp->_cnt != 0)
+#else
--------------> You Lose <--------------
-# endif
-# endif
#endif
static VALUE
@@ -968,7 +963,7 @@ Fselect(argc, argv, obj)
int i, max = 0, n;
int interrupt = 0;
- rb_scan_args(argc, argv, argv, "13", &read, &write, &except, &timeout);
+ rb_scan_args(argc, argv, "13", &read, &write, &except, &timeout);
if (timeout) {
tp = time_timeval(timeout);
}
@@ -986,7 +981,7 @@ Fselect(argc, argv, obj)
for (i=0; i<RARRAY(read)->len; i++) {
GetOpenFile(RARRAY(read)->ptr[i], fptr);
FD_SET(fileno(fptr->f), rp);
- if (READ_PENDING(fptr->f)) { /* check for buffered data */
+ if (READ_DATA_PENDING(fptr->f)) { /* check for buffered data */
pending++;
FD_SET(fileno(fptr->f), &pset);
}
@@ -1395,6 +1390,10 @@ Init_IO()
rb_defout = rb_stdout;
rb_define_variable("$>", &rb_defout, Qnil, io_defset, 0);
+ rb_define_const(C_Object, "STDIN", rb_stdin);
+ rb_define_const(C_Object, "STDOUT", rb_stdout);
+ rb_define_const(C_Object, "STDERR", rb_stderr);
+
argf = obj_alloc(C_Object);
rb_define_variable("$<", &argf, Qnil, rb_readonly_hook, 0);
rb_define_variable("$ARGF", &argf, Qnil, rb_readonly_hook, 0);
diff --git a/io.h b/io.h
index c121659..2205906 100644
--- a/io.h
+++ b/io.h
@@ -7,7 +7,7 @@
$Date: 1994/08/12 11:06:42 $
created at: Fri Nov 12 16:47:09 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/math.c b/math.c
index 6a6c720..78a6615 100644
--- a/math.c
+++ b/math.c
@@ -6,7 +6,7 @@
$Date: 1994/11/01 08:28:03 $
created at: Tue Jan 25 14:12:56 JST 1994
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/node.h b/node.h
index 9af249e..7db04c5 100644
--- a/node.h
+++ b/node.h
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:41 $
created at: Fri May 28 15:14:02 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
@@ -70,6 +70,7 @@ enum node_type {
NODE_UNDEF,
NODE_CLASS,
NODE_MODULE,
+ NODE_CREF,
NODE_INC,
NODE_DOT3,
NODE_ATTRSET,
@@ -165,73 +166,77 @@ typedef struct RNode {
#define nd_super u3.id
#define nd_modl u1.id
+#define nd_clss u1.value
#define nd_beg u1.node
#define nd_end u2.node
#define nd_state u3.state
#define nd_rval u3.node
-#define NEW_METHOD(n,x) newnode(NODE_METHOD,x,n,Qnil)
+#define NEW_METHOD(n,x) newnode(NODE_METHOD,x,n,0)
#define NEW_FBODY(n,i,o) newnode(NODE_FBODY,n,i,o)
-#define NEW_DEFN(i,d,p) newnode(NODE_DEFN,p,i,d)
-#define NEW_DEFS(r,i,d) newnode(NODE_DEFS,r,i,d)
-#define NEW_CFUNC(f,c) newnode(NODE_CFUNC,f,c,Qnil)
+#define NEW_DEFN(i,a,d,p) newnode(NODE_DEFN,p,i,NEW_RFUNC(a,d))
+#define NEW_DEFS(r,i,a,d) newnode(NODE_DEFS,r,i,NEW_RFUNC(a,d))
+#define NEW_CFUNC(f,c) newnode(NODE_CFUNC,f,c,0)
#define NEW_RFUNC(b1,b2) NEW_SCOPE(block_append(b1,b2))
#define NEW_SCOPE(b) newnode(NODE_SCOPE,local_tbl(),(b),local_cnt(0))
-#define NEW_BLOCK(a) newnode(NODE_BLOCK,a,1,Qnil)
+#define NEW_BLOCK(a) newnode(NODE_BLOCK,a,1,0)
#define NEW_IF(c,t,e) newnode(NODE_IF,c,t,e)
-#define NEW_EXNOT(c) newnode(NODE_EXNOT,c,Qnil,Qnil)
-#define NEW_CASE(h,b) newnode(NODE_CASE,h,b,Qnil)
+#define NEW_EXNOT(c) newnode(NODE_EXNOT,c,0,0)
+#define NEW_CASE(h,b) newnode(NODE_CASE,h,b,0)
#define NEW_WHEN(c,t,e) newnode(NODE_WHEN,c,t,e)
-#define NEW_WHILE(c,b) newnode(NODE_WHILE,c,b,Qnil)
-#define NEW_WHILE2(c,b) newnode(NODE_WHILE2,c,b,Qnil)
+#define NEW_WHILE(c,b) newnode(NODE_WHILE,c,b,0)
+#define NEW_WHILE2(c,b) newnode(NODE_WHILE2,c,b,0)
#define NEW_FOR(v,i,b) newnode(NODE_FOR,v,b,i)
#define NEW_ITER(v,i,b) newnode(NODE_ITER,v,b,i)
#define NEW_BEGIN(b,ex,en) newnode(NODE_BEGIN,b,ex,en)
-#define NEW_REDO() newnode(NODE_REDO,Qnil,Qnil,Qnil)
-#define NEW_BREAK() newnode(NODE_BREAK,Qnil,Qnil,Qnil)
-#define NEW_CONT() newnode(NODE_CONTINUE,Qnil,Qnil,Qnil)
-#define NEW_RETRY() newnode(NODE_RETRY,Qnil,Qnil,Qnil)
-#define NEW_RET(s) newnode(NODE_RETURN,s,Qnil,Qnil)
-#define NEW_FAIL(s) newnode(NODE_FAIL,s,Qnil,Qnil)
-#define NEW_YIELD(a) newnode(NODE_YIELD,a,Qnil,Qnil)
+#define NEW_REDO() newnode(NODE_REDO,0,0,0)
+#define NEW_BREAK() newnode(NODE_BREAK,0,0,0)
+#define NEW_CONT() newnode(NODE_CONTINUE,0,0,0)
+#define NEW_RETRY() newnode(NODE_RETRY,0,0,0)
+#define NEW_RET(s) newnode(NODE_RETURN,s,0,0)
+#define NEW_FAIL(s) newnode(NODE_FAIL,s,0,0)
+#define NEW_YIELD(a) newnode(NODE_YIELD,a,0,0)
#define NEW_LIST(a) NEW_ARRAY(a)
-#define NEW_ARRAY(a) newnode(NODE_ARRAY,a,1,Qnil)
-#define NEW_ZARRAY() newnode(NODE_ZARRAY,Qnil,Qnil,Qnil)
-#define NEW_HASH(a) newnode(NODE_HASH,a,Qnil,Qnil)
-#define NEW_AND(a,b) newnode(NODE_AND,a,b,Qnil)
-#define NEW_OR(a,b) newnode(NODE_OR,a,b,Qnil)
-#define NEW_NOT(a) newnode(NODE_NOT,Qnil,a,Qnil)
-#define NEW_MASGN(l,r) newnode(NODE_MASGN,l,r,Qnil)
+#define NEW_ARRAY(a) newnode(NODE_ARRAY,a,1,0)
+#define NEW_ZARRAY() newnode(NODE_ZARRAY,0,0,0)
+#define NEW_HASH(a) newnode(NODE_HASH,a,0,0)
+#define NEW_AND(a,b) newnode(NODE_AND,a,b,0)
+#define NEW_OR(a,b) newnode(NODE_OR,a,b,0)
+#define NEW_NOT(a) newnode(NODE_NOT,0,a,0)
+#define NEW_MASGN(l,r) newnode(NODE_MASGN,l,r,0)
#define NEW_GASGN(v,val) newnode(NODE_GASGN,v,val,rb_global_entry(v))
#define NEW_LASGN(v,val) newnode(NODE_LASGN,v,val,local_cnt(v))
-#define NEW_IASGN(v,val) newnode(NODE_IASGN,v,val,Qnil)
-#define NEW_CASGN(v,val) newnode(NODE_CASGN,v,val,Qnil)
+#define NEW_IASGN(v,val) newnode(NODE_IASGN,v,val,0)
+#define NEW_CASGN(v,val) newnode(NODE_CASGN,v,val,0)
#define NEW_OP_ASGN1(p,id,a) newnode(NODE_OP_ASGN1,p,id,a)
#define NEW_OP_ASGN2(r,i,val) newnode(NODE_OP_ASGN1,r,val,i)
-#define NEW_GVAR(v) newnode(NODE_GVAR,v,Qnil,rb_global_entry(v))
-#define NEW_LVAR(v) newnode(NODE_LVAR,v,Qnil,local_cnt(v))
-#define NEW_LVAR2(v) newnode(NODE_LVAR2,v,Qnil,local_cnt(v))
-#define NEW_IVAR(v) newnode(NODE_IVAR,v,Qnil,Qnil)
-#define NEW_CVAR(v) newnode(NODE_CVAR,v,Qnil,Qnil)
-#define NEW_LIT(l) newnode(NODE_LIT,l,Qnil,Qnil)
-#define NEW_STR(s) newnode(NODE_STR,s,Qnil,Qnil)
-#define NEW_STR2(s) newnode(NODE_STR2,s,Qnil,Qnil)
-#define NEW_XSTR(s) newnode(NODE_XSTR,s,Qnil,Qnil)
-#define NEW_XSTR2(s) newnode(NODE_XSTR2,s,Qnil,Qnil)
+#define NEW_GVAR(v) newnode(NODE_GVAR,v,0,rb_global_entry(v))
+#define NEW_LVAR(v) newnode(NODE_LVAR,v,0,local_cnt(v))
+#define NEW_LVAR2(v) newnode(NODE_LVAR2,v,0,0)
+#define NEW_IVAR(v) newnode(NODE_IVAR,v,0,0)
+#define NEW_CVAR(v) newnode(NODE_CVAR,v,0,cref_list)
+#define NEW_LIT(l) newnode(NODE_LIT,l,0,0)
+#define NEW_STR(s) newnode(NODE_STR,s,0,0)
+#define NEW_STR2(s) newnode(NODE_STR2,s,0,0)
+#define NEW_XSTR(s) newnode(NODE_XSTR,s,0,0)
+#define NEW_XSTR2(s) newnode(NODE_XSTR2,s,0,0)
#define NEW_CALL(r,m,a) newnode(NODE_CALL,r,m,a)
-#define NEW_SUPER(a) newnode(NODE_SUPER,Qnil,Qnil,a)
-#define NEW_ZSUPER() newnode(NODE_ZSUPER,Qnil,Qnil,Qnil)
-#define NEW_ARGS(f,r) newnode(NODE_ARGS,Qnil,r,f)
-#define NEW_ALIAS(n,o) newnode(NODE_ALIAS,Qnil,n,o)
-#define NEW_UNDEF(i) newnode(NODE_UNDEF,Qnil,i,Qnil)
-#define NEW_CLASS(n,b,s) newnode(NODE_CLASS,n,NEW_SCOPE(b),s)
-#define NEW_MODULE(n,b) newnode(NODE_MODULE,n,NEW_SCOPE(b),Qnil)
-#define NEW_INC(m) newnode(NODE_INC,m,Qnil,Qnil)
+#define NEW_SUPER(a) newnode(NODE_SUPER,0,0,a)
+#define NEW_ZSUPER() newnode(NODE_ZSUPER,0,0,0)
+#define NEW_ARGS(f,r) newnode(NODE_ARGS,0,r,f)
+#define NEW_ALIAS(n,o) newnode(NODE_ALIAS,0,n,o)
+#define NEW_UNDEF(i) newnode(NODE_UNDEF,0,i,0)
+#define NEW_CLASS(n,b,s) newnode(NODE_CLASS,n,NEW_CBODY(b),s)
+#define NEW_MODULE(n,b) newnode(NODE_MODULE,n,NEW_CBODY(b),0)
+#define NEW_CREF0() (cref_list=newnode(NODE_CREF,the_class,0,0))
+#define NEW_CREF(b) (cref_list=newnode(NODE_CREF,0,0,cref_list))
+#define NEW_CBODY(b) (cref_list->nd_body=NEW_SCOPE(b),cref_list)
+#define NEW_INC(m) newnode(NODE_INC,m,0,0)
#define NEW_DOT3(b,e) newnode(NODE_DOT3,b,e,0)
-#define NEW_ATTRSET(a) newnode(NODE_ATTRSET,a,Qnil,Qnil)
-#define NEW_SELF() newnode(NODE_SELF,Qnil,Qnil,Qnil)
-#define NEW_NIL() newnode(NODE_NIL,Qnil,Qnil,Qnil)
+#define NEW_ATTRSET(a) newnode(NODE_ATTRSET,a,0,0)
+#define NEW_SELF() newnode(NODE_SELF,0,0,0)
+#define NEW_NIL() newnode(NODE_NIL,0,0,0)
NODE *newnode();
VALUE rb_method_booundp();
diff --git a/numeric.c b/numeric.c
index cab3c69..8381762 100644
--- a/numeric.c
+++ b/numeric.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:42 $
created at: Fri Aug 13 18:33:09 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/object.c b/object.c
index 6266f77..7aa1648 100644
--- a/object.c
+++ b/object.c
@@ -6,7 +6,7 @@
$Date: 1995/01/12 08:54:49 $
created at: Thu Jul 15 12:01:24 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/pack.c b/pack.c
index e0c6e67..7935f33 100644
--- a/pack.c
+++ b/pack.c
@@ -6,7 +6,7 @@
$Date: 1994/12/09 09:40:22 $
created at: Thu Feb 10 15:17:05 JST 1994
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/parse.y b/parse.y
index 0566808..74b500b 100644
--- a/parse.y
+++ b/parse.y
@@ -47,8 +47,9 @@ static enum lex_state {
EXPR_FNAME, /* ignore newline, +/- is a operator. */
} lex_state;
-static ID cur_class = Qnil, cur_mid = Qnil;
-static int in_module, in_single;
+static int class_nest = 0;
+static int in_single = 0;
+static ID cur_mid = Qnil;
static int value_expr();
static NODE *cond();
@@ -66,16 +67,20 @@ static NODE *asignable();
static NODE *aryset();
static NODE *attrset();
-static void push_local();
-static void pop_local();
-static int local_cnt();
-static int local_id();
-static ID *local_tbl();
+static void local_push();
+static void local_pop();
+static int local_cnt();
+static int local_id();
+static ID *local_tbl();
+
+#define cref_push() NEW_CREF(0)
+static void cref_pop();
+static NODE *cref_list;
struct global_entry* rb_global_entry();
-static void init_top_local();
-static void setup_top_local();
+static void top_local_init();
+static void top_local_setup();
%}
%union {
@@ -182,12 +187,12 @@ static void setup_top_local();
%%
program : {
lex_state = EXPR_BEG;
- init_top_local();
+ top_local_init();
}
compexpr
{
eval_tree = block_append(eval_tree, $2);
- setup_top_local();
+ top_local_setup();
}
compexpr : exprs opt_term
@@ -719,6 +724,7 @@ primary : literal
| primary '{' opt_iter_var '|' compexpr rbrace
{
if (nd_type($1) == NODE_LVAR
+ || nd_type($1) == NODE_LVAR2
|| nd_type($1) == NODE_CVAR) {
$1 = NEW_CALL(Qnil, $1->nd_vid, Qnil);
}
@@ -787,59 +793,61 @@ primary : literal
if (cur_mid || in_single)
Error("class definition in method body");
- cur_class = $2;
- push_local();
+ class_nest++;
+ cref_push();
+ local_push();
}
compexpr
END
{
$$ = NEW_CLASS($2, $5, $3);
- pop_local();
- cur_class = Qnil;
+ local_pop();
+ cref_pop();
+ class_nest--;
}
| MODULE CONSTANT
{
if (cur_mid || in_single)
Error("module definition in method body");
- cur_class = $2;
- in_module = 1;
- push_local();
+ class_nest++;
+ cref_push();
+ local_push();
}
compexpr
END
{
$$ = NEW_MODULE($2, $4);
- pop_local();
- cur_class = Qnil;
- in_module = 0;
+ local_pop();
+ cref_pop();
+ class_nest--;
}
| DEF fname
{
if (cur_mid || in_single)
Error("nested method definition");
cur_mid = $2;
- push_local();
+ local_push();
}
f_arglist
compexpr
END
{
- $$ = NEW_DEFN($2, NEW_RFUNC($4, $5), cur_class?0:1);
- pop_local();
+ $$ = NEW_DEFN($2, $4, $5, class_nest?1:0);
+ local_pop();
cur_mid = Qnil;
}
| DEF singleton '.' fname
{
value_expr($2);
in_single++;
- push_local();
+ local_push();
}
f_arglist
compexpr
END
{
- $$ = NEW_DEFS($2, $4, NEW_RFUNC($6, $7));
- pop_local();
+ $$ = NEW_DEFS($2, $4, $6, $7);
+ local_pop();
in_single--;
}
@@ -1084,7 +1092,6 @@ rbracket : ']' { yyerrok; }
rbrace : '}' { yyerrok; }
comma : ',' { yyerrok; }
%%
-
#include <ctype.h>
#include <sys/types.h>
#include "regex.h"
@@ -1221,8 +1228,7 @@ parse_regx()
return DREGEXP;
}
else {
- yylval.val = regexp_new(tok(), toklen());
- if (casefold) FL_SET(yylval.val, FL_USER1);
+ yylval.val = regexp_new(tok(), toklen(), casefold);
return REGEXP;
}
case -1:
@@ -1560,24 +1566,24 @@ retry:
return '|';
case '+':
- if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
- c = nextc();
- pushback();
- if (isdigit(c)) {
- goto start_num;
- }
- lex_state = EXPR_BEG;
- return UPLUS;
- }
- else if (lex_state == EXPR_FNAME) {
+ if (lex_state == EXPR_FNAME) {
if ((c = nextc()) == '@') {
return UPLUS;
}
pushback();
return '+';
}
+ c = nextc();
+ if (lex_state != EXPR_END) {
+ pushback();
+ if (isdigit(c)) {
+ goto start_num;
+ }
+ lex_state = EXPR_BEG;
+ return UMINUS;
+ }
lex_state = EXPR_BEG;
- if ((c = nextc()) == '=') {
+ if (c == '=') {
yylval.id = '+';
return OP_ASGN;
}
@@ -1585,8 +1591,15 @@ retry:
return '+';
case '-':
- if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
- c = nextc();
+ if (lex_state == EXPR_FNAME) {
+ if ((c = nextc()) == '@') {
+ return UMINUS;
+ }
+ pushback();
+ return '-';
+ }
+ c = nextc();
+ if (lex_state != EXPR_END) {
pushback();
if (isdigit(c)) {
c = '-';
@@ -1595,15 +1608,8 @@ retry:
lex_state = EXPR_BEG;
return UMINUS;
}
- else if (lex_state == EXPR_FNAME) {
- if ((c = nextc()) == '@') {
- return UMINUS;
- }
- pushback();
- return '-';
- }
lex_state = EXPR_BEG;
- if ((c = nextc()) == '=') {
+ if (c == '=') {
yylval.id = '-';
return OP_ASGN;
}
@@ -2448,8 +2454,8 @@ attrset(recv, id, val)
{
value_expr(recv);
value_expr(val);
-
- id &= ~ID_SCOPE_MASK;
+
+ id &= ~ID_SCOPE_MASK;
id |= ID_ATTRSET;
return NEW_CALL(recv, id, NEW_LIST(val));
@@ -2555,7 +2561,7 @@ static struct local_vars {
} *lvtbl;
static void
-push_local()
+local_push()
{
struct local_vars *local;
@@ -2567,7 +2573,7 @@ push_local()
}
static void
-pop_local()
+local_pop()
{
struct local_vars *local = lvtbl;
@@ -2620,10 +2626,10 @@ local_id(id)
}
static void
-init_top_local()
+top_local_init()
{
if (lvtbl == Qnil) {
- push_local();
+ local_push();
}
else if (the_scope->local_tbl) {
lvtbl->cnt = the_scope->local_tbl[0];
@@ -2638,10 +2644,11 @@ init_top_local()
else {
lvtbl->tbl = Qnil;
}
+ NEW_CREF0(); /* initialize constant c-ref */
}
static void
-setup_top_local()
+top_local_setup()
{
int len = lvtbl->cnt;
int i;
@@ -2676,6 +2683,16 @@ setup_top_local()
free(lvtbl->tbl);
}
}
+ cref_list = Qnil;
+}
+
+static void
+cref_pop()
+{
+ NODE *cref = cref_list;
+
+ cref_list = cref_list->nd_next;
+ cref->nd_next = Qnil;
}
void
@@ -2758,6 +2775,7 @@ Init_sym()
int strcmp();
sym_tbl = st_init_table(strcmp, st_strhash);
+ rb_global_variable(&cref_list);
}
ID
diff --git a/process.c b/process.c
index 92ff8b9..e7e2261 100644
--- a/process.c
+++ b/process.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:47 $
created at: Tue Aug 10 14:30:50 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/random.c b/random.c
index b687434..09d04ff 100644
--- a/random.c
+++ b/random.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:48 $
created at: Fri Dec 24 16:39:21 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/range.c b/range.c
index 97e68bd..e1ca3c9 100644
--- a/range.c
+++ b/range.c
@@ -6,7 +6,7 @@
$Date: 1994/12/06 09:30:12 $
created at: Thu Aug 19 17:46:47 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/re.c b/re.c
index 2b2a06f..bc83ec7 100644
--- a/re.c
+++ b/re.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:49 $
created at: Mon Aug 9 18:24:49 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
@@ -84,7 +84,7 @@ str_cicmp(str1, str2)
return str1->len - str2->len;
}
-Regexp*
+static Regexp*
make_regexp(s, len)
char *s;
int len;
@@ -108,6 +108,7 @@ int len;
if ((err = re_compile_pattern(s, (size_t)len, &(rp->pat))) != NULL)
Fail("%s: /%s/", err, s);
+
return rp;
}
@@ -118,26 +119,27 @@ struct match {
};
struct match last_match;
+VALUE ignorecase;
int
-research(reg, str, start, ignorecase)
+research(reg, str, start)
struct RRegexp *reg;
struct RString *str;
int start;
- int ignorecase;
{
int result;
+ int casefold = ignorecase;
/* case-flag set for the object */
if (FL_TEST(reg, FL_USER1)) {
- ignorecase = 1;
+ casefold = TRUE;
}
- if (ignorecase)
+ if (casefold)
reg->ptr->pat.translate = casetable;
else
reg->ptr->pat.translate = NULL;
- if (start >= str->len) return -1;
+ if (start > str->len) return -1;
result = re_search(&(reg->ptr->pat), str->ptr, str->len,
start, str->len - start, &(reg->ptr->regs));
@@ -290,14 +292,13 @@ const char *s;
Fail(s);
}
-VALUE ignorecase;
VALUE C_Regexp;
static VALUE
-regexp_new_1(class, s, len)
+regexp_new_1(class, s, len, ci)
VALUE class;
char *s;
- int len;
+ int len, ci;
{
NEWOBJ(re, struct RRegexp);
OBJSETUP(re, class, T_REGEXP);
@@ -307,15 +308,17 @@ regexp_new_1(class, s, len)
memcpy(re->str, s, len);
re->str[len] = '\0';
re->len = len;
+
+ if (ci) FL_SET(re, FL_USER1);
return (VALUE)re;
}
VALUE
-regexp_new(s, len)
+regexp_new(s, len, ci)
char *s;
- int len;
+ int len, ci;
{
- return regexp_new_1(C_Regexp, s, len);
+ return regexp_new_1(C_Regexp, s, len, ci);
}
static VALUE str_cache, reg_cache;
@@ -329,7 +332,7 @@ re_regcomp(str)
return reg_cache;
str_cache = (VALUE)str;
- return reg_cache = regexp_new(str->ptr, str->len);
+ return reg_cache = regexp_new(str->ptr, str->len, ignorecase);
}
VALUE
@@ -340,7 +343,7 @@ Freg_match(re, str)
int start;
Check_Type(str, T_STRING);
- start = research(re, str, 0, ignorecase);
+ start = research(re, str, 0);
if (start == -1) {
return Qnil;
}
@@ -357,7 +360,7 @@ Freg_match2(re)
if (TYPE(rb_lastline) != T_STRING)
Fail("$_ is not a string");
- start = research(re, rb_lastline, 0, ignorecase);
+ start = research(re, rb_lastline, 0);
if (start == -1) {
return Qnil;
}
@@ -371,27 +374,27 @@ Sreg_new(argc, argv, self)
VALUE self;
{
VALUE src, reg;
+ int ci = 0;
if (argc == 0 || argc > 2) {
Fail("wrong # of argument");
}
+ if (argc == 2 && argv[1]) {
+ ci = 1;
+ }
src = argv[0];
switch (TYPE(src)) {
case T_STRING:
- reg = regexp_new_1(self, RREGEXP(src)->ptr, RREGEXP(src)->len);
+ reg = regexp_new_1(self, RREGEXP(src)->ptr, RREGEXP(src)->len, ci);
case T_REGEXP:
- reg = regexp_new_1(self, RREGEXP(src)->str, RREGEXP(src)->len);
+ reg = regexp_new_1(self, RREGEXP(src)->str, RREGEXP(src)->len, ci);
default:
Check_Type(src, T_STRING);
}
- if (argc == 2 && argv[1]) {
- FL_SET(reg, FL_USER1);
- }
-
return Qnil;
}
@@ -429,7 +432,8 @@ static VALUE
Freg_clone(re)
struct RRegexp *re;
{
- return regexp_new_1(CLASS_OF(re), re->str, re->len);
+ int ci = FL_TEST(re, FL_USER1);
+ return regexp_new_1(CLASS_OF(re), re->str, re->len, ci);
}
VALUE
diff --git a/re.h b/re.h
index 4c6ecfb..e26d325 100644
--- a/re.h
+++ b/re.h
@@ -7,7 +7,7 @@
$Date: 1994/08/12 04:47:52 $
created at: Thu Sep 30 14:18:32 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/regex.c b/regex.c
index e23d33e..bfd604f 100644
--- a/regex.c
+++ b/regex.c
@@ -1633,12 +1633,12 @@ re_compile_fastmap (bufp)
#endif
{
case exactn:
-#if 0 /* The original was: */
+#if 1 /* The original was: */
if (translate)
fastmap[translate[p[1]]] = 1;
else
fastmap[p[1]] = 1;
-#else /* The compiled pattern has already been translated. */
+#else /* The compiled pattern has already been translated. (not true for ruby) */
fastmap[p[1]] = 1;
#endif
break;
@@ -1775,7 +1775,7 @@ re_compile_fastmap (bufp)
for (j = *p++ * BYTEWIDTH - 1; j >= 0; j--)
if (p[j / BYTEWIDTH] & (1 << (j % BYTEWIDTH)))
{
-#if 0 /* The original was: */
+#if 1 /* The original was: */
if (translate)
fastmap[translate[j]] = 1;
else
@@ -2911,7 +2911,9 @@ re_match_2 (pbufp, string1_arg, size1, string2_arg, size2, pos, regs, mstop)
goto fail;
continue;
}
- if ((unsigned char) translate[c] != (unsigned char) *p++)
+ /* compiled code translation needed for ruby */
+ if ((unsigned char) translate[c]
+ != (unsigned char) translate[*p++])
goto fail;
}
while (--mcnt);
diff --git a/ruby.c b/ruby.c
index 50d4570..87bb14b 100644
--- a/ruby.c
+++ b/ruby.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:51 $
created at: Tue Aug 10 12:47:31 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
@@ -421,8 +421,6 @@ ruby_init0(argc, argv, envp)
origargc = argc; origargv = argv; origenvp = envp;
- rb_call_inits();
-
rb_define_variable("$@", &errat, Qnil, Qnil, 0);
errat = str_new2(argv[0]);
rb_define_variable("$VERBOSE", &verbose, Qnil, Qnil, 0);
diff --git a/ruby.h b/ruby.h
index b52bd3c..5786574 100644
--- a/ruby.h
+++ b/ruby.h
@@ -6,7 +6,7 @@
$Date: 1995/01/12 08:54:52 $
created at: Thu Jun 10 14:26:32 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
*************************************************/
diff --git a/sample/MANIFEST b/sample/MANIFEST
index c91c078..93c971b 100644
--- a/sample/MANIFEST
+++ b/sample/MANIFEST
@@ -20,6 +20,7 @@ fib.pl
fib.rb
fib.scm
freq.rb
+from.rb
fullpath.pl
fullpath.rb
gctest.rb
diff --git a/sample/biorhythm.rb b/sample/biorhythm.rb
index eb14ca7..5a452e0 100644
--- a/sample/biorhythm.rb
+++ b/sample/biorhythm.rb
@@ -76,9 +76,9 @@ end
#
parseArgs(0, nil, "vg", "D:", "sdate", "date:", "birthday:", "days:")
-printf($stderr, "\n")
-printf($stderr, "Biorhythm (c) 1987-1994 V3.0\n")
-printf($stderr, "\n")
+printf(STDERR, "\n")
+printf(STDERR, "Biorhythm (c) 1987-1994 V3.0\n")
+printf(STDERR, "\n")
if ($OPT_D)
dtmp = Time.now.strftime("%Y%m%d")
jh = dtmp[0,4].to_i
@@ -94,11 +94,11 @@ else
if ($OPT_birthday)
dtmp = $OPT_birthday
else
- printf($stderr, "Birthday (YYYYMMDD) : ")
- dtmp = $stdin.gets.chop
+ printf(STDERR, "Birthday (YYYYMMDD) : ")
+ dtmp = STDIN.gets.chop
end
if (dtmp.length != 8)
- printf($stderr, "BAD Input Birthday!!\n")
+ printf(STDERR, "BAD Input Birthday!!\n")
exit()
end
jg = dtmp[0,4].to_i
@@ -112,8 +112,8 @@ else
elsif ($OPT_date)
dtmp = $OPT_date
else
- printf($stderr, "Date [<RETURN> for Systemdate] (YYYYMMDD) : ")
- dtmp = $stdin.gets.chop
+ printf(STDERR, "Date [<RETURN> for Systemdate] (YYYYMMDD) : ")
+ dtmp = STDIN.gets.chop
end
if (dtmp.length != 8)
dtmp = Time.now.strftime("%Y%m%d")
@@ -127,8 +127,8 @@ else
elsif ($OPT_g)
ausgabeart = "g"
else
- printf($stderr, "Values for today or Graph (v/g) [default g] : ")
- ausgabeart = $stdin.gets.chop
+ printf(STDERR, "Values for today or Graph (v/g) [default g] : ")
+ ausgabeart = STDIN.gets.chop
end
end
if (ausgabeart == "v")
@@ -151,8 +151,8 @@ else
if ($OPT_D)
ktage = 9
else
- printf($stderr, "Graph for how many days [default 10] : ")
- ktage = $stdin.gets.chop
+ printf(STDERR, "Graph for how many days [default 10] : ")
+ ktage = STDIN.gets.chop
if (ktage == "")
ktage = 9
else
diff --git a/sample/cbreak.rb b/sample/cbreak.rb
index 5d2d849..cbb15d2 100644
--- a/sample/cbreak.rb
+++ b/sample/cbreak.rb
@@ -15,7 +15,7 @@ end
def set_cbreak (on)
tty = "\0" * 256
- $stdin.ioctl(TIOCGETP, tty)
+ STDIN.ioctl(TIOCGETP, tty)
ttys = tty.unpack("C4 S")
if on
ttys[4] |= CBREAK
@@ -25,7 +25,7 @@ def set_cbreak (on)
ttys[4] |= ECHO
end
tty = ttys.pack("C4 S")
- $stdin.ioctl(TIOCSETP, tty)
+ STDIN.ioctl(TIOCSETP, tty)
end
cbreak();
diff --git a/sample/clnt.rb b/sample/clnt.rb
index a687d12..d2c71ec 100644
--- a/sample/clnt.rb
+++ b/sample/clnt.rb
@@ -2,7 +2,7 @@
# usage: ruby clnt.rb [host] port
host=(if $ARGV.length == 2; $ARGV.shift; else "localhost"; end)
print("Trying ", host, " ...")
-$stdout.flush
+STDOUT.flush
s = TCPsocket.open(host, $ARGV.shift)
print(" done\n")
print("addr: ", s.addr.join(":"), "\n")
diff --git a/sample/from.rb b/sample/from.rb
new file mode 100644
index 0000000..f660294
--- /dev/null
+++ b/sample/from.rb
@@ -0,0 +1,100 @@
+#! /usr/local/bin/ruby
+
+$= = TRUE
+
+module ParseDate
+ MONTHS = {
+ 'jan' => 1, 'feb' => 2, 'mar' => 3, 'apr' => 4,
+ 'may' => 5, 'jun' => 6, 'jul' => 7, 'aug' => 8,
+ 'sep' => 9, 'oct' =>10, 'nov' =>11, 'dec' =>12 }
+ MONTHPAT = MONTHS.keys.join('|')
+ DAYPAT = 'mon|tue|wed|thu|fri|sat|sun'
+
+ def ParseDate.parsedate(date)
+ if date.sub(/(#{DAYPAT})/i, ' ')
+ dayofweek = $1
+ end
+ if date.sub(/\s+(\d+:\d+(:\d+)?)/, ' ')
+ time = $1
+ end
+ if date =~ /19\d\d/
+ year = $&
+ end
+ if date.sub(/\s*(\d+)\s+(#{MONTHPAT})\S*\s+/, ' ')
+ dayofmonth = $1
+ monthname = $2
+ elsif date.sub(/\s*(#{MONTHPAT})\S*\s+(\d+)\s+/, ' ')
+ monthname = $1
+ dayofmonth = $2
+ elsif date.sub(/\s*(#{MONTHPAT})\S*\s+(\d+)\D+/, ' ')
+ monthname = $1
+ dayofmonth = $2
+ elsif date.sub(/\s*(\d\d?)\/(\d\d?)/, ' ')
+ month = $1
+ dayofmonth = $2
+ end
+ if monthname
+ month = MONTHS[monthname.tolower]
+ end
+ if ! year && date =~ /\d\d/
+ year = $&
+ end
+ return year, month, dayofmonth
+ end
+
+end
+
+ def parsedate(date)
+ ParseDate.parsedate(date)
+ end
+
+# include ParseDate
+
+if $ARGV[0] == '-w'
+ wait = TRUE
+ $ARGV.shift
+end
+
+$ARGV[0] = '/usr/spool/mail/' + ENV['USER'] if $ARGV.length == 0
+
+$outcount = 0;
+def fromout(date, from, subj)
+ y, m, d = parsedate(date)
+ printf "%-2d/%02d/%02d [%.28s] %.40s\n", y, m, d, from, subj
+ $outcount += 1
+end
+
+while TRUE
+ fields = {}
+ while gets()
+ $_.chop
+ continue if /^From / # skip From-line
+ break if /^[ \t]*$/ # end of header
+ if /^(\S+):\s*(.*)/
+ fields[attr = $1] = $2
+ elsif attr
+ sub(/^\s*/, '')
+ fields[attr] += "\n" + $_
+ end
+ end
+
+ break if ! $_
+
+ fromout fields['Date'], fields['From'], fields['Subject']
+
+ while gets()
+# print $_
+ break if /^From /
+ end
+
+ break if ! $_
+end
+
+if $outcount == 0
+ print "You have no mail.\n"
+ sleep 2 if wait
+elsif wait
+ system "stty cbreak -echo"
+ getc()
+ system "stty cooked echo"
+end
diff --git a/sample/io.rb b/sample/io.rb
index c3c1a47..c12e4f4 100644
--- a/sample/io.rb
+++ b/sample/io.rb
@@ -1,7 +1,7 @@
# IO test
# usage: ruby io.rb file..
-home = getenv("HOME")
+home = ENV["HOME"]
home.sub("m", "&&")
print(home, "\n")
print(home.reverse, "\n")
diff --git a/sample/ruby-mode.el b/sample/ruby-mode.el
index 20e1abe..aa91be3 100644
--- a/sample/ruby-mode.el
+++ b/sample/ruby-mode.el
@@ -321,12 +321,12 @@ An end of a defun is found by moving forward from the beginning of one."
(defun ruby-reindent-then-newline-and-indent ()
(interactive "*")
- (save-excursion
- (delete-region (point) (progn (skip-chars-backward " \t") (point))))
(insert ?\n)
(save-excursion
(forward-line -1)
- (indent-according-to-mode))
+ (indent-according-to-mode)
+ (end-of-line)
+ (delete-region (point) (progn (skip-chars-backward " \t") (point))))
(indent-according-to-mode))
(defun ruby-encomment-region (beg end)
diff --git a/sample/svr.rb b/sample/svr.rb
index 91faa56..23b2bf7 100644
--- a/sample/svr.rb
+++ b/sample/svr.rb
@@ -2,7 +2,9 @@
# usage: ruby svr.rb
gs = TCPserver.open(0)
-printf("server port is on %d\n", gs.port)
+addr = gs.addr
+addr.shift
+printf("server is on %d\n", addr.join(":"))
socks = [gs]
while TRUE
@@ -10,7 +12,9 @@ while TRUE
if nsock == nil; continue end
for s in nsock[0]
if s == gs
- socks.push(s.accept)
+ ns = s.accept
+ socks.push(ns)
+ print(s, " is accepted\n")
else
if s.eof
print(s, " is gone\n")
diff --git a/sample/time.rb b/sample/time.rb
index b0ef065..715d98a 100755
--- a/sample/time.rb
+++ b/sample/time.rb
@@ -5,4 +5,4 @@ system(cmd)
e = Time.now
ut, st, cut, cst = Time.times
total = (e - b).to_f
-printf $stderr, "%11.1f real %11.1f user %11.1f sys\n", total, cut, cst
+printf STDERR, "%11.1f real %11.1f user %11.1f sys\n", total, cut, cst
diff --git a/sample/trojan.rb b/sample/trojan.rb
index b42fd16..2024da0 100644
--- a/sample/trojan.rb
+++ b/sample/trojan.rb
@@ -1,5 +1,5 @@
#! /usr/local/bin/ruby
-path = $ENV['PATH'].split(/:/)
+path = ENV['PATH'].split(/:/)
for dir in path
if File.d(dir)
diff --git a/spec b/spec
index 42849d5..cf7e380 100644
--- a/spec
+++ b/spec
@@ -86,8 +86,8 @@ tab) CR(carriage return)(form feed)Ǥ롥(newline)
a +
b
-Τ褦˹ԤǽꡤιԤ³Ȥʾζ
-ڤȤƤǧ롥
+Τ褦˹ԤǽꡤιԤ³Ȥ(Ǹʸ
+黻Ҥ뤤`,'Ǥ)ζڤȤǧ롥
* ץ
@@ -96,19 +96,17 @@ tab) CR(carriage return)(form feed)Ǥ롥(newline)
print "hello world!\n"
ץϼ¤٤ΤǤ롥ȼδ֤ϥߥ(`;')ޤϲ
-ԤǶڤ()
-
- ιԤ˷³뤳ȤʻˤϲԤϼζڤˤʤʤ
+ԤǶڤ롥
*
-RubyǤnilʳɾ롥CPerl ʤɤȤϰۤʤꡤ0
+RubyǤnilʳɾ롥CPerlʤɤȤϰۤʤꡤ0
""(ʸ)ϵȤɾʤΤǵĤ뤳ȡ
** ʸ
- "..." # ХååβѿŸ
- '...' # Хååβʤ(\\\'ϲ᤹)
+֥륯(`"')dz줿ʸϥХåå³ʸʲ
+Τ褦˲ᤵ롥
Хåå嵭ˡ
@@ -125,17 +123,14 @@ RubyǤnilʳɾ롥CPerl ʤɤȤϰۤʤꡤ0
\^c ȥʸ(cASCIIʸ)
\C-c ȥʸ(Ʊ)
\M-c ᥿ʸ(c|0x80)
- \ʳ ʸΤ
-
-ʸ󼰤󿷤ʸ󥪥֥ȤΤǡʸƤ
-ƤȤȤʸѤʤ
+ \x ʸxΤ
-ѿŸ
+ޤ`#'ˤѿŸԤ롥󥰥륯(`'')dz
+ʸϡ`\\'(Хåå夽Τ)`\''(󥰥륯)
+ơʸȤβԤʤ
-֥륯(`"')ǰϤޤ줿ʸɽǤ `#{ѿ̾}'Ȥ
-ѿƤŸ뤳ȤǤ롥ѿѿ(`$',`@')ǻ
-ޤˤ`#ѿ̾'ȤǤŸǤ롥ʸ`#'³ʸ
-`{',`$',`@'ǤʤСΤޤ`#'ȤƲᤵ롥
+ʸ󼰤󿷤ʸ󥪥֥ȤΤǡʸƤ
+Ƥ⡤ȤȤʸѤʤ
** ޥɽ
@@ -146,7 +141,8 @@ RubyǤshΤ褦˥ޥɤμ¹Է̤ʸƥΤ褦˻ȤȤ
** ɽ
- /.../[i]
+`/'ǰϤޤ줿ʸɽɽ`/'θʸ`i'Ϳ
+줿ˤϡɽϥޥåʸʸζ̤򤷤ʤ
^ Ƭ
$
@@ -168,8 +164,7 @@ RubyǤshΤ褦˥ޥɤμ¹Է̤ʸƥΤ褦˻ȤȤ
|
( ) ɽޤȤ
-¾ʸƱХåå嵭ˡѿŸͭǤ롥ɽ
-θiĤˤʸʸΰ㤤̵뤹롥
+¾ʸƱХåå嵭ˡѿŸͭǤ롥
** 磻ɥɼ
@@ -182,6 +177,14 @@ RubyǤshΤ褦˥ޥɤμ¹Է̤ʸƥΤ褦˻ȤȤ
¾ʸƱХåå嵭ˡѿŸͭǤ롥
+** ѿŸ
+
+֥륯(`"')ǰϤޤ줿ʸ󼰡ޥʸɽ
+ӥ磻ɥɼǤ`#{ѿ̾}'ȤѿƤŸ
+ȤǤ롥ѿѿ(`$',`@')ǻϤޤˤ`#ѿ̾'Ȥ
+ǤŸǤ롥ʸ`#'³ʸ `{',`$',`@'ǤʤСΤޤ
+ʸ`#'ȤƲᤵ롥
+
** ͥƥ
123
@@ -237,11 +240,11 @@ Rubyѿϥ(ͭϰ)ȼ̿(ͭ)ˤä4ʬव졤
FOOBAR
-ʸǻϤޤ뼱̻ҤϤϥ饹ؤΥǤꡤΥ饹
-Υ֥饹Υ󥹥󥹤黲ȤǤ롥ؤϥȥåץ٥롤
-ʤ᥽åɤǤ٥ǤΤǽǤ롥ѿϥ饹
-֤ͤͭ졤ͤѹ뤳ȤǤʤ饹
-μ̿ϥ饹μ̿
+ʸǻϤޤ뼱̻Ҥϥ饹ؤΥǤꡤΥ饹Ƥ
+֥饹ΥǻȤǤ롥ؤϥȥåץ٥롤ʤ
+᥽åɤǤ٥ǤΤ߲ǽǤ롥ѿϥ饹֤ͤ
+ͭ졤ͤѹ뤳ȤǤʤ饹μ̿
+饹μ̿
饹ϼưŪΤǡ饹̾Ǥ롥
@@ -254,8 +257,10 @@ Rubyѿϥ(ͭϰ)ȼ̿(ͭ)ˤä4ʬव졤
ʸޤ`_'ǻϤޤ뼱̻ҤϥѿؤΥǤ롥
ʤѿͤnilǤ
-ѿΥפϼ̿⤽Υ֥åνޤ(ȥåץ٥Υ
-ѿϥץνλޤ)Ǥ롥
+ѿΥפϥ֥åϰ(᥽åǤϥ᥽åɤν
+ޤǡ饹/⥸塼ǤϤνޤ)Ǥ롥̿⤽
+֥åνޤ(ȥåץ٥Υѿϥץνλޤ)
+롥
*** ѿ
@@ -274,7 +279,6 @@ Rubyѿϥ(ͭϰ)ȼ̿(ͭ)ˤä4ʬव졤
:
(1+2)*3
- (foo();bar())
ϳ̤ˤäƥ롼ԥ󥰤뤳ȤǤ롥
@@ -352,10 +356,12 @@ Rubyѿϥ(ͭϰ)ȼ̿(ͭ)ˤä4ʬव졤
foo -1 # ѿfoo - 1
쥷Фꤷ᥽åɸƤӽФǤϤξ1Ĥʤˤ
-άǤ롥
+άǤ(쥷Фꤷʤ硤̤Ĥʤȥѿ
+ȤȤƲᤵ)
-᥽å̾ȤƤǤդμ̻ҤѤ뤳ȤǤ롥ѿ̾Ȥϼ̻Ҥ
-֤̾㤦ΤǽʣƤ⹽ʤ
+᥽å̾ȤƤǤդμ̻ҤѤ뤳ȤǤ롥ǽʸʸ
+Ǥ⾮ʸǤ⹽ʤѿ̾Ȥϼ̻Ҥ֤̾㤦ΤǽʣƤ
饹ʸγǻꤵ줿᥽åɤȥ饹Moduleunexport᥽åɤ
ꤵ줿᥽åɤϴؿŪ᥽åɤȸƤФ졤ؿǤƤӽФ
@@ -516,9 +522,9 @@ Rubyѿϥ(ͭϰ)ȼ̿(ͭ)ˤä4ʬव졤
Ǥ( 1 `[' 2.. `]' `=' n)
- 1. `[]=' (2..)
+ 1. `[]=' (2.., n)
-ʳ2黻( 黻 )
+ʳ2黻(1 黻 2)
1. 黻 (2)
@@ -535,9 +541,9 @@ Rubyѿϥ(ͭϰ)ȼ̿(ͭ)ˤä4ʬव졤
.. ]
end
-ȽǼ1ξ˼1ɾ롥ʳξϼ2ɾ
-롥Rubyifelse ifǤelifǤʤelsififϢ³ԤʤȤ
-դ뤳ȡ
+ȽǼRubyifelse ifǤelifǤʤelsififϢ³Ԥʤ
+Ȥդ뤳ȡ郎ΩƼ¹Ԥ֤ͤ¹Ԥʤä
+ͤnil
ifξȽμǤʸɽƥϼ$_=~ ƥפ
άǤȤߤʤ롥
@@ -613,9 +619,8 @@ orξդμǤʸɽƥϼ$_=~ ƥפξά
1ˤʤޤǤϵ֤θϼ2֤ޤǤϿ֤2
ˤʤо֤ϵ롥
-黻`...'ξդϾPǤꡤ `...'ξդμǤʸ
-ɽƥϼ$_=~ ƥפξά$.==פξά
-Ȳᤵ롥
+`...'ξդμǤʸɽƥϼ$_=~ ƥפξά
+ϡ$.==פξάȲᤵ롥
** NOT
@@ -626,7 +631,6 @@ orξդμǤʸɽƥϼ$_=~ ƥפξά
`!'Ǥʸɽƥϼ$_=~ ƥפξάǤȤ
ʤ롥
-
1 `!=' 2
!(1 == 2)פξά
@@ -663,9 +667,6 @@ whileξȽμǤʸɽƥϼ$_=~ ƥ
ƥ졼θƤӽФϰʲιʸǹԤʤ롥
-ƥ졼Ȥ湽¤(ä˥롼)ݲΤѤ᥽åɤ
-Ǥ롥ƥ졼θƤӽФϰʲιʸǹԤʤ롥
-
`{' ռ.. `|' .. `}'
ּפ֥åȤꤷּפΥ᥽åɤ򥤥ƥ졼Ȥɾ
@@ -673,7 +674,7 @@ whileξȽμǤʸɽƥϼ$_=~ ƥ
쥷Фɽ䡤μϥƥ졼ȤƤϸƤӽФʤּ
ʣμޤơƥ졼Ȥƽ˸ƤФ롥
-ƥ졼yield¹Ԥȡǻꤵ줿ͤdoǻꤵ
+ƥ졼yield¹Ԥȡǻꤵ줿ͤռǻꤵ
줿ѿ졤֥å¹Ԥ롥֥åμ¹ԤλȤ
ͤ yieldͤȤ֤롥᥽åɤƥ졼ȤƸƤӽ
줿ɤϥ᥽åiterator_p()ͤΤ뤳ȤǤ롥ˤ
@@ -714,11 +715,12 @@ yieldΰγ̤ۣǤʤ¤άǤ롥
㳰ȯ롥åͿ줿ˤȯե
ֹ̾򥷥ƥѿ`$@'ˡå`$!'˥åȤ롥
-failΰγ̤ۣǤʤ¤άǤ롥
+failΰγ̤ϾάǤ롥
** BEGIN
-ʣμޤȤ뤿begin롥beginηϰʲ̤Ǥ롥
+ʣμޤȤ뤿㳰Τbegin롥beginη
+ʲ̤Ǥ롥
begin
..
@@ -729,10 +731,10 @@ failΰγ̤ۣǤʤ¤άǤ롥
end
beginͤϰֺǸɾ줿ͤǤ롥beginνȯ
-㳰resqueͤ뤳Ȥ롥ξͤresqueǺ
-ɾͤǤ롥ensure᤬¸ߤbeginλ
-ɬ(ェλǤʤ㳰, return, break, continue, redoʤ
-ˤæФǤ)ensureμɾ롥
+㳰resqueͤ뤳Ȥ롥ξbeginͤ
+resqueǺǸɾͤǤ롥ensure᤬¸ߤ
+beginλɬ(ェλǤʤ㳰, return, break,
+continue, redoʤɤˤæФǤ)ensureμɾ롥
** RETURN
@@ -750,6 +752,7 @@ break ϥ롼פæФ롥CȰ㤤breakϤäȤ¦Υ롼פæФ
Ѥcase ȴѤϻʤ
** CONTINUE
+
continue
continueϤäȤ¦Υ롼פμη֤Ϥ롥
@@ -776,8 +779,7 @@ beginresqueǻȤbeginϤᤫ¹Ԥ롥㳰Ԥʤä
end
-饹̾Ǥդμ̻ҤǤ(ʸǻϤ뤳Ȥ侩)饹
-ΥͥȤϤǤʤΤ¾Ǥϥ饹Ǥʤ
+饹̾ʸǻϤޤ뼱̻ҤǤ롥
** ⥸塼
@@ -787,8 +789,7 @@ beginresqueǻȤbeginϤᤫ¹Ԥ롥㳰Ԥʤä
end
-⥸塼̾ʸǻϤޤ뼱̻ҤǤ롥饹Ʊ͡⥸塼
-ͥȤǤʤ
+⥸塼̾ʸǻϤޤ뼱̻ҤǤ롥
** ᥽å
@@ -830,23 +831,22 @@ beginresqueǻȤbeginϤᤫ¹Ԥ롥㳰Ԥʤä
ɬפ롥̾᥽åȤϰۤʤꡤðۥ᥽åɤϥ᥽å
ǤͥȤ뤳ȤǤ롥
-ðۥ᥽åɤ̾ϷѾʤ㳰Ȥƥ饹ðۥ᥽åɤϤ
-Υ֥饹ˤѾ롥ؤХ饹ðۥ᥽åɤ¾Υ
-Ȼظƥˤ륯饹᥽åɤƯ򤹤롥
+ðۥ᥽åɤ̾ϷѾʤ㳰Ȥƥ饹ðۥ᥽åɤϤ
+֥饹ˤѾ롥ؤХ饹ðۥ᥽åɤ¾Υ֥
+Ȼظƥˤ륯饹᥽åɤƯ򤹤롥
** INCLUDE
⥸塼򥤥󥯥롼ɤ뤳Ȥˤäơ饹ޤϥ⥸塼˵ǽ
-ɲäǤ롥⥸塼򥤥󥯥롼ɤ硤Υ⥸塼(
-Υ⥸塼뤬˥󥯥롼ɤƤ⥸塼)ƤΥ᥽åɤ
-Ѥ̤Τ򤹤Х󥯥롼ɤϸꤵ줿¿ŷѾȤ롥
-
-¾Υ⥸塼򥤥󥯥롼ɤ빽ϰʲ̤Ǥ롥
+ɲäǤ롥ߤΥ饹ޤϥ⥸塼(ȥåץ٥Ǥ
+Object饹)˻ꤷ⥸塼򥤥󥯥롼ɤ빽ϰʲ̤
+롥
include ⥸塼̾ [`,' ⥸塼̾..]
-ߤΥ饹ޤϥ⥸塼(ȥåץ٥ǤObject饹)˻
-ꤷ⥸塼򥤥󥯥롼ɤ롥
+⥸塼򥤥󥯥롼ɤȡΥ⥸塼(ӤΥ⥸塼뤬
+˥󥯥롼ɤƤ⥸塼)ƤΥ᥽åɤѤ̤Τ
+򤹤Х󥯥롼ɤϸꤵ줿¿ŷѾ(Mixin)Ȥ롥
** ALIAS
@@ -855,8 +855,8 @@ beginresqueǻȤbeginϤᤫ¹Ԥ롥㳰Ԥʤä
alias ᥽å̾1 ᥽å̾2
̾դ줿᥽åɤϡλǤΥ᥽åѤΥ
-åɤƤ⡤Ť᥽åɤƤӽФ줿ΤƱƯ
-롥
+åɤƤ⡤θŤ᥽åɤƤӽФ줿ΤƱ
+Ư򤹤롥
** UNDEF
@@ -866,10 +866,10 @@ beginresqueǻȤbeginϤᤫ¹Ԥ롥㳰Ԥʤä
ꤷ᥽åɤä
-defˤ̾undefˤäȤȥ饹Υ󥿥ե
-򥹡ѡ饹Ωѹ뤳ȤǤ롥᥽åɤself
-˥åäƤ⤢Τǡ褯դʤȴ¸Υ᥽å
-ưʤʤǽ롥
+defˤ̾undefˤäˤäƥ饹Υ󥿥ե
+򥹡ѡ饹Ωѹ뤳ȤǤ롥᥽åɤself
+ ˥åäƤ⤢Τǡ褯դʤȴ¸Υ᥽
+ɤưʤʤǽ롥
* Ȥ߹ߴؿ
@@ -922,10 +922,6 @@ Rubyˤϸ̩ʰ̣ǤϴؿϤʤKernel饹δؿ᥽åɤ(Ƥ
ɸϤʸФͤɤ߹ʸʸ
(ASCII)ɽFixnumǤ롥
- getenv(name)
-
- name˳ĶѿФ$ENV[name]Ʊ
-
gets()
ȤͿ줿ե(ʤɸ)ǹ벾
@@ -1028,11 +1024,6 @@ Rubyˤϸ̩ʰ̣ǤϴؿϤʤKernel饹δؿ᥽åɤ(Ƥ
nilǤʤȤ3Ǥ֤γǤ//
㳰ԤΥ֥ȤǤȤƻġ
- setenv(name, value)
-
- nameǻꤵĶѿvalue˥åȤ롥$ENV[name]=value
- ƱƯ򤹤롥
-
sleep([sec])
secäץμ¹Ԥߤ롥secά줿硤ץ
@@ -1175,10 +1166,6 @@ Rubyˤϸ̩ʰ̣ǤϴؿϤʤKernel饹δؿ᥽åɤ(Ƥ
$DEBUG `-d'ե饰ξ()
- $ENV Ķѿ˥Ϣʸ򥭡ȤͿ
- бĶѿͤ롥Ķѿ¸ߤ
- nil֤롥
-
$FILENAME ۥե`$<'Ǹɤ߹(᥽ågets()
ɤǤ)ե̾$<.filenameƱ
@@ -1190,9 +1177,6 @@ Rubyˤϸ̩ʰ̣ǤϴؿϤʤKernel饹δؿ᥽åɤ(Ƥ
$VERBOSE `-v'ե饰ξ()
- $VERSION rubyΥС򼨤ʸ
-
-
TRUE t
FALSE nil
@@ -1212,6 +1196,16 @@ Rubyˤϸ̩ʰ̣ǤϴؿϤʤKernel饹δؿ᥽åɤ(Ƥ
ϴˤƱǤϤʤFALSE˴ؤƤϡΤ褦
ʤ
+ STDIN ɸ
+ STDOUT ɸ
+ STDERR ɸ२顼
+
+ ENV Ķѿ˥Ϣʸ򥭡ȤͿ
+ бĶѿͤ롥Ķѿ¸ߤ
+ nil֤롥
+
+ VERSION rubyΥС򼨤ʸ
+
* Ȥ߹ߥ饹ȥ⥸塼
** Array(饹)
@@ -3867,9 +3861,9 @@ RubyθͤϿ¿θαƶƤ. ʲˤΤϤμ
C, Perl, CLU, Sather, CLOS, Eiffel, Icon, tcl, AWK, bourne shell,
Smalltalk, Emacs Lisp.
-ޤrubyθͤꤹ뤿˶ϤƲäʲˤ
+ޤrubyθͤꤹ뤿˶ϤƲäʲˤ롥
- ͷƣϺ¼ΣţáغDEC
+ ͷƣϺ¼Σţáغܣģţá
ʤֺ.ٻ(ɾά)
-------------------------------------------------------
Local variables:
diff --git a/sprintf.c b/sprintf.c
index c74ec08..e75f0bb 100644
--- a/sprintf.c
+++ b/sprintf.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:42:59 $
created at: Fri Oct 15 10:39:26 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/string.c b/string.c
index 0b23655..a107a7f 100644
--- a/string.c
+++ b/string.c
@@ -6,7 +6,7 @@
$Date: 1995/01/10 10:43:01 $
created at: Mon Aug 9 17:12:58 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
@@ -358,7 +358,6 @@ Fstr_cmp(str1, str2)
return INT2FIX(result);
}
-Regexp * make_regexp();
VALUE Freg_match();
extern VALUE C_Glob;
@@ -376,7 +375,7 @@ Fstr_match(x, y)
case T_STRING:
reg = re_regcomp(y);
- start = research(reg, x, 0, ignorecase);
+ start = research(reg, x, 0);
if (start == -1) {
return FALSE;
}
@@ -403,7 +402,7 @@ Fstr_match2(str)
Fail("$_ is not a string");
reg = re_regcomp(str);
- start = research(reg, rb_lastline, 0, ignorecase);
+ start = research(reg, rb_lastline, 0);
if (start == -1) {
return Qnil;
}
@@ -451,7 +450,7 @@ Fstr_index(argc, argv, str)
switch (TYPE(sub)) {
case T_REGEXP:
- pos = research(sub, str, pos, ignorecase);
+ pos = research(sub, str, pos);
break;
case T_STRING:
@@ -684,7 +683,7 @@ str_sub(str, pat, val, once)
int beg, end, offset, n;
for (offset=0, n=0;
- (beg=research(pat, str, offset, ignorecase)) >= 0;
+ (beg=research(pat, str, offset)) >= 0;
offset=RREGEXP(pat)->ptr->regs.start[0]+STRLEN(val)) {
end = RREGEXP(pat)->ptr->regs.end[0]-1;
sub = re_regsub(val);
@@ -1034,14 +1033,14 @@ static VALUE
Fstr_toupper(str)
struct RString *str;
{
- return Fstr_upcase(str_new(str_new(str->ptr, str->len)));
+ return Fstr_upcase(str_new(str->ptr, str->len));
}
static VALUE
Fstr_tolower(str)
struct RString *str;
{
- return Fstr_downcase(str_new(str_new(str->ptr, str->len)));
+ return Fstr_downcase(str_new(str->ptr, str->len));
}
struct tr {
@@ -1343,7 +1342,7 @@ Fstr_split(argc, argv, str)
#define LMATCH spat->ptr->regs.start
#define RMATCH spat->ptr->regs.end
- while ((end = research(spat, str, start, ignorecase)) >= 0) {
+ while ((end = research(spat, str, start)) >= 0) {
if (start == end && LMATCH[0] == RMATCH[0]) {
if (last_null == 1) {
if (ismbchar(str->ptr[beg]))
diff --git a/struct.c b/struct.c
index a368605..8ba8f43 100644
--- a/struct.c
+++ b/struct.c
@@ -4,7 +4,7 @@
$Author: matz $
$Date: 1995/01/10 10:43:02 $
- created at: Tue Mar 22 18:44:30 JST 1994
+ created at: Tue Mar 22 18:44:30 JST 1995
************************************************/
diff --git a/time.c b/time.c
index 73f3837..ae2aa4f 100644
--- a/time.c
+++ b/time.c
@@ -6,7 +6,7 @@
$Date: 1994/12/06 09:30:28 $
created at: Tue Dec 28 14:31:59 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
diff --git a/variable.c b/variable.c
index 9ac538c..b65a1fc 100644
--- a/variable.c
+++ b/variable.c
@@ -335,22 +335,29 @@ rb_ivar_set(id, val)
}
VALUE
-rb_const_get(id)
+rb_const_get(class, id)
+ struct RClass *class;
ID id;
{
- struct RClass *class = (struct RClass*)CLASS_OF(Qself);
VALUE value;
while (class) {
if (class->iv_tbl && st_lookup(class->iv_tbl, id, &value)) {
return value;
}
- class = class->super;
+ if (BUILTIN_TYPE(class) == T_MODULE) {
+ class = RCLASS(C_Object);
+ }
+ else {
+ class = class->super;
+ }
}
/* pre-defined class */
if (st_lookup(class_tbl, id, &value)) return value;
+ /* here comes autoload code in the future. */
+
Fail("Uninitialized constant %s", rb_id2name(id));
/* not reached */
}
@@ -366,6 +373,8 @@ rb_const_bound(class, id)
}
class = class->super;
}
+ if (st_lookup(class_tbl, id, Qnil))
+ return TRUE;
return FALSE;
}
diff --git a/version.c b/version.c
index 27a3182..38af6d7 100644
--- a/version.c
+++ b/version.c
@@ -7,7 +7,7 @@
$Date: 1995/01/12 08:54:54 $
created at: Thu Sep 30 20:08:01 JST 1993
- Copyright (C) 1994 Yukihiro Matsumoto
+ Copyright (C) 1995 Yukihiro Matsumoto
************************************************/
@@ -15,14 +15,11 @@
#include "version.h"
#include <stdio.h>
-static VALUE rb_version;
-
-VALUE rb_readonly_hook();
+extern VALUE C_Kernel;
Init_version()
{
- rb_version = str_new2(RUBY_VERSION);
- rb_define_variable("$VERSION", &rb_version, Qnil, rb_readonly_hook, 0);
+ rb_define_const(C_Kernel, "VERSION", str_new2(RUBY_VERSION));
}
show_version()
@@ -32,6 +29,6 @@ show_version()
show_copyright()
{
- fprintf(stderr, "ruby - Copyright (C) 1994 Yukihiro Matsumoto\n");
+ fprintf(stderr, "ruby - Copyright (C) 1995 Yukihiro Matsumoto\n");
exit(0);
}
diff --git a/version.h b/version.h
index f94892d..4ef6289 100644
--- a/version.h
+++ b/version.h
@@ -1,2 +1,2 @@
-#define RUBY_VERSION "0.67"
-#define VERSION_DATE "95/02/21"
+#define RUBY_VERSION "0.68"
+#define VERSION_DATE "95/02/23"