Skip to content

Commit

Permalink
* error.c (exc_exception): clone the receiver exception instead of
Browse files Browse the repository at this point in the history
  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: http://svn.ruby-lang.org/repos/ruby/trunk@1555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
matz committed Jul 2, 2001
1 parent 870d7cf commit 3d59109
Show file tree
Hide file tree
Showing 24 changed files with 373 additions and 163 deletions.
72 changes: 72 additions & 0 deletions 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.
Expand All @@ -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
Expand Down
23 changes: 13 additions & 10 deletions array.c
Expand Up @@ -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:
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions class.c
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions compar.c
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions dir.c
Expand Up @@ -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)
Expand Down Expand Up @@ -596,6 +596,7 @@ static void
remove_backslashes(p)
char *p;
{
#if defined DOSISH
char *pend = p + strlen(p);
char *t = p;

Expand All @@ -606,6 +607,7 @@ remove_backslashes(p)
*t++ = *p++;
}
*t = '\0';
#endif
}

#ifndef S_ISDIR
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion dln.c
Expand Up @@ -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"
Expand Down
47 changes: 41 additions & 6 deletions error.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3d59109

Please sign in to comment.