"requiring version.rb" strategy has some issues.
- cannot work when cross-compiling
- often introduces wrong namespace
- must know the superclasses
- costs at each runtime than at build-time
etc.
Cfuncs that use rb_scan_args with the : entry suffer similar keyword
argument separation issues that Ruby methods suffer if the cfuncs
accept optional or variable arguments.
This makes the following changes to : handling.
* Treats as **kw, prompting keyword argument separation warnings
if called with a positional hash.
* Do not look for an option hash if empty keywords are provided.
For backwards compatibility, treat an empty keyword splat as a empty
mandatory positional hash argument, but emit a a warning, as this
behavior will be removed in Ruby 3. The argument number check
needs to be moved lower so it can correctly handle an empty
positional argument being added.
* If the last argument is nil and it is necessary to treat it as an option
hash in order to make sure all arguments are processed, continue to
treat the last argument as the option hash. Emit a warning in this case,
as this behavior will be removed in Ruby 3.
* If splitting the keyword hash into two hashes, issue a warning, as we
will not be splitting hashes in Ruby 3.
* If the keyword argument is required to fill a mandatory positional
argument, continue to do so, but emit a warning as this behavior will
be going away in Ruby 3.
* If keyword arguments are provided and the last argument is not a hash,
that indicates something wrong. This can happen if a cfunc is calling
rb_scan_args multiple times, and providing arguments that were not
passed to it from Ruby. Callers need to switch to the new
rb_scan_args_kw function, which allows passing of whether keywords
were provided.
This commit fixes all warnings caused by the changes above.
It switches some function calls to *_kw versions with appropriate
kw_splat flags. If delegating arguments, RB_PASS_CALLED_KEYWORDS
is used. If creating new arguments, RB_PASS_KEYWORDS is used if
the last argument is a hash to be treated as keywords.
In open_key_args in io.c, use rb_scan_args_kw.
In this case, the arguments provided come from another C
function, not Ruby. The last argument may or may not be a hash,
so we can't set keyword argument mode. However, if it is a
hash, we don't want to warn when treating it as keywords.
In Ruby files, make sure to appropriately use keyword splats
or literal keywords when calling Cfuncs that now issue keyword
argument separation warnings through rb_scan_args. Also, make
sure not to pass nil in place of an option hash.
Work around Kernel#warn warnings due to problems in the Rubygems
override of the method. There is an open pull request to fix
these issues in Rubygems, but part of the Rubygems tests for
their override fail on ruby-head due to rb_scan_args not
recognizing empty keyword splats, which this commit fixes.
Implementation wise, adding rb_scan_args_kw is kind of a pain,
because rb_scan_args takes a variable number of arguments.
In order to not duplicate all the code, the function internals need
to be split into two functions taking a va_list, and to avoid passing
in a ton of arguments, a single struct argument is used to handle
the variables previously local to the function.
* lib/pstore.rb (PStore::CHECKSUM_ALGO): find available hashing
algorithm for checksum. MD5 is not available in FIPS mode.
[Feature #6943]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/pstore.rb (PStore::CHECKSUM_ALGO): extract the algorithm for
checksum, instead of qualified names for each times.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
When you change this to true, you may need to add more tests.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
See #5248.
* lib/pstore.rb (save_data):
* Delete inadequate Marshal check.
* Deferred file truncation: when writing the new content, truncate
the saved file to the data size after writing the data, instead of
truncating whole bytes before writing data.
* Deferred MD5 calculation: when comparing MD5 hash to check the
content modification, calculate MD5 hash of new data iif the
content length is differ from the old one.
* Compare content size with String#bytesize instead of String#size.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
is true. Patch by Masaki Matsushita (Glass_saga). [ruby-dev:43337]
* test/test_pstore.rb: Test for above.
Patch by Masaki Matsushita (Glass_saga) [ruby-dev:43337]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31101 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
overriding. [ruby-dev:34305]
* lib/yaml/store.rb (YAML::Store::marshal_dump_supports_canonical_option?):
add a method to support faster PStore.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[ruby-core:7304]
* lib/pstore.rb: should raise PStore::Error if not in transaction.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9887 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
[ruby-dev:27535]
* time.c (time_sunday): added predicate methods for the days of the
week. [ruby-list:41340]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c (rb_io_flags_mode): requires output buffer no more. no
allocation needed.
* array.c (rb_ary_index): takes a block to compare items in an
array. [ruby-talk:113069] [Ruby2]
* array.c (rb_ary_rindex): ditto.
* marshal.c (r_byte): retrieve pointer from string value for each
time. [ruby-dev:24404]
* marshal.c (r_bytes0): ditto.
* enum.c (sort_by_i): re-entrance check added. [ruby-dev:24399]
* io.c (io_read): should freeze all reading buffer.
[ruby-dev:24400]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* hash.c (env_shift): ditto.
* hash.c (env_invert): ditto.
* hash.c (env_replace): ditto.
* hash.c (env_update): ditto.
* array.c (rb_ary_join): dispatch based on "to_str".
* array.c (rb_ary_times): ditto.
* array.c (rb_ary_equal): ditto.
* process.c (rb_f_exec): dispatch based on "to_ary".
* eval.c (umethod_bind): exact class match is not required. relax
the restriction to subclasses.
* eval.c (rb_eval): call "inherited" before executing class body.
* class.c (rb_define_class): call "inherited" after defining the
constant.
* class.c (rb_define_class_under): ditto.
* eval.c (massign): expand first element if RHS is an array and
its size is 1, and LHS has concrete assignment target (i.e. LHS
has target(s) other than *var).
* eval.c (massign): avoid unnecessary avalue/svalue conversion.
* eval.c (rb_yield_0): ditto
* array.c (rb_ary_update): do not allocate unused array if rpl is
nil (i.e. merely removing elements).
* io.c (io_read): should resize supplied string if it's shorter
than expected.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
asin, acosh, atanh, log, log10 and sqrt.
* eval.c (rb_add_method): initialize should always be private.
* parse.y (expr): add rescue modifier rule.
* parse.y (command_call): return, break and next with argument is
now part of this rule.
* parse.y (yylex): "a" in "a /5" should be considered as a local
variable. [experimental]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
substring, slice! should return nil without exception.
* array.c (rb_ary_insert): type fixed.
* string.c (rb_str_split_m): accept separator value nil as well.
* string.c (rb_str_become): was leaking memory.
* class.c (rb_include_module): should not alter other
classes/modules by inclusion. by this fix, local order may not
be preserved for some cases.
* class.c (include_class_new): module may be T_ICLASS; retrieve
original module information.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
string literals.
* parse.y (here_document): should be aware of __END__ within here
documents.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
expression interpolation.
* pack.c (pack_unpack): should give length to utf8_to_uv().
* pack.c (utf8_to_uv): add length check.
* massages: replace "wrong #" by "wrong number".
* marshal.c (w_float): output Infinity and NaN explicitly.
* marshal.c (r_object): support new explicit float format.
* eval.c (rb_thread_wait_for): select may cause ERESTART on
Solaris.
* eval.c (rb_thread_select): ditto.
* array.c (rb_ary_join): dumped core if sep is not T_STRING nor T_NIL.
* array.c (rb_ary_join): buffer size calculattion was wrong.
* array.c (rb_ary_to_s): if rb_output_fs is nil, insert newlines
between array elements (use rb_default_rs as newline litral)
[experimental].
* gc.c (init_mark_stack): no need to clear mark_stack.
* gc.c (gc_mark_all): need to handle finalizer mark.
* gc.c (gc_mark_rest): use MEMCPY instead of memcpy.
* gc.c (rb_gc_mark): earlier const check to avoid pusing special
constants into mark stack.
* numeric.c (fix_to_s): 'to_s' now takes optional argument to
specify radix. [new]
* bignum.c (rb_big_to_s): ditto. [new]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
and Marshal::MINOR_VERSION.
* marshal.c (marshal_load): ruby_verbose test should be wrapped by
RTEST().
* hash.c (rb_hash_index): should return nil (not the default
value) if value is not in the hash.
* numeric.c (num_div): new method added. alias to '/' which
should be preserved even if '/' is redefined (e.g. by
mathn). [new]
* bignum.c (rb_cstr2inum): "0 ff".hex should return 0, not 255.
* file.c (rb_file_s_expand_path): fixed using CharNext().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e