* class.c (rb_scan_args): Add support for optional keyword

argument hash.

* README.EXT, README.EXT.ja: Update documentation accordingly.

* dir.c (dir_initialize): Make use of the new rb_scan_args()
  feature.

* io.c (rb_io_s_popen, rb_scan_open_args, rb_io_initialize)
  (rb_io_s_pipe, open_key_args, io_s_foreach, io_s_readlines)
  (rb_io_s_read, rb_io_set_encoding): Ditto.

* transcode.c (str_transcode, econv_args)
  (econv_primitive_convert): Ditto.

* ext/zlib/zlib.c (rb_gzreader_initialize): Ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2010-09-10 07:51:58 +00:00
parent 4f77c495cd
commit 82abe79b9f
8 changed files with 130 additions and 83 deletions

View file

@ -1105,12 +1105,13 @@ according to the format string. The format can be described in ABNF
as follows:
--
scan-arg-spec := param-arg-spec [block-arg-spec]
scan-arg-spec := param-arg-spec [option-hash-arg-spec] [block-arg-spec]
param-arg-spec := pre-arg-spec [post-arg-spec] / post-arg-spec / pre-opt-post-arg-spec
pre-arg-spec := num-of-leading-mandatory-args [num-of-optional-args]
post-arg-spec := sym-for-variable-length-args [num-of-trailing-mandatory-args]
pre-opt-post-arg-spec := num-of-leading-mandatory-args num-of-optional-args num-of-trailing-mandatory-args
option-hash-arg-spec := sym-for-option-hash-arg
block-arg-spec := sym-for-block-arg
num-of-leading-mandatory-args := DIGIT ; The number of leading
@ -1122,6 +1123,18 @@ sym-for-variable-length-args := "*" ; Indicates that variable
; captured as a ruby array
num-of-trailing-mandatory-args := DIGIT ; The number of trailing
; mandatory arguments
sym-for-option-hash-arg := ":" ; Indicates that an option
; hash is captured if the last
; argument is a hash or can be
; converted to a hash with
; #to_hash. When the last
; argument is nil, it is
; captured if it is not
; ambiguous to take it as
; empty option hash; i.e. '*'
; is not specified and
; arguments are given more
; than sufficient.
sym-for-block-arg := "&" ; Indicates that an iterator
; block should be captured if
; given
@ -1134,8 +1147,8 @@ assigned to captured arguments. For omitted arguments, variables are
set to Qnil. NULL can be put in place of a variable reference, which
means the corresponding captured argument(s) should be just dropped.
The number of given arguments, excluding an iterator block, is
returned.
The number of given arguments, excluding an option hash or iterator
block, is returned.
** Invoking Ruby method