diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-09-12 05:37:38 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-09-12 05:37:38 +0000 |
commit | fbcc6dea0c86e7e4d087f1d4b2de19b211d16647 (patch) | |
tree | 68bde87194755712893e5efa4d7f9d2f5312df10 | |
parent | 9d823983dc3e88cb7775c78908a4bb5133ad88ac (diff) |
matz: 1.6.0 final (hopufully)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@934 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 35 | ||||
-rw-r--r-- | array.c | 6 | ||||
-rw-r--r-- | compar.c | 11 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | eval.c | 28 | ||||
-rw-r--r-- | ext/dbm/dbm.c | 3 | ||||
-rw-r--r-- | ext/dbm/extconf.rb | 1 | ||||
-rw-r--r-- | gc.c | 2 | ||||
-rw-r--r-- | hash.c | 6 | ||||
-rw-r--r-- | lib/net/ftp.rb | 14 | ||||
-rw-r--r-- | lib/net/http.rb | 12 | ||||
-rw-r--r-- | lib/net/pop.rb | 6 | ||||
-rw-r--r-- | lib/net/protocol.rb | 10 | ||||
-rw-r--r-- | lib/net/smtp.rb | 6 | ||||
-rw-r--r-- | lib/net/telnet.rb | 14 | ||||
-rw-r--r-- | misc/ruby-mode.el | 22 | ||||
-rw-r--r-- | object.c | 10 | ||||
-rw-r--r-- | parse.y | 17 | ||||
-rw-r--r-- | ruby.1 | 4 | ||||
-rw-r--r-- | version.h | 4 |
20 files changed, 135 insertions, 78 deletions
@@ -1,12 +1,39 @@ +Tue Sep 12 14:36:49 2000 Yukihiro Matsumoto <[email protected]> + + * stable version 1.6.0 released. + Tue Sep 12 07:05:24 2000 Wakou Aoyama <[email protected]> * lib/cgi.rb: version 2.0.0: require ruby1.5.4 or later. * lib/net/telnet.rb: version 1.6.0 -Wed Sep 6 17:06:59 2000 Yukihiro Matsumoto <[email protected]> +Tue Sep 12 03:26:07 2000 Yukihiro Matsumoto <[email protected]> - * stable version 1.6.0 released. + * eval.c (massign): use to_ary to get an array if available. + + * object.c (rb_Array): ditto. + +Mon Sep 11 14:24:47 2000 Yukihiro Matsumoto <[email protected]> + + * hash.c (ruby_setenv): should not free the element of + origenvironment. + + * parse.y (command_call): kYIELD moved to this rule to allow + 'a = yield b'. (ruby-bugs-ja:#PR15) + +Mon Sep 11 01:27:54 2000 Yukihiro Matsumoto <[email protected]> + + * eval.c (rb_yield_0): proc#call([]) should pass single value to + the block. + + * eval.c (callargs): reduce array allocation. + + * eval.c (massign): precise check for argument number. + +Fri Sep 8 10:05:17 2000 Yukihiro Matsumoto <[email protected]> + + * gc.c (STR_NO_ORIG): should be FL_USER2. Thu Sep 7 14:17:51 2000 Yukihiro Matsumoto <[email protected]> @@ -163,7 +190,7 @@ Fri Aug 25 15:24:39 2000 Yukihiro Matsumoto <[email protected]> * variable.c (rb_cvar_declare): ditto. * variable.c (mod_av_set): second class variable assignment at the - toplevel shoule not give warning. + toplevel should not give warning. Fri Aug 25 01:18:36 2000 Yukihiro Matsumoto <[email protected]> @@ -720,7 +747,7 @@ Sat Jul 1 15:22:35 2000 Yukihiro Matsumoto <[email protected]> Sat Jul 1 15:22:35 2000 Yukihiro Matsumoto <[email protected]> * eval.c (rb_eval): the value from RTEST() is not valid Ruby - objct. result shoule be either true or false. + objct. result should be either true or false. Sat Jul 1 09:30:06 2000 Katsuyuki Komatsu <[email protected]> @@ -355,7 +355,10 @@ rb_ary_unshift_m(argc, argv, ary) VALUE *argv; VALUE ary; { - if (argc > 0) { + if (argc == 0) { + rb_raise(rb_eArgError, "wrong # of arguments(at least 1)"); + } + if (argc > 1) { long len = RARRAY(ary)->len; /* make rooms by setting the last item */ @@ -363,7 +366,6 @@ rb_ary_unshift_m(argc, argv, ary) /* sliding items */ MEMMOVE(RARRAY(ary)->ptr + argc, RARRAY(ary)->ptr, VALUE, len); - MEMCPY(RARRAY(ary)->ptr, argv, VALUE, argc); } return ary; @@ -34,14 +34,6 @@ cmp_failed() } static VALUE -cmp_eq2(a) - VALUE *a; -{ - return rb_rescue2(cmp_eq, (VALUE)a, cmp_failed, 0, - rb_eStandardError, rb_eNameError, 0); -} - -static VALUE cmp_equal(x, y) VALUE x, y; { @@ -50,7 +42,8 @@ cmp_equal(x, y) if (x == y) return Qtrue; a[0] = x; a[1] = y; - return rb_rescue2(cmp_eq2, (VALUE)a, cmp_failed, 0, rb_eScriptError, 0); + return rb_rescue2(cmp_eq, (VALUE)a, cmp_failed, 0, + rb_eStandardError, rb_eNameError, 0); } static VALUE diff --git a/configure.in b/configure.in index 285aa2199d..6d35250417 100644 --- a/configure.in +++ b/configure.in @@ -945,7 +945,7 @@ AC_DEFINE_UNQUOTED(RUBY_ARCHLIB, "${RUBY_LIB_PATH}/${arch}") AC_DEFINE_UNQUOTED(RUBY_SITE_ARCHLIB, "${RUBY_SITE_LIB_PATH2}/${arch}") AC_ARG_WITH(search-path, - [--with-search-path specify the additional search path], + [--with-search-path=DIR specify the additional search path], [search_path=$withval]) if test "$search_path" != ""; then AC_DEFINE_UNQUOTED(RUBY_SEARCH_PATH,"$search_path") @@ -439,7 +439,8 @@ rb_method_boundp(klass, id, ex) return Qfalse; } -static ID init, eqq, each, aref, aset, match, missing, added, singleton_added; +static ID init, eqq, each, aref, aset, match, to_ary; +static ID missing, added, singleton_added; static ID __id__, __send__; void @@ -3425,8 +3426,13 @@ rb_yield_0(val, self, klass, acheck) if ((state = EXEC_TAG()) == 0) { if (nd_type(block->var) == NODE_MASGN) massign(self, block->var, val, acheck); - else + else { + if (val != Qundef && + TYPE(val) == T_ARRAY && RARRAY(val)->len == 1) { + val = RARRAY(val)->ptr[0]; + } assign(self, block->var, val, acheck); + } } POP_TAG(); if (state) goto pop_state; @@ -3524,7 +3530,17 @@ massign(self, node, val, check) val = rb_ary_new2(0); } else if (TYPE(val) != T_ARRAY) { - val = rb_ary_new3(1, val); + if (rb_respond_to(val, to_ary)) { + VALUE ary = rb_funcall(val, to_ary, 0); + if (TYPE(ary) != T_ARRAY) { + rb_raise(rb_eTypeError, "%s#to_ary should return Array", + rb_class2name(CLASS_OF(val))); + } + val = ary; + } + else { + val = rb_ary_new3(1, val); + } } len = RARRAY(val)->len; list = node->nd_head; @@ -3546,6 +3562,9 @@ massign(self, node, val, check) assign(self, node->nd_args, rb_ary_new2(0), check); } } + else if (check && i < len) { + goto arg_error; + } while (list) { i++; @@ -5567,6 +5586,7 @@ Init_eval() aref = rb_intern("[]"); aset = rb_intern("[]="); match = rb_intern("=~"); + to_ary = rb_intern("to_ary"); missing = rb_intern("method_missing"); added = rb_intern("method_added"); singleton_added = rb_intern("singleton_method_added"); @@ -5961,8 +5981,6 @@ callargs(args) case 0: return Qundef; break; - case 1: - return RARRAY(args)->ptr[0]; default: return args; } diff --git a/ext/dbm/dbm.c b/ext/dbm/dbm.c index 87b364731e..b1564793d1 100644 --- a/ext/dbm/dbm.c +++ b/ext/dbm/dbm.c @@ -15,6 +15,9 @@ #ifdef HAVE_CDEFS_H # include <cdefs.h> #endif +#ifdef HAVE_SYS_CDEFS_H +# include <sys/cdefs.h> +#endif #include <ndbm.h> #include <fcntl.h> #include <errno.h> diff --git a/ext/dbm/extconf.rb b/ext/dbm/extconf.rb index 55dadc2601..9ce235a2b5 100644 --- a/ext/dbm/extconf.rb +++ b/ext/dbm/extconf.rb @@ -6,6 +6,7 @@ if have_library("gdbm", "dbm_open") end gdbm or have_library("db", "dbm_open") or have_library("dbm", "dbm_open") have_header("cdefs.h") +have_header("sys/cdefs.h") if have_header("ndbm.h") and have_func("dbm_open") have_func("dbm_clearerr") unless gdbm create_makefile("dbm") @@ -751,7 +751,7 @@ obj_free(obj) } break; case T_STRING: -#define STR_NO_ORIG FL_USER3 /* copied from string.c */ +#define STR_NO_ORIG FL_USER2 /* copied from string.c */ if (!RANY(obj)->as.string.orig || FL_TEST(obj, STR_NO_ORIG)) free(RANY(obj)->as.string.ptr); break; @@ -1055,7 +1055,8 @@ ruby_setenv(name, value) environ = tmpenv; /* tell exec where it is now */ } if (!value) { - free(environ[i]); + if (environ[i] != origenviron[i]) + free(environ[i]); while (environ[i]) { environ[i] = environ[i+1]; i++; @@ -1067,7 +1068,8 @@ ruby_setenv(name, value) environ[i+1] = 0; /* make sure it's null terminated */ } else { - free(environ[i]); + if (environ[i] != origenviron[i]) + free(environ[i]); } environ[i] = ALLOC_N(char, strlen(name) + strlen(value) + 2); #ifndef MSDOS diff --git a/lib/net/ftp.rb b/lib/net/ftp.rb index ab10853bed..7383b003c7 100644 --- a/lib/net/ftp.rb +++ b/lib/net/ftp.rb @@ -276,7 +276,7 @@ module Net end def retrlines(cmd, callback = nil) - if iterator? + if block_given? callback = Proc.new elsif not callback.is_a?(Proc) callback = Proc.new {|line| print line, "\n"} @@ -300,7 +300,7 @@ module Net end def storbinary(cmd, file, blocksize, rest_offset = nil, callback = nil) - if iterator? + if block_given? callback = Proc.new end use_callback = callback.is_a?(Proc) @@ -319,7 +319,7 @@ module Net end def storlines(cmd, file, callback = nil) - if iterator? + if block_given? callback = Proc.new end use_callback = callback.is_a?(Proc) @@ -342,7 +342,7 @@ module Net def getbinaryfile(remotefile, localfile, blocksize = DEFAULT_BLOCKSIZE, callback = nil) - if iterator? + if block_given? callback = Proc.new end use_callback = callback.is_a?(Proc) @@ -365,7 +365,7 @@ module Net end def gettextfile(remotefile, localfile, callback = nil) - if iterator? + if block_given? callback = Proc.new end use_callback = callback.is_a?(Proc) @@ -383,7 +383,7 @@ module Net def putbinaryfile(localfile, remotefile, blocksize = DEFAULT_BLOCKSIZE, callback = nil) - if iterator? + if block_given? callback = Proc.new end use_callback = callback.is_a?(Proc) @@ -404,7 +404,7 @@ module Net end def puttextfile(localfile, remotefile, callback = nil) - if iterator? + if block_given? callback = Proc.new end use_callback = callback.is_a?(Proc) diff --git a/lib/net/http.rb b/lib/net/http.rb index e5822d6138..65cd5a9937 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -33,7 +33,7 @@ the terms of the Ruby Distribute License. : start {|http| .... } creates a new Net::HTTP object and starts HTTP session. - When this method is called as iterator, gives HTTP object to block + When this method is called with a block, gives HTTP object to block and close HTTP session after block call finished. : get( path, header = nil, dest = '' ) @@ -46,7 +46,7 @@ the terms of the Ruby Distribute License. # example response, body = http.get( '/index.html' ) - If called as iterator, give a part String of entity body. + If called with a block, give a part String of entity body. Note: If status is not 2xx(success), ProtocolError exception is @@ -81,7 +81,7 @@ the terms of the Ruby Distribute License. "header" must be a Hash like { 'Accept' => '*/*', ... }. This method returns Net::HTTPResponse object and "dest". - If called as iterator, gives a part String of entity body. + If called with a block, gives a part String of entity body. : get2( path, header = nil ) {|adapter| .... } send GET request for "path". @@ -165,7 +165,7 @@ All "key" is case-insensitive. entity body. A body is written to "dest" using "<<" method. : body {|str| ... } - get entity body by using iterator. + get entity body by using block. If this method is called twice, block is not called and returns first "dest". @@ -350,11 +350,13 @@ module Net @socket.reopen end - resp = yield( u_header ) + yield( u_header ) if ublock then adapter = HTTPReadAdapter.new( @command ) ublock.call adapter resp = adapter.off + else + resp = @command.get_response end unless keep_alive? u_header, resp then diff --git a/lib/net/pop.rb b/lib/net/pop.rb index 6e12d4064a..61f7b52cad 100644 --- a/lib/net/pop.rb +++ b/lib/net/pop.rb @@ -31,7 +31,7 @@ Net::Protocol : start( account, password ) {|pop| .... } starts POP3 session. - When called as iterator, give a POP3 object to block and + When called with a block, give a POP3 object to block and close session after block call is finished. : each {|popmail| .... } @@ -80,7 +80,7 @@ Object end : all {|str| .... } - You can use all/pop/mail as the iterator. + You can use all/pop/mail with a block. argument 'str' is a read string (a part of mail). # usage example @@ -180,7 +180,7 @@ module Net end def all( dest = '' ) - if iterator? then + if block_given? then dest = NetPrivate::ReadAdapter.new( Proc.new ) end @command.retr( @num, dest ) diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb index 16d6cac747..3eced45d3a 100644 --- a/lib/net/protocol.rb +++ b/lib/net/protocol.rb @@ -46,7 +46,7 @@ Object '*args' are specified in subclasses. - When is called as iterator, gives Protocol object to block and + When is called with a block, gives Protocol object to block and close session when block finished. : finish @@ -73,7 +73,7 @@ module Net def start( address = 'localhost', port = nil, *args ) instance = new( address, port ) - if iterator? then + if block_given? then instance.start( *args ) { yield instance } else instance.start( *args ) @@ -167,9 +167,9 @@ module Net connect do_start( *args ) @active = true - yield self if iterator? + yield self if block_given? ensure - finish if iterator? + finish if block_given? end end @@ -561,7 +561,7 @@ module Net while (str = readuntil( "\r\n" )) != ".\r\n" do str.chop! arr.push str - yield str if iterator? + yield str if block_given? end @pipe << "read #{arr.size} lines\n" if pipeon diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index 53bed4910b..f7af92d635 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -33,7 +33,7 @@ Net::Protocol opens TCP connection and starts SMTP session. If protocol had been started, do nothing and return false. - When this methods is called as iterator, give a SMTP object to block and + When this methods is called with a block, give a SMTP object to block and close session after block call finished. If account and password are given, is trying to get authentication @@ -42,7 +42,7 @@ Net::Protocol : send_mail( mailsrc, from_addr, *to_addrs ) : sendmail( mailsrc, from_addr, *to_addrs ) This method sends 'mailsrc' as mail. SMTP read strings - from 'mailsrc' by calling 'each' iterator, and convert them + from 'mailsrc' by calling 'each' method, and convert them into "\r\n" terminated string when write. from_addr must be String. @@ -62,7 +62,7 @@ Net::Protocol : ready( from_addr, to_addrs ) {|adapter| .... } This method stands by the SMTP object for sending mail. - In the block of this iterator, you can call ONLY 'write' method + In the block of this method, you can call ONLY 'write' method for 'adapter'. # usage example diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb index 1b8a52bc78..44bb223ddf 100644 --- a/lib/net/telnet.rb +++ b/lib/net/telnet.rb @@ -312,7 +312,7 @@ module Net end else message = "Trying " + @options["Host"] + "...\n" - yield(message) if iterator? + yield(message) if block_given? @log.write(message) if @options.has_key?("Output_log") @dumplog.log_dump('#', message) if @options.has_key?("Dump_log") @@ -335,7 +335,7 @@ module Net @sock.binmode message = "Connected to " + @options["Host"] + ".\n" - yield(message) if iterator? + yield(message) if block_given? @log.write(message) if @options.has_key?("Output_log") @dumplog.log_dump('#', message) if @options.has_key?("Dump_log") end @@ -489,11 +489,11 @@ module Net end @log.print(buf) if @options.has_key?("Output_log") line.concat(buf) - yield buf if iterator? + yield buf if block_given? rescue EOFError # End of file reached if line == '' line = nil - yield nil if iterator? + yield nil if block_given? end break end @@ -554,7 +554,7 @@ module Net end self.puts(string) - if iterator? + if block_given? waitfor({"Prompt" => match, "Timeout" => time_out}){|c| yield c } else waitfor({"Prompt" => match, "Timeout" => time_out}) @@ -569,7 +569,7 @@ module Net username = options end - if iterator? + if block_given? line = waitfor(/login[: ]*\z/n){|c| yield c } if password line.concat( cmd({"String" => username, @@ -706,7 +706,7 @@ end * 1999/04/11 - wakou * version 0.163 - * STDOUT.write(message) --> yield(message) if iterator? + * STDOUT.write(message) --> yield(message) if block_given? * 1999/03/17 - wakou * version 0.162 diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el index e884e06994..b5d70403e0 100644 --- a/misc/ruby-mode.el +++ b/misc/ruby-mode.el @@ -544,18 +544,20 @@ The variable ruby-indent-level controls the amount of indentation. (or (not (eq ?| (char-after (point)))) (save-excursion (or (eolp) (forward-char -1)) - (and (search-backward "|") - (skip-chars-backward " \t\n") - (and (not (eolp)) - (progn - (forward-char -1) - (not (looking-at "\\{"))) - (progn - (forward-word -1) - (not (looking-at "do\\>[^_]"))))))))) + (cond + ((search-backward "|" nil t) + (skip-chars-backward " \t\n") + (and (not (eolp)) + (progn + (forward-char -1) + (not (looking-at "\\{"))) + (progn + (forward-word -1) + (not (looking-at "do\\>[^_]"))))) + (t t)))))) (setq indent (+ indent ruby-indent-level))))))) indent))) - + (defun ruby-electric-brace (arg) (interactive "P") (self-insert-command (prefix-numeric-value arg)) @@ -990,8 +990,16 @@ VALUE rb_Array(val) VALUE val; { + ID to_ary; + if (TYPE(val) == T_ARRAY) return val; - val = rb_funcall(val, rb_intern("to_a"), 0); + to_ary = rb_intern("to_ary"); + if (rb_respond_to(val, to_ary)) { + val = rb_funcall(val, to_ary, 0); + } + else { + val = rb_funcall(val, rb_intern("to_a"), 0); + } if (TYPE(val) != T_ARRAY) { rb_raise(rb_eTypeError, "`to_a' did not return Array"); } @@ -190,7 +190,7 @@ static void top_local_setup(); %type <node> aref_args opt_block_arg block_arg stmt_rhs %type <node> mrhs superclass generic_call block_call var_ref %type <node> f_arglist f_args f_optarg f_opt f_block_arg opt_f_block_arg -%type <node> array assoc_list assocs assoc undef_list backref +%type <node> assoc_list assocs assoc undef_list backref %type <node> block_var opt_block_var brace_block do_block lhs none %type <node> mlhs mlhs_head mlhs_basic mlhs_entry mlhs_item mlhs_node %type <id> fitem variable sym symbol operation operation2 operation3 @@ -421,10 +421,6 @@ expr : mlhs '=' mrhs yyerror("return appeared outside of method"); $$ = NEW_RETURN($2); } - | kYIELD ret_args - { - $$ = NEW_YIELD($2); - } | command_call | expr kAND expr { @@ -469,6 +465,12 @@ command_call : operation call_args $$ = new_super($2); fixpos($$, $2); } + | kYIELD ret_args + { + $$ = NEW_YIELD($2); + fixpos($$, $2); + } + mlhs : mlhs_basic | tLPAREN mlhs_entry ')' @@ -1025,9 +1027,6 @@ ret_args : call_args } } -array : none - | args trailer - primary : literal { $$ = NEW_LIT($1); @@ -1083,7 +1082,7 @@ primary : literal value_expr($1); $$ = NEW_CALL($1, tAREF, $3); } - | tLBRACK array ']' + | tLBRACK aref_args ']' { if ($2 == 0) $$ = NEW_ZARRAY(); /* zero length array*/ @@ -1,6 +1,6 @@ .\"Ruby is copyrighted by Yukihiro Matsumoto <[email protected]>. .na -.TH RUBY 1 "ruby 1.6" "2000-09-04" "Ruby Programmers Reference Guide" +.TH RUBY 1 "ruby 1.6" "2000-09-11" "Ruby Programmers Reference Guide" .SH NAME ruby - Interpreted object-oriented scripting language .SH SYNOPSIS @@ -195,7 +195,7 @@ used to tell Ruby where to load the library scripts. Directory path will be added to the load-path variable ($:'). .TP .B -Kkcode -specifies KANJI (Japanese) code-set. +specifies KANJI (Japanese) encoding. .TP .B -l enables automatic line-ending processing, which means to firstly set @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.6.0" -#define RUBY_RELEASE_DATE "2000-09-07" +#define RUBY_RELEASE_DATE "2000-09-12" #define RUBY_VERSION_CODE 160 -#define RUBY_RELEASE_CODE 20000907 +#define RUBY_RELEASE_CODE 20000912 |