diff options
-rw-r--r-- | ChangeLog | 22 | ||||
-rw-r--r-- | ToDo | 5 | ||||
-rw-r--r-- | configure | 2 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | eval.c | 115 | ||||
-rw-r--r-- | ext/socket/socket.c | 4 | ||||
-rw-r--r-- | file.c | 11 | ||||
-rw-r--r-- | lib/tk.rb | 2 | ||||
-rw-r--r-- | ruby.c | 5 | ||||
-rw-r--r-- | sample/ruby-mode.el | 19 | ||||
-rw-r--r-- | sample/test.rb | 21 |
11 files changed, 160 insertions, 48 deletions
@@ -1,3 +1,9 @@ +Mon Mar 30 11:12:29 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * file.c (f_test): raises exception for unkown command. + + * eval.c (Init_eval): `class_eval': alias to the module_eval. + Mon Mar 30 14:07:07 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * string.c (str_intern): typo in error message. @@ -6,6 +12,22 @@ Mon Mar 30 14:06:19 1998 Tadayoshi Funaba <tadf@kt.rim.or.jp> * string.c (str_capitalize_bang): did not check string modification. + * string.c (str_delete_bang): wrong conversion. + +Mon Mar 30 01:44:13 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * eval.c (obj_instance_eval): accepts block as evaluation body. + No compilation needed each time. + + * eval.c (mod_module_eval): ditto + + * file.c (file_s_umask): umask did not return old values, if no + argument given. + +Sun Mar 29 00:54:23 1998 Yukihiro Matsumoto <matz@netlab.co.jp> + + * eval.c (f_throw): nil returned always. + Sat Mar 28 20:40:12 1998 Yukihiro Matsumoto <matz@netlab.co.jp> * experimental release 1.1b9_06. @@ -1,4 +1,3 @@ * non-blocking open/write for thread -* パッケージまたは大域変数のアクセス制御 -* format機能 -* re-write regex code for speed and copyright +* package or access control for global variables +* format @@ -3774,7 +3774,7 @@ EOF cat >> confdefs.h <<EOF -#define RUBY_SITE_THIN_ARCHLIB "${prefix}/lib/site_ruby/" __ARCHITECTURE__ "-${host_os}" +#define RUBY_SITE_THIN_ARCHLIB "${prefix}/lib/ruby/" __ARCHITECTURE__ "-${host_os}" EOF diff --git a/configure.in b/configure.in index f522e6e581..dc561b4d78 100644 --- a/configure.in +++ b/configure.in @@ -463,7 +463,7 @@ if test "$fat_binary" = yes ; then "${prefix}/lib/ruby/" __ARCHITECTURE__ "-${host_os}" ) AC_DEFINE_UNQUOTED(RUBY_SITE_THIN_ARCHLIB, - "${prefix}/lib/site_ruby/" __ARCHITECTURE__ "-${host_os}" ) + "${prefix}/lib/ruby/" __ARCHITECTURE__ "-${host_os}" ) AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${prefix}/lib/ruby/${arch}") AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${prefix}/lib/site_ruby/${arch}") @@ -359,7 +359,6 @@ extern int nerrs; extern VALUE mKernel; extern VALUE cModule; -extern VALUE cClass; extern VALUE eFatal; extern VALUE eGlobalExit; extern VALUE eInterrupt; @@ -3818,8 +3817,10 @@ f_eval(argc, argv, self) } static VALUE -eval_under(under, self, src) - VALUE under, self, src; +exec_under(func, under, args) + VALUE (*func)(); + VALUE under; + void *args; { VALUE val; /* OK */ int state; @@ -3828,14 +3829,14 @@ eval_under(under, self, src) PUSH_CLASS(); the_class = under; PUSH_FRAME(); - the_frame->last_func = _frame.last_func; - the_frame->last_class = _frame.last_class; - the_frame->argc = 1; - the_frame->argv = &src; + the_frame->last_func = _frame.prev->last_func; + the_frame->last_class = _frame.prev->last_class; + the_frame->argc = _frame.prev->argc; + the_frame->argv = _frame.prev->argv; the_frame->cbase = (VALUE)node_newnode(NODE_CREF,under,0,cbase); PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { - val = eval(self, src, Qnil, 0, 0); + val = (*func)(args); } POP_TAG(); POP_FRAME(); @@ -3846,29 +3847,101 @@ eval_under(under, self, src) } static VALUE -obj_instance_eval(self, src) - VALUE self, src; +eval_under_i(args) + VALUE *args; +{ + return eval(args[0], args[1], Qnil, 0, 0); +} + +static VALUE +eval_under(under, self, src) + VALUE under, self, src; +{ + VALUE args[2]; + + args[0] = self; + args[1] = src; + return exec_under(eval_under_i, under, args); +} + +static VALUE +yield_under_i(self) + VALUE self; +{ + return rb_yield_0(self, self); +} + +static VALUE +yield_under(under, self) + VALUE under, self; +{ + return exec_under(yield_under_i, under, self); +} + +static VALUE +obj_instance_eval(argc, argv, self) + int argc; + VALUE *argv; + VALUE self; { - return eval_under(CLASS_OF(self), self, src); + VALUE src; + + if (argc == 0) { + if (!iterator_p()) { + ArgError("block not supplied"); + } + return yield_under(CLASS_OF(self), self); + } + if (argc == 1) { + Check_SafeStr(argv[0]); + } + else { + ArgError("Wrong # of arguments: %s(src) or %s{..}", + rb_id2name(the_frame->last_func), + rb_id2name(the_frame->last_func)); + } + + return eval_under(CLASS_OF(self), self, argv[0]); } static VALUE -mod_module_eval(mod, src) - VALUE mod, src; +mod_module_eval(argc, argv, mod) + int argc; + VALUE *argv; + VALUE mod; { int state; int mode; VALUE result = Qnil; + if (argc == 0) { + if (!iterator_p()) { + ArgError("block not supplied"); + } + } + else if (argc == 1) { + Check_SafeStr(argv[0]); + } + else { + ArgError("Wrong # of arguments: %s(src) or %s{..}", + rb_id2name(the_frame->last_func), + rb_id2name(the_frame->last_func)); + } + mode = FL_TEST(the_scope, SCOPE_MASK); - PUSH_TAG(PROT_NONE) + SCOPE_SET(the_scope, SCOPE_PUBLIC); + PUSH_TAG(PROT_NONE); if ((state = EXEC_TAG()) == 0) { - result = eval_under(mod, mod, src); + if (argc == 0) { + result = yield_under(mod, mod); + } + else { + result = eval_under(mod, mod, argv[0]); + } } POP_TAG(); SCOPE_SET(the_scope, mode); if (state) JUMP_TAG(state); - return result; } @@ -4470,7 +4543,7 @@ Init_eval() rb_define_method(mKernel, "send", f_send, -1); rb_define_method(mKernel, "__send__", f_send, -1); - rb_define_method(mKernel, "instance_eval", obj_instance_eval, 1); + rb_define_method(mKernel, "instance_eval", obj_instance_eval, -1); rb_define_private_method(cModule, "append_features", mod_append_features, 1); rb_define_private_method(cModule, "extend_object", mod_extend_object, 1); @@ -4482,7 +4555,8 @@ Init_eval() rb_define_method(cModule, "method_defined?", mod_method_defined, 1); rb_define_method(cModule, "public_class_method", mod_public_method, -1); rb_define_method(cModule, "private_class_method", mod_private_method, -1); - rb_define_method(cModule, "module_eval", mod_module_eval, 1); + rb_define_method(cModule, "module_eval", mod_module_eval, -1); + rb_define_method(cModule, "class_eval", mod_module_eval, -1); rb_define_method(cModule, "remove_method", mod_remove_method, 1); rb_define_method(cModule, "undef_method", mod_undef_method, 1); @@ -6220,7 +6294,7 @@ f_catch(dmy, tag) if ((state = EXEC_TAG()) == 0) { val = rb_yield(tag); } - else if (state == TAG_THROW && prot_tag->tag == prot_tag->dst) { + else if (state == TAG_THROW && t == prot_tag->dst) { val = prot_tag->retval; state = 0; } @@ -6245,7 +6319,6 @@ f_throw(argc, argv) while (tt) { if (tt->tag == t) { tt->dst = t; - tt->retval = value; break; } #ifdef THREAD @@ -6257,10 +6330,10 @@ f_throw(argc, argv) #endif tt = tt->prev; } - if (!tt) { NameError("uncaught throw `%s'", rb_id2name(t)); } + return_value(value); trap_restore_mask(); JUMP_TAG(TAG_THROW); /* not reached */ diff --git a/ext/socket/socket.c b/ext/socket/socket.c index d45db8b818..fc82854a4d 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -114,7 +114,9 @@ bsock_shutdown(argc, argv, sock) how = 2; else { how = NUM2INT(howto); - if (how < 0 && how > 2) how = 2; +#if 0 + if (how < 0 || 2 < how) how = 2; +#endif } GetOpenFile(sock, fptr); if (shutdown(fileno(fptr->f), how) == -1) @@ -1464,12 +1464,7 @@ f_test(argc, argv) int cmd; if (argc == 0) ArgError("Wrong # of arguments"); - if (TYPE(argv[0]) == T_STRING && RSTRING(argv[0])->len == 1) { - cmd = RSTRING(argv[0])->ptr[0]; - } - else { - cmd = NUM2INT(argv[0]); - } + cmd = NUM2CHR(argv[0]); if (cmd == 0) return FALSE; if (strchr("bcdefgGkloOprRsSuwWxXz", cmd)) { CHECK(1); @@ -1587,7 +1582,9 @@ f_test(argc, argv) break; } } - return FALSE; + /* unknown command */ + ArgError("unknow command ?%c", cmd); + return Qnil; /* not reached */ } extern VALUE mKernel; @@ -289,7 +289,7 @@ module TkCore str = arg.to_s() end argstr += " " if argstr != "" - argstr += '"' + str.gsub(/[][$"]/, '\\\\\&') + '"' + argstr += '"' + str.gsub(/[][$"]/, '\\\\\&') + '"' #' } return argstr end @@ -68,6 +68,9 @@ extern char *sourcefile; #ifndef RUBY_LIB #define RUBY_LIB "/usr/local/lib/ruby" #endif +#ifndef RUBY_SITE_LIB +#define RUBY_SITE_LIB "/usr/local/lib/site_ruby" +#endif #if defined(MSDOS) || defined(NT) #define RUBY_LIB_SEP ';' @@ -703,9 +706,7 @@ ruby_prog_init() addpath(RUBY_THIN_ARCHLIB); #endif -#ifdef RUBY_SITE_LIB addpath(RUBY_SITE_LIB); -#endif #ifdef RUBY_SITE_ARCHLIB addpath(RUBY_SITE_ARCHLIB); #endif diff --git a/sample/ruby-mode.el b/sample/ruby-mode.el index 0d94df0fc8..5d5af3437d 100644 --- a/sample/ruby-mode.el +++ b/sample/ruby-mode.el @@ -361,6 +361,9 @@ The variable ruby-indent-level controls the amount of indentation. ))))))) (list in-string (car nest) depth (car (car pcol)))))) +(defun ruby-indent-size (pos nest) + (+ pos (* (if nest nest 1) ruby-indent-level))) + (defun ruby-calculate-indent (&optional parse-start) (save-excursion (beginning-of-line) @@ -388,19 +391,19 @@ The variable ruby-indent-level controls the amount of indentation. ((and (nth 2 s) (> (nth 2 s) 0)) (goto-char (cdr (nth 1 s))) (forward-word -1) - (setq indent (+ (current-column) ruby-indent-level))) + (setq indent (ruby-indent-size (current-column) (nth 2 state)))) (t (setq indent (current-column))))) (cond ((nth 3 state) (goto-char (nth 3 state)) - (setq indent (+ (current-column) ruby-indent-level))) + (setq indent (ruby-indent-size (current-column) (nth 2 state)))) (t (goto-char parse-start) (back-to-indentation) - (setq indent (+ (current-column) (* (nth 2 state) ruby-indent-level))))) + (setq indent (ruby-indent-size (current-column) (nth 2 state))))) )) - + ((and (nth 2 state)(> (nth 2 state) 0)) ; in nest (if (null (cdr (nth 1 state))) (error "invalid nest")) @@ -411,17 +414,17 @@ The variable ruby-indent-level controls the amount of indentation. (cond ((nth 3 state) (goto-char (nth 3 state)) - (setq indent (+ (current-column) ruby-indent-level))) + (setq indent (ruby-indent-size (current-column) (nth 2 state)))) (t (goto-char parse-start) (back-to-indentation) - (setq indent (+ (current-column) (* (nth 2 state) ruby-indent-level)))))) + (setq indent (ruby-indent-size (current-column) (nth 2 state)))))) (t (setq indent (+ (current-column) ruby-indent-level))))) ((and (nth 2 state) (< (nth 2 state) 0)) ; in negative nest - (setq indent (+ (current-column) (* (nth 2 state) ruby-indent-level))))) - + (setq indent (ruby-indent-size (current-column) (nth 2 state))))) + (cond (indent (goto-char indent-point) diff --git a/sample/test.rb b/sample/test.rb index a3f23a6d24..69a168f2c4 100644 --- a/sample/test.rb +++ b/sample/test.rb @@ -109,8 +109,8 @@ tmp.close $bad = false tmp = open("while_tmp", "r") while tmp.gets() - next if /vt100/; - $bad = 1 if /vt100/; + next if /vt100/; + $bad = 1 if /vt100/; end ok(!(!tmp.eof? || /vt100/ || $bad)) tmp.close @@ -240,6 +240,18 @@ while true end ok(!$bad) +ok(catch(:foo) { + loop do + loop do + throw :foo, true + break + end + break + ok(false) # should no reach here + end + false + }) + check "array" ok([1, 2] + [3, 4] == [1, 2, 3, 4]) ok([1, 2] * 2 == [1, 2, 1, 2]) @@ -287,7 +299,8 @@ ok($x == [7,5,3,2,1]) # split test $x = "The Book of Mormon" -ok($x.split(//).reverse!.join == "nomroM fo kooB ehT") +ok($x.split(//).reverse!.join == $x.reverse) +ok($x.reverse == $x.reverse!) ok("1 byte string".split(//).reverse.join(":") == "g:n:i:r:t:s: :e:t:y:b: :1") $x = "a b c d" ok($x.split == ['a', 'b', 'c', 'd']) @@ -539,6 +552,8 @@ ok(?\M-\C-a == 129) ok("a".upcase![0] == ?A) ok("A".downcase![0] == ?a) ok("abc".tr!("a-z", "A-Z") == "ABC") +ok("aabbcccc".tr_s!("a-z", "A-Z") == "ABC") +ok("abc".tr!("0-9", "A-Z") == nil) ok("abcc".squeeze!("a-z") == "abc") ok("abcd".delete!("bc") == "ad") |