Permalink
Browse files

* 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
  • Loading branch information...
1 parent cc13bb4 commit ffe1cf575ecd5f9215a75728947520e9e668fb8a matz committed Jul 2, 2001
Showing with 373 additions and 163 deletions.
  1. +72 −0 ChangeLog
  2. +13 −10 array.c
  3. +2 −2 class.c
  4. +1 −2 compar.c
  5. +5 −3 dir.c
  6. +1 −1 dln.c
  7. +41 −6 error.c
  8. +51 −28 eval.c
  9. +1 −1 ext/pty/lib/expect.rb
  10. +24 −27 ext/readline/README
  11. +63 −0 ext/readline/README.jp
  12. +33 −14 gc.c
  13. +1 −0 intern.h
  14. +1 −1 keywords
  15. +7 −3 lex.c
  16. +3 −1 lib/debug.rb
  17. +1 −2 numeric.c
  18. +5 −7 object.c
  19. +6 −9 parse.y
  20. +2 −3 range.c
  21. +1 −0 regex.c
  22. +2 −3 ruby.c
  23. +6 −5 struct.c
  24. +31 −35 variable.c
View
@@ -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
View
@@ -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
View
@@ -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);
View
@@ -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
View
@@ -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)
View
@@ -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"
View
@@ -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);
Oops, something went wrong.

0 comments on commit ffe1cf5

Please sign in to comment.