summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYukihiro Matsumoto <matz@ruby-lang.org>1995-02-21 09:56:56 (GMT)
committerTakashi Kokubun <takashikkbn@gmail.com>2019-08-17 13:09:31 (GMT)
commit2f106ab85c4f4e171374aee261f5a12bdd923c41 (patch)
tree6810f0a05ad8df30a269eb522eea5f77186b90c6
parentc080fb6d10bbcb697b6ba16e640de8db3f1973d0 (diff)
version 0.67v0_67
https://cache.ruby-lang.org/pub/ruby/1.0/ruby-0.66-0.67.diff.gz 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文字が大文字の識別子に変 更.それにともないクラスは定数となった. * eval.c: クラス定義内のselfがクラス定義外部のthe_classだった. * variable.c(rb_name_class): クラス名をインスタンス変数に格納する. Thu Feb 16 15:36:17 1995 Yukihiro Matsumoto (matz@ix-02) * parse.y: BLOCKをbraceで表現する文法に変更したものを作ってみる. MLに提示してみるが反応がない. * object.c(do,forever): なくした. Wed Feb 15 13:20:49 1995 Yukihiro Matsumoto (matz@ix-02) * re.c(new): 第2引数が与えられて,かつnilでないときだけ設定するよ うに(以前はnilの時にも設定を行なっていた). * parse.y(parse_regexp): 正規表現リテラルで大文字小文字を無視する かどうか指定できるように. Tue Feb 14 00:55:33 1995 Yukihiro Matsumoto (matz@dyna) * parse.y: (compexpr) -> (expr). Fri Feb 10 16:30:00 1995 Yukihiro Matsumoto (matz@ix-02) * ruby.c(load_file): scriptを読み込む時だけ"#!"の解析を行うように. * ruby.c(readin): ファイル読み込み時に先頭に"#!"があり,rubyに引数 が与えられていれば,その引数も有効になる. * parse.y(yylex): コメント行の終りが`\'であった時,次の行に継続し ているとみなすようにした.
-rw-r--r--ChangeLog38
-rw-r--r--array.c4
-rw-r--r--class.c55
-rw-r--r--dict.c1
-rw-r--r--dir.c3
-rw-r--r--error.c2
-rw-r--r--eval.c53
-rw-r--r--node.h4
-rw-r--r--object.c24
-rw-r--r--parse.y208
-rw-r--r--process.c6
-rw-r--r--re.c13
-rw-r--r--ruby.124
-rw-r--r--ruby.c82
-rw-r--r--sample/Artistic117
-rw-r--r--sample/MANIFEST3
-rw-r--r--sample/attr.rb2
-rw-r--r--sample/cbreak.rb24
-rw-r--r--sample/const.rb16
-rw-r--r--sample/evaldef.rb4
-rw-r--r--sample/export.rb2
-rw-r--r--sample/getopts.rb16
-rwxr-xr-xsample/getopts.test2
-rwxr-xr-xsample/less.rb2
-rw-r--r--sample/opt_x.rb10
-rw-r--r--sample/opt_x.test10
-rw-r--r--sample/ruby-mode.el16
-rw-r--r--sample/svr.rb2
-rw-r--r--sample/tt.rb2
-rw-r--r--spec218
-rw-r--r--string.c12
-rw-r--r--variable.c60
-rw-r--r--version.h4
33 files changed, 500 insertions, 539 deletions
diff --git a/ChangeLog b/ChangeLog
index 838091a..f66a446 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,41 @@
+Mon Feb 20 16:10:14 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * parse.y(yylex): `%̻'顤1ʸʸμ̻Ҥ
+ ˤȤʤ饹Ȥʤä
+
+ * eval.c: 饹self饹the_classä
+
+ * variable.c(rb_name_class): 饹̾򥤥󥹥ѿ˳Ǽ롥
+
+Thu Feb 16 15:36:17 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * parse.y: BLOCKbraceɽʸˡѹΤäƤߤ롥
+ ML󼨤Ƥߤ뤬ȿʤ
+
+ * object.c(do,forever): ʤ
+
+Wed Feb 15 13:20:49 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * re.c(new): 2ͿơnilǤʤȤꤹ
+ (nilλˤԤʤäƤ)
+
+ * parse.y(parse_regexp): ɽƥʸʸ̵뤹
+ ɤǤ褦ˡ
+
+Tue Feb 14 00:55:33 1995 Yukihiro Matsumoto (matz@dyna)
+
+ * parse.y: (compexpr) -> (expr).
+
+Fri Feb 10 16:30:00 1995 Yukihiro Matsumoto (matz@ix-02)
+
+ * ruby.c(load_file): scriptɤ߹"#!"βϤԤ褦ˡ
+
+ * ruby.c(readin): եɤ߹߻Ƭ"#!"ꡤruby˰
+ ͿƤСΰͭˤʤ롥
+
+ * parse.y(yylex): ȹԤν꤬`\'ǤäιԤ˷³
+ ƤȤߤʤ褦ˤ
+
Thu Feb 9 16:18:37 1995 Yukihiro Matsumoto (matz@ix-02)
* parse.y: protectbeginѹbegin..end㳰Ǥʤ
diff --git a/array.c b/array.c
index 28d755b..895a679 100644
--- a/array.c
+++ b/array.c
@@ -262,9 +262,7 @@ range_beg_end(range, begp, lenp, len)
if (beg > end) {
int tmp;
- if (verbose) {
- Warning("start %d is bigger than end %d", beg, end);
- }
+ Warning("start %d is bigger than end %d", beg, end);
tmp = beg; beg = end; end = tmp;
}
*begp = beg; *lenp = end - beg + 1;
diff --git a/class.c b/class.c
index 6c790b7..2d05183 100644
--- a/class.c
+++ b/class.c
@@ -16,6 +16,7 @@
#include "st.h"
struct st_table *new_idhash();
+extern st_table *rb_class_tbl;
extern VALUE C_Class;
extern VALUE C_Module;
@@ -81,7 +82,6 @@ rb_define_class_id(id, super)
struct RClass *cls = (struct RClass*)class_new(super);
rb_name_class(cls, id);
-
/* make metaclass */
RBASIC(cls)->class = single_class_new(super?super->class:C_Class);
@@ -93,7 +93,29 @@ rb_define_class(name, super)
char *name;
VALUE super;
{
- return rb_define_class_id(rb_intern(name), super);
+ VALUE class;
+ ID id;
+
+ id = rb_intern(name);
+ class = rb_define_class_id(id, super);
+ st_add_direct(rb_class_tbl, id, class);
+
+ return class;
+}
+
+rb_define_class_under(under, name, super)
+ VALUE under;
+ char *name;
+ VALUE super;
+{
+ VALUE class;
+ ID id;
+
+ id = rb_intern(name);
+ class = rb_define_class_id(id, super);
+ rb_const_set(under, id, class);
+
+ return class;
}
VALUE
@@ -112,9 +134,11 @@ VALUE
rb_define_module_id(id)
ID id;
{
+ extern st_table *rb_class_tbl;
struct RClass *mdl = (struct RClass*)module_new();
rb_name_class(mdl, id);
+
return (VALUE)mdl;
}
@@ -122,7 +146,28 @@ VALUE
rb_define_module(name)
char *name;
{
- return rb_define_module_id(rb_intern(name));
+ VALUE module;
+ ID id;
+
+ id = rb_intern(name);
+ module = rb_define_module_id(id);
+ st_add_direct(rb_class_tbl, id, module);
+
+ return module;
+}
+
+rb_define_module_under(under, name)
+ VALUE under;
+ char *name;
+{
+ VALUE module;
+ ID id;
+
+ id = rb_intern(name);
+ module = rb_define_module_id(id);
+ rb_const_set(under, id, module);
+
+ return module;
}
static struct RClass *
@@ -189,9 +234,7 @@ rb_add_method(class, mid, node, noex)
if (class == Qnil) class = (struct RClass*)C_Object;
if (st_lookup(class->m_tbl, mid, &body)) {
- if (verbose) {
- Warning("redefine %s", rb_id2name(mid));
- }
+ Warning("redefine %s", rb_id2name(mid));
rb_clear_cache(body);
}
body = NEW_METHOD(node, noex);
diff --git a/dict.c b/dict.c
index fa4ffc0..b973fb7 100644
--- a/dict.c
+++ b/dict.c
@@ -579,7 +579,6 @@ Init_Dict()
hash = rb_intern("hash");
C_Dict = rb_define_class("Dict", C_Object);
- rb_name_class(C_Dict, rb_intern("Hash")); /* alias */
rb_include_module(C_Dict, M_Enumerable);
diff --git a/dir.c b/dir.c
index 755290f..73478a7 100644
--- a/dir.c
+++ b/dir.c
@@ -241,8 +241,7 @@ Init_Dir()
{
extern VALUE M_Enumerable;
- C_Dir = rb_define_class("Directory", C_Object);
- rb_name_class(C_Dir, rb_intern("Dir")); /* alias */
+ C_Dir = rb_define_class("Dir", C_Object);
rb_include_module(C_Dir, M_Enumerable);
diff --git a/error.c b/error.c
index e962616..dad7c5f 100644
--- a/error.c
+++ b/error.c
@@ -85,6 +85,8 @@ Warning(fmt, va_alist)
char buf[BUFSIZ];
va_list args;
+ if (!verbose) return;
+
sprintf(buf, "warning: %s", fmt);
va_start(args);
diff --git a/eval.c b/eval.c
index fa61e47..0287e9f 100644
--- a/eval.c
+++ b/eval.c
@@ -115,9 +115,7 @@ rb_alias(class, name, def)
}
if (st_lookup(class->m_tbl, name, &old)) {
- if (verbose) {
- Warning("redefine %s", rb_id2name(name));
- }
+ Warning("redefine %s", rb_id2name(name));
rb_clear_cache(old->nd_body);
}
@@ -1017,11 +1015,7 @@ rb_eval(node)
Bug("unexpected local variable");
return the_scope->local_vars[node->nd_cnt];
- case NODE_GVAR:
- return rb_gvar_get(node->nd_entry);
- case NODE_IVAR:
- return rb_ivar_get(node->nd_vid);
- case NODE_MVAR:
+ case NODE_LVAR2:
if (the_scope->flags & SCOPE_MALLOCED) {
ID id = node->nd_vid, *tbl = the_scope->local_tbl;
int i, len = tbl[0];
@@ -1034,7 +1028,13 @@ rb_eval(node)
return the_scope->local_vars[i];
}
}
- return rb_mvar_get(node->nd_vid);
+ Warning("local var %s not initialized", rb_id2name(node->nd_vid));
+ return Qnil;
+
+ case NODE_GVAR:
+ return rb_gvar_get(node->nd_entry);
+ case NODE_IVAR:
+ return rb_ivar_get(node->nd_vid);
case NODE_CVAR:
{
@@ -1189,56 +1189,55 @@ rb_eval(node)
else {
super = C_Object;
}
- if (class = rb_id2class(node->nd_cname)) {
- if (verbose) {
- Warning("redefine class %s", rb_id2name(node->nd_cname));
- }
+ if (verbose && rb_id2class(node->nd_cname)) {
+ Warning("redefine class %s", rb_id2name(node->nd_cname));
}
- PUSH_SELF((VALUE)the_class);
+ class = rb_define_class_id(node->nd_cname, super);
+ rb_const_set(the_class, node->nd_cname, class);
PUSH_CLASS();
- the_class = (struct RClass*)
- rb_define_class_id(node->nd_cname, super);
+ 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_CLASS();
POP_SELF();
+ POP_CLASS();
if (state) JUMP_TAG(state);
+ return class;
}
- return Qnil;
case NODE_MODULE:
{
VALUE module;
- if (module = rb_id2class(node->nd_cname)) {
- if (verbose) {
- Warning("redefine module %s", rb_id2name(node->nd_cname));
- }
+ if (verbose && rb_id2class(node->nd_cname)) {
+ Warning("redefine module %s", rb_id2name(node->nd_cname));
}
- PUSH_SELF((VALUE)the_class);
+ module = rb_define_module_id(node->nd_cname);
+ rb_const_set(the_class, node->nd_cname, module);
PUSH_CLASS();
- the_class = (struct RClass*)rb_define_module_id(node->nd_cname);
+ 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_CLASS();
POP_SELF();
+ POP_CLASS();
if (state) JUMP_TAG(state);
+ return module;
}
- return Qnil;
case NODE_INC:
{
struct RClass *module;
- module = (struct RClass*)rb_id2class(node->nd_modl);
+ module = (struct RClass*)rb_const_get(node->nd_modl);
if (module == Qnil) {
Fail("undefined module %s", rb_id2name(node->nd_modl));
}
diff --git a/node.h b/node.h
index f98be64..9af249e 100644
--- a/node.h
+++ b/node.h
@@ -51,9 +51,9 @@ enum node_type {
NODE_FAIL,
NODE_YIELD,
NODE_LVAR,
+ NODE_LVAR2,
NODE_GVAR,
NODE_IVAR,
- NODE_MVAR,
NODE_CVAR,
NODE_CONST,
NODE_LIT,
@@ -211,8 +211,8 @@ typedef struct RNode {
#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_MVAR(v) newnode(NODE_MVAR,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)
diff --git a/object.c b/object.c
index a35e683..6266f77 100644
--- a/object.c
+++ b/object.c
@@ -356,24 +356,15 @@ VALUE boot_defclass(name, super)
char *name;
VALUE super;
{
+ extern st_table *rb_class_tbl;
struct RClass *obj = (struct RClass*)class_new(super);
+ ID id = rb_intern(name);
- rb_name_class(obj, rb_intern(name));
+ rb_name_class(obj, id);
+ st_add_direct(rb_class_tbl, id, obj);
return (VALUE)obj;
}
-Fdo()
-{
- return rb_yield(Qnil);
-}
-
-Fforever()
-{
- for (;;) {
- rb_yield(Qnil);
- }
-}
-
VALUE TopSelf;
VALUE TRUE = 1;
@@ -437,9 +428,6 @@ Init_Object()
rb_define_private_method(C_Kernel, "sprintf", Fsprintf, -1);
rb_define_alias(C_Kernel, "format", "sprintf");
- rb_define_private_method(C_Kernel, "do", Fdo, 0);
- rb_define_private_method(C_Kernel, "forever", Fforever, 0);
-
rb_define_private_method(C_Object, "init_object", Fobj_init_object, -1);
rb_define_method(C_Object, "clone", Fobj_clone, 0);
@@ -478,8 +466,8 @@ Init_Object()
TRUE = obj_alloc(C_Object);
rb_define_single_method(TRUE, "to_s", Ftrue_to_s, 0);
- rb_define_const(C_Kernel, "%TRUE", TRUE);
- rb_define_const(C_Kernel, "%FALSE", FALSE);
+ rb_define_const(C_Kernel, "TRUE", TRUE);
+ rb_define_const(C_Kernel, "FALSE", FALSE);
init_object = rb_intern("init_object");
}
diff --git a/parse.y b/parse.y
index 7dabc5d..0566808 100644
--- a/parse.y
+++ b/parse.y
@@ -326,11 +326,11 @@ lhs : variable
$$ = attrset($1, $3, Qnil);
}
-inc_list : IDENTIFIER
+inc_list : CONSTANT
{
$$ = NEW_INC($1);
}
- | inc_list comma IDENTIFIER
+ | inc_list comma CONSTANT
{
$$ = block_append($1, NEW_INC($3));
}
@@ -346,6 +346,7 @@ inc_list : IDENTIFIER
}
fname : IDENTIFIER
+ | CONSTANT
| op
{
lex_state = EXPR_END;
@@ -718,7 +719,7 @@ primary : literal
| primary '{' opt_iter_var '|' compexpr rbrace
{
if (nd_type($1) == NODE_LVAR
- || nd_type($1) == NODE_MVAR) {
+ || nd_type($1) == NODE_CVAR) {
$1 = NEW_CALL(Qnil, $1->nd_vid, Qnil);
}
$$ = NEW_ITER($3, $1, $5);
@@ -775,14 +776,17 @@ primary : literal
$$ = NEW_BEGIN($2, $3, $4);
}
}
- | LPAREN compexpr rparen
+ | LPAREN expr
+ opt_nl
+ rparen
{
$$ = $2;
}
- | CLASS IDENTIFIER superclass
+ | CLASS CONSTANT superclass
{
- if (cur_class || cur_mid || in_single)
- Error("nested class definition");
+ if (cur_mid || in_single)
+ Error("class definition in method body");
+
cur_class = $2;
push_local();
}
@@ -793,10 +797,10 @@ primary : literal
pop_local();
cur_class = Qnil;
}
- | MODULE IDENTIFIER
+ | MODULE CONSTANT
{
- if (cur_class != Qnil)
- Error("nested module definition");
+ if (cur_mid || in_single)
+ Error("module definition in method body");
cur_class = $2;
in_module = 1;
push_local();
@@ -877,12 +881,7 @@ case_body : WHEN args then
}
cases : opt_else
- | WHEN args then
- compexpr
- cases
- {
- $$ = NEW_WHEN($2, $4, $5);
- }
+ | case_body
resque : /* none */
{
@@ -916,7 +915,6 @@ literal : numeric
symbol : fname
| IVAR
| GVAR
- | CONSTANT
numeric : INTEGER
| FLOAT
@@ -947,7 +945,7 @@ superclass : term
{
lex_state = EXPR_BEG;
}
- IDENTIFIER
+ CONSTANT
{
$$ = $3;
}
@@ -1069,6 +1067,9 @@ assoc : arg ASSOC arg
opt_term : /* none */
| term
+opt_nl : /* none */
+ | nl
+
term : sc
| nl
@@ -1158,6 +1159,7 @@ static int
parse_regx()
{
register int c;
+ int casefold = 0;
int in_brack = 0;
int re_start = sourceline;
NODE *list = Qnil;
@@ -1199,6 +1201,13 @@ parse_regx()
if (in_brack)
break;
+ if ('i' == nextc()) {
+ casefold = 1;
+ }
+ else {
+ pushback();
+ }
+
tokfix();
lex_state = EXPR_END;
if (list) {
@@ -1207,11 +1216,13 @@ parse_regx()
list_append(list, NEW_STR(ss));
}
nd_set_type(list, NODE_DREGX);
+ if (casefold) list->nd_cflag = 1;
yylval.node = list;
return DREGEXP;
}
else {
yylval.val = regexp_new(tok(), toklen());
+ if (casefold) FL_SET(yylval.val, FL_USER1);
return REGEXP;
}
case -1:
@@ -1347,7 +1358,6 @@ yylex()
{
register int c;
struct kwtable *low = kwtable, *mid, *high = LAST(kwtable);
- int last;
retry:
switch (c = nextc()) {
@@ -1366,6 +1376,10 @@ retry:
while ((c = nextc()) != '\n') {
if (c == -1)
return 0;
+ if (c == '\\') { /* skip a char */
+ c = nextc();
+ if (c == '\n') sourceline++;
+ }
}
/* fall through */
case '\n':
@@ -1801,22 +1815,13 @@ retry:
return '\\';
case '%':
- if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
- /* class constant */
- newtok();
- tokadd('%');
- c = nextc();
- break;
- }
- else {
- lex_state = EXPR_BEG;
- if (nextc() == '=') {
- yylval.id = '%';
- return OP_ASGN;
- }
- pushback();
- return c;
+ lex_state = EXPR_BEG;
+ if (nextc() == '=') {
+ yylval.id = '%';
+ return OP_ASGN;
}
+ pushback();
+ return c;
case '$':
newtok();
@@ -1844,14 +1849,16 @@ retry:
case '>': /* $>: default output handle */
case '"': /* $": already loaded files */
tokadd(c);
- tokadd('\0');
- goto id_fetch;
+ tokfix();
+ yylval.id = rb_intern(tok());
+ lex_state = EXPR_END;
+ return GVAR;
default:
- if (is_identchar(c))
- break;
- pushback();
- return tok()[0];
+ if (!is_identchar(c)) {
+ pushback();
+ return '$';
+ }
}
break;
@@ -1886,51 +1893,55 @@ retry:
pushback();
tokfix();
- /* See if it is a reserved word. */
- while (low <= high) {
- mid = low + (high - low)/2;
- if (( c = strcmp(mid->name, tok())) == 0) {
- enum lex_state state = lex_state;
- lex_state = mid->state;
- if (state != EXPR_BEG) {
- if (mid->id == IF) return IF_MOD;
- if (mid->id == WHILE) return WHILE_MOD;
- }
- return mid->id;
- }
- else if (c < 0) {
- low = mid + 1;
- }
- else {
- high = mid - 1;
- }
- }
-
- id_fetch:
{
- enum lex_state state = lex_state;
+ int result;
- lex_state = EXPR_END;
- yylval.id = rb_intern(tok());
switch (tok()[0]) {
- case '%':
- return CONSTANT;
case '$':
- return GVAR;
+ result = GVAR;
+ break;
case '@':
- return IVAR;
+ result = IVAR;
+ break;
default:
- if (state == EXPR_FNAME) {
+ /* See if it is a reserved word. */
+ while (low <= high) {
+ mid = low + (high - low)/2;
+ if (( c = strcmp(mid->name, tok())) == 0) {
+ enum lex_state state = lex_state;
+ lex_state = mid->state;
+ if (state != EXPR_BEG) {
+ if (mid->id == IF) return IF_MOD;
+ if (mid->id == WHILE) return WHILE_MOD;
+ }
+ return mid->id;
+ }
+ else if (c < 0) {
+ low = mid + 1;
+ }
+ else {
+ high = mid - 1;
+ }
+ }
+
+ if (lex_state == EXPR_FNAME) {
if ((c = nextc()) == '=') {
- yylval.id &= ~ID_SCOPE_MASK;
- yylval.id |= ID_ATTRSET;
+ tokadd(c);
}
else {
pushback();
}
}
- return IDENTIFIER;
+ if (isupper(tok()[0])) {
+ result = CONSTANT;
+ }
+ else {
+ result = IDENTIFIER;
+ }
}
+ lex_state = EXPR_END;
+ yylval.id = rb_intern(tok());
+ return result;
}
}
@@ -1949,7 +1960,7 @@ var_extend(list, term)
tokadd('#');
pushback();
return list;
- case '@': case '%':
+ case '@':
t = nextc();
pushback();
if (!is_identchar(t)) {
@@ -1998,7 +2009,7 @@ var_extend(list, term)
goto fetch_id;
}
/* through */
- case '@': case '%':
+ case '@':
tokadd(c);
c = nextc();
break;
@@ -2370,7 +2381,7 @@ gettable(id)
if (local_id(id))
return NEW_LVAR(id);
else
- return NEW_MVAR(id);
+ return NEW_LVAR2(id);
}
else if (is_global_id(id)) {
return NEW_GVAR(id);
@@ -2510,9 +2521,7 @@ cond(node)
case NODE_GASGN:
case NODE_IASGN:
case NODE_CASGN:
- if (verbose) {
- Warning("asignment in condition");
- }
+ Warning("asignment in condition");
break;
}
@@ -2771,11 +2780,6 @@ rb_intern(name)
case '@':
id |= ID_INSTANCE;
break;
- case '%':
- if (name[1] != '\0') {
- id |= ID_CONST;
- break;
- }
/* fall through */
default:
if (name[0] != '_' && !isalpha(name[0]) && !ismbchar(name[0])) {
@@ -2792,6 +2796,7 @@ rb_intern(name)
if (id == Qnil) Bug("Unknown operator `%s'", name);
break;
}
+
last = strlen(name)-1;
if (name[last] == '=') {
/* attribute asignment */
@@ -2803,6 +2808,9 @@ rb_intern(name)
id &= ~ID_SCOPE_MASK;
id |= ID_ATTRSET;
}
+ else if (isupper(name[0])) {
+ id |= ID_CONST;
+ }
else {
id |= ID_LOCAL;
}
@@ -2861,40 +2869,6 @@ rb_id2name(id)
return find_ok;
}
-char *
-rb_class2name(class)
- struct RClass *class;
-{
- extern st_table *rb_class_tbl;
-
- find_ok = Qnil;
-
- switch (TYPE(class)) {
- case T_ICLASS:
- class = (struct RClass*)RBASIC(class)->class;
- break;
- case T_CLASS:
- case T_MODULE:
- break;
- default:
- Fail("0x%x is not a class/module", class);
- }
-
- while (FL_TEST(class, FL_SINGLE)) {
- class = (struct RClass*)class->super;
- }
-
- while (TYPE(class) == T_ICLASS) {
- class = (struct RClass*)class->super;
- }
-
- st_foreach(rb_class_tbl, id_find, class);
- if (find_ok) {
- return rb_id2name((ID)find_ok);
- }
- Bug("class 0x%x not named", class);
-}
-
static int
const_check(id, val, class)
ID id;
diff --git a/process.c b/process.c
index e8bcaaa..92ff8b9 100644
--- a/process.c
+++ b/process.c
@@ -508,9 +508,9 @@ Init_process()
rb_define_module_function(M_Process, "getpriority", Fproc_getpriority, 2);
rb_define_module_function(M_Process, "setpriority", Fproc_setpriority, 3);
- rb_define_const(M_Process, "%PRIO_PROCESS", INT2FIX(PRIO_PROCESS));
- rb_define_const(M_Process, "%PRIO_PGRP", INT2FIX(PRIO_PGRP));
- rb_define_const(M_Process, "%PRIO_USER", INT2FIX(PRIO_USER));
+ rb_define_const(M_Process, "PRIO_PROCESS", INT2FIX(PRIO_PROCESS));
+ rb_define_const(M_Process, "PRIO_PGRP", INT2FIX(PRIO_PGRP));
+ rb_define_const(M_Process, "PRIO_USER", INT2FIX(PRIO_USER));
rb_define_module_function(M_Process, "uid", Fproc_getuid, 0);
rb_define_module_function(M_Process, "uid=", Fproc_setuid, 1);
diff --git a/re.c b/re.c
index d631d0c..2b2a06f 100644
--- a/re.c
+++ b/re.c
@@ -128,8 +128,9 @@ research(reg, str, start, ignorecase)
{
int result;
- if (FL_TEST(reg, FL_USER1)) { /* case-flag set for the object */
- ignorecase = FL_TEST(reg, FL_USER2); /* case-flag */
+ /* case-flag set for the object */
+ if (FL_TEST(reg, FL_USER1)) {
+ ignorecase = 1;
}
if (ignorecase)
reg->ptr->pat.translate = casetable;
@@ -387,14 +388,8 @@ Sreg_new(argc, argv, self)
Check_Type(src, T_STRING);
}
- if (argc == 2) {
+ if (argc == 2 && argv[1]) {
FL_SET(reg, FL_USER1);
- if (argv[1]) {
- FL_SET(reg, FL_USER2);
- }
- else {
- FL_UNSET(reg, FL_USER2);
- }
}
return Qnil;
diff --git a/ruby.1 b/ruby.1
index 5c3df05..f3bb919 100644
--- a/ruby.1
+++ b/ruby.1
@@ -164,7 +164,29 @@ ruby \- ֥Ȼظץȸ
.TP 5
.B \-S
ץ̾`/'ǻϤޤäƤʤ, Ķѿ`PATH'ͤ
-ȤäƥץȤõ.
+ȤäƥץȤõ. ϡ#! 򥵥ݡȤƤʤޥ
+ǡ#! ˤ¹Ԥ򥨥ߥ졼Ȥ뤿ˡʲΤ褦ˤ
+ƻȤȤǤ:
+
+ #! /usr/local/bin/ruby
+ # This line makes the next one a comment in ruby \
+ eval "exec /usr/local/bin/ruby -S $0 $*"
+
+ƥϺǽιԤ̵뤷ץȤ`/bin/sh'Ϥ
+`/bin/sh'rubyץȤ򥷥륹ץȤȤƼ¹Ԥ褦
+Ȥ롥2ܤ򥳥ȤǤȲᤷ3ܤ
+Υ륳ޥɤȤƼ¹Ԥruby󥿥ץ꥿ư롥
+
+ƥˤäƤ`$0'ɬեѥޤޤʤΤǡ`-S'
+Ѥrubyɬפ˱ƥץȤõ褦˻ؼ롥
+rubyץȤ򸫤ĤȡιԤβϤϤ뤬
+ruby2ܤιˤХååˤꡤ2ܤΥ
+Ȥ3ܤޤǷ³Ȥߤʤơ3ܤ̵뤹롥
+
+ե̾˴ޤޤ륹ڡʤɤˤϡ`$*'
+`${1+"$@"}'Τۤ褤csh᤹ˤư
+
.TP 5
.B \-v, \-\-verbose
Ĺ⡼. ư˥СֹɽԤ, ƥѿ
diff --git a/ruby.c b/ruby.c
index 8029a3e..50d4570 100644
--- a/ruby.c
+++ b/ruby.c
@@ -52,7 +52,7 @@ char *rb_dln_argv0;
#endif
static void load_stdin();
-void rb_load_file();
+static void load_file();
static int do_loop = FALSE, do_print = FALSE;
static int do_check = FALSE, do_line = FALSE;
@@ -210,7 +210,7 @@ proc_options(argcp, argvp)
script = dln_find_file(script, getenv("PATH"));
if (!script) script = argv[optind];
}
- rb_load_file(script);
+ load_file(script, 1);
optind++;
}
}
@@ -242,12 +242,13 @@ proc_options(argcp, argvp)
}
static void
-readin(fd, fname)
+readin(fd, fname, script)
int fd;
char *fname;
+ int script;
{
struct stat st;
- char *ptr, *p, *pend;
+ char *ptr, *p, *pend, *s;
if (fstat(fd, &st) < 0) rb_sys_fail(fname);
if (!S_ISREG(st.st_mode))
@@ -259,39 +260,62 @@ readin(fd, fname)
rb_sys_fail(fname);
}
pend = p + st.st_size;
- if (xflag) {
- char *s = p;
+ *pend = '\0';
+
+ if (script) {
+ if (xflag) {
+ xflag = FALSE;
+ while (p < pend) {
+ if (p[0] == '#' && p[1] == '!') {
+ char *s = p;
+ while (s < pend && *s != '\n') s++;
+ if (*s == '\n') {
+ *s = '\0';
+ if (strstr(p, "ruby")) {
+ *s = '\n';
+ goto start_read;
+ }
+ }
+ p = s + 1;
+ }
+ else {
+ while (p < pend && *p++ != '\n')
+ ;
+ if (p >= pend) break;
+ }
+ }
+ free(ptr);
+ Fail("No Ruby script found in input");
+ }
+
+ start_read:
+ if (p[0] == '#' && p[1] == '!') {
+ char *s = p, *q;
- *pend = '\0';
- xflag = FALSE;
- while (p < pend) {
while (s < pend && *s != '\n') s++;
- if (*s != '\n') break;
- *s = '\0';
- if (p[0] == '#' && p[1] == '!' && strstr(p, "ruby")) {
- if (p = strstr(p, "ruby -")) {
+ if (*s == '\n') {
+ *s = '\0';
+ if (q = strstr(p, "ruby -")) {
int argc; char *argv[2]; char **argvp = argv;
- argc = 2; argv[0] = Qnil; argv[1] = p + 5;
+ argc = 2; argv[0] = Qnil; argv[1] = q + 5;
proc_options(&argc, &argvp);
+ p = s + 1;
+ }
+ else {
+ *s = '\n';
}
- xflag = TRUE;
- p = s + 1;
- goto start_read;
}
- p = s + 1;
}
- free(ptr);
- Fail("No Ruby script found in input");
}
- start_read:
lex_setsrc(fname, p, pend - p);
yyparse();
free(ptr);
}
-void
-rb_load_file(fname)
+static void
+load_file(fname, script)
char *fname;
+ int script;
{
int fd;
char *ptr;
@@ -303,10 +327,17 @@ rb_load_file(fname)
fd = open(fname, O_RDONLY, 0);
if (fd < 0) rb_sys_fail(fname);
- readin(fd, fname);
+ readin(fd, fname, script);
close(fd);
}
+void
+rb_load_file(fname)
+ char *fname;
+{
+ load_file(fname, 0);
+}
+
static void
load_stdin()
{
@@ -324,9 +355,6 @@ load_stdin()
putc(c, f);
}
fclose(f);
-
- if (fd < 0) rb_sys_fail(buf);
-
readin(fd, "-");
}
diff --git a/sample/Artistic b/sample/Artistic
index fbf7989..e69de29 100644
--- a/sample/Artistic
+++ b/sample/Artistic
@@ -1,117 +0,0 @@
-
-
-
-
- The "Artistic License"
-
- Preamble
-
-The intent of this document is to state the conditions under which a
-Package may be copied, such that the Copyright Holder maintains some
-semblance of artistic control over the development of the package,
-while giving the users of the package the right to use and distribute
-the Package in a more-or-less customary fashion, plus the right to make
-reasonable modifications.
-
-Definitions:
-
- "Package" refers to the collection of files distributed by the
- Copyright Holder, and derivatives of that collection of files
- created through textual modification.
-
- "Standard Version" refers to such a Package if it has not been
- modified, or has been modified in accordance with the wishes
- of the Copyright Holder.
-
- "Copyright Holder" is whoever is named in the copyright or
- copyrights for the package.
-
- "You" is you, if you're thinking about copying or distributing
- this Package.
-
- "Reasonable copying fee" is whatever you can justify on the
- basis of media cost, duplication charges, time of people involved,
- and so on. (You will not be required to justify it to the
- Copyright Holder, but only to the computing community at large
- as a market that must bear the fee.)
-
- "Freely Available" means that no fee is charged for the item
- itself, though there may be fees involved in handling the item.
- It also means that recipients of the item may redistribute it
- under the same conditions they received it.
-
-1. You may make and give away verbatim copies of the source form of the
-Standard Version of this Package without restriction, provided that you
-duplicate all of the original copyright notices and associated disclaimers.
-
-2. You may apply bug fixes, portability fixes and other modifications
-derived from the Public Domain or from the Copyright Holder. A Package
-modified in such a way shall still be considered the Standard Version.
-
-3. You may otherwise modify your copy of this Package in any way, provided
-that you insert a prominent notice in each changed file stating how and
-when you changed that file, and provided that you do at least ONE of the
-following:
-
- a) place your modifications in the Public Domain or otherwise make them
- Freely Available, such as by posting said modifications to Usenet or
- an equivalent medium, or placing the modifications on a major archive
- site such as uunet.uu.net, or by allowing the Copyright Holder to include
- your modifications in the Standard Version of the Package.
-
- b) use the modified Package only within your corporation or organization.
-
- c) rename any non-standard executables so the names do not conflict
- with standard executables, which must also be provided, and provide
- a separate manual page for each non-standard executable that clearly
- documents how it differs from the Standard Version.
-
- d) make other distribution arrangements with the Copyright Holder.
-
-4. You may distribute the programs of this Package in object code or
-executable form, provided that you do at least ONE of the following:
-
- a) distribute a Standard Version of the executables and library files,
- together with instructions (in the manual page or equivalent) on where
- to get the Standard Version.
-
- b) accompany the distribution with the machine-readable source of
- the Package with your modifications.
-
- c) accompany any non-standard executables with their corresponding
- Standard Version executables, giving the non-standard executables
- non-standard names, and clearly documenting the differences in manual
- pages (or equivalent), together with instructions on where to get
- the Standard Version.
-
- d) make other distribution arrangements with the Copyright Holder.
-
-5. You may charge a reasonable copying fee for any distribution of this
-Package. You may charge any fee you choose for support of this Package.
-You may not charge a fee for this Package itself. However,
-you may distribute this Package in aggregate with other (possibly
-commercial) programs as part of a larger (possibly commercial) software
-distribution provided that you do not advertise this Package as a
-product of your own.
-
-6. The scripts and library files supplied as input to or produced as
-output from the programs of this Package do not automatically fall
-under the copyright of this Package, but belong to whomever generated
-them, and may be sold commercially, and may be aggregated with this
-Package.
-
-7. C subroutines supplied by you and linked into this Package in order
-to emulate subroutines and variables of the language defined by this
-Package shall not be considered part of this Package, but are the
-equivalent of input as in Paragraph 6, provided these subroutines do
-not change the language in any way that would cause it to fail the
-regression tests for the language.
-
-8. The name of the Copyright Holder may not be used to endorse or promote
-products derived from this software without specific prior written permission.
-
-9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-
- The End
diff --git a/sample/MANIFEST b/sample/MANIFEST
index c54adf3..c91c078 100644
--- a/sample/MANIFEST
+++ b/sample/MANIFEST
@@ -1,5 +1,4 @@
MANIFEST
-Artistic
aset.rb
attr.rb
biorhythm.rb
@@ -39,7 +38,7 @@ occur.pl
occur.rb
occur2.rb
opt_s.rb
-opt_x.rb
+opt_x.test
parsearg.rb
rcs.awk
rcs.dat
diff --git a/sample/attr.rb b/sample/attr.rb
index 8326529..1d329ea 100644
--- a/sample/attr.rb
+++ b/sample/attr.rb
@@ -4,7 +4,7 @@
# #<Foo: @test=10>
class Foo
- attr "test", %TRUE
+ attr "test", TRUE
end
foo = Foo.new
diff --git a/sample/cbreak.rb b/sample/cbreak.rb
index 6d3d551..5d2d849 100644
--- a/sample/cbreak.rb
+++ b/sample/cbreak.rb
@@ -1,31 +1,31 @@
# ioctl example works on Sun
-%CBREAK = 0x00000002
-%ECHO = 0x00000008
-%TIOCGETP = 0x40067408
-%TIOCSETP = 0x80067409
+CBREAK = 0x00000002
+ECHO = 0x00000008
+TIOCGETP = 0x40067408
+TIOCSETP = 0x80067409
def cbreak ()
- set_cbreak(%TRUE)
+ set_cbreak(TRUE)
end
def cooked ()
- set_cbreak(%FALSE)
+ set_cbreak(FALSE)
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
- ttys[4] &= ~%ECHO
+ ttys[4] |= CBREAK
+ ttys[4] &= ~ECHO
else
- ttys[4] &= ~%CBREAK
- ttys[4] |= %ECHO
+ ttys[4] &= ~CBREAK
+ ttys[4] |= ECHO
end
tty = ttys.pack("C4 S")
- $stdin.ioctl(%TIOCSETP, tty)
+ $stdin.ioctl(TIOCSETP, tty)
end
cbreak();
diff --git a/sample/const.rb b/sample/const.rb
index 783965c..5078040 100644
--- a/sample/const.rb
+++ b/sample/const.rb
@@ -2,23 +2,23 @@
# output:
# 1234
# 1268
-%test1 = 1
-%test2 = 2
+TEST1 = 1
+TEST2 = 2
module Const
- %test3 = 3
- %test4 = 4
+ TEST3 = 3
+ TEST4 = 4
end
module Const2
- %test3 = 6
- %test4 = 8
+ TEST3 = 6
+ TEST4 = 8
end
include Const
-print(%test1,%test2,%test3,%test4,"\n")
+print(TEST1,TEST2,TEST3,TEST4,"\n")
include Const2
-print(%test1,%test2,%test3,%test4,"\n")
+print(TEST1,TEST2,TEST3,TEST4,"\n")
diff --git a/sample/evaldef.rb b/sample/evaldef.rb
index 1d77a3c..a705300 100644
--- a/sample/evaldef.rb
+++ b/sample/evaldef.rb
@@ -3,7 +3,7 @@
# bar
# (eval):26: method `baz' not available for "#<foo: 0xbfc5c>"(foo)
-class foo
+class Foo
def foo
eval("
def baz
@@ -12,7 +12,7 @@ end")
end
end
-class bar:foo
+class Bar : Foo
def bar
baz()
end
diff --git a/sample/export.rb b/sample/export.rb
index 03b9492..a6dfa8e 100644
--- a/sample/export.rb
+++ b/sample/export.rb
@@ -3,7 +3,7 @@
# foobar
# foo
-class foo
+class Foo
export :printf
end
diff --git a/sample/getopts.rb b/sample/getopts.rb
index 01eddce..37fd3dc 100644
--- a/sample/getopts.rb
+++ b/sample/getopts.rb
@@ -28,7 +28,7 @@
#
# IvV̎w肪ꍇ, ϐ $OPT_?? non-nil , ̃I
# vV̈Zbg܂.
-# -f -> $OPT_f = %TRUE
+# -f -> $OPT_f = TRUE
# --geometry 300x400 -> $OPT_geometry = 300x400
#
# - -- , ȍ~, SăIvV̉͂܂.
@@ -50,7 +50,8 @@ def getopts(single_opts, *opts)
end
end
end
-
+
+ opts = {}
count = 0
while ($ARGV.length != 0)
compare = nil
@@ -68,11 +69,13 @@ def getopts(single_opts, *opts)
return nil
end
eval("$OPT_" + compare + " = " + '$ARGV[1]')
+ opts[compare] = TRUE
$ARGV.shift
count += 1
break
elsif (option == compare)
- eval("$OPT_" + compare + " = %TRUE")
+ eval("$OPT_" + compare + " = TRUE")
+ opts[compare] = TRUE
count += 1
break
end
@@ -82,16 +85,19 @@ def getopts(single_opts, *opts)
for index in 1..($ARGV[0].length - 1)
compare = $ARGV[0][index, 1]
if (single_opts && compare =~ "[" + single_opts + "]")
- eval("$OPT_" + compare + " = %TRUE")
+ eval("$OPT_" + compare + " = TRUE")
+ opts[compare] = TRUE
count += 1
elsif (single_colon != "" && compare =~ "[" + single_colon + "]")
if ($ARGV[0][index..-1].length > 1)
eval("$OPT_" + compare + " = " + '$ARGV[0][(index + 1)..-1]')
+ opts[compare] = TRUE
count += 1
elsif ($ARGV.length <= 1)
return nil
else
eval("$OPT_" + compare + " = " + '$ARGV[1]')
+ opts[compare] = TRUE
$ARGV.shift
count = count + 1
end
@@ -103,7 +109,7 @@ def getopts(single_opts, *opts)
end
$ARGV.shift
- if (!defined("$OPT_" + compare))
+ if (!opts.includes(compare))
return nil
end
end
diff --git a/sample/getopts.test b/sample/getopts.test
index cdb818d..adef762 100755
--- a/sample/getopts.test
+++ b/sample/getopts.test
@@ -1,4 +1,4 @@
-#! /mp/free/bin/ruby -- -*- ruby -*-
+#! /usr/local/bin/ruby
load("parsearg.rb")
diff --git a/sample/less.rb b/sample/less.rb
index 6960b9c..b0906d5 100755
--- a/sample/less.rb
+++ b/sample/less.rb
@@ -1,4 +1,4 @@
-#! /usr/local/bin/ruby -- -*- ruby -*-
+#! /usr/local/bin/ruby
ZCAT = "/usr/local/bin/zcat"
LESS = "/usr/local/bin/less"
diff --git a/sample/opt_x.rb b/sample/opt_x.rb
index 47a67f6..e69de29 100644
--- a/sample/opt_x.rb
+++ b/sample/opt_x.rb
@@ -1,10 +0,0 @@
-test for option `-x'
-
-this is a forwarding header
-this is a header too.
-
-from here script starts
-#! ./ruby -v
-print("tt\n")
-__END__
-this is a trailer
diff --git a/sample/opt_x.test b/sample/opt_x.test
new file mode 100644
index 0000000..47a67f6
--- /dev/null
+++ b/sample/opt_x.test
@@ -0,0 +1,10 @@
+test for option `-x'
+
+this is a forwarding header
+this is a header too.
+
+from here script starts
+#! ./ruby -v
+print("tt\n")
+__END__
+this is a trailer
diff --git a/sample/ruby-mode.el b/sample/ruby-mode.el
index 4396b10..20e1abe 100644
--- a/sample/ruby-mode.el
+++ b/sample/ruby-mode.el
@@ -8,7 +8,7 @@
;;;
(defconst ruby-block-beg-re
- "class\\|module\\|def\\|if\\|unless\\|case\\|while\\|until\\|for\\|begin"
+ "class\\|module\\|def\\|if\\|case\\|while\\|for\\|begin"
)
(defconst ruby-block-mid-re
@@ -170,10 +170,14 @@ The variable ruby-indent-level controls the amount of indentation.
((or (string= "\"" w) ;skip string
(string= "'" w)
(string= "`" w))
- (if (search-forward w indent-point t)
- nil
+ (cond
+ ((string= w (char-to-string (char-after (point))))
+ (forward-char 1))
+ ((re-search-forward (format "[^\\]%s" w) indent-point t)
+ nil)
+ (t
(goto-char indent-point)
- (setq in-string t)))
+ (setq in-string t))))
((or (string= "/" w)
(string= "<" w))
(if (string= "<" w) (setq w ">"))
@@ -189,7 +193,9 @@ The variable ruby-indent-level controls the amount of indentation.
(and (eq c ?w)
(save-excursion
(forward-word -1)
- (looking-at ruby-block-beg-re))))
+ (or
+ (looking-at ruby-block-beg-re)
+ (looking-at ruby-block-mid-re)))))
(if (search-forward w indent-point t)
nil
(goto-char indent-point)
diff --git a/sample/svr.rb b/sample/svr.rb
index 1c0104c..91faa56 100644
--- a/sample/svr.rb
+++ b/sample/svr.rb
@@ -5,7 +5,7 @@ gs = TCPserver.open(0)
printf("server port is on %d\n", gs.port)
socks = [gs]
-while %TRUE
+while TRUE
nsock = select(socks);
if nsock == nil; continue end
for s in nsock[0]
diff --git a/sample/tt.rb b/sample/tt.rb
index c53ec39..4afa202 100644
--- a/sample/tt.rb
+++ b/sample/tt.rb
@@ -43,7 +43,7 @@ if offset = (ttt =~ /this ([^ ]*) (.*)/)
println("2 = ", $2);
end
-class Fib:Object
+class Fib : Object
print("in Fib:Object\n")
def Fib.test(*args)
diff --git a/spec b/spec
index fb5d046..42849d5 100644
--- a/spec
+++ b/spec
@@ -54,9 +54,10 @@ tab) CR(carriage return)(form feed)Ǥ롥(newline)
̻ҤŤϤʤߤμϼ̻ҤȤƥޥХȥ
(EUC,SJIS)̤ʤ
-Хѿ̾"$"³̻Ҥޤϵ1ʸ󥹥ѿ
-"@"³̻ҡ饹"%"³̻ҤǤ롥᥽å̾
-ѿ̾ȥ饹̾ñʤ뼱̻ҤѤ롥
+Хѿ̾"$"³̻Ҥޤϵ1ʸ󥹥ѿ
+"@"³̻ҡˤʸǻϤޤ뼱̻ҡѿ̾Ͼʸ
+ǻϤޤ뼱̻ҤǤ롥᥽å̾ˤñʤ뼱̻ҤѤ(᥽å̾
+ʸǤ⾮ʸǤϤ)
**
@@ -126,12 +127,15 @@ RubyǤnilʳɾ롥CPerl ʤɤȤϰۤʤꡤ0
\M-c ᥿ʸ(c|0x80)
\ʳ ʸΤ
+ʸ󼰤󿷤ʸ󥪥֥ȤΤǡʸƤ
+ƤȤȤʸѤʤ
+
ѿŸ
֥륯(`"')ǰϤޤ줿ʸɽǤ `#{ѿ̾}'Ȥ
-ѿƤŸ뤳ȤǤ롥ѿѿ(`$',`@',`%')
- ǻϤޤˤ`#ѿ̾'ȤǤŸǤ롥ʸ`#'³ʸ
- `{',`$',`@',`%'ǤʤСΤޤ`#'ȤƲᤵ롥
+ѿƤŸ뤳ȤǤ롥ѿѿ(`$',`@')ǻ
+ޤˤ`#ѿ̾'ȤǤŸǤ롥ʸ`#'³ʸ
+`{',`$',`@'ǤʤСΤޤ`#'ȤƲᤵ롥
** ޥɽ
@@ -142,7 +146,7 @@ RubyǤshΤ褦˥ޥɤμ¹Է̤ʸƥΤ褦˻ȤȤ
** ɽ
- /.../
+ /.../[i]
^ Ƭ
$
@@ -164,7 +168,8 @@ RubyǤshΤ褦˥ޥɤμ¹Է̤ʸƥΤ褦˻ȤȤ
|
( ) ɽޤȤ
-¾ʸƱХåå嵭ˡѿŸͭǤ롥
+¾ʸƱХåå嵭ˡѿŸͭǤ롥ɽ
+θiĤˤʸʸΰ㤤̵뤹롥
** 磻ɥɼ
@@ -226,57 +231,32 @@ Rubyѿϥ(ͭϰ)ȼ̿(ͭ)ˤä4ʬव졤
᥽åɤ黲ȤǤ롥פϥ᥽åǤꡤμ̿ϥ֥
Ȥμ̿
-*** 饹̾/⥸塼̾/ѿ
+*** 饹
:
- Array
- Math
- foobar
+ FOOBAR
-ե٥åȤޤ`_'ǻϤޤѿϼ̻ҤȤƤФ졤ѿ
-饹̾ޤϥ⥸塼̾Ǥ롥
+ʸǻϤޤ뼱̻ҤϤϥ饹ؤΥǤꡤΥ饹
+Υ֥饹Υ󥹥󥹤黲ȤǤ롥ؤϥȥåץ٥롤
+ʤ᥽åɤǤ٥ǤΤǽǤ롥ѿϥ饹
+֤ͤͭ졤ͤѹ뤳ȤǤʤ饹
+μ̿ϥ饹μ̿
-֤Ǥϼ̻Ҥϥ饹/⥸塼̾Ȥߤʤ뤬(륯饹
-¸ߤʤͤnil)κդ˸줿̻ҤϡΥ
-ǤϥѿȤƸʤ졤Ʊ̾Υ饹⥸塼ϱ롥
-ΰ̣Ǽ̻ҤؤȤƤƯġ
+饹ϼưŪΤǡ饹̾Ǥ롥
- Array # 󥯥饹 Array
- Array = 15 # ʸArrayϥѿ
- print Array, "\n" # `15'Ϥ
+*** ѿ
-ȤƤβϥѥ˹Ԥʤ뤿ᡤ̻Ҥؤ
-ºݤ˼¹ԤƤ⤵ʤƤ⡤ʹߤΥǤϤμ̻Ҥ
-ѿȤߤʤ롥
+:
- Array # 󥯥饹 Array
- if %FALSE
- Array = 15 # Υɤϼ¹Ԥʤ
- # ʹArrayϥѿȤߤʤ롥
- end
- print Array, "\n" # `nil'Ϥ
+ foobar
-Υ롼ϰ츫ʣ饹/⥸塼̾ȥѿ̾ʣ
-ʤ¤ꡤ̤ΥѿͤnilǤȹͤƤ⺹٤Ϥ
-RubyȤ߹ߥ饹ʸΥե٥åȤǻϤޤ̾Ĥ
-ꡤ桼⥯饹/⥸塼̾ˤʸǻϤޤ뼱̻Ҥ򡤥
-ѿ̾ˤϾʸޤ`_'ǻϤޤ뼱̻ҤȤȤ򶯤侩롥
+ʸޤ`_'ǻϤޤ뼱̻ҤϥѿؤΥǤ롥
+ʤѿͤnilǤ
-ѿΥפ̿⤽Υ֥åνޤ(ȥåץ٥Υ
+ѿΥפϼ̿⤽Υ֥åνޤ(ȥåץ٥Υ
ѿϥץνλޤ)Ǥ롥
-*** 饹
-
-:
-
- %foobar
-
-`%'ǻϤޤѿϥ饹ǤꡤΥ饹ƤΥ֥饹Υ
-󥹤黲ȤǤ롥ؤϥȥåץ٥롤ʤ᥽åɤ
-Ǥ٥ǤΤǽǤ롥ѿϥ饹֤ͤͭ졤
-ͤѹ뤳ȤǤʤ
-
*** ѿ
̾ѿʳ˵ѿȸƤФüѿ4Ĥ롥
@@ -300,14 +280,6 @@ Rubyѿϥ(ͭϰ)ȼ̿(ͭ)ˤä4ʬव졤
`(' `)'
-̤ˤñʤ뼰ǤϤʤ¤(ץ)֤Ȥ
-롥
-
- `(' `;' .. `)'
-
-¤ӤͤϺǸɾͤǤ롥ĤޤͤϺǸɾ
-ͤˤʤ롥
-
**
:
@@ -365,10 +337,13 @@ Rubyѿϥ(ͭϰ)ȼ̿(ͭ)ˤä4ʬव졤
åǡ쥷Фselfξ硤쥷Фά̾Υץ
ߥ󥰸ˤؿΤ褦ʷǥ᥽åɤƤӽФȤǤ롥
-᥽åɸƤӽФǤۣ椵ʤˤϳ̤άǤ롥ۣ椵
-ȤʲʸޤͽǻϤޤǤ롥
+᥽åɸƤӽФΰμγ̤άǤ뤬Ȥʤ뼰
+ʸޤͽǻϤޤϡ̤ͥδطͽ̤η̤
+ʤ礬롥
- (, [, {, <, /, %, +, -, if, while
+ (, [, {, <, /, +, -, if, while
+
+ɤΤ褦ɾ뤫ۣʾˤϳ̤Ĥ
foo bar+baz # ᥽åɸƤӽФfoo(bar+baz)
@@ -416,31 +391,31 @@ Rubyѿϥ(ͭϰ)ȼ̿(ͭ)ˤä4ʬव졤
foo[0] = bar
foo.bar = baz
-ˤѿФ()ȡץñˤ뤿Υ
-å奬ȤƤ롥ϰʲηǤ롥
+ѿʤɤͤꤹ뤿Ѥ롥ϱ黻ҷȤ
+Ƥ뤬᥽åɤǤϤʤΤǺ뤳ȤϤǤʤդˤʤ뤳
+Τϰʲ3μǤ롥
- ѿ `='
+ѿ(`$'̻ | `@'̻ | ̻)
-ϼɾѿͤȤ롥饹⥸塼䵿ѿ
-ˤǤʤ饹⥸塼ѹ뤿ˤclass
-moduleѤ롥ϱ黻ҷȤäƤ뤬᥽åɤǤϤʤ
-Ǻ뤳ȤϤǤʤ
+ ѿ `='
-󥿥å奬ȤƤϰʲΤΤ롥
+ѿؤϱդμɾ줿ͤդǻꤵ줿ѿ
+롥
-Ǥؤ
+󻲾([..])
1`[' 2.. `]' `=' n
-1ɾ륪֥Ȥˡ2鼰nޤǤȤơ"[]="
-Ȥ᥽åɤƤӽФ
+󻲾ȼؤϡ1ɾ륪֥Ȥˡ2鼰n
+ޤǤȤơ"[]=" Ȥ᥽åɤƤӽФ
+°(`.'̻)
1 `.' ̻ `=' 2
-1ɾ륪֥(쥷Фά줿`self')
-Фơ"̻="Ȥ᥽åɤ 2ȤƸƤӽФ
+°(ʤΥ᥽åɸƤӽФ)ؤϡ1ɾ
+֥(쥷Фά줿`self')Фơ"̻="Ȥ
+᥽åɤ 2ȤƸƤӽФ
**
@@ -472,11 +447,12 @@ moduleѤ롥ϱ黻ҷȤäƤ뤬᥽åɤǤϤʤ
`,' [ `,'..] [`*' ]= [, ..]
-դμĤʤϡͤȤ(ɬפʤto_a᥽
-ɤѴ)Ǥ򤽤줾캸դ롥ʳξˤϡ
-줾μͤդ롥դοȱդǤοʤ
-ˤ­ʤѿˤ nil졤;äǤ̵뤵롥¿
-κǸǤ`*'硤ĤưȤ롥
+դˤ3μ롥դμĤʤϡ
+Ȥ(ɬפʤto_a᥽åɤѴ)Ǥ򤽤줾캸
+դ롥ʳξˤϡ줾μͤդ롥
+դοȱդǤοʤˤ­ʤѿˤ nil졤
+;äǤ̵뤵롥¿κǸǤ`*'硤Ĥ
+ưȤ롥
foo, bar = [1, 2] # foo = 1; bar = 2
foo, bar = 1, 2 # foo = 1; bar = 2
@@ -690,7 +666,7 @@ whileξȽμǤʸɽƥϼ$_=~ ƥ
ƥ졼Ȥ湽¤(ä˥롼)ݲΤѤ᥽åɤ
Ǥ롥ƥ졼θƤӽФϰʲιʸǹԤʤ롥
- `{' ѿ.. `|' .. `}'
+ `{' ռ.. `|' .. `}'
ּפ֥åȤꤷּפΥ᥽åɤ򥤥ƥ졼Ȥɾ
롥ּפΥȥåץ٥Υ᥽åɤƥ졼ȤƸƤӽФ졤
@@ -709,13 +685,13 @@ Enumerable⥸塼grep᥽åɤΤ褦˥ƥ졼ȤƸƤФ줿
֥ȤγǤФԤʤη󶡤Ƥ롥
ϰʲ̤ꡥ
- for ѿ.. in
+ for ռ.. in
end
γǤФ¹Ԥ롥ϰʲμǤ롥
- ().each `{' ѿ.. `|' `}'
+ ().each `{' ռ.. `|' `}'
äƼͤΥ֥Ȥ᥽åeachʤ硤for¹Ԥ
㳰ȯ롥
@@ -908,13 +884,6 @@ Rubyˤϸ̩ʰ̣ǤϴؿϤʤKernel饹δؿ᥽åɤ(Ƥ
exit()Ȥϰäơ㳰ʤɤϰڹԤʤʤfork()θ塤
ץλʤɤѤ롥
- do()
-
- ֥å1٤¹Ԥ륤ƥ졼֥åޤȤ뤿
- ¸ߤ롥Ȥ:
-
- do { foobar() } while (baz())
-
eof()
ޥɥ饤󤫤ϤEOFãƤ硤֤
@@ -1048,8 +1017,8 @@ Rubyˤϸ̩ʰ̣ǤϴؿϤʤKernel饹δؿ᥽åɤ(Ƥ
fileɤ롥loadȤưΰ㤤requireϥɤե
Υեѥѿ`$"'˳ФƤơ˥ɤե
- ƥɤʤǤ롥ºݤ˥ɤˤ%TRUE˥
- ɤƤˤ%FALSE֤
+ ƥɤʤǤ롥ºݤ˥ɤˤTRUE˥
+ ƤˤFALSE֤
select(reads[, writes[, execpts[, timeout]]])
@@ -1224,23 +1193,23 @@ Rubyˤϸ̩ʰ̣ǤϴؿϤʤKernel饹δؿ᥽åɤ(Ƥ
$VERSION rubyΥС򼨤ʸ
- %TRUE t
- %FALSE nil
+ TRUE t
+ FALSE nil
줾쿿ͤɽȽǤnil򵶡ʳƤͤ
- ȤȽǤ뤿ᡤ%TRUEͤɽŪʿͤȤʾΰ
- ̣ʤäơ᥽åɤͤǤȤȤȡ
- 줬%TRUE֤ȤȤϸ̩ˤƱǤϤʤ(ҸŪѤ
- ᥽åɤ񿿤ͤȤ%TRUE֤褦ˤϤʤäƤ
- )Ĥޤ
+ ȤȽǤ뤿ᡤTRUEͤɽŪʿͤȤʾΰ̣
+ ʤäơ᥽åɤͤǤȤȤȡ
+ 줬TRUE֤ȤȤϸ̩ˤƱǤϤʤ(ҸŪѤ
+ ᥽åɤ񿿤ͤȤTRUE֤褦ˤϤʤäƤ뤬)
+ Ĥޤ
if some.method() then ... else ... end
- if some.method() == %TRUE then ... else ... end
+ if some.method() == TRUE then ... else ... end
- ϴˤƱǤϤʤ%FALSE˴ؤƤϡΤ褦
+ ϴˤƱǤϤʤFALSE˴ؤƤϡΤ褦
ʤ
* Ȥ߹ߥ饹ȥ⥸塼
@@ -1708,8 +1677,8 @@ Single Methods:
** Dict(饹)
񤢤뤤ϢǤդΥ֥ȤźȤǤΥ饹Ǥ
-롥HashȤ̾Ǥ⥢Ǥ롥Ϣ󥪥֥Ȥϰ
-ŪˤϢ``{a=>b,..}'' ǹԤʤ롥
+롥Ϣ󥪥֥ȤϰŪˤϢ``{a=>b,..}'' ǹ
+ʤ롥
SuperClass: Object
@@ -1796,10 +1765,9 @@ Single Methods:
()񥪥֥Ȥ֤
-** Directory(饹)
+** Dir(饹)
ǥ쥯ȥǤ֤ǥ쥯ȥꥹȥ꡼ΤΥ饹
-DirȤ̾Ǥ⥢Ǥ롥
SuperClass: Object
@@ -2681,7 +2649,7 @@ Private Methods:
άǽ2publicͿơĤͤnilǤʤ
Ϥ°ˤ°᥽åɤѰդ졤ǽˤ
- 롥attr("attr", %TRUE)ϥ饹˰ʲΥɤɲä
+ 롥attr("attr", TRUE)ϥ饹˰ʲΥɤɲä
ȤۤƱǤ롥
def attr; @attr; end
@@ -2690,7 +2658,7 @@ Private Methods:
°᥽åɤ뤳Ȥˤäơư
ѹǤ롥㤨
- attr("test", %TRUE)
+ attr("test", TRUE)
def test=(val)
print("test was ", @test, "\n")
print("and now is ", @test = val, "\n")
@@ -2843,8 +2811,8 @@ Single Methods:
whichwhoǻꤵץץ롼ס桼θ
̤֤ͥܺ٤getpriority(2)򻲾ȡProcess⥸塼
- ǤwhichȤƻǤ%PRIO_PROCESS%PRIO_PGRP
- %PRIO_USERƤ롥
+ ǤwhichȤƻǤPRIO_PROCESSPRIO_PGRP
+ PRIO_USERƤ롥
gid
@@ -2893,9 +2861,9 @@ Single Methods:
ξϰʲ®.
- do 1.upto(5)
+ 1.upto(5) {
...
- end
+ }
ϰϥ֥Ȥ`..'黻ҤξդComparableޤ९饹Υ
󥹥󥹤ǤвǤ⹽ʤϰϤϻȽޤळȤդ
@@ -3025,10 +2993,9 @@ Single Methods:
new(string[, casefold])
ʸɽѴ֥Ȥ֤άǽ2
- Ϳ줿ˤϡɽ֥Ȥϥƥ
- ѿ`$='ͤ˴ؤ餺λʸʸ̵뤷λ
- ̤롥ꤵʤϥޥåԤʤäΥƥѿ
- `$='ͤˤäƶ̤뤫ʤꤵ롥
+ Ϳ졤ͤnilǤʤˤϡ줿ɽ
+ Ȥϥƥѿ`$='ͤ˴ؤ餺ޥåʸ
+ ʸΰ㤤̵뤹롥
quote(str)
@@ -3456,7 +3423,7 @@ TCP/IPȥ꡼෿³Υ¦ΥåȤΥ饹Υ饹ˤä
gs = TCPserver.open(4444)
socks = [gs]
- while %TRUE
+ while TRUE
nsock = select(socks);
if nsock == nil; continue end
for s in nsock[0]
@@ -3766,7 +3733,8 @@ ARG : LHS `=' ARG
| ARG `||' ARG
| PRIMARY
-PRIMARY : LITERAL
+PRIMARY : `(' EXPR `)'
+ | LITERAL
| VARIABLE
| super `(' [CALL_ARGS] `)'
| super
@@ -3807,7 +3775,6 @@ PRIMARY : LITERAL
[resque COMPEXPR]
[ensure COMPEXPR]
end
- | `(' COMPEXPR `)'
| class identifier `:' identifier
COMPEXPR
end
@@ -3852,8 +3819,7 @@ ASSOCS : ASSOC (`,' ASSOC)*
ASSOC : ARG `=>' ARG
-VARIABLE : identifier
- | VARNAME
+VARIABLE : VARNAME
| nil
| self
| `__FILE__'
@@ -3880,7 +3846,7 @@ FNAME : identifier | `::' | `..' | `|' | `^' | `&'
VARNAME : GLOBAL
| `@'identifier
- | `%'identifier
+ | identifier
GLOBAL : `$'identifier
| `$'any_char
@@ -3889,18 +3855,22 @@ STRING : `"' any_char* `"'
| `'' any_char* `''
| ``' any_char* ``'
-REGEXP : `/' any_char* `/'
+REGEXP : `/' any_char* `/'[i]
GLOB : `<' any_char* `>'
* ռ
-RubyθͤC, Perl, EiffelγƸˤν˱ƶƤ.
-¾˱ƶȤƤtcl, AWK, bourne shell, CLU, Sather,
-Icon, Smalltalk, Emacs Lispʤɤ. ޤrubyθͤꤹ뤿
-˶ϤƲäʲˤ(ɾά): ͷ
-ƣϺ¼ΣţáغDECʤ@ֺ.ٻ̡
+RubyθͤϿ¿θαƶƤ. ʲˤΤϤμ
+ʸǤ롥
+
+ C, Perl, CLU, Sather, CLOS, Eiffel, Icon, tcl, AWK, bourne shell,
+ Smalltalk, Emacs Lisp.
+
+ޤrubyθͤꤹ뤿˶ϤƲäʲˤ
+ ͷƣϺ¼ΣţáغDEC
+ ʤֺ.ٻ(ɾά)
-------------------------------------------------------
Local variables:
fill-column: 70
diff --git a/string.c b/string.c
index aacc6f6..0b23655 100644
--- a/string.c
+++ b/string.c
@@ -209,9 +209,7 @@ str_subseq(str, beg, end)
if (beg > end) {
int tmp;
- if (verbose) {
- Warning("start %d is bigger than end %d", beg, end);
- }
+ Warning("start %d is bigger than end %d", beg, end);
tmp = beg; beg = end; end = tmp;
}
@@ -606,9 +604,7 @@ Fstr_aref_internal(str, indx)
if (beg > end) {
int tmp;
- if (verbose) {
- Warning("start %d is bigger than end %d", beg, end);
- }
+ Warning("start %d is bigger than end %d", beg, end);
tmp = beg; beg = end; end = tmp;
}
@@ -743,9 +739,7 @@ Fstr_aset_internal(str, indx, val)
if (beg > end) {
int tmp;
- if (verbose) {
- Warning("start %d is bigger than end %d", beg, end);
- }
+ Warning("start %d is bigger than end %d", beg, end);
tmp = beg; beg = end; end = tmp;
}
diff --git a/variable.c b/variable.c
index bdfca0a..9ac538c 100644
--- a/variable.c
+++ b/variable.c
@@ -38,11 +38,40 @@ rb_name_class(class, id)
{
VALUE body;
- if (st_lookup(class_tbl, id, &body)) {
- Bug("%s %s already exists",
- TYPE(body)==T_CLASS?"class":"module", rb_id2name(id));
+ rb_ivar_set_1(class, rb_intern("__classname__"), INT2FIX(id));
+}
+
+char *
+rb_class2name(class)
+ struct RClass *class;
+{
+ int name;
+
+ switch (TYPE(class)) {
+ case T_ICLASS:
+ class = (struct RClass*)RBASIC(class)->class;
+ break;
+ case T_CLASS:
+ case T_MODULE:
+ break;
+ default:
+ Fail("0x%x is not a class/module", class);
+ }
+
+ while (FL_TEST(class, FL_SINGLE)) {
+ class = (struct RClass*)class->super;
+ }
+
+ while (TYPE(class) == T_ICLASS) {
+ class = (struct RClass*)class->super;
}
- st_add_direct(class_tbl, id, class);
+
+ name = rb_ivar_get_1(class, rb_intern("__classname__"));
+ if (name) {
+ name = FIX2INT(name);
+ return rb_id2name((ID)name);
+ }
+ Bug("class 0x%x not named", class);
}
struct global_entry {
@@ -203,8 +232,7 @@ rb_gvar_get(entry)
default:
break;
}
- if (verbose)
- Warning("global var %s not initialized", rb_id2name(entry->id));
+ Warning("global var %s not initialized", rb_id2name(entry->id));
return Qnil;
}
@@ -248,18 +276,6 @@ rb_gvar_set2(name, val)
}
VALUE
-rb_mvar_get(id)
- ID id;
-{
- VALUE val;
-
- if (st_lookup(class_tbl, id, &val)) return val;
- if (verbose)
- Warning("local var %s not initialized", rb_id2name(id));
- return Qnil;
-}
-
-VALUE
rb_ivar_get_1(obj, id)
struct RObject *obj;
ID id;
@@ -278,9 +294,7 @@ rb_ivar_get_1(obj, id)
rb_class2name(CLASS_OF(obj)));
break;
}
- if (verbose) {
- Warning("instance var %s not initialized", rb_id2name(id));
- }
+ Warning("instance var %s not initialized", rb_id2name(id));
return Qnil;
}
@@ -333,6 +347,10 @@ rb_const_get(id)
}
class = class->super;
}
+
+ /* pre-defined class */
+ if (st_lookup(class_tbl, id, &value)) return value;
+
Fail("Uninitialized constant %s", rb_id2name(id));
/* not reached */
}
diff --git a/version.h b/version.h
index d8dfe80..f94892d 100644
--- a/version.h
+++ b/version.h
@@ -1,2 +1,2 @@
-#define RUBY_VERSION "0.66"
-#define VERSION_DATE "95/02/09"
+#define RUBY_VERSION "0.67"
+#define VERSION_DATE "95/02/21"