summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-07-02 08:46:28 (GMT)
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-07-02 08:46:28 (GMT)
commitffe1cf575ecd5f9215a75728947520e9e668fb8a (patch)
tree9536b7d2a0fae33e4e3a5b7cdccfac0bc0b04a4f
parentcc13bb43bcb1e6b6798bb3190eeb65494dd2d320 (diff)
* error.c (exc_exception): clone the receiver exception instead of
creating brand new exception object of the receiver. * eval.c (rb_eval_string_wrap): extend new ruby_top_self, not original self. * eval.c (rb_eval_cmd): respect ruby_wrapper if set. * eval.c (eval): do not update ruby_class unless scope is not provided. * eval.c (eval): preserve wrapper information. * eval.c (proc_invoke): ditto. * eval.c (block_pass): ditto. * parse.y (void_expr): too much warnings for void context (e.g. foo[1] that can be mere Proc call). * error.c (rb_name_error): new function to raise NameError with name attribute set. * eval.c (rb_f_missing): set name and args in the exception object. [new] * error.c (name_name): NameError#name - new method. * error.c (nometh_args): NoMethodError#args - new method. * lex.c (rb_reserved_word): lex_state after tRESCUE should be EXPR_MID. * gc.c (add_heap): allocation size of the heap unit is doubled for each allocation. * dir.c (isdelim): space, tab, and newline are no longer delimiters for glob patterns. * eval.c (svalue_to_avalue): new conversion scheme between single value and array values. * eval.c (avalue_to_svalue): ditto. * eval.c (rb_eval): REXPAND now uses avalue_to_svalue(), return and yield too. * eval.c (rb_yield_0): use avalue_to_svalue(). * eval.c (proc_invoke): Proc#call gives avaules, whereas Proc#yield gives mvalues. * eval.c (bmcall): convert given value (svalue) to avalue. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog72
-rw-r--r--array.c23
-rw-r--r--class.c4
-rw-r--r--compar.c3
-rw-r--r--dir.c8
-rw-r--r--dln.c2
-rw-r--r--error.c47
-rw-r--r--eval.c79
-rw-r--r--ext/pty/lib/expect.rb2
-rw-r--r--ext/readline/README51
-rw-r--r--ext/readline/README.jp63
-rw-r--r--gc.c47
-rw-r--r--intern.h1
-rw-r--r--keywords2
-rw-r--r--lex.c10
-rw-r--r--lib/debug.rb4
-rw-r--r--numeric.c3
-rw-r--r--object.c12
-rw-r--r--parse.y15
-rw-r--r--range.c5
-rw-r--r--regex.c1
-rw-r--r--ruby.c5
-rw-r--r--struct.c11
-rw-r--r--variable.c66
24 files changed, 373 insertions, 163 deletions
diff --git a/ChangeLog b/ChangeLog
index 9b1cde1..338e6d0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,48 @@
+Mon Jul 2 17:22:00 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (exc_exception): clone the receiver exception instead of
+ creating brand new exception object of the receiver.
+
+Mon Jul 2 09:53:12 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (rb_eval_string_wrap): extend new ruby_top_self, not
+ original self.
+
+ * eval.c (rb_eval_cmd): respect ruby_wrapper if set.
+
+ * eval.c (eval): do not update ruby_class unless scope is not
+ provided.
+
+Sun Jul 1 10:51:15 2001 Shugo Maeda <shugo@ruby-lang.org>
+
+ * eval.c (eval): preserve wrapper information.
+
+ * eval.c (proc_invoke): ditto.
+
+ * eval.c (block_pass): ditto.
+
+Sat Jun 30 02:55:45 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * parse.y (void_expr): too much warnings for void context
+ (e.g. foo[1] that can be mere Proc call).
+
+Fri Jun 29 17:23:18 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * error.c (rb_name_error): new function to raise NameError with
+ name attribute set.
+
+ * eval.c (rb_f_missing): set name and args in the exception
+ object. [new]
+
+ * error.c (name_name): NameError#name - new method.
+
+ * error.c (nometh_args): NoMethodError#args - new method.
+
+Fri Jun 29 15:29:31 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * lex.c (rb_reserved_word): lex_state after tRESCUE should be
+ EXPR_MID.
+
Thu Jun 28 00:21:28 2001 Keiju Ishitsuka <keiju@ishitsuka.com>
* lib/matrix.rb: resolve 'ruby -w' warnings.
@@ -23,6 +68,33 @@ Wed Jun 27 08:53:26 2001 Minero Aoki <aamine@loveruby.net>
* lib/net/protocol.rb,smtp.rb,pop.rb,http.rb: add document.
+Tue Jun 26 18:42:42 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * gc.c (add_heap): allocation size of the heap unit is doubled for
+ each allocation.
+
+Mon Jun 25 09:54:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (isdelim): space, tab, and newline are no longer
+ delimiters for glob patterns.
+
+Sat Jun 23 22:28:52 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * eval.c (svalue_to_avalue): new conversion scheme between single
+ value and array values.
+
+ * eval.c (avalue_to_svalue): ditto.
+
+ * eval.c (rb_eval): REXPAND now uses avalue_to_svalue(), return
+ and yield too.
+
+ * eval.c (rb_yield_0): use avalue_to_svalue().
+
+ * eval.c (proc_invoke): Proc#call gives avaules, whereas
+ Proc#yield gives mvalues.
+
+ * eval.c (bmcall): convert given value (svalue) to avalue.
+
Sat Jun 23 18:28:52 2001 Akinori MUSHA <knu@iDaemons.org>
* ext/readline/readline.c (readline_event): a non-void function
diff --git a/array.c b/array.c
index d0f6977..1b7a6fa 100644
--- a/array.c
+++ b/array.c
@@ -419,28 +419,31 @@ rb_ary_aref(argc, argv, ary)
VALUE *argv;
VALUE ary;
{
- VALUE arg1, arg2;
+ VALUE arg;
long beg, len;
- if (rb_scan_args(argc, argv, "11", &arg1, &arg2) == 2) {
- beg = NUM2LONG(arg1);
- len = NUM2LONG(arg2);
+ if (argc == 2) {
+ beg = NUM2LONG(argv[0]);
+ len = NUM2LONG(argv[1]);
if (beg < 0) {
beg += RARRAY(ary)->len;
}
return rb_ary_subseq(ary, beg, len);
}
-
+ if (argc != 1) {
+ rb_scan_args(argc, argv, "11", 0, 0);
+ }
+ arg = argv[0];
/* special case - speeding up */
- if (FIXNUM_P(arg1)) {
- return rb_ary_entry(ary, FIX2LONG(arg1));
+ if (FIXNUM_P(arg)) {
+ return rb_ary_entry(ary, FIX2LONG(arg));
}
- else if (TYPE(arg1) == T_BIGNUM) {
+ else if (TYPE(arg) == T_BIGNUM) {
rb_raise(rb_eIndexError, "index too big");
}
else {
/* check if idx is Range */
- switch (rb_range_beg_len(arg1, &beg, &len, RARRAY(ary)->len, 0)) {
+ switch (rb_range_beg_len(arg, &beg, &len, RARRAY(ary)->len, 0)) {
case Qfalse:
break;
case Qnil:
@@ -449,7 +452,7 @@ rb_ary_aref(argc, argv, ary)
return rb_ary_subseq(ary, beg, len);
}
}
- return rb_ary_entry(ary, NUM2LONG(arg1));
+ return rb_ary_entry(ary, NUM2LONG(arg));
}
static VALUE
diff --git a/class.c b/class.c
index 0f5dcd7..6f6c5d2 100644
--- a/class.c
+++ b/class.c
@@ -149,7 +149,7 @@ rb_define_class(name, super)
id = rb_intern(name);
if (rb_const_defined(rb_cObject, id)) {
klass = rb_const_get(rb_cObject, id);
- rb_raise(rb_eNameError, "%s is already defined", name);
+ rb_name_error(id, "%s is already defined", name);
}
klass = rb_define_class_id(id, super);
st_add_direct(rb_class_tbl, id, klass);
@@ -169,7 +169,7 @@ rb_define_class_under(outer, name, super)
id = rb_intern(name);
if (rb_const_defined_at(outer, id)) {
klass = rb_const_get(outer, id);
- rb_raise(rb_eNameError, "%s is already defined", name);
+ rb_name_error(id, "%s is already defined", name);
}
klass = rb_define_class_id(id, super);
rb_const_set(outer, id, klass);
diff --git a/compar.c b/compar.c
index 6ae4b1a..86494e2 100644
--- a/compar.c
+++ b/compar.c
@@ -42,8 +42,7 @@ cmp_equal(x, y)
if (x == y) return Qtrue;
a[0] = x; a[1] = y;
- return rb_rescue2(cmp_eq, (VALUE)a, cmp_failed, 0,
- rb_eStandardError, rb_eNameError, 0);
+ return rb_rescue(cmp_eq, (VALUE)a, cmp_failed, 0);
}
static VALUE
diff --git a/dir.c b/dir.c
index e778b4a..d2c2796 100644
--- a/dir.c
+++ b/dir.c
@@ -538,8 +538,8 @@ has_magic(s, send, flags)
case '*':
return Qtrue;
- case '[': /* Only accept an open brace if there is a close */
- open++; /* brace to match it. Bracket expressions must be */
+ case '[': /* Only accept an open brace if there is a close */
+ open++; /* brace to match it. Bracket expressions must be */
continue; /* complete, according to Posix.2 */
case ']':
if (open)
@@ -596,6 +596,7 @@ static void
remove_backslashes(p)
char *p;
{
+#if defined DOSISH
char *pend = p + strlen(p);
char *t = p;
@@ -606,6 +607,7 @@ remove_backslashes(p)
*t++ = *p++;
}
*t = '\0';
+#endif
}
#ifndef S_ISDIR
@@ -845,7 +847,7 @@ push_braces(ary, s)
}
}
-#define isdelim(c) ((c)==' '||(c)=='\t'||(c)=='\n'||(c)=='\0')
+#define isdelim(c) ((c)=='\0')
static VALUE
dir_s_glob(dir, str)
diff --git a/dln.c b/dln.c
index 6910fa9..4d9f541 100644
--- a/dln.c
+++ b/dln.c
@@ -87,7 +87,7 @@ int eaccess();
#endif
#ifndef FUNCNAME_PATTERN
-# if defined(__hp9000s300) || (defined(__NetBSD__) && !defined(__ELF__)) || defined(__BORLANDC__) || (defined(__FreeBSD__) && __FreeBSD__ < 3) || defined(__OpenBSD__) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__)
+# if defined(__hp9000s300) || (defined(__NetBSD__) && !defined(__ELF__)) || defined(__BORLANDC__) || (defined(__FreeBSD__) && !defined(__ELF__)) || defined(__OpenBSD__) || defined(NeXT) || defined(__WATCOMC__) || defined(__APPLE__)
# define FUNCNAME_PATTERN "_Init_%s"
# else
# define FUNCNAME_PATTERN "Init_%s"
diff --git a/error.c b/error.c
index a2c3715..7f196ba 100644
--- a/error.c
+++ b/error.c
@@ -322,15 +322,11 @@ exc_exception(argc, argv, self)
VALUE *argv;
VALUE self;
{
- VALUE etype, exc;
+ VALUE exc;
if (argc == 0) return self;
if (argc == 1 && self == argv[0]) return self;
- etype = CLASS_OF(self);
- while (FL_TEST(etype, FL_SINGLETON)) {
- etype = RCLASS(etype)->super;
- }
- exc = rb_obj_alloc(etype);
+ exc = rb_obj_clone(self);
rb_obj_call_init(exc, argc, argv);
return exc;
@@ -417,6 +413,43 @@ exit_status(exc)
return rb_iv_get(exc, "status");
}
+void
+#ifdef HAVE_STDARG_PROTOTYPES
+rb_name_error(ID id, const char *fmt, ...)
+#else
+rb_name_error(id, fmt, va_alist)
+ ID id;
+ const char *fmt;
+ va_dcl
+#endif
+{
+ VALUE exc;
+
+ va_list args;
+ char buf[BUFSIZ];
+
+ va_init_list(args, fmt);
+ vsnprintf(buf, BUFSIZ, fmt, args);
+ va_end(args);
+ exc = rb_exc_new2(rb_eLoadError, buf);
+ rb_iv_set(exc, "name", ID2SYM(id));
+ rb_exc_raise(exc);
+}
+
+static VALUE
+name_name(self)
+ VALUE self;
+{
+ return rb_iv_get(self, "name");
+}
+
+static VALUE
+nometh_args(self)
+ VALUE self;
+{
+ return rb_iv_get(self, "args");
+}
+
#ifdef __BEOS__
typedef struct {
VALUE *list;
@@ -594,7 +627,9 @@ Init_Exception()
rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
rb_eRangeError = rb_define_class("RangeError", rb_eStandardError);
rb_eNameError = rb_define_class("NameError", rb_eStandardError);
+ rb_define_method(rb_eNameError, "name", name_name, 0);
rb_eNoMethodError = rb_define_class("NoMethodError", rb_eNameError);
+ rb_define_method(rb_eNoMethodError, "args", nometh_args, 0);
rb_eScriptError = rb_define_class("ScriptError", rb_eException);
rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError);
diff --git a/eval.c b/eval.c
index 74ef503..f8d1ea8 100644
--- a/eval.c
+++ b/eval.c
@@ -168,10 +168,10 @@ print_undef(klass, id)
VALUE klass;
ID id;
{
- rb_raise(rb_eNameError, "undefined method `%s' for %s `%s'",
- rb_id2name(id),
- (TYPE(klass) == T_MODULE)?"module":"class",
- rb_class2name(klass));
+ rb_name_error(id, "undefined method `%s' for %s `%s'",
+ rb_id2name(id),
+ (TYPE(klass) == T_MODULE)?"module":"class",
+ rb_class2name(klass));
}
static ID removed, singleton_removed, undefined, singleton_undefined;
@@ -315,8 +315,8 @@ remove_method(klass, mid)
}
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
if (!st_delete(RCLASS(klass)->m_tbl, &mid, &body)) {
- rb_raise(rb_eNameError, "method `%s' not defined in %s",
- rb_id2name(mid), rb_class2name(klass));
+ rb_name_error(mid, "method `%s' not defined in %s",
+ rb_id2name(mid), rb_class2name(klass));
}
rb_clear_cache_by_id(mid);
if (FL_TEST(klass, FL_SINGLETON)) {
@@ -546,6 +546,7 @@ struct BLOCK {
int flags;
struct RVarmap *dyna_vars;
VALUE orig_thread;
+ VALUE wrapper;
struct BLOCK *prev;
};
@@ -1273,7 +1274,7 @@ rb_eval_string_wrap(str, state)
PUSH_CLASS();
ruby_class = ruby_wrapper = rb_module_new();
ruby_top_self = rb_obj_clone(ruby_top_self);
- rb_extend_object(self, ruby_class);
+ rb_extend_object(ruby_top_self, ruby_class);
val = rb_eval_string_protect(str, &status);
ruby_top_self = self;
@@ -1336,7 +1337,7 @@ rb_eval_cmd(cmd, arg)
saved_scope = ruby_scope;
ruby_scope = top_scope;
- ruby_class = rb_cObject;
+ ruby_class = ruby_wrapper ? ruby_wrapper : rb_cObject;
if (OBJ_TAINTED(cmd)) {
ruby_safe_level = 4;
}
@@ -1545,8 +1546,8 @@ rb_undef(klass, id)
else if (TYPE(c) == T_MODULE) {
s0 = " module";
}
- rb_raise(rb_eNameError, "undefined method `%s' for%s `%s'",
- rb_id2name(id),s0,rb_class2name(c));
+ rb_name_error(id, "undefined method `%s' for%s `%s'",
+ rb_id2name(id),s0,rb_class2name(c));
}
rb_add_method(klass, id, 0, NOEX_PUBLIC);
rb_clear_cache_by_id(id);
@@ -2378,7 +2379,7 @@ rb_eval(self, n)
case NODE_BREAK:
if (node->nd_stts) {
- return_value(rb_eval(self, node->nd_stts));
+ return_value(avalue_to_svalue(rb_eval(self, node->nd_stts)));
}
else {
return_value(Qnil);
@@ -2388,7 +2389,7 @@ rb_eval(self, n)
case NODE_NEXT:
if (node->nd_stts) {
- return_value(rb_eval(self, node->nd_stts));
+ return_value(avalue_to_svalue(rb_eval(self, node->nd_stts)));
}
else {
return_value(Qnil);
@@ -2616,8 +2617,9 @@ rb_eval(self, n)
TMP_PROTECT;
if (ruby_frame->last_class == 0) {
- rb_raise(rb_eNameError, "superclass method `%s' disabled",
- rb_id2name(ruby_frame->last_func));
+ rb_name_error(ruby_frame->last_func,
+ "superclass method `%s' disabled",
+ rb_id2name(ruby_frame->last_func));
}
if (nd_type(node) == NODE_ZSUPER) {
argc = ruby_frame->argc;
@@ -4119,7 +4121,6 @@ rb_f_missing(argc, argv, obj)
}
id = SYM2ID(argv[0]);
- argc--; argv++;
switch (TYPE(obj)) {
case T_NIL:
@@ -4167,9 +4168,17 @@ rb_f_missing(argc, argv, obj)
PUSH_FRAME(); /* fake frame */
*ruby_frame = *_frame.prev->prev;
- rb_raise(exc, format, rb_id2name(id),
- desc, desc[0]=='#'?"":":",
- desc[0]=='#'?"":rb_class2name(CLASS_OF(obj)));
+ {
+ char buf[BUFSIZ];
+
+ snprintf(buf, BUFSIZ, format, rb_id2name(id),
+ desc, desc[0]=='#'?"":":",
+ desc[0]=='#'?"":rb_class2name(CLASS_OF(obj)));
+ exc = rb_exc_new2(exc, buf);
+ rb_iv_set(exc, "name", argv[0]);
+ rb_iv_set(exc, "args", rb_ary_new4(argc-1, argv+1));
+ rb_exc_raise(exc);
+ }
POP_FRAME();
return Qnil; /* not reached */
@@ -4195,15 +4204,15 @@ rb_undefined(obj, id, argc, argv, call_status)
}
#ifdef DJGPP
-static int STACK_LEVEL_MAX = 65535;
+static unsigned int STACK_LEVEL_MAX = 65535;
#else
#ifdef __human68k__
-extern int _stacksize;
+extern unsigned int _stacksize;
# define STACK_LEVEL_MAX (_stacksize - 4096)
#undef HAVE_GETRLIMIT
#else
#ifdef HAVE_GETRLIMIT
-static int STACK_LEVEL_MAX = 655300;
+static unsigned int STACK_LEVEL_MAX = 655300;
#else
# define STACK_LEVEL_MAX 655300
#endif
@@ -4586,8 +4595,8 @@ rb_call(klass, recv, mid, argc, argv, scope)
}
else if ((body = rb_get_method_body(&klass, &id, &noex)) == 0) {
if (scope == 3) {
- rb_raise(rb_eNameError, "super: no superclass method `%s'",
- rb_id2name(mid));
+ rb_name_error(mid, "super: no superclass method `%s'",
+ rb_id2name(mid));
}
return rb_undefined(recv, mid, argc, argv, scope==2?CSTAT_VCALL:0);
}
@@ -4712,8 +4721,8 @@ rb_call_super(argc, argv)
VALUE result;
if (ruby_frame->last_class == 0) {
- rb_raise(rb_eNameError, "superclass method `%s' must be enabled by rb_enable_super()",
- rb_id2name(ruby_frame->last_func));
+ rb_name_error(ruby_frame->last_func, "superclass method `%s' must be enabled by rb_enable_super()",
+ rb_id2name(ruby_frame->last_func));
}
PUSH_ITER(ruby_iter->iter?ITER_PRE:ITER_NOT);
@@ -4843,6 +4852,7 @@ eval(self, src, scope, file, line)
struct RVarmap * volatile old_dyna_vars;
VALUE volatile old_cref;
int volatile old_vmode;
+ volatile VALUE old_wrapper;
struct FRAME frame;
char *filesave = ruby_sourcefile;
int linesave = ruby_sourceline;
@@ -4853,6 +4863,7 @@ eval(self, src, scope, file, line)
file = ruby_sourcefile;
line = ruby_sourceline;
}
+ PUSH_CLASS();
if (!NIL_P(scope)) {
if (!rb_obj_is_block(scope)) {
rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc/Binding)",
@@ -4874,17 +4885,18 @@ eval(self, src, scope, file, line)
scope_vmode = data->vmode;
old_cref = (VALUE)ruby_cref;
ruby_cref = (NODE*)ruby_frame->cbase;
+ old_wrapper = ruby_wrapper;
+ ruby_wrapper = data->wrapper;
self = data->self;
ruby_frame->iter = data->iter;
+ ruby_class = ruby_cbase;
}
else {
if (ruby_frame->prev) {
ruby_frame->iter = ruby_frame->prev->iter;
}
}
- PUSH_CLASS();
- ruby_class = ruby_cbase;
ruby_in_eval++;
if (TYPE(ruby_class) == T_ICLASS) {
@@ -4909,6 +4921,7 @@ eval(self, src, scope, file, line)
if (!NIL_P(scope)) {
int dont_recycle = ruby_scope->flags & SCOPE_DONT_RECYCLE;
+ ruby_wrapper = old_wrapper;
ruby_cref = (NODE*)old_cref;
ruby_frame = frame.tmp;
ruby_scope = old_scope;
@@ -6079,6 +6092,7 @@ blk_mark(data)
rb_gc_mark((VALUE)data->dyna_vars);
rb_gc_mark((VALUE)data->klass);
rb_gc_mark((VALUE)data->tag);
+ rb_gc_mark(data->wrapper);
data = data->prev;
}
}
@@ -6194,6 +6208,7 @@ rb_f_binding(self)
*data = *ruby_block;
data->orig_thread = rb_thread_current();
+ data->wrapper = ruby_wrapper;
data->iter = rb_f_block_given_p();
frame_dup(&data->frame);
if (ruby_frame->prev) {
@@ -6283,6 +6298,7 @@ proc_new(klass)
*data = *ruby_block;
data->orig_thread = rb_thread_current();
+ data->wrapper = ruby_wrapper;
data->iter = data->prev?Qtrue:Qfalse;
frame_dup(&data->frame);
if (data->iter) {
@@ -6352,6 +6368,7 @@ proc_invoke(proc, args, pcall)
int state;
volatile int orphan;
volatile int safe = ruby_safe_level;
+ volatile VALUE old_wrapper = ruby_wrapper;
if (rb_block_given_p() && ruby_frame->last_func) {
rb_warning("block for %s#%s is useless",
@@ -6362,6 +6379,7 @@ proc_invoke(proc, args, pcall)
Data_Get_Struct(proc, struct BLOCK, data);
orphan = blk_orphan(data);
+ ruby_wrapper = data->wrapper;
/* PUSH BLOCK from data */
old_block = ruby_block;
_block = *data;
@@ -6387,6 +6405,7 @@ proc_invoke(proc, args, pcall)
state &= TAG_MASK;
}
ruby_block = old_block;
+ ruby_wrapper = old_wrapper;
ruby_safe_level = safe;
switch (state) {
@@ -6496,6 +6515,7 @@ block_pass(self, node)
int state;
volatile int orphan;
volatile int safe = ruby_safe_level;
+ volatile VALUE old_wrapper = ruby_wrapper;
if (NIL_P(block)) {
return rb_eval(self, node->nd_iter);
@@ -6511,6 +6531,8 @@ block_pass(self, node)
Data_Get_Struct(block, struct BLOCK, data);
orphan = blk_orphan(data);
+ ruby_wrapper = data->wrapper;
+
/* PUSH BLOCK from data */
old_block = ruby_block;
_block = *data;
@@ -6548,6 +6570,7 @@ block_pass(self, node)
}
}
ruby_block = old_block;
+ ruby_wrapper = old_wrapper;
ruby_safe_level = safe;
switch (state) {/* escape from orphan procedure */
@@ -8989,7 +9012,7 @@ rb_f_throw(argc, argv)
tt = tt->prev;
}
if (!tt) {
- rb_raise(rb_eNameError, "uncaught throw `%s'", rb_id2name(t));
+ rb_name_error(t, "uncaught throw `%s'", rb_id2name(t));
}
return_value(value);
rb_trap_restore_mask();
diff --git a/ext/pty/lib/expect.rb b/ext/pty/lib/expect.rb
index 54c69ed..5b5619e 100644
--- a/ext/pty/lib/expect.rb
+++ b/ext/pty/lib/expect.rb
@@ -25,7 +25,7 @@ class IO
break
end
end
- if iterator? then
+ if block_given? then
yield result
else
return result
diff --git a/ext/readline/README b/ext/readline/README
index affe51f..1eb1f8b 100644
--- a/ext/readline/README
+++ b/ext/readline/README
@@ -1,63 +1,60 @@
-GNU Readline Libraryを利用するための拡張モジュールです。
+Extension for GNU Readline Library
-require "readline"
-include Readline
+Example:
-line = readline("Prompt> ", TRUE)
+ require "readline"
+ include Readline
-のように使用してください。
+ line = readline("Prompt> ", true)
[Readline]
-<モジュール関数>
+<module function>
-readline(prompt, add=nil)
+readline(prompt, add_hostory=nil)
- 一行入力を読み込みます。
- addがTRUEの場合、ヒストリに読み込んだ文字列を追加します。
+ Reads one line wit line edit. the line is added to the
+ history also if "add" is true.
-<クラスメソッド>
+<class mehods>
completion_proc = proc
- 補完時の動作を決定するProcオブジェクトを指定します。
- procは引数に入力文字列を取り、候補文字列の配列を返すように
- してください。
+ Specifies Proc object to determin completion behavior. It
+ shoule take input-string, and return completion candidates.
completion_proc
- 補完時の動作を決定するProcオブジェクトを返します。
+ Returns the completion Proc object.
-completion_case_fold = case_fold
+completion_case_fold = bool
- 補完時に大文字小文字を区別しない場合、TRUEを指定します。
+ Sets whether or not to ignore case on completion.
completion_case_fold
- 補完時に大文字小文字を区別しない場合、TRUEを返します。
+ Returns true if completion ignores case.
completion_append_character = char
- 補完時に付加される文字を文字列で指定します。先頭の一文字が
- 設定され、空文字列 ("") または nil を指定すると何も付加
- されなくなります。
+ Specifies a chacatcter to be appended on completion.
+ Nothing will be appended if empty string ("") or nil is specified.
completion_append_character
- 補完時に付加される文字を文字列で返します。デフォルトは
- 空白 (" ") です。
+ Returns a string contains a character to be appended on
+ completion. The default is a space (" ").
vi_editing_mode
- VIモードになります。
+ Specifies VI editing mode.
emacs_editing_mode
- Emacsモードになります。
+ Specifies Emacs editing mode.
-<クラス定数>
+<class constants>
HISTORY
-ヒストリに対する操作はこの定数を通して行ってください。
-配列と同じように扱えるようになっています。
+The history buffer. It behaves just like an array.
diff --git a/ext/readline/README.jp b/ext/readline/README.jp
new file mode 100644
index 0000000..e342ca4
--- /dev/null
+++ b/ext/readline/README.jp
@@ -0,0 +1,63 @@
+GNU Readline Libraryを利用するための拡張モジュールです。
+
+require "readline"
+include Readline
+
+line = readline("Prompt> ", true)
+
+のように使用してください。
+
+[Readline]
+
+<モジュール関数>
+
+readline(prompt, add=nil)
+
+ 一行入力を読み込みます。
+ addがtrueの場合、ヒストリに読み込んだ文字列を追加します。
+
+<クラスメソッド>
+
+completion_proc = proc
+
+ 補完時の動作を決定するProcオブジェクトを指定します。
+ procは引数に入力文字列を取り、候補文字列の配列を返すように
+ してください。
+
+completion_proc
+
+ 補完時の動作を決定するProcオブジェクトを返します。
+
+completion_case_fold = case_fold
+
+ 補完時に大文字小文字を区別しない場合、trueを指定します。
+
+completion_case_fold
+
+ 補完時に大文字小文字を区別しない場合、trueを返します。
+
+completion_append_character = char
+
+ 補完時に付加される文字を文字列で指定します。先頭の一文字が
+ 設定され、空文字列 ("") または nil を指定すると何も付加
+ されなくなります。
+
+completion_append_character
+
+ 補完時に付加される文字を文字列で返します。デフォルトは
+ 空白 (" ") です。
+
+vi_editing_mode
+
+ VIモードになります。
+
+emacs_editing_mode
+
+ Emacsモードになります。
+
+<クラス定数>
+
+HISTORY
+
+ヒストリに対する操作はこの定数を通して行ってください。
+配列と同じように扱えるようになっています。
diff --git a/gc.c b/gc.c
index cfe981d..6c9a054 100644
--- a/gc.c
+++ b/gc.c
@@ -258,7 +258,10 @@ static RVALUE **heaps;
static int heaps_length = 0;
static int heaps_used = 0;
-#define HEAP_SLOTS 10000
+#define HEAP_MIN_SLOTS 10000
+static int *heaps_limits;
+static int heap_slots = HEAP_MIN_SLOTS;
+
#define FREE_MIN 4096
static RVALUE *himem, *lomem;
@@ -275,13 +278,29 @@ add_heap()
(RVALUE**)realloc(heaps, heaps_length*sizeof(RVALUE*)):
(RVALUE**)malloc(heaps_length*sizeof(RVALUE*)));
if (heaps == 0) mem_error("heaps: can't alloc memory");
+ RUBY_CRITICAL(heaps_limits = (heaps_used>0)?
+ (int*)realloc(heaps_limits, heaps_length*sizeof(int)):
+ (int*)malloc(heaps_length*sizeof(int)));
+ if (heaps_limits == 0) mem_error("heaps_limits: can't alloc memory");
}
- RUBY_CRITICAL(p = heaps[heaps_used++] = (RVALUE*)malloc(sizeof(RVALUE)*HEAP_SLOTS));
- if (p == 0) mem_error("add_heap: can't alloc memory");
- pend = p + HEAP_SLOTS;
+ for (;;) {
+ RUBY_CRITICAL(p = heaps[heaps_used] = (RVALUE*)malloc(sizeof(RVALUE)*heap_slots));
+ heaps_limits[heaps_used] = heap_slots;
+ if (p == 0) {
+ if (heap_slots == HEAP_MIN_SLOTS) {
+ mem_error("add_heap: can't alloc memory");
+ }
+ heap_slots = HEAP_MIN_SLOTS;
+ continue;
+ }
+ break;
+ }
+ pend = p + heap_slots;
if (lomem == 0 || lomem > p) lomem = p;
if (himem < pend) himem = pend;
+ heaps_used++;
+ heap_slots *= 2;
while (p < pend) {
p->as.free.flags = 0;
@@ -337,8 +356,8 @@ is_pointer_to_heap(ptr)
/* check if p looks like a pointer */
for (i=0; i < heaps_used; i++) {
heap_org = heaps[i];
- if (heap_org <= p && p < heap_org + HEAP_SLOTS
- && ((((char*)p)-((char*)heap_org))%sizeof(RVALUE)) == 0)
+ if (heap_org <= p && p < heap_org + heaps_limits[i] &&
+ ((((char*)p)-((char*)heap_org))%sizeof(RVALUE)) == 0)
return Qtrue;
}
return Qfalse;
@@ -512,6 +531,8 @@ rb_gc_mark(ptr)
case NODE_DEFINED:
case NODE_MATCH:
case NODE_RETURN:
+ case NODE_BREAK:
+ case NODE_NEXT:
case NODE_YIELD:
case NODE_COLON2:
case NODE_ARGS:
@@ -539,8 +560,6 @@ rb_gc_mark(ptr)
case NODE_BACK_REF:
case NODE_ALIAS:
case NODE_VALIAS:
- case NODE_BREAK:
- case NODE_NEXT:
case NODE_REDO:
case NODE_RETRY:
case NODE_UNDEF:
@@ -676,7 +695,7 @@ gc_sweep()
if (ruby_in_compile) {
/* should not reclaim nodes during compilation */
for (i = 0; i < used; i++) {
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ p = heaps[i]; pend = p + heaps_limits[i];
while (p < pend) {
if (!(p->as.basic.flags&FL_MARK) && BUILTIN_TYPE(p) == T_NODE)
rb_gc_mark((VALUE)p);
@@ -691,7 +710,7 @@ gc_sweep()
for (i = 0; i < used; i++) {
int n = 0;
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ p = heaps[i]; pend = p + heaps_limits[i];
while (p < pend) {
if (!(p->as.basic.flags & FL_MARK)) {
if (p->as.basic.flags) {
@@ -1045,7 +1064,7 @@ os_live_obj()
for (i = 0; i < heaps_used; i++) {
RVALUE *p, *pend;
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ p = heaps[i]; pend = p + heaps_limits[i];
for (;p < pend; p++) {
if (p->as.basic.flags) {
switch (TYPE(p)) {
@@ -1078,7 +1097,7 @@ os_obj_of(of)
for (i = 0; i < heaps_used; i++) {
RVALUE *p, *pend;
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ p = heaps[i]; pend = p + heaps_limits[i];
for (;p < pend; p++) {
if (p->as.basic.flags) {
switch (TYPE(p)) {
@@ -1245,7 +1264,7 @@ rb_gc_call_finalizer_at_exit()
}
}
for (i = 0; i < heaps_used; i++) {
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ p = heaps[i]; pend = p + heaps_limits[i];
while (p < pend) {
if (FL_TEST(p, FL_FINALIZE)) {
FL_UNSET(p, FL_FINALIZE);
@@ -1258,7 +1277,7 @@ rb_gc_call_finalizer_at_exit()
}
/* run data object's finaliers */
for (i = 0; i < heaps_used; i++) {
- p = heaps[i]; pend = p + HEAP_SLOTS;
+ p = heaps[i]; pend = p + heaps_limits[i];
while (p < pend) {
if (BUILTIN_TYPE(p) == T_DATA &&
DATA_PTR(p) && RANY(p)->as.data.dfree) {
diff --git a/intern.h b/intern.h
index ebfc57c..340c3f0 100644
--- a/intern.h
+++ b/intern.h
@@ -109,6 +109,7 @@ VALUE rb_exc_new _((VALUE, const char*, long));
VALUE rb_exc_new2 _((VALUE, const char*));
VALUE rb_exc_new3 _((VALUE, VALUE));
NORETURN(void rb_loaderror __((const char*, ...)));
+NORETURN(void rb_name_error __((VALUE id, const char*, ...)));
void rb_compile_error __((const char*, ...));
void rb_compile_error_append __((const char*, ...));
NORETURN(void rb_load_fail _((char*)));
diff --git a/keywords b/keywords
index eafc5ed..7bf0d69 100644
--- a/keywords
+++ b/keywords
@@ -27,7 +27,7 @@ nil, kNIL, kNIL, EXPR_END
not, kNOT, kNOT, EXPR_BEG
or, kOR, kOR, EXPR_BEG
redo, kREDO, kREDO, EXPR_END
-rescue, kRESCUE, kRESCUE_MOD, EXPR_END
+rescue, kRESCUE, kRESCUE_MOD, EXPR_MID
retry, kRETRY, kRETRY, EXPR_END
return, kRETURN, kRETURN, EXPR_MID
self, kSELF, kSELF, EXPR_END
diff --git a/lex.c b/lex.c
index 0784c24..a5fb82e 100644
--- a/lex.c
+++ b/lex.c
@@ -1,5 +1,5 @@
-/* C code produced by gperf version 2.7.1 (19981006 egcs) */
-/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$ ./keywords */
+/* C code produced by gperf version 2.7.2 */
+/* Command-line: gperf -p -j1 -i 1 -g -o -t -N rb_reserved_word -k'1,3,$' ./keywords */
struct kwtable {char *name; int id[2]; enum lex_state state;};
#define TOTAL_KEYWORDS 40
@@ -11,6 +11,10 @@ struct kwtable {char *name; int id[2]; enum lex_state state;};
#ifdef __GNUC__
__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
#endif
static unsigned int
hash (str, len)
@@ -79,7 +83,7 @@ rb_reserved_word (str, len)
{"module", kMODULE, kMODULE, EXPR_BEG},
{"elsif", kELSIF, kELSIF, EXPR_BEG},
{"def", kDEF, kDEF, EXPR_FNAME},
- {"rescue", kRESCUE, kRESCUE_MOD, EXPR_END},
+ {"rescue", kRESCUE, kRESCUE_MOD, EXPR_MID},
{"not", kNOT, kNOT, EXPR_BEG},
{"then", kTHEN, kTHEN, EXPR_BEG},
{"yield", kYIELD, kYIELD, EXPR_ARG},
diff --git a/lib/debug.rb b/lib/debug.rb
index 2216f3a..a8a41ef 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -300,7 +300,9 @@ class DEBUGGER__
when /^\s*b(?:reak)?\s+((?:.*?+:)?.+)$/
pos = $1
if pos.index(":")
- file, pos = pos.split(":")
+ pos = pos.split(":")
+ file = pos[0...-1].join(":")
+ pos = pos[-1]
end
file = File.basename(file)
if pos =~ /^\d+$/
diff --git a/numeric.c b/numeric.c
index 66ac564..67b5eb3 100644
--- a/numeric.c
+++ b/numeric.c
@@ -70,8 +70,7 @@ do_coerce(x, y)
VALUE a[2];
a[0] = *x; a[1] = *y;
- ary = rb_rescue2(coerce_body, (VALUE)a, coerce_rescue, (VALUE)a,
- rb_eStandardError, rb_eNameError, 0);
+ ary = rb_rescue(coerce_body, (VALUE)a, coerce_rescue, (VALUE)a);
if (TYPE(ary) != T_ARRAY || RARRAY(ary)->len != 2) {
rb_raise(rb_eTypeError, "coerce must return [x, y]");
}
diff --git a/object.c b/object.c
index 89b1265..2d70029 100644
--- a/object.c
+++ b/object.c
@@ -769,7 +769,7 @@ rb_mod_const_get(mod, name)
ID id = rb_to_id(name);
if (!rb_is_const_id(id)) {
- rb_raise(rb_eNameError, "wrong constant name %s", rb_id2name(id));
+ rb_name_error(id, "wrong constant name %s", rb_id2name(id));
}
return rb_const_get(mod, id);
}
@@ -781,7 +781,7 @@ rb_mod_const_set(mod, name, value)
ID id = rb_to_id(name);
if (!rb_is_const_id(id)) {
- rb_raise(rb_eNameError, "wrong constant name %s", rb_id2name(id));
+ rb_name_error(id, "wrong constant name %s", rb_id2name(id));
}
rb_const_set(mod, id, value);
return value;
@@ -794,7 +794,7 @@ rb_mod_const_defined(mod, name)
ID id = rb_to_id(name);
if (!rb_is_const_id(id)) {
- rb_raise(rb_eNameError, "wrong constant name %s", rb_id2name(id));
+ rb_name_error(id, "wrong constant name %s", rb_id2name(id));
}
return rb_const_defined_at(mod, id);
}
@@ -866,8 +866,7 @@ rb_convert_type(val, type, tname, method)
arg1.val = arg2.val = val;
arg1.s = method;
arg2.s = tname;
- val = rb_rescue2(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2,
- rb_eStandardError, rb_eNameError, 0);
+ val = rb_rescue2(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2);
if (TYPE(val) != type) {
rb_raise(rb_eTypeError, "%s#%s should return %s",
rb_class2name(CLASS_OF(arg1.val)), method, tname);
@@ -886,8 +885,7 @@ rb_to_integer(val, method)
arg1.val = arg2.val = val;
arg1.s = method;
arg2.s = "Integer";
- val = rb_rescue2(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2,
- rb_eStandardError, rb_eNameError, 0);
+ val = rb_rescue(to_type, (VALUE)&arg1, fail_to_type, (VALUE)&arg2);
if (!rb_obj_is_kind_of(val, rb_cInteger)) {
rb_raise(rb_eTypeError, "%s#%s should return Integer",
rb_class2name(CLASS_OF(arg1.val)), method);
diff --git a/parse.y b/parse.y
index 4a30d34..dcad843 100644
--- a/parse.y
+++ b/parse.y
@@ -99,7 +99,6 @@ static int in_single = 0;
static int in_def = 0;
static int compile_for_eval = 0;
static ID cur_mid = 0;
-static ID last_id = 0;
static NODE *cond();
static NODE *logop();
@@ -1091,16 +1090,16 @@ command_args : {
}
open_args : call_args
- | tLPAREN_ARG {lex_state = EXPR_ENDARG;} ')'
+ | tLPAREN_ARG {lex_state = EXPR_ENDARG;} ')'
{
rb_warning("%s (...) interpreted as method call",
- rb_id2name(last_id));
+ rb_id2name($<id>1));
$$ = 0;
}
| tLPAREN_ARG call_args2 {lex_state = EXPR_ENDARG;} ')'
{
rb_warning("%s (...) interpreted as method call",
- rb_id2name(last_id));
+ rb_id2name($<id>1));
$$ = $2;
}
@@ -1192,7 +1191,7 @@ primary : literal
}
| tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} ')'
{
- rb_warning("%s (...) interpreted as command call", rb_id2name(last_id));
+ rb_warning("%s (...) interpreted as command call", rb_id2name($<id>1));
$$ = $2;
}
| tLPAREN compstmt ')'
@@ -2892,6 +2891,7 @@ double strtod ();
static int
yylex()
{
+ static ID last_id = 0;
register int c;
int space_seen = 0;
int cmd_state;
@@ -3460,6 +3460,7 @@ yylex()
else if (lex_state == EXPR_ARG) {
rb_warning("%s (...) interpreted as method call", tok());
c = tLPAREN_ARG;
+ yylval.id = last_id;
}
}
COND_PUSH(0);
@@ -4422,10 +4423,6 @@ void_expr(node)
case tLEQ:
case tEQ:
case tNEQ:
- case tAREF:
- case tRSHFT:
- case tCOLON2:
- case tCOLON3:
useless = rb_id2name(node->nd_mid);
break;
}
diff --git a/range.c b/range.c
index 128733d..fc02a69 100644
--- a/range.c
+++ b/range.c
@@ -45,8 +45,7 @@ range_init(obj, beg, end, exclude_end)
args[0] = beg; args[1] = end;
if (!FIXNUM_P(beg) || !FIXNUM_P(end)) {
- rb_rescue2(range_check, (VALUE)args, range_failed, 0,
- rb_eStandardError, rb_eNameError, 0);
+ rb_rescue2(range_check, (VALUE)args, range_failed, 0);
}
SET_EXCL(obj, exclude_end);
@@ -76,7 +75,7 @@ range_initialize(argc, argv, obj)
rb_scan_args(argc, argv, "21", &beg, &end, &flags);
/* Ranges are immutable, so that they should be initialized only once. */
if (rb_ivar_defined(obj, id_beg)) {
- rb_raise(rb_eNameError, "`initialize' called twice");
+ rb_name_error(rb_intern("initialized"), "`initialize' called twice");
}
range_init(obj, beg, end, RTEST(flags));
return Qnil;
diff --git a/regex.c b/regex.c
index e40c0e4..7f65e4e 100644
--- a/regex.c
+++ b/regex.c
@@ -3496,6 +3496,7 @@ init_regs(regs, num_regs)
else if (regs->allocated < num_regs) {
TREALLOC(regs->beg, num_regs, int);
TREALLOC(regs->end, num_regs, int);
+ regs->allocated = num_regs;
}
for (i=0; i<num_regs; i++) {
regs->beg[i] = regs->end[i] = -1;
diff --git a/ruby.c b/ruby.c
index e010829..b5fdfb0 100644
--- a/ruby.c
+++ b/ruby.c
@@ -265,20 +265,19 @@ ruby_init_loadpath()
ruby_incpush(RUBY_RELATIVE(RUBY_SEARCH_PATH));
#endif
+ ruby_incpush(RUBY_RELATIVE(RUBY_SITE_LIB2));
#ifdef RUBY_SITE_THIN_ARCHLIB
ruby_incpush(RUBY_RELATIVE(RUBY_SITE_THIN_ARCHLIB));
#endif
ruby_incpush(RUBY_RELATIVE(RUBY_SITE_ARCHLIB));
- ruby_incpush(RUBY_RELATIVE(RUBY_SITE_LIB2));
ruby_incpush(RUBY_RELATIVE(RUBY_SITE_LIB));
+ ruby_incpush(RUBY_RELATIVE(RUBY_LIB));
#ifdef RUBY_THIN_ARCHLIB
ruby_incpush(RUBY_RELATIVE(RUBY_THIN_ARCHLIB));
#endif
ruby_incpush(RUBY_RELATIVE(RUBY_ARCHLIB));
- ruby_incpush(RUBY_RELATIVE(RUBY_LIB));
-
if (rb_safe_level() == 0) {
ruby_incpush(".");
}
diff --git a/struct.c b/struct.c
index a07df58..69e94d2 100644
--- a/struct.c
+++ b/struct.c
@@ -89,7 +89,7 @@ rb_struct_getmember(obj, id)
return RSTRUCT(obj)->ptr[i];
}
}
- rb_raise(rb_eNameError, "%s is not struct member", rb_id2name(id));
+ rb_name_error(id, "%s is not struct member", rb_id2name(id));
return Qnil; /* not reached */
}
@@ -141,7 +141,8 @@ rb_struct_set(obj, val)
return RSTRUCT(obj)->ptr[i] = val;
}
}
- rb_raise(rb_eNameError, "not struct member");
+ rb_name_error(rb_frame_last_func(), "`%s' is not a struct member",
+ rb_id2name(rb_frame_last_func()));
return Qnil; /* not reached */
}
@@ -160,7 +161,7 @@ make_struct(name, member, klass)
char *cname = StringValuePtr(name);
id = rb_intern(cname);
if (!rb_is_const_id(id)) {
- rb_raise(rb_eNameError, "identifier %s needs to be constant", cname);
+ rb_name_error(id, "identifier %s needs to be constant", cname);
}
nstr = rb_define_class_under(klass, cname, klass);
}
@@ -435,7 +436,7 @@ rb_struct_aref_id(s, id)
return RSTRUCT(s)->ptr[i];
}
}
- rb_raise(rb_eNameError, "no member '%s' in struct", rb_id2name(id));
+ rb_name_error(id, "no member '%s' in struct", rb_id2name(id));
return Qnil; /* not reached */
}
@@ -481,7 +482,7 @@ rb_struct_aset_id(s, id, val)
return val;
}
}
- rb_raise(rb_eNameError, "no member '%s' in struct", rb_id2name(id));
+ rb_name_error(id, "no member '%s' in struct", rb_id2name(id));
}
VALUE
diff --git a/variable.c b/variable.c
index dfb4b16..23b246d 100644
--- a/variable.c
+++ b/variable.c
@@ -251,8 +251,7 @@ rb_autoload_id(id, filename)
{
rb_secure(4);
if (!rb_is_const_id(id)) {
- rb_raise(rb_eNameError, "autoload must be constant name",
- rb_id2name(id));
+ rb_name_error(id, "autoload must be constant name", rb_id2name(id));
}
if (!autoload_tbl) {
@@ -418,7 +417,7 @@ readonly_setter(val, id, var)
ID id;
void *var;
{
- rb_raise(rb_eNameError, "can't set variable %s", rb_id2name(id));
+ rb_name_error(id, "can't set variable %s", rb_id2name(id));
}
static int
@@ -528,8 +527,7 @@ rb_f_trace_var(argc, argv)
}
id = rb_to_id(var);
if (!st_lookup(rb_global_tbl, id, &entry)) {
- rb_raise(rb_eNameError, "undefined global variable %s",
- rb_id2name(id));
+ rb_name_error(id, "undefined global variable %s", rb_id2name(id));
}
trace = ALLOC(struct trace_var);
trace->next = entry->trace;
@@ -575,8 +573,7 @@ rb_f_untrace_var(argc, argv)
rb_scan_args(argc, argv, "11", &var, &cmd);
id = rb_to_id(var);
if (!st_lookup(rb_global_tbl, id, &entry)) {
- rb_raise(rb_eNameError, "undefined global variable %s",
- rb_id2name(id));
+ rb_name_error(id, "undefined global variable %s", rb_id2name(id));
}
trace = entry->trace;
@@ -1005,8 +1002,7 @@ rb_obj_remove_instance_variable(obj, name)
rb_raise(rb_eSecurityError, "Insecure: can't modify instance variable");
if (OBJ_FROZEN(obj)) rb_error_frozen("object");
if (!rb_is_instance_id(id)) {
- rb_raise(rb_eNameError, "`%s' is not an instance variable",
- rb_id2name(id));
+ rb_name_error(id, "`%s' is not an instance variable", rb_id2name(id));
}
switch (TYPE(obj)) {
@@ -1055,9 +1051,9 @@ rb_const_get_at(klass, id)
if (klass == rb_cObject && top_const_get(id, &value)) {
return value;
}
- rb_raise(rb_eNameError, "uninitialized constant %s::%s",
- RSTRING(rb_class_path(klass))->ptr,
- rb_id2name(id));
+ rb_name_error(id, "uninitialized constant %s::%s",
+ RSTRING(rb_class_path(klass))->ptr,
+ rb_id2name(id));
return Qnil; /* not reached */
}
@@ -1104,12 +1100,12 @@ rb_const_get(klass, id)
/* Uninitialized constant */
if (klass && klass != rb_cObject) {
- rb_raise(rb_eNameError, "uninitialized constant %s at %s",
- rb_id2name(id),
- RSTRING(rb_class_path(klass))->ptr);
+ rb_name_error(id, "uninitialized constant %s at %s",
+ rb_id2name(id),
+ RSTRING(rb_class_path(klass))->ptr);
}
else {
- rb_raise(rb_eNameError, "uninitialized constant %s",rb_id2name(id));
+ rb_name_error(id, "uninitialized constant %s",rb_id2name(id));
}
return Qnil; /* not reached */
}
@@ -1122,7 +1118,7 @@ rb_mod_remove_const(mod, name)
VALUE val;
if (!rb_is_const_id(id)) {
- rb_raise(rb_eNameError, "`%s' is not constant", rb_id2name(id));
+ rb_name_error(id, "`%s' is not constant", rb_id2name(id));
}
if (!OBJ_TAINTED(mod) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't remove constant");
@@ -1132,11 +1128,11 @@ rb_mod_remove_const(mod, name)
return val;
}
if (rb_const_defined_at(mod, id)) {
- rb_raise(rb_eNameError, "cannot remove %s::%s",
+ rb_name_error(id, "cannot remove %s::%s",
rb_class2name(mod), rb_id2name(id));
}
- rb_raise(rb_eNameError, "constant %s::%s not defined",
- rb_class2name(mod), rb_id2name(id));
+ rb_name_error(id, "constant %s::%s not defined",
+ rb_class2name(mod), rb_id2name(id));
return Qnil; /* not reached */
}
@@ -1339,11 +1335,11 @@ rb_const_assign(klass, id, val)
/* Uninitialized constant */
if (klass && klass != rb_cObject)
- rb_raise(rb_eNameError, "uninitialized constant %s::%s",
- RSTRING(rb_class_path(klass))->ptr,
- rb_id2name(id));
+ rb_name_error(id, "uninitialized constant %s::%s",
+ RSTRING(rb_class_path(klass))->ptr,
+ rb_id2name(id));
else {
- rb_raise(rb_eNameError, "uninitialized constant %s",rb_id2name(id));
+ rb_name_error(id, "uninitialized constant %s",rb_id2name(id));
}
}
@@ -1402,8 +1398,8 @@ rb_cvar_set(klass, id, val)
tmp = RCLASS(tmp)->super;
}
- rb_raise(rb_eNameError,"uninitialized class variable %s in %s",
- rb_id2name(id), rb_class2name(klass));
+ rb_name_error(id,"uninitialized class variable %s in %s",
+ rb_id2name(id), rb_class2name(klass));
}
void
@@ -1444,8 +1440,8 @@ rb_cvar_get(klass, id)
tmp = RCLASS(tmp)->super;
}
- rb_raise(rb_eNameError,"uninitialized class variable %s in %s",
- rb_id2name(id), rb_class2name(klass));
+ rb_name_error(id,"uninitialized class variable %s in %s",
+ rb_id2name(id), rb_class2name(klass));
return Qnil; /* not reached */
}
@@ -1475,7 +1471,7 @@ rb_cv_set(klass, name, val)
{
ID id = rb_intern(name);
if (!rb_is_class_id(id)) {
- rb_raise(rb_eNameError, "wrong class variable name %s", name);
+ rb_name_error(id, "wrong class variable name %s", name);
}
rb_cvar_set(klass, id, val);
}
@@ -1487,7 +1483,7 @@ rb_cv_get(klass, name)
{
ID id = rb_intern(name);
if (!rb_is_class_id(id)) {
- rb_raise(rb_eNameError, "wrong class variable name %s", name);
+ rb_name_error(id, "wrong class variable name %s", name);
}
return rb_cvar_get(klass, id);
}
@@ -1501,7 +1497,7 @@ rb_define_class_variable(klass, name, val)
ID id = rb_intern(name);
if (!rb_is_class_id(id)) {
- rb_raise(rb_eNameError, "wrong class variable name %s", name);
+ rb_name_error(id, "wrong class variable name %s", name);
}
rb_cvar_declare(klass, id, val);
}
@@ -1549,7 +1545,7 @@ rb_mod_remove_cvar(mod, name)
VALUE val;
if (!rb_is_class_id(id)) {
- rb_raise(rb_eNameError, "wrong class variable name %s", name);
+ rb_name_error(id, "wrong class variable name %s", name);
}
if (!OBJ_TAINTED(mod) && rb_safe_level() >= 4)
rb_raise(rb_eSecurityError, "Insecure: can't remove class variable");
@@ -1559,11 +1555,11 @@ rb_mod_remove_cvar(mod, name)
return val;
}
if (rb_cvar_defined(mod, id)) {
- rb_raise(rb_eNameError, "cannot remove %s for %s",
+ rb_name_error(id, "cannot remove %s for %s",
rb_id2name(id), rb_class2name(mod));
}
- rb_raise(rb_eNameError, "class variable %s not defined for %s",
- rb_id2name(id), rb_class2name(mod));
+ rb_name_error(id, "class variable %s not defined for %s",
+ rb_id2name(id), rb_class2name(mod));
return Qnil; /* not reached */
}