summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog22
-rw-r--r--Makefile.in5
-rw-r--r--array.c6
-rw-r--r--dir.c12
-rw-r--r--eval.c47
-rw-r--r--ext/dbm/dbm.c2
-rw-r--r--ext/dbm/extconf.rb1
-rw-r--r--ext/gtk/gtk.c110
-rw-r--r--ext/socket/socket.c16
-rw-r--r--file.c1
-rw-r--r--io.c68
-rw-r--r--lib/delegate.rb4
-rw-r--r--parse.y500
-rw-r--r--sample/ruby-mode.el2
-rw-r--r--sample/test.rb2
-rw-r--r--struct.c16
16 files changed, 490 insertions, 324 deletions
diff --git a/ChangeLog b/ChangeLog
index fcd1bd088da..ec7a4bf83ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+Tue Apr 14 11:34:50 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * struct.c (struct_s_def): supports subclassing of Struct.
+
+ * io.c (io_s_new): supports subclassing of IO.
+
+Mon Apr 13 11:07:39 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * eval.c (f_binding): need to restore method name.
+
+ * eval.c (rb_call0): raises SystemStackError, not Fatal.
+
+ * io.c (obj_display): same as `print self'.
+
+ * io.c (f_p): can now be called in the method form.
+
+ * re.c (reg_regsub): needed to be mbchar aware.
+
Mon Apr 13 13:18:32 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
* eval.c (thread_trap_eval): all handlers executed under main_thread.
@@ -10,6 +28,10 @@ Sun Apr 12 22:14:07 1998 Kazunori NISHI <kazunori@swlab.csce.kyushu-u.ac.jp>
* array.c (ary_uniq_bang): should be `==', not `='. embarrassing.
+Sat Apr 11 02:13:30 1998 Yukihiro Matsumoto <matz@netlab.co.jp>
+
+ * array.c (ary_subseq): SEGVed for `[][1,1]'.
+
Fri Apr 10 21:29:06 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp>
* array.c (ary_subseq): add check for beg larger than array length.
diff --git a/Makefile.in b/Makefile.in
index a84da25f3f8..d6b80e9f317 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -66,7 +66,7 @@ OBJS = array.o \
$(MISSING)
all: miniruby$(binsuffix) rbconfig.rb
- @cd ext; ../miniruby$(binsuffix) ./extmk.rb @EXTSTATIC@
+ @./miniruby$(binsuffix) -Xext extmk.rb @EXTSTATIC@
miniruby$(binsuffix): $(OBJS) $(MAINOBJ) dmyext.o
@rm -f $@
@@ -86,8 +86,7 @@ install: rbconfig.rb
clean:; @rm -f $(OBJS) $(LIBRUBY) $(MAINOBJ) rbconfig.rb
@rm -f ext/extinit.c ext/extinit.o dmyext.o
@if test -f ./miniruby$(binsuffix); then \
- cd ext; \
- ../miniruby$(binsuffix) ./extmk.rb clean; \
+ ./miniruby$(binsuffix) -Xext extmk.rb clean; \
fi
realclean: clean
diff --git a/array.c b/array.c
index a53554ba2dc..6fdcf661fa7 100644
--- a/array.c
+++ b/array.c
@@ -306,9 +306,6 @@ ary_subseq(ary, beg, len)
beg = RARRAY(ary)->len + beg;
if (beg < 0) beg = 0;
}
- if (beg >= RARRAY(ary)->len) {
- IndexError("out of range %d", beg);
- }
if (len < 0) {
IndexError("negative length %d", RARRAY(ary)->len);
}
@@ -318,6 +315,9 @@ ary_subseq(ary, beg, len)
if (beg + len > RARRAY(ary)->len) {
len = RARRAY(ary)->len - beg;
}
+ if (len < 0) {
+ len = 0;
+ }
ary2 = ary_new2(len);
MEMCPY(RARRAY(ary2)->ptr, RARRAY(ary)->ptr+beg, VALUE, len);
diff --git a/dir.c b/dir.c
index e2a6fd45ba5..a4b8b8db94e 100644
--- a/dir.c
+++ b/dir.c
@@ -100,7 +100,6 @@ dir_closed()
if (dirp == NULL) dir_closed();\
}
-#if 0
static VALUE
dir_read(dir)
VALUE dir;
@@ -109,13 +108,16 @@ dir_read(dir)
struct dirent *dp;
GetDIR(dir, dirp);
+ errno = 0;
dp = readdir(dirp);
if (dp)
return str_taint(str_new(dp->d_name, NAMLEN(dp)));
- else
- return Qnil;
+ else {
+ if (errno == 0) /* end of stream */
+ return Qnil;
+ rb_sys_fail(0);
+ }
}
-#endif
static VALUE
dir_each(dir)
@@ -428,9 +430,7 @@ Init_Dir()
rb_define_singleton_method(cDir, "open", dir_s_open, 1);
rb_define_singleton_method(cDir, "foreach", dir_foreach, 1);
-#if 0
rb_define_method(cDir,"read", dir_read, 0);
-#endif
rb_define_method(cDir,"each", dir_each, 0);
rb_define_method(cDir,"rewind", dir_rewind, 0);
rb_define_method(cDir,"tell", dir_tell, 0);
diff --git a/eval.c b/eval.c
index 123ba4f7311..0ae56d2c3d2 100644
--- a/eval.c
+++ b/eval.c
@@ -369,6 +369,7 @@ extern VALUE eException;
extern VALUE eRuntimeError;
extern VALUE eSyntaxError;
static VALUE eLocalJumpError;
+static VALUE eSysStackError;
extern VALUE eSecurityError;
extern VALUE TopSelf;
@@ -404,7 +405,8 @@ struct BLOCK {
VALUE orig_thread;
#endif
struct BLOCK *prev;
-} *the_block;
+};
+static struct BLOCK *the_block;
#define PUSH_BLOCK(v,b) { \
struct BLOCK _block; \
@@ -513,10 +515,11 @@ dyna_var_asgn(id, value)
return value;
}
-static struct iter {
+struct iter {
int iter;
struct iter *prev;
-} *the_iter;
+};
+static struct iter *the_iter;
#define ITER_NOT 0
#define ITER_PRE 1
@@ -532,7 +535,7 @@ static struct iter {
the_iter = _iter.prev; \
}
-static struct tag {
+struct tag {
jmp_buf buf;
struct FRAME *frame;
struct iter *iter;
@@ -540,7 +543,8 @@ static struct tag {
VALUE retval;
ID dst;
struct tag *prev;
-} *prot_tag;
+};
+static struct tag *prot_tag;
#define PUSH_TAG(ptag) { \
struct tag _tag; \
@@ -675,9 +679,13 @@ rb_check_safe_str(x)
TypeError("wrong argument type %s (expected String)",
rb_class2name(CLASS_OF(x)));
}
- if (rb_safe_level() > 0 && str_tainted(x)) {
- Raise(eSecurityError, "Insecure operation - %s",
- rb_id2name(the_frame->last_func));
+ if (str_tainted(x)) {
+ if (safe_level > 0){
+ Raise(eSecurityError, "Insecure operation - %s",
+ rb_id2name(the_frame->last_func));
+ }
+ Warning("Insecure operation - %s",
+ rb_id2name(the_frame->last_func));
}
}
@@ -2402,7 +2410,7 @@ rb_eval(self, node)
rb_id2name(node->nd_cname));
}
}
- if (safe_level >= 4) {
+ if (safe_level >= 3) {
Raise(eSecurityError, "extending class prohibited");
}
rb_clear_cache();
@@ -2412,6 +2420,7 @@ rb_eval(self, node)
klass = rb_define_class_id(node->nd_cname, super);
rb_const_set(the_class, node->nd_cname, klass);
rb_set_class_path(klass,the_class,rb_id2name(node->nd_cname));
+ obj_call_init(klass);
}
return module_setup(klass, node->nd_body);
@@ -2430,7 +2439,7 @@ rb_eval(self, node)
if (TYPE(module) != T_MODULE) {
TypeError("%s is not a module", rb_id2name(node->nd_cname));
}
- if (safe_level >= 4) {
+ if (safe_level >= 3) {
Raise(eSecurityError, "extending module prohibited");
}
}
@@ -2438,6 +2447,7 @@ rb_eval(self, node)
module = rb_define_module_id(node->nd_cname);
rb_const_set(the_class, node->nd_cname, module);
rb_set_class_path(module,the_class,rb_id2name(node->nd_cname));
+ obj_call_init(module);
}
result = module_setup(module, node->nd_body);
@@ -3238,7 +3248,7 @@ rb_call0(klass, recv, id, argc, argv, body, nosuper)
}
if ((++tick & 0xfff) == 0 && stack_length() > STACK_LEVEL_MAX)
- Fatal("stack level too deep");
+ Raise(eSysStackError, "stack level too deep");
PUSH_ITER(itr);
PUSH_FRAME();
@@ -4738,6 +4748,9 @@ f_binding(self)
data->orig_thread = thread_current();
#endif
data->iter = f_iterator_p();
+ if (the_frame->prev) {
+ data->frame.last_func = the_frame->prev->last_func;
+ }
data->frame.argv = ALLOC_N(VALUE, data->frame.argc);
MEMCPY(data->frame.argv, the_block->frame.argv, VALUE, data->frame.argc);
@@ -4802,6 +4815,7 @@ proc_s_new(klass)
break;
}
}
+ obj_call_init(proc);
return proc;
}
@@ -5122,6 +5136,7 @@ void
Init_Proc()
{
eLocalJumpError = rb_define_class("LocalJumpError", eException);
+ eSysStackError = rb_define_class("SystemStackError", eException);
cProc = rb_define_class("Proc", cObject);
rb_define_singleton_method(cProc, "new", proc_s_new, 0);
@@ -5200,7 +5215,6 @@ struct thread {
struct FRAME *frame;
struct SCOPE *scope;
- int vmode;
struct RVarmap *dyna_vars;
struct BLOCK *block;
struct iter *iter;
@@ -5208,6 +5222,7 @@ struct thread {
VALUE klass;
VALUE trace;
+ int misc; /* misc. states (vmode/trap_immediate) */
char *file;
int line;
@@ -5354,7 +5369,7 @@ thread_save_context(th)
th->klass = the_class;
th->dyna_vars = the_dyna_vars;
th->block = the_block;
- th->vmode = scope_vmode;
+ th->misc = scope_vmode | (trap_immediate<<8);
th->iter = the_iter;
th->tag = prot_tag;
th->errat = errat;
@@ -5414,7 +5429,8 @@ thread_restore_context(th, exit)
the_class = th->klass;
the_dyna_vars = th->dyna_vars;
the_block = th->block;
- scope_vmode = th->vmode;
+ scope_vmode = th->misc&SCOPE_MASK;
+ trap_immediate = th->misc>>8;
the_iter = th->iter;
prot_tag = th->tag;
errat = th->errat;
@@ -5445,6 +5461,7 @@ thread_restore_context(th, exit)
case 3:
rb_trap_eval(th_cmd, th_sig);
+ errno = EINTR;
break;
case 4:
@@ -6058,7 +6075,6 @@ catch_timer(sig)
#endif
if (!thread_critical) {
if (trap_immediate) {
- trap_immediate = 0;
thread_schedule();
}
else thread_pending = 1;
@@ -6259,6 +6275,7 @@ thread_trap_eval(cmd, sig)
thread_ready(main_thread);
if (curr_thread == main_thread) {
rb_trap_eval(cmd, sig);
+ return;
}
thread_save_context(curr_thread);
if (setjmp(curr_thread->context)) {
diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c
index 98c406ace04..2ecc725ecb2 100644
--- a/ext/dbm/dbm.c
+++ b/ext/dbm/dbm.c
@@ -328,7 +328,9 @@ fdbm_store(obj, keystr, valstr)
dbmp->di_size = -1;
dbm = dbmp->di_dbm;
if (dbm_store(dbm, key, val, DBM_REPLACE)) {
+#ifdef HAVE_DBM_CLAERERR
dbm_clearerr(dbm);
+#endif
if (errno == EPERM) rb_sys_fail(Qnil);
Fail("dbm_store failed");
}
diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb
index 4a5d41f275e..595640737d4 100644
--- a/ext/dbm/extconf.rb
+++ b/ext/dbm/extconf.rb
@@ -1,5 +1,6 @@
$LDFLAGS = "-L/usr/local/lib"
have_library("gdbm", "dbm_open") or have_library("dbm", "dbm_open")
if have_func("dbm_open")
+ have_func("dbm_clearerr")
create_makefile("dbm")
end
diff --git a/ext/gtk/gtk.c b/ext/gtk/gtk.c
index df0cf58eb13..418c6774604 100644
--- a/ext/gtk/gtk.c
+++ b/ext/gtk/gtk.c
@@ -44,6 +44,7 @@ static VALUE gColorSel;
static VALUE gColorSelDialog;
static VALUE gImage;
static VALUE gDrawArea;
+static VALUE gEditable;
static VALUE gEntry;
static VALUE gEventBox;
static VALUE gFixed;
@@ -4430,6 +4431,98 @@ darea_size(self, w, h)
}
static VALUE
+edit_sel_region(self, start, end)
+ VALUE self, start, end;
+{
+ gtk_editable_select_region(GTK_EDITABLE(get_widget(self)),
+ NUM2INT(start), NUM2INT(end));
+ return self;
+}
+
+static VALUE
+edit_insert_text(self, new_text)
+ VALUE self;
+{
+ gint pos;
+
+ Check_Type(new_text, T_STRING);
+ gtk_editable_insert_text(GTK_EDITABLE(get_widget(self)),
+ RSTRING(new_text)->ptr,
+ RSTRING(new_text)->len,
+ &pos);
+ return INT2NUM(pos);
+}
+
+static VALUE
+edit_delete_text(self, start, end)
+ VALUE self, start, end;
+{
+ gtk_editable_delete_text(GTK_EDITABLE(get_widget(self)),
+ NUM2INT(start), NUM2INT(end));
+ return self;
+}
+
+static VALUE
+edit_get_chars(self, start, end)
+ VALUE self, start, end;
+{
+ gchar *s;
+
+ s = gtk_editable_get_chars(GTK_EDITABLE(get_widget(self)),
+ NUM2INT(start), NUM2INT(end));
+ return str_new2(s);
+}
+
+static VALUE
+edit_cut_clipboard(self, time)
+ VALUE self, time;
+{
+ gtk_editable_cut_clipboard(GTK_EDITABLE(get_widget(self)),NUM2INT(time));
+ return self;
+}
+
+static VALUE
+edit_copy_clipboard(self, time)
+ VALUE self, time;
+{
+ gtk_editable_copy_clipboard(GTK_EDITABLE(get_widget(self)),NUM2INT(time));
+ return self;
+}
+
+static VALUE
+edit_paste_clipboard(self, time)
+ VALUE self, time;
+{
+ gtk_editable_paste_clipboard(GTK_EDITABLE(get_widget(self)),NUM2INT(time));
+ return self;
+}
+
+static VALUE
+edit_claim_selection(self, claim, time)
+ VALUE self, claim, time;
+{
+ gtk_editable_claim_selection(GTK_EDITABLE(get_widget(self)),
+ RTEST(claim), NUM2INT(time));
+ return self;
+}
+
+static VALUE
+edit_delete_selection(self)
+ VALUE self;
+{
+ gtk_editable_delete_selection(GTK_EDITABLE(get_widget(self)));
+ return self;
+}
+
+static VALUE
+edit_changed(self)
+ VALUE self;
+{
+ gtk_editable_changed(GTK_EDITABLE(get_widget(self)));
+ return self;
+}
+
+static VALUE
entry_initialize(self)
VALUE self;
{
@@ -5625,7 +5718,8 @@ Init_gtk()
gColorSelDialog = rb_define_class_under(mGtk, "ColorSelectionDialog", gWindow);
gImage = rb_define_class_under(mGtk, "Image", gMisc);
gDrawArea = rb_define_class_under(mGtk, "DrawingArea", gWidget);
- gEntry = rb_define_class_under(mGtk, "Entry", gWidget);
+ gEditable = rb_define_class_under(mGtk, "Editable", gWidget);
+ gEntry = rb_define_class_under(mGtk, "Entry", gEditable);
gEventBox = rb_define_class_under(mGtk, "EventBox", gBin);
gFixed = rb_define_class_under(mGtk, "Fixed", gContainer);
gGamma = rb_define_class_under(mGtk, "GammaCurve", gVBox);
@@ -5666,7 +5760,7 @@ Init_gtk()
gProgressBar = rb_define_class_under(mGtk, "ProgressBar", gWidget);
gScrolledWin = rb_define_class_under(mGtk, "ScrolledWindow", gContainer);
gTable = rb_define_class_under(mGtk, "Table", gContainer);
- gText = rb_define_class_under(mGtk, "Text", gWidget);
+ gText = rb_define_class_under(mGtk, "Text", gEditable);
gToolbar = rb_define_class_under(mGtk, "Toolbar", gContainer);
gTooltips = rb_define_class_under(mGtk, "Tooltips", cData);
gTree = rb_define_class_under(mGtk, "Tree", gContainer);
@@ -5958,6 +6052,18 @@ Init_gtk()
rb_define_method(gDrawArea, "initialize", darea_initialize, 0);
rb_define_method(gDrawArea, "size", darea_size, 2);
+ /* Editable */
+ rb_define_method(gEditable, "select_region", edit_sel_region, 2);
+ rb_define_method(gEditable, "insert_text", edit_insert_text, 3);
+ rb_define_method(gEditable, "delete_text", edit_delete_text, 2);
+ rb_define_method(gEditable, "get_chars", edit_get_chars, 2);
+ rb_define_method(gEditable, "cut_clipboard", edit_cut_clipboard, 1);
+ rb_define_method(gEditable, "copy_clipboard", edit_copy_clipboard, 1);
+ rb_define_method(gEditable, "paste_clipboard", edit_paste_clipboard, 1);
+ rb_define_method(gEditable, "claim_selection", edit_claim_selection, 2);
+ rb_define_method(gEditable, "delete_selection", edit_delete_selection, 0);
+ rb_define_method(gEditable, "changed", edit_changed, 0);
+
/* Entry */
rb_define_method(gEntry, "initialize", entry_initialize, 0);
rb_define_method(gEntry, "set_text", entry_set_text, 1);
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index 0b3090124a3..5aaff22c04b 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -94,6 +94,7 @@ sock_new(class, fd)
fp->f2 = rb_fdopen(fd, "w");
fp->mode = FMODE_READWRITE;
io_unbuffered(fp);
+ obj_call_init((VALUE)sock);
return (VALUE)sock;
}
@@ -543,7 +544,6 @@ tcp_s_open(class, host, serv)
VALUE s;
Check_SafeStr(host);
s = open_inet(class, host, serv, INET_CLIENT);
- obj_call_init(s);
return s;
}
@@ -562,7 +562,6 @@ socks_s_open(class, host, serv)
Check_SafeStr(host);
s = open_inet(class, host, serv, INET_SOCKS);
- obj_call_init(s);
return s;
}
#endif
@@ -579,7 +578,6 @@ tcp_svr_s_open(argc, argv, class)
s = open_inet(class, arg1, arg2, INET_SERVER);
else
s = open_inet(class, 0, arg1, INET_SERVER);
- obj_call_init(s);
return s;
}
@@ -812,7 +810,6 @@ udp_s_open(class)
VALUE s;
s = sock_new(class, socket(AF_INET, SOCK_DGRAM, 0));
- obj_call_init(s);
return s;
}
@@ -958,7 +955,6 @@ unix_s_sock_open(sock, path)
{
VALUE s;
s = open_unix(sock, path, 0);
- obj_call_init(s);
return s;
}
@@ -985,7 +981,6 @@ unix_svr_s_open(sock, path)
{
VALUE s;
s = open_unix(sock, path, 1);
- obj_call_init(s);
return s;
}
@@ -1144,20 +1139,15 @@ sock_s_open(class, domain, type, protocol)
setup_domain_and_type(domain, &d, type, &t);
fd = socket(d, t, NUM2INT(protocol));
if (fd < 0) rb_sys_fail("socket(2)");
- s = sock_new(class, fd);
- obj_call_init(s);
- return s;
+ return sock_new(class, fd);
}
static VALUE
sock_s_for_fd(class, fd)
VALUE class, fd;
{
- VALUE s = sock_new(class, NUM2INT(fd));
-
- obj_call_init(s);
- return s;
+ return sock_new(class, NUM2INT(fd));
}
static VALUE
diff --git a/file.c b/file.c
index 338a1dd5577..3ed9e2ff60e 100644
--- a/file.c
+++ b/file.c
@@ -73,6 +73,7 @@ file_open(fname, mode)
fptr->mode = io_mode_flags(mode);
fptr->f = rb_fopen(fname, mode);
fptr->path = strdup(fname);
+ obj_call_init((VALUE)port);
return (VALUE)port;
}
diff --git a/io.c b/io.c
index 9f7be6777a5..ee3f23b8c99 100644
--- a/io.c
+++ b/io.c
@@ -1002,6 +1002,7 @@ pipe_open(pname, mode)
fptr->f2 = f;
io_unbuffered(fptr);
}
+ obj_call_init((VALUE)port);
return (VALUE)port;
}
#else
@@ -1089,6 +1090,7 @@ pipe_open(pname, mode)
fptr->finalize = pipe_finalize;
pipe_add_fptr(fptr);
#endif
+ obj_call_init((VALUE)port);
return (VALUE)port;
}
}
@@ -1454,14 +1456,21 @@ f_puts(argc, argv)
}
static VALUE
-f_p(obj, val)
- VALUE obj, val;
+f_p(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
{
- VALUE str = rb_inspect(val);
+ VALUE str;
+ if (argc > 0) {
+ rb_scan_args(argc, argv, "1", &self);
+ }
+ str = rb_inspect(self);
Check_Type(str, T_STRING);
io_write(rb_defout, str);
io_write(rb_defout, str_new2("\n"));
+
return Qnil;
}
@@ -1469,7 +1478,26 @@ void
rb_p(obj) /* for debug print within C code */
VALUE obj;
{
- f_p(Qnil, obj);
+ f_p(0, 0, obj);
+}
+
+static VALUE
+obj_display(argc, argv, self)
+ int argc;
+ VALUE *argv;
+ VALUE self;
+{
+ VALUE out;
+ VALUE str;
+
+ rb_scan_args(argc, argv, "01", &out);
+ if (NIL_P(out)) {
+ out = rb_defout;
+ }
+
+ io_write(out, self);
+
+ return Qnil;
}
static void
@@ -1512,29 +1540,31 @@ io_stdio_set(val, id, var)
}
static VALUE
-prep_stdio(f, mode)
+prep_stdio(f, mode, klass)
FILE *f;
int mode;
+ VALUE klass;
{
OpenFile *fp;
NEWOBJ(obj, struct RFile);
- OBJSETUP(obj, cIO, T_FILE);
+ OBJSETUP(obj, klass, T_FILE);
MakeOpenFile(obj, fp);
fp->f = f;
fp->mode = mode;
+ obj_call_init((VALUE)obj);
return (VALUE)obj;
}
static VALUE
-io_s_new(argc, argv)
+io_s_new(argc, argv, klass)
int argc;
VALUE *argv;
+ VALUE klass;
{
VALUE fnum, mode;
char *m = "r";
- VALUE io;
rb_scan_args(argc, argv, "11", &fnum, &mode);
@@ -1542,10 +1572,7 @@ io_s_new(argc, argv)
Check_SafeStr(mode);
m = RSTRING(mode)->ptr;
}
- io = prep_stdio(rb_fdopen(NUM2INT(fnum), m), io_mode_flags(m));
- obj_call_init(io);
-
- return io;
+ return prep_stdio(rb_fdopen(NUM2INT(fnum), m), io_mode_flags(m), klass);
}
static VALUE filename, file;
@@ -1635,9 +1662,9 @@ next_argv()
fchown(fileno(fw), st.st_uid, st.st_gid);
}
#endif
- rb_defout = prep_stdio(fw, FMODE_WRITABLE);
+ rb_defout = prep_stdio(fw, FMODE_WRITABLE, cIO);
}
- file = prep_stdio(fr, FMODE_READABLE);
+ file = prep_stdio(fr, FMODE_READABLE, cIO);
}
}
else {
@@ -2135,8 +2162,8 @@ io_s_pipe()
#endif
rb_sys_fail(0);
- r = prep_stdio(fdopen(pipes[0], "r"), FMODE_READABLE);
- w = prep_stdio(fdopen(pipes[1], "w"), FMODE_WRITABLE);
+ r = prep_stdio(fdopen(pipes[0], "r"), FMODE_READABLE, cIO);
+ w = prep_stdio(fdopen(pipes[1], "w"), FMODE_WRITABLE, cIO);
ary = ary_new2(2);
ary_push(ary, r);
@@ -2396,7 +2423,8 @@ Init_IO()
rb_define_global_function("`", f_backquote, 1);
rb_define_global_function("pipe", io_s_pipe, 0);
- rb_define_global_function("p", f_p, 1);
+ rb_define_method(mKernel, "p", f_p, -1);
+ rb_define_method(mKernel, "display", obj_display, -1);
cIO = rb_define_class("IO", cObject);
rb_include_module(cIO, mEnumerable);
@@ -2466,11 +2494,11 @@ Init_IO()
rb_define_method(cIO, "ioctl", io_ioctl, -1);
rb_define_method(cIO, "fcntl", io_fcntl, -1);
- rb_stdin = prep_stdio(stdin, FMODE_READABLE);
+ rb_stdin = prep_stdio(stdin, FMODE_READABLE, cIO);
rb_define_hooked_variable("$stdin", &rb_stdin, 0, io_stdio_set);
- rb_stdout = prep_stdio(stdout, FMODE_WRITABLE);
+ rb_stdout = prep_stdio(stdout, FMODE_WRITABLE, cIO);
rb_define_hooked_variable("$stdout", &rb_stdout, 0, io_stdio_set);
- rb_stderr = prep_stdio(stderr, FMODE_WRITABLE);
+ rb_stderr = prep_stdio(stderr, FMODE_WRITABLE, cIO);
rb_define_hooked_variable("$stderr", &rb_stderr, 0, io_stdio_set);
rb_defout = rb_stdout;
rb_define_hooked_variable("$>", &rb_defout, 0, io_defset);
diff --git a/lib/delegate.rb b/lib/delegate.rb
index a4bbe0615c3..c73a3bd8a02 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -13,12 +13,12 @@
class Delegator
def initialize(obj)
+ preserved = ::Kernel.instance_methods
for t in self.type.ancestors
preserved |= t.instance_methods
break if t == Delegator
end
- preserved |= ::Kernel.instance_methods
- preserved -= ["to_s", "nil?", "to_a", "hash", "dup", "==", "=~"]
+ preserved -= ["__getobj__","to_s","nil?","to_a","hash","dup","==","=~"]
for method in obj.methods
next if preserved.include? method
eval "def self.#{method}(*args,&block); __getobj__.__send__(:#{method}, *args,&block); end"
diff --git a/parse.y b/parse.y
index e511257b618..1db24ef38aa 100644
--- a/parse.y
+++ b/parse.y
@@ -166,9 +166,9 @@ static void top_local_setup();
k__LINE__
k__FILE__
-%token <id> IDENTIFIER FID GVAR IVAR CONSTANT
-%token <val> INTEGER FLOAT STRING XSTRING REGEXP
-%token <node> DSTRING DXSTRING DREGEXP NTH_REF BACK_REF
+%token <id> tIDENTIFIER tFID tGVAR tIVAR tCONSTANT
+%token <val> tINTEGER tFLOAT tSTRING tXSTRING tREGEXP
+%token <node> tDSTRING tDXSTRING tDREGEXP tNTH_REF tBACK_REF
%type <node> singleton
%type <val> literal numeric
@@ -184,30 +184,30 @@ static void top_local_setup();
%type <id> variable symbol operation
%type <id> cname fname op f_rest_arg
%type <num> f_arg
-%token UPLUS /* unary+ */
-%token UMINUS /* unary- */
-%token POW /* ** */
-%token CMP /* <=> */
-%token EQ /* == */
-%token EQQ /* === */
-%token NEQ /* != <> */
-%token GEQ /* >= */
-%token LEQ /* <= */
-%token ANDOP OROP /* && and || */
-%token MATCH NMATCH /* =~ and !~ */
-%token DOT2 DOT3 /* .. and ... */
-%token AREF ASET /* [] and []= */
-%token LSHFT RSHFT /* << and >> */
-%token COLON2 /* :: */
-%token COLON3 /* :: at EXPR_BEG */
-%token <id> OP_ASGN /* +=, -= etc. */
-%token ASSOC /* => */
-%token LPAREN /* ( */
-%token LBRACK /* [ */
-%token LBRACE /* { */
-%token STAR /* * */
-%token AMPER /* & */
-%token SYMBEG
+%token tUPLUS /* unary+ */
+%token tUMINUS /* unary- */
+%token tPOW /* ** */
+%token tCMP /* <=> */
+%token tEQ /* == */
+%token tEQQ /* === */
+%token tNEQ /* != <> */
+%token tGEQ /* >= */
+%token tLEQ /* <= */
+%token tANDOP tOROP /* && and || */
+%token tMATCH tNMATCH /* =~ and !~ */
+%token tDOT2 tDOT3 /* .. and ... */
+%token tAREF tASET /* [] and []= */
+%token tLSHFT tRSHFT /* << and >> */
+%token tCOLON2 /* :: */
+%token tCOLON3 /* :: at EXPR_BEG */
+%token <id> tOP_ASGN /* +=, -= etc. */
+%token tASSOC /* => */
+%token tLPAREN /* ( */
+%token tLBRACK /* [ */
+%token tLBRACE /* { */
+%token tSTAR /* * */
+%token tAMPER /* & */
+%token tSYMBEG
/*
* precedence table
@@ -217,20 +217,20 @@ static void top_local_setup();
%left kOR kAND
%right kNOT
%nonassoc kDEFINED
-%right '=' OP_ASGN
+%right '=' tOP_ASGN
%right '?' ':'
-%nonassoc DOT2 DOT3
-%left OROP
-%left ANDOP
-%nonassoc CMP EQ EQQ NEQ MATCH NMATCH
-%left '>' GEQ '<' LEQ
+%nonassoc tDOT2 tDOT3
+%left tOROP
+%left tANDOP
+%nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH
+%left '>' tGEQ '<' tLEQ
%left '|' '^'
%left '&'
-%left LSHFT RSHFT
+%left tLSHFT tRSHFT
%left '+' '-'
%left '*' '/' '%'
-%right '!' '~' UPLUS UMINUS
-%right POW
+%right '!' '~' tUPLUS tUMINUS
+%right tPOW
%token LAST_TOKEN
@@ -284,13 +284,13 @@ stmt : iterator iter_do_block
yyerror("alias within method");
$$ = NEW_ALIAS($2, $4);
}
- | kALIAS GVAR GVAR
+ | kALIAS tGVAR tGVAR
{
if (cur_mid || in_single)
yyerror("alias within method");
$$ = NEW_VALIAS($2, $3);
}
- | kALIAS GVAR BACK_REF
+ | kALIAS tGVAR tBACK_REF
{
char buf[3];
@@ -299,7 +299,7 @@ stmt : iterator iter_do_block
sprintf(buf, "$%c", $3->nd_nth);
$$ = NEW_VALIAS($2, rb_intern(buf));
}
- | kALIAS GVAR NTH_REF
+ | kALIAS tGVAR tNTH_REF
{
yyerror("can't make alias for the number variables");
$$ = 0;
@@ -416,7 +416,7 @@ command_call : operation call_args
$$ = new_call($1, $3, $4);
fixpos($$, $1);
}
- | primary COLON2 operation call_args
+ | primary tCOLON2 operation call_args
{
value_expr($1);
$$ = new_call($1, $3, $4);
@@ -434,7 +434,7 @@ mlhs : mlhs_head
{
$$ = NEW_MASGN(NEW_LIST($1), 0);
}
- | mlhs_head STAR lhs
+ | mlhs_head tSTAR lhs
{
$$ = NEW_MASGN(NEW_LIST($1), $3);
}
@@ -442,11 +442,11 @@ mlhs : mlhs_head
{
$$ = NEW_MASGN(list_concat(NEW_LIST($1),$2), 0);
}
- | mlhs_head mlhs_tail ',' STAR lhs
+ | mlhs_head mlhs_tail ',' tSTAR lhs
{
$$ = NEW_MASGN(list_concat(NEW_LIST($1),$2),$5);
}
- | STAR lhs
+ | tSTAR lhs
{
$$ = NEW_MASGN(0, $2);
}
@@ -470,7 +470,7 @@ lhs : variable
{
$$ = aryset($1, $3, 0);
}
- | primary '.' IDENTIFIER
+ | primary '.' tIDENTIFIER
{
$$ = attrset($1, $3, 0);
}
@@ -480,15 +480,15 @@ lhs : variable
$$ = 0;
}
-cname : IDENTIFIER
+cname : tIDENTIFIER
{
yyerror("class/module name must be CONSTANT");
}
- | CONSTANT
+ | tCONSTANT
-fname : IDENTIFIER
- | CONSTANT
- | FID
+fname : tIDENTIFIER
+ | tCONSTANT
+ | tFID
| op
{
lex_state = EXPR_END;
@@ -509,32 +509,32 @@ undef_list : fname
$$ = block_append($1, NEW_UNDEF($4));
}
-op : DOT2 { $$ = DOT2; }
+op : tDOT2 { $$ = tDOT2; }
| '|' { $$ = '|'; }
| '^' { $$ = '^'; }
| '&' { $$ = '&'; }
- | CMP { $$ = CMP; }
- | EQ { $$ = EQ; }
- | EQQ { $$ = EQQ; }
- | MATCH { $$ = MATCH; }
+ | tCMP { $$ = tCMP; }
+ | tEQ { $$ = tEQ; }
+ | tEQQ { $$ = tEQQ; }
+ | tMATCH { $$ = tMATCH; }
| '>' { $$ = '>'; }
- | GEQ { $$ = GEQ; }
+ | tGEQ { $$ = tGEQ; }
| '<' { $$ = '<'; }
- | LEQ { $$ = LEQ; }
- | LSHFT { $$ = LSHFT; }
- | RSHFT { $$ = RSHFT; }
+ | tLEQ { $$ = tLEQ; }
+ | tLSHFT { $$ = tLSHFT; }
+ | tRSHFT { $$ = tRSHFT; }
| '+' { $$ = '+'; }
| '-' { $$ = '-'; }
| '*' { $$ = '*'; }
- | STAR { $$ = '*'; }
+ | tSTAR { $$ = '*'; }
| '/' { $$ = '/'; }
| '%' { $$ = '%'; }
- | POW { $$ = POW; }
+ | tPOW { $$ = tPOW; }
| '~' { $$ = '~'; }
- | UPLUS { $$ = UPLUS; }
- | UMINUS { $$ = UMINUS; }
- | AREF { $$ = AREF; }
- | ASET { $$ = ASET; }
+ | tUPLUS { $$ = tUPLUS; }
+ | tUMINUS { $$ = tUMINUS; }
+ | tAREF { $$ = tAREF; }
+ | tASET { $$ = tASET; }
| '`' { $$ = '`'; }
reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND
@@ -556,7 +556,7 @@ arg : variable '=' arg
$$ = aryset($1, $3, $6);
fixpos($$, $1);
}
- | primary '.' IDENTIFIER '=' arg
+ | primary '.' tIDENTIFIER '=' arg
{
$$ = attrset($1, $3, $5);
fixpos($$, $5);
@@ -567,7 +567,7 @@ arg : variable '=' arg
backref_error($1);
$$ = 0;
}
- | variable OP_ASGN arg
+ | variable tOP_ASGN arg
{
value_expr($3);
if (is_local_id($1)) {
@@ -581,7 +581,7 @@ arg : variable '=' arg
$$ = assignable($1,call_op(gettable($1),$2,1,$3));
fixpos($$, $3);
}
- | primary '[' aref_args ']' OP_ASGN arg
+ | primary '[' aref_args ']' tOP_ASGN arg
{
NODE *args = NEW_LIST($6);
@@ -590,26 +590,26 @@ arg : variable '=' arg
$$ = NEW_OP_ASGN1($1, $5, args);
fixpos($$, $1);
}
- | primary '.' IDENTIFIER OP_ASGN arg
+ | primary '.' tIDENTIFIER tOP_ASGN arg
{
$$ = NEW_OP_ASGN2($1, $3, $4, $5);
fixpos($$, $1);
}
- | primary '.' CONSTANT OP_ASGN arg
+ | primary '.' tCONSTANT tOP_ASGN arg
{
$$ = NEW_OP_ASGN2($1, $3, $4, $5);
fixpos($$, $1);
}
- | backref OP_ASGN arg
+ | backref tOP_ASGN arg
{
backref_error($1);
$$ = 0;
}
- | arg DOT2 arg
+ | arg tDOT2 arg
{
$$ = NEW_DOT2($1, $3);
}
- | arg DOT3 arg
+ | arg tDOT3 arg
{
$$ = NEW_DOT3($1, $3);
}
@@ -633,17 +633,17 @@ arg : variable '=' arg
{
$$ = call_op($1, '%', 1, $3);
}
- | arg POW arg
+ | arg tPOW arg
{
- $$ = call_op($1, POW, 1, $3);
+ $$ = call_op($1, tPOW, 1, $3);
}
- | UPLUS arg
+ | tUPLUS arg
{
- $$ = call_op($2, UPLUS, 0);
+ $$ = call_op($2, tUPLUS, 0);
}
- | UMINUS arg
+ | tUMINUS arg
{
- $$ = call_op($2, UMINUS, 0);
+ $$ = call_op($2, tUMINUS, 0);
}
| arg '|' arg
{
@@ -657,43 +657,43 @@ arg : variable '=' arg
{
$$ = call_op($1, '&', 1, $3);
}
- | arg CMP arg
+ | arg tCMP arg
{
- $$ = call_op($1, CMP, 1, $3);
+ $$ = call_op($1, tCMP, 1, $3);
}
| arg '>' arg
{
$$ = call_op($1, '>', 1, $3);
}
- | arg GEQ arg
+ | arg tGEQ arg
{
- $$ = call_op($1, GEQ, 1, $3);
+ $$ = call_op($1, tGEQ, 1, $3);
}
| arg '<' arg
{
$$ = call_op($1, '<', 1, $3);
}
- | arg LEQ arg
+ | arg tLEQ arg
{
- $$ = call_op($1, LEQ, 1, $3);
+ $$ = call_op($1, tLEQ, 1, $3);
}
- | arg EQ arg
+ | arg tEQ arg
{
- $$ = call_op($1, EQ, 1, $3);
+ $$ = call_op($1, tEQ, 1, $3);
}
- | arg EQQ arg
+ | arg tEQQ arg
{
- $$ = call_op($1, EQQ, 1, $3);
+ $$ = call_op($1, tEQQ, 1, $3);
}
- | arg NEQ arg
+ | arg tNEQ arg
{
- $$ = NEW_NOT(call_op($1, EQ, 1, $3));
+ $$ = NEW_NOT(call_op($1, tEQ, 1, $3));
}
- | arg MATCH arg
+ | arg tMATCH arg
{
$$ = match_gen($1, $3);
}
- | arg NMATCH arg
+ | arg tNMATCH arg
{
$$ = NEW_NOT(match_gen($1, $3));
}
@@ -706,19 +706,19 @@ arg : variable '=' arg
{
$$ = call_op($2, '~', 0);
}
- | arg LSHFT arg
+ | arg tLSHFT arg
{
- $$ = call_op($1, LSHFT, 1, $3);
+ $$ = call_op($1, tLSHFT, 1, $3);
}
- | arg RSHFT arg
+ | arg tRSHFT arg
{
- $$ = call_op($1, RSHFT, 1, $3);
+ $$ = call_op($1, tRSHFT, 1, $3);
}
- | arg ANDOP arg
+ | arg tANDOP arg
{
$$ = logop(NODE_AND, $1, $3);
}
- | arg OROP arg
+ | arg tOROP arg
{
$$ = logop(NODE_OR, $1, $3);
}
@@ -761,7 +761,7 @@ call_args : command_call
{
$$ = arg_blk_pass($1, $2);
}
- | args ',' STAR arg opt_block_arg
+ | args ',' tSTAR arg opt_block_arg
{
$$ = arg_add($1, $4);
$$ = arg_blk_pass($$, $5);
@@ -771,7 +771,7 @@ call_args : command_call
$$ = NEW_LIST(NEW_HASH($1));
$$ = arg_blk_pass($$, $2);
}
- | assocs ',' STAR arg opt_block_arg
+ | assocs ',' tSTAR arg opt_block_arg
{
$$ = arg_add(NEW_LIST(NEW_HASH($1)), $4);
$$ = arg_blk_pass($$, $5);
@@ -781,19 +781,19 @@ call_args : command_call
$$ = list_append($1, NEW_HASH($3));
$$ = arg_blk_pass($$, $4);
}
- | args ',' assocs ',' STAR arg opt_block_arg
+ | args ',' assocs ',' tSTAR arg opt_block_arg
{
$$ = arg_add(list_append($1, NEW_HASH($3)), $6);
$$ = arg_blk_pass($$, $7);
}
- | STAR arg opt_block_arg
+ | tSTAR arg opt_block_arg
{
value_expr($2);
$$ = arg_blk_pass($2, $3);
}
| block_arg
-block_arg : AMPER arg
+block_arg : tAMPER arg
{
value_expr($2);
$$ = NEW_BLOCK_PASS($2);
@@ -836,11 +836,11 @@ mrhs : args
$$ = $1;
}
}
- | args ',' STAR arg
+ | args ',' tSTAR arg
{
$$ = arg_add($1, $4);
}
- | STAR arg
+ | tSTAR arg
{
value_expr($2);
$$ = $2;
@@ -870,34 +870,34 @@ primary : literal
{
$$ = NEW_LIT($1);
}
- | primary COLON2 cname
+ | primary tCOLON2 cname
{
value_expr($1);
$$ = NEW_COLON2($1, $3);
}
- | COLON3 cname
+ | tCOLON3 cname
{
$$ = NEW_COLON3($2);
}
- | STRING
+ | tSTRING
{
$$ = NEW_STR($1);
}
- | DSTRING
- | XSTRING
+ | tDSTRING
+ | tXSTRING
{
$$ = NEW_XSTR($1);
}
- | DXSTRING
- | DREGEXP
+ | tDXSTRING
+ | tDREGEXP
| var_ref
| backref
| primary '[' aref_args ']'
{
value_expr($1);
- $$ = NEW_CALL($1, AREF, $3);
+ $$ = NEW_CALL($1, tAREF, $3);
}
- | LBRACK array ']'
+ | tLBRACK array ']'
{
if ($2 == 0)
$$ = NEW_ZARRAY(); /* zero length array*/
@@ -905,7 +905,7 @@ primary : literal
$$ = $2;
}
}
- | LBRACE assoc_list '}'
+ | tLBRACE assoc_list '}'
{
$$ = NEW_HASH($2);
}
@@ -946,7 +946,7 @@ primary : literal
in_defined = 0;
$$ = NEW_DEFINED($5);
}
- | FID
+ | tFID
{
$$ = NEW_VCALL($1);
}
@@ -1030,7 +1030,7 @@ primary : literal
}
fixpos($$, $2);
}
- | LPAREN compstmt ')'
+ | tLPAREN compstmt ')'
{
$$ = $2;
}
@@ -1052,7 +1052,7 @@ primary : literal
cref_pop();
class_nest--;
}
- | kCLASS LSHFT expr term
+ | kCLASS tLSHFT expr term
{
class_nest++;
cref_push();
@@ -1172,7 +1172,7 @@ opt_iter_var : /* node */
{
$$ = 0;
}
- | OROP
+ | tOROP
{
$$ = 0;
}
@@ -1206,15 +1206,15 @@ iter_block : '{'
dyna_pop($<vars>2);
}
-iterator : IDENTIFIER
+iterator : tIDENTIFIER
{
$$ = NEW_VCALL($1);
}
- | CONSTANT
+ | tCONSTANT
{
$$ = NEW_VCALL($1);
}
- | FID
+ | tFID
{
$$ = NEW_VCALL($1);
}
@@ -1237,7 +1237,7 @@ method_call : operation '(' opt_call_args ')'
value_expr($1);
$$ = new_call($1, $3, 0);
}
- | primary COLON2 operation '(' opt_call_args ')'
+ | primary tCOLON2 operation '(' opt_call_args ')'
{
value_expr($1);
$$ = new_call($1, $3, $5);
@@ -1289,23 +1289,23 @@ ensure : /* none */
}
literal : numeric
- | SYMBEG symbol
+ | tSYMBEG symbol
{
$$ = INT2FIX($2);
}
- | REGEXP
+ | tREGEXP
symbol : fname
- | IVAR
- | GVAR
+ | tIVAR
+ | tGVAR
-numeric : INTEGER
- | FLOAT
+numeric : tINTEGER
+ | tFLOAT
-variable : IDENTIFIER
- | IVAR
- | GVAR
- | CONSTANT
+variable : tIDENTIFIER
+ | tIVAR
+ | tGVAR
+ | tCONSTANT
| kNIL {$$ = kNIL;}
| kSELF {$$ = kSELF;}
| kTRUE {$$ = kTRUE;}
@@ -1318,8 +1318,8 @@ var_ref : variable
$$ = gettable($1);
}
-backref : NTH_REF
- | BACK_REF
+backref : tNTH_REF
+ | tBACK_REF
superclass : term
{
@@ -1382,14 +1382,14 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
$$ = NEW_ARGS(0, 0, -1);
}
-f_arg : IDENTIFIER
+f_arg : tIDENTIFIER
{
if (!is_local_id($1))
yyerror("formal argument must be local variable");
local_cnt($1);
$$ = 1;
}
- | f_arg ',' IDENTIFIER
+ | f_arg ',' tIDENTIFIER
{
if (!is_local_id($3))
yyerror("formal argument must be local variable");
@@ -1397,7 +1397,7 @@ f_arg : IDENTIFIER
$$ += 1;
}
-f_opt : IDENTIFIER '=' arg
+f_opt : tIDENTIFIER '=' arg
{
if (!is_local_id($1))
yyerror("formal argument must be local variable");
@@ -1414,14 +1414,14 @@ f_optarg : f_opt
$$ = block_append($1, $3);
}
-f_rest_arg : STAR IDENTIFIER
+f_rest_arg : tSTAR tIDENTIFIER
{
if (!is_local_id($2))
yyerror("rest argument must be local variable");
$$ = local_cnt($2);
}
-f_block_arg : AMPER IDENTIFIER
+f_block_arg : tAMPER tIDENTIFIER
{
$$ = NEW_BLOCK_ARG($2);
}
@@ -1448,7 +1448,7 @@ singleton : var_ref
$$ = $1;
}
}
- | LPAREN expr opt_nl ')'
+ | tLPAREN expr opt_nl ')'
{
switch (nd_type($2)) {
case NODE_STR:
@@ -1488,14 +1488,14 @@ assocs : assoc
$$ = list_concat($1, $3);
}
-assoc : arg ASSOC arg
+assoc : arg tASSOC arg
{
$$ = list_append(NEW_LIST($1), $3);
}
-operation : IDENTIFIER
- | CONSTANT
- | FID
+operation : tIDENTIFIER
+ | tCONSTANT
+ | tFID
opt_terms : /* none */
| terms
@@ -1535,15 +1535,15 @@ static NODE *str_extend();
static VALUE lex_input; /* non-nil if File */
static VALUE lex_lastline; /* gc protect */
-static char *lex_pbeg;
-static char *lex_p;
-static char *lex_pend;
+static UCHAR *lex_pbeg;
+static UCHAR *lex_p;
+static UCHAR *lex_pend;
static int
yyerror(msg)
char *msg;
{
- char *p, *pe, *buf;
+ UCHAR *p, *pe, *buf;
int len, i;
Error("%s", msg);
@@ -1948,11 +1948,11 @@ parse_regx(term)
nd_set_type(list, once?NODE_DREGX_ONCE:NODE_DREGX);
list->nd_cflag = kcode | casefold;
yylval.node = list;
- return DREGEXP;
+ return tDREGEXP;
}
else {
yylval.val = reg_new(tok(), toklen(), kcode | casefold);
- return REGEXP;
+ return tREGEXP;
}
}
tokadd(c);
@@ -2024,15 +2024,15 @@ parse_string(func,term)
yylval.node = list;
if (func == '`') {
nd_set_type(list, NODE_DXSTR);
- return DXSTRING;
+ return tDXSTRING;
}
else {
- return DSTRING;
+ return tDSTRING;
}
}
else {
yylval.val = str_new(tok(), toklen());
- return (func == '`') ? XSTRING : STRING;
+ return (func == '`') ? tXSTRING : tSTRING;
}
}
@@ -2085,7 +2085,7 @@ parse_qstring(term)
tokfix();
yylval.val = str_new(tok(), toklen());
lex_state = EXPR_END;
- return STRING;
+ return tSTRING;
}
static int
@@ -2094,7 +2094,7 @@ parse_quotedword(term)
{
if (parse_qstring(term) == 0) return 0;
yylval.node = NEW_CALL(NEW_STR(yylval.val), rb_intern("split"), 0);
- return DSTRING;
+ return tDSTRING;
}
char *strdup();
@@ -2161,8 +2161,8 @@ here_document(term)
lex_pbeg = lex_p = RSTRING(line)->ptr;
lex_pend = lex_p + RSTRING(line)->len;
switch (parse_string(term, '\n')) {
- case STRING:
- case XSTRING:
+ case tSTRING:
+ case tXSTRING:
str_cat(yylval.val, "\n", 1);
if (!list) {
str_cat(str, RSTRING(yylval.val)->ptr, RSTRING(yylval.val)->len);
@@ -2171,8 +2171,8 @@ here_document(term)
list_append(list, NEW_STR(yylval.val));
}
break;
- case DSTRING:
- case DXSTRING:
+ case tDSTRING:
+ case tDXSTRING:
list_append(yylval.node, NEW_STR(str_new2("\n")));
nd_set_type(yylval.node, NODE_STR);
if (!list) list = NEW_DSTR(str);
@@ -2199,12 +2199,12 @@ here_document(term)
switch (term) {
case '\'':
case '"':
- if (list) return DSTRING;
+ if (list) return tDSTRING;
yylval.val = str;
- return STRING;
+ return tSTRING;
case '`':
- if (list) return DXSTRING;
- return XSTRING;
+ if (list) return tDXSTRING;
+ return tXSTRING;
}
return 0;
}
@@ -2280,26 +2280,26 @@ retry:
if ((c = nextc()) == '*') {
lex_state = EXPR_BEG;
if (nextc() == '=') {
- yylval.id = POW;
- return OP_ASGN;
+ yylval.id = tPOW;
+ return tOP_ASGN;
}
pushback(c);
- return POW;
+ return tPOW;
}
if (c == '=') {
yylval.id = '*';
lex_state = EXPR_BEG;
- return OP_ASGN;
+ return tOP_ASGN;
}
pushback(c);
if (lex_state == EXPR_ARG && space_seen && !isspace(c)){
arg_ambiguous();
lex_state = EXPR_BEG;
- return STAR;
+ return tSTAR;
}
if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
lex_state = EXPR_BEG;
- return STAR;
+ return tSTAR;
}
lex_state = EXPR_BEG;
return '*';
@@ -2307,10 +2307,10 @@ retry:
case '!':
lex_state = EXPR_BEG;
if ((c = nextc()) == '=') {
- return NEQ;
+ return tNEQ;
}
if (c == '~') {
- return NMATCH;
+ return tNMATCH;
}
pushback(c);
return '!';
@@ -2341,16 +2341,16 @@ retry:
lex_state = EXPR_BEG;
if ((c = nextc()) == '=') {
if ((c = nextc()) == '=') {
- return EQQ;
+ return tEQQ;
}
pushback(c);
- return EQ;
+ return tEQ;
}
if (c == '~') {
- return MATCH;
+ return tMATCH;
}
else if (c == '>') {
- return ASSOC;
+ return tASSOC;
}
pushback(c);
return '=';
@@ -2373,18 +2373,18 @@ retry:
lex_state = EXPR_BEG;
if (c == '=') {
if ((c = nextc()) == '>') {
- return CMP;
+ return tCMP;
}
pushback(c);
- return LEQ;
+ return tLEQ;
}
if (c == '<') {
if (nextc() == '=') {
- yylval.id = LSHFT;
- return OP_ASGN;
+ yylval.id = tLSHFT;
+ return tOP_ASGN;
}
pushback(c);
- return LSHFT;
+ return tLSHFT;
}
pushback(c);
return '<';
@@ -2392,15 +2392,15 @@ retry:
case '>':
lex_state = EXPR_BEG;
if ((c = nextc()) == '=') {
- return GEQ;
+ return tGEQ;
}
if (c == '>') {
if ((c = nextc()) == '=') {
- yylval.id = RSHFT;
- return OP_ASGN;
+ yylval.id = tRSHFT;
+ return tOP_ASGN;
}
pushback(c);
- return RSHFT;
+ return tRSHFT;
}
pushback(c);
return '>';
@@ -2434,27 +2434,27 @@ retry:
c &= 0xff;
yylval.val = INT2FIX(c);
lex_state = EXPR_END;
- return INTEGER;
+ return tINTEGER;
case '&':
if ((c = nextc()) == '&') {
lex_state = EXPR_BEG;
- return ANDOP;
+ return tANDOP;
}
else if (c == '=') {
yylval.id = '&';
lex_state = EXPR_BEG;
- return OP_ASGN;
+ return tOP_ASGN;
}
pushback(c);
if (lex_state == EXPR_ARG && space_seen && !isspace(c)){
arg_ambiguous();
lex_state = EXPR_BEG;
- return AMPER;
+ return tAMPER;
}
if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
lex_state = EXPR_BEG;
- return AMPER;
+ return tAMPER;
}
lex_state = EXPR_BEG;
return '&';
@@ -2462,11 +2462,11 @@ retry:
case '|':
lex_state = EXPR_BEG;
if ((c = nextc()) == '|') {
- return OROP;
+ return tOROP;
}
else if (c == '=') {
yylval.id = '|';
- return OP_ASGN;
+ return tOP_ASGN;
}
pushback(c);
return '|';
@@ -2475,7 +2475,7 @@ retry:
c = nextc();
if (lex_state == EXPR_FNAME) {
if (c == '@') {
- return UPLUS;
+ return tUPLUS;
}
pushback(c);
return '+';
@@ -2483,7 +2483,7 @@ retry:
if (c == '=') {
lex_state = EXPR_BEG;
yylval.id = '+';
- return OP_ASGN;
+ return tOP_ASGN;
}
if (lex_state == EXPR_ARG) {
if (space_seen && !isspace(c)) {
@@ -2499,7 +2499,7 @@ retry:
}
pushback(c);
lex_state = EXPR_BEG;
- return UPLUS;
+ return tUPLUS;
}
lex_state = EXPR_BEG;
pushback(c);
@@ -2509,7 +2509,7 @@ retry:
c = nextc();
if (lex_state == EXPR_FNAME) {
if (c == '@') {
- return UMINUS;
+ return tUMINUS;
}
pushback(c);
return '-';
@@ -2517,7 +2517,7 @@ retry:
if (c == '=') {
lex_state = EXPR_BEG;
yylval.id = '-';
- return OP_ASGN;
+ return tOP_ASGN;
}
if (lex_state == EXPR_ARG) {
if (space_seen && !isspace(c)) {
@@ -2535,7 +2535,7 @@ retry:
}
lex_state = EXPR_BEG;
pushback(c);
- return UMINUS;
+ return tUMINUS;
}
lex_state = EXPR_BEG;
pushback(c);
@@ -2545,10 +2545,10 @@ retry:
lex_state = EXPR_BEG;
if ((c = nextc()) == '.') {
if ((c = nextc()) == '.') {
- return DOT3;
+ return tDOT3;
}
pushback(c);
- return DOT2;
+ return tDOT2;
}
pushback(c);
if (!isdigit(c)) {
@@ -2583,7 +2583,7 @@ retry:
pushback(c);
tokfix();
yylval.val = str2inum(tok(), 16);
- return INTEGER;
+ return tINTEGER;
}
else if (c >= '0' && c <= '7') {
/* octal */
@@ -2595,7 +2595,7 @@ retry:
pushback(c);
tokfix();
yylval.val = str2inum(tok(), 8);
- return INTEGER;
+ return tINTEGER;
}
else if (c > '7' && c <= '9') {
yyerror("Illegal octal digit");
@@ -2606,7 +2606,7 @@ retry:
else {
pushback(c);
yylval.val = INT2FIX(0);
- return INTEGER;
+ return tINTEGER;
}
}
@@ -2663,10 +2663,10 @@ retry:
tokfix();
if (is_float) {
yylval.val = float_new(atof(tok()));
- return FLOAT;
+ return tFLOAT;
}
yylval.val = str2inum(tok(), 10);
- return INTEGER;
+ return tINTEGER;
}
case ']':
@@ -2680,15 +2680,15 @@ retry:
if (c == ':') {
if (lex_state == EXPR_BEG) {
lex_state = EXPR_BEG;
- return COLON3;
+ return tCOLON3;
}
if (lex_state == EXPR_ARG && space_seen) {
arg_ambiguous();
lex_state = EXPR_BEG;
- return COLON3;
+ return tCOLON3;
}
lex_state = EXPR_DOT;
- return COLON2;
+ return tCOLON2;
}
pushback(c);
if (lex_state == EXPR_END || isspace(c)) {
@@ -2696,7 +2696,7 @@ retry:
return ':';
}
lex_state = EXPR_FNAME;
- return SYMBEG;
+ return tSYMBEG;
case '/':
if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
@@ -2705,7 +2705,7 @@ retry:
if ((c = nextc()) == '=') {
lex_state = EXPR_BEG;
yylval.id = '/';
- return OP_ASGN;
+ return tOP_ASGN;
}
if (lex_state == EXPR_ARG) {
if (space_seen && !isspace(c)) {
@@ -2722,7 +2722,7 @@ retry:
lex_state = EXPR_BEG;
if (nextc() == '=') {
yylval.id = '^';
- return OP_ASGN;
+ return tOP_ASGN;
}
pushback(c);
return c;
@@ -2743,7 +2743,7 @@ retry:
case '(':
if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
- c = LPAREN;
+ c = tLPAREN;
lex_state = EXPR_BEG;
}
else {
@@ -2755,27 +2755,27 @@ retry:
if (lex_state == EXPR_FNAME) {
if ((c = nextc()) == ']') {
if ((c = nextc()) == '=') {
- return ASET;
+ return tASET;
}
pushback(c);
- return AREF;
+ return tAREF;
}
pushback(c);
return '[';
}
else if (lex_state == EXPR_BEG || lex_state == EXPR_MID) {
- c = LBRACK;
+ c = tLBRACK;
}
else if (lex_state == EXPR_ARG && space_seen) {
arg_ambiguous();
- c = LBRACK;
+ c = tLBRACK;
}
lex_state = EXPR_BEG;
return c;
case '{':
if (lex_state != EXPR_END && lex_state != EXPR_ARG)
- c = LBRACE;
+ c = tLBRACE;
lex_state = EXPR_BEG;
return c;
@@ -2843,7 +2843,7 @@ retry:
}
if ((c = nextc()) == '=') {
yylval.id = '%';
- return OP_ASGN;
+ return tOP_ASGN;
}
if (lex_state == EXPR_ARG) {
if (space_seen && !isspace(c)) {
@@ -2884,7 +2884,7 @@ retry:
tokadd(c);
tokfix();
yylval.id = rb_intern(tok());
- return GVAR;
+ return tGVAR;
case '-':
tokadd('$');
@@ -2893,14 +2893,14 @@ retry:
tokadd(c);
tokfix();
yylval.id = rb_intern(tok());
- return GVAR;
+ return tGVAR;
case '&': /* $&: last match */
case '`': /* $`: string before last match */
case '\'': /* $': string after last match */
case '+': /* $+: string matches last paren. */
yylval.node = NEW_BACK_REF(c);
- return BACK_REF;
+ return tBACK_REF;
case '1': case '2': case '3':
case '4': case '5': case '6':
@@ -2912,7 +2912,7 @@ retry:
pushback(c);
tokfix();
yylval.node = NEW_NTH_REF(atoi(tok()));
- return NTH_REF;
+ return tNTH_REF;
default:
if (!is_identchar(c)) {
@@ -2966,11 +2966,11 @@ retry:
switch (tok()[0]) {
case '$':
lex_state = EXPR_END;
- result = GVAR;
+ result = tGVAR;
break;
case '@':
lex_state = EXPR_END;
- result = IVAR;
+ result = tIVAR;
break;
default:
if (lex_state != EXPR_DOT) {
@@ -3002,12 +3002,12 @@ retry:
lex_state = EXPR_END;
}
if (isupper(tok()[0])) {
- result = CONSTANT;
+ result = tCONSTANT;
}
else if (toklast() == '!' || toklast() == '?') {
- result = FID;
+ result = tFID;
} else {
- result = IDENTIFIER;
+ result = tIDENTIFIER;
}
}
tokfix();
@@ -3349,7 +3349,7 @@ match_gen(node1, node2)
}
}
- return NEW_CALL(node1, MATCH, NEW_LIST(node2));
+ return NEW_CALL(node1, tMATCH, NEW_LIST(node2));
}
static NODE*
@@ -3468,7 +3468,7 @@ aryset(recv, idx, val)
idx = arg_add(idx, val);
}
}
- return NEW_CALL(recv, ASET, idx);
+ return NEW_CALL(recv, tASET, idx);
}
ID
@@ -3586,6 +3586,7 @@ assign_in_cond(node)
return 1;
default:
+ break;
}
if (assign_in_cond(node->nd_value) == 0) {
Warning("assignment in condition");
@@ -3653,7 +3654,7 @@ cond2(node)
type = nd_type(node);
if (type == NODE_NEWLINE) node = node->nd_next;
if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) {
- return call_op(node,EQ,1,NEW_GVAR(rb_intern("$.")));
+ return call_op(node,tEQ,1,NEW_GVAR(rb_intern("$.")));
}
return node;
}
@@ -3904,7 +3905,7 @@ yywhile_loop(chop, split)
}
static struct op_tbl rb_op_tbl[] = {
- DOT2, "..",
+ tDOT2, "..",
'+', "+",
'-', "-",
'+', "+(binary)",
@@ -3912,35 +3913,36 @@ static struct op_tbl rb_op_tbl[] = {
'*', "*",
'/', "/",
'%', "%",
- POW, "**",
- UPLUS, "+@",
- UMINUS, "-@",
- UPLUS, "+(unary)",
- UMINUS, "-(unary)",
+ tPOW, "**",
+ tUPLUS, "+@",
+ tUMINUS, "-@",
+ tUPLUS, "+(unary)",
+ tUMINUS, "-(unary)",
'|', "|",
'^', "^",
'&', "&",
- CMP, "<=>",
+ tCMP, "<=>",
'>', ">",
- GEQ, ">=",
+ tGEQ, ">=",
'<', "<",
- LEQ, "<=",
- EQ, "==",
- EQQ, "===",
- NEQ, "!=",
- MATCH, "=~",
- NMATCH, "!~",
+ tLEQ, "<=",
+ tEQ, "==",
+ tEQQ, "===",
+ tNEQ, "!=",
+ tMATCH, "=~",
+ tNMATCH, "!~",
'!', "!",
'~', "~",
'!', "!(unary)",
'~', "~(unary)",
'!', "!@",
'~', "~@",
- AREF, "[]",
- ASET, "[]=",
- LSHFT, "<<",
- RSHFT, ">>",
- COLON2, "::",
+ tAREF, "[]",
+ tASET, "[]=",
+ tLSHFT, "<<",
+ tRSHFT, ">>",
+ tCOLON2, "::",
+ tCOLON3, "::",
'`', "`",
0, 0,
};
diff --git a/sample/ruby-mode.el b/sample/ruby-mode.el
index e33a164bd9c..33e9d2ce4da 100644
--- a/sample/ruby-mode.el
+++ b/sample/ruby-mode.el
@@ -141,7 +141,7 @@ The variable ruby-indent-level controls the amount of indentation.
(use-local-map ruby-mode-map)
(setq mode-name "ruby")
(setq major-mode 'ruby-mode)
- (ruby-mode-variable)
+ (ruby-mode-variables)
(run-hooks 'ruby-mode-hook))
(defun ruby-current-indentation ()
diff --git a/sample/test.rb b/sample/test.rb
index 29670987faf..f09619b827e 100644
--- a/sample/test.rb
+++ b/sample/test.rb
@@ -675,8 +675,6 @@ if defined? Process.kill
x = $!
end
ok(x && x =~ /Interrupt/)
-else
- ok(false)
end
check "eval"
diff --git a/struct.c b/struct.c
index 6d31896d374..6cd1eafe6b3 100644
--- a/struct.c
+++ b/struct.c
@@ -121,8 +121,8 @@ struct_set(obj, val)
VALUE struct_alloc();
static VALUE
-make_struct(name, member)
- VALUE name, member;
+make_struct(name, member, klass)
+ VALUE name, member, klass;
{
VALUE nstr;
ID id;
@@ -132,7 +132,7 @@ make_struct(name, member)
if (!rb_is_const_id(id)) {
NameError("identifier %s needs to be constant", RSTRING(name)->ptr);
}
- nstr = rb_define_class_under(cStruct, RSTRING(name)->ptr, cStruct);
+ nstr = rb_define_class_under(klass, RSTRING(name)->ptr, klass);
rb_iv_set(nstr, "__size__", INT2FIX(RARRAY(member)->len));
rb_iv_set(nstr, "__member__", member);
@@ -174,11 +174,11 @@ struct_define(name, va_alist)
}
va_end(ar);
- return make_struct(nm, ary);
+ return make_struct(nm, ary, cStruct);
}
static VALUE
-struct_s_def(argc, argv)
+struct_s_def(argc, argv, klass)
int argc;
VALUE *argv;
{
@@ -193,8 +193,8 @@ struct_s_def(argc, argv)
ID id = rb_to_id(rest->ptr[i]);
rest->ptr[i] = INT2FIX(id);
}
- st = make_struct(name, rest);
- obj_call_init((VALUE)st);
+ st = make_struct(name, rest, klass);
+ obj_call_init(st);
return st;
}
@@ -218,7 +218,7 @@ struct_alloc(klass, values)
st->ptr = ALLOC_N(VALUE, n);
st->len = n;
MEMCPY(st->ptr, RARRAY(values)->ptr, VALUE, RARRAY(values)->len);
- memclear(st->ptr+RARRAY(values)->len, n - RARRAY(values)->len);
+ memclear(st->ptr+RARRAY(values)->len, n-RARRAY(values)->len);
obj_call_init((VALUE)st);
return (VALUE)st;