diff options
author | Michael Leibowitz <michael.leibowitz@intel.com> | 2013-08-15 15:02:54 -0700 |
---|---|---|
committer | Michael Leibowitz <michael.leibowitz@intel.com> | 2013-08-15 15:02:54 -0700 |
commit | 6b0e2a11aeccf2ebc707c22548a0c15c8c2bae06 (patch) | |
tree | d9d59f4b502927634d32832e963db76629ff5a2e | |
parent | 3b35de2a90e26b99e2a6d4f61dc56d6ce7ded748 (diff) | |
download | ruby-upstream.tar.gz ruby-upstream.tar.bz2 ruby-upstream.zip |
Imported Upstream version 1.9.3.p448upstream/1.9.3.p448upstream
256 files changed, 11511 insertions, 6812 deletions
@@ -1,3 +1,1925 @@ +Thu Jun 27 20:11:52 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * ext/openssl/lib/openssl/ssl-inernal.rb (verify_certificate_identity): + fix hostname verification. Patched by nahi. + + * test/openssl/test_ssl.rb (test_verify_certificate_identity): test for + above. + +Wed Jun 26 18:28:29 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/ruby/test_m17n.rb: assert_predicate and assert_not_predicate + is not available on 1.9.3. + +Wed Jun 26 17:08:13 2013 Kazuki Tsujimoto <kazuki@callcc.net> + + * include/ruby/ruby.h, vm_eval.c (rb_funcall_with_block): + new function to invoke a method with a block passed + as an argument. + + * string.c (sym_call): use the above function to avoid + a block sharing. [ruby-dev:47438] [Bug #8531] + + * vm_insnhelper.c (vm_yield_with_cfunc): don't set block + in the frame. + + * test/ruby/test_symbol.rb (TestSymbol#test_block_given_to_proc): + run related tests. + +Wed Jun 26 17:01:22 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * benchmark/bm_hash_shift.rb: add benchmark for Hash#shift + + * hash.c (rb_hash_shift): use st_shift if hash is not being iterated to + delete element without iterating the whole hash. + + * hash.c (shift_i): remove function + + * include/ruby/st.h (st_shift): add st_shift function + + * st.c (st_shift): ditto + + [Backport #8328] [ruby-core:55250] Patch by funny-falcon + +Wed Jun 26 16:52:57 2013 Kazuki Tsujimoto <kazuki@callcc.net> + + * test/ruby/test_proc.rb (TestProc#test_block_given_method_to_proc): + run test for r41359. + +Wed Jun 26 16:52:57 2013 Kazuki Tsujimoto <kazuki@callcc.net> + + * include/ruby/intern.h, proc.c (rb_method_call_with_block): + new function to invoke a Method object with a block passed + as an argument. + + * proc.c (bmcall): use the above function to avoid a block sharing. + [ruby-core:54626] [Bug #8341] + + * test/ruby/test_proc.rb (TestProc#test_block_persist_between_calls): + run related tests. + +Wed Jun 26 16:36:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * defs/id.def (predefined): add "idProc". + + * proc.c (mnew, mproc, mlambda): use predefined IDs. + + * vm.c (Init_VM): ditto. + +Wed Jun 26 16:36:39 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * include/ruby/intern.h (rb_block_lambda): add declaration instead of + deprecated rb_f_lambda. + +Wed Jun 26 16:31:49 2013 Shugo Maeda <shugo@ruby-lang.org> + + * lib/net/imap.rb (capability_response): should ignore trailing + spaces. Thanks, Peter Kovacs. [ruby-core:55024] [Bug #8415] + + * test/net/imap/test_imap_response_parser.rb: related test. + +Wed Jun 26 16:29:41 2013 Charlie Somerville <charliesome@ruby-lang.org> + + * intern.h: remove dangling rb_class_init_copy declaration + [ruby-core:55120] [Bug #8434] + +Wed Jun 26 16:22:12 2013 Charlie Somerville <charliesome@ruby-lang.org> + + * class.c (include_modules_at): invalidate method cache if included + module contains constants + + * test/ruby/test_module.rb: add test + +Wed Jun 26 16:13:25 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * io.c (io_getc): fix 7bit coderange condition, check if ascii read + data instead of read length. [ruby-core:55444] [Bug #8516] + +Wed Jun 26 16:10:01 2013 Eric Hodel <drbrain@segment7.net> + + * ext/socket/extconf.rb: Enable RFC 3542 IPV6 socket options for OS X + 10.7+. [ruby-trunk - Bug #8517] + +Wed Jun 5 12:38:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * win32/win32.c (setup_overlapped, finish_overlapped): extract from + rb_w32_read() and rb_w32_write(). + +Wed May 29 21:03:08 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * configure.in (POSTLINK): default to : command to get rid of flag + only command, since BSD make does not work with it. + +Wed May 29 20:59:38 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * lib/yaml.rb: documentation updates, patched by zzak. + [ruby-core:54735] [Backport #8356] + +Wed May 15 14:04:39 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * Makefile.in (miniruby): 1.9.3 doesn't have POSTLINK macro. + reported by Takahiro Kambe at [ruby-list:49362]. + +Wed May 15 01:06:26 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * include/ruby/intern.h: should include sys/time.h for struct timeval + if it exists. + +Wed May 15 00:23:07 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * configure.in (warnflags): disable -Werror by default unless + development. [ruby-core:52131] [Bug #7830] + +Wed May 15 00:21:31 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * signal.c: need to include unistd.h for write(2). + +Tue May 14 20:25:58 2013 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org> + + * ext/dl/lib/dl/func.rb (DL::Function#call): check tainted when + $SAFE > 0. + * ext/fiddle/function.c (function_call): check tainted when $SAFE > 0. + * test/fiddle/test_func.rb (module Fiddle): add test for above. + + +Tue May 14 11:36:22 2013 Shugo Maeda <shugo@ruby-lang.org> + + * lib/net/imap.rb (getacl_response): parse the mailbox of an ACL + response correctly. [ruby-core:54365] [Bug #8281] + +Tue May 14 11:24:22 2013 Martin Bosslet <Martin.Bosslet@gmail.com> + + * ext/openssl/ossl_ssl.c: Correct shutdown behavior w.r.t GC. + + * test/openssl/test_ssl.rb: Add tests to verify correct behavior. + + [Bug #8240] Patch provided by Shugo Maeda. Thanks! + +Tue May 14 11:22:33 2013 Naohisa Goto <ngotogenome@gmail.com> + + * configure.in (AC_CHECK_HEADERS): atomic.h for Solaris atomic_ops. + + * ruby_atomic.h: Skip using Solaris10 atomic_ops on Solaris 9 or + earlier if atomic.h is not available. [ruby-dev:47229] [Bug #8228] + +Tue May 14 10:42:23 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/mkmf.rb (MAIN_DOES_NOTHING): ensure symbols for tests to be + preserved. [ruby-core:53745] [Bug #8169] + +Tue May 14 10:42:23 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/mkmf.rb (MAIN_DOES_NOTHING): force to refer symbols for tests + to be preserved. [ruby-core:53745] [Bug #8169] + +Tue May 14 10:39:33 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * regexec.c (onig_search): fix problem with optimization of \z. + [Backport #8210] + patched by k_takata at [ruby-core:54251]. + +Tue May 14 09:36:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * time.c (GetTimeval): check if already initialized instance. + + * time.c (GetNewTimeval): check if newly created instance. + + * time.c (time_init_0, time_init_1, time_init_copy, time_mload): must + be newly created instance. [ruby-core:53436] [Bug #8099] + +Thu Apr 11 11:24:42 2013 Akinori MUSHA <knu@iDaemons.org> + + * lib/ipaddr.rb (IPAddr#in6_addr): Fix a typo with the closing + parenthesis. + +Thu Apr 11 11:24:42 2013 Akinori MUSHA <knu@iDaemons.org> + + * lib/ipaddr.rb (IPAddr#in6_addr): Fix the parser so that it can + recognize IPv6 addresses with only one edge 16-bit piece + compressed, like [::2:3:4:5:6:7:8] or [1:2:3:4:5:6:7::]. + [Bug #7477] + +Thu Apr 11 11:22:32 2013 Naohisa Goto <ngoto@gen-info.osaka-u.ac.jp> + + * string.c (rb_str_concat): set array element after definition + to fix compile error with Fujitsu C Compiler 5.6 on Solaris 10 + on Sparc. [Bug #5878] [ruby-dev:45123] + +Thu Apr 11 11:21:25 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (parser_magic_comment): should pass the proper value. + [ruby-dev:44984][Bug #5753] + +Thu Apr 11 11:18:57 2013 Tadayoshi Funaba <tadf@dotrb.org> + + * ext/date/date_core.c: [ruby-core:52303] + +Thu Apr 4 16:21:39 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * ext/objspace/objspace.c (count_nodes): fix key for unknown node. + based on a patch by tmm1 (Aman Gupta) in [ruby-core:53130] [Bug #8014] + +Thu Apr 4 16:17:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * Makefile.in (miniruby, ruby): move MAINLIBC because linker arguments + must appear after object files with newer versions of gcc. patch by + tmm1 (Aman Gupta) in [ruby-core:53121] [Bug #8009] + +Thu Apr 4 09:44:10 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * configure.in (DLDFLAGS): use TARGET_ENTRY to specify an entry point + instead of TARGET which may contain non-identifer characters. + + * lib/mkmf.rb (create_makefile): add TARGET_NAME which is the first + part consists of only word characters. [ruby-core:46248][Bug #6709] + +Tue Apr 2 13:13:19 2013 Martin Duerst <duerst@it.aoyama.ac.jp> + + * transcode.c (documentation for str_encode): Explain + that transcoding to the same encoding is a no-op + (i.e. no exceptions, no replacements,...). + [ruby-core:43557][Bug #6190] + +Tue Apr 2 13:13:19 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * transcode.c (str_encode_bang, encoded_dup): if nothing was + transcoded, just set encoding but leave coderange unchanged as + forcee_encoding. [ruby-core:43557][Bug #6190] + +Tue Apr 2 13:07:29 2013 Tanaka Akira <akr@fsij.org> + + * time.c (num_exact): use to_r method only if to_int method is + available. + [ruby-core:53764] [Bug #8173] reported by Hiro Asari. + +Tue Apr 2 13:01:55 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * configure.in (EXTDLDFLAGS): split options for each extension + libraries, and unused in ruby.pc. [Bug #6734] + + * lib/mkmf.rb (MakeMakefile#configuration): add EXTDLDFLAGS. + +Tue Apr 2 12:59:35 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * win32/win32.c (rb_w32_read): Windows 8 fixed one of a bug of console + API. + based on the patch by Heesob Park at [ruby-core:49479] [Bug #7379] + +Tue Apr 2 12:56:15 2013 Naohisa Goto <ngotogenome@gmail.com> + + * signal.c (ruby_abort): fix typo in r39354 [Bug #5014] + +Tue Apr 2 12:56:15 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * signal.c (check_stack_overflow): extract duplicated code and get rid + of declaration-after-statement. [Bug #5014] + +Tue Apr 2 12:56:15 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * signal.c (sigsegv): avoid to use async signal unsafe functions + when nested sigsegv is happen. + [Bug #5014] [ruby-dev:44082] + +Fri Mar 29 13:22:15 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * include/ruby/missing.h: fixed merge mistake of r39985. + [Backport #8080] + +Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * include/ruby/missing.h: removed __linux__. it's unnecessary. + +Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * thread.c: disabled _FORTIFY_SOURCE for avoid to hit glibc bug. + [Bug #8080] [ruby-core:53349] + * test/ruby/test_io.rb (TestIO#test_io_select_with_many_files): + test for the above. + +Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * include/ruby/missing.h (__syscall): moved to... + * io.c: here. because __syscall() is only used from io.c. + + * include/ruby/missing.h: move "#include <sys/type.h>" to .... + * include/ruby/intern.h: here. because it was introduced for + fixing NFDBITS issue. [ruby-core:05179]. + +Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * include/ruby/missing.h (struct timespec): include <sys/time.h> + +Thu Mar 28 19:01:54 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * configure.in: check struct timeval exist or not. + * include/ruby/missing.h (struct timeval): check HAVE_STRUCT_TIMEVAL + properly. and don't include sys/time.h if struct timeval exist. + + * file.c: include sys/time.h explicitly. + * random.c: ditto. + * thread_pthread.c: ditto. + * time.c: ditto. + * ext/date/date_strftime.c: ditto. + +Thu Mar 28 18:54:31 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * regcomp.c (optimize_node_left, set_optimize_info_from_tree): right + handling for look behind anchor. + + * regexec.c (onig_search): ditto. + [Backport #8076] + + this patch is derived from Onigmo base tree. + +Thu Mar 28 18:35:01 2013 Luis Lavena <luislavena@gmail.com> + + * win32/file.c (get_user_from_path): add internal function that retrieves + username from supplied path (refactored). + * win32/file.c (rb_file_expand_path_internal): refactor expansion of user + home to use get_user_from_path and cover dir_string corner cases. + [ruby-core:53168] [Bug #8034] + +Thu Mar 28 18:35:01 2013 Luis Lavena <luislavena@gmail.com> + + * win32/file.c (rb_file_expand_path_internal): Expand home directory when + used as second parameter (dir_string). [ruby-core:53168] [Bug #8034] + * test/ruby/test_file_exhaustive.rb: add test to verify. + +Thu Mar 28 18:18:49 2013 Martin Bosslet <Martin.Bosslet@googlemail.com> + + * ext/openssl/ossl_asn1.c: raise TypeError when trying to encode nil + values for Primitive instances. + * test/openssl/test_asn1.rb: Assert consistent behavior when + encoding nil values: Primitives raise TypeError, Constructives + raise NoMethodError. + Fixes [ruby-core:43009][Bug #6102] + +Thu Mar 28 18:14:41 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * tool/mkconfig.rb: reconstruct comma separated list values. a + command line to Windows batch file is split not only by spaces + and equal signs but also by commas and semicolons. + +Thu Mar 28 18:13:38 2013 NARUSE, Yui <naruse@ruby-lang.org> + + * string.c (str_byte_substr): don't set coderange if it's not known. + [Bug #7954] [ruby-dev:47108] + +Thu Mar 28 18:12:19 2013 Kouhei Sutou <kou@cozmixng.org> + + * lib/rexml/document.rb: move entity_expansion_text_limit accessor to ... + * lib/rexml/rexml.rb: ... here to make rexml/text independent from + REXML::Document. It causes circular require. + * lib/rexml/document.rb (REXML::Document.entity_expansion_text_limit): + deprecated. + * lib/rexml/document.rb (REXML::Document.entity_expansion_text_limit=): + deprecated. + * lib/rexml/text.rb: add missing require "rexml/rexml" for + REXML.entity_expansion_text_limit. + Reported by Robert Ulejczyk. Thanks!!! [ruby-core:52895] [Bug #7961] + +Thu Mar 21 20:34:52 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/win32ole/test_err_in_callback.rb (TestErrInCallBack#setup): + allow using different root for source and build directories. + this may fixes a minor problem of r39834. + +Thu Mar 21 20:34:52 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/win32ole/test_err_in_callback.rb (TestErrInCallBack#setup): use + relative path to get rid of "too long commandline" error. + +Thu Mar 21 20:34:52 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/win32ole/test_err_in_callback.rb + (TestErrInCallBack#test_err_in_callback): shouldn't create a file in + the top of build directory. + +Tue Feb 26 09:53:59 2013 NARUSE, Yui <naruse@ruby-lang.org> + + * st.c (st_add_direct): int is not always same with st_index_t. some + version of clang reports error. + + * thread.c (vm_living_thread_num): ditto. + reported by d6rkaiz (Isao Sugimoto) at [ruby-dev:47096] + [Backport #7946] + +Fri Feb 22 18:36:51 2013 Aaron Patterson <aaron@tenderlovemaking.com> + + * lib/rexml/document.rb (REXML::Document.entity_expansion_text_limit): + new attribute to read/write entity expansion text limit. the default + limit is 10Kb. + + * lib/rexml/text.rb (REXML::Text.unnormalize): check above attribute. + +Fri Feb 22 14:48:15 2013 NARUSE, Yui <naruse@ruby-lang.org> + + * vm.c (vm_exec): get rid of a SEGV when calling rb_iter_break() from + some extention libraries. [Backport #7896] [ruby-core:52607] + +Fri Feb 22 14:40:57 2013 Narihiro Nakamura <authornari@gmail.com> + + * gc.c : remove a unused function. + +Fri Feb 22 14:40:57 2013 NARUSE, Yui <naruse@ruby-lang.org> + + * regparse.c (onig_number_of_names): suppress a warning. + +Fri Feb 22 14:40:57 2013 NARUSE, Yui <naruse@ruby-lang.org> + + * vm_insnhelper.c (vm_call_cfunc): remove useless hack. + +Fri Feb 22 14:40:57 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * vm_insnhelper.c (vm_call_cfunc): suppress a warning. note that + `volatile type *var' doesn't make var itself volatile. + +Fri Feb 22 14:28:17 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * eval_jump.c (rb_exec_end_proc): remember the latest exit status. + [ruby-core:43173][Bug #5218] + +Fri Feb 22 14:25:57 2013 NARUSE, Yui <naruse@ruby-lang.org> + + * ext/readline/readline.c (Init_readline): don't set 0 to + rl_catch_signals and rl_catch_sigwinch. [Bug #5423] + +Wed Feb 13 16:18:22 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * ext/json: Import JSON 1.5.5. + +Wed Feb 6 17:39:19 2013 Eric Hodel <drbrain@segment7.net> + + * lib/rdoc: Import RDoc 3.9.5. + +Wed Feb 6 14:27:25 2013 Shugo Maeda <shugo@ruby-lang.org> + + * ext/socket/raddrinfo.c (rsock_unix_sockaddr_len): return + sizeof(sa_familiy_t) if path is empty. see "Autobind Feature" in + unix(7) for details. + + * ext/socket/lib/socket.rb (unix_socket_abstract_name?): treat an + empty path as an abstract name. + + * test/socket/test_unix.rb: related test. + + * ext/socket/unixsocket.c (rsock_init_unixsock): use rb_inspect() + because rb_sys_fail_str() fails if its argument contains NUL. + + * test/socket/test_unix.rb: related test. + + * ext/socket/socket.c (sock_s_pack_sockaddr_un): calculate the + correct address length of an abstract socket. + + * test/socket/test_unix.rb: related test. + + * ext/socket/raddrinfo (rsock_unix_sockaddr_len): renamed from + rsock_unixpath_len, because it returns not the length of the path, + but the length of a socket address for the path. + + * ext/socket/raddrinfo.c (rsock_unixpath_len, init_unix_addrinfo), + ext/socket/unixsocket.c (unixsock_connect_internal, + rsock_init_unixsock): calculate the correct address length of + an abstract socket. Without this fix, sizeof(struct sockaddr_un) + is specified as the length of an abstract socket for bind(2) or + connect(2), so the address of the socket is filled with extra NUL + characters. See unix(7) for details. + + * ext/socket/lib/socket.rb (unix_server_socket): don't access the + file system if the platform is Linux and path starts with NUL, + which means that the socket is an abstract socket. + + * test/socket/test_unix.rb: related test. + + * ext/socket/socket.c (sock_s_pack_sockaddr_un): support the longest + path in sockaddr_un, really. + reported by nagachika. + http://d.hatena.ne.jp/nagachika/20120426/ruby_trunk_changes_35474_35476 + + * ext/socket/raddrinfo.c (init_unix_addrinfo): support the longest + path in sockaddr_un. + (inspect_sockaddr): ditto. + (addrinfo_mdump): ditto. + (addrinfo_mload): ditto. + (rsock_unixpath_str): new function. + (rsock_unixpath): removed. + (rsock_unixaddr): use rsock_unixpath_str. + + * ext/socket/socket.c (sock_s_pack_sockaddr_un): support the longest + path in sockaddr_un. + (sock_s_unpack_sockaddr_un): ditto. + (sock_s_gethostbyaddr): unused variable removed. + + * ext/socket/unixsocket.c (rsock_init_unixsock): support the longest + path in sockaddr_un. + + * ext/socket/rubysocket.h (rsock_unixpath_str): declared. + (rsock_unixpath): removed. + + * test/socket/test_unix.rb: comment out test_nul because abstract unix + sockets may contain NULs. + +Wed Feb 6 14:20:12 2013 Tanaka Akira <akr@fsij.org> + + * ext/socket/basicsocket.c (bsock_getsockname): ignore truncated + part of socket address. + (bsock_getpeername): ditto. + (bsock_local_address): ditto. + (bsock_remote_address): ditto. + + * ext/socket/unixsocket.c (unix_path): ditto. + (unix_addr): ditto. + (unix_peeraddr): ditto. + + * ext/socket/init.c (cloexec_accept): ditto. + +Wed Feb 6 14:19:07 2013 Kouhei Sutou <kou@cozmixng.org> + + * lib/rexml/parsers/baseparser.rb, test/rexml/test_comment.rb: + allow a single hyphen in comment. [Bug #5278] [ruby-core:39289] + Reported by Thomas Fritzsche. Thanks!!! + +Wed Feb 6 14:14:38 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (realpath_rec): prevent link from GC while link_names refers + the content. + +Wed Feb 6 14:13:25 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * missing/setproctitle.c (environ): use (*_NSGetEnviron()) instead of + environ on Darwin for namespace cleanness, same as [ruby-core:00537]. + [ruby-core:45615] [Bug #6576] + +Wed Feb 6 14:05:09 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * dir.c (glob_make_pattern): names under recursive need to be single + basenames to match for each name. [ruby-core:47418] [Bug #6977] + +Tue Jan 15 16:30:29 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * thread_pthread.c (gvl_init): Reset gvl.wait_yield explicitly when + fork()ing. Patch by Apollon Oikonomopoulos. Thanks! + [Bug #7693][ruby-core:51424] + +Tue Jan 15 16:25:35 2013 Narihiro Nakamura <authornari@gmail.com> + + * gc.c (rb_objspace_call_finalizer): finalize_deferred may free up + a object which is reachable from a part after this function, + e.g. ruby_vm_destruct(). [ruby-dev:46647] [Bug #7452] + + * test/ruby/test_gc.rb (test_finalizing_main_thread): add a test + for above. + +Tue Jan 15 16:23:30 2013 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/net/protocol.rb (Net::InternetMessageIO#each_crlf_line): + treat \r as newline as mame pointed. [ruby-dev:46425] [Bug #7278] + +Tue Jan 15 16:23:30 2013 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/net/protocol.rb (Net::InternetMessageIO#each_crlf_line): + don't use /n in universal regexp. [ruby-dev:46394] [Bug #7278] + +Tue Jan 15 16:13:47 2013 Kenta Murata <mrkn@mrkn.jp> + + * ext/bigdecimal/bigdecimal.c (BigDecimal_to_s): use CRuby style. + +Tue Jan 15 16:13:47 2013 Kenta Murata <mrkn@mrkn.jp> + + * ext/bigdecimal/bigdecimal.c: use `RB_TYPE_P(x, t)` instead of + `TYPE(x) == t`. + +Tue Jan 15 16:13:47 2013 Kenta Murata <mrkn@mrkn.jp> + + * ext/bigdecimal/bigdecimal.c (BigDecimal_sub): + need to specify precision for converting Rational and Float. + [ruby-dev:46544] [Bug #7404] + + * ext/bigdecimal/bigdecimal.c (BigDecimal_mult): ditto. + + * ext/bigdecimal/bigdecimal.c (BigDecimal_divide): ditto. + + * ext/bigdecimal/bigdecimal.c (BigDecimal_DoDivmod): ditto. + + * ext/bigdecimal/bigdecimal.c (BigDecimal_divremain): ditto. + + * test/bigdecimal/test_bigdecimal.rb: add tests for the above fixes. + +Tue Jan 15 16:03:30 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * tool/mkconfig.rb: use configured libdir value to fix + --enable-load-relative on systems where libdir is not default value, + overridden in config.site files. [ruby-core:47267] [Bug #6903] + +Tue Jan 15 15:55:09 2013 Eric Hodel <drbrain@segment7.net> + + * object.c (Init_Object): Added RDoc location pointers for + Kernel#methods, Kernel#protected_methods, Kernel#private_methods and + Kernel#public_methods. [Bug #6666] + +Fri Jan 11 17:12:44 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * vm_core.h (rb_iseq_t): move flip_cnt from struct iseq_compile_data, + because it has same life span as enclosing iseq. [Bug #7671] + [ruby-core:51296] + +Fri Jan 11 17:11:26 2013 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/mkmf.rb: add dummy clean-static target to prevent errors for the + case real clean-static target doesn't exist. + +Fri Jan 11 17:02:59 2013 Koichi Sasada <ko1@atdot.net> + + * vm_exec.h (GENTRY): GENTRY should be pointer size. + A patch by yoshidam (Yoshida Masato) [Bug #7332]. + +Fri Jan 11 16:57:31 2013 NAKAMURA Usaku <usa@ruby-lang.org> + + * vm_trace.c (rb_threadptr_exec_event_hooks): added a parameter to pop + a frame before JUMP_TAG() if exception occurred. This change fix bug + of Ruby 1.9. [ruby-core:51128] [ruby-trunk - Bug #7624] + + * vm_core.h (EXEC_EVENT_HOOK_AND_POP_FRAME): add to use + `rb_threadptr_exec_event_hooks()' with the pop flag. + + * vm.c (vm_exec): use EXEC_EVENT_HOOK_AND_POP_FRAME() while exception + handling. While exception hadnling, if an exception is raised in + hooks, need to pop current frame and raise this raised exception by + hook. + + * bootstraptest/test_flow.rb: add a test. + +Mon Jan 7 15:50:25 2013 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * vm.c (rb_vm_make_proc): save the proc made from the given block so + that it will not get collected. [ruby-core:50545] [Bug #7507] + +Tue Dec 25 23:35:09 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/mkmf.rb: fix for if config["libdir"] is nil. + +Tue Dec 25 20:40:47 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * bignum.c, include/ruby/intern.h (rb_big_eql): exported. + + * thread.c (recursive_check): object_id maybe a Bignum, not Fixnum on + LLP64. see also r38493 and r38548. + reported by Heesob Park at [ruby-core:51083] [Bug #7607], and patched + by shirosaki at [ruby-core:51095] + +Tue Dec 25 09:54:31 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com> + + * gc.c (obj_id_to_ref): add a macro to treat Bignum object id. + This follows the change r38493. + + * gc.c (id2ref): fix for working fine with Bignum object id on x64 + Windows. + * gc.c (wmap_finalize): ditto. + +Sat Dec 22 00:33:28 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * object.c (rb_obj_hash): shouldn't assume object_id can be long. + based on a patch by Heesob Park at [ruby-core:51060]. + cf. [Backport #7454] + +Sat Dec 22 00:33:28 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * gc.c (nonspecial_obj_id): VALUE is not compatible with Fixnum on + LLP64 platform, such as 64bit Windows. + reporeted by Heesob Park at [ruby-core:50255] [Bug #7454], and the + fix is suggested by akr. + +Fri Dec 21 16:03:54 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/ruby/test_argf.rb (TestArgf#test_chars): since marshal data is + binary, shouldn't pass via text mode. use base64 encoded data. + +Thu Dec 13 23:10:52 Charlie Somerville <charlie@charliesomerville.com> + * object.c (Init_Object): use rb_mod_init_copy for Class#initialize_copy + * class.c (rb_class_init_copy): rename to class_init_copy_check, performs type + checks on arguments to prevent reinitialization of initialized class + [ruby-core:50869] [Bug #7557] + * class.c (rb_mod_init_copy): use class_init_copy_check if receiver is T_CLASS + * test/ruby/test_class.rb (class TestClass): related test + + +Thu Dec 20 18:46:17 2012 Naohisa Goto <ngotogenome@gmail.com> + + * test/dl/test_func.rb (test_name_with_block, test_bind, test_qsort1): + call unbind to release the callback closure because maximum number + of callbacks is limited to DL::MAX_CALLBACK (== 5) with pure DL + without Fiddle. + +Thu Dec 20 18:46:17 2012 Naohisa Goto <ngotogenome@gmail.com> + + * ext/dl/lib/dl/func.rb (DL::Function#unbind, #bound?): suppress + NoMethodError when Fiddle is available. [ruby-core:50756] [Bug #7543] + * test/dl/test_func.rb (test_bound*, test_unbind*): tests for the above. + +Thu Dec 20 18:46:17 2012 Naohisa Goto <ngotogenome@gmail.com> + + * ext/dl/lib/dl/func.rb (DL::Function#initialize, DL::Function#bind): + ABI should be set by using CFunc#calltype even when Fiddle is used. + When Fiddle is used and a block is given, name shoud not be ignored. + [ruby-core:50562] [Bug #7514] + + * ext/dl/lib/dl/import.rb (DL::Importer#bind_function): should respect + abi and name when Fiddle is used. + + * test/dl/test_func.rb (test_name_with_block): test for "name" method + with giving a block. + +Thu Dec 20 18:43:00 2012 Naohisa Goto <ngotogenome@gmail.com> + + * ext/fiddle/extconf.rb, ext/fiddle/function.c + (Fiddle::Function::STDCALL): FFI_STDCALL is not a macro, but an + enumeration. [ruby-core:50398] [Bug #7483] + +Thu Dec 20 18:40:25 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * thread.c (exec_event_hooks): exceptions in event hooks should not + propagate outside. + +Thu Dec 20 18:37:45 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * test/ruby/test_m17n_comb.rb (test_str_crypt): Use RbConfig to get + libc's directory. Patched by Vit Ondruch [ruby-core:49763] [Bug #7312] + +Thu Dec 20 18:37:45 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * string.c (rb_str_crypt): crypt(3) may return NULL. + Latest glibc (2.16?) crypt(3) actually returns NULL. [Bug #7312] + +Thu Dec 20 18:36:19 2012 Naohisa Goto <ngotogenome@gmail.com> + + * ext/dl/lib/dl/func.rb (DL::Function#bind): When Fiddle is used, + @ptr should be updated. This fixes SEGV raised in DL::Function#call + after calling DL::Function#bind. [Bug #7516] [ruby-dev:46708] + + * test/dl/test_func.rb (test_bind): test for the above + +Thu Dec 20 18:35:36 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * gc.h (SET_MACHINE_STACK_END): add volatile for preventing + harmful optimization. [ruby-dev:46665] [Bug #7468] + +Thu Dec 20 18:34:38 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com> + + * compile.c (ADD_CATCH_ENTRY): add a cast to fix SEGV with x64 mingw + on Windows 8. Without cast, 0 might be non zero value at higher bits + in rb_ary_new3(). + [ruby-core:50258] [Bug #7456] + +Wed Dec 19 21:24:40 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * io.c (argf_each_codepoint): add missing ARGF#codepoints [Bug #7438] + +Wed Dec 19 21:20:23 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (file_expand_path): use wcscasecmp(). + +Wed Dec 19 21:15:29 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (parser_yylex): fix false usage of local variable, it cannot + appear in fname state [ruby-core:49659] [Bug #7408] + +Wed Dec 19 21:14:28 2012 Narihiro Nakamura <authornari@gmail.com> + + * gc.c: return true or false. Patch by Dirkjan Bussink. [Bug #6821] + + * test/ruby/test_gc.rb: add test-case for this bug. + +Wed Dec 19 21:12:49 2012 Shugo Maeda <shugo@ruby-lang.org> + + * marshal.c (r_entry0): don't taint classes and modules because + Marshal.load just returns the dumped classes and modules. + [Bug #7325] [ruby-core:49198] + + * test/ruby/test_marshal.rb: related test. + +Tue Dec 11 19:19:33 2012 Luis Lavena <luislavena@gmail.com> + + * win32/file.c (replace_to_long_name): correct logic around wildcard + characters detection and ensure wide-chars are used as pattern. + [ruby-core:49451] [Bug #7374] + +Sat Nov 17 21:45:12 Luis Lavena <luislavena@gmail.com> + + * win32/file.c (replace_to_long_name): skip expansion for all wildcard + characters. + [ruby-core:49451] [Bug #7374] + + * test/ruby/test_file_exhaustive.rb: add more assertions to test. + +Tue Dec 11 19:19:33 2012 Luis Lavena <luislavena@gmail.com> + + * win32/file.c (replace_to_long_name): skip automatic path expansion + when wildcard character is used. [ruby-core:49451] [Bug #7374] + + * test/ruby/test_file_exhaustive.rb: add a test for above. + +Tue Dec 11 19:18:12 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * win32/mkexports.rb (each_export): skip garbages generated by VS2012's + nmake. + reported and patched by Yoshida Masato at [Bug #7333] [ruby-dev:46484] + +Tue Dec 11 19:15:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (parser_here_document): flush string content between new + line and :string_embexpr. [ruby-core:48703] [Bug #7255] + +Tue Dec 11 17:53:55 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * compile.c (iseq_compile_each): count flip-flop state in local iseq + not in each iseqs, so that the keys can be other than hidden + strings. [ruby-core:47253] [Bug #6899] + + * vm_insnhelper.c (lep_svar_get, lep_svar_set, vm_getspecial): store + flip-flop states in an array instead of a hash. + + * iseq.c (set_relation): main iseq also can has local scope. + +Tue Dec 11 17:52:30 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * include/ruby/backward/rubysig.h: fix visibility. [Bug #6607] + +Tue Dec 11 17:49:45 2012 Koichi Sasada <ko1@atdot.net> + + * vm.c (rb_vm_make_env_object): make Proc object if Env is possible + to point block. [ruby-core:41038] [ruby-trunk - Bug #5634] + + * vm.c (rb_vm_make_proc): No need to make Proc object here. + + * bootstraptest/test_proc.rb: add tests. + +Tue Dec 11 17:47:01 2012 Narihiro Nakamura <authornari@gmail.com> + + * lib/irb/magic-file.rb: set a encoding, which is detected from + the file to read, to the internal encoding. + [Bug #4281][ruby-dev:43036] + +Thu Nov 15 15:17:11 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * gc.c (free_method_entry_i): method entry may be in + unlinked_method_entry_list. [ruby-core:43383][Bug #6171] + +Wed Nov 14 20:20:46 2012 Naohisa Goto <ngotogenome@gmail.com> + + * ruby_atomic.h: renamed from atomic.h to avoid header file name + conflict on Solaris 10. [ruby-dev:46414] [Bug #7287] + + * gc.c, signal.c, vm_core.h, common.mk: reflect the rename from + atomic.h to ruby_atomic.h. + +Tue Nov 13 18:13:10 2012 Narihiro Nakamura <authornari@gmail.com> + + * gc.c: Use the non-recursive marking instead of recursion. The + recursion marking of CRuby needs checking stack overflow and the + fail-safe system, but these systems not good at partial points, + for example, marking deep tree structures. [ruby-dev:46184] + [Feature #7095] + + * configure.in (GC_MARK_STACKFRAME_WORD): removed. It's used by + checking stack overflow of marking. + + * win32/Makefile.sub (GC_MARK_STACKFRAME_WORD): ditto. + + * gc.c (free_stack_chunks): it is used only when per-VM object space + is enabled. + + * gc.c (rb_objspace_call_finalizer): mark self-referencing finalizers + before run finalizers, to fix SEGV from btest on 32bit. + + * gc.c (gc_mark_stacked_objects): extract from gc_marks(). + + * gc.c (rb_objspace_call_finalizer): call gc_mark_stacked_objects + at suitable point. + + * gc.c (init_heap): call init_mark_stack before to allocate + altstack. This change avoid the stack overflow at the signal + handler on 32bit, but I don't understand reason... [Feature #7095] + +Sat Nov 10 01:25:52 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (append_fspath): no need to do encoding trick here. + +Sat Nov 10 00:37:02 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * siphash.h: check configure macros before include newer headers. + +Sat Nov 10 00:37:02 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * siphash.c (sip_init_state): use union to suppress warnings by gcc + 4.7. + +Sat Nov 10 00:37:02 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * random.c (rb_memhash): use siphash. + +Fri Nov 9 16:17:09 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (append_fspath): revert a part of r37562. + + * file.c (rb_file_expand_path_internal): ditto. + + * file.c (rb_file_expand_path_internal): ignore the encoding of the + given path name and use filesystem encoding, except when the result + is 8bit range and the filesystem encoding is US-ASCII. + [ruby-dev:39393] [Bug #2154] + +Fri Nov 9 16:15:50 2012 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org> + + * test/csv/test_features.rb: add require for Tempfile. + * test/csv/test_serialization.rb: ditto. + +Fri Nov 9 13:47:45 2012 Luis Lavena <luislavena@gmail.com> + + * test/win32ole/test_win32ole.rb (test_s_codepage_changed): + FileSystemObject only supports ANSI or UTF-16LE encoding. + Patch by bosko (Bosko Ivanisevic) [ruby-trunk - Bug #6650] + +Fri Nov 9 13:16:16 2012 Kenta Murata <mrkn@mrkn.jp> + + * bignum.c (bigmul0): enable big_mul_toom3. + [ruby-core:48552] [Bug #7242] + + * bignum.c (bigmul1_toom3): fix incorrect calculation. + the patch is made by Heesob Park. + [ruby-core:48552] [Bug #7242] + +Fri Nov 9 13:16:16 2012 Kenta Murata <mrkn@mrkn.jp> + + * bignum.c (bigmul0): disable big_mul_toom3 temporalily. + [ruby-core:48552] [Bug #7242] + + * test/ruby/test_bignum.rb (test_mul_large_numbers): + add a test for bigmul1_toom3 suggested in [Bug #7242]. + +Thu Nov 8 17:37:54 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (append_fspath): filesystem encoding is prior to the encoding + of argument. + + * file.c (rb_file_expand_path_internal, EXPAND_PATH_BUFFER): ignore + the encoding of the given path name, use filesystem encoding always + instead. [ruby-dev:39393] [Bug #2154] + + * test/ruby/test_file_exhaustive.rb: removed 2.0 spec tests. + +Thu Nov 8 17:33:53 2012 Luis Lavena <luislavena@gmail.com> + + * ext/zlib/extconf.rb: Recognize zlibwapi as linking library. + Patch by Daniel Berger. + + [ruby-core:44979] [Feature #6421] + +Thu Nov 8 16:17:54 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/ruby/test_dir_m17n.rb: remove a garbage. + +Thu Nov 8 15:22:09 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/ruby/test_dir_m17n.rb: sorry, typo. + +Thu Nov 8 14:50:02 2012 Masaki Suketa <masaki.suketa@nifty.ne.jp> + + * test/win32ole/test_win32ole_variant.rb: setting WIN32OLE.locale + to pass some assertion. Thanks to Hiroshi Shirosaki. + [ruby-core:46873][Bug #6814] + +Thu Nov 8 14:46:17 2012 Masaki Suketa <masaki.suketa@nifty.ne.jp> + + * test/win32ole/test_win32ole.rb (test_s_codepage_changed): + FileSystemObject only supports ANSI or UTF-16LE encoding. + Patch by h.shirosaki (Hiroshi Shirosaki) [ruby-trunk - Bug #6650] + + +Thu Nov 8 14:43:17 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/ruby/test_dir_m17n.rb: refactoring. RE should be in the left side + of the =~ operator, and compare the result with nil is meaningless. + +Thu Nov 8 14:43:17 2012 Luis Lavena <luislavena@gmail.com> + + * test/ruby/test_dir_m17n.rb (create_and_check_raw_file_name): add new + helper method to ease encoding testing. Patch by Oleg Sukhodolsky. + [ruby-core:46589][Bug #6765] + + * test/ruby/test_dir_m17n.rb (test_filename_extutf8): use filesystem + encoding when reading entries and comparing. + + * test/ruby/test_dir_m17n.rb (test_filename_utf8_raw_name): removed. + + * test/ruby/test_dir_m17n.rb (test_filename_utf8_raw_jp_name): split test. + +Thu Nov 8 14:16:53 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/mkmf.rb (MakeMakefile#timestamp_file): use .-. instead of !, a + special character of NMAKE and BSD make. [Bug #7265] + +Thu Nov 8 14:16:53 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/mkmf.rb (MakeMakefile#timestamp_file): use ! instead of %, a GNU + make special character. + +Thu Nov 8 14:16:53 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/mkmf.rb (create_makefile): use timestamp for destination + directories to make them before making or copying files there. + [ruby-dev:46067] [Bug #6904] + +Thu Nov 8 14:13:53 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * configure.in (visibility_option): visibility attribute is not + available before GCC 4, so do not use -fvisibility option in that + case. [ruby-core:48147] [Bug #7205] + +Thu Nov 8 14:11:49 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * vm.c (rb_vm_jump_tag_but_local_jump): pass through thrown objects. + [ruby-dev:46234] [Bug #7185] + + * vm_eval.c (rb_eval_cmd): if state is non-zero, val should be nil and + rb_vm_jump_tag_but_local_jump() just jump tag. + +Thu Nov 8 14:09:18 2012 Kenta Murata <mrkn@mrkn.jp> + + * ext/bigdecimal/bigdecimal.c (BigDecimal_add), + test/bigdecimal/test_bigdecimal.rb: + need to specify precision for converting Rational and Float. + [ruby-core:48045] [Bug #7176] + +Thu Nov 8 14:05:31 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * win32/win32.c (has_redirection): should use shell (cmd.exe) when + the commandline containts '&'. + reported by Roger Pack at [ruby-core:47912] [Bug #7143], and + patched by Heesob Park at [ruby-core:47931]. + +Fri Oct 26 17:22:18 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * file.c (append_fspath): need to set the encoding to result always. + +Fri Oct 26 11:03:46 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (rb_enc_path_next, rb_enc_path_skip_prefix) + (rb_enc_path_last_separator, rb_enc_path_end) + (ruby_enc_find_basename, ruby_enc_find_extname): encoding-aware + path handling functions. + + * file.c (rb_home_dir, file_expand_path, rb_realpath_internal) + (rb_file_s_basename, rb_file_dirname, rb_file_s_extname) + (rb_file_join): should respect the encodings of arguments than + file system encoding. [ruby-dev:45145] [Bug #5919] + + * dir.c (check_dirname, ruby_glob0): ditto. + + * ext/pathname/pathname.c (path_sub_ext): ditto. + +Fri Oct 26 11:03:46 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * util.c, include/ruby/util.h (ruby_add_suffix): remove the function. + [Bug #5153] [ruby-core:38736] + + * io.c (argf_next_argv): remove the call of above function. + + * ext/-test-/add_suffix, test/-ext-/test_add_suffix.rb: remove the test + extension module because this is only for testsing ruby_add_suffix(). + + * LEGAL: remove the mention about a part of util.c, because now we + removed the part. + + * io.c (argf_next_argv): now the new filename is not guranteed to + use, so should check the return value of rename(2). + + * test/ruby/test_argf.rb (TestArgf#test_inplace_rename_impossible): + now we expect same result with other platforms on no_safe_rename + platforms (=Windows). + +Thu Oct 25 18:16:25 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/rubygems/installer.rb (check_that_user_bin_dir_is_in_path): + test_generate_bin_bindir_with_user_install_warning(TestGemInstaller) + fails on Windows with msys bash. It makes comparing paths + case-insensitive. + pick from upstream to fix a failure of test-all [ruby-core:47711] + https://github.com/rubygems/rubygems/commit/c474edb2f3704206f04da1c8c6cf9fb079d84abe + +Thu Oct 25 17:55:01 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/etc/test_etc.rb (TestEtc#test_getpwuid): `s' is never set to nil. + +Thu Oct 25 16:59:17 2012 Luis Lavena <luislavena@gmail.com> + + * test/ruby/test_file_exhaustive.rb: fix test introduced in r36811 for + posix environments where HOME is not defined. [ruby-core:47322] + +Thu Oct 25 16:59:17 2012 Luis Lavena <luislavena@gmail.com> + + * configure.in (mingw): add shlwapi to the list of dependency + libs for Windows. + * win32/Makefile.sub (EXTSOLIBS): ditto. + + * internal.h: declare internal functions rb_w32_init_file, + rb_file_expand_path_internal and rb_file_expand_path_fast. + + * file.c (Init_File): invoke Windows initialization rb_w32_init_file + + * win32/file.c (rb_file_load_path_internal): new function. + Windows-specific implementation that replaces file_expand_path. + [Bug #6836][ruby-core:46996] + + * win32/file.c (rb_w32_init_file): new function. Initialize codepage + cache for faster conversion encodings lookup. + + * file.c (file_expand_path): rename to rb_file_expand_path_internal. + Conditionally exclude from Windows. + + * file.c (rb_file_expand_path_fast): new function. delegates to + rb_file_expand_path_internal without performing a hit to the + filesystem. + + * file.c (file_expand_path_1): use rb_file_expand_path_internal without + path expansion (used by require). + * file.c (rb_find_file_ext_safe): ditto. + * file.c (rb_find_file_safe): ditto. + + * load.c (rb_get_expanded_load_path): use rb_file_expand_path_fast. + * load.c (rb_feature_provided): ditto. + + * file.c (rb_file_expand_path): use rb_file_expand_path_internal with + path expansion. + * file.c (rb_file_absolute_path): ditto. + + * test/ruby/test_file_exhaustive.rb: new tests to exercise + rb_file_expand_path_internal implementation and compliance with + existing behaviors. + +Thu Oct 25 16:59:17 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * win32/file.c (INVALID_FILE_ATTRIBUTES): define for old SDK. + +Thu Oct 25 16:59:17 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * win32/makedirs.bat: new command to make intermediate + directories, and not to report any errors if the directory + already exists. + + * win32/Makefile.sub (MAKEDIRS): enable command extensions. + +Thu Oct 25 16:59:17 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * win32/Makefile.sub (MAKEDIRS): use mkdir of cmd.exe instead of ruby. + [Bug #6103] [ruby-core:43012] + + * win32/README.win32: added a notice about command extension of cmd.exe. + +Thu Oct 25 16:59:17 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com> + + * Makefile.in (PLATFORM_DIR): add a variable for `win32` directory. + * Makefile.in (clean-platform): add new target. + It cleans `win32` directory. + + * common.mk (clean): add a dependency for `win32` directory. + * common.mk (distclean): ditto. + * common.mk (distclean-platform): add new target. + It cleans `win32` directory. + * common.mk ($(PLATFORM_D)): add new target to make `win32` directory. + * common.mk (win32/win32.$(OBJEXT)): move win32.o into `win32` + directory. + * common.mk (win32/file.$(OBJEXT)): add new target for win32/file.c. + + * configure.in: move win32.o into `win32` directory and add + win32/file.o to MISSING. + + * file.c (file_load_ok, rb_file_load_ok): replace static + file_load_ok() with public rb_file_load_ok(). + It's to link Windows implementation in win32/file.c. + * file.c (rb_find_file_ext_safe): ditto. + * file.c (rb_find_file_safe): ditto. + + * win32/file.c (rb_file_load_ok): new file. Add Windows specific + optimized implementation of rb_file_load_ok(). We created a + separated file to avoid too many #ifdef macro which is unreadable. + + * win32/Makefile.sub (PLATFORM_DIR): add a variable for `win32` + directory. + * win32/Makefile.sub (MISSING): move win32.obj into `win32` + directory and add win32/file.obj to MISSING. + * win32/Makefile.sub (MAKEDIRS): replace MINIRUBY with BASERUBY. + It's because miniruby doesn't exist when making `win32` directory. + * win32/Makefile.sub (clean-platform): add new target to clean `win32` + directory. + * win32/Makefile.sub ({$(srcdir)}.c{}.obj): make it not match + win32/file.c to build properly. + * win32/Makefile.sub (win32/win32.$(OBJEXT)): move win32.obj into + `win32` directory. + + Patch created with Luis Lavena. + [ruby-core:42480] [Feature #5999] + +Fri Oct 19 13:28:29 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * configure.in (opt-dir): allow multiple directories separated by + $PATH_SEPARATOR as well as dir_config in mkmf.rb. [ruby-core:47868] + [Bug #7120] + +Tue Oct 16 11:18:06 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/mkmf.rb (dir_config, init_mkmf): use configured libdir value as + default library path. [ruby-core:43726] [Bug #6207] + +Tue Oct 16 10:56:55 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (rb_find_file_ext_safe, rb_find_file_safe): default to + US-ASCII for encdb and transdb. + + * load.c (search_required): keep encoding of feature name. set + loading path to filesystem encoding. [Bug #6377][ruby-core:44750] + + * ruby.c (add_modules, require_libraries): assume default external + encoding as well as ARGV. + +Tue Oct 16 10:47:43 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * random.c (random_s_rand): ensure default PRNG is re-initialized + after fork. patched by Eric Wong. [ruby-core:41209][Bug #5661] + +Tue Oct 16 10:21:23 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * ruby.c (rb_f_sub, rb_f_gsub): pass the given block. + [ruby-core:47967] [Bug #7157] + +Tue Oct 16 09:47:47 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/ruby/test_regexp.rb + (TextRegexp#test_raw_hyphen_and_tk_char_type_after_range): use + Regexp.new instead of literal to ignore a parser warning. + +Tue Oct 16 09:47:47 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/ruby/test_regexp.rb + (TextRegexp#test_raw_hyphen_and_tk_char_type_after_range): ignoring + warnings are already set in setup method. + +Sun Oct 14 01:21:42 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * regparse.c (parse_char_class): should match with a hyphen after a + range in a character class. + + * test/ruby/test_regexp.rb (TestRegexp#test_char_class): fixed wrong + test. + + * test/ruby/test_regexp.rb (TestRegexp#check): now can accept the + error message. + + * test/ruby/test_regexp.rb + (TextRegexp#test_raw_hyphen_and_tk_char_type_after_range): renamed + because the previous name was wrong. + + * test/ruby/test_regexp.rb + (TextRegexp#test_raw_hyphen_and_tk_char_type_after_range): added + more test pattern. + +Sat Oct 13 01:41:38 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * regparse.c (parse_char_class): also need to check the type of token + after raw hyphen in regexp class, because the charcter code area + is union'ed with the property of TK_CHAR_TYPE. + reported by Bushi Zhang at [ruby-core:47115] [Backport #6853]. + +Sat Oct 13 01:39:46 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/ruby/test_regexp.rb + (TestRegexp#test_raw_hyphen_and_type_char_after_range): added new + test. ref [ruby-core:47115] [Backport #6853] + +Fri Oct 12 18:19:35 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (rb_get_path_check): path name must not contain NUL bytes. + +Fri Oct 12 17:51:43 2012 Shugo Maeda <shugo@ruby-lang.org> + + * error.c (exc_to_s, name_err_to_s, name_err_mesg_to_str): do not + taint messages. + +Fri Oct 12 16:11:23 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * configure.in (LIBDIR_BASENAME): use configured libdir value to fix + --enable-load-relative on systems where libdir is not default value, + overridden in config.site files. [ruby-core:47267] [Bug #6903] + + * ruby.c (ruby_init_loadpath_safe): ditto. + +Fri Oct 12 13:56:01 2012 Ayumu AIZAWA <ayumu.aizawa@gmail.com> + + * test/rexml/test_encoding.rb: + Add require 'require 'rexml/document' + +Fri Oct 12 13:36:32 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * numeric.c (flodivmod): must through the same pass if HAVE_FMOD or not. + this is a bugfix of r35013. + +Fri Oct 12 13:28:37 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * io.c (rb_cloexec_fcntl_dupfd): get rid of compile error on windows. + reported by Donovan Lampa at [ruby-core:43152] [Backport #6127], + based on a patch by Hiroshi Shirosaki at [ruby-core:47917]. + +Fri Oct 12 00:30:17 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * io.c (ioctl_narg_len, linux_iocparm_len): reinstantiate linux + specific narg length calculation. + * test/ruby/test_io.rb (test_ioctl_linux2): add new test for old and + unstructured ioctl. + +Fri Oct 12 00:30:17 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * io.c (ioctl_narg_len): don't use _IOC_SIZE macro on Linux. + On Linux some constants for ioctl(2) doesn't include the size of + its return value and 16bit value; for example FIONREAD 0x541B. + Moreover the manual, ioctl_list(2), says "Note that the size + bits are very unreliable: in lots of cases they are wrong, + either because of buggy macros using sizeof(sizeof(struct)), + or because of legacy values." + So we shouldn't use it. + +Tue Sep 25 09:30:36 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * win32/mkexports.rb: should not export DllMain(). + reported by luis at [ruby-core:46743] [Bug #6790], solved by + Heesob Park, and confirmed by nobu. + +Mon Sep 24 16:34:07 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com> + + * include/ruby/win32.h (rb_w32_pow): add new function. + We use powl() instead of broken pow() for x64-mingw32. This workaround + fixes test failures related to floating point numeric. + [ruby-core:46686] [Bug #6784] + +Mon Sep 24 10:38:55 2012 Luis Lavena <luislavena@gmail.com> + + * test/win32ole/test_win32ole_method.rb (is_ruby64?): Correct platform + used to identify mingw-w64 (x64-mingw32). Patch by Hiroshi Shirosaki. + [ruby-core:46651][Bug #6782] + +Mon Sep 24 10:37:56 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/test/unit/parallel.rb: workaround fix for rubygems. + RubyGems can't find rake if the source directory is not equal to + the directory which is running the test. [Bug #6604] + +Fri Sep 21 19:53:38 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * ext/dl/cfunc.c (rb_dlcfunc_call): should convert a Bignum value to + unsigned long long on Win64. + [ruby-core:44636][Bug #6364] reported by raylinn@gmail.com (ray linn) + +Fri Sep 21 18:45:20 2012 Luis Lavena <luislavena@gmail.com> + + * include/ruby/win32.h: undef stat to silence mingw-w64 stat + redefinition warnings (GCC 4.6.3). + +Fri Sep 21 17:54:54 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * configure.in: add -Wall always. + +Thu Sep 20 10:23:37 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * thread_pthread.c (native_cond_initialize): destroy condattr + after using it. Patch by Stanislav Sedov. Thank you. + [Bug #7041] [ruby-core:47619] + +Sun Sep 9 23:01:43 2012 Tanaka Akira <akr@fsij.org> + + * ext/zlib/extconf.rb: detect z_crc_t type which will be defined + since zlib-1.2.7. + + * ext/zlib/zlib.c (rb_zlib_crc_table): use z_crc_t if available. + +Sun Sep 9 02:44:21 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * ext/zlib/extconf.rb: Use an exception instaed of bare puts. + +Sun Sep 9 02:44:21 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * ext/psych/extconf.rb: Use an exception instaed of bare abort. + +Sun Sep 9 02:44:21 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * ext/fiddle/extconf.rb: Use an exception instaed of bare abort. + +Sun Sep 9 02:44:21 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * ext/readline/extconf.rb: Use an exception instead of bare exit. + +Sun Sep 9 02:34:39 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * ext/extmk.rb: Show a message when extconf.rb raised an exception. + * ext/openssl/extconf.rb: Use exception raising instead of message + and/or abort. We want to display error message to console _and_ + logging into mkmf.log. + +Sun Sep 9 02:30:20 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * thread.c (rb_mutex_lock): stop multiple threads use + pthread_cond_timedwait() concurrently. [Bug #6278] [ruby-core:44275] + +Thu Aug 30 09:24:43 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/uri/ftp.rb (URI::FTP#initialize): raise InvalidURIError if "//" + is not present [ruby-core:47344] [Bug #6945] + +Tue Aug 28 00:40:14 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/webrick/test_cgi.rb (TestWEBrickCGI#start_cgi_server): there are + no guarantee of existance of RbConfig::CONFIG['LIBPATHENV']. + it only exists in Unix-like environments. + + * test/webrick/test_filehandler.rb + (WEBrick::TestFileHandler#test_script_disclosure): ditto. + +Thu Aug 23 12:08:25 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com> + + * test/ruby/test_file_exhaustive.rb + (TestFileExhaustive#test_stat_special_file): add a test. + GetFileAttributesExW fails to get attributes of special files + such as pagefile.sys. + + * win32/win32.c (check_valid_dir): for performance, check the path + by FindFirstFileW only if the path contains "...". + + * win32/win32.c (winnt_stat): use GetFileAttributesExW instead of + FindFirstFileW since GetFileAttributesExW is faster. + Based on the patch by Dusan D. Majkic. + [ruby-core:47083] [Feature #6845] + +Thu Aug 23 11:19:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * thread_pthread.c (ruby_init_stack): STACK_GROW_DIR_DETECTION is + necessary on platforms with unknown stack direction. [Bug #6761] + +Thu Aug 23 11:19:51 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * thread_pthread.c (get_stack): Linux is the only OS which includes + the size of guard page into the stack size. + +Thu Aug 23 11:19:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * gc.h (IS_STACK_DIR_UPPER): utility macro. + + * thread_pthread.c (get_stack): seems stack size does not include + guard size on Mac OS X. + + * thread_pthread.c (ruby_init_stack): adjust stack size for offset of + addr from the bottom. + +Thu Aug 23 11:19:51 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * thread_pthread.c (ruby_init_stack): use stack info if possible. + +Mon Aug 20 17:11:01 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * file.c (file_path_convert): don't convert it when the path string is + ascii only. [ruby-core:41556] [Bug #5733] + tests are contributed by nobu. + +Thu Aug 9 22:48:58 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * pack.c (pack_unpack): when unpack('M') occurs an illegal byte + sequence, output the "=" character and the following character in + the decoded data without any transformation. + [ruby-dev:44875] [Bug #5635] + +Tue Jul 31 10:36:12 2012 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/psych/lib/psych.rb: updated to released version. + + * ext/psych/psych.gemspec: ditto + +Thu Jul 19 09:33:46 2012 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/psych/emitter.c (initialize): allow a configuration object to be + passed to the constructor so that mutation isn't required after + instantiation. + + * ext/psych/lib/psych/handler.rb: add configuration object + + * ext/psych/lib/psych/visitors/emitter.rb: use configuration object if + extra configuration is present. + +Tue Jul 17 03:56:34 2012 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/psych/lib/psych/visitors/to_ruby.rb: strings with YAML anchors + are properly referenced. Patched by Joe Rafaniello via Github: + https://github.com/tenderlove/psych/pull/69 + * ext/psych/lib/psych/visitors/yaml_tree.rb: ditto + * test/psych/test_alias_and_anchor.rb: test for change + +Sat Jun 16 01:27:14 2012 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/psych/lib/psych.rb: bumping psych to 1.3.3 + * ext/psych/psych.gemspec: ditto + +Fri May 18 15:53:05 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * ext/psych/extconf.rb: Use an exception instaed of bare abort. + +Fri May 18 01:28:21 2012 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/psych/parser.c (transcode_string): fix encoding index names. + Thanks markizko for reporting. + +Wed May 16 05:11:29 2012 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/psych/lib/psych/visitors/to_ruby.rb: fix a bug with string + subclass dumping and loading. + + * test/psych/test_array.rb: pertinent tests + + * test/psych/test_string.rb: ditto + +Wed May 16 01:31:21 2012 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/psych/lib/psych/visitors/to_ruby.rb: convert omap tagged maps to + Psych::Omap objects rather than hashes. [Bug #6425] + + * test/psych/test_omap.rb: pertinent test. + +Wed May 16 01:15:45 2012 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/psych/lib/psych/visitors/yaml_tree.rb: keep a reference to + custom coders so that GC does not impact dumped yaml reference ids. + +Mon Apr 30 04:43:53 2012 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/psych/lib/psych/json/yaml_events.rb: implicit styles should not + be changeable for JSON events. + +Sun Jul 29 04:32:31 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * configure.in (ruby_pc): make configurable. [Bug #6051] + +Sun Jul 29 04:32:06 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * template/ruby.pc.in: added rubylibprefix, {rubylib,vendor,site}dir + and {ruby,vendor,site}archdir. [ruby-core:42766][Feature #6052] + +Sun Jul 29 04:31:01 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * bignum.c: Added #include <strings.h> for ffs(). Patch by Perry + Smith. Thank you. [Bug #6748] + +Sat Jul 28 04:04:01 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * include/ruby/intern.h (rb_num_zerodiv): Added NORETURN. + Patched by Xi Wang. [Bug #6736] + +Wed Jul 4 19:36:17 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * ext/dl/cfunc.c (rb_dlcfunc_call): also needed the workaround for VC8 + for x64. [ruby-dev:45875] [Bug #6676] + reported by aves_ramphastos (Seigo Ishigane) + +Tue Jul 3 19:37:52 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (rmext): no extension to strip if empty string. + + * proc.c (rb_vm_rewrite_dfp_in_errinfo): Fix `unexpected return' + occurs when a proc is called in ensure. [Backport #6460] + +Tue Jul 3 11:44:23 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * file.c (rb_enc_path_next, rb_enc_path_skip_prefix) + (rb_enc_path_last_separator, rb_enc_path_end) + (ruby_enc_find_basename, ruby_enc_find_extname): encoding-aware + path handling functions. + + * file.c (rb_home_dir, file_expand_path, rb_realpath_internal) + (rb_file_s_basename, rb_file_dirname, rb_file_s_extname) + (rb_file_join): should respect the encodings of arguments than + file system encoding. [ruby-dev:45145] [Bug #5919] + + * dir.c (check_dirname, ruby_glob0): ditto. + + * ext/pathname/pathname.c (path_sub_ext): ditto. + +Tue Jul 3 11:43:46 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * dir.c (dir_chdir, check_dirname): get rid of optimization-out. + +Thu Jun 28 17:57:49 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * win32/win32.c (is_socket, is_console): add prototypes to fix compile + problem with gcc introduced at r32549. + +Wed Jun 27 08:31:50 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * insns.def (splatarray): make new array if flag is set. + + * compile.c (iseq_compile_each): make new array with + splat. [ruby-core:21901][Feature #1125] + +Wed Jun 27 04:23:26 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * win32/win32.c (rb_w32_sysinit): let the system not display the + critical-error-handler message box and the Windows Error Reporting + dialog. [ruby-core:45389] [Bug #6535] + +Wed Jun 27 04:20:41 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * bignum.c (rb_big_pow): estimate result bit size more precisely. + [ruby-core:30735][Feature #3429] + +Tue Jun 26 20:36:53 2012 Tanaka Akira <akr@fsij.org> + + * lib/drb/ssl.rb: generate 1024 bits RSA key instead of 512 bits. + OpenSSL 1.0.1 rejects 512 bits RSA key for TLS1.2 with SHA512. + http://rt.openssl.org/Ticket/Display.html?id=2769&user=guest&pass=guest + reported by Bohuslav Kabrda. + [ruby-core:43844] [ruby-trunk - Bug #6221] + +Tue Jun 26 20:35:59 2012 Eric Hodel <drbrain@segment7.net> + + * ext/zlib/zlib.c (do_inflate): Inflate more data if buffered data + exists. Allows Zlib::Inflate#set_dictionary to work. + [ruby-trunk - Bug #5929] + +Thu Jun 21 13:42:57 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * thread.c (rb_threadptr_execute_interrupts_common): + test_signal_requiring of test/ruby/test_signal.rb fail if the sub + process is killed on waiting IO in lex_io_gets in rb_load_file in + rb_load_internal in require. + This is because + (1) the process receive the killing signal in + rb_thread_io_blocking_region in rb_read_internal in lex_io_gets. + (2) set th->errinfo as INT2FIX(TAG_FATAL) at + rb_threadptr_execute_interrupts_common. + (3) escape rb_load_file in rb_load_internal and jump to EXEC_TAG() + without set loaded as TRUE. + (4) call first rb_exc_raise(GET_THREAD()->errinfo); because loaded + is FALSE as above. this errinfo should be an exception object + but this is INT2FIX(TAG_FATAL). + Don't call first rb_exc_raise if GET_THREAD()->errinfo is Fixnum. + +Mon Jun 11 19:56:22 2012 KOSAKI Motohiro <kosaki.motohiro@gmail.com> + + * test/webrick/test_cgi.rb (class TestWEBrickCGI): respect + RbConfig::CONFIG["LIBPATHENV"]. [Bug #5135] [ruby-core:38653] + * test/webrick/test_filehandler.rb (class WEBrick): ditto. + +Tue Jun 5 14:03:53 2012 Akinori MUSHA <knu@iDaemons.org> + + * lib/ipaddr.rb: Inhibit zero-filled octets in an IPv4 address in + all platforms. [ruby-dev:45671] + + * lib/ipaddr.rb: Allow the x:x:x:x:x:x:d.d.d.d form not limited to + IPv4 mapped/compatible addresses. This change also makes it + possible for the parser to understand IPv4 mapped and compatible + IPv6 addresses in non-compressed form. + + * lib/ipaddr.rb: Stop exposing IPSocket.valid*? methods which were + only usable on non-IPv6-ready platforms. + +Sat Jun 2 18:49:39 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * string.c (rb_enc_cr_str_buf_cat): don't reset coderange as unknown. + the condition 'ptr_a8 && str_cr != ENC_CODERANGE_7BIT' means not + unknown, str is also ASCII-8BIT because str_encindex == ptr_encindex, + and nont (str_cr == ENC_CODERANGE_UNKNOWN) and + str_cr != ENC_CODERANGE_7BIT means str_cr is valid because ASCII-8BIT + can't be broken. [ruby-dev:45688] [Bug #6509] + +Wed May 30 17:19:56 2012 Eric Hodel <drbrain@segment7.net> + + * ext/zlib/zlib.c (do_inflate): Inflate more data if buffered data + exists. Allows Zlib::Inflate#set_dictionary to work. + [ruby-trunk - Bug #5929] + +Mon May 28 11:40:19 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * io.c (rb_io_extract_modeenc): fail only if conflicting + text/binary modes given explicitly. [ruby-dev:45268][Bug #6055] + +Fri May 25 17:18:06 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (f_arglist): should reset lexical states after empty + argument list with no parenthesis as well as parenthesized list, + so that reserved name method definition work. [ruby-dev:45626] + [Bug #6403] + +Fri May 25 10:40:31 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com> + + * include/ruby/win32.h (FD_SET): change function to macro. + To avoid buffer overflow when smaller FD_SETSISE is used in ext + libraries. + + * win32/win32.c (rb_w32_fdset): this function is not used anymore. + But we leave this for compatibility. + + * win32/win32.c (rb_w32_select_with_thread): fix SEGV when smaller + FD_SETSISE is used in ext libraries. Dereference of fd_set pointer + causes SEGV. + + * test/-ext-/win32/test_fd_setsize.rb(TestFdSetSize): add tests for + above. + * ext/-test-/win32/fd_setsize/depend: ditto. + * ext/-test-/win32/fd_setsize/extconf.rb: ditto. + * ext/-test-/win32/fd_setsize/fd_setsize.c: ditto. + + [ruby-core:44588] [Bug #6352] + +Fri May 25 10:38:06 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * io.c (io_strip_bom): check EOF. [Bug #6487][ruby-core:45203] + +Fri May 25 10:36:38 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (f_arglist): should reset lexical states after empty + argument list with no parenthesis as well as parenthesized list, + so that reserved name method definition work. [ruby-dev:45626] + [Bug #6403] + +Mon May 21 16:24:40 2012 Akinori MUSHA <knu@iDaemons.org> + + * ext/syslog/syslog.c (mSyslog_inspect): Use rb_sprintf(). + + * ext/syslog/syslog.c (mSyslog_inspect): Make sure self is a + module before calling rb_class2name(). + +Sat May 19 14:42:37 2012 NAKAMURA Usaku <usa@ruby-lang.org> + + * test/drb/drbtest.rb ({DRbCore,DRbAry}#teardown}: cannot pass SIGTERM + to another process on Windows, so use SIGINT instead. + +Sat May 19 14:42:20 2012 Tanaka Akira <akr@fsij.org> + + * lib/drb/ssl.rb: generate 1024 bits RSA key instead of 512 bits. + OpenSSL 1.0.1 rejects 512 bits RSA key for TLS1.2 with SHA512. + http://rt.openssl.org/Ticket/Display.html?id=2769&user=guest&pass=guest + reported by Bohuslav Kabrda. + [ruby-core:43844] [ruby-trunk - Bug #6221] + +Sat May 19 14:41:45 2012 Tanaka Akira <akr@fsij.org> + + * test/drb/drbtest.rb: rescue Errno::ESRCH for Process.kill. + reported by NARUSE, Yui. [ruby-dev:45551] + +Sat May 19 14:41:09 2012 Tanaka Akira <akr@fsij.org> + + * lib/drb/extservm.rb (DRb::ExtServManager): don't use /bin/sh to + invoke service subprocess. mark detach threads for clean up. + + * test/drb/drbtest.rb: clean up the service subprocess in teardown. + + * test/drb/test_drb.rb: set @service_name for teardown. + + * test/drb/test_drbunix.rb: ditto. + + * test/drb/test_drbssl.rb: ditto. + +Sat May 19 14:40:49 2012 Tanaka Akira <akr@fsij.org> + + * lib/drb/ssl.rb: close accepted TCP socket if SSL accept is failed. + [ruby-dev:45541] + +Sat May 19 14:39:50 2012 Tanaka Akira <akr@fsij.org> + + * lib/webrick/utils.rb: fix fcntl call. + + * lib/drb/unix.rb: ditto. + +Fri May 18 18:13:44 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/mkmf.rb (MakeMakefile#configuration): keep space at end of + OUTFLAG and COUTFLAG. [ruby-dev:45650] + +Fri May 18 00:04:53 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * win32/win32.c (rb_w32_fstat, rb_w32_fstati64): convert FILETIME + to time_t directly, not to be affected by TZ unnecessarily. + + * win32/win32.c (unixtime_to_filetime): convert time_t to FILETIME + simply. + +Wed May 16 01:07:46 2012 Aaron Patterson <aaron@tenderlovemaking.com> + + * ext/digest/md5/extconf.rb: use pkg_config for openssl so that + customized ssl paths are used for linking. Backports fixes for + [ruby-core:44755]. + * ext/digest/rmd160/extconf.rb: ditto + * ext/digest/sha1/extconf.rb: ditto + * ext/digest/sha2/extconf.rb: ditto + +Mon May 14 17:14:10 2012 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org> + + * test/ruby/test_io.rb (test_flush_in_finalizer1): don't use IO.for_fd + to close IO objects. it create IO object with already closed fd, and + cause occasional Errno::EBADF in following tests. [ruby-core:45020] + [Bug #6228] + +Mon May 14 17:14:10 2012 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org> + + * test/ruby/test_io.rb (TestIO): revert r35631. it broke the intent of + test_flush_in_finalizer1. [ruby-core:43951] [Bug ##6228] + +Mon May 14 13:18:56 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (parser_tokadd_string): insert a backslash only if + quoted by single quotes. [ruby-dev:45281] [Bug #6069] + +Mon May 14 13:17:57 2012 Luis Lavena <luislavena@gmail.com> + + * test/ruby/test_io.rb (class TestIO): Disable GC during IO tests to + avoid file descriptors being GC'ed. Suggestion by Tomoyuki Chikanaga + [ruby-core:43951][Bug #6228] + +Fri May 11 14:09:48 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * ext/bigdecimal/bigdecimal.c (PUSH): to prevent VALUE from GC, + must not cast it to unsigned long, which may be shorter than + VALUE, and the result can be mere garbage. + +Fri May 11 01:04:54 2012 Hiroshi Shirosaki <h.shirosaki@gmail.com> + + * io.c (io_unread): fix IO#pos with mode 'r' bug on Windows. + If the end of reading buffer is CR, io_unread() needs to unread one + more byte. + [ruby-core:44874] [Bug #6401] + + * test/ruby/test_io_m17n.rb (TestIO_M17N#test_pos_with_buffer_end_cr): + add a test for above. + +Wed May 9 15:59:17 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * configure.in (RUBY_WERROR_FLAG): append all warning flags which + are enabled to compile, so that printf format modifiers properly + fail. [ruby-core:41351] [Bug #5679] + +Mon May 7 20:23:29 2012 Tanaka Akira <akr@fsij.org> + + * lib/securerandom.rb (random_bytes): call to_int method for the + argument at first. + +Mon May 7 20:23:29 2012 Tanaka Akira <akr@fsij.org> + + * lib/securerandom.rb: show actual read length in an error message. + +Mon May 7 11:09:20 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * ext/bigdecimal/bigdecimal.c (Init_bigdecimal): define IDs before + they are used. [ruby-core:44900] [Bug #6406] + +Fri Apr 27 11:02:33 2012 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp> + + * test/rinda/test_rinda.rb (test_core_03_notify): Fixed test failures + [ruby-dev:44430] [Ruby 1.9 - Bug #372] + +Fri Apr 27 08:29:51 2012 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp> + + * test/rinda/test_rinda.rb: fix sticks on some testsf problem + [Bug #6272] + +Wed Apr 25 05:56:56 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/optparse.rb (OptionParser#to_a): split for each lines. + [ruby-dev:45568][Bug #6348] + +Tue Apr 24 21:20:39 2012 NARUSE, Yui <naruse@ruby-lang.org> + + * lib/optparse.rb (OptionParser#to_a): should split by end-of-line, + and MUST TEST IT, MUST RUN THE TEST, MUST VERIFY BEFORE BACKPORT. + [ruby-dev:45568][Bug #6348] + +Tue Apr 24 14:55:41 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * lib/optparse.rb (OptionParser#to_a): String#to_a is no longer + defined. [ruby-dev:45568][Bug #6348] + +Sat Apr 21 07:16:16 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * strftime.c (rb_strftime_with_timespec): fix padding of time zone + offset. [ruby-dev:43287][Bug #4458] + + * strftime.c (rb_strftime_with_timespec): add an interim digit for + the timezone offset which is less than an hour. + + * strftime.c (rb_strftime_with_timespec): fix carry-up bug and + overwrite '+' with '-' if negative offset less than a hour. + [ruby-core:44447][Bug #6323] + +Fri Apr 20 12:30:06 2012 Eric Hodel <drbrain@segment7.net> + + * lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem: Removed to avoid + conflict with ca-bundle.pem + * lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem: + ditto. + * lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem: + ditto. + Fri Apr 20 08:30:55 2012 Eric Hodel <drbrain@segment7.net> * lib/rubygems: Update to RubyGems 1.8.23 which contains security @@ -718,7 +2640,7 @@ Wed Feb 15 05:03:41 2012 CHIKANAGA Tomoyuki <nagachika00@gmail.com> Wed Feb 15 05:02:43 2012 Masaki Suketa <masaki.suketa@nifty.ne.jp> - * test/win32ole/test_err_in_callback.rb (test_err_in_callback): + * test/win32ole/test_err_in_callback.rb (test_err_in_callback): skip test if ADODB.connection is not available. Wed Feb 15 04:49:23 2012 Yusuke Endoh <mame@tsg.ne.jp> @@ -739,7 +2661,7 @@ Tue Feb 14 16:52:17 2012 NAKAMURA Usaku <usa@ruby-lang.org> see https://github.com/rdoc/rdoc/issues/87 * test/rdoc/test_rdoc_markup_pre_process.rb - (TestRDocMarkupPreProcess#test_include_file, + (TestRDocMarkupPreProcess#test_include_file, TestRDocMarkupPreProcess#test_include_file_encoding_incompatible): follow above change. diff --git a/KNOWNBUGS.rb b/KNOWNBUGS.rb index 5c0e4d5..b97a08d 100644 --- a/KNOWNBUGS.rb +++ b/KNOWNBUGS.rb @@ -3,14 +3,3 @@ # So all tests will cause failure. # -assert_normal_exit %q{ - open("tst-remove-load.rb", "w") {|f| - f << <<-'End' - module Kernel - remove_method :load - end - raise - End - } - load "tst-remove-load.rb" -}, '[ruby-dev:40234] [ruby-core:27959]', :timeout => 1 @@ -148,7 +148,6 @@ util.c (partly): REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. -util.c (partly): win32/win32.[ch]: You can apply the Artistic License to these files. (or GPL, diff --git a/Makefile.in b/Makefile.in index b0f4434..41ea412 100644 --- a/Makefile.in +++ b/Makefile.in @@ -10,6 +10,7 @@ NULL = /dev/null srcdir = @srcdir@ top_srcdir = $(srcdir) hdrdir = $(srcdir)/include +PLATFORM_DIR = @PLATFORM_DIR@ CC = @CC@ CPP = @CPP@ @@ -57,9 +58,9 @@ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir) -I$(srcdir) XCFLAGS = @XCFLAGS@ CPPFLAGS = @CPPFLAGS@ $(INCFLAGS) LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@ -EXTLDFLAGS = +EXTLDFLAGS = XLDFLAGS = @XLDFLAGS@ $(EXTLDFLAGS) -EXTLIBS = +EXTLIBS = LIBS = @LIBS@ $(EXTLIBS) MISSING = @LIBOBJS@ @ALLOCA@ LDSHARED = @LIBRUBY_LDSHARED@ @@ -162,12 +163,12 @@ all: miniruby$(EXEEXT): @-if test -f $@; then $(MV) -f $@ $@.old; $(RM) $@.old; fi $(ECHO) linking $@ - $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(LIBS) $(OUTFLAG)$@ + $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(MAINLIBS) $(LIBS) $(OUTFLAG)$@ $(PROGRAM): @$(RM) $@ $(ECHO) linking $@ - $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINLIBS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(LIBS) $(OUTFLAG)$@ + $(Q) $(PURIFY) $(CC) $(LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(OUTFLAG)$@ # We must `rm' the library each time this rule is invoked because "updating" a # MAB library on Apple/NeXT (see --enable-fat-binary in configure) is not @@ -342,6 +343,9 @@ clean-capi distclean-capi realclean-capi: @echo $(@:-capi=ing) capi $(Q)$(RMALL) $(CAPIOUT) +clean-platform: + @$(RM) $(PLATFORM_D) + -$(Q) $(RMDIR) $(PLATFORM_DIR) 2> /dev/null || true ext/extinit.$(OBJEXT): ext/extinit.c $(SETUP) $(ECHO) compiling $@ @@ -478,10 +478,9 @@ rb_check_array_type(VALUE ary) * call-seq: * Array.try_convert(obj) -> array or nil * - * Try to convert <i>obj</i> into an array, using +to_ary+ method. - * Returns converted array or +nil+ if <i>obj</i> cannot be converted - * for any reason. This method can be used to check if an argument is an - * array. + * Tries to convert +obj+ into an array, using +to_ary+ method. Returns the + * converted array or +nil+ if +obj+ cannot be converted for any reason. + * This method can be used to check if an argument is an array. * * Array.try_convert([1]) #=> [1] * Array.try_convert("1") #=> nil @@ -506,36 +505,54 @@ rb_ary_s_try_convert(VALUE dummy, VALUE ary) * Array.new(array) * Array.new(size) {|index| block } * - * Returns a new array. In the first form, the new array is - * empty. In the second it is created with _size_ copies of _obj_ - * (that is, _size_ references to the same - * _obj_). The third form creates a copy of the array - * passed as a parameter (the array is generated by calling - * to_ary on the parameter). In the last form, an array - * of the given size is created. Each element in this array is - * calculated by passing the element's index to the given block and - * storing the return value. - * - * Array.new - * Array.new(2) - * Array.new(5, "A") - * - * # only one copy of the object is created + * Returns a new array. + * + * In the first form, if no arguments are sent, the new array will be empty. + * When a +size+ and an optional +obj+ are sent, an array is created with + * +size+ copies of +obj+. Take notice that all elements will reference the + * same object +obj+. + * + * The second form creates a copy of the array passed as a parameter (the + * array is generated by calling to_ary on the parameter). + * + * first_array = ["Matz", "Guido"] + * + * second_array = Array.new(first_array) #=> ["Matz", "Guido"] + * + * first_array.equal? second_array #=> false + * + * In the last form, an array of the given size is created. Each element in + * this array is created by passing the element's index to the given block + * and storing the return value. + * + * Array.new(3){ |index| index ** 2 } + * # => [0, 1, 4] + * + * == Common gotchas + * + * When sending the second parameter, the same object will be used as the + * value for all the array elements: + * * a = Array.new(2, Hash.new) + * # => [{}, {}] + * * a[0]['cat'] = 'feline' - * a + * a # => [{"cat"=>"feline"}, {"cat"=>"feline"}] + * * a[1]['cat'] = 'Felix' - * a + * a # => [{"cat"=>"Felix"}, {"cat"=>"Felix"}] + * + * Since all the Array elements store the same hash, changes to one of them + * will affect them all. + * + * If multiple copies are what you want, you should use the block + * version which uses the result of that block each time an element + * of the array needs to be initialized: * - * # here multiple copies are created * a = Array.new(2) { Hash.new } * a[0]['cat'] = 'feline' - * a - * - * squares = Array.new(5) {|i| i*i} - * squares + * a # => [{"cat"=>"feline"}, {}] * - * copy = Array.new(squares) */ static VALUE @@ -1208,9 +1225,9 @@ rb_ary_index(int argc, VALUE *argv, VALUE ary) * If neither block nor argument is given, an enumerator is returned instead. * * a = [ "a", "b", "b", "b", "c" ] - * a.rindex("b") #=> 3 - * a.rindex("z") #=> nil - * a.rindex{|x|x=="b"} #=> 3 + * a.rindex("b") #=> 3 + * a.rindex("z") #=> nil + * a.rindex { |x| x == "b" } #=> 3 */ static VALUE @@ -3496,18 +3513,23 @@ push_value(st_data_t key, st_data_t val, st_data_t ary) /* * call-seq: - * ary.uniq! -> ary or nil + * ary.uniq! -> ary or nil + * ary.uniq! { |item| ... } -> ary or nil * - * Removes duplicate elements from +self+. + * Removes duplicate elements from +self+. If a block is given, + * it will use the return value of the block for comparison. * Returns <code>nil</code> if no changes are made (that is, no * duplicates are found). * * a = [ "a", "a", "b", "b", "c" ] - * a.uniq! #=> ["a", "b", "c"] + * a.uniq! # => ["a", "b", "c"] + * * b = [ "a", "b", "c" ] - * b.uniq! #=> nil - * c = [ "a:def", "a:xyz", "b:abc", "b:xyz", "c:jkl" ] - * c.uniq! {|s| s[/^\w+/]} #=> [ "a:def", "b:abc", "c:jkl" ] + * b.uniq! # => nil + * + * c = [["student","sam"], ["student","george"], ["teacher","matz"]] + * c.uniq! { |s| s.first } # => [["student", "sam"], ["teacher", "matz"]] + * */ static VALUE @@ -3552,14 +3574,18 @@ rb_ary_uniq_bang(VALUE ary) /* * call-seq: - * ary.uniq -> new_ary + * ary.uniq -> new_ary + * ary.uniq { |item| ... } -> new_ary * - * Returns a new array by removing duplicate values in +self+. + * Returns a new array by removing duplicate values in +self+. If a block + * is given, it will use the return value of the block for comparison. * * a = [ "a", "a", "b", "b", "c" ] - * a.uniq #=> ["a", "b", "c"] - * c = [ "a:def", "a:xyz", "b:abc", "b:xyz", "c:jkl" ] - * c.uniq {|s| s[/^\w+/]} #=> [ "a:def", "b:abc", "c:jkl" ] + * a.uniq # => ["a", "b", "c"] + * + * b = [["student","sam"], ["student","george"], ["teacher","matz"]] + * b.uniq { |s| s.first } # => [["student", "sam"], ["teacher", "matz"]] + * */ static VALUE diff --git a/atomic.h b/atomic.h deleted file mode 100644 index 5b3fb99..0000000 --- a/atomic.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef RUBY_ATOMIC_H -#define RUBY_ATOMIC_H - -#ifdef _WIN32 -#if defined _MSC_VER && _MSC_VER > 1200 -#pragma intrinsic(_InterlockedOr) -#endif -typedef LONG rb_atomic_t; - -# define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val)) -# define ATOMIC_INC(var) InterlockedIncrement(&(var)) -# define ATOMIC_DEC(var) InterlockedDecrement(&(var)) -#if defined __GNUC__ -# define ATOMIC_OR(var, val) __asm__("lock\n\t" "orl\t%1, %0" : "=m"(var) : "Ir"(val)) -#elif defined _MSC_VER && _MSC_VER <= 1200 -# define ATOMIC_OR(var, val) rb_w32_atomic_or(&(var), (val)) -static inline void -rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val) -{ -#ifdef _M_IX86 - __asm mov eax, var; - __asm mov ecx, val; - __asm lock or [eax], ecx; -#else -#error unsupported architecture -#endif -} -#else -# define ATOMIC_OR(var, val) _InterlockedOr(&(var), (val)) -#endif -# define ATOMIC_EXCHANGE(var, val) InterlockedExchange(&(var), (val)) - -#elif defined HAVE_GCC_ATOMIC_BUILTINS -/* @shyouhei hack to support atomic operations in case of gcc. Gcc - * has its own pseudo-insns to support them. See info, or - * http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html */ - -typedef unsigned int rb_atomic_t; /* Anything OK */ -# define ATOMIC_SET(var, val) __sync_lock_test_and_set(&(var), (val)) -# define ATOMIC_INC(var) __sync_fetch_and_add(&(var), 1) -# define ATOMIC_DEC(var) __sync_fetch_and_sub(&(var), 1) -# define ATOMIC_OR(var, val) __sync_or_and_fetch(&(var), (val)) -# define ATOMIC_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val)) - -#else -typedef int rb_atomic_t; -extern rb_atomic_t ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val); - -# define ATOMIC_SET(var, val) ((var) = (val)) -# define ATOMIC_INC(var) (++(var)) -# define ATOMIC_DEC(var) (--(var)) -# define ATOMIC_OR(var, val) ((var) |= (val)) -# define ATOMIC_EXCHANGE(var, val) ruby_atomic_exchange(&(var), (val)) -#endif - -#endif /* RUBY_ATOMIC_H */ @@ -2,7 +2,7 @@ bignum.c - - $Author: mrkn $ + $Author: usa $ created at: Fri Jun 10 00:48:55 JST 1994 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -13,6 +13,9 @@ #include "ruby/util.h" #include "internal.h" +#ifdef HAVE_STRINGS_H +#include <strings.h> +#endif #include <math.h> #include <float.h> #include <ctype.h> @@ -1625,7 +1628,7 @@ rb_big_eq(VALUE x, VALUE y) * 68719476736.eql?(68719476736.0) #=> false */ -static VALUE +VALUE rb_big_eql(VALUE x, VALUE y) { if (TYPE(y) != T_BIGNUM) return Qfalse; @@ -2416,7 +2419,7 @@ bigmul1_toom3(VALUE x, VALUE y) z2 = bigtrunc(bigadd(u2, u0, 0)); /* z3 <- (z2 - z3) / 2 + 2 * z(inf) == (z2 - z3) / 2 + 2 * u4 */ - z3 = bigadd(z2, z3, 0); + z3 = bigtrunc(bigadd(z2, z3, 0)); bigrsh_bang(BDIGITS(z3), RBIGNUM_LEN(z3), 1); t = big_lshift(u4, 1); /* TODO: combining with next addition */ z3 = bigtrunc(bigadd(z3, t, 1)); @@ -2726,7 +2729,7 @@ bigdivrem(VALUE x, VALUE y, volatile VALUE *divp, volatile VALUE *modp) if (modp) { /* normalize remainder */ *modp = zz = rb_big_clone(z); zds = BDIGITS(zz); - while (--ny && !zds[ny]); ++ny; + while (ny > 1 && !zds[ny-1]) --ny; if (dd) { t2 = 0; i = ny; while(i--) { @@ -3079,10 +3082,11 @@ rb_big_pow(VALUE x, VALUE y) else { VALUE z = 0; SIGNED_VALUE mask; - const long BIGLEN_LIMIT = 1024*1024 / SIZEOF_BDIGITS; + const long xlen = RBIGNUM_LEN(x) - 1; + const long xbits = ffs(RBIGNUM_DIGITS(x)[xlen]) + SIZEOF_BDIGITS*BITSPERDIG*xlen; + const long BIGLEN_LIMIT = BITSPERDIG*1024*1024; - if ((RBIGNUM_LEN(x) > BIGLEN_LIMIT) || - (RBIGNUM_LEN(x) > BIGLEN_LIMIT / yy)) { + if ((xbits > BIGLEN_LIMIT) || (xbits * yy > BIGLEN_LIMIT)) { rb_warn("in a**b, b may be too big"); d = (double)yy; break; diff --git a/bootstraptest/test_flow.rb b/bootstraptest/test_flow.rb index d40d814..6b3ef74 100644 --- a/bootstraptest/test_flow.rb +++ b/bootstraptest/test_flow.rb @@ -543,9 +543,36 @@ assert_equal %Q{ENSURE\n}, %q{ end end e = Bug5234.new +}], + ['[ruby-dev:45656]', %q{ + class Bug6460 + include Enumerable + def each + begin + yield :foo + ensure + 1.times { Proc.new } + end + end + end + e = Bug6460.new }]].each do |bug, src| assert_equal "foo", src + %q{e.detect {true}}, bug assert_equal "true", src + %q{e.any? {true}}, bug assert_equal "false", src + %q{e.all? {false}}, bug assert_equal "true", src + %q{e.include?(:foo)}, bug end + +assert_equal('ok', %q{ + class FOO < RuntimeError; end + class BAR < RuntimeError; end + def m + raise FOO + end + set_trace_func(proc{|t,| raise BAR if t == 'return'}) + begin + m + rescue BAR + 'ok' + end +}, '[ruby-core:51128] [ruby-trunk - Bug #7624]') diff --git a/bootstraptest/test_proc.rb b/bootstraptest/test_proc.rb index 3d34700..dfe8903 100644 --- a/bootstraptest/test_proc.rb +++ b/bootstraptest/test_proc.rb @@ -456,3 +456,27 @@ assert_equal 'ok', %q{ end } +assert_equal 'ok', %q{ + def x + binding + end + b = x{|a| a } + b.eval('yield("ok")') +}, '[Bug #5634]' + +assert_equal 'ok', %q{ + def x + binding + end + eval("x { 'ok' }").eval "yield" +}, '[Bug #5634]' + +assert_equal 'ok', %q{ + def x + binding + end + def m + x{ 'ok' } + end + eval('yield', m) +}, '[Bug #5634]' @@ -2,7 +2,7 @@ class.c - - $Author: yugui $ + $Author: usa $ created at: Tue Aug 10 15:05:44 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -159,10 +159,27 @@ clone_const_i(st_data_t key, st_data_t value, st_data_t data) return clone_const((ID)key, (const rb_const_entry_t *)value, (st_table *)data); } +static void +class_init_copy_check(VALUE clone, VALUE orig) +{ + if (orig == rb_cBasicObject) { + rb_raise(rb_eTypeError, "can't copy the root class"); + } + if (RCLASS_SUPER(clone) != 0 || clone == rb_cBasicObject) { + rb_raise(rb_eTypeError, "already initialized class"); + } + if (FL_TEST(orig, FL_SINGLETON)) { + rb_raise(rb_eTypeError, "can't copy singleton class"); + } +} + /* :nodoc: */ VALUE rb_mod_init_copy(VALUE clone, VALUE orig) { + if (RB_TYPE_P(clone, T_CLASS)) { + class_init_copy_check(clone, orig); + } rb_obj_init_copy(clone, orig); if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) { RBASIC(clone)->klass = rb_singleton_class_clone(orig); @@ -203,22 +220,6 @@ rb_mod_init_copy(VALUE clone, VALUE orig) return clone; } -/* :nodoc: */ -VALUE -rb_class_init_copy(VALUE clone, VALUE orig) -{ - if (orig == rb_cBasicObject) { - rb_raise(rb_eTypeError, "can't copy the root class"); - } - if (RCLASS_SUPER(clone) != 0 || clone == rb_cBasicObject) { - rb_raise(rb_eTypeError, "already initialized class"); - } - if (FL_TEST(orig, FL_SINGLETON)) { - rb_raise(rb_eTypeError, "can't copy singleton class"); - } - return rb_mod_init_copy(clone, orig); -} - VALUE rb_singleton_class_clone(VALUE obj) { @@ -698,6 +699,8 @@ rb_include_module(VALUE klass, VALUE module) c = RCLASS_SUPER(c) = include_class_new(module, RCLASS_SUPER(c)); if (RMODULE_M_TBL(module) && RMODULE_M_TBL(module)->num_entries) changed = 1; + if (RMODULE_CONST_TBL(module) && RMODULE_CONST_TBL(module)->num_entries) + changed = 1; skip: module = RCLASS_SUPER(module); } @@ -26,6 +26,7 @@ EXTCONF = extconf.rb RBCONFIG = ./.rbconfig.time LIBRUBY_EXTS = ./.libruby-with-ext.time REVISION_H = ./.revision.time +PLATFORM_D = ./$(PLATFORM_DIR)/.time RDOCOUT = $(EXTOUT)/rdoc CAPIOUT = doc/capi ID_H_TARGET = -id.h- @@ -232,14 +233,14 @@ $(ruby_pc): $(srcdir)/template/ruby.pc.in config.status install-all: docs pre-install-all do-install-all post-install-all pre-install-all:: pre-install-local pre-install-ext pre-install-doc -do-install-all: $(PROGRAM) +do-install-all: all $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=all --rdoc-output="$(RDOCOUT)" post-install-all:: post-install-local post-install-ext post-install-doc @$(NULLCMD) install-nodoc: pre-install-nodoc do-install-nodoc post-install-nodoc pre-install-nodoc:: pre-install-local pre-install-ext -do-install-nodoc: $(PREP) +do-install-nodoc: main $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) post-install-nodoc:: post-install-local post-install-ext @@ -257,7 +258,7 @@ post-install-ext:: post-install-ext-arch post-install-ext-comm install-arch: pre-install-arch do-install-arch post-install-arch pre-install-arch:: pre-install-bin pre-install-ext-arch -do-install-arch: $(PREP) +do-install-arch: main $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=bin --install=ext-arch post-install-arch:: post-install-bin post-install-ext-arch @@ -426,7 +427,7 @@ install-prereq: $(CLEAR_INSTALLED_LIST) PHONY clear-installed-list: PHONY @> $(INSTALLED_LIST) set MAKE="$(MAKE)" -clean: clean-ext clean-local clean-enc clean-golf clean-rdoc clean-capi clean-extout +clean: clean-ext clean-local clean-enc clean-golf clean-rdoc clean-capi clean-extout clean-platform clean-local:: PHONY @$(RM) $(OBJS) $(MINIOBJS) $(MAINOBJ) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES) @$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) $(ARCHFILE) .*.time @@ -436,10 +437,11 @@ clean-golf: PHONY @$(RM) $(GORUBY)$(EXEEXT) $(GOLFOBJS) clean-rdoc: PHONY clean-capi: PHONY +clean-platform: PHONY clean-extout: PHONY clean-docs: clean-rdoc clean-capi -distclean: distclean-ext distclean-local distclean-enc distclean-golf distclean-extout +distclean: distclean-ext distclean-local distclean-enc distclean-golf distclean-extout distclean-platform distclean-local:: clean-local @$(RM) $(MKFILES) yasmdata.rb *.inc @$(RM) config.cache config.status config.status.lineno $(PRELUDES) @@ -450,6 +452,7 @@ distclean-golf: clean-golf distclean-rdoc: PHONY distclean-capi: PHONY distclean-extout: clean-extout +distclean-platform: clean-platform realclean:: realclean-ext realclean-local realclean-enc realclean-golf realclean-extout realclean-local:: distclean-local @@ -573,7 +576,12 @@ dl_os2.$(OBJEXT): {$(VPATH)}dl_os2.c ia64.$(OBJEXT): {$(VPATH)}ia64.s $(CC) $(CFLAGS) -c $< -win32.$(OBJEXT): {$(VPATH)}win32.c $(RUBY_H_INCLUDES) +$(PLATFORM_D): + $(Q) $(MAKEDIRS) $(PLATFORM_DIR) + @exit > $@ + +win32/win32.$(OBJEXT): {$(VPATH)}win32/win32.c $(RUBY_H_INCLUDES) $(PLATFORM_D) +win32/file.$(OBJEXT): {$(VPATH)}win32/file.c $(RUBY_H_INCLUDES) $(PLATFORM_D) ### @@ -583,7 +591,7 @@ RUBY_H_INCLUDES = {$(VPATH)}ruby.h {$(VPATH)}config.h {$(VPATH)}defines.h \ ENCODING_H_INCLUDES= {$(VPATH)}encoding.h {$(VPATH)}oniguruma.h ID_H_INCLUDES = {$(VPATH)}id.h {$(VPATH)}vm_opts.h VM_CORE_H_INCLUDES = {$(VPATH)}vm_core.h {$(VPATH)}thread_$(THREAD_MODEL).h \ - {$(VPATH)}node.h {$(VPATH)}method.h {$(VPATH)}atomic.h \ + {$(VPATH)}node.h {$(VPATH)}method.h {$(VPATH)}ruby_atomic.h \ $(ID_H_INCLUDES) array.$(OBJEXT): {$(VPATH)}array.c $(RUBY_H_INCLUDES) {$(VPATH)}util.h \ @@ -663,7 +671,8 @@ proc.$(OBJEXT): {$(VPATH)}proc.c {$(VPATH)}eval_intern.h \ process.$(OBJEXT): {$(VPATH)}process.c $(RUBY_H_INCLUDES) \ {$(VPATH)}util.h {$(VPATH)}io.h $(ENCODING_H_INCLUDES) {$(VPATH)}dln.h \ $(VM_CORE_H_INCLUDES) {$(VPATH)}debug.h {$(VPATH)}internal.h -random.$(OBJEXT): {$(VPATH)}random.c $(RUBY_H_INCLUDES) +random.$(OBJEXT): {$(VPATH)}random.c $(RUBY_H_INCLUDES) \ + {$(VPATH)}siphash.c {$(VPATH)}siphash.h range.$(OBJEXT): {$(VPATH)}range.c $(RUBY_H_INCLUDES) \ $(ENCODING_H_INCLUDES) {$(VPATH)}internal.h rational.$(OBJEXT): {$(VPATH)}rational.c $(RUBY_H_INCLUDES) {$(VPATH)}internal.h @@ -2,7 +2,7 @@ compile.c - ruby node tree -> VM instruction sequence - $Author: nobu $ + $Author: usa $ created at: 04/01/01 03:42:15 JST Copyright (C) 2004-2007 Koichi Sasada @@ -251,7 +251,7 @@ r_value(VALUE value) (rb_ary_push(iseq->compile_data->catch_table_ary, \ rb_ary_new3(5, (type), \ (VALUE)(ls) | 1, (VALUE)(le) | 1, \ - (iseqv), (VALUE)(lc) | 1))) + (VALUE)(iseqv), (VALUE)(lc) | 1))) /* compile node */ #define COMPILE(anchor, desc, node) \ @@ -4629,7 +4629,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) } case NODE_SPLAT:{ COMPILE(ret, "splat", node->nd_head); - ADD_INSN1(ret, nd_line(node), splatarray, Qfalse); + ADD_INSN1(ret, nd_line(node), splatarray, Qtrue); if (poped) { ADD_INSN(ret, nd_line(node), pop); @@ -4844,12 +4844,13 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped) LABEL *lend = NEW_LABEL(nd_line(node)); LABEL *lfin = NEW_LABEL(nd_line(node)); LABEL *ltrue = NEW_LABEL(nd_line(node)); - VALUE key = rb_sprintf("flipflag/%s-%p-%d", - RSTRING_PTR(iseq->name), (void *)iseq, - iseq->compile_data->flip_cnt++); + rb_iseq_t *local_iseq = iseq->local_iseq; + rb_num_t cnt; + VALUE key; + + cnt = local_iseq->flip_cnt++ + DEFAULT_SPECIAL_VAR_COUNT; + key = INT2FIX(cnt); - hide_obj(key); - iseq_add_mark_object_compile_time(iseq, key); ADD_INSN2(ret, nd_line(node), getspecial, key, INT2FIX(0)); ADD_INSNL(ret, nd_line(node), branchif, lend); @@ -1,11 +1,9 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68. +# Generated by GNU Autoconf 2.69. # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -134,6 +132,31 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -167,7 +190,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -212,21 +236,25 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -328,6 +356,14 @@ $as_echo X"$as_dir" | } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -449,6 +485,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -483,16 +523,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -504,28 +544,8 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -623,6 +643,7 @@ RI_BASE_NAME ridir rubylibprefix MAKEFILES +PLATFORM_DIR THREAD_MODEL MINIOBJS SYMBOL_PREFIX @@ -647,6 +668,7 @@ rubyw_install_name RUBY_INSTALL_NAME LIBRUBY_DLDFLAGS LIBRUBY_LDSHARED +EXTDLDFLAGS XLDFLAGS XCFLAGS warnflags @@ -690,6 +712,7 @@ ARCH_FLAG DLDFLAGS ALLOCA LIBOBJS +POSTLINK WERRORFLAG CHDIR RMALL @@ -802,6 +825,7 @@ with_baseruby with_gcc with_arch enable_load_relative +enable_werror enable_largefile enable_win95 enable_pthread @@ -831,6 +855,7 @@ with_vendorhdrdir with_opt_dir with_mantype enable_rubygems +with_ruby_pc ' ac_precious_vars='build_alias host_alias @@ -1299,8 +1324,6 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1464,6 +1487,9 @@ Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-load-relative resolve load paths at run time + --disable-werror don't make warnings into errors even if a compiler + support -Werror feature [[disabled by default unless + development version]] --disable-largefile omit support for large files --enable-win95 enable Windows 95 series support --enable-pthread obsolete, and ignored @@ -1511,8 +1537,10 @@ Optional Packages: --with-sitehdrdir=DIR core site headers in DIR [[RUBYHDRDIR/site_ruby]] --with-vendorhdrdir=DIR core vendor headers in DIR [[RUBYHDRDIR/vendor_ruby]] - --with-opt-dir=DIR add optional headers and libraries DIR + --with-opt-dir=DIR-LIST add optional headers and libraries directories + separated by $PATH_SEPARATOR --with-mantype=TYPE specify man page type; TYPE is one of man and doc + pc file basename Some influential environment variables: CC C compiler command @@ -1593,9 +1621,9 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure -generated by GNU Autoconf 2.68 +generated by GNU Autoconf 2.69 -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1746,7 +1774,7 @@ $as_echo "$ac_try_echo"; } >&5 test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext + test -x conftest$ac_exeext }; then : ac_retval=0 else @@ -1996,7 +2024,8 @@ int main () { static int test_array [1 - 2 * !(($2) >= 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2012,7 +2041,8 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2038,7 +2068,8 @@ int main () { static int test_array [1 - 2 * !(($2) < 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2054,7 +2085,8 @@ int main () { static int test_array [1 - 2 * !(($2) >= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2088,7 +2120,8 @@ int main () { static int test_array [1 - 2 * !(($2) <= $ac_mid)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -2331,7 +2364,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2753,6 +2786,7 @@ RUBY_PROGRAM_VERSION=`sed -n 's/^#define RUBY_VERSION "\(.*\)"/\1/p' $srcdir/ver RUBY_RELEASE_DATE=`sed -n 's/^#define RUBY_RELEASE_DATE "\(.*\)"/\1/p' $srcdir/version.h` +RUBY_PATCHLEVEL=`sed -n 's/^#define RUBY_PATCHLEVEL //p' $srcdir/version.h` if test "$MAJOR" = "1"; then $as_echo "#define CANONICALIZATION_FOR_MATHN 1" >>confdefs.h @@ -2991,7 +3025,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3031,7 +3065,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3089,7 +3123,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3129,7 +3163,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3182,7 +3216,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3223,7 +3257,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3281,7 +3315,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3325,7 +3359,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3771,8 +3805,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdarg.h> #include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3885,7 +3918,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3929,7 +3962,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CXX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4269,7 +4302,7 @@ do for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -4335,7 +4368,7 @@ do for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -4708,7 +4741,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4748,7 +4781,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4800,7 +4833,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="${ac_tool_prefix}ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4840,7 +4873,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="ar" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4894,7 +4927,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4938,7 +4971,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AS="${ac_tool_prefix}as" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4978,7 +5011,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AS="as" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5043,7 +5076,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5087,7 +5120,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5143,7 +5176,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJCOPY="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5187,7 +5220,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJCOPY="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5245,7 +5278,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_WINDRES="${ac_tool_prefix}windres" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5285,7 +5318,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_WINDRES="windres" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5337,7 +5370,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLWRAP="${ac_tool_prefix}dllwrap" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5377,7 +5410,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLWRAP="dllwrap" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5486,7 +5519,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NM="${ac_tool_prefix}nm" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5527,7 +5560,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NM="nm" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5585,7 +5618,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NM="${ac_tool_prefix}nm" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5625,7 +5658,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NM="nm" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5740,7 +5773,7 @@ case $as_dir/ in #(( # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -5809,7 +5842,7 @@ do test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ @@ -5867,7 +5900,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DOT="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5909,7 +5942,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DOXYGEN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5951,7 +5984,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "`"$as_dir/$ac_word$ac_exec_ext" --print-errors --version > /dev/null 2>&1 || echo "$as_dir/$ac_word$ac_exec_ext"`"; then ac_prog_rejected=yes continue @@ -6149,8 +6182,8 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# define __EXTENSIONS__ 1 - $ac_includes_default +# define __EXTENSIONS__ 1 + $ac_includes_default int main () { @@ -6224,35 +6257,45 @@ $as_echo "$CHDIR" >&6; } +case $RUBY_PATCHLEVEL in #( + -*) : + particular_werror_flags=yes ;; #( + *) : + particular_werror_flags=no ;; +esac +# Check whether --enable-werror was given. +if test "${enable_werror+set}" = set; then : + enableval=$enable_werror; particular_werror_flags=$enableval +fi + + rb_cv_warnflags="$warnflags" if test "$GCC:${warnflags+set}:no" = yes::no; then - particular_werror_flags=yes for wflag in -Wno-unused-parameter -Wno-parentheses -Wno-long-long \ -Wno-missing-field-initializers \ -Werror=pointer-arith \ -Werror=write-strings \ -Werror=declaration-after-statement \ -Werror=shorten-64-to-32 \ - -Werror-implicit-function-declaration \ + -Werror=implicit-function-declaration \ ; do - if test "$particular_werror_flags" = yes; then - wflag=`echo x$wflag | sed 's/^x-Werror-/-Werror=/;s/^x//'` - else + if test "$particular_werror_flags" != yes; then wflag=`echo x$wflag | sed 's/^x-Werror=/-W/;s/^x//'` fi ok=no - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $wflag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $wflag is accepted" >&5 $as_echo_n "checking whether $wflag is accepted... " >&6; } - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag fi ac_c_werror_flag=yes + CFLAGS="$CFLAGS $wflag" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6275,30 +6318,31 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else unset ac_c_werror_flag fi - CFLAGS="$save_CFLAGS" - save_CFLAGS= case $ok:$wflag in #( no:-Werror=*) : wflag=`echo x$wflag | sed 's/^x-Werror=/-W/'` - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $wflag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $wflag is accepted" >&5 $as_echo_n "checking whether $wflag is accepted... " >&6; } - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag fi ac_c_werror_flag=yes + CFLAGS="$CFLAGS $wflag" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6324,13 +6368,13 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else unset ac_c_werror_flag fi - CFLAGS="$save_CFLAGS" - save_CFLAGS= ;; #( *) : @@ -6339,22 +6383,23 @@ esac done case " $warnflags " in #( *" -Wno-missing-field-initializers "*) : - wflag=-Wextra ;; #( + wflag="-Wall -Wextra" ;; #( *) : wflag=-Wall ;; esac - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $wflag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $wflag is accepted" >&5 $as_echo_n "checking whether $wflag is accepted... " >&6; } - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag fi ac_c_werror_flag=yes + CFLAGS="$CFLAGS $wflag" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6377,13 +6422,13 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else unset ac_c_werror_flag fi - CFLAGS="$save_CFLAGS" - save_CFLAGS= # Disable warnflags while conftest. -Werror=* flags might make bad OS capability guess. rb_cv_warnflags="$warnflags" @@ -6391,17 +6436,18 @@ fi fi if test "$GCC" = yes; then test "${debugflags+set}" || { - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -ggdb" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -ggdb is accepted" >&5 $as_echo_n "checking whether -ggdb is accepted... " >&6; } - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag fi ac_c_werror_flag=yes + CFLAGS="$CFLAGS -ggdb" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6424,26 +6470,27 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else unset ac_c_werror_flag fi - CFLAGS="$save_CFLAGS" - save_CFLAGS= } test "${debugflags+set}" || { - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -g3" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -g3 is accepted" >&5 $as_echo_n "checking whether -g3 is accepted... " >&6; } - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag fi ac_c_werror_flag=yes + CFLAGS="$CFLAGS -g3" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6466,13 +6513,13 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else unset ac_c_werror_flag fi - CFLAGS="$save_CFLAGS" - save_CFLAGS= } fi test $ac_cv_prog_cc_g = yes && : ${debugflags=-g} @@ -6486,18 +6533,41 @@ if test "$GCC" = ""; then esac fi if test "$GCC" = yes; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + + #if !(defined __GNUC__ && __GNUC__ >= 4) + #error not GCC 4 or later + >>>not GCC 4 or later<<< + #endif +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + visibility_option=yes +else + visibility_option=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test "$visibility_option" = yes; then - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fvisibility=hidden" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -fvisibility=hidden is accepted" >&5 $as_echo_n "checking whether -fvisibility=hidden is accepted... " >&6; } - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag fi ac_c_werror_flag=yes + CFLAGS="$CFLAGS -fvisibility=hidden" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6510,32 +6580,25 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - # RUBY_APPEND_OPTION(XCFLAGS, -fvisibility=hidden) - case " ${XCFLAGS-} " in #( - *' -fvisibility=hidden '*) : - ;; #( - ' ') : - XCFLAGS="-fvisibility=hidden" ;; #( - *) : - XCFLAGS="$XCFLAGS -fvisibility=hidden" ;; -esac + visibility_option=yes { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } else - + visibility_option=no { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else unset ac_c_werror_flag fi - CFLAGS="$save_CFLAGS" - save_CFLAGS= + fi WERRORFLAG="-Werror" if test "$visibility_option" = yes; then @@ -6554,7 +6617,9 @@ esac LDFLAGS="$LDFLAGS -Wl,-unexported_symbol,_Init_*" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -Wl,-unexported_symbol,_Init_* is accepted" >&5 $as_echo_n "checking whether -Wl,-unexported_symbol,_Init_* is accepted... " >&6; } - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag @@ -6584,6 +6649,8 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -6601,17 +6668,18 @@ if test "$GCC" = yes; then mingw*) : - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -fno-omit-frame-pointer" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -fno-omit-frame-pointer is accepted" >&5 $as_echo_n "checking whether -fno-omit-frame-pointer is accepted... " >&6; } - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag fi ac_c_werror_flag=yes + CFLAGS="$CFLAGS -fno-omit-frame-pointer" cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -6634,13 +6702,13 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else unset ac_c_werror_flag fi - CFLAGS="$save_CFLAGS" - save_CFLAGS= ;; #( *) : @@ -6849,6 +6917,8 @@ _ACEOF esac rm -rf conftest* fi + + fi mv confdefs.h largefile.h @@ -7097,11 +7167,11 @@ else int main () { -/* FIXME: Include the comments suggested by Paul. */ + #ifndef __cplusplus - /* Ultrix mips cc rejects this. */ + /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; - const charset cs; + const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -7118,8 +7188,9 @@ main () ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -7135,10 +7206,10 @@ main () iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this saying + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -7178,7 +7249,8 @@ int main () { static int test_array [1 - 2 * !(((char) -1) < 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -7356,7 +7428,8 @@ int main () { static int test_array [1 - 2 * !(!HAVE_INT)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -7374,7 +7447,8 @@ int main () { static int test_array [1 - 2 * !(HAVE_INT == (SIZEOF_INT == ($[s / rb_cv_char_bit])))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -7595,7 +7669,8 @@ int main () { static int test_array [1 - 2 * !(SIZEOF_LONG == sizeof($t))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -7629,7 +7704,8 @@ int main () { static int test_array [1 - 2 * !(!HAVE_LONG)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -7647,7 +7723,8 @@ int main () { static int test_array [1 - 2 * !(HAVE_LONG == (SIZEOF_LONG == ($[s / rb_cv_char_bit])))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -8064,7 +8141,8 @@ int main () { static int test_array [1 - 2 * !(SIZEOF_VOIDP == sizeof($t))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -8098,7 +8176,8 @@ int main () { static int test_array [1 - 2 * !(!HAVE_VOIDP)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -8116,7 +8195,8 @@ int main () { static int test_array [1 - 2 * !(HAVE_VOIDP == (SIZEOF_VOIDP == ($[s / rb_cv_char_bit])))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -8435,7 +8515,8 @@ int main () { static int test_array [1 - 2 * !(SIZEOF_TIME_T == sizeof($t))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -8551,7 +8632,9 @@ if ${rb_cv_pri_prefix_long_long+:} false; then : else rb_cv_pri_prefix_long_long=NONE - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag @@ -8583,6 +8666,8 @@ if ac_fn_c_try_compile "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -8607,7 +8692,9 @@ if ${rb_cv_pri_prefix___int64+:} false; then : else rb_cv_pri_prefix___int64=NONE - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag @@ -8639,6 +8726,8 @@ if ac_fn_c_try_compile "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -8686,7 +8775,8 @@ int main () { static int test_array [1 - 2 * !(($n)-1 > 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -8714,7 +8804,8 @@ int main () { static int test_array [1 - 2 * !(sizeof(rbcv_conftest_target_type) == sizeof(rbcv_conftest_replace_type))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -8788,7 +8879,8 @@ int main () { static int test_array [1 - 2 * !(($n)-1 > 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -8816,7 +8908,8 @@ int main () { static int test_array [1 - 2 * !(sizeof(rbcv_conftest_target_type) == sizeof(rbcv_conftest_replace_type))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -8890,7 +8983,8 @@ int main () { static int test_array [1 - 2 * !(($n)-1 > 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -8918,7 +9012,8 @@ int main () { static int test_array [1 - 2 * !(sizeof(rbcv_conftest_target_type) == sizeof(rbcv_conftest_replace_type))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -8994,7 +9089,8 @@ int main () { static int test_array [1 - 2 * !(($n)-1 > 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -9023,7 +9119,8 @@ int main () { static int test_array [1 - 2 * !(sizeof(rbcv_conftest_target_type) == sizeof(rbcv_conftest_replace_type))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -9097,7 +9194,8 @@ int main () { static int test_array [1 - 2 * !(($n)-1 > 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -9125,7 +9223,8 @@ int main () { static int test_array [1 - 2 * !(sizeof(rbcv_conftest_target_type) == sizeof(rbcv_conftest_replace_type))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -9201,7 +9300,8 @@ int main () { static int test_array [1 - 2 * !(($n)-1 > 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -9230,7 +9330,8 @@ int main () { static int test_array [1 - 2 * !(sizeof(rbcv_conftest_target_type) == sizeof(rbcv_conftest_replace_type))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -9306,7 +9407,8 @@ int main () { static int test_array [1 - 2 * !(($n)-1 > 0)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -9335,7 +9437,8 @@ int main () { static int test_array [1 - 2 * !(sizeof(rbcv_conftest_target_type) == sizeof(rbcv_conftest_replace_type))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -9466,7 +9569,8 @@ int main () { static int test_array [1 - 2 * !(sizeof(stringized) == 32)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -9511,7 +9615,8 @@ int main () { static int test_array [1 - 2 * !(sizeof(concatenated_literal) == 26)]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -9615,6 +9720,8 @@ if ${rb_cv_func_noreturn+:} false; then : $as_echo_n "(cached) " >&6 else rb_cv_func_noreturn=x +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else @@ -9644,6 +9751,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -9675,6 +9784,8 @@ if ${rb_cv_func_deprecated+:} false; then : $as_echo_n "(cached) " >&6 else rb_cv_func_deprecated=x +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else @@ -9704,6 +9815,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -9735,6 +9848,8 @@ if ${rb_cv_func_noinline+:} false; then : $as_echo_n "(cached) " >&6 else rb_cv_func_noinline=x +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else @@ -9764,6 +9879,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -9797,6 +9914,8 @@ if ${rb_cv_func_stdcall+:} false; then : $as_echo_n "(cached) " >&6 else rb_cv_func_stdcall=x +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else @@ -9828,6 +9947,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -9859,6 +9980,8 @@ if ${rb_cv_func_cdecl+:} false; then : $as_echo_n "(cached) " >&6 else rb_cv_func_cdecl=x +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else @@ -9890,6 +10013,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -9921,6 +10046,8 @@ if ${rb_cv_func_fastcall+:} false; then : $as_echo_n "(cached) " >&6 else rb_cv_func_fastcall=x +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else @@ -9952,6 +10079,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -10061,6 +10190,8 @@ if ${rb_cv_func_exported+:} false; then : else rb_cv_func_exported=no +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else @@ -10087,6 +10218,8 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -10189,6 +10322,8 @@ case "$target_os" in #( ac_cv_func_daemon=no ;; esac +POSTLINK=: + case "$target_os" in #( solaris*) : @@ -10531,7 +10666,7 @@ esac ;; #( mingw*) : - LIBS="-lshell32 -lws2_32 -limagehlp $LIBS" + LIBS="-lshell32 -lws2_32 -limagehlp -lshlwapi $LIBS" ac_cv_header_a_out_h=no ac_cv_header_pwd_h=no ac_cv_header_utime_h=no @@ -10561,6 +10696,7 @@ esac ac_cv_func_fcntl=yes ac_cv_func_flock=yes rb_cv_large_fd_select=yes + ac_cv_type_struct_timeval=yes case " $LIBOBJS " in *" langinfo.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS langinfo.$ac_objext" @@ -11074,60 +11210,60 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include <stdbool.h> -#ifndef bool - "error: bool is not defined" -#endif -#ifndef false - "error: false is not defined" -#endif -#if false - "error: false is not 0" -#endif -#ifndef true - "error: true is not defined" -#endif -#if true != 1 - "error: true is not 1" -#endif -#ifndef __bool_true_false_are_defined - "error: __bool_true_false_are_defined is not defined" -#endif - - struct s { _Bool s: 1; _Bool t; } s; - - char a[true == 1 ? 1 : -1]; - char b[false == 0 ? 1 : -1]; - char c[__bool_true_false_are_defined == 1 ? 1 : -1]; - char d[(bool) 0.5 == true ? 1 : -1]; - /* See body of main program for 'e'. */ - char f[(_Bool) 0.0 == false ? 1 : -1]; - char g[true]; - char h[sizeof (_Bool)]; - char i[sizeof s.t]; - enum { j = false, k = true, l = false * true, m = true * 256 }; - /* The following fails for - HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ - _Bool n[m]; - char o[sizeof n == m * sizeof n[0] ? 1 : -1]; - char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; - /* Catch a bug in an HP-UX C compiler. See - http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html - http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html - */ - _Bool q = true; - _Bool *pq = &q; + #include <stdbool.h> + #ifndef bool + "error: bool is not defined" + #endif + #ifndef false + "error: false is not defined" + #endif + #if false + "error: false is not 0" + #endif + #ifndef true + "error: true is not defined" + #endif + #if true != 1 + "error: true is not 1" + #endif + #ifndef __bool_true_false_are_defined + "error: __bool_true_false_are_defined is not defined" + #endif + + struct s { _Bool s: 1; _Bool t; } s; + + char a[true == 1 ? 1 : -1]; + char b[false == 0 ? 1 : -1]; + char c[__bool_true_false_are_defined == 1 ? 1 : -1]; + char d[(bool) 0.5 == true ? 1 : -1]; + /* See body of main program for 'e'. */ + char f[(_Bool) 0.0 == false ? 1 : -1]; + char g[true]; + char h[sizeof (_Bool)]; + char i[sizeof s.t]; + enum { j = false, k = true, l = false * true, m = true * 256 }; + /* The following fails for + HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */ + _Bool n[m]; + char o[sizeof n == m * sizeof n[0] ? 1 : -1]; + char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1]; + /* Catch a bug in an HP-UX C compiler. See + http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html + http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html + */ + _Bool q = true; + _Bool *pq = &q; int main () { - bool e = &s; - *pq |= q; - *pq |= ! q; - /* Refer to every declared value, to avoid compiler optimizations. */ - return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l - + !m + !n + !o + !p + !q + !pq); + bool e = &s; + *pq |= q; + *pq |= ! q; + /* Refer to every declared value, to avoid compiler optimizations. */ + return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l + + !m + !n + !o + !p + !q + !pq); ; return 0; @@ -11142,7 +11278,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5 $as_echo "$ac_cv_header_stdbool_h" >&6; } -ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" + ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default" if test "x$ac_cv_type__Bool" = xyes; then : cat >>confdefs.h <<_ACEOF @@ -11152,6 +11288,7 @@ _ACEOF fi + if test $ac_cv_header_stdbool_h = yes; then $as_echo "#define HAVE_STDBOOL_H 1" >>confdefs.h @@ -11204,7 +11341,7 @@ for ac_header in limits.h sys/file.h sys/ioctl.h sys/syscall.h\ syscall.h pwd.h grp.h a.out.h utime.h direct.h sys/resource.h \ sys/mkdev.h sys/utime.h xti.h netinet/in_systm.h float.h ieeefp.h \ ucontext.h intrinsics.h langinfo.h locale.h sys/sendfile.h time.h \ - net/socket.h sys/socket.h process.h + net/socket.h sys/socket.h process.h atomic.h do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" @@ -11253,7 +11390,8 @@ int main () { static int test_array [1 - 2 * !(SIZEOF_SIZE_T == sizeof($t))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -11381,7 +11519,8 @@ int main () { static int test_array [1 - 2 * !(SIZEOF_PTRDIFF_T == sizeof($t))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -11493,7 +11632,9 @@ if ${rb_cv_pri_prefix_size_t+:} false; then : else rb_cv_pri_prefix_size_t=NONE - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag @@ -11525,6 +11666,8 @@ if ac_fn_c_try_compile "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -11548,7 +11691,9 @@ if ${rb_cv_pri_prefix_ptrdiff_t+:} false; then : else rb_cv_pri_prefix_ptrdiff_t=NONE - if test "${ac_c_werror_flag+set}"; then + save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" +if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else unset rb_c_werror_flag @@ -11580,6 +11725,8 @@ if ac_fn_c_try_compile "$LINENO"; then : fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -11665,7 +11812,8 @@ int main () { static int test_array [1 - 2 * !(SIZEOF_STRUCT_STAT_ST_SIZE == sizeof($t))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -11759,7 +11907,8 @@ int main () { static int test_array [1 - 2 * !(SIZEOF_STRUCT_STAT_ST_BLOCKS == sizeof($t))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -11920,6 +12069,23 @@ _ACEOF fi +ac_fn_c_check_type "$LINENO" "struct timeval" "ac_cv_type_struct_timeval" "#ifdef HAVE_TIME_H +#include <time.h> +#endif +#ifdef HAVE_SYS_TIME_H +#include <sys/time.h> +#endif +" +if test "x$ac_cv_type_struct_timeval" = xyes; then : + +cat >>confdefs.h <<_ACEOF +#define HAVE_STRUCT_TIMEVAL 1 +_ACEOF + + +fi + + ac_fn_c_check_type "$LINENO" "struct timespec" "ac_cv_type_struct_timespec" "#ifdef HAVE_TIME_H #include <time.h> #endif @@ -12966,7 +13132,8 @@ int main () { static int test_array [1 - 2 * !(SIZEOF_INTPTR_T == sizeof($t))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -13151,7 +13318,8 @@ int main () { static int test_array [1 - 2 * !(SIZEOF_UINTPTR_T == sizeof($t))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -13338,7 +13506,8 @@ int main () { static int test_array [1 - 2 * !(SIZEOF_SSIZE_T == sizeof($t))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -13490,85 +13659,6 @@ _ACEOF fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gc_mark and gc_children stack frame approximate size(word)" >&5 -$as_echo_n "checking for gc_mark and gc_children stack frame approximate size(word)... " >&6; } -if ${rb_cv_gc_mark_stackframe_word+:} false; then : - $as_echo_n "(cached) " >&6 -else - save_CFLAGS="$CFLAGS" -CFLAGS="-O0" -if test "$cross_compiling" = yes; then : - rb_cv_gc_mark_stackframe_word="30" -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int word; -char *stack_start; - -void -set_stackframe_word() -{ - int dumy = 42; - int diff; - - if (stack_start < (char *)&dumy) { - diff = (int)((char *)&dumy - stack_start); - } - else { - diff = (int)(stack_start - (char *)&dumy); - } - word = (diff/sizeof(void *)); - if ((diff % sizeof(void *)) != 0) { - word++; - } -} - -void -gc_mark_children(void *p1, void *p2, int lev) -{ - void *obj = p2; - - set_stackframe_word(p1,p2,lev); -} - -void -gc_mark(void *p1, void *p2, int lev) -{ - void *obj = p2; - - gc_mark_children(p1,p2,lev++); -} - -int -main() { - int dumy = 42; - - stack_start = (char *)&dumy; - gc_mark(0, 0, 255); - return word; -} - -_ACEOF -if ac_fn_c_try_run "$LINENO"; then : - rb_cv_gc_mark_stackframe_word="$?" -else - rb_cv_gc_mark_stackframe_word="$?" -fi -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ - conftest.$ac_objext conftest.beam conftest.$ac_ext -fi - -CFLAGS="$save_CFLAGS" -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $rb_cv_gc_mark_stackframe_word" >&5 -$as_echo "$rb_cv_gc_mark_stackframe_word" >&6; } -cat >>confdefs.h <<_ACEOF -#define GC_MARK_STACKFRAME_WORD $rb_cv_gc_mark_stackframe_word -_ACEOF - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5 $as_echo_n "checking for uid_t in sys/types.h... " >&6; } if ${ac_cv_type_uid_t+:} false; then : @@ -13893,23 +13983,20 @@ else /* end confdefs.h. */ $ac_includes_default int -find_stack_direction () +find_stack_direction (int *addr, int depth) { - static char *addr = 0; - auto char dummy; - if (addr == 0) - { - addr = &dummy; - return find_stack_direction (); - } - else - return (&dummy > addr) ? 1 : -1; + int dir, dummy = 0; + if (! addr) + addr = &dummy; + *addr = addr < &dummy ? 1 : addr == &dummy ? 0 : -1; + dir = depth ? find_stack_direction (addr, depth - 1) : 0; + return dir + dummy; } int -main () +main (int argc, char **argv) { - return find_stack_direction () < 0; + return find_stack_direction (0, argc + !argv + 20) < 0; } _ACEOF if ac_fn_c_try_run "$LINENO"; then : @@ -15229,7 +15316,8 @@ int main () { static int test_array [1 - 2 * !((-1==(-1>>1)))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -15386,7 +15474,8 @@ int main () { static int test_array [1 - 2 * !(SIZEOF_STRUCT_STAT_ST_INO == sizeof($t))]; -test_array [0] = 0 +test_array [0] = 0; +return test_array [0]; ; return 0; @@ -16228,7 +16317,7 @@ esac ;; #( aix*) : : ${LDSHARED='$(CC)'} LDSHARED="$LDSHARED ${linker_flag}-G" - DLDFLAGS='-eInit_$(TARGET)' + EXTDLDFLAGS='-e$(TARGET_ENTRY)' XLDFLAGS="${linker_flag}"'-bE:$(ARCHFILE)'" ${linker_flag}-brtl" XLDFLAGS="$XLDFLAGS ${linker_flag}-blibpath:${prefix}/lib:${LIBPATH:-/usr/lib:/lib}" : ${ARCHFILE="ruby.imp"} @@ -16248,7 +16337,8 @@ esac ;; #( powerpc*) : : ${LDSHARED="ld -xms"} - DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o' + EXTDLDFLAGS='-export $(TARGET_ENTRY)' + DLDFLAGS="$DLDFLAGS -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o" LDFLAGS="$LDFLAGS -L/boot/home/config/lib -lbe -lroot" ;; #( i586*) : @@ -16267,7 +16357,8 @@ esac powerpc*) : : ${LDSHARED="ld -xms"} - DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o' + EXTDLDFLAGS='-export $(TARGET_ENTRY)' + DLDFLAGS="$DLDFLAGS -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o" ;; #( i586*) : @@ -16474,7 +16565,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -16514,7 +16605,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -16690,6 +16781,21 @@ case "$enable_shared" in #( if test "$rb_cv_binary_elf" = yes; then SOLIBS='$(LIBS)' fi + # libdir can be overridden in config.site file (on OpenSUSE at least). + libdir_basename=lib + if test "$bindir" = '${exec_prefix}/bin'; then + case "$libdir" in #( + '${exec_prefix}/'*) : + libdir_basename=`basename "$libdir"` ;; #( + *) : + ;; +esac + fi + cat >>confdefs.h <<_ACEOF +#define LIBDIR_BASENAME "${libdir_basename}" +_ACEOF + + case "$target_os" in #( sunos4*) : @@ -16700,7 +16806,7 @@ case "$enable_shared" in #( LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)' LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' if test "$load_relative" = yes; then - LIBRUBY_RPATHFLAGS="'-Wl,-rpath,\$\${ORIGIN}/../lib'" + LIBRUBY_RPATHFLAGS="'-Wl,-rpath,\$\${ORIGIN}/../${libdir_basename}'" LIBRUBY_RELATIVE=yes fi ;; #( @@ -16769,7 +16875,7 @@ esac RUBY_SO_NAME="$RUBY_SO_NAME"'.$(MAJOR).$(MINOR).$(TEENY)' LIBRUBY_LDSHARED='$(CC) -dynamiclib' if test "$load_relative" = yes; then - libprefix='@executable_path/../lib' + libprefix="@executable_path/../${libdir_basename}" LIBRUBY_RELATIVE=yes fi LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-install_name '${libprefix}'/$(LIBRUBY_SO)' @@ -17039,8 +17145,14 @@ esac EXPORT_PREFIX=' ' DLDFLAGS="${DLDFLAGS}"' $(DEFFILE)' case " $LIBOBJS " in - *" win32.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS win32.$ac_objext" + *" win32/win32.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS win32/win32.$ac_objext" + ;; +esac + + case " $LIBOBJS " in + *" win32/file.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS win32/file.$ac_objext" ;; esac @@ -17048,6 +17160,7 @@ esac # COMMON_MACROS="WIN32_LEAN_AND_MEAN=" COMMON_HEADERS="winsock2.h windows.h" THREAD_MODEL=win32 + PLATFORM_DIR=win32 ;; #( *) : ;; @@ -17285,6 +17398,7 @@ cxxflags="$orig_cxxflags "'${optflags} ${debugflags} ${warnflags}' + MAKEFILES="Makefile `echo $FIRSTMAKEFILE | sed 's/:.*//'`" MAKEFILES="`echo $MAKEFILES`" @@ -17614,6 +17728,17 @@ fi # Check whether --with-opt-dir was given. if test "${with_opt_dir+set}" = set; then : withval=$with_opt_dir; + CPPFLAGS="$CPPFLAGS `echo \"$PATH_SEPARATOR$withval\" | sed \"s|$PATH_SEPARATOR\([^$PATH_SEPARATOR]*\)| -I\1/include|g;s/^ //\"`" + set -x + val=`IFS="$PATH_SEPARATOR" + for dir in $withval; do + echo x ${LIBPATHFLAG} ${RPATHFLAG} | + sed -E 's/^x *//;s'"${PATH_SEPARATOR}"'%1\\$-s|%s'"${IFS}${dir}/lib${IFS}g" + done | tr '\012' ' '` + set +x + LDFLAGS="$LDFLAGS${LDFLAGS:+ }$val" + DLDFLAGS="$DLDFLAGS${DLDFLAGS:+ }$val" + fi @@ -17652,7 +17777,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_NROFF="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -17752,7 +17877,14 @@ ac_config_files="$ac_config_files $FIRSTMAKEFILE" ac_config_files="$ac_config_files Makefile" -ruby_pc="${RUBY_BASE_NAME}-${MAJOR}.${MINOR}.pc" + +# Check whether --with-ruby-pc was given. +if test "${with_ruby_pc+set}" = set; then : + withval=$with_ruby_pc; ruby_pc="$withval" +else + ruby_pc="${RUBY_BASE_NAME}-${MAJOR}.${MINOR}.pc" +fi + exec=exec @@ -18204,16 +18336,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -18273,28 +18405,16 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -18316,7 +18436,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # values after options handling. ac_log=" This file was extended by $as_me, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -18369,10 +18489,10 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ config.status -configured by $0, generated by GNU Autoconf 2.68, +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -18451,7 +18571,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' diff --git a/configure.in b/configure.in index 6d24689..7453c91 100644 --- a/configure.in +++ b/configure.in @@ -83,6 +83,7 @@ RUBY_PROGRAM_VERSION=`sed -n 's/^#define RUBY_VERSION "\(.*\)"/\1/p' $srcdir/ver AC_SUBST(RUBY_PROGRAM_VERSION) RUBY_RELEASE_DATE=`sed -n 's/^#define RUBY_RELEASE_DATE "\(.*\)"/\1/p' $srcdir/version.h` AC_SUBST(RUBY_RELEASE_DATE) +RUBY_PATCHLEVEL=`sed -n 's/^#define RUBY_PATCHLEVEL //p' $srcdir/version.h` if test "$MAJOR" = "1"; then AC_DEFINE(CANONICALIZATION_FOR_MATHN) fi @@ -409,6 +410,8 @@ dnl } dnl compiler section { AC_DEFUN([RUBY_WERROR_FLAG], [dnl +save_CFLAGS="$CFLAGS" +CFLAGS="$CFLAGS $rb_cv_warnflags" if test "${ac_c_werror_flag+set}"; then rb_c_werror_flag="$ac_c_werror_flag" else @@ -416,6 +419,8 @@ else fi ac_c_werror_flag=yes $1 +CFLAGS="$save_CFLAGS" +save_CFLAGS= if test "${rb_c_werror_flag+set}"; then ac_c_werror_flag="$rb_c_werror_flag" else @@ -423,18 +428,15 @@ else fi]) AC_DEFUN(RUBY_TRY_CFLAGS, [ - save_CFLAGS="$CFLAGS" - CFLAGS="[$]CFLAGS $1" AC_MSG_CHECKING([whether ]$1[ is accepted]) RUBY_WERROR_FLAG([ + CFLAGS="[$]CFLAGS $1" AC_TRY_COMPILE([$4], [$5], [$2 AC_MSG_RESULT(yes)], [$3 AC_MSG_RESULT(no)]) ]) - CFLAGS="$save_CFLAGS" - save_CFLAGS= ]) AC_DEFUN(RUBY_TRY_LDFLAGS, [ @@ -452,20 +454,26 @@ AC_DEFUN(RUBY_TRY_LDFLAGS, [ save_LDFLAGS= ]) +AS_CASE([$RUBY_PATCHLEVEL], [-*], + [particular_werror_flags=yes], [particular_werror_flags=no]) +AC_ARG_ENABLE(werror, + AS_HELP_STRING([--disable-werror], + [don't make warnings into errors + even if a compiler support -Werror feature + [[disabled by default unless development version]]]), + [particular_werror_flags=$enableval]) + rb_cv_warnflags="$warnflags" if test "$GCC:${warnflags+set}:no" = yes::no; then - particular_werror_flags=yes for wflag in -Wno-unused-parameter -Wno-parentheses -Wno-long-long \ -Wno-missing-field-initializers \ -Werror=pointer-arith \ -Werror=write-strings \ -Werror=declaration-after-statement \ -Werror=shorten-64-to-32 \ - -Werror-implicit-function-declaration \ + -Werror=implicit-function-declaration \ ; do - if test "$particular_werror_flags" = yes; then - wflag=`echo x$wflag | sed 's/^x-Werror-/-Werror=/;s/^x//'` - else + if test "$particular_werror_flags" != yes; then wflag=`echo x$wflag | sed 's/^x-Werror=/-W/;s/^x//'` fi ok=no @@ -478,7 +486,7 @@ if test "$GCC:${warnflags+set}:no" = yes::no; then ]) ]) done - AS_CASE([" $warnflags "],[*" -Wno-missing-field-initializers "*], [wflag=-Wextra], + AS_CASE([" $warnflags "],[*" -Wno-missing-field-initializers "*], [wflag="-Wall -Wextra"], [wflag=-Wall]) RUBY_TRY_CFLAGS($wflag, [warnflags="$wflag${warnflags+ $warnflags}"]) # Disable warnflags while conftest. -Werror=* flags might make bad OS capability guess. @@ -495,7 +503,15 @@ if test "$GCC" = ""; then AS_CASE(["$target_os"],[aix*],[warnflags="-qinfo=por"]) fi if test "$GCC" = yes; then - RUBY_TRY_CFLAGS(-fvisibility=hidden, [RUBY_APPEND_OPTION(XCFLAGS, -fvisibility=hidden)]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ + @%:@if !(defined __GNUC__ && __GNUC__ >= 4) + @%:@error not GCC 4 or later + >>>not GCC 4 or later<<< + @%:@endif])], + [visibility_option=yes], [visibility_option=no]) + if test "$visibility_option" = yes; then + RUBY_TRY_CFLAGS(-fvisibility=hidden, [visibility_option=yes], [visibility_option=no]) + fi AC_SUBST(WERRORFLAG, "-Werror") if test "$visibility_option" = yes; then RUBY_APPEND_OPTION(XCFLAGS, -fvisibility=hidden) @@ -939,6 +955,8 @@ AC_ARG_ENABLE(pthread, dnl Checks for libraries. AS_CASE(["$target_os"],[*bsd*|dragonfly*],[],[ac_cv_func_daemon=no]) +POSTLINK=: +AC_SUBST(POSTLINK) AS_CASE(["$target_os"], [solaris*], [ AC_DEFINE(SIZEOF_STRUCT_DIRENT_TOO_SMALL, 1) @@ -1059,7 +1077,7 @@ main() AC_CHECK_FUNCS(cygwin_conv_path) AC_LIBOBJ([langinfo]) ], -[mingw*], [ LIBS="-lshell32 -lws2_32 -limagehlp $LIBS" +[mingw*], [ LIBS="-lshell32 -lws2_32 -limagehlp -lshlwapi $LIBS" ac_cv_header_a_out_h=no ac_cv_header_pwd_h=no ac_cv_header_utime_h=no @@ -1089,6 +1107,7 @@ main() ac_cv_func_fcntl=yes ac_cv_func_flock=yes rb_cv_large_fd_select=yes + ac_cv_type_struct_timeval=yes AC_LIBOBJ([langinfo]) : ${enable_win95=maybe} ], @@ -1159,7 +1178,7 @@ AC_CHECK_HEADERS(limits.h sys/file.h sys/ioctl.h sys/syscall.h\ syscall.h pwd.h grp.h a.out.h utime.h direct.h sys/resource.h \ sys/mkdev.h sys/utime.h xti.h netinet/in_systm.h float.h ieeefp.h \ ucontext.h intrinsics.h langinfo.h locale.h sys/sendfile.h time.h \ - net/socket.h sys/socket.h process.h) + net/socket.h sys/socket.h process.h atomic.h) AC_TYPE_SIZE_T RUBY_CHECK_SIZEOF(size_t, [int long void*], [], [@%:@include <sys/types.h>]) @@ -1183,6 +1202,13 @@ AC_CHECK_MEMBERS([struct stat.st_ctim]) AC_CHECK_MEMBERS([struct stat.st_ctimespec]) AC_CHECK_MEMBERS([struct stat.st_ctimensec]) +AC_CHECK_TYPES([struct timeval], [], [], [@%:@ifdef HAVE_TIME_H +@%:@include <time.h> +@%:@endif +@%:@ifdef HAVE_SYS_TIME_H +@%:@include <sys/time.h> +@%:@endif]) + AC_CHECK_TYPES([struct timespec], [], [], [@%:@ifdef HAVE_TIME_H @%:@include <time.h> @%:@endif]) @@ -1259,63 +1285,6 @@ if test $rb_cv_stack_end_address != no; then AC_DEFINE_UNQUOTED(STACK_END_ADDRESS, $rb_cv_stack_end_address) fi -AC_CACHE_CHECK(for gc_mark and gc_children stack frame approximate size(word), rb_cv_gc_mark_stackframe_word, -[save_CFLAGS="$CFLAGS" -CFLAGS="-O0" -AC_TRY_RUN([ -int word; -char *stack_start; - -void -set_stackframe_word() -{ - int dumy = 42; - int diff; - - if (stack_start < (char *)&dumy) { - diff = (int)((char *)&dumy - stack_start); - } - else { - diff = (int)(stack_start - (char *)&dumy); - } - word = (diff/sizeof(void *)); - if ((diff % sizeof(void *)) != 0) { - word++; - } -} - -void -gc_mark_children(void *p1, void *p2, int lev) -{ - void *obj = p2; - - set_stackframe_word(p1,p2,lev); -} - -void -gc_mark(void *p1, void *p2, int lev) -{ - void *obj = p2; - - gc_mark_children(p1,p2,lev++); -} - -int -main() { - int dumy = 42; - - stack_start = (char *)&dumy; - gc_mark(0, 0, 255); - return word; -} -], - [rb_cv_gc_mark_stackframe_word="$?"], - [rb_cv_gc_mark_stackframe_word="$?"], - [rb_cv_gc_mark_stackframe_word="30"]) -CFLAGS="$save_CFLAGS"]) -AC_DEFINE_UNQUOTED(GC_MARK_STACKFRAME_WORD, $rb_cv_gc_mark_stackframe_word) - - dnl Checks for library functions. AC_TYPE_GETGROUPS AC_TYPE_SIGNAL @@ -2105,7 +2074,7 @@ if test "$with_dln_a_out" != yes; then rb_cv_dlopen=yes], [aix*], [ : ${LDSHARED='$(CC)'} LDSHARED="$LDSHARED ${linker_flag}-G" - DLDFLAGS='-eInit_$(TARGET)' + EXTDLDFLAGS='-e$(TARGET_ENTRY)' XLDFLAGS="${linker_flag}"'-bE:$(ARCHFILE)'" ${linker_flag}-brtl" XLDFLAGS="$XLDFLAGS ${linker_flag}-blibpath:${prefix}/lib:${LIBPATH:-/usr/lib:/lib}" : ${ARCHFILE="ruby.imp"} @@ -2122,7 +2091,8 @@ if test "$with_dln_a_out" != yes; then [beos*], [ AS_CASE(["$target_cpu"], [powerpc*], [ : ${LDSHARED="ld -xms"} - DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o' + EXTDLDFLAGS='-export $(TARGET_ENTRY)' + DLDFLAGS="$DLDFLAGS -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o" LDFLAGS="$LDFLAGS -L/boot/home/config/lib -lbe -lroot" ], [i586*], [ @@ -2135,7 +2105,8 @@ if test "$with_dln_a_out" != yes; then [haiku*], [ AS_CASE(["$target_cpu"], [powerpc*], [ : ${LDSHARED="ld -xms"} - DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o' + EXTDLDFLAGS='-export $(TARGET_ENTRY)' + DLDFLAGS="$DLDFLAGS -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o" ], [i586*], [ : ${LDSHARED="ld -shared"} @@ -2354,6 +2325,13 @@ AS_CASE("$enable_shared", [yes], [ if test "$rb_cv_binary_elf" = yes; then SOLIBS='$(LIBS)' fi + # libdir can be overridden in config.site file (on OpenSUSE at least). + libdir_basename=lib + if test "$bindir" = '${exec_prefix}/bin'; then + AS_CASE(["$libdir"], ['${exec_prefix}/'*], [libdir_basename=`basename "$libdir"`]) + fi + AC_DEFINE_UNQUOTED(LIBDIR_BASENAME, ["${libdir_basename}"]) + AS_CASE(["$target_os"], [sunos4*], [ LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' @@ -2362,7 +2340,7 @@ AS_CASE("$enable_shared", [yes], [ LIBRUBY_DLDFLAGS='-Wl,-soname,lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR)' LIBRUBY_ALIASES='lib$(RUBY_SO_NAME).so.$(MAJOR).$(MINOR) lib$(RUBY_SO_NAME).so' if test "$load_relative" = yes; then - LIBRUBY_RPATHFLAGS="'-Wl,-rpath,\$\${ORIGIN}/../lib'" + LIBRUBY_RPATHFLAGS="'-Wl,-rpath,\$\${ORIGIN}/../${libdir_basename}'" LIBRUBY_RELATIVE=yes fi ], @@ -2419,7 +2397,7 @@ AS_CASE("$enable_shared", [yes], [ RUBY_SO_NAME="$RUBY_SO_NAME"'.$(MAJOR).$(MINOR).$(TEENY)' LIBRUBY_LDSHARED='$(CC) -dynamiclib' if test "$load_relative" = yes; then - libprefix='@executable_path/../lib' + libprefix="@executable_path/../${libdir_basename}" LIBRUBY_RELATIVE=yes fi LIBRUBY_DLDFLAGS="$LIBRUBY_DLDFLAGS "'-install_name '${libprefix}'/$(LIBRUBY_SO)' @@ -2578,11 +2556,13 @@ AS_CASE(["$target_os"], fi EXPORT_PREFIX=' ' DLDFLAGS="${DLDFLAGS}"' $(DEFFILE)' - AC_LIBOBJ([win32]) + AC_LIBOBJ([win32/win32]) + AC_LIBOBJ([win32/file]) COMMON_LIBS=m # COMMON_MACROS="WIN32_LEAN_AND_MEAN=" COMMON_HEADERS="winsock2.h windows.h" THREAD_MODEL=win32 + PLATFORM_DIR=win32 ]) LIBRUBY_ALIASES='' FIRSTMAKEFILE=GNUmakefile:cygwin/GNUmakefile.in @@ -2711,6 +2691,7 @@ AC_SUBST(debugflags)dnl AC_SUBST(warnflags)dnl AC_SUBST(XCFLAGS)dnl AC_SUBST(XLDFLAGS)dnl +AC_SUBST(EXTDLDFLAGS)dnl AC_SUBST(LIBRUBY_LDSHARED) AC_SUBST(LIBRUBY_DLDFLAGS) AC_SUBST(RUBY_INSTALL_NAME) @@ -2735,6 +2716,7 @@ AC_SUBST(EXPORT_PREFIX) AC_SUBST(SYMBOL_PREFIX) AC_SUBST(MINIOBJS) AC_SUBST(THREAD_MODEL) +AC_SUBST(PLATFORM_DIR) MAKEFILES="Makefile `echo $FIRSTMAKEFILE | sed 's/:.*//'`" MAKEFILES="`echo $MAKEFILES`" @@ -2937,7 +2919,20 @@ AC_SUBST(sitehdrdir)dnl AC_SUBST(vendorhdrdir)dnl AC_ARG_WITH(opt-dir, - AS_HELP_STRING([--with-opt-dir=DIR], [add optional headers and libraries DIR])) + AS_HELP_STRING([--with-opt-dir=DIR-LIST], + [add optional headers and libraries directories separated by $PATH_SEPARATOR]), + [ + CPPFLAGS="$CPPFLAGS `echo \"$PATH_SEPARATOR$withval\" | sed \"s|$PATH_SEPARATOR\([[^$PATH_SEPARATOR]*]\)| -I\1/include|g;s/^ //\"`" + set -x + val=`IFS="$PATH_SEPARATOR" + for dir in $withval; do + echo x ${LIBPATHFLAG} ${RPATHFLAG} | + sed -E 's/^x *//;s'"${PATH_SEPARATOR}"'%1\\$-s|%s'"${IFS}${dir}/lib${IFS}g" + done | tr '\012' ' '` + set +x + LDFLAGS="$LDFLAGS${LDFLAGS:+ }$val" + DLDFLAGS="$DLDFLAGS${DLDFLAGS:+ }$val" + ]) AC_ARG_WITH(mantype, AS_HELP_STRING([--with-mantype=TYPE], [specify man page type; TYPE is one of man and doc]), @@ -3037,7 +3032,10 @@ AC_CONFIG_FILES(Makefile, [{ }], [EXEEXT='$EXEEXT' gnumake='$gnumake']) -ruby_pc="${RUBY_BASE_NAME}-${MAJOR}.${MINOR}.pc" +AC_ARG_WITH([ruby-pc], + AC_HELP_STRING([pc file basename]), + [ruby_pc="$withval"], + [ruby_pc="${RUBY_BASE_NAME}-${MAJOR}.${MINOR}.pc"]) AC_SUBST(ruby_pc) AC_SUBST(exec, [exec]) @@ -2,7 +2,7 @@ dir.c - - $Author: naruse $ + $Author: usa $ created at: Wed Jan 5 09:51:01 JST 1994 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -762,7 +762,6 @@ dir_close(VALUE dir) static void dir_chdir(VALUE path) { - path = rb_str_encode_ospath(path); if (chdir(RSTRING_PTR(path)) < 0) rb_sys_fail_path(path); } @@ -845,6 +844,7 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj) rb_secure(2); if (rb_scan_args(argc, argv, "01", &path) == 1) { FilePathValue(path); + path = rb_str_encode_ospath(path); } else { const char *dist = getenv("HOME"); @@ -862,9 +862,8 @@ dir_s_chdir(int argc, VALUE *argv, VALUE obj) if (rb_block_given_p()) { struct chdir_data args; - char *cwd = my_getcwd(); - args.old_path = rb_tainted_str_new2(cwd); xfree(cwd); + args.old_path = rb_str_encode_ospath(rb_dir_getwd()); args.new_path = path; args.done = FALSE; return rb_ensure(chdir_yield, (VALUE)&args, chdir_restore, (VALUE)&args); @@ -909,14 +908,21 @@ dir_s_getwd(VALUE dir) static void check_dirname(volatile VALUE *dir) { + VALUE d = *dir; char *path, *pend; + long len; + rb_encoding *enc; rb_secure(2); - FilePathValue(*dir); - path = RSTRING_PTR(*dir); - if (path && *(pend = rb_path_end(rb_path_skip_prefix(path)))) { - *dir = rb_str_new(path, pend - path); + FilePathValue(d); + enc = rb_enc_get(d); + RSTRING_GETMEM(d, path, len); + pend = path + len; + pend = rb_enc_path_end(rb_enc_path_skip_prefix(path, pend, enc), pend, enc); + if (pend - path < len) { + d = rb_str_subseq(d, 0, pend - path); } + *dir = rb_str_encode_ospath(d); } #if defined(HAVE_CHROOT) @@ -933,8 +939,6 @@ static VALUE dir_s_chroot(VALUE dir, VALUE path) { check_dirname(&path); - - path = rb_str_encode_ospath(path); if (chroot(RSTRING_PTR(path)) == -1) rb_sys_fail_path(path); @@ -973,7 +977,6 @@ dir_s_mkdir(int argc, VALUE *argv, VALUE obj) } check_dirname(&path); - path = rb_str_encode_ospath(path); if (mkdir(RSTRING_PTR(path), mode) == -1) rb_sys_fail_path(path); @@ -993,7 +996,6 @@ static VALUE dir_s_rmdir(VALUE obj, VALUE dir) { check_dirname(&dir); - dir = rb_str_encode_ospath(dir); if (rmdir(RSTRING_PTR(dir)) < 0) rb_sys_fail_path(dir); @@ -1173,6 +1175,7 @@ glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc) { struct glob_pattern *list, *tmp, **tail = &list; int dirsep = 0; /* pattern is terminated with '/' */ + int recursive = 0; while (p < e && *p) { tmp = GLOB_ALLOC(struct glob_pattern); @@ -1183,13 +1186,14 @@ glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc) tmp->type = RECURSIVE; tmp->str = 0; dirsep = 1; + recursive = 1; } else { const char *m = find_dirsep(p, e, flags, enc); int magic = has_magic(p, m, flags, enc); char *buf; - if (!magic && *m) { + if (!magic && !recursive && *m) { const char *m2; while (!has_magic(m+1, m2 = find_dirsep(m+1, e, flags, enc), flags, enc) && *m2) { @@ -1497,7 +1501,7 @@ ruby_glob0(const char *path, int flags, ruby_glob_func *func, VALUE arg, rb_enco start = root = path; flags |= FNM_SYSCASE; #if defined DOSISH - root = rb_path_skip_prefix(root); + root = rb_enc_path_skip_prefix(root, root + strlen(root), enc); #endif if (root && *root == '/') root++; @@ -2,7 +2,7 @@ error.c - - $Author: naruse $ + $Author: usa $ created at: Mon Aug 9 16:11:34 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -569,7 +569,6 @@ exc_to_s(VALUE exc) if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc)); r = rb_String(mesg); - OBJ_INFECT(r, exc); return r; } @@ -853,11 +852,7 @@ name_err_to_s(VALUE exc) if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc)); StringValue(str); - if (str != mesg) { - rb_iv_set(exc, "mesg", mesg = str); - } - OBJ_INFECT(mesg, exc); - return mesg; + return str; } /* @@ -988,7 +983,6 @@ name_err_mesg_to_str(VALUE obj) args[2] = d; mesg = rb_f_sprintf(NAME_ERR_MESG_COUNT, args); } - OBJ_INFECT(mesg, obj); return mesg; } diff --git a/eval_jump.c b/eval_jump.c index a8f0480..f3a1f78 100644 --- a/eval_jump.c +++ b/eval_jump.c @@ -99,6 +99,8 @@ rb_exec_end_proc(void) struct end_proc_data *volatile link; int status; volatile int safe = rb_safe_level(); + rb_thread_t *th = GET_THREAD(); + VALUE errinfo = th->errinfo; while (ephemeral_end_procs) { link = ephemeral_end_procs; @@ -112,6 +114,7 @@ rb_exec_end_proc(void) POP_TAG(); if (status) { error_handle(status); + if (!NIL_P(th->errinfo)) errinfo = th->errinfo; } xfree(link); } @@ -128,10 +131,12 @@ rb_exec_end_proc(void) POP_TAG(); if (status) { error_handle(status); + if (!NIL_P(th->errinfo)) errinfo = th->errinfo; } xfree(link); } rb_set_safe_level_force(safe); + th->errinfo = errinfo; } void diff --git a/ext/-test-/add_suffix/bug.c b/ext/-test-/add_suffix/bug.c deleted file mode 100644 index 3dc1201..0000000 --- a/ext/-test-/add_suffix/bug.c +++ /dev/null @@ -1,32 +0,0 @@ -static unsigned long ruby_scan_oct(); -static unsigned long ruby_scan_hex(); -static unsigned long ruby_strtoul(); -static void ruby_qsort(); -static char *ruby_strdup(); -static char *ruby_getcwd(); -static double ruby_strtod(); -static char *ruby_dtoa(); -static void ruby_each_words(); -static char *ruby_hdtoa(); -#include "ruby.h" -#include "ruby/defines.h" -#include "ruby/util.h" -#ifndef HAVE_RUBY_ADD_SUFFIX -#define _WIN32 1 -#include "util.c" -#endif - -static VALUE -add_suffix(VALUE self, VALUE path, VALUE suffix) -{ - StringValueCStr(path); - ruby_add_suffix(path, StringValueCStr(suffix)); - return path; -} - -void -Init_bug(void) -{ - VALUE mBug = rb_define_module("Bug"); - rb_define_module_function(mBug, "add_suffix", add_suffix, 2); -} diff --git a/ext/-test-/add_suffix/depend b/ext/-test-/add_suffix/depend deleted file mode 100644 index 943d0d9..0000000 --- a/ext/-test-/add_suffix/depend +++ /dev/null @@ -1 +0,0 @@ -bug.o: $(hdrdir)/ruby/util.h $(top_srcdir)/util.c diff --git a/ext/-test-/add_suffix/extconf.rb b/ext/-test-/add_suffix/extconf.rb deleted file mode 100644 index bffd155..0000000 --- a/ext/-test-/add_suffix/extconf.rb +++ /dev/null @@ -1,4 +0,0 @@ -unless have_func("ruby_add_suffix", "ruby/util.h") - $INCFLAGS << " -I$(top_srcdir)" -end -create_makefile("-test-/add_suffix/bug") diff --git a/ext/-test-/win32/dln/extconf.rb b/ext/-test-/win32/dln/extconf.rb index cc94a67..0b5089a 100644 --- a/ext/-test-/win32/dln/extconf.rb +++ b/ext/-test-/win32/dln/extconf.rb @@ -1,12 +1,14 @@ if $mingw or $mswin $objs = ["dlntest.o"] - $cleanfiles << "$(topdir)/dlntest.dll" + testdll = "$(topdir)/dlntest.dll" + $cleanfiles << testdll config_string('cleanobjs') {|t| $cleanfiles.concat(t.gsub(/\$\*/, 'dlntest').split)} create_makefile("-test-/win32/dln") m = File.read("Makefile") dlntestlib = "dlntest.#{$LIBEXT}" m.sub!(/^OBJS =.*/) {"#{$&} #{dlntestlib}"} + FileUtils.rm_f(RbConfig.expand(testdll.dup)) open("Makefile", "wb") do |mf| mf.puts m, "\n" sodir = $extout ? "$(RUBYARCHDIR)/" : '' diff --git a/ext/-test-/win32/fd_setsize/depend b/ext/-test-/win32/fd_setsize/depend new file mode 100644 index 0000000..4936d6b --- /dev/null +++ b/ext/-test-/win32/fd_setsize/depend @@ -0,0 +1,2 @@ +fd_setsize.o: $(top_srcdir)/win32/win32.c \ + $(hdrdir)/ruby/ruby.h diff --git a/ext/-test-/win32/fd_setsize/extconf.rb b/ext/-test-/win32/fd_setsize/extconf.rb new file mode 100644 index 0000000..ed40f8b --- /dev/null +++ b/ext/-test-/win32/fd_setsize/extconf.rb @@ -0,0 +1,3 @@ +if $mingw or $mswin + create_makefile("-test-/win32/fd_setsize") +end diff --git a/ext/-test-/win32/fd_setsize/fd_setsize.c b/ext/-test-/win32/fd_setsize/fd_setsize.c new file mode 100644 index 0000000..8da8b1e --- /dev/null +++ b/ext/-test-/win32/fd_setsize/fd_setsize.c @@ -0,0 +1,55 @@ +#undef FD_SETSIZE +/* redefine smaller size then default 64 */ +#define FD_SETSIZE 32 +#include <ruby.h> + +static VALUE +test_select(VALUE self) +{ + int sd = socket(AF_INET, SOCK_DGRAM, 0); + struct timeval zero; + fd_set read; + fd_set write; + fd_set error; + + zero.tv_sec = 0; + zero.tv_usec = 0; + + FD_ZERO(&read); + FD_ZERO(&write); + FD_ZERO(&error); + + FD_SET(sd, &read); + FD_SET(sd, &write); + FD_SET(sd, &error); + + select(sd+1, &read, &write, &error, &zero); + + return Qtrue; +} + +static VALUE +test_fdset(VALUE self) +{ + int i; + fd_set set; + + FD_ZERO(&set); + + for (i = 0; i < FD_SETSIZE * 2; i++) { + int sd = socket(AF_INET, SOCK_DGRAM, 0); + FD_SET(sd, &set); + if (set.fd_count > FD_SETSIZE) { + return Qfalse; + } + } + return Qtrue; +} + +void +Init_fd_setsize(void) +{ + VALUE m = rb_define_module_under(rb_define_module("Bug"), "Win32"); + rb_define_module_function(m, "test_select", test_select, 0); + rb_define_module_function(m, "test_fdset", test_fdset, 0); +} diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 1dc2f15..14f80b1 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -61,7 +61,7 @@ static ID id_eq; /* MACRO's to guard objects from GC by keeping them in stack */ #define ENTER(n) volatile VALUE vStack[n];int iStack=0 -#define PUSH(x) vStack[iStack++] = (unsigned long)(x); +#define PUSH(x) vStack[iStack++] = (VALUE)(x); #define SAVE(p) PUSH(p->obj); #define GUARD_OBJ(p,y) {p=y;SAVE(p);} @@ -660,7 +660,7 @@ BigDecimal_to_i(VALUE self) ret = rb_funcall(numerator, '*', 1, rb_funcall(INT2FIX(10), rb_intern("**"), 1, INT2FIX(dpower))); - if (TYPE(ret) == T_FLOAT) + if (RB_TYPE_P(ret, T_FLOAT)) rb_raise(rb_eFloatDomainError, "Infinity"); return ret; } @@ -768,11 +768,11 @@ BigDecimal_coerce(VALUE self, VALUE other) VALUE obj; Real *b; - if (TYPE(other) == T_FLOAT) { + if (RB_TYPE_P(other, T_FLOAT)) { obj = rb_assoc_new(other, BigDecimal_to_f(self)); } else { - if (TYPE(other) == T_RATIONAL) { + if (RB_TYPE_P(other, T_RATIONAL)) { Real* pv = DATA_PTR(self); GUARD_OBJ(b, GetVpValueWithPrec(other, pv->Prec*VpBaseFig(), 1)); } @@ -808,23 +808,37 @@ BigDecimal_add(VALUE self, VALUE r) ENTER(5); Real *c, *a, *b; size_t mx; - GUARD_OBJ(a,GetVpValue(self,1)); - b = GetVpValue(r,0); - if(!b) return DoSomeOne(self,r,'+'); + + GUARD_OBJ(a, GetVpValue(self, 1)); + if (RB_TYPE_P(r, T_FLOAT)) { + b = GetVpValueWithPrec(r, DBL_DIG+1, 1); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); + } + else { + b = GetVpValue(r,0); + } + + if (!b) return DoSomeOne(self,r,'+'); SAVE(b); - if(VpIsNaN(b)) return b->obj; - if(VpIsNaN(a)) return a->obj; - mx = GetAddSubPrec(a,b); + + if (VpIsNaN(b)) return b->obj; + if (VpIsNaN(a)) return a->obj; + + mx = GetAddSubPrec(a, b); if (mx == (size_t)-1L) { - GUARD_OBJ(c,VpCreateRbObject(VpBaseFig() + 1, "0")); - VpAddSub(c, a, b, 1); - } else { - GUARD_OBJ(c,VpCreateRbObject(mx *(VpBaseFig() + 1), "0")); - if(!mx) { - VpSetInf(c,VpGetSign(a)); - } else { - VpAddSub(c, a, b, 1); - } + GUARD_OBJ(c,VpCreateRbObject(VpBaseFig() + 1, "0")); + VpAddSub(c, a, b, 1); + } + else { + GUARD_OBJ(c, VpCreateRbObject(mx * (VpBaseFig() + 1), "0")); + if(!mx) { + VpSetInf(c, VpGetSign(a)); + } + else { + VpAddSub(c, a, b, 1); + } } return ToValue(c); } @@ -848,7 +862,16 @@ BigDecimal_sub(VALUE self, VALUE r) size_t mx; GUARD_OBJ(a,GetVpValue(self,1)); - b = GetVpValue(r,0); + if (RB_TYPE_P(r, T_FLOAT)) { + b = GetVpValueWithPrec(r, DBL_DIG+1, 1); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); + } + else { + b = GetVpValue(r,0); + } + if(!b) return DoSomeOne(self,r,'-'); SAVE(b); @@ -1081,7 +1104,16 @@ BigDecimal_mult(VALUE self, VALUE r) size_t mx; GUARD_OBJ(a,GetVpValue(self,1)); - b = GetVpValue(r,0); + if (RB_TYPE_P(r, T_FLOAT)) { + b = GetVpValueWithPrec(r, DBL_DIG+1, 1); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); + } + else { + b = GetVpValue(r,0); + } + if(!b) return DoSomeOne(self,r,'*'); SAVE(b); @@ -1100,9 +1132,19 @@ BigDecimal_divide(Real **c, Real **res, Real **div, VALUE self, VALUE r) size_t mx; GUARD_OBJ(a,GetVpValue(self,1)); - b = GetVpValue(r,0); + if (RB_TYPE_P(r, T_FLOAT)) { + b = GetVpValueWithPrec(r, DBL_DIG+1, 1); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); + } + else { + b = GetVpValue(r,0); + } + if(!b) return DoSomeOne(self,r,'/'); SAVE(b); + *div = b; mx = a->Prec + vabs(a->exponent); if(mx<b->Prec + vabs(b->exponent)) mx = b->Prec + vabs(b->exponent); @@ -1163,7 +1205,16 @@ BigDecimal_DoDivmod(VALUE self, VALUE r, Real **div, Real **mod) size_t mx; GUARD_OBJ(a,GetVpValue(self,1)); - b = GetVpValue(r,0); + if (RB_TYPE_P(r, T_FLOAT)) { + b = GetVpValueWithPrec(r, DBL_DIG+1, 1); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); + } + else { + b = GetVpValue(r,0); + } + if(!b) return Qfalse; SAVE(b); @@ -1253,7 +1304,16 @@ BigDecimal_divremain(VALUE self, VALUE r, Real **dv, Real **rv) Real *f=NULL; GUARD_OBJ(a,GetVpValue(self,1)); - b = GetVpValue(r,0); + if (RB_TYPE_P(r, T_FLOAT)) { + b = GetVpValueWithPrec(r, DBL_DIG+1, 1); + } + else if (RB_TYPE_P(r, T_RATIONAL)) { + b = GetVpValueWithPrec(r, a->Prec*VpBaseFig(), 1); + } + else { + b = GetVpValue(r,0); + } + if(!b) return DoSomeOne(self,r,rb_intern("remainder")); SAVE(b); @@ -1727,8 +1787,8 @@ static VALUE BigDecimal_to_s(int argc, VALUE *argv, VALUE self) { ENTER(5); - int fmt=0; /* 0:E format */ - int fPlus=0; /* =0:default,=1: set ' ' before digits ,set '+' before digits. */ + int fmt = 0; /* 0:E format */ + int fPlus = 0; /* =0:default,=1: set ' ' before digits ,set '+' before digits. */ Real *vp; volatile VALUE str; char *psz; @@ -1738,42 +1798,53 @@ BigDecimal_to_s(int argc, VALUE *argv, VALUE self) GUARD_OBJ(vp,GetVpValue(self,1)); - if(rb_scan_args(argc,argv,"01",&f)==1) { - if(TYPE(f)==T_STRING) { - SafeStringValue(f); - psz = RSTRING_PTR(f); - if(*psz==' ') { - fPlus = 1; psz++; - } else if(*psz=='+') { - fPlus = 2; psz++; - } - while((ch=*psz++)!=0) { - if(ISSPACE(ch)) continue; - if(!ISDIGIT(ch)) { - if(ch=='F' || ch=='f') fmt = 1; /* F format */ - break; - } - mc = mc * 10 + ch - '0'; - } - } + if (rb_scan_args(argc,argv,"01",&f)==1) { + if (RB_TYPE_P(f, T_STRING)) { + SafeStringValue(f); + psz = RSTRING_PTR(f); + if (*psz == ' ') { + fPlus = 1; + psz++; + } + else if (*psz == '+') { + fPlus = 2; + psz++; + } + while ((ch = *psz++) != 0) { + if (ISSPACE(ch)) { + continue; + } + if (!ISDIGIT(ch)) { + if (ch == 'F' || ch == 'f') { + fmt = 1; /* F format */ + } + break; + } + mc = mc * 10 + ch - '0'; + } + } else { - mc = (size_t)GetPositiveInt(f); - } + mc = (size_t)GetPositiveInt(f); + } } - if(fmt) { - nc = VpNumOfChars(vp,"F"); - } else { - nc = VpNumOfChars(vp,"E"); + if (fmt) { + nc = VpNumOfChars(vp, "F"); + } + else { + nc = VpNumOfChars(vp, "E"); + } + if (mc > 0) { + nc += (nc + mc - 1) / mc + 1; } - if(mc>0) nc += (nc + mc - 1) / mc + 1; str = rb_str_new(0, nc); psz = RSTRING_PTR(str); - if(fmt) { - VpToFString(vp, psz, mc, fPlus); - } else { - VpToString (vp, psz, mc, fPlus); + if (fmt) { + VpToFString(vp, psz, mc, fPlus); + } + else { + VpToString (vp, psz, mc, fPlus); } rb_str_resize(str, strlen(psz)); return str; @@ -1890,7 +1961,7 @@ static VALUE BigMath_s_log(VALUE, VALUE, VALUE); inline static int is_integer(VALUE x) { - return (TYPE(x) == T_FIXNUM || TYPE(x) == T_BIGNUM); + return (RB_TYPE_P(x, T_FIXNUM) || RB_TYPE_P(x, T_BIGNUM)); } inline static int @@ -1899,10 +1970,10 @@ is_negative(VALUE x) if (FIXNUM_P(x)) { return FIX2LONG(x) < 0; } - else if (TYPE(x) == T_BIGNUM) { + else if (RB_TYPE_P(x, T_BIGNUM)) { return RBIGNUM_NEGATIVE_P(x); } - else if (TYPE(x) == T_FLOAT) { + else if (RB_TYPE_P(x, T_FLOAT)) { return RFLOAT_VALUE(x) < 0.0; } return RTEST(rb_funcall(x, '<', 1, INT2FIX(0))); @@ -2161,7 +2232,7 @@ retry: if (exp != NULL) { return rmpd_power_by_big_decimal(x, exp, n); } - else if (TYPE(vexp) == T_BIGNUM) { + else if (RB_TYPE_P(vexp, T_BIGNUM)) { VALUE abs_value = BigDecimal_abs(self); if (is_one(abs_value)) { return ToValue(VpCreateRbObject(n, "1")); @@ -2557,7 +2628,7 @@ BigMath_s_log(VALUE klass, VALUE x, VALUE vprec) double flo; long fix; - if (TYPE(vprec) != T_FIXNUM && TYPE(vprec) != T_BIGNUM) { + if (!is_integer(vprec)) { rb_raise(rb_eArgError, "precision must be an Integer"); } @@ -2802,6 +2873,10 @@ Init_bigdecimal(void) { VALUE arg; + id_BigDecimal_exception_mode = rb_intern_const("BigDecimal.exception_mode"); + id_BigDecimal_rounding_mode = rb_intern_const("BigDecimal.rounding_mode"); + id_BigDecimal_precision_limit = rb_intern_const("BigDecimal.precision_limit"); + /* Initialize VP routines */ VpInit(0UL); @@ -2993,10 +3068,6 @@ Init_bigdecimal(void) rb_define_singleton_method(rb_mBigMath, "exp", BigMath_s_exp, 2); rb_define_singleton_method(rb_mBigMath, "log", BigMath_s_log, 2); - id_BigDecimal_exception_mode = rb_intern_const("BigDecimal.exception_mode"); - id_BigDecimal_rounding_mode = rb_intern_const("BigDecimal.rounding_mode"); - id_BigDecimal_precision_limit = rb_intern_const("BigDecimal.precision_limit"); - id_up = rb_intern_const("up"); id_down = rb_intern_const("down"); id_truncate = rb_intern_const("truncate"); diff --git a/ext/curses/extconf.rb b/ext/curses/extconf.rb index 4172c8a..a1a1613 100644 --- a/ext/curses/extconf.rb +++ b/ext/curses/extconf.rb @@ -16,7 +16,7 @@ elsif have_header(*curses=%w"ncurses/curses.h") and have_library("ncurses", "ini elsif have_header(*curses=%w"curses_colr/curses.h") and have_library("cur_colr", "initscr") curses.unshift("varargs.h") make=true -elsif have_header(*curses=%w"curses.h") and have_library("curses", "initscr") +elsif have_header(*curses=%w"curses.h") and (have_library("curses", "initscr") || have_library("pdcurses", "initscr")) make=true end diff --git a/ext/date/date_core.c b/ext/date/date_core.c index c22a9d4..4048d13 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -7864,7 +7864,7 @@ datetime_s_now(int argc, VALUE *argv, VALUE klass) of = tm.tm_gmtoff; #elif defined(HAVE_VAR_TIMEZONE) #ifdef HAVE_VAR_ALTZONE - of = (long)((tm.tm_isdst > 0) ? altzone : timezone); + of = (long)-((tm.tm_isdst > 0) ? altzone : timezone); #else of = (long)-timezone; if (tm.tm_isdst) { diff --git a/ext/digest/md5/extconf.rb b/ext/digest/md5/extconf.rb index 15646ef..4ed9701 100644 --- a/ext/digest/md5/extconf.rb +++ b/ext/digest/md5/extconf.rb @@ -1,5 +1,5 @@ # $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $ -# $Id: extconf.rb 25189 2009-10-02 12:04:37Z akr $ +# $Id: extconf.rb 35653 2012-05-15 16:10:46Z tenderlove $ require "mkmf" @@ -9,6 +9,7 @@ $INCFLAGS << " -I$(srcdir)/.." $objs = [ "md5init.#{$OBJEXT}" ] dir_config("openssl") +pkg_config("openssl") if !with_config("bundled-md5") && have_library("crypto") && have_header("openssl/md5.h") diff --git a/ext/digest/rmd160/extconf.rb b/ext/digest/rmd160/extconf.rb index f005271..9a18184 100644 --- a/ext/digest/rmd160/extconf.rb +++ b/ext/digest/rmd160/extconf.rb @@ -1,5 +1,5 @@ # $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $ -# $Id: extconf.rb 25189 2009-10-02 12:04:37Z akr $ +# $Id: extconf.rb 35653 2012-05-15 16:10:46Z tenderlove $ require "mkmf" @@ -9,6 +9,7 @@ $INCFLAGS << " -I$(srcdir)/.." $objs = [ "rmd160init.#{$OBJEXT}" ] dir_config("openssl") +pkg_config("openssl") if !with_config("bundled-rmd160") && have_library("crypto") && have_header("openssl/ripemd.h") diff --git a/ext/digest/sha1/extconf.rb b/ext/digest/sha1/extconf.rb index 1a51cd9..b7b38bc 100644 --- a/ext/digest/sha1/extconf.rb +++ b/ext/digest/sha1/extconf.rb @@ -1,5 +1,5 @@ # $RoughId: extconf.rb,v 1.3 2001/08/14 19:54:51 knu Exp $ -# $Id: extconf.rb 25189 2009-10-02 12:04:37Z akr $ +# $Id: extconf.rb 35653 2012-05-15 16:10:46Z tenderlove $ require "mkmf" @@ -9,6 +9,7 @@ $INCFLAGS << " -I$(srcdir)/.." $objs = [ "sha1init.#{$OBJEXT}" ] dir_config("openssl") +pkg_config("openssl") if !with_config("bundled-sha1") && have_library("crypto") && have_header("openssl/sha.h") diff --git a/ext/digest/sha2/extconf.rb b/ext/digest/sha2/extconf.rb index e1306c0..95109c8 100644 --- a/ext/digest/sha2/extconf.rb +++ b/ext/digest/sha2/extconf.rb @@ -1,5 +1,5 @@ # $RoughId: extconf.rb,v 1.4 2001/08/14 19:54:51 knu Exp $ -# $Id: extconf.rb 27433 2010-04-21 12:25:29Z akr $ +# $Id: extconf.rb 35653 2012-05-15 16:10:46Z tenderlove $ require "mkmf" @@ -9,6 +9,7 @@ $INCFLAGS << " -I$(srcdir)/.." $objs = [ "sha2init.#{$OBJEXT}" ] dir_config("openssl") +pkg_config("openssl") if !with_config("bundled-sha2") && have_library("crypto") && diff --git a/ext/dl/cfunc.c b/ext/dl/cfunc.c index 45e019f..0ee0e25 100644 --- a/ext/dl/cfunc.c +++ b/ext/dl/cfunc.c @@ -1,5 +1,5 @@ /* -*- C -*- - * $Id: cfunc.c 34604 2012-02-14 20:09:27Z naruse $ + * $Id: cfunc.c 37007 2012-09-21 10:53:50Z naruse $ */ #include <ruby.h> @@ -324,7 +324,7 @@ rb_dlcfunc_inspect(VALUE self) } -#if defined(_MSC_VER) && defined(_M_AMD64) && _MSC_VER == 1500 +#if defined(_MSC_VER) && defined(_M_AMD64) && _MSC_VER >= 1400 && _MSC_VER < 1600 # pragma optimize("", off) #endif /* @@ -366,7 +366,11 @@ rb_dlcfunc_call(VALUE self, VALUE ary) stack[i] = (DLSTACK_TYPE)FIX2LONG(arg); } else if (RB_TYPE_P(arg, T_BIGNUM)) { +#if SIZEOF_VOIDP == SIZEOF_LONG stack[i] = (DLSTACK_TYPE)rb_big2ulong_pack(arg); +#else + stack[i] = (DLSTACK_TYPE)rb_big2ull(arg); +#endif } else { Check_Type(arg, T_FIXNUM); @@ -594,7 +598,7 @@ rb_dlcfunc_call(VALUE self, VALUE ary) return result; } -#if defined(_MSC_VER) && defined(_M_AMD64) && _MSC_VER == 1500 +#if defined(_MSC_VER) && defined(_M_AMD64) && _MSC_VER >= 1400 && _MSC_VER < 1600 # pragma optimize("", on) #endif diff --git a/ext/dl/lib/dl/func.rb b/ext/dl/lib/dl/func.rb index 3c2245f..9a984ed 100644 --- a/ext/dl/lib/dl/func.rb +++ b/ext/dl/lib/dl/func.rb @@ -11,13 +11,50 @@ module DL include DL include ValueUtil + if DL.fiddle? + # :stopdoc: + CALL_TYPE_TO_ABI = Hash.new { |h, k| + raise RuntimeError, "unsupported call type: #{k}" + }.merge({ :stdcall => + (Fiddle::Function::STDCALL rescue Fiddle::Function::DEFAULT), + :cdecl => Fiddle::Function::DEFAULT, + nil => Fiddle::Function::DEFAULT + }).freeze + private_constant :CALL_TYPE_TO_ABI + # :startdoc: + + def self.call_type_to_abi(call_type) # :nodoc: + CALL_TYPE_TO_ABI[call_type] + end + private_class_method :call_type_to_abi + + class FiddleClosureCFunc < Fiddle::Closure # :nodoc: all + def initialize ctype, arg, abi, name + @name = name + super(ctype, arg, abi) + end + def name + @name + end + def ptr + to_i + end + end + private_constant :FiddleClosureCFunc + + def self.class_fiddle_closure_cfunc # :nodoc: + FiddleClosureCFunc + end + private_class_method :class_fiddle_closure_cfunc + end + def initialize cfunc, argtypes, abi = nil, &block if DL.fiddle? - abi ||= Fiddle::Function::DEFAULT + abi ||= CALL_TYPE_TO_ABI[(cfunc.calltype rescue nil)] if block_given? - @cfunc = Class.new(Fiddle::Closure) { + @cfunc = Class.new(FiddleClosureCFunc) { define_method(:call, block) - }.new(cfunc.ctype, argtypes) + }.new(cfunc.ctype, argtypes, abi, cfunc.name) else @cfunc = cfunc end @@ -55,6 +92,9 @@ module DL super else funcs = [] + if $SAFE >= 1 && args.any? { |x| x.tainted? } + raise SecurityError, "tainted parameter not allowed" + end _args = wrap_args(args, @stack.types, funcs, &block) r = @cfunc.call(@stack.pack(_args)) funcs.each{|f| f.unbind_at_call()} @@ -76,16 +116,18 @@ module DL def bind(&block) if DL.fiddle? - @cfunc = Class.new(Fiddle::Closure) { - def initialize ctype, args, block - super(ctype, args) + @cfunc = Class.new(FiddleClosureCFunc) { + def initialize ctype, args, abi, name, block + super(ctype, args, abi, name) @block = block end def call *args @block.call(*args) end - }.new(@cfunc.ctype, @args, block) + }.new(@cfunc.ctype, @args, abi, name, block) + @ptr = @cfunc + return nil else if( !block ) raise(RuntimeError, "block must be given.") @@ -118,6 +160,25 @@ module DL end def unbind() + if DL.fiddle? then + if @cfunc.kind_of?(Fiddle::Closure) and @cfunc.ptr != 0 then + call_type = case abi + when CALL_TYPE_TO_ABI[nil] + nil + when CALL_TYPE_TO_ABI[:stdcall] + :stdcall + else + raise(RuntimeError, "unsupported abi: #{abi}") + end + @cfunc = CFunc.new(0, @cfunc.ctype, name, call_type) + return 0 + elsif @cfunc.ptr != 0 then + @cfunc.ptr = 0 + return 0 + else + return nil + end + end if( @cfunc.ptr != 0 ) case @cfunc.calltype when :cdecl diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb index eec65cd..a4fa406 100644 --- a/ext/dl/lib/dl/import.rb +++ b/ext/dl/lib/dl/import.rb @@ -231,11 +231,13 @@ module DL def bind_function(name, ctype, argtype, call_type = nil, &block) if DL.fiddle? - closure = Class.new(Fiddle::Closure) { + klass = Function.instance_eval { class_fiddle_closure_cfunc } + abi = Function.instance_eval { call_type_to_abi(call_type) } + closure = Class.new(klass) { define_method(:call, block) - }.new(ctype, argtype) + }.new(ctype, argtype, abi, name) - Function.new(closure, argtype) + Function.new(closure, argtype, abi) else f = Function.new(CFunc.new(0, ctype, name, call_type || :cdecl), argtype) f.bind(&block) diff --git a/ext/extmk.rb b/ext/extmk.rb index 5665a96..de6e037 100755 --- a/ext/extmk.rb +++ b/ext/extmk.rb @@ -183,6 +183,8 @@ def extmake(target) end rescue SystemExit # ignore + rescue => error + ok = false ensure rm_f "conftest*" config = $0 @@ -194,7 +196,15 @@ def extmake(target) open(makefile, "w") do |f| f.print(*dummy_makefile(CONFIG["srcdir"])) end - print "Failed to configure #{target}. It will not be installed.\n" + + mess = "Failed to configure #{target}. It will not be installed.\n" + if error + mess.prepend(error.to_s + "\n") + end + + Logging::message(mess) + print(mess) + $stdout.flush return true end args = sysquote($mflags) diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c index a3c0792..2179666 100644 --- a/ext/fiddle/closure.c +++ b/ext/fiddle/closure.c @@ -284,7 +284,7 @@ Init_fiddle_closure() /* * Document-method: new * - * call-seq: new(ret, *args, abi = Fiddle::DEFAULT) + * call-seq: new(ret, args, abi = Fiddle::DEFAULT) * * Construct a new Closure object. * diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb index 03b0ac2..2cb9ae0 100644 --- a/ext/fiddle/extconf.rb +++ b/ext/fiddle/extconf.rb @@ -9,16 +9,46 @@ unless have_header('ffi.h') if have_header('ffi/ffi.h') $defs.push(format('-DUSE_HEADER_HACKS')) else - abort "ffi.h is missing. Please install libffi." + raise "ffi.h is missing. Please install libffi." end end unless have_library('ffi') || have_library('libffi') - abort "libffi is missing. Please install libffi." + raise "libffi is missing. Please install libffi." end have_header 'sys/mman.h' +if have_header "dlfcn.h" + have_library "dl" + + %w{ dlopen dlclose dlsym }.each do |func| + abort "missing function #{func}" unless have_func(func) + end + + have_func "dlerror" +elsif have_header "windows.h" + %w{ LoadLibrary FreeLibrary GetProcAddress }.each do |func| + abort "missing function #{func}" unless have_func(func) + end +end + +have_const('FFI_STDCALL', 'ffi.h') || have_const('FFI_STDCALL', 'ffi/ffi.h') + +config = File.read(RbConfig.expand(File.join($arch_hdrdir, "ruby/config.h"))) +types = {"SIZE_T"=>"SSIZE_T", "PTRDIFF_T"=>nil, "INTPTR_T"=>nil} +types.each do |type, signed| + if /^\#define\s+SIZEOF_#{type}\s+(SIZEOF_(.+)|\d+)/ =~ config + if size = $2 and size != 'VOIDP' + size = types.fetch(size) {size} + $defs << format("-DTYPE_%s=TYPE_%s", signed||type, size) + end + if signed + check_signedness(type.downcase, "stddef.h") + end + end +end + create_makefile 'fiddle' # :startdoc: diff --git a/ext/fiddle/function.c b/ext/fiddle/function.c index 6e89099..52f7695 100644 --- a/ext/fiddle/function.c +++ b/ext/fiddle/function.c @@ -101,6 +101,15 @@ function_call(int argc, VALUE argv[], VALUE self) TypedData_Get_Struct(self, ffi_cif, &function_data_type, cif); + if (rb_safe_level() >= 1) { + for (i = 0; i < argc; i++) { + VALUE src = argv[i]; + if (OBJ_TAINTED(src)) { + rb_raise(rb_eSecurityError, "tainted parameter not allowed"); + } + } + } + values = xcalloc((size_t)argc + 1, (size_t)sizeof(void *)); generic_args = xcalloc((size_t)argc, (size_t)sizeof(fiddle_generic)); @@ -179,7 +188,7 @@ Init_fiddle_function(void) */ rb_define_const(cFiddleFunction, "DEFAULT", INT2NUM(FFI_DEFAULT_ABI)); -#ifdef FFI_STDCALL +#ifdef HAVE_CONST_FFI_STDCALL /* * Document-const: STDCALL * @@ -203,7 +212,7 @@ Init_fiddle_function(void) /* * Document-method: new - * call-seq: new(ptr, *args, ret_type, abi = DEFAULT) + * call-seq: new(ptr, args, ret_type, abi = DEFAULT) * * Constructs a Function object. * * +ptr+ is a referenced function, of a DL::Handle diff --git a/ext/json/lib/json/add/core.rb b/ext/json/lib/json/add/core.rb index 1ae00d0..01b8e04 100644 --- a/ext/json/lib/json/add/core.rb +++ b/ext/json/lib/json/add/core.rb @@ -36,8 +36,8 @@ class Time if usec = object.delete('u') # used to be tv_usec -> tv_nsec object['n'] = usec * 1000 end - if respond_to?(:tv_nsec) - at(*object.values_at('s', 'n')) + if instance_methods.include?(:tv_nsec) + at(object['s'], Rational(object['n'], 1000)) else at(object['s'], object['n'] / 1000) end @@ -46,10 +46,13 @@ class Time # Returns a hash, that will be turned into a JSON object and represent this # object. def as_json(*) + nanoseconds = [ tv_usec * 1000 ] + respond_to?(:tv_nsec) and nanoseconds << tv_nsec + nanoseconds = nanoseconds.max { JSON.create_id => self.class.name, 's' => tv_sec, - 'n' => respond_to?(:tv_nsec) ? tv_nsec : tv_usec * 1000 + 'n' => nanoseconds, } end diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb index 43e249c..9ad1fab 100644 --- a/ext/json/lib/json/common.rb +++ b/ext/json/lib/json/common.rb @@ -141,7 +141,7 @@ module JSON # the default. # * *create_additions*: If set to false, the Parser doesn't create # additions even if a matching class and create_id was found. This option - # defaults to true. + # defaults to false. # * *object_class*: Defaults to Hash # * *array_class*: Defaults to Array def parse(source, opts = {}) @@ -162,7 +162,7 @@ module JSON # to true. # * *create_additions*: If set to false, the Parser doesn't create # additions even if a matching class and create_id was found. This option - # defaults to true. + # defaults to false. def parse!(source, opts = {}) opts = { :max_nesting => false, @@ -287,11 +287,18 @@ module JSON # Load a ruby data structure from a JSON _source_ and return it. A source can # either be a string-like object, an IO-like object, or an object responding # to the read method. If _proc_ was given, it will be called with any nested - # Ruby object as an argument recursively in depth first order. + # Ruby object as an argument recursively in depth first order. To modify the + # default options pass in the optional _options_ argument as well. # # This method is part of the implementation of the load/dump interface of # Marshal and YAML. - def load(source, proc = nil) + def load(source, proc = nil, options = {}) + load_default_options = { + :max_nesting => false, + :allow_nan => true, + :create_additions => false + } + opts = load_default_options.merge options if source.respond_to? :to_str source = source.to_str elsif source.respond_to? :to_io @@ -299,7 +306,7 @@ module JSON else source = source.read end - result = parse(source, :max_nesting => false, :allow_nan => true) + result = parse(source, opts) recurse_proc(result, &proc) if proc result end diff --git a/ext/json/lib/json/version.rb b/ext/json/lib/json/version.rb index 2175ac0..baacdc9 100644 --- a/ext/json/lib/json/version.rb +++ b/ext/json/lib/json/version.rb @@ -1,6 +1,6 @@ module JSON # JSON version - VERSION = '1.5.4' + VERSION = '1.5.5' VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc: VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc: VERSION_MINOR = VERSION_ARRAY[1] # :nodoc: diff --git a/ext/json/parser/parser.c b/ext/json/parser/parser.c index c0ec9ec..8a321a8 100644 --- a/ext/json/parser/parser.c +++ b/ext/json/parser/parser.c @@ -1676,7 +1676,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) if (option_given_p(opts, tmp)) { json->create_additions = RTEST(rb_hash_aref(opts, tmp)); } else { - json->create_additions = 1; + json->create_additions = 0; } tmp = ID2SYM(i_create_id); if (option_given_p(opts, tmp)) { @@ -1723,7 +1723,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) } -#line 1719 "parser.c" +#line 1722 "parser.c" static const int JSON_start = 1; static const int JSON_first_final = 10; static const int JSON_error = 0; @@ -1731,7 +1731,7 @@ static const int JSON_error = 0; static const int JSON_en_main = 1; -#line 726 "parser.rl" +#line 729 "parser.rl" static VALUE cParser_parse_strict(VALUE self) @@ -1742,16 +1742,16 @@ static VALUE cParser_parse_strict(VALUE self) GET_PARSER; -#line 1738 "parser.c" +#line 1741 "parser.c" { cs = JSON_start; } -#line 736 "parser.rl" +#line 739 "parser.rl" p = json->source; pe = p + json->len; -#line 1747 "parser.c" +#line 1750 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1807,7 +1807,7 @@ case 5: goto st1; goto st5; tr3: -#line 715 "parser.rl" +#line 718 "parser.rl" { char *np; json->current_nesting = 1; @@ -1816,7 +1816,7 @@ tr3: } goto st10; tr4: -#line 708 "parser.rl" +#line 711 "parser.rl" { char *np; json->current_nesting = 1; @@ -1828,7 +1828,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 1824 "parser.c" +#line 1827 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -1885,7 +1885,7 @@ case 9: _out: {} } -#line 739 "parser.rl" +#line 742 "parser.rl" if (cs >= JSON_first_final && p == pe) { return result; @@ -1897,7 +1897,7 @@ case 9: -#line 1893 "parser.c" +#line 1896 "parser.c" static const int JSON_quirks_mode_start = 1; static const int JSON_quirks_mode_first_final = 10; static const int JSON_quirks_mode_error = 0; @@ -1905,7 +1905,7 @@ static const int JSON_quirks_mode_error = 0; static const int JSON_quirks_mode_en_main = 1; -#line 764 "parser.rl" +#line 767 "parser.rl" static VALUE cParser_parse_quirks_mode(VALUE self) @@ -1916,16 +1916,16 @@ static VALUE cParser_parse_quirks_mode(VALUE self) GET_PARSER; -#line 1912 "parser.c" +#line 1915 "parser.c" { cs = JSON_quirks_mode_start; } -#line 774 "parser.rl" +#line 777 "parser.rl" p = json->source; pe = p + json->len; -#line 1921 "parser.c" +#line 1924 "parser.c" { if ( p == pe ) goto _test_eof; @@ -1959,7 +1959,7 @@ st0: cs = 0; goto _out; tr2: -#line 756 "parser.rl" +#line 759 "parser.rl" { char *np = JSON_parse_value(json, p, pe, &result); if (np == NULL) { p--; {p++; cs = 10; goto _out;} } else {p = (( np))-1;} @@ -1969,7 +1969,7 @@ st10: if ( ++p == pe ) goto _test_eof10; case 10: -#line 1965 "parser.c" +#line 1968 "parser.c" switch( (*p) ) { case 13: goto st10; case 32: goto st10; @@ -2058,7 +2058,7 @@ case 9: _out: {} } -#line 777 "parser.rl" +#line 780 "parser.rl" if (cs >= JSON_quirks_mode_first_final && p == pe) { return result; diff --git a/ext/json/parser/parser.rl b/ext/json/parser/parser.rl index dcb5d2d..fe6427a 100644 --- a/ext/json/parser/parser.rl +++ b/ext/json/parser/parser.rl @@ -607,6 +607,9 @@ static VALUE convert_encoding(VALUE source) * defaults to true. * * *object_class*: Defaults to Hash * * *array_class*: Defaults to Array + * * *quirks_mode*: Enables quirks_mode for parser, that is for example + * parsing single JSON values instead of documents is possible. + * */ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) { @@ -657,7 +660,7 @@ static VALUE cParser_initialize(int argc, VALUE *argv, VALUE self) if (option_given_p(opts, tmp)) { json->create_additions = RTEST(rb_hash_aref(opts, tmp)); } else { - json->create_additions = 1; + json->create_additions = 0; } tmp = ID2SYM(i_create_id); if (option_given_p(opts, tmp)) { diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c index 65e0d84..109cfbd 100644 --- a/ext/objspace/objspace.c +++ b/ext/objspace/objspace.c @@ -2,7 +2,7 @@ objspace.c - ObjectSpace extender for MRI. - $Author: ktsj $ + $Author: usa $ created at: Wed Jun 17 07:39:17 2009 NOTE: This extension library is not expected to exist except C Ruby. @@ -531,7 +531,7 @@ count_nodes(int argc, VALUE *argv, VALUE os) COUNT_NODE(NODE_LAMBDA); COUNT_NODE(NODE_OPTBLOCK); #undef COUNT_NODE - default: node = INT2FIX(nodes[i]); + default: node = INT2FIX(i); } rb_hash_aset(hash, node, SIZET2NUM(nodes[i])); } diff --git a/ext/openssl/extconf.rb b/ext/openssl/extconf.rb index f515847..bfb1ea4 100644 --- a/ext/openssl/extconf.rb +++ b/ext/openssl/extconf.rb @@ -11,7 +11,7 @@ (See the file 'LICENCE'.) = Version - $Id: extconf.rb 32230 2011-06-26 01:32:03Z emboss $ + $Id: extconf.rb 36929 2012-09-09 06:39:23Z kosaki $ =end require "mkmf" @@ -58,8 +58,7 @@ unless result end unless have_header("openssl/conf_api.h") - message "OpenSSL 0.9.6 or later required.\n" - exit 1 + raise "OpenSSL 0.9.6 or later required." end %w"rb_str_set_len rb_block_call".each {|func| have_func(func, "ruby.h")} diff --git a/ext/openssl/lib/openssl/ssl-internal.rb b/ext/openssl/lib/openssl/ssl-internal.rb index 9c0320c..d750471 100644 --- a/ext/openssl/lib/openssl/ssl-internal.rb +++ b/ext/openssl/lib/openssl/ssl-internal.rb @@ -11,7 +11,7 @@ (See the file 'LICENCE'.) = Version - $Id: ssl-internal.rb 29189 2010-09-06 01:53:00Z nahi $ + $Id: ssl-internal.rb 41673 2013-06-27 11:13:08Z usa $ =end require "openssl/buffering" @@ -88,14 +88,22 @@ module OpenSSL should_verify_common_name = true cert.extensions.each{|ext| next if ext.oid != "subjectAltName" - ext.value.split(/,\s+/).each{|general_name| - if /\ADNS:(.*)/ =~ general_name + id, ostr = OpenSSL::ASN1.decode(ext.to_der).value + sequence = OpenSSL::ASN1.decode(ostr.value) + sequence.value.each{|san| + case san.tag + when 2 # dNSName in GeneralName (RFC5280) should_verify_common_name = false - reg = Regexp.escape($1).gsub(/\\\*/, "[^.]+") + reg = Regexp.escape(san.value).gsub(/\\\*/, "[^.]+") return true if /\A#{reg}\z/i =~ hostname - elsif /\AIP Address:(.*)/ =~ general_name + when 7 # iPAddress in GeneralName (RFC5280) should_verify_common_name = false - return true if $1 == hostname + # follows GENERAL_NAME_print() in x509v3/v3_alt.c + if san.value.size == 4 + return true if san.value.unpack('C*').join('.') == hostname + elsif san.value.size == 16 + return true if san.value.unpack('n*').map { |e| sprintf("%X", e) }.join(':') == hostname + end end } } diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index 2a50b75..3cc2645 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -1,5 +1,5 @@ /* - * $Id: ossl_asn1.c 34505 2012-02-09 03:25:07Z nobu $ + * $Id: ossl_asn1.c 39980 2013-03-28 09:19:07Z usa $ * 'OpenSSL for Ruby' team members * Copyright (C) 2003 * All rights reserved. @@ -149,11 +149,16 @@ num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai) ASN1_INTEGER * num_to_asn1integer(VALUE obj, ASN1_INTEGER *ai) { - BIGNUM *bn = GetBNPtr(obj); + BIGNUM *bn; + + if (NIL_P(obj)) + ossl_raise(rb_eTypeError, "Can't convert nil into Integer"); - if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) { + bn = GetBNPtr(obj); + + if (!(ai = BN_to_ASN1_INTEGER(bn, ai))) ossl_raise(eOSSLError, NULL); - } + return ai; } #endif @@ -219,6 +224,9 @@ static ID sivVALUE, sivTAG, sivTAG_CLASS, sivTAGGING, sivINFINITE_LENGTH, sivUNU static ASN1_BOOLEAN obj_to_asn1bool(VALUE obj) { + if (NIL_P(obj)) + ossl_raise(rb_eTypeError, "Can't convert nil into Boolean"); + #if OPENSSL_VERSION_NUMBER < 0x00907000L return RTEST(obj) ? 0xff : 0x100; #else diff --git a/ext/openssl/ossl_ssl.c b/ext/openssl/ossl_ssl.c index 855082d..72e9350 100644 --- a/ext/openssl/ossl_ssl.c +++ b/ext/openssl/ossl_ssl.c @@ -1,5 +1,5 @@ /* - * $Id: ossl_ssl.c 34524 2012-02-09 17:04:41Z emboss $ + * $Id: ossl_ssl.c 40717 2013-05-14 02:35:39Z usa $ * 'OpenSSL for Ruby' project * Copyright (C) 2000-2002 GOTOU Yuuzou <gotoyuzo@notwork.org> * Copyright (C) 2001-2002 Michal Rokos <m.rokos@sh.cvut.cz> @@ -995,7 +995,6 @@ ossl_ssl_shutdown(SSL *ssl) static void ossl_ssl_free(SSL *ssl) { - ossl_ssl_shutdown(ssl); SSL_free(ssl); } @@ -1405,9 +1404,16 @@ ossl_ssl_close(VALUE self) SSL *ssl; Data_Get_Struct(self, SSL, ssl); - ossl_ssl_shutdown(ssl); - if (RTEST(ossl_ssl_get_sync_close(self))) - rb_funcall(ossl_ssl_get_io(self), rb_intern("close"), 0); + if (ssl) { + VALUE io = ossl_ssl_get_io(self); + if (!RTEST(rb_funcall(io, rb_intern("closed?"), 0))) { + ossl_ssl_shutdown(ssl); + SSL_free(ssl); + DATA_PTR(self) = NULL; + if (RTEST(ossl_ssl_get_sync_close(self))) + rb_funcall(io, rb_intern("close"), 0); + } + } return Qnil; } diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c index e1632c5..e35c19d 100644 --- a/ext/pathname/pathname.c +++ b/ext/pathname/pathname.c @@ -1,4 +1,5 @@ #include "ruby.h" +#include "ruby/encoding.h" static VALUE rb_cPathname; static ID id_at_path, id_to_path; @@ -184,15 +185,15 @@ path_sub_ext(VALUE self, VALUE repl) StringValue(repl); p = RSTRING_PTR(str); - ext = ruby_find_extname(p, &extlen); + extlen = RSTRING_LEN(str); + ext = ruby_enc_find_extname(p, &extlen, rb_enc_get(str)); if (ext == NULL) { ext = p + RSTRING_LEN(str); } else if (extlen <= 1) { ext += extlen; } - str2 = rb_str_dup(str); - rb_str_resize(str2, ext-p); + str2 = rb_str_subseq(str, 0, ext-p); rb_str_append(str2, repl); OBJ_INFECT(str2, str); return rb_class_new_instance(1, &str2, rb_obj_class(self)); diff --git a/ext/psych/emitter.c b/ext/psych/emitter.c index 15fdcfe..f0d0326 100644 --- a/ext/psych/emitter.c +++ b/ext/psych/emitter.c @@ -2,6 +2,9 @@ VALUE cPsychEmitter; static ID id_write; +static ID id_line_width; +static ID id_indentation; +static ID id_canonical; static void emit(yaml_emitter_t * emitter, yaml_event_t * event) { @@ -39,15 +42,30 @@ static VALUE allocate(VALUE klass) return Data_Wrap_Struct(klass, 0, dealloc, emitter); } -/* call-seq: Psych::Emitter.new(io) +/* call-seq: Psych::Emitter.new(io, options = Psych::Emitter::OPTIONS) * * Create a new Psych::Emitter that writes to +io+. */ -static VALUE initialize(VALUE self, VALUE io) +static VALUE initialize(int argc, VALUE *argv, VALUE self) { yaml_emitter_t * emitter; + VALUE io, options; + VALUE line_width; + VALUE indent; + VALUE canonical; + Data_Get_Struct(self, yaml_emitter_t, emitter); + if (rb_scan_args(argc, argv, "11", &io, &options) == 2) { + line_width = rb_funcall(options, id_line_width, 0); + indent = rb_funcall(options, id_indentation, 0); + canonical = rb_funcall(options, id_canonical, 0); + + yaml_emitter_set_width(emitter, NUM2INT(line_width)); + yaml_emitter_set_indent(emitter, NUM2INT(indent)); + yaml_emitter_set_canonical(emitter, Qtrue == canonical ? 1 : 0); + } + yaml_emitter_set_output(emitter, writer, (void *)io); return self; @@ -494,7 +512,7 @@ void Init_psych_emitter() rb_define_alloc_func(cPsychEmitter, allocate); - rb_define_method(cPsychEmitter, "initialize", initialize, 1); + rb_define_method(cPsychEmitter, "initialize", initialize, -1); rb_define_method(cPsychEmitter, "start_stream", start_stream, 1); rb_define_method(cPsychEmitter, "end_stream", end_stream, 0); rb_define_method(cPsychEmitter, "start_document", start_document, 3); @@ -512,6 +530,9 @@ void Init_psych_emitter() rb_define_method(cPsychEmitter, "line_width", line_width, 0); rb_define_method(cPsychEmitter, "line_width=", set_line_width, 1); - id_write = rb_intern("write"); + id_write = rb_intern("write"); + id_line_width = rb_intern("line_width"); + id_indentation = rb_intern("indentation"); + id_canonical = rb_intern("canonical"); } /* vim: set noet sws=4 sw=4: */ diff --git a/ext/psych/extconf.rb b/ext/psych/extconf.rb index 11f44ac..ccc8c9c 100644 --- a/ext/psych/extconf.rb +++ b/ext/psych/extconf.rb @@ -5,7 +5,7 @@ require 'mkmf' dir_config 'libyaml' def asplode missing - abort "#{missing} is missing. Please install libyaml." + raise "#{missing} is missing. Please install libyaml." end asplode('yaml.h') unless find_header 'yaml.h' diff --git a/ext/psych/lib/psych.rb b/ext/psych/lib/psych.rb index 1895be6..19d8b2b 100644 --- a/ext/psych/lib/psych.rb +++ b/ext/psych/lib/psych.rb @@ -93,7 +93,7 @@ require 'psych/handlers/document_stream' module Psych # The version is Psych you're using - VERSION = '1.3.2' + VERSION = '1.3.4' # The version of libyaml Psych is using LIBYAML_VERSION = Psych.libyaml_version.join '.' diff --git a/ext/psych/lib/psych/handler.rb b/ext/psych/lib/psych/handler.rb index a2aa6bb..d3b9963 100644 --- a/ext/psych/lib/psych/handler.rb +++ b/ext/psych/lib/psych/handler.rb @@ -11,6 +11,21 @@ module Psych # See Psych::Parser for more details class Handler ### + # Configuration options for dumping YAML. + class DumperOptions + attr_accessor :line_width, :indentation, :canonical + + def initialize + @line_width = 0 + @indentation = 2 + @canonical = false + end + end + + # Default dumping options + OPTIONS = DumperOptions.new + + ### # Called with +encoding+ when the YAML stream starts. This method is # called once per stream. A stream may contain multiple documents. # diff --git a/ext/psych/lib/psych/json/yaml_events.rb b/ext/psych/lib/psych/json/yaml_events.rb index 01d4660..d054d9b 100644 --- a/ext/psych/lib/psych/json/yaml_events.rb +++ b/ext/psych/lib/psych/json/yaml_events.rb @@ -10,11 +10,11 @@ module Psych end def start_mapping anchor, tag, implicit, style - super(anchor, nil, implicit, Nodes::Mapping::FLOW) + super(anchor, nil, true, Nodes::Mapping::FLOW) end def start_sequence anchor, tag, implicit, style - super(anchor, nil, implicit, Nodes::Sequence::FLOW) + super(anchor, nil, true, Nodes::Sequence::FLOW) end def scalar value, anchor, tag, plain, quoted, style diff --git a/ext/psych/lib/psych/visitors/emitter.rb b/ext/psych/lib/psych/visitors/emitter.rb index 30db176..c886e50 100644 --- a/ext/psych/lib/psych/visitors/emitter.rb +++ b/ext/psych/lib/psych/visitors/emitter.rb @@ -2,10 +2,17 @@ module Psych module Visitors class Emitter < Psych::Visitors::Visitor def initialize io, options = {} - @handler = Psych::Emitter.new io - @handler.indentation = options[:indentation] if options[:indentation] - @handler.canonical = options[:canonical] if options[:canonical] - @handler.line_width = options[:line_width] if options[:line_width] + opts = [:indentation, :canonical, :line_width].find_all { |opt| + options.key?(opt) + } + + if opts.empty? + @handler = Psych::Emitter.new io + else + du = Handler::DumperOptions.new + opts.each { |option| du.send :"#{option}=", options[option] } + @handler = Psych::Emitter.new io, du + end end def visit_Psych_Nodes_Stream o diff --git a/ext/psych/lib/psych/visitors/to_ruby.rb b/ext/psych/lib/psych/visitors/to_ruby.rb index 2e082f9..088301a 100644 --- a/ext/psych/lib/psych/visitors/to_ruby.rb +++ b/ext/psych/lib/psych/visitors/to_ruby.rb @@ -147,8 +147,8 @@ module Psych string = members.delete 'str' if klass - string = klass.allocate - string.replace string + string = klass.allocate.replace string + register(o, string) end init_with(string, members.map { |k,v| [k.to_s.sub(/^@/, ''),v] }, o) @@ -222,6 +222,13 @@ module Psych when /^!map:(.*)$/, /^!ruby\/hash:(.*)$/ revive_hash resolve_class($1).new, o + when '!omap', 'tag:yaml.org,2002:omap' + map = register(o, Psych::Omap.new) + o.children.each_slice(2) do |l,r| + map[accept(l)] = accept r + end + map + else revive_hash({}, o) end diff --git a/ext/psych/lib/psych/visitors/yaml_tree.rb b/ext/psych/lib/psych/visitors/yaml_tree.rb index 80af046..948a976 100644 --- a/ext/psych/lib/psych/visitors/yaml_tree.rb +++ b/ext/psych/lib/psych/visitors/yaml_tree.rb @@ -20,6 +20,7 @@ module Psych @st = {} @ss = ss @options = options + @coders = [] @dispatch_cache = Hash.new do |h,klass| method = "visit_#{(klass.name || '').split('::').join('_')}" @@ -253,7 +254,7 @@ module Psych maptag = '!ruby/string' maptag << ":#{o.class}" unless o.class == ::String - @emitter.start_mapping nil, maptag, false, Nodes::Mapping::BLOCK + register o, @emitter.start_mapping(nil, maptag, false, Nodes::Mapping::BLOCK) @emitter.scalar 'str', nil, nil, true, false, Nodes::Scalar::ANY @emitter.scalar str, nil, tag, plain, quote, style @@ -406,6 +407,7 @@ module Psych end def dump_coder o + @coders << o tag = Psych.dump_tags[o.class] unless tag klass = o.class == Object ? nil : o.class.name diff --git a/ext/psych/parser.c b/ext/psych/parser.c index 6f4c456..0908a1b 100644 --- a/ext/psych/parser.c +++ b/ext/psych/parser.c @@ -79,8 +79,8 @@ static VALUE make_exception(yaml_parser_t * parser, VALUE path) static VALUE transcode_string(VALUE src, int * parser_encoding) { int utf8 = rb_utf8_encindex(); - int utf16le = rb_enc_find_index("UTF16_LE"); - int utf16be = rb_enc_find_index("UTF16_BE"); + int utf16le = rb_enc_find_index("UTF-16LE"); + int utf16be = rb_enc_find_index("UTF-16BE"); int source_encoding = rb_enc_get_index(src); if (source_encoding == utf8) { diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb index b8e9e0f..e1c37ce 100644 --- a/ext/readline/extconf.rb +++ b/ext/readline/extconf.rb @@ -40,14 +40,14 @@ when true unless (have_readline_header("editline/readline.h") || have_readline_header("readline/readline.h")) && have_library("edit", "readline") - exit + raise "libedit not found" end when false # --disable-libedit unless ((have_readline_header("readline/readline.h") && have_readline_header("readline/history.h")) && have_library("readline", "readline")) - exit + raise "readline not found" end else # does not specify @@ -57,7 +57,7 @@ else have_library("edit", "readline"))) || (have_readline_header("editline/readline.h") && have_library("edit", "readline")) - exit + raise "readline nor libedit not found" end end diff --git a/ext/readline/readline.c b/ext/readline/readline.c index 6dae5cd..c09bbdd 100644 --- a/ext/readline/readline.c +++ b/ext/readline/readline.c @@ -2,13 +2,13 @@ readline.c - GNU Readline module - $Author: nobu $ + $Author: usa $ created at: Wed Jan 20 13:59:32 JST 1999 Copyright (C) 1997-2008 Shugo Maeda Copyright (C) 2008-2009 TAKAO Kouji - $Id: readline.c 34505 2012-02-09 03:25:07Z nobu $ + $Id: readline.c 39377 2013-02-22 05:27:47Z usa $ Contact: - TAKAO Kouji <kouji at takao7 dot net> (current maintainer) @@ -1678,10 +1678,8 @@ Init_readline() rl_attempted_completion_function = readline_attempted_completion_function; #ifdef HAVE_RL_CATCH_SIGNALS rl_catch_signals = 0; -#endif -#ifdef HAVE_RL_CATCH_SIGWINCH - rl_catch_sigwinch = 0; -#endif +#endif + #ifdef HAVE_RL_CLEAR_SIGNALS rl_clear_signals(); #endif diff --git a/ext/ripper/ripper.c b/ext/ripper/ripper.c index 40bd701..6b34695 100644 --- a/ext/ripper/ripper.c +++ b/ext/ripper/ripper.c @@ -1,21 +1,24 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.3. */ -/* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - + the Free Software Foundation; either version 2, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -26,7 +29,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -44,7 +47,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5" +#define YYBISON_VERSION "2.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -52,20 +55,261 @@ /* Pure parsers. */ #define YYPURE 1 -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - /* Using locations. */ #define YYLSP_NEEDED 0 -/* Copy the first part of user declarations. */ +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + keyword_class = 258, + keyword_module = 259, + keyword_def = 260, + keyword_undef = 261, + keyword_begin = 262, + keyword_rescue = 263, + keyword_ensure = 264, + keyword_end = 265, + keyword_if = 266, + keyword_unless = 267, + keyword_then = 268, + keyword_elsif = 269, + keyword_else = 270, + keyword_case = 271, + keyword_when = 272, + keyword_while = 273, + keyword_until = 274, + keyword_for = 275, + keyword_break = 276, + keyword_next = 277, + keyword_redo = 278, + keyword_retry = 279, + keyword_in = 280, + keyword_do = 281, + keyword_do_cond = 282, + keyword_do_block = 283, + keyword_do_LAMBDA = 284, + keyword_return = 285, + keyword_yield = 286, + keyword_super = 287, + keyword_self = 288, + keyword_nil = 289, + keyword_true = 290, + keyword_false = 291, + keyword_and = 292, + keyword_or = 293, + keyword_not = 294, + modifier_if = 295, + modifier_unless = 296, + modifier_while = 297, + modifier_until = 298, + modifier_rescue = 299, + keyword_alias = 300, + keyword_defined = 301, + keyword_BEGIN = 302, + keyword_END = 303, + keyword__LINE__ = 304, + keyword__FILE__ = 305, + keyword__ENCODING__ = 306, + tIDENTIFIER = 307, + tFID = 308, + tGVAR = 309, + tIVAR = 310, + tCONSTANT = 311, + tCVAR = 312, + tLABEL = 313, + tINTEGER = 314, + tFLOAT = 315, + tSTRING_CONTENT = 316, + tCHAR = 317, + tNTH_REF = 318, + tBACK_REF = 319, + tREGEXP_END = 320, + tUPLUS = 321, + tUMINUS = 322, + tPOW = 323, + tCMP = 324, + tEQ = 325, + tEQQ = 326, + tNEQ = 327, + tGEQ = 328, + tLEQ = 329, + tANDOP = 330, + tOROP = 331, + tMATCH = 332, + tNMATCH = 333, + tDOT2 = 334, + tDOT3 = 335, + tAREF = 336, + tASET = 337, + tLSHFT = 338, + tRSHFT = 339, + tCOLON2 = 340, + tCOLON3 = 341, + tOP_ASGN = 342, + tASSOC = 343, + tLPAREN = 344, + tLPAREN_ARG = 345, + tRPAREN = 346, + tLBRACK = 347, + tLBRACE = 348, + tLBRACE_ARG = 349, + tSTAR = 350, + tAMPER = 351, + tLAMBDA = 352, + tSYMBEG = 353, + tSTRING_BEG = 354, + tXSTRING_BEG = 355, + tREGEXP_BEG = 356, + tWORDS_BEG = 357, + tQWORDS_BEG = 358, + tSTRING_DBEG = 359, + tSTRING_DVAR = 360, + tSTRING_END = 361, + tLAMBEG = 362, + tLOWEST = 363, + tUMINUS_NUM = 364, + idNULL = 365, + idRespond_to = 366, + idIFUNC = 367, + idCFUNC = 368, + id_core_set_method_alias = 369, + id_core_set_variable_alias = 370, + id_core_undef_method = 371, + id_core_define_method = 372, + id_core_define_singleton_method = 373, + id_core_set_postexe = 374, + tLAST_TOKEN = 375 + }; +#endif +/* Tokens. */ +#define keyword_class 258 +#define keyword_module 259 +#define keyword_def 260 +#define keyword_undef 261 +#define keyword_begin 262 +#define keyword_rescue 263 +#define keyword_ensure 264 +#define keyword_end 265 +#define keyword_if 266 +#define keyword_unless 267 +#define keyword_then 268 +#define keyword_elsif 269 +#define keyword_else 270 +#define keyword_case 271 +#define keyword_when 272 +#define keyword_while 273 +#define keyword_until 274 +#define keyword_for 275 +#define keyword_break 276 +#define keyword_next 277 +#define keyword_redo 278 +#define keyword_retry 279 +#define keyword_in 280 +#define keyword_do 281 +#define keyword_do_cond 282 +#define keyword_do_block 283 +#define keyword_do_LAMBDA 284 +#define keyword_return 285 +#define keyword_yield 286 +#define keyword_super 287 +#define keyword_self 288 +#define keyword_nil 289 +#define keyword_true 290 +#define keyword_false 291 +#define keyword_and 292 +#define keyword_or 293 +#define keyword_not 294 +#define modifier_if 295 +#define modifier_unless 296 +#define modifier_while 297 +#define modifier_until 298 +#define modifier_rescue 299 +#define keyword_alias 300 +#define keyword_defined 301 +#define keyword_BEGIN 302 +#define keyword_END 303 +#define keyword__LINE__ 304 +#define keyword__FILE__ 305 +#define keyword__ENCODING__ 306 +#define tIDENTIFIER 307 +#define tFID 308 +#define tGVAR 309 +#define tIVAR 310 +#define tCONSTANT 311 +#define tCVAR 312 +#define tLABEL 313 +#define tINTEGER 314 +#define tFLOAT 315 +#define tSTRING_CONTENT 316 +#define tCHAR 317 +#define tNTH_REF 318 +#define tBACK_REF 319 +#define tREGEXP_END 320 +#define tUPLUS 321 +#define tUMINUS 322 +#define tPOW 323 +#define tCMP 324 +#define tEQ 325 +#define tEQQ 326 +#define tNEQ 327 +#define tGEQ 328 +#define tLEQ 329 +#define tANDOP 330 +#define tOROP 331 +#define tMATCH 332 +#define tNMATCH 333 +#define tDOT2 334 +#define tDOT3 335 +#define tAREF 336 +#define tASET 337 +#define tLSHFT 338 +#define tRSHFT 339 +#define tCOLON2 340 +#define tCOLON3 341 +#define tOP_ASGN 342 +#define tASSOC 343 +#define tLPAREN 344 +#define tLPAREN_ARG 345 +#define tRPAREN 346 +#define tLBRACK 347 +#define tLBRACE 348 +#define tLBRACE_ARG 349 +#define tSTAR 350 +#define tAMPER 351 +#define tLAMBDA 352 +#define tSYMBEG 353 +#define tSTRING_BEG 354 +#define tXSTRING_BEG 355 +#define tREGEXP_BEG 356 +#define tWORDS_BEG 357 +#define tQWORDS_BEG 358 +#define tSTRING_DBEG 359 +#define tSTRING_DVAR 360 +#define tSTRING_END 361 +#define tLAMBEG 362 +#define tLOWEST 363 +#define tUMINUS_NUM 364 +#define idNULL 365 +#define idRespond_to 366 +#define idIFUNC 367 +#define idCFUNC 368 +#define id_core_set_method_alias 369 +#define id_core_set_variable_alias 370 +#define id_core_undef_method 371 +#define id_core_define_method 372 +#define id_core_define_singleton_method 373 +#define id_core_set_postexe 374 +#define tLAST_TOKEN 375 + + -/* Line 268 of yacc.c */ + +/* Copy the first part of user declarations. */ #line 12 "ripper.y" @@ -668,9 +912,6 @@ static void token_info_pop(struct parser_params*, const char *token); #endif -/* Line 268 of yacc.c */ -#line 673 "parse.c" - /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 1 @@ -689,165 +930,31 @@ static void token_info_pop(struct parser_params*, const char *token); # define YYTOKEN_TABLE 0 #endif - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - keyword_class = 258, - keyword_module = 259, - keyword_def = 260, - keyword_undef = 261, - keyword_begin = 262, - keyword_rescue = 263, - keyword_ensure = 264, - keyword_end = 265, - keyword_if = 266, - keyword_unless = 267, - keyword_then = 268, - keyword_elsif = 269, - keyword_else = 270, - keyword_case = 271, - keyword_when = 272, - keyword_while = 273, - keyword_until = 274, - keyword_for = 275, - keyword_break = 276, - keyword_next = 277, - keyword_redo = 278, - keyword_retry = 279, - keyword_in = 280, - keyword_do = 281, - keyword_do_cond = 282, - keyword_do_block = 283, - keyword_do_LAMBDA = 284, - keyword_return = 285, - keyword_yield = 286, - keyword_super = 287, - keyword_self = 288, - keyword_nil = 289, - keyword_true = 290, - keyword_false = 291, - keyword_and = 292, - keyword_or = 293, - keyword_not = 294, - modifier_if = 295, - modifier_unless = 296, - modifier_while = 297, - modifier_until = 298, - modifier_rescue = 299, - keyword_alias = 300, - keyword_defined = 301, - keyword_BEGIN = 302, - keyword_END = 303, - keyword__LINE__ = 304, - keyword__FILE__ = 305, - keyword__ENCODING__ = 306, - tIDENTIFIER = 307, - tFID = 308, - tGVAR = 309, - tIVAR = 310, - tCONSTANT = 311, - tCVAR = 312, - tLABEL = 313, - tINTEGER = 314, - tFLOAT = 315, - tSTRING_CONTENT = 316, - tCHAR = 317, - tNTH_REF = 318, - tBACK_REF = 319, - tREGEXP_END = 320, - tUPLUS = 321, - tUMINUS = 322, - tPOW = 323, - tCMP = 324, - tEQ = 325, - tEQQ = 326, - tNEQ = 327, - tGEQ = 328, - tLEQ = 329, - tANDOP = 330, - tOROP = 331, - tMATCH = 332, - tNMATCH = 333, - tDOT2 = 334, - tDOT3 = 335, - tAREF = 336, - tASET = 337, - tLSHFT = 338, - tRSHFT = 339, - tCOLON2 = 340, - tCOLON3 = 341, - tOP_ASGN = 342, - tASSOC = 343, - tLPAREN = 344, - tLPAREN_ARG = 345, - tRPAREN = 346, - tLBRACK = 347, - tLBRACE = 348, - tLBRACE_ARG = 349, - tSTAR = 350, - tAMPER = 351, - tLAMBDA = 352, - tSYMBEG = 353, - tSTRING_BEG = 354, - tXSTRING_BEG = 355, - tREGEXP_BEG = 356, - tWORDS_BEG = 357, - tQWORDS_BEG = 358, - tSTRING_DBEG = 359, - tSTRING_DVAR = 360, - tSTRING_END = 361, - tLAMBEG = 362, - tLOWEST = 363, - tUMINUS_NUM = 364, - idNULL = 365, - idRespond_to = 366, - idIFUNC = 367, - idCFUNC = 368, - id_core_set_method_alias = 369, - id_core_set_variable_alias = 370, - id_core_undef_method = 371, - id_core_define_method = 372, - id_core_define_singleton_method = 373, - id_core_set_postexe = 374, - tLAST_TOKEN = 375 - }; -#endif - - - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -{ - -/* Line 293 of yacc.c */ #line 616 "ripper.y" - +{ VALUE val; NODE *node; ID id; int num; const struct vtable *vars; - - - -/* Line 293 of yacc.c */ -#line 839 "parse.c" -} YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 +} +/* Line 187 of yacc.c. */ +#line 945 "parse.c" + YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 #endif + /* Copy the second part of user declarations. */ -/* Line 343 of yacc.c */ -#line 851 "parse.c" +/* Line 216 of yacc.c. */ +#line 958 "parse.c" #ifdef short # undef short @@ -897,7 +1004,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS +# if YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -922,14 +1029,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int yyi) +YYID (int i) #else static int -YYID (yyi) - int yyi; +YYID (i) + int i; #endif { - return yyi; + return i; } #endif @@ -950,11 +1057,11 @@ YYID (yyi) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 +# ifndef _STDLIB_H +# define _STDLIB_H 1 # endif # endif # endif @@ -977,24 +1084,24 @@ YYID (yyi) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined EXIT_SUCCESS \ +# if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 +# ifndef _STDLIB_H +# define _STDLIB_H 1 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif @@ -1010,9 +1117,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; -}; + yytype_int16 yyss; + YYSTYPE yyvs; + }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -1023,27 +1130,6 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) -# define YYCOPY_NEEDED 1 - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -#if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY @@ -1061,7 +1147,24 @@ union yyalloc while (YYID (0)) # endif # endif -#endif /* !YYCOPY_NEEDED */ + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 @@ -1426,15 +1529,15 @@ static const yytype_uint16 yyrline[] = 4155, 4181, 4189, 4197, 4205, 4208, 4219, 4220, 4221, 4222, 4225, 4255, 4256, 4257, 4265, 4275, 4276, 4277, 4278, 4279, 4282, 4283, 4284, 4285, 4286, 4287, 4288, 4291, 4304, 4314, - 4322, 4332, 4333, 4336, 4345, 4344, 4352, 4364, 4374, 4380, - 4388, 4396, 4404, 4412, 4420, 4428, 4436, 4444, 4452, 4460, - 4468, 4476, 4484, 4493, 4502, 4511, 4520, 4529, 4540, 4541, - 4548, 4557, 4576, 4583, 4596, 4608, 4620, 4628, 4644, 4652, - 4668, 4669, 4672, 4685, 4696, 4697, 4700, 4717, 4721, 4731, - 4741, 4741, 4770, 4771, 4781, 4788, 4798, 4806, 4816, 4817, - 4818, 4821, 4822, 4823, 4824, 4827, 4828, 4829, 4832, 4837, - 4844, 4845, 4848, 4849, 4852, 4855, 4858, 4859, 4860, 4863, - 4864, 4867, 4868, 4872 + 4322, 4332, 4333, 4336, 4345, 4344, 4352, 4364, 4374, 4382, + 4390, 4398, 4406, 4414, 4422, 4430, 4438, 4446, 4454, 4462, + 4470, 4478, 4486, 4495, 4504, 4513, 4522, 4531, 4542, 4543, + 4550, 4559, 4578, 4585, 4598, 4610, 4622, 4630, 4646, 4654, + 4670, 4671, 4674, 4687, 4698, 4699, 4702, 4719, 4723, 4733, + 4743, 4743, 4772, 4773, 4783, 4790, 4800, 4808, 4818, 4819, + 4820, 4823, 4824, 4825, 4826, 4829, 4830, 4831, 4834, 4839, + 4846, 4847, 4850, 4851, 4854, 4857, 4860, 4861, 4862, 4865, + 4866, 4869, 4870, 4874 }; #endif @@ -1472,35 +1575,34 @@ static const char *const yytname[] = "id_core_define_method", "id_core_define_singleton_method", "id_core_set_postexe", "tLAST_TOKEN", "'{'", "'}'", "'['", "'.'", "','", "'`'", "'('", "')'", "']'", "';'", "' '", "'\\n'", "$accept", "program", - "$@1", "top_compstmt", "top_stmts", "top_stmt", "$@2", "bodystmt", - "compstmt", "stmts", "stmt", "$@3", "command_asgn", "expr", "expr_value", + "@1", "top_compstmt", "top_stmts", "top_stmt", "@2", "bodystmt", + "compstmt", "stmts", "stmt", "@3", "command_asgn", "expr", "expr_value", "command_call", "block_command", "cmd_brace_block", "@4", "command", "mlhs", "mlhs_inner", "mlhs_basic", "mlhs_item", "mlhs_head", "mlhs_post", "mlhs_node", "lhs", "cname", "cpath", "fname", "fsym", - "fitem", "undef_list", "$@5", "op", "reswords", "arg", "$@6", - "arg_value", "aref_args", "paren_args", "opt_paren_args", - "opt_call_args", "call_args", "command_args", "@7", "block_arg", - "opt_block_arg", "args", "mrhs", "primary", "@8", "$@9", "$@10", "$@11", - "$@12", "$@13", "$@14", "$@15", "$@16", "@17", "@18", "@19", "@20", - "@21", "$@22", "$@23", "primary_value", "k_begin", "k_if", "k_unless", - "k_while", "k_until", "k_case", "k_for", "k_class", "k_module", "k_def", - "k_end", "then", "do", "if_tail", "opt_else", "for_var", "f_marg", - "f_marg_list", "f_margs", "block_param", "opt_block_param", - "block_param_def", "opt_bv_decl", "bv_decls", "bvar", "lambda", "@24", - "@25", "f_larglist", "lambda_body", "do_block", "@26", "block_call", - "method_call", "brace_block", "@27", "@28", "case_body", "cases", - "opt_rescue", "exc_list", "exc_var", "opt_ensure", "literal", "strings", - "string", "string1", "xstring", "regexp", "words", "word_list", "word", - "qwords", "qword_list", "string_contents", "xstring_contents", - "regexp_contents", "string_content", "@29", "@30", "@31", "string_dvar", - "symbol", "sym", "dsym", "numeric", "user_variable", "keyword_variable", - "var_ref", "var_lhs", "backref", "superclass", "$@32", "f_arglist", - "f_args", "f_bad_arg", "f_norm_arg", "f_arg_item", "f_arg", "f_opt", - "f_block_opt", "f_block_optarg", "f_optarg", "restarg_mark", - "f_rest_arg", "blkarg_mark", "f_block_arg", "opt_f_block_arg", - "singleton", "$@33", "assoc_list", "assocs", "assoc", "operation", - "operation2", "operation3", "dot_or_colon", "opt_terms", "opt_nl", - "rparen", "rbracket", "trailer", "term", "terms", "none", 0 + "fitem", "undef_list", "@5", "op", "reswords", "arg", "@6", "arg_value", + "aref_args", "paren_args", "opt_paren_args", "opt_call_args", + "call_args", "command_args", "@7", "block_arg", "opt_block_arg", "args", + "mrhs", "primary", "@8", "@9", "@10", "@11", "@12", "@13", "@14", "@15", + "@16", "@17", "@18", "@19", "@20", "@21", "@22", "@23", "primary_value", + "k_begin", "k_if", "k_unless", "k_while", "k_until", "k_case", "k_for", + "k_class", "k_module", "k_def", "k_end", "then", "do", "if_tail", + "opt_else", "for_var", "f_marg", "f_marg_list", "f_margs", "block_param", + "opt_block_param", "block_param_def", "opt_bv_decl", "bv_decls", "bvar", + "lambda", "@24", "@25", "f_larglist", "lambda_body", "do_block", "@26", + "block_call", "method_call", "brace_block", "@27", "@28", "case_body", + "cases", "opt_rescue", "exc_list", "exc_var", "opt_ensure", "literal", + "strings", "string", "string1", "xstring", "regexp", "words", + "word_list", "word", "qwords", "qword_list", "string_contents", + "xstring_contents", "regexp_contents", "string_content", "@29", "@30", + "@31", "string_dvar", "symbol", "sym", "dsym", "numeric", + "user_variable", "keyword_variable", "var_ref", "var_lhs", "backref", + "superclass", "@32", "f_arglist", "f_args", "f_bad_arg", "f_norm_arg", + "f_arg_item", "f_arg", "f_opt", "f_block_opt", "f_block_optarg", + "f_optarg", "restarg_mark", "f_rest_arg", "blkarg_mark", "f_block_arg", + "opt_f_block_arg", "singleton", "@33", "assoc_list", "assocs", "assoc", + "operation", "operation2", "operation3", "dot_or_colon", "opt_terms", + "opt_nl", "rparen", "rbracket", "trailer", "term", "terms", "none", 0 }; #endif @@ -1653,8 +1755,8 @@ static const yytype_uint8 yyr2[] = 1, 1, 2, 0 }; -/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE doesn't specify something else to do. Zero +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint16 yydefact[] = { @@ -1915,7 +2017,8 @@ static const yytype_int16 yypgoto[] = /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF, syntax error. */ + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -574 static const yytype_int16 yytable[] = { @@ -2996,12 +3099,6 @@ static const yytype_int16 yytable[] = 325, 326, 327, 328, 329, 330, 331, 332, 333 }; -#define yypact_value_is_default(yystate) \ - ((yystate) == (-747)) - -#define yytable_value_is_error(yytable_value) \ - ((yytable_value) == (-574)) - static const yytype_int16 yycheck[] = { 2, 55, 340, 28, 2, 454, 4, 52, 593, 16, @@ -4199,18 +4296,9 @@ static const yytype_uint16 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ + Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif #define YYRECOVERING() (!!yyerrstatus) @@ -4220,6 +4308,7 @@ do \ { \ yychar = (Token); \ yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ @@ -4261,10 +4350,19 @@ while (YYID (0)) #endif -/* This macro is provided for backward compatibility. */ +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif #endif @@ -4371,20 +4469,17 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, parser) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) #else static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; #endif { YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } @@ -4419,11 +4514,11 @@ yy_reduce_print (yyvsp, yyrule, parser) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - YYFPRINTF (stderr, " $%d = ", yyi + 1); + fprintf (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , parser); - YYFPRINTF (stderr, "\n"); + fprintf (stderr, "\n"); } } @@ -4462,6 +4557,7 @@ int yydebug; # define YYMAXDEPTH 10000 #endif + #if YYERROR_VERBOSE @@ -4564,142 +4660,115 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) { - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = 0; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - Assume YYFAIL is not used. It's too flawed to consider. See - <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html> - for details. YYERROR is fine as it does not invoke this - function. - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } + int yyn = yypact[yystate]; - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } - yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } + if (yysize_overflow) + return YYSIZE_MAXIMUM; - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } } #endif /* YYERROR_VERBOSE */ + /*-----------------------------------------------. | Release the memory associated to this symbol. | @@ -4733,9 +4802,10 @@ yydestruct (yymsg, yytype, yyvaluep, parser) break; } } - + /* Prevent warnings from -Wmissing-prototypes. */ + #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -4751,6 +4821,10 @@ int yyparse (); #endif /* ! YYPARSE_PARAM */ + + + + /*----------. | yyparse. | `----------*/ @@ -4777,46 +4851,22 @@ yyparse (parser) #endif #endif { -/* The lookahead symbol. */ + /* The look-ahead symbol. */ int yychar; -/* The semantic value of the lookahead symbol. */ +/* The semantic value of the look-ahead symbol. */ YYSTYPE yylval; - /* Number of syntax errors so far. */ - int yynerrs; - - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; +/* Number of syntax errors so far. */ +int yynerrs; + int yystate; int yyn; int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -4824,28 +4874,51 @@ YYSTYPE yylval; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; - yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ + yyssp = yyss; yyvsp = yyvs; @@ -4875,6 +4948,7 @@ YYSTYPE yylval; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; + /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -4882,6 +4956,7 @@ YYSTYPE yylval; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); yyss = yyss1; @@ -4904,8 +4979,9 @@ YYSTYPE yylval; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -4916,6 +4992,7 @@ YYSTYPE yylval; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; + YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -4925,9 +5002,6 @@ YYSTYPE yylval; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - if (yystate == YYFINAL) - YYACCEPT; - goto yybackup; /*-----------. @@ -4936,16 +5010,16 @@ YYSTYPE yylval; yybackup: /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ + look-ahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to lookahead token. */ + /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; - if (yypact_value_is_default (yyn)) + if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ + /* Not known => get a look-ahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -4971,22 +5045,26 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yytable_value_is_error (yyn)) - goto yyerrlab; + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; yyn = -yyn; goto yyreduce; } + if (yyn == YYFINAL) + YYACCEPT; + /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the lookahead token. */ + /* Shift the look-ahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token. */ - yychar = YYEMPTY; + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -5026,8 +5104,6 @@ yyreduce: switch (yyn) { case 2: - -/* Line 1806 of yacc.c */ #line 782 "ripper.y" { lex_state = EXPR_BEG; @@ -5036,12 +5112,10 @@ yyreduce: #endif local_push(0); - } + ;} break; case 3: - -/* Line 1806 of yacc.c */ #line 791 "ripper.y" { #if 0 @@ -5062,12 +5136,10 @@ yyreduce: parser->result = dispatch1(program, (yyval.val)); local_pop(); - } + ;} break; case 4: - -/* Line 1806 of yacc.c */ #line 814 "ripper.y" { #if 0 @@ -5076,12 +5148,10 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (2)].val); - } + ;} break; case 5: - -/* Line 1806 of yacc.c */ #line 825 "ripper.y" { #if 0 @@ -5090,12 +5160,10 @@ yyreduce: (yyval.val) = dispatch2(stmts_add, dispatch0(stmts_new), dispatch0(void_stmt)); - } + ;} break; case 6: - -/* Line 1806 of yacc.c */ #line 834 "ripper.y" { #if 0 @@ -5103,12 +5171,10 @@ yyreduce: #endif (yyval.val) = dispatch2(stmts_add, dispatch0(stmts_new), (yyvsp[(1) - (1)].val)); - } + ;} break; case 7: - -/* Line 1806 of yacc.c */ #line 842 "ripper.y" { #if 0 @@ -5116,21 +5182,17 @@ yyreduce: #endif (yyval.val) = dispatch2(stmts_add, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 8: - -/* Line 1806 of yacc.c */ #line 850 "ripper.y" { (yyval.val) = remove_begin((yyvsp[(2) - (2)].val)); - } + ;} break; case 10: - -/* Line 1806 of yacc.c */ #line 857 "ripper.y" { if (in_def || in_single) { @@ -5140,12 +5202,10 @@ yyreduce: /* local_push(0); */ #endif - } + ;} break; case 11: - -/* Line 1806 of yacc.c */ #line 867 "ripper.y" { #if 0 @@ -5157,12 +5217,10 @@ yyreduce: #endif (yyval.val) = dispatch1(BEGIN, (yyvsp[(4) - (5)].val)); - } + ;} break; case 12: - -/* Line 1806 of yacc.c */ #line 884 "ripper.y" { #if 0 @@ -5190,12 +5248,10 @@ yyreduce: escape_Qundef((yyvsp[(3) - (4)].val)), escape_Qundef((yyvsp[(4) - (4)].val))); - } + ;} break; case 13: - -/* Line 1806 of yacc.c */ #line 914 "ripper.y" { #if 0 @@ -5204,12 +5260,10 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (2)].val); - } + ;} break; case 14: - -/* Line 1806 of yacc.c */ #line 925 "ripper.y" { #if 0 @@ -5218,12 +5272,10 @@ yyreduce: (yyval.val) = dispatch2(stmts_add, dispatch0(stmts_new), dispatch0(void_stmt)); - } + ;} break; case 15: - -/* Line 1806 of yacc.c */ #line 934 "ripper.y" { #if 0 @@ -5231,12 +5283,10 @@ yyreduce: #endif (yyval.val) = dispatch2(stmts_add, dispatch0(stmts_new), (yyvsp[(1) - (1)].val)); - } + ;} break; case 16: - -/* Line 1806 of yacc.c */ #line 942 "ripper.y" { #if 0 @@ -5244,28 +5294,22 @@ yyreduce: #endif (yyval.val) = dispatch2(stmts_add, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 17: - -/* Line 1806 of yacc.c */ #line 950 "ripper.y" { (yyval.val) = remove_begin((yyvsp[(2) - (2)].val)); - } + ;} break; case 18: - -/* Line 1806 of yacc.c */ #line 955 "ripper.y" - {lex_state = EXPR_FNAME;} + {lex_state = EXPR_FNAME;;} break; case 19: - -/* Line 1806 of yacc.c */ #line 956 "ripper.y" { #if 0 @@ -5273,12 +5317,10 @@ yyreduce: #endif (yyval.val) = dispatch2(alias, (yyvsp[(2) - (4)].val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 20: - -/* Line 1806 of yacc.c */ #line 964 "ripper.y" { #if 0 @@ -5286,12 +5328,10 @@ yyreduce: #endif (yyval.val) = dispatch2(var_alias, (yyvsp[(2) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 21: - -/* Line 1806 of yacc.c */ #line 972 "ripper.y" { #if 0 @@ -5302,12 +5342,10 @@ yyreduce: #endif (yyval.val) = dispatch2(var_alias, (yyvsp[(2) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 22: - -/* Line 1806 of yacc.c */ #line 983 "ripper.y" { #if 0 @@ -5317,12 +5355,10 @@ yyreduce: (yyval.val) = dispatch2(var_alias, (yyvsp[(2) - (3)].val), (yyvsp[(3) - (3)].val)); (yyval.val) = dispatch1(alias_error, (yyval.val)); - } + ;} break; case 23: - -/* Line 1806 of yacc.c */ #line 993 "ripper.y" { #if 0 @@ -5330,12 +5366,10 @@ yyreduce: #endif (yyval.val) = dispatch1(undef, (yyvsp[(2) - (2)].val)); - } + ;} break; case 24: - -/* Line 1806 of yacc.c */ #line 1001 "ripper.y" { #if 0 @@ -5344,12 +5378,10 @@ yyreduce: #endif (yyval.val) = dispatch2(if_mod, (yyvsp[(3) - (3)].val), (yyvsp[(1) - (3)].val)); - } + ;} break; case 25: - -/* Line 1806 of yacc.c */ #line 1010 "ripper.y" { #if 0 @@ -5358,12 +5390,10 @@ yyreduce: #endif (yyval.val) = dispatch2(unless_mod, (yyvsp[(3) - (3)].val), (yyvsp[(1) - (3)].val)); - } + ;} break; case 26: - -/* Line 1806 of yacc.c */ #line 1019 "ripper.y" { #if 0 @@ -5376,12 +5406,10 @@ yyreduce: #endif (yyval.val) = dispatch2(while_mod, (yyvsp[(3) - (3)].val), (yyvsp[(1) - (3)].val)); - } + ;} break; case 27: - -/* Line 1806 of yacc.c */ #line 1032 "ripper.y" { #if 0 @@ -5394,12 +5422,10 @@ yyreduce: #endif (yyval.val) = dispatch2(until_mod, (yyvsp[(3) - (3)].val), (yyvsp[(1) - (3)].val)); - } + ;} break; case 28: - -/* Line 1806 of yacc.c */ #line 1045 "ripper.y" { #if 0 @@ -5408,12 +5434,10 @@ yyreduce: #endif (yyval.val) = dispatch2(rescue_mod, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 29: - -/* Line 1806 of yacc.c */ #line 1054 "ripper.y" { if (in_def || in_single) { @@ -5425,12 +5449,10 @@ yyreduce: #endif (yyval.val) = dispatch1(END, (yyvsp[(3) - (4)].val)); - } + ;} break; case 31: - -/* Line 1806 of yacc.c */ #line 1067 "ripper.y" { #if 0 @@ -5440,12 +5462,10 @@ yyreduce: #endif (yyval.val) = dispatch2(massign, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 32: - -/* Line 1806 of yacc.c */ #line 1077 "ripper.y" { #if 0 @@ -5474,12 +5494,10 @@ yyreduce: #endif (yyval.val) = dispatch3(opassign, (yyvsp[(1) - (3)].val), (yyvsp[(2) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 33: - -/* Line 1806 of yacc.c */ #line 1106 "ripper.y" { #if 0 @@ -5500,12 +5518,10 @@ yyreduce: (yyval.val) = dispatch2(aref_field, (yyvsp[(1) - (6)].val), escape_Qundef((yyvsp[(3) - (6)].val))); (yyval.val) = dispatch3(opassign, (yyval.val), (yyvsp[(5) - (6)].val), (yyvsp[(6) - (6)].val)); - } + ;} break; case 34: - -/* Line 1806 of yacc.c */ #line 1127 "ripper.y" { #if 0 @@ -5522,12 +5538,10 @@ yyreduce: (yyval.val) = dispatch3(field, (yyvsp[(1) - (5)].val), ripper_id2sym('.'), (yyvsp[(3) - (5)].val)); (yyval.val) = dispatch3(opassign, (yyval.val), (yyvsp[(4) - (5)].val), (yyvsp[(5) - (5)].val)); - } + ;} break; case 35: - -/* Line 1806 of yacc.c */ #line 1144 "ripper.y" { #if 0 @@ -5544,12 +5558,10 @@ yyreduce: (yyval.val) = dispatch3(field, (yyvsp[(1) - (5)].val), ripper_id2sym('.'), (yyvsp[(3) - (5)].val)); (yyval.val) = dispatch3(opassign, (yyval.val), (yyvsp[(4) - (5)].val), (yyvsp[(5) - (5)].val)); - } + ;} break; case 36: - -/* Line 1806 of yacc.c */ #line 1161 "ripper.y" { #if 0 @@ -5560,12 +5572,10 @@ yyreduce: (yyval.val) = dispatch3(opassign, (yyval.val), (yyvsp[(4) - (5)].val), (yyvsp[(5) - (5)].val)); (yyval.val) = dispatch1(assign_error, (yyval.val)); - } + ;} break; case 37: - -/* Line 1806 of yacc.c */ #line 1172 "ripper.y" { #if 0 @@ -5582,12 +5592,10 @@ yyreduce: (yyval.val) = dispatch3(field, (yyvsp[(1) - (5)].val), ripper_intern("::"), (yyvsp[(3) - (5)].val)); (yyval.val) = dispatch3(opassign, (yyval.val), (yyvsp[(4) - (5)].val), (yyvsp[(5) - (5)].val)); - } + ;} break; case 38: - -/* Line 1806 of yacc.c */ #line 1189 "ripper.y" { #if 0 @@ -5597,12 +5605,10 @@ yyreduce: (yyval.val) = dispatch2(assign, dispatch1(var_field, (yyvsp[(1) - (3)].val)), (yyvsp[(3) - (3)].val)); (yyval.val) = dispatch1(assign_error, (yyval.val)); - } + ;} break; case 39: - -/* Line 1806 of yacc.c */ #line 1199 "ripper.y" { #if 0 @@ -5611,12 +5617,10 @@ yyreduce: #endif (yyval.val) = dispatch2(assign, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 40: - -/* Line 1806 of yacc.c */ #line 1208 "ripper.y" { #if 0 @@ -5625,12 +5629,10 @@ yyreduce: #endif (yyval.val) = dispatch2(massign, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 41: - -/* Line 1806 of yacc.c */ #line 1217 "ripper.y" { #if 0 @@ -5639,12 +5641,10 @@ yyreduce: #endif (yyval.val) = dispatch2(massign, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 43: - -/* Line 1806 of yacc.c */ #line 1229 "ripper.y" { #if 0 @@ -5653,12 +5653,10 @@ yyreduce: #endif (yyval.val) = dispatch2(assign, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 44: - -/* Line 1806 of yacc.c */ #line 1238 "ripper.y" { #if 0 @@ -5667,12 +5665,10 @@ yyreduce: #endif (yyval.val) = dispatch2(assign, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 46: - -/* Line 1806 of yacc.c */ #line 1251 "ripper.y" { #if 0 @@ -5680,12 +5676,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("and"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 47: - -/* Line 1806 of yacc.c */ #line 1259 "ripper.y" { #if 0 @@ -5693,12 +5687,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("or"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 48: - -/* Line 1806 of yacc.c */ #line 1267 "ripper.y" { #if 0 @@ -5706,12 +5698,10 @@ yyreduce: #endif (yyval.val) = dispatch2(unary, ripper_intern("not"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 49: - -/* Line 1806 of yacc.c */ #line 1275 "ripper.y" { #if 0 @@ -5719,12 +5709,10 @@ yyreduce: #endif (yyval.val) = dispatch2(unary, ripper_id2sym('!'), (yyvsp[(2) - (2)].val)); - } + ;} break; case 51: - -/* Line 1806 of yacc.c */ #line 1286 "ripper.y" { #if 0 @@ -5734,12 +5722,10 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 55: - -/* Line 1806 of yacc.c */ #line 1303 "ripper.y" { #if 0 @@ -5748,12 +5734,10 @@ yyreduce: (yyval.val) = dispatch3(call, (yyvsp[(1) - (4)].val), ripper_id2sym('.'), (yyvsp[(3) - (4)].val)); (yyval.val) = method_arg((yyval.val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 56: - -/* Line 1806 of yacc.c */ #line 1312 "ripper.y" { #if 0 @@ -5762,12 +5746,10 @@ yyreduce: (yyval.val) = dispatch3(call, (yyvsp[(1) - (4)].val), ripper_intern("::"), (yyvsp[(3) - (4)].val)); (yyval.val) = method_arg((yyval.val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 57: - -/* Line 1806 of yacc.c */ #line 1323 "ripper.y" { (yyvsp[(1) - (1)].vars) = dyna_push(); @@ -5775,12 +5757,10 @@ yyreduce: (yyval.num) = ruby_sourceline; #endif - } + ;} break; case 58: - -/* Line 1806 of yacc.c */ #line 1333 "ripper.y" { #if 0 @@ -5790,12 +5770,10 @@ yyreduce: (yyval.val) = dispatch2(brace_block, escape_Qundef((yyvsp[(3) - (5)].val)), (yyvsp[(4) - (5)].val)); dyna_pop((yyvsp[(1) - (5)].vars)); - } + ;} break; case 59: - -/* Line 1806 of yacc.c */ #line 1345 "ripper.y" { #if 0 @@ -5804,12 +5782,10 @@ yyreduce: #endif (yyval.val) = dispatch2(command, (yyvsp[(1) - (2)].val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 60: - -/* Line 1806 of yacc.c */ #line 1354 "ripper.y" { #if 0 @@ -5821,12 +5797,10 @@ yyreduce: (yyval.val) = dispatch2(command, (yyvsp[(1) - (3)].val), (yyvsp[(2) - (3)].val)); (yyval.val) = method_add_block((yyval.val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 61: - -/* Line 1806 of yacc.c */ #line 1366 "ripper.y" { #if 0 @@ -5835,12 +5809,10 @@ yyreduce: #endif (yyval.val) = dispatch4(command_call, (yyvsp[(1) - (4)].val), ripper_id2sym('.'), (yyvsp[(3) - (4)].val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 62: - -/* Line 1806 of yacc.c */ #line 1375 "ripper.y" { #if 0 @@ -5852,12 +5824,10 @@ yyreduce: (yyval.val) = dispatch4(command_call, (yyvsp[(1) - (5)].val), ripper_id2sym('.'), (yyvsp[(3) - (5)].val), (yyvsp[(4) - (5)].val)); (yyval.val) = method_add_block((yyval.val), (yyvsp[(5) - (5)].val)); - } + ;} break; case 63: - -/* Line 1806 of yacc.c */ #line 1387 "ripper.y" { #if 0 @@ -5866,12 +5836,10 @@ yyreduce: #endif (yyval.val) = dispatch4(command_call, (yyvsp[(1) - (4)].val), ripper_intern("::"), (yyvsp[(3) - (4)].val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 64: - -/* Line 1806 of yacc.c */ #line 1396 "ripper.y" { #if 0 @@ -5883,12 +5851,10 @@ yyreduce: (yyval.val) = dispatch4(command_call, (yyvsp[(1) - (5)].val), ripper_intern("::"), (yyvsp[(3) - (5)].val), (yyvsp[(4) - (5)].val)); (yyval.val) = method_add_block((yyval.val), (yyvsp[(5) - (5)].val)); - } + ;} break; case 65: - -/* Line 1806 of yacc.c */ #line 1408 "ripper.y" { #if 0 @@ -5897,12 +5863,10 @@ yyreduce: #endif (yyval.val) = dispatch1(super, (yyvsp[(2) - (2)].val)); - } + ;} break; case 66: - -/* Line 1806 of yacc.c */ #line 1417 "ripper.y" { #if 0 @@ -5911,12 +5875,10 @@ yyreduce: #endif (yyval.val) = dispatch1(yield, (yyvsp[(2) - (2)].val)); - } + ;} break; case 67: - -/* Line 1806 of yacc.c */ #line 1426 "ripper.y" { #if 0 @@ -5924,12 +5886,10 @@ yyreduce: #endif (yyval.val) = dispatch1(return, (yyvsp[(2) - (2)].val)); - } + ;} break; case 68: - -/* Line 1806 of yacc.c */ #line 1434 "ripper.y" { #if 0 @@ -5937,12 +5897,10 @@ yyreduce: #endif (yyval.val) = dispatch1(break, (yyvsp[(2) - (2)].val)); - } + ;} break; case 69: - -/* Line 1806 of yacc.c */ #line 1442 "ripper.y" { #if 0 @@ -5950,12 +5908,10 @@ yyreduce: #endif (yyval.val) = dispatch1(next, (yyvsp[(2) - (2)].val)); - } + ;} break; case 71: - -/* Line 1806 of yacc.c */ #line 1453 "ripper.y" { #if 0 @@ -5963,12 +5919,10 @@ yyreduce: #endif (yyval.val) = dispatch1(mlhs_paren, (yyvsp[(2) - (3)].val)); - } + ;} break; case 73: - -/* Line 1806 of yacc.c */ #line 1464 "ripper.y" { #if 0 @@ -5976,12 +5930,10 @@ yyreduce: #endif (yyval.val) = dispatch1(mlhs_paren, (yyvsp[(2) - (3)].val)); - } + ;} break; case 74: - -/* Line 1806 of yacc.c */ #line 1474 "ripper.y" { #if 0 @@ -5989,12 +5941,10 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 75: - -/* Line 1806 of yacc.c */ #line 1482 "ripper.y" { #if 0 @@ -6002,12 +5952,10 @@ yyreduce: #endif (yyval.val) = mlhs_add((yyvsp[(1) - (2)].val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 76: - -/* Line 1806 of yacc.c */ #line 1490 "ripper.y" { #if 0 @@ -6015,12 +5963,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 77: - -/* Line 1806 of yacc.c */ #line 1498 "ripper.y" { #if 0 @@ -6029,12 +5975,10 @@ yyreduce: (yyvsp[(1) - (5)].val) = mlhs_add_star((yyvsp[(1) - (5)].val), (yyvsp[(3) - (5)].val)); (yyval.val) = mlhs_add((yyvsp[(1) - (5)].val), (yyvsp[(5) - (5)].val)); - } + ;} break; case 78: - -/* Line 1806 of yacc.c */ #line 1507 "ripper.y" { #if 0 @@ -6042,12 +5986,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star((yyvsp[(1) - (2)].val), Qnil); - } + ;} break; case 79: - -/* Line 1806 of yacc.c */ #line 1515 "ripper.y" { #if 0 @@ -6056,12 +5998,10 @@ yyreduce: (yyvsp[(1) - (4)].val) = mlhs_add_star((yyvsp[(1) - (4)].val), Qnil); (yyval.val) = mlhs_add((yyvsp[(1) - (4)].val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 80: - -/* Line 1806 of yacc.c */ #line 1524 "ripper.y" { #if 0 @@ -6069,12 +6009,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star(mlhs_new(), (yyvsp[(2) - (2)].val)); - } + ;} break; case 81: - -/* Line 1806 of yacc.c */ #line 1532 "ripper.y" { #if 0 @@ -6083,12 +6021,10 @@ yyreduce: (yyvsp[(2) - (4)].val) = mlhs_add_star(mlhs_new(), (yyvsp[(2) - (4)].val)); (yyval.val) = mlhs_add((yyvsp[(2) - (4)].val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 82: - -/* Line 1806 of yacc.c */ #line 1541 "ripper.y" { #if 0 @@ -6096,12 +6032,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star(mlhs_new(), Qnil); - } + ;} break; case 83: - -/* Line 1806 of yacc.c */ #line 1549 "ripper.y" { #if 0 @@ -6110,12 +6044,10 @@ yyreduce: (yyval.val) = mlhs_add_star(mlhs_new(), Qnil); (yyval.val) = mlhs_add((yyval.val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 85: - -/* Line 1806 of yacc.c */ #line 1561 "ripper.y" { #if 0 @@ -6123,12 +6055,10 @@ yyreduce: #endif (yyval.val) = dispatch1(mlhs_paren, (yyvsp[(2) - (3)].val)); - } + ;} break; case 86: - -/* Line 1806 of yacc.c */ #line 1571 "ripper.y" { #if 0 @@ -6136,12 +6066,10 @@ yyreduce: #endif (yyval.val) = mlhs_add(mlhs_new(), (yyvsp[(1) - (2)].val)); - } + ;} break; case 87: - -/* Line 1806 of yacc.c */ #line 1579 "ripper.y" { #if 0 @@ -6149,12 +6077,10 @@ yyreduce: #endif (yyval.val) = mlhs_add((yyvsp[(1) - (3)].val), (yyvsp[(2) - (3)].val)); - } + ;} break; case 88: - -/* Line 1806 of yacc.c */ #line 1589 "ripper.y" { #if 0 @@ -6162,12 +6088,10 @@ yyreduce: #endif (yyval.val) = mlhs_add(mlhs_new(), (yyvsp[(1) - (1)].val)); - } + ;} break; case 89: - -/* Line 1806 of yacc.c */ #line 1597 "ripper.y" { #if 0 @@ -6175,30 +6099,24 @@ yyreduce: #endif (yyval.val) = mlhs_add((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 90: - -/* Line 1806 of yacc.c */ #line 1607 "ripper.y" { (yyval.val) = assignable((yyvsp[(1) - (1)].val), 0); - } + ;} break; case 91: - -/* Line 1806 of yacc.c */ #line 1611 "ripper.y" { (yyval.val) = assignable((yyvsp[(1) - (1)].val), 0); - } + ;} break; case 92: - -/* Line 1806 of yacc.c */ #line 1615 "ripper.y" { #if 0 @@ -6206,12 +6124,10 @@ yyreduce: #endif (yyval.val) = dispatch2(aref_field, (yyvsp[(1) - (4)].val), escape_Qundef((yyvsp[(3) - (4)].val))); - } + ;} break; case 93: - -/* Line 1806 of yacc.c */ #line 1623 "ripper.y" { #if 0 @@ -6219,12 +6135,10 @@ yyreduce: #endif (yyval.val) = dispatch3(field, (yyvsp[(1) - (3)].val), ripper_id2sym('.'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 94: - -/* Line 1806 of yacc.c */ #line 1631 "ripper.y" { #if 0 @@ -6232,12 +6146,10 @@ yyreduce: #endif (yyval.val) = dispatch2(const_path_field, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 95: - -/* Line 1806 of yacc.c */ #line 1639 "ripper.y" { #if 0 @@ -6245,12 +6157,10 @@ yyreduce: #endif (yyval.val) = dispatch3(field, (yyvsp[(1) - (3)].val), ripper_id2sym('.'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 96: - -/* Line 1806 of yacc.c */ #line 1647 "ripper.y" { #if 0 @@ -6262,12 +6172,10 @@ yyreduce: yyerror("dynamic constant assignment"); (yyval.val) = dispatch2(const_path_field, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 97: - -/* Line 1806 of yacc.c */ #line 1659 "ripper.y" { #if 0 @@ -6277,12 +6185,10 @@ yyreduce: #endif (yyval.val) = dispatch1(top_const_field, (yyvsp[(2) - (2)].val)); - } + ;} break; case 98: - -/* Line 1806 of yacc.c */ #line 1669 "ripper.y" { #if 0 @@ -6292,12 +6198,10 @@ yyreduce: (yyval.val) = dispatch1(var_field, (yyvsp[(1) - (1)].val)); (yyval.val) = dispatch1(assign_error, (yyval.val)); - } + ;} break; case 99: - -/* Line 1806 of yacc.c */ #line 1681 "ripper.y" { (yyval.val) = assignable((yyvsp[(1) - (1)].val), 0); @@ -6306,12 +6210,10 @@ yyreduce: #endif (yyval.val) = dispatch1(var_field, (yyval.val)); - } + ;} break; case 100: - -/* Line 1806 of yacc.c */ #line 1690 "ripper.y" { (yyval.val) = assignable((yyvsp[(1) - (1)].val), 0); @@ -6320,12 +6222,10 @@ yyreduce: #endif (yyval.val) = dispatch1(var_field, (yyval.val)); - } + ;} break; case 101: - -/* Line 1806 of yacc.c */ #line 1699 "ripper.y" { #if 0 @@ -6333,12 +6233,10 @@ yyreduce: #endif (yyval.val) = dispatch2(aref_field, (yyvsp[(1) - (4)].val), escape_Qundef((yyvsp[(3) - (4)].val))); - } + ;} break; case 102: - -/* Line 1806 of yacc.c */ #line 1707 "ripper.y" { #if 0 @@ -6346,12 +6244,10 @@ yyreduce: #endif (yyval.val) = dispatch3(field, (yyvsp[(1) - (3)].val), ripper_id2sym('.'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 103: - -/* Line 1806 of yacc.c */ #line 1715 "ripper.y" { #if 0 @@ -6359,12 +6255,10 @@ yyreduce: #endif (yyval.val) = dispatch3(field, (yyvsp[(1) - (3)].val), ripper_intern("::"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 104: - -/* Line 1806 of yacc.c */ #line 1723 "ripper.y" { #if 0 @@ -6372,12 +6266,10 @@ yyreduce: #endif (yyval.val) = dispatch3(field, (yyvsp[(1) - (3)].val), ripper_id2sym('.'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 105: - -/* Line 1806 of yacc.c */ #line 1731 "ripper.y" { #if 0 @@ -6390,12 +6282,10 @@ yyreduce: (yyval.val) = dispatch1(assign_error, (yyval.val)); } - } + ;} break; case 106: - -/* Line 1806 of yacc.c */ #line 1744 "ripper.y" { #if 0 @@ -6408,12 +6298,10 @@ yyreduce: (yyval.val) = dispatch1(assign_error, (yyval.val)); } - } + ;} break; case 107: - -/* Line 1806 of yacc.c */ #line 1757 "ripper.y" { #if 0 @@ -6422,12 +6310,10 @@ yyreduce: #endif (yyval.val) = dispatch1(assign_error, (yyvsp[(1) - (1)].val)); - } + ;} break; case 108: - -/* Line 1806 of yacc.c */ #line 1768 "ripper.y" { #if 0 @@ -6435,12 +6321,10 @@ yyreduce: #endif (yyval.val) = dispatch1(class_name_error, (yyvsp[(1) - (1)].val)); - } + ;} break; case 110: - -/* Line 1806 of yacc.c */ #line 1779 "ripper.y" { #if 0 @@ -6448,12 +6332,10 @@ yyreduce: #endif (yyval.val) = dispatch1(top_const_ref, (yyvsp[(2) - (2)].val)); - } + ;} break; case 111: - -/* Line 1806 of yacc.c */ #line 1787 "ripper.y" { #if 0 @@ -6461,12 +6343,10 @@ yyreduce: #endif (yyval.val) = dispatch1(const_ref, (yyvsp[(1) - (1)].val)); - } + ;} break; case 112: - -/* Line 1806 of yacc.c */ #line 1795 "ripper.y" { #if 0 @@ -6474,22 +6354,18 @@ yyreduce: #endif (yyval.val) = dispatch2(const_path_ref, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 116: - -/* Line 1806 of yacc.c */ #line 1808 "ripper.y" { lex_state = EXPR_ENDFN; (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 117: - -/* Line 1806 of yacc.c */ #line 1813 "ripper.y" { lex_state = EXPR_ENDFN; @@ -6498,12 +6374,10 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 120: - -/* Line 1806 of yacc.c */ #line 1828 "ripper.y" { #if 0 @@ -6511,12 +6385,10 @@ yyreduce: #endif (yyval.val) = dispatch1(symbol_literal, (yyvsp[(1) - (1)].val)); - } + ;} break; case 122: - -/* Line 1806 of yacc.c */ #line 1839 "ripper.y" { #if 0 @@ -6524,19 +6396,15 @@ yyreduce: #endif (yyval.val) = rb_ary_new3(1, (yyvsp[(1) - (1)].val)); - } + ;} break; case 123: - -/* Line 1806 of yacc.c */ #line 1846 "ripper.y" - {lex_state = EXPR_FNAME;} + {lex_state = EXPR_FNAME;;} break; case 124: - -/* Line 1806 of yacc.c */ #line 1847 "ripper.y" { #if 0 @@ -6544,215 +6412,155 @@ yyreduce: #endif rb_ary_push((yyvsp[(1) - (4)].val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 125: - -/* Line 1806 of yacc.c */ #line 1856 "ripper.y" - { ifndef_ripper((yyval.val) = '|'); } + { ifndef_ripper((yyval.val) = '|'); ;} break; case 126: - -/* Line 1806 of yacc.c */ #line 1857 "ripper.y" - { ifndef_ripper((yyval.val) = '^'); } + { ifndef_ripper((yyval.val) = '^'); ;} break; case 127: - -/* Line 1806 of yacc.c */ #line 1858 "ripper.y" - { ifndef_ripper((yyval.val) = '&'); } + { ifndef_ripper((yyval.val) = '&'); ;} break; case 128: - -/* Line 1806 of yacc.c */ #line 1859 "ripper.y" - { ifndef_ripper((yyval.val) = tCMP); } + { ifndef_ripper((yyval.val) = tCMP); ;} break; case 129: - -/* Line 1806 of yacc.c */ #line 1860 "ripper.y" - { ifndef_ripper((yyval.val) = tEQ); } + { ifndef_ripper((yyval.val) = tEQ); ;} break; case 130: - -/* Line 1806 of yacc.c */ #line 1861 "ripper.y" - { ifndef_ripper((yyval.val) = tEQQ); } + { ifndef_ripper((yyval.val) = tEQQ); ;} break; case 131: - -/* Line 1806 of yacc.c */ #line 1862 "ripper.y" - { ifndef_ripper((yyval.val) = tMATCH); } + { ifndef_ripper((yyval.val) = tMATCH); ;} break; case 132: - -/* Line 1806 of yacc.c */ #line 1863 "ripper.y" - { ifndef_ripper((yyval.val) = tNMATCH); } + { ifndef_ripper((yyval.val) = tNMATCH); ;} break; case 133: - -/* Line 1806 of yacc.c */ #line 1864 "ripper.y" - { ifndef_ripper((yyval.val) = '>'); } + { ifndef_ripper((yyval.val) = '>'); ;} break; case 134: - -/* Line 1806 of yacc.c */ #line 1865 "ripper.y" - { ifndef_ripper((yyval.val) = tGEQ); } + { ifndef_ripper((yyval.val) = tGEQ); ;} break; case 135: - -/* Line 1806 of yacc.c */ #line 1866 "ripper.y" - { ifndef_ripper((yyval.val) = '<'); } + { ifndef_ripper((yyval.val) = '<'); ;} break; case 136: - -/* Line 1806 of yacc.c */ #line 1867 "ripper.y" - { ifndef_ripper((yyval.val) = tLEQ); } + { ifndef_ripper((yyval.val) = tLEQ); ;} break; case 137: - -/* Line 1806 of yacc.c */ #line 1868 "ripper.y" - { ifndef_ripper((yyval.val) = tNEQ); } + { ifndef_ripper((yyval.val) = tNEQ); ;} break; case 138: - -/* Line 1806 of yacc.c */ #line 1869 "ripper.y" - { ifndef_ripper((yyval.val) = tLSHFT); } + { ifndef_ripper((yyval.val) = tLSHFT); ;} break; case 139: - -/* Line 1806 of yacc.c */ #line 1870 "ripper.y" - { ifndef_ripper((yyval.val) = tRSHFT); } + { ifndef_ripper((yyval.val) = tRSHFT); ;} break; case 140: - -/* Line 1806 of yacc.c */ #line 1871 "ripper.y" - { ifndef_ripper((yyval.val) = '+'); } + { ifndef_ripper((yyval.val) = '+'); ;} break; case 141: - -/* Line 1806 of yacc.c */ #line 1872 "ripper.y" - { ifndef_ripper((yyval.val) = '-'); } + { ifndef_ripper((yyval.val) = '-'); ;} break; case 142: - -/* Line 1806 of yacc.c */ #line 1873 "ripper.y" - { ifndef_ripper((yyval.val) = '*'); } + { ifndef_ripper((yyval.val) = '*'); ;} break; case 143: - -/* Line 1806 of yacc.c */ #line 1874 "ripper.y" - { ifndef_ripper((yyval.val) = '*'); } + { ifndef_ripper((yyval.val) = '*'); ;} break; case 144: - -/* Line 1806 of yacc.c */ #line 1875 "ripper.y" - { ifndef_ripper((yyval.val) = '/'); } + { ifndef_ripper((yyval.val) = '/'); ;} break; case 145: - -/* Line 1806 of yacc.c */ #line 1876 "ripper.y" - { ifndef_ripper((yyval.val) = '%'); } + { ifndef_ripper((yyval.val) = '%'); ;} break; case 146: - -/* Line 1806 of yacc.c */ #line 1877 "ripper.y" - { ifndef_ripper((yyval.val) = tPOW); } + { ifndef_ripper((yyval.val) = tPOW); ;} break; case 147: - -/* Line 1806 of yacc.c */ #line 1878 "ripper.y" - { ifndef_ripper((yyval.val) = '!'); } + { ifndef_ripper((yyval.val) = '!'); ;} break; case 148: - -/* Line 1806 of yacc.c */ #line 1879 "ripper.y" - { ifndef_ripper((yyval.val) = '~'); } + { ifndef_ripper((yyval.val) = '~'); ;} break; case 149: - -/* Line 1806 of yacc.c */ #line 1880 "ripper.y" - { ifndef_ripper((yyval.val) = tUPLUS); } + { ifndef_ripper((yyval.val) = tUPLUS); ;} break; case 150: - -/* Line 1806 of yacc.c */ #line 1881 "ripper.y" - { ifndef_ripper((yyval.val) = tUMINUS); } + { ifndef_ripper((yyval.val) = tUMINUS); ;} break; case 151: - -/* Line 1806 of yacc.c */ #line 1882 "ripper.y" - { ifndef_ripper((yyval.val) = tAREF); } + { ifndef_ripper((yyval.val) = tAREF); ;} break; case 152: - -/* Line 1806 of yacc.c */ #line 1883 "ripper.y" - { ifndef_ripper((yyval.val) = tASET); } + { ifndef_ripper((yyval.val) = tASET); ;} break; case 153: - -/* Line 1806 of yacc.c */ #line 1884 "ripper.y" - { ifndef_ripper((yyval.val) = '`'); } + { ifndef_ripper((yyval.val) = '`'); ;} break; case 195: - -/* Line 1806 of yacc.c */ #line 1902 "ripper.y" { #if 0 @@ -6761,12 +6569,10 @@ yyreduce: #endif (yyval.val) = dispatch2(assign, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 196: - -/* Line 1806 of yacc.c */ #line 1911 "ripper.y" { #if 0 @@ -6776,12 +6582,10 @@ yyreduce: #endif (yyval.val) = dispatch2(assign, (yyvsp[(1) - (5)].val), dispatch2(rescue_mod, (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val))); - } + ;} break; case 197: - -/* Line 1806 of yacc.c */ #line 1921 "ripper.y" { #if 0 @@ -6810,12 +6614,10 @@ yyreduce: #endif (yyval.val) = dispatch3(opassign, (yyvsp[(1) - (3)].val), (yyvsp[(2) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 198: - -/* Line 1806 of yacc.c */ #line 1950 "ripper.y" { #if 0 @@ -6846,12 +6648,10 @@ yyreduce: (yyvsp[(3) - (5)].val) = dispatch2(rescue_mod, (yyvsp[(3) - (5)].val), (yyvsp[(5) - (5)].val)); (yyval.val) = dispatch3(opassign, (yyvsp[(1) - (5)].val), (yyvsp[(2) - (5)].val), (yyvsp[(3) - (5)].val)); - } + ;} break; case 199: - -/* Line 1806 of yacc.c */ #line 1981 "ripper.y" { #if 0 @@ -6877,12 +6677,10 @@ yyreduce: (yyvsp[(1) - (6)].val) = dispatch2(aref_field, (yyvsp[(1) - (6)].val), escape_Qundef((yyvsp[(3) - (6)].val))); (yyval.val) = dispatch3(opassign, (yyvsp[(1) - (6)].val), (yyvsp[(5) - (6)].val), (yyvsp[(6) - (6)].val)); - } + ;} break; case 200: - -/* Line 1806 of yacc.c */ #line 2007 "ripper.y" { #if 0 @@ -6899,12 +6697,10 @@ yyreduce: (yyvsp[(1) - (5)].val) = dispatch3(field, (yyvsp[(1) - (5)].val), ripper_id2sym('.'), (yyvsp[(3) - (5)].val)); (yyval.val) = dispatch3(opassign, (yyvsp[(1) - (5)].val), (yyvsp[(4) - (5)].val), (yyvsp[(5) - (5)].val)); - } + ;} break; case 201: - -/* Line 1806 of yacc.c */ #line 2024 "ripper.y" { #if 0 @@ -6921,12 +6717,10 @@ yyreduce: (yyvsp[(1) - (5)].val) = dispatch3(field, (yyvsp[(1) - (5)].val), ripper_id2sym('.'), (yyvsp[(3) - (5)].val)); (yyval.val) = dispatch3(opassign, (yyvsp[(1) - (5)].val), (yyvsp[(4) - (5)].val), (yyvsp[(5) - (5)].val)); - } + ;} break; case 202: - -/* Line 1806 of yacc.c */ #line 2041 "ripper.y" { #if 0 @@ -6943,12 +6737,10 @@ yyreduce: (yyvsp[(1) - (5)].val) = dispatch3(field, (yyvsp[(1) - (5)].val), ripper_intern("::"), (yyvsp[(3) - (5)].val)); (yyval.val) = dispatch3(opassign, (yyvsp[(1) - (5)].val), (yyvsp[(4) - (5)].val), (yyvsp[(5) - (5)].val)); - } + ;} break; case 203: - -/* Line 1806 of yacc.c */ #line 2058 "ripper.y" { #if 0 @@ -6959,12 +6751,10 @@ yyreduce: (yyval.val) = dispatch3(opassign, (yyval.val), (yyvsp[(4) - (5)].val), (yyvsp[(5) - (5)].val)); (yyval.val) = dispatch1(assign_error, (yyval.val)); - } + ;} break; case 204: - -/* Line 1806 of yacc.c */ #line 2069 "ripper.y" { #if 0 @@ -6975,12 +6765,10 @@ yyreduce: (yyval.val) = dispatch3(opassign, (yyval.val), (yyvsp[(3) - (4)].val), (yyvsp[(4) - (4)].val)); (yyval.val) = dispatch1(assign_error, (yyval.val)); - } + ;} break; case 205: - -/* Line 1806 of yacc.c */ #line 2080 "ripper.y" { #if 0 @@ -6991,12 +6779,10 @@ yyreduce: (yyval.val) = dispatch3(opassign, (yyval.val), (yyvsp[(2) - (3)].val), (yyvsp[(3) - (3)].val)); (yyval.val) = dispatch1(assign_error, (yyval.val)); - } + ;} break; case 206: - -/* Line 1806 of yacc.c */ #line 2091 "ripper.y" { #if 0 @@ -7010,12 +6796,10 @@ yyreduce: #endif (yyval.val) = dispatch2(dot2, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 207: - -/* Line 1806 of yacc.c */ #line 2105 "ripper.y" { #if 0 @@ -7029,12 +6813,10 @@ yyreduce: #endif (yyval.val) = dispatch2(dot3, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 208: - -/* Line 1806 of yacc.c */ #line 2119 "ripper.y" { #if 0 @@ -7042,12 +6824,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ID2SYM('+'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 209: - -/* Line 1806 of yacc.c */ #line 2127 "ripper.y" { #if 0 @@ -7055,12 +6835,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ID2SYM('-'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 210: - -/* Line 1806 of yacc.c */ #line 2135 "ripper.y" { #if 0 @@ -7068,12 +6846,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ID2SYM('*'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 211: - -/* Line 1806 of yacc.c */ #line 2143 "ripper.y" { #if 0 @@ -7081,12 +6857,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ID2SYM('/'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 212: - -/* Line 1806 of yacc.c */ #line 2151 "ripper.y" { #if 0 @@ -7094,12 +6868,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ID2SYM('%'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 213: - -/* Line 1806 of yacc.c */ #line 2159 "ripper.y" { #if 0 @@ -7107,12 +6879,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("**"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 214: - -/* Line 1806 of yacc.c */ #line 2167 "ripper.y" { #if 0 @@ -7121,12 +6891,10 @@ yyreduce: (yyval.val) = dispatch3(binary, (yyvsp[(2) - (4)].val), ripper_intern("**"), (yyvsp[(4) - (4)].val)); (yyval.val) = dispatch2(unary, ripper_intern("-@"), (yyval.val)); - } + ;} break; case 215: - -/* Line 1806 of yacc.c */ #line 2176 "ripper.y" { #if 0 @@ -7135,12 +6903,10 @@ yyreduce: (yyval.val) = dispatch3(binary, (yyvsp[(2) - (4)].val), ripper_intern("**"), (yyvsp[(4) - (4)].val)); (yyval.val) = dispatch2(unary, ripper_intern("-@"), (yyval.val)); - } + ;} break; case 216: - -/* Line 1806 of yacc.c */ #line 2185 "ripper.y" { #if 0 @@ -7148,12 +6914,10 @@ yyreduce: #endif (yyval.val) = dispatch2(unary, ripper_intern("+@"), (yyvsp[(2) - (2)].val)); - } + ;} break; case 217: - -/* Line 1806 of yacc.c */ #line 2193 "ripper.y" { #if 0 @@ -7161,12 +6925,10 @@ yyreduce: #endif (yyval.val) = dispatch2(unary, ripper_intern("-@"), (yyvsp[(2) - (2)].val)); - } + ;} break; case 218: - -/* Line 1806 of yacc.c */ #line 2201 "ripper.y" { #if 0 @@ -7174,12 +6936,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ID2SYM('|'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 219: - -/* Line 1806 of yacc.c */ #line 2209 "ripper.y" { #if 0 @@ -7187,12 +6947,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ID2SYM('^'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 220: - -/* Line 1806 of yacc.c */ #line 2217 "ripper.y" { #if 0 @@ -7200,12 +6958,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ID2SYM('&'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 221: - -/* Line 1806 of yacc.c */ #line 2225 "ripper.y" { #if 0 @@ -7213,12 +6969,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("<=>"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 222: - -/* Line 1806 of yacc.c */ #line 2233 "ripper.y" { #if 0 @@ -7226,12 +6980,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ID2SYM('>'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 223: - -/* Line 1806 of yacc.c */ #line 2241 "ripper.y" { #if 0 @@ -7239,12 +6991,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern(">="), (yyvsp[(3) - (3)].val)); - } + ;} break; case 224: - -/* Line 1806 of yacc.c */ #line 2249 "ripper.y" { #if 0 @@ -7252,12 +7002,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ID2SYM('<'), (yyvsp[(3) - (3)].val)); - } + ;} break; case 225: - -/* Line 1806 of yacc.c */ #line 2257 "ripper.y" { #if 0 @@ -7265,12 +7013,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("<="), (yyvsp[(3) - (3)].val)); - } + ;} break; case 226: - -/* Line 1806 of yacc.c */ #line 2265 "ripper.y" { #if 0 @@ -7278,12 +7024,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("=="), (yyvsp[(3) - (3)].val)); - } + ;} break; case 227: - -/* Line 1806 of yacc.c */ #line 2273 "ripper.y" { #if 0 @@ -7291,12 +7035,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("==="), (yyvsp[(3) - (3)].val)); - } + ;} break; case 228: - -/* Line 1806 of yacc.c */ #line 2281 "ripper.y" { #if 0 @@ -7304,12 +7046,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("!="), (yyvsp[(3) - (3)].val)); - } + ;} break; case 229: - -/* Line 1806 of yacc.c */ #line 2289 "ripper.y" { #if 0 @@ -7320,12 +7060,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("=~"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 230: - -/* Line 1806 of yacc.c */ #line 2300 "ripper.y" { #if 0 @@ -7333,12 +7071,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("!~"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 231: - -/* Line 1806 of yacc.c */ #line 2308 "ripper.y" { #if 0 @@ -7346,12 +7082,10 @@ yyreduce: #endif (yyval.val) = dispatch2(unary, ID2SYM('!'), (yyvsp[(2) - (2)].val)); - } + ;} break; case 232: - -/* Line 1806 of yacc.c */ #line 2316 "ripper.y" { #if 0 @@ -7359,12 +7093,10 @@ yyreduce: #endif (yyval.val) = dispatch2(unary, ID2SYM('~'), (yyvsp[(2) - (2)].val)); - } + ;} break; case 233: - -/* Line 1806 of yacc.c */ #line 2324 "ripper.y" { #if 0 @@ -7372,12 +7104,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("<<"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 234: - -/* Line 1806 of yacc.c */ #line 2332 "ripper.y" { #if 0 @@ -7385,12 +7115,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern(">>"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 235: - -/* Line 1806 of yacc.c */ #line 2340 "ripper.y" { #if 0 @@ -7398,12 +7126,10 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("&&"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 236: - -/* Line 1806 of yacc.c */ #line 2348 "ripper.y" { #if 0 @@ -7411,19 +7137,15 @@ yyreduce: #endif (yyval.val) = dispatch3(binary, (yyvsp[(1) - (3)].val), ripper_intern("||"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 237: - -/* Line 1806 of yacc.c */ #line 2355 "ripper.y" - {in_defined = 1;} + {in_defined = 1;;} break; case 238: - -/* Line 1806 of yacc.c */ #line 2356 "ripper.y" { #if 0 @@ -7433,12 +7155,10 @@ yyreduce: in_defined = 0; (yyval.val) = dispatch1(defined, (yyvsp[(4) - (4)].val)); - } + ;} break; case 239: - -/* Line 1806 of yacc.c */ #line 2366 "ripper.y" { #if 0 @@ -7448,21 +7168,17 @@ yyreduce: #endif (yyval.val) = dispatch3(ifop, (yyvsp[(1) - (6)].val), (yyvsp[(3) - (6)].val), (yyvsp[(6) - (6)].val)); - } + ;} break; case 240: - -/* Line 1806 of yacc.c */ #line 2376 "ripper.y" { (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 241: - -/* Line 1806 of yacc.c */ #line 2382 "ripper.y" { #if 0 @@ -7472,21 +7188,17 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 243: - -/* Line 1806 of yacc.c */ #line 2395 "ripper.y" { (yyval.val) = (yyvsp[(1) - (2)].val); - } + ;} break; case 244: - -/* Line 1806 of yacc.c */ #line 2399 "ripper.y" { #if 0 @@ -7494,12 +7206,10 @@ yyreduce: #endif (yyval.val) = arg_add_assocs((yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val)); - } + ;} break; case 245: - -/* Line 1806 of yacc.c */ #line 2407 "ripper.y" { #if 0 @@ -7507,12 +7217,10 @@ yyreduce: #endif (yyval.val) = arg_add_assocs(arg_new(), (yyvsp[(1) - (2)].val)); - } + ;} break; case 246: - -/* Line 1806 of yacc.c */ #line 2417 "ripper.y" { #if 0 @@ -7520,21 +7228,17 @@ yyreduce: #endif (yyval.val) = dispatch1(arg_paren, escape_Qundef((yyvsp[(2) - (3)].val))); - } + ;} break; case 251: - -/* Line 1806 of yacc.c */ #line 2433 "ripper.y" { (yyval.val) = (yyvsp[(1) - (2)].val); - } + ;} break; case 252: - -/* Line 1806 of yacc.c */ #line 2437 "ripper.y" { #if 0 @@ -7542,12 +7246,10 @@ yyreduce: #endif (yyval.val) = arg_add_assocs((yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val)); - } + ;} break; case 253: - -/* Line 1806 of yacc.c */ #line 2445 "ripper.y" { #if 0 @@ -7555,12 +7257,10 @@ yyreduce: #endif (yyval.val) = arg_add_assocs(arg_new(), (yyvsp[(1) - (2)].val)); - } + ;} break; case 254: - -/* Line 1806 of yacc.c */ #line 2455 "ripper.y" { #if 0 @@ -7569,12 +7269,10 @@ yyreduce: #endif (yyval.val) = arg_add(arg_new(), (yyvsp[(1) - (1)].val)); - } + ;} break; case 255: - -/* Line 1806 of yacc.c */ #line 2464 "ripper.y" { #if 0 @@ -7582,12 +7280,10 @@ yyreduce: #endif (yyval.val) = arg_add_optblock((yyvsp[(1) - (2)].val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 256: - -/* Line 1806 of yacc.c */ #line 2472 "ripper.y" { #if 0 @@ -7597,12 +7293,10 @@ yyreduce: (yyval.val) = arg_add_assocs(arg_new(), (yyvsp[(1) - (2)].val)); (yyval.val) = arg_add_optblock((yyval.val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 257: - -/* Line 1806 of yacc.c */ #line 2482 "ripper.y" { #if 0 @@ -7611,42 +7305,34 @@ yyreduce: #endif (yyval.val) = arg_add_optblock(arg_add_assocs((yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val)), (yyvsp[(4) - (4)].val)); - } + ;} break; case 258: - -/* Line 1806 of yacc.c */ #line 2493 "ripper.y" { (yyval.val) = arg_add_block(arg_new(), (yyvsp[(1) - (1)].val)); - } + ;} break; case 259: - -/* Line 1806 of yacc.c */ #line 2499 "ripper.y" { (yyval.val) = cmdarg_stack; CMDARG_PUSH(1); - } + ;} break; case 260: - -/* Line 1806 of yacc.c */ #line 2504 "ripper.y" { /* CMDARG_POP() */ cmdarg_stack = (yyvsp[(1) - (2)].val); (yyval.val) = (yyvsp[(2) - (2)].val); - } + ;} break; case 261: - -/* Line 1806 of yacc.c */ #line 2512 "ripper.y" { #if 0 @@ -7654,30 +7340,24 @@ yyreduce: #endif (yyval.val) = (yyvsp[(2) - (2)].val); - } + ;} break; case 262: - -/* Line 1806 of yacc.c */ #line 2522 "ripper.y" { (yyval.val) = (yyvsp[(2) - (2)].val); - } + ;} break; case 263: - -/* Line 1806 of yacc.c */ #line 2526 "ripper.y" { (yyval.val) = 0; - } + ;} break; case 264: - -/* Line 1806 of yacc.c */ #line 2532 "ripper.y" { #if 0 @@ -7685,12 +7365,10 @@ yyreduce: #endif (yyval.val) = arg_add(arg_new(), (yyvsp[(1) - (1)].val)); - } + ;} break; case 265: - -/* Line 1806 of yacc.c */ #line 2540 "ripper.y" { #if 0 @@ -7698,12 +7376,10 @@ yyreduce: #endif (yyval.val) = arg_add_star(arg_new(), (yyvsp[(2) - (2)].val)); - } + ;} break; case 266: - -/* Line 1806 of yacc.c */ #line 2548 "ripper.y" { #if 0 @@ -7717,12 +7393,10 @@ yyreduce: #endif (yyval.val) = arg_add((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 267: - -/* Line 1806 of yacc.c */ #line 2562 "ripper.y" { #if 0 @@ -7736,12 +7410,10 @@ yyreduce: #endif (yyval.val) = arg_add_star((yyvsp[(1) - (4)].val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 268: - -/* Line 1806 of yacc.c */ #line 2578 "ripper.y" { #if 0 @@ -7755,12 +7427,10 @@ yyreduce: #endif (yyval.val) = mrhs_add(args2mrhs((yyvsp[(1) - (3)].val)), (yyvsp[(3) - (3)].val)); - } + ;} break; case 269: - -/* Line 1806 of yacc.c */ #line 2592 "ripper.y" { #if 0 @@ -7775,12 +7445,10 @@ yyreduce: #endif (yyval.val) = mrhs_add_star(args2mrhs((yyvsp[(1) - (4)].val)), (yyvsp[(4) - (4)].val)); - } + ;} break; case 270: - -/* Line 1806 of yacc.c */ #line 2607 "ripper.y" { #if 0 @@ -7788,12 +7456,10 @@ yyreduce: #endif (yyval.val) = mrhs_add_star(mrhs_new(), (yyvsp[(2) - (2)].val)); - } + ;} break; case 279: - -/* Line 1806 of yacc.c */ #line 2625 "ripper.y" { #if 0 @@ -7801,24 +7467,20 @@ yyreduce: #endif (yyval.val) = method_arg(dispatch1(fcall, (yyvsp[(1) - (1)].val)), arg_new()); - } + ;} break; case 280: - -/* Line 1806 of yacc.c */ #line 2633 "ripper.y" { #if 0 (yyval.num) = ruby_sourceline; #endif - } + ;} break; case 281: - -/* Line 1806 of yacc.c */ #line 2641 "ripper.y" { #if 0 @@ -7835,19 +7497,15 @@ yyreduce: #endif (yyval.val) = dispatch1(begin, (yyvsp[(3) - (4)].val)); - } + ;} break; case 282: - -/* Line 1806 of yacc.c */ #line 2657 "ripper.y" - {lex_state = EXPR_ENDARG;} + {lex_state = EXPR_ENDARG;;} break; case 283: - -/* Line 1806 of yacc.c */ #line 2658 "ripper.y" { rb_warning0("(...) interpreted as grouped expression"); @@ -7856,12 +7514,10 @@ yyreduce: #endif (yyval.val) = dispatch1(paren, (yyvsp[(2) - (4)].val)); - } + ;} break; case 284: - -/* Line 1806 of yacc.c */ #line 2667 "ripper.y" { #if 0 @@ -7869,12 +7525,10 @@ yyreduce: #endif (yyval.val) = dispatch1(paren, (yyvsp[(2) - (3)].val)); - } + ;} break; case 285: - -/* Line 1806 of yacc.c */ #line 2675 "ripper.y" { #if 0 @@ -7882,12 +7536,10 @@ yyreduce: #endif (yyval.val) = dispatch2(const_path_ref, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 286: - -/* Line 1806 of yacc.c */ #line 2683 "ripper.y" { #if 0 @@ -7895,12 +7547,10 @@ yyreduce: #endif (yyval.val) = dispatch1(top_const_ref, (yyvsp[(2) - (2)].val)); - } + ;} break; case 287: - -/* Line 1806 of yacc.c */ #line 2691 "ripper.y" { #if 0 @@ -7913,12 +7563,10 @@ yyreduce: #endif (yyval.val) = dispatch1(array, escape_Qundef((yyvsp[(2) - (3)].val))); - } + ;} break; case 288: - -/* Line 1806 of yacc.c */ #line 2704 "ripper.y" { #if 0 @@ -7926,12 +7574,10 @@ yyreduce: #endif (yyval.val) = dispatch1(hash, escape_Qundef((yyvsp[(2) - (3)].val))); - } + ;} break; case 289: - -/* Line 1806 of yacc.c */ #line 2712 "ripper.y" { #if 0 @@ -7939,12 +7585,10 @@ yyreduce: #endif (yyval.val) = dispatch0(return0); - } + ;} break; case 290: - -/* Line 1806 of yacc.c */ #line 2720 "ripper.y" { #if 0 @@ -7952,12 +7596,10 @@ yyreduce: #endif (yyval.val) = dispatch1(yield, dispatch1(paren, (yyvsp[(3) - (4)].val))); - } + ;} break; case 291: - -/* Line 1806 of yacc.c */ #line 2728 "ripper.y" { #if 0 @@ -7965,12 +7607,10 @@ yyreduce: #endif (yyval.val) = dispatch1(yield, dispatch1(paren, arg_new())); - } + ;} break; case 292: - -/* Line 1806 of yacc.c */ #line 2736 "ripper.y" { #if 0 @@ -7978,19 +7618,15 @@ yyreduce: #endif (yyval.val) = dispatch0(yield0); - } + ;} break; case 293: - -/* Line 1806 of yacc.c */ #line 2743 "ripper.y" - {in_defined = 1;} + {in_defined = 1;;} break; case 294: - -/* Line 1806 of yacc.c */ #line 2744 "ripper.y" { #if 0 @@ -8000,12 +7636,10 @@ yyreduce: in_defined = 0; (yyval.val) = dispatch1(defined, (yyvsp[(5) - (6)].val)); - } + ;} break; case 295: - -/* Line 1806 of yacc.c */ #line 2754 "ripper.y" { #if 0 @@ -8013,12 +7647,10 @@ yyreduce: #endif (yyval.val) = dispatch2(unary, ripper_intern("not"), (yyvsp[(3) - (4)].val)); - } + ;} break; case 296: - -/* Line 1806 of yacc.c */ #line 2762 "ripper.y" { #if 0 @@ -8026,12 +7658,10 @@ yyreduce: #endif (yyval.val) = dispatch2(unary, ripper_intern("not"), Qnil); - } + ;} break; case 297: - -/* Line 1806 of yacc.c */ #line 2770 "ripper.y" { #if 0 @@ -8042,12 +7672,10 @@ yyreduce: (yyval.val) = method_arg(dispatch1(fcall, (yyvsp[(1) - (2)].val)), arg_new()); (yyval.val) = method_add_block((yyval.val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 299: - -/* Line 1806 of yacc.c */ #line 2782 "ripper.y" { #if 0 @@ -8058,21 +7686,17 @@ yyreduce: #endif (yyval.val) = method_add_block((yyvsp[(1) - (2)].val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 300: - -/* Line 1806 of yacc.c */ #line 2793 "ripper.y" { (yyval.val) = (yyvsp[(2) - (2)].val); - } + ;} break; case 301: - -/* Line 1806 of yacc.c */ #line 2800 "ripper.y" { #if 0 @@ -8081,12 +7705,10 @@ yyreduce: #endif (yyval.val) = dispatch3(if, (yyvsp[(2) - (6)].val), (yyvsp[(4) - (6)].val), escape_Qundef((yyvsp[(5) - (6)].val))); - } + ;} break; case 302: - -/* Line 1806 of yacc.c */ #line 2812 "ripper.y" { #if 0 @@ -8095,26 +7717,20 @@ yyreduce: #endif (yyval.val) = dispatch3(unless, (yyvsp[(2) - (6)].val), (yyvsp[(4) - (6)].val), escape_Qundef((yyvsp[(5) - (6)].val))); - } + ;} break; case 303: - -/* Line 1806 of yacc.c */ #line 2820 "ripper.y" - {COND_PUSH(1);} + {COND_PUSH(1);;} break; case 304: - -/* Line 1806 of yacc.c */ #line 2820 "ripper.y" - {COND_POP();} + {COND_POP();;} break; case 305: - -/* Line 1806 of yacc.c */ #line 2823 "ripper.y" { #if 0 @@ -8123,26 +7739,20 @@ yyreduce: #endif (yyval.val) = dispatch2(while, (yyvsp[(3) - (7)].val), (yyvsp[(6) - (7)].val)); - } + ;} break; case 306: - -/* Line 1806 of yacc.c */ #line 2831 "ripper.y" - {COND_PUSH(1);} + {COND_PUSH(1);;} break; case 307: - -/* Line 1806 of yacc.c */ #line 2831 "ripper.y" - {COND_POP();} + {COND_POP();;} break; case 308: - -/* Line 1806 of yacc.c */ #line 2834 "ripper.y" { #if 0 @@ -8151,12 +7761,10 @@ yyreduce: #endif (yyval.val) = dispatch2(until, (yyvsp[(3) - (7)].val), (yyvsp[(6) - (7)].val)); - } + ;} break; case 309: - -/* Line 1806 of yacc.c */ #line 2845 "ripper.y" { #if 0 @@ -8165,12 +7773,10 @@ yyreduce: #endif (yyval.val) = dispatch2(case, (yyvsp[(2) - (5)].val), (yyvsp[(4) - (5)].val)); - } + ;} break; case 310: - -/* Line 1806 of yacc.c */ #line 2854 "ripper.y" { #if 0 @@ -8178,26 +7784,20 @@ yyreduce: #endif (yyval.val) = dispatch2(case, Qnil, (yyvsp[(3) - (4)].val)); - } + ;} break; case 311: - -/* Line 1806 of yacc.c */ #line 2862 "ripper.y" - {COND_PUSH(1);} + {COND_PUSH(1);;} break; case 312: - -/* Line 1806 of yacc.c */ #line 2864 "ripper.y" - {COND_POP();} + {COND_POP();;} break; case 313: - -/* Line 1806 of yacc.c */ #line 2867 "ripper.y" { #if 0 @@ -8258,12 +7858,10 @@ yyreduce: #endif (yyval.val) = dispatch3(for, (yyvsp[(2) - (9)].val), (yyvsp[(5) - (9)].val), (yyvsp[(8) - (9)].val)); - } + ;} break; case 314: - -/* Line 1806 of yacc.c */ #line 2928 "ripper.y" { if (in_def || in_single) @@ -8273,12 +7871,10 @@ yyreduce: (yyval.num) = ruby_sourceline; #endif - } + ;} break; case 315: - -/* Line 1806 of yacc.c */ #line 2939 "ripper.y" { #if 0 @@ -8288,33 +7884,27 @@ yyreduce: (yyval.val) = dispatch3(class, (yyvsp[(2) - (6)].val), (yyvsp[(3) - (6)].val), (yyvsp[(5) - (6)].val)); local_pop(); - } + ;} break; case 316: - -/* Line 1806 of yacc.c */ #line 2949 "ripper.y" { (yyval.num) = in_def; in_def = 0; - } + ;} break; case 317: - -/* Line 1806 of yacc.c */ #line 2954 "ripper.y" { (yyval.num) = in_single; in_single = 0; local_push(0); - } + ;} break; case 318: - -/* Line 1806 of yacc.c */ #line 2961 "ripper.y" { #if 0 @@ -8326,12 +7916,10 @@ yyreduce: local_pop(); in_def = (yyvsp[(4) - (8)].num); in_single = (yyvsp[(6) - (8)].num); - } + ;} break; case 319: - -/* Line 1806 of yacc.c */ #line 2973 "ripper.y" { if (in_def || in_single) @@ -8341,12 +7929,10 @@ yyreduce: (yyval.num) = ruby_sourceline; #endif - } + ;} break; case 320: - -/* Line 1806 of yacc.c */ #line 2984 "ripper.y" { #if 0 @@ -8356,24 +7942,20 @@ yyreduce: (yyval.val) = dispatch2(module, (yyvsp[(2) - (5)].val), (yyvsp[(4) - (5)].val)); local_pop(); - } + ;} break; case 321: - -/* Line 1806 of yacc.c */ #line 2994 "ripper.y" { (yyval.id) = cur_mid; cur_mid = (yyvsp[(2) - (2)].val); in_def++; local_push(0); - } + ;} break; case 322: - -/* Line 1806 of yacc.c */ #line 3003 "ripper.y" { #if 0 @@ -8387,30 +7969,24 @@ yyreduce: local_pop(); in_def--; cur_mid = (yyvsp[(3) - (6)].id); - } + ;} break; case 323: - -/* Line 1806 of yacc.c */ #line 3016 "ripper.y" - {lex_state = EXPR_FNAME;} + {lex_state = EXPR_FNAME;;} break; case 324: - -/* Line 1806 of yacc.c */ #line 3017 "ripper.y" { in_single++; lex_state = EXPR_ENDFN; /* force for args */ local_push(0); - } + ;} break; case 325: - -/* Line 1806 of yacc.c */ #line 3025 "ripper.y" { #if 0 @@ -8423,12 +7999,10 @@ yyreduce: local_pop(); in_single--; - } + ;} break; case 326: - -/* Line 1806 of yacc.c */ #line 3038 "ripper.y" { #if 0 @@ -8436,12 +8010,10 @@ yyreduce: #endif (yyval.val) = dispatch1(break, arg_new()); - } + ;} break; case 327: - -/* Line 1806 of yacc.c */ #line 3046 "ripper.y" { #if 0 @@ -8449,12 +8021,10 @@ yyreduce: #endif (yyval.val) = dispatch1(next, arg_new()); - } + ;} break; case 328: - -/* Line 1806 of yacc.c */ #line 3054 "ripper.y" { #if 0 @@ -8462,12 +8032,10 @@ yyreduce: #endif (yyval.val) = dispatch0(redo); - } + ;} break; case 329: - -/* Line 1806 of yacc.c */ #line 3062 "ripper.y" { #if 0 @@ -8475,12 +8043,10 @@ yyreduce: #endif (yyval.val) = dispatch0(retry); - } + ;} break; case 330: - -/* Line 1806 of yacc.c */ #line 3072 "ripper.y" { #if 0 @@ -8490,93 +8056,73 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 331: - -/* Line 1806 of yacc.c */ #line 3084 "ripper.y" { token_info_push("begin"); - } + ;} break; case 332: - -/* Line 1806 of yacc.c */ #line 3090 "ripper.y" { token_info_push("if"); - } + ;} break; case 333: - -/* Line 1806 of yacc.c */ #line 3096 "ripper.y" { token_info_push("unless"); - } + ;} break; case 334: - -/* Line 1806 of yacc.c */ #line 3102 "ripper.y" { token_info_push("while"); - } + ;} break; case 335: - -/* Line 1806 of yacc.c */ #line 3108 "ripper.y" { token_info_push("until"); - } + ;} break; case 336: - -/* Line 1806 of yacc.c */ #line 3114 "ripper.y" { token_info_push("case"); - } + ;} break; case 337: - -/* Line 1806 of yacc.c */ #line 3120 "ripper.y" { token_info_push("for"); - } + ;} break; case 338: - -/* Line 1806 of yacc.c */ #line 3126 "ripper.y" { token_info_push("class"); - } + ;} break; case 339: - -/* Line 1806 of yacc.c */ #line 3132 "ripper.y" { token_info_push("module"); - } + ;} break; case 340: - -/* Line 1806 of yacc.c */ #line 3138 "ripper.y" { token_info_push("def"); @@ -8584,42 +8130,32 @@ yyreduce: (yyval.num) = ruby_sourceline; #endif - } + ;} break; case 341: - -/* Line 1806 of yacc.c */ #line 3148 "ripper.y" { token_info_pop("end"); - } + ;} break; case 342: - -/* Line 1806 of yacc.c */ #line 3156 "ripper.y" - { (yyval.val) = Qnil; } + { (yyval.val) = Qnil; ;} break; case 344: - -/* Line 1806 of yacc.c */ #line 3162 "ripper.y" - { (yyval.val) = (yyvsp[(2) - (2)].val); } + { (yyval.val) = (yyvsp[(2) - (2)].val); ;} break; case 345: - -/* Line 1806 of yacc.c */ #line 3169 "ripper.y" - { (yyval.val) = Qnil; } + { (yyval.val) = Qnil; ;} break; case 348: - -/* Line 1806 of yacc.c */ #line 3178 "ripper.y" { #if 0 @@ -8628,12 +8164,10 @@ yyreduce: #endif (yyval.val) = dispatch3(elsif, (yyvsp[(2) - (5)].val), (yyvsp[(4) - (5)].val), escape_Qundef((yyvsp[(5) - (5)].val))); - } + ;} break; case 350: - -/* Line 1806 of yacc.c */ #line 3190 "ripper.y" { #if 0 @@ -8641,12 +8175,10 @@ yyreduce: #endif (yyval.val) = dispatch1(else, (yyvsp[(2) - (2)].val)); - } + ;} break; case 353: - -/* Line 1806 of yacc.c */ #line 3204 "ripper.y" { (yyval.val) = assignable((yyvsp[(1) - (1)].val), 0); @@ -8654,12 +8186,10 @@ yyreduce: #endif (yyval.val) = dispatch1(mlhs_paren, (yyval.val)); - } + ;} break; case 354: - -/* Line 1806 of yacc.c */ #line 3212 "ripper.y" { #if 0 @@ -8667,12 +8197,10 @@ yyreduce: #endif (yyval.val) = dispatch1(mlhs_paren, (yyvsp[(2) - (3)].val)); - } + ;} break; case 355: - -/* Line 1806 of yacc.c */ #line 3222 "ripper.y" { #if 0 @@ -8680,12 +8208,10 @@ yyreduce: #endif (yyval.val) = mlhs_add(mlhs_new(), (yyvsp[(1) - (1)].val)); - } + ;} break; case 356: - -/* Line 1806 of yacc.c */ #line 3230 "ripper.y" { #if 0 @@ -8693,12 +8219,10 @@ yyreduce: #endif (yyval.val) = mlhs_add((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 357: - -/* Line 1806 of yacc.c */ #line 3240 "ripper.y" { #if 0 @@ -8706,12 +8230,10 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 358: - -/* Line 1806 of yacc.c */ #line 3248 "ripper.y" { (yyval.val) = assignable((yyvsp[(4) - (4)].val), 0); @@ -8720,12 +8242,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star((yyvsp[(1) - (4)].val), (yyval.val)); - } + ;} break; case 359: - -/* Line 1806 of yacc.c */ #line 3257 "ripper.y" { (yyval.val) = assignable((yyvsp[(4) - (6)].val), 0); @@ -8734,12 +8254,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star((yyvsp[(1) - (6)].val), (yyval.val)); - } + ;} break; case 360: - -/* Line 1806 of yacc.c */ #line 3266 "ripper.y" { #if 0 @@ -8747,12 +8265,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star((yyvsp[(1) - (3)].val), Qnil); - } + ;} break; case 361: - -/* Line 1806 of yacc.c */ #line 3274 "ripper.y" { #if 0 @@ -8760,12 +8276,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star((yyvsp[(1) - (5)].val), (yyvsp[(5) - (5)].val)); - } + ;} break; case 362: - -/* Line 1806 of yacc.c */ #line 3282 "ripper.y" { (yyval.val) = assignable((yyvsp[(2) - (2)].val), 0); @@ -8774,12 +8288,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star(mlhs_new(), (yyval.val)); - } + ;} break; case 363: - -/* Line 1806 of yacc.c */ #line 3291 "ripper.y" { (yyval.val) = assignable((yyvsp[(2) - (4)].val), 0); @@ -8791,12 +8303,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star((yyval.val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 364: - -/* Line 1806 of yacc.c */ #line 3303 "ripper.y" { #if 0 @@ -8804,12 +8314,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star(mlhs_new(), Qnil); - } + ;} break; case 365: - -/* Line 1806 of yacc.c */ #line 3311 "ripper.y" { #if 0 @@ -8817,12 +8325,10 @@ yyreduce: #endif (yyval.val) = mlhs_add_star(mlhs_new(), Qnil); - } + ;} break; case 366: - -/* Line 1806 of yacc.c */ #line 3321 "ripper.y" { #if 0 @@ -8830,12 +8336,10 @@ yyreduce: #endif (yyval.val) = params_new((yyvsp[(1) - (6)].val), (yyvsp[(3) - (6)].val), (yyvsp[(5) - (6)].val), Qnil, escape_Qundef((yyvsp[(6) - (6)].val))); - } + ;} break; case 367: - -/* Line 1806 of yacc.c */ #line 3329 "ripper.y" { #if 0 @@ -8843,12 +8347,10 @@ yyreduce: #endif (yyval.val) = params_new((yyvsp[(1) - (8)].val), (yyvsp[(3) - (8)].val), (yyvsp[(5) - (8)].val), (yyvsp[(7) - (8)].val), escape_Qundef((yyvsp[(8) - (8)].val))); - } + ;} break; case 368: - -/* Line 1806 of yacc.c */ #line 3337 "ripper.y" { #if 0 @@ -8856,12 +8358,10 @@ yyreduce: #endif (yyval.val) = params_new((yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val), Qnil, Qnil, escape_Qundef((yyvsp[(4) - (4)].val))); - } + ;} break; case 369: - -/* Line 1806 of yacc.c */ #line 3345 "ripper.y" { #if 0 @@ -8869,12 +8369,10 @@ yyreduce: #endif (yyval.val) = params_new((yyvsp[(1) - (6)].val), (yyvsp[(3) - (6)].val), Qnil, (yyvsp[(5) - (6)].val), escape_Qundef((yyvsp[(6) - (6)].val))); - } + ;} break; case 370: - -/* Line 1806 of yacc.c */ #line 3353 "ripper.y" { #if 0 @@ -8882,12 +8380,10 @@ yyreduce: #endif (yyval.val) = params_new((yyvsp[(1) - (4)].val), Qnil, (yyvsp[(3) - (4)].val), Qnil, escape_Qundef((yyvsp[(4) - (4)].val))); - } + ;} break; case 371: - -/* Line 1806 of yacc.c */ #line 3361 "ripper.y" { #if 0 @@ -8896,12 +8392,10 @@ yyreduce: (yyval.val) = params_new((yyvsp[(1) - (2)].val), Qnil, Qnil, Qnil, Qnil); dispatch1(excessed_comma, (yyval.val)); - } + ;} break; case 372: - -/* Line 1806 of yacc.c */ #line 3370 "ripper.y" { #if 0 @@ -8909,12 +8403,10 @@ yyreduce: #endif (yyval.val) = params_new((yyvsp[(1) - (6)].val), Qnil, (yyvsp[(3) - (6)].val), (yyvsp[(5) - (6)].val), escape_Qundef((yyvsp[(6) - (6)].val))); - } + ;} break; case 373: - -/* Line 1806 of yacc.c */ #line 3378 "ripper.y" { #if 0 @@ -8922,12 +8414,10 @@ yyreduce: #endif (yyval.val) = params_new((yyvsp[(1) - (2)].val), Qnil,Qnil, Qnil, escape_Qundef((yyvsp[(2) - (2)].val))); - } + ;} break; case 374: - -/* Line 1806 of yacc.c */ #line 3386 "ripper.y" { #if 0 @@ -8935,12 +8425,10 @@ yyreduce: #endif (yyval.val) = params_new(Qnil, (yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val), Qnil, escape_Qundef((yyvsp[(4) - (4)].val))); - } + ;} break; case 375: - -/* Line 1806 of yacc.c */ #line 3394 "ripper.y" { #if 0 @@ -8948,12 +8436,10 @@ yyreduce: #endif (yyval.val) = params_new(Qnil, (yyvsp[(1) - (6)].val), (yyvsp[(3) - (6)].val), (yyvsp[(5) - (6)].val), escape_Qundef((yyvsp[(6) - (6)].val))); - } + ;} break; case 376: - -/* Line 1806 of yacc.c */ #line 3402 "ripper.y" { #if 0 @@ -8961,12 +8447,10 @@ yyreduce: #endif (yyval.val) = params_new(Qnil, (yyvsp[(1) - (2)].val), Qnil, Qnil,escape_Qundef((yyvsp[(2) - (2)].val))); - } + ;} break; case 377: - -/* Line 1806 of yacc.c */ #line 3410 "ripper.y" { #if 0 @@ -8974,12 +8458,10 @@ yyreduce: #endif (yyval.val) = params_new(Qnil, (yyvsp[(1) - (4)].val), Qnil, (yyvsp[(3) - (4)].val), escape_Qundef((yyvsp[(4) - (4)].val))); - } + ;} break; case 378: - -/* Line 1806 of yacc.c */ #line 3418 "ripper.y" { #if 0 @@ -8987,12 +8469,10 @@ yyreduce: #endif (yyval.val) = params_new(Qnil, Qnil, (yyvsp[(1) - (2)].val), Qnil, escape_Qundef((yyvsp[(2) - (2)].val))); - } + ;} break; case 379: - -/* Line 1806 of yacc.c */ #line 3426 "ripper.y" { #if 0 @@ -9000,12 +8480,10 @@ yyreduce: #endif (yyval.val) = params_new(Qnil, Qnil, (yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val), escape_Qundef((yyvsp[(4) - (4)].val))); - } + ;} break; case 380: - -/* Line 1806 of yacc.c */ #line 3434 "ripper.y" { #if 0 @@ -9013,21 +8491,17 @@ yyreduce: #endif (yyval.val) = params_new(Qnil, Qnil, Qnil, Qnil, (yyvsp[(1) - (1)].val)); - } + ;} break; case 382: - -/* Line 1806 of yacc.c */ #line 3445 "ripper.y" { command_start = TRUE; - } + ;} break; case 383: - -/* Line 1806 of yacc.c */ #line 3451 "ripper.y" { #if 0 @@ -9036,12 +8510,10 @@ yyreduce: (yyval.val) = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil), escape_Qundef((yyvsp[(2) - (3)].val))); - } + ;} break; case 384: - -/* Line 1806 of yacc.c */ #line 3460 "ripper.y" { #if 0 @@ -9050,12 +8522,10 @@ yyreduce: (yyval.val) = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil), Qnil); - } + ;} break; case 385: - -/* Line 1806 of yacc.c */ #line 3469 "ripper.y" { #if 0 @@ -9063,12 +8533,10 @@ yyreduce: #endif (yyval.val) = blockvar_new(escape_Qundef((yyvsp[(2) - (4)].val)), escape_Qundef((yyvsp[(3) - (4)].val))); - } + ;} break; case 387: - -/* Line 1806 of yacc.c */ #line 3481 "ripper.y" { #if 0 @@ -9076,30 +8544,24 @@ yyreduce: #endif (yyval.val) = (yyvsp[(2) - (2)].val); - } + ;} break; case 388: - -/* Line 1806 of yacc.c */ #line 3493 "ripper.y" { (yyval.val) = rb_ary_new3(1, (yyvsp[(1) - (1)].val)); - } + ;} break; case 389: - -/* Line 1806 of yacc.c */ #line 3500 "ripper.y" { rb_ary_push((yyval.val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 390: - -/* Line 1806 of yacc.c */ #line 3507 "ripper.y" { new_bv(get_id((yyvsp[(1) - (1)].val))); @@ -9107,40 +8569,32 @@ yyreduce: #endif (yyval.val) = get_value((yyvsp[(1) - (1)].val)); - } + ;} break; case 391: - -/* Line 1806 of yacc.c */ #line 3515 "ripper.y" { (yyval.val) = 0; - } + ;} break; case 392: - -/* Line 1806 of yacc.c */ #line 3520 "ripper.y" { (yyval.vars) = dyna_push(); - } + ;} break; case 393: - -/* Line 1806 of yacc.c */ #line 3523 "ripper.y" { (yyval.num) = lpar_beg; lpar_beg = ++paren_nest; - } + ;} break; case 394: - -/* Line 1806 of yacc.c */ #line 3529 "ripper.y" { lpar_beg = (yyvsp[(2) - (4)].num); @@ -9151,12 +8605,10 @@ yyreduce: (yyval.val) = dispatch2(lambda, (yyvsp[(3) - (4)].val), (yyvsp[(4) - (4)].val)); dyna_pop((yyvsp[(1) - (4)].vars)); - } + ;} break; case 395: - -/* Line 1806 of yacc.c */ #line 3542 "ripper.y" { #if 0 @@ -9164,12 +8616,10 @@ yyreduce: #endif (yyval.val) = dispatch1(paren, (yyvsp[(2) - (4)].val)); - } + ;} break; case 396: - -/* Line 1806 of yacc.c */ #line 3550 "ripper.y" { #if 0 @@ -9177,42 +8627,34 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 397: - -/* Line 1806 of yacc.c */ #line 3560 "ripper.y" { (yyval.val) = (yyvsp[(2) - (3)].val); - } + ;} break; case 398: - -/* Line 1806 of yacc.c */ #line 3564 "ripper.y" { (yyval.val) = (yyvsp[(2) - (3)].val); - } + ;} break; case 399: - -/* Line 1806 of yacc.c */ #line 3570 "ripper.y" { (yyvsp[(1) - (1)].vars) = dyna_push(); #if 0 (yyval.num) = ruby_sourceline; #endif - } + ;} break; case 400: - -/* Line 1806 of yacc.c */ #line 3579 "ripper.y" { #if 0 @@ -9222,12 +8664,10 @@ yyreduce: (yyval.val) = dispatch2(do_block, escape_Qundef((yyvsp[(3) - (5)].val)), (yyvsp[(4) - (5)].val)); dyna_pop((yyvsp[(1) - (5)].vars)); - } + ;} break; case 401: - -/* Line 1806 of yacc.c */ #line 3591 "ripper.y" { #if 0 @@ -9243,12 +8683,10 @@ yyreduce: #endif (yyval.val) = method_add_block((yyvsp[(1) - (2)].val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 402: - -/* Line 1806 of yacc.c */ #line 3607 "ripper.y" { #if 0 @@ -9257,12 +8695,10 @@ yyreduce: (yyval.val) = dispatch3(call, (yyvsp[(1) - (4)].val), ripper_id2sym('.'), (yyvsp[(3) - (4)].val)); (yyval.val) = method_optarg((yyval.val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 403: - -/* Line 1806 of yacc.c */ #line 3616 "ripper.y" { #if 0 @@ -9271,12 +8707,10 @@ yyreduce: (yyval.val) = dispatch3(call, (yyvsp[(1) - (4)].val), ripper_intern("::"), (yyvsp[(3) - (4)].val)); (yyval.val) = method_optarg((yyval.val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 404: - -/* Line 1806 of yacc.c */ #line 3627 "ripper.y" { #if 0 @@ -9285,12 +8719,10 @@ yyreduce: #endif (yyval.val) = method_arg(dispatch1(fcall, (yyvsp[(1) - (2)].val)), (yyvsp[(2) - (2)].val)); - } + ;} break; case 405: - -/* Line 1806 of yacc.c */ #line 3636 "ripper.y" { #if 0 @@ -9300,12 +8732,10 @@ yyreduce: (yyval.val) = dispatch3(call, (yyvsp[(1) - (4)].val), ripper_id2sym('.'), (yyvsp[(3) - (4)].val)); (yyval.val) = method_optarg((yyval.val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 406: - -/* Line 1806 of yacc.c */ #line 3646 "ripper.y" { #if 0 @@ -9315,12 +8745,10 @@ yyreduce: (yyval.val) = dispatch3(call, (yyvsp[(1) - (4)].val), ripper_id2sym('.'), (yyvsp[(3) - (4)].val)); (yyval.val) = method_optarg((yyval.val), (yyvsp[(4) - (4)].val)); - } + ;} break; case 407: - -/* Line 1806 of yacc.c */ #line 3656 "ripper.y" { #if 0 @@ -9328,12 +8756,10 @@ yyreduce: #endif (yyval.val) = dispatch3(call, (yyvsp[(1) - (3)].val), ripper_intern("::"), (yyvsp[(3) - (3)].val)); - } + ;} break; case 408: - -/* Line 1806 of yacc.c */ #line 3664 "ripper.y" { #if 0 @@ -9344,12 +8770,10 @@ yyreduce: ripper_intern("call")); (yyval.val) = method_optarg((yyval.val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 409: - -/* Line 1806 of yacc.c */ #line 3675 "ripper.y" { #if 0 @@ -9360,12 +8784,10 @@ yyreduce: ripper_intern("call")); (yyval.val) = method_optarg((yyval.val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 410: - -/* Line 1806 of yacc.c */ #line 3686 "ripper.y" { #if 0 @@ -9373,12 +8795,10 @@ yyreduce: #endif (yyval.val) = dispatch1(super, (yyvsp[(2) - (2)].val)); - } + ;} break; case 411: - -/* Line 1806 of yacc.c */ #line 3694 "ripper.y" { #if 0 @@ -9386,12 +8806,10 @@ yyreduce: #endif (yyval.val) = dispatch0(zsuper); - } + ;} break; case 412: - -/* Line 1806 of yacc.c */ #line 3702 "ripper.y" { #if 0 @@ -9403,12 +8821,10 @@ yyreduce: #endif (yyval.val) = dispatch2(aref, (yyvsp[(1) - (4)].val), escape_Qundef((yyvsp[(3) - (4)].val))); - } + ;} break; case 413: - -/* Line 1806 of yacc.c */ #line 3716 "ripper.y" { (yyvsp[(1) - (1)].vars) = dyna_push(); @@ -9416,12 +8832,10 @@ yyreduce: (yyval.num) = ruby_sourceline; #endif - } + ;} break; case 414: - -/* Line 1806 of yacc.c */ #line 3725 "ripper.y" { #if 0 @@ -9431,12 +8845,10 @@ yyreduce: (yyval.val) = dispatch2(brace_block, escape_Qundef((yyvsp[(3) - (5)].val)), (yyvsp[(4) - (5)].val)); dyna_pop((yyvsp[(1) - (5)].vars)); - } + ;} break; case 415: - -/* Line 1806 of yacc.c */ #line 3735 "ripper.y" { (yyvsp[(1) - (1)].vars) = dyna_push(); @@ -9444,12 +8856,10 @@ yyreduce: (yyval.num) = ruby_sourceline; #endif - } + ;} break; case 416: - -/* Line 1806 of yacc.c */ #line 3744 "ripper.y" { #if 0 @@ -9459,12 +8869,10 @@ yyreduce: (yyval.val) = dispatch2(do_block, escape_Qundef((yyvsp[(3) - (5)].val)), (yyvsp[(4) - (5)].val)); dyna_pop((yyvsp[(1) - (5)].vars)); - } + ;} break; case 417: - -/* Line 1806 of yacc.c */ #line 3758 "ripper.y" { #if 0 @@ -9472,12 +8880,10 @@ yyreduce: #endif (yyval.val) = dispatch3(when, (yyvsp[(2) - (5)].val), (yyvsp[(4) - (5)].val), escape_Qundef((yyvsp[(5) - (5)].val))); - } + ;} break; case 420: - -/* Line 1806 of yacc.c */ #line 3774 "ripper.y" { #if 0 @@ -9494,12 +8900,10 @@ yyreduce: escape_Qundef((yyvsp[(5) - (6)].val)), escape_Qundef((yyvsp[(6) - (6)].val))); - } + ;} break; case 422: - -/* Line 1806 of yacc.c */ #line 3794 "ripper.y" { #if 0 @@ -9507,12 +8911,10 @@ yyreduce: #endif (yyval.val) = rb_ary_new3(1, (yyvsp[(1) - (1)].val)); - } + ;} break; case 423: - -/* Line 1806 of yacc.c */ #line 3802 "ripper.y" { #if 0 @@ -9520,21 +8922,17 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 425: - -/* Line 1806 of yacc.c */ #line 3813 "ripper.y" { (yyval.val) = (yyvsp[(2) - (2)].val); - } + ;} break; case 427: - -/* Line 1806 of yacc.c */ #line 3820 "ripper.y" { #if 0 @@ -9542,12 +8940,10 @@ yyreduce: #endif (yyval.val) = dispatch1(ensure, (yyvsp[(2) - (2)].val)); - } + ;} break; case 430: - -/* Line 1806 of yacc.c */ #line 3832 "ripper.y" { #if 0 @@ -9555,12 +8951,10 @@ yyreduce: #endif (yyval.val) = dispatch1(symbol_literal, (yyvsp[(1) - (1)].val)); - } + ;} break; case 432: - -/* Line 1806 of yacc.c */ #line 3843 "ripper.y" { #if 0 @@ -9575,12 +8969,10 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 435: - -/* Line 1806 of yacc.c */ #line 3862 "ripper.y" { #if 0 @@ -9588,12 +8980,10 @@ yyreduce: #endif (yyval.val) = dispatch2(string_concat, (yyvsp[(1) - (2)].val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 436: - -/* Line 1806 of yacc.c */ #line 3872 "ripper.y" { #if 0 @@ -9601,12 +8991,10 @@ yyreduce: #endif (yyval.val) = dispatch1(string_literal, (yyvsp[(2) - (3)].val)); - } + ;} break; case 437: - -/* Line 1806 of yacc.c */ #line 3882 "ripper.y" { #if 0 @@ -9631,12 +9019,10 @@ yyreduce: #endif (yyval.val) = dispatch1(xstring_literal, (yyvsp[(2) - (3)].val)); - } + ;} break; case 438: - -/* Line 1806 of yacc.c */ #line 3909 "ripper.y" { #if 0 @@ -9699,12 +9085,10 @@ yyreduce: #endif (yyval.val) = dispatch2(regexp_literal, (yyvsp[(2) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 439: - -/* Line 1806 of yacc.c */ #line 3974 "ripper.y" { #if 0 @@ -9713,12 +9097,10 @@ yyreduce: (yyval.val) = dispatch0(words_new); (yyval.val) = dispatch1(array, (yyval.val)); - } + ;} break; case 440: - -/* Line 1806 of yacc.c */ #line 3983 "ripper.y" { #if 0 @@ -9726,12 +9108,10 @@ yyreduce: #endif (yyval.val) = dispatch1(array, (yyvsp[(2) - (3)].val)); - } + ;} break; case 441: - -/* Line 1806 of yacc.c */ #line 3993 "ripper.y" { #if 0 @@ -9739,12 +9119,10 @@ yyreduce: #endif (yyval.val) = dispatch0(words_new); - } + ;} break; case 442: - -/* Line 1806 of yacc.c */ #line 4001 "ripper.y" { #if 0 @@ -9752,22 +9130,18 @@ yyreduce: #endif (yyval.val) = dispatch2(words_add, (yyvsp[(1) - (3)].val), (yyvsp[(2) - (3)].val)); - } + ;} break; case 443: - -/* Line 1806 of yacc.c */ #line 4013 "ripper.y" { (yyval.val) = dispatch0(word_new); (yyval.val) = dispatch2(word_add, (yyval.val), (yyvsp[(1) - (1)].val)); - } + ;} break; case 444: - -/* Line 1806 of yacc.c */ #line 4019 "ripper.y" { #if 0 @@ -9775,12 +9149,10 @@ yyreduce: #endif (yyval.val) = dispatch2(word_add, (yyvsp[(1) - (2)].val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 445: - -/* Line 1806 of yacc.c */ #line 4029 "ripper.y" { #if 0 @@ -9789,12 +9161,10 @@ yyreduce: (yyval.val) = dispatch0(qwords_new); (yyval.val) = dispatch1(array, (yyval.val)); - } + ;} break; case 446: - -/* Line 1806 of yacc.c */ #line 4038 "ripper.y" { #if 0 @@ -9802,12 +9172,10 @@ yyreduce: #endif (yyval.val) = dispatch1(array, (yyvsp[(2) - (3)].val)); - } + ;} break; case 447: - -/* Line 1806 of yacc.c */ #line 4048 "ripper.y" { #if 0 @@ -9815,12 +9183,10 @@ yyreduce: #endif (yyval.val) = dispatch0(qwords_new); - } + ;} break; case 448: - -/* Line 1806 of yacc.c */ #line 4056 "ripper.y" { #if 0 @@ -9828,12 +9194,10 @@ yyreduce: #endif (yyval.val) = dispatch2(qwords_add, (yyvsp[(1) - (3)].val), (yyvsp[(2) - (3)].val)); - } + ;} break; case 449: - -/* Line 1806 of yacc.c */ #line 4066 "ripper.y" { #if 0 @@ -9841,12 +9205,10 @@ yyreduce: #endif (yyval.val) = dispatch0(string_content); - } + ;} break; case 450: - -/* Line 1806 of yacc.c */ #line 4074 "ripper.y" { #if 0 @@ -9854,12 +9216,10 @@ yyreduce: #endif (yyval.val) = dispatch2(string_add, (yyvsp[(1) - (2)].val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 451: - -/* Line 1806 of yacc.c */ #line 4084 "ripper.y" { #if 0 @@ -9867,12 +9227,10 @@ yyreduce: #endif (yyval.val) = dispatch0(xstring_new); - } + ;} break; case 452: - -/* Line 1806 of yacc.c */ #line 4092 "ripper.y" { #if 0 @@ -9880,12 +9238,10 @@ yyreduce: #endif (yyval.val) = dispatch2(xstring_add, (yyvsp[(1) - (2)].val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 453: - -/* Line 1806 of yacc.c */ #line 4102 "ripper.y" { #if 0 @@ -9893,12 +9249,10 @@ yyreduce: #endif (yyval.val) = dispatch0(regexp_new); - } + ;} break; case 454: - -/* Line 1806 of yacc.c */ #line 4110 "ripper.y" { #if 0 @@ -9925,23 +9279,19 @@ yyreduce: #endif (yyval.val) = dispatch2(regexp_add, (yyvsp[(1) - (2)].val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 456: - -/* Line 1806 of yacc.c */ #line 4140 "ripper.y" { (yyval.node) = lex_strterm; lex_strterm = 0; lex_state = EXPR_BEG; - } + ;} break; case 457: - -/* Line 1806 of yacc.c */ #line 4146 "ripper.y" { #if 0 @@ -9951,35 +9301,29 @@ yyreduce: lex_strterm = (yyvsp[(2) - (3)].node); (yyval.val) = dispatch1(string_dvar, (yyvsp[(3) - (3)].val)); - } + ;} break; case 458: - -/* Line 1806 of yacc.c */ #line 4156 "ripper.y" { (yyvsp[(1) - (1)].val) = cond_stack; (yyval.val) = cmdarg_stack; cond_stack = 0; cmdarg_stack = 0; - } + ;} break; case 459: - -/* Line 1806 of yacc.c */ #line 4162 "ripper.y" { (yyval.node) = lex_strterm; lex_strterm = 0; lex_state = EXPR_BEG; - } + ;} break; case 460: - -/* Line 1806 of yacc.c */ #line 4168 "ripper.y" { cond_stack = (yyvsp[(1) - (5)].val); @@ -9991,12 +9335,10 @@ yyreduce: #endif (yyval.val) = dispatch1(string_embexpr, (yyvsp[(4) - (5)].val)); - } + ;} break; case 461: - -/* Line 1806 of yacc.c */ #line 4182 "ripper.y" { #if 0 @@ -10004,12 +9346,10 @@ yyreduce: #endif (yyval.val) = dispatch1(var_ref, (yyvsp[(1) - (1)].val)); - } + ;} break; case 462: - -/* Line 1806 of yacc.c */ #line 4190 "ripper.y" { #if 0 @@ -10017,12 +9357,10 @@ yyreduce: #endif (yyval.val) = dispatch1(var_ref, (yyvsp[(1) - (1)].val)); - } + ;} break; case 463: - -/* Line 1806 of yacc.c */ #line 4198 "ripper.y" { #if 0 @@ -10030,12 +9368,10 @@ yyreduce: #endif (yyval.val) = dispatch1(var_ref, (yyvsp[(1) - (1)].val)); - } + ;} break; case 465: - -/* Line 1806 of yacc.c */ #line 4209 "ripper.y" { lex_state = EXPR_END; @@ -10044,12 +9380,10 @@ yyreduce: #endif (yyval.val) = dispatch1(symbol, (yyvsp[(2) - (2)].val)); - } + ;} break; case 470: - -/* Line 1806 of yacc.c */ #line 4226 "ripper.y" { lex_state = EXPR_END; @@ -10077,12 +9411,10 @@ yyreduce: #endif (yyval.val) = dispatch1(dyna_symbol, (yyvsp[(2) - (3)].val)); - } + ;} break; case 473: - -/* Line 1806 of yacc.c */ #line 4258 "ripper.y" { #if 0 @@ -10090,12 +9422,10 @@ yyreduce: #endif (yyval.val) = dispatch2(unary, ripper_intern("-@"), (yyvsp[(2) - (2)].val)); - } + ;} break; case 474: - -/* Line 1806 of yacc.c */ #line 4266 "ripper.y" { #if 0 @@ -10103,61 +9433,45 @@ yyreduce: #endif (yyval.val) = dispatch2(unary, ripper_intern("-@"), (yyvsp[(2) - (2)].val)); - } + ;} break; case 480: - -/* Line 1806 of yacc.c */ #line 4282 "ripper.y" - {ifndef_ripper((yyval.val) = keyword_nil);} + {ifndef_ripper((yyval.val) = keyword_nil);;} break; case 481: - -/* Line 1806 of yacc.c */ #line 4283 "ripper.y" - {ifndef_ripper((yyval.val) = keyword_self);} + {ifndef_ripper((yyval.val) = keyword_self);;} break; case 482: - -/* Line 1806 of yacc.c */ #line 4284 "ripper.y" - {ifndef_ripper((yyval.val) = keyword_true);} + {ifndef_ripper((yyval.val) = keyword_true);;} break; case 483: - -/* Line 1806 of yacc.c */ #line 4285 "ripper.y" - {ifndef_ripper((yyval.val) = keyword_false);} + {ifndef_ripper((yyval.val) = keyword_false);;} break; case 484: - -/* Line 1806 of yacc.c */ #line 4286 "ripper.y" - {ifndef_ripper((yyval.val) = keyword__FILE__);} + {ifndef_ripper((yyval.val) = keyword__FILE__);;} break; case 485: - -/* Line 1806 of yacc.c */ #line 4287 "ripper.y" - {ifndef_ripper((yyval.val) = keyword__LINE__);} + {ifndef_ripper((yyval.val) = keyword__LINE__);;} break; case 486: - -/* Line 1806 of yacc.c */ #line 4288 "ripper.y" - {ifndef_ripper((yyval.val) = keyword__ENCODING__);} + {ifndef_ripper((yyval.val) = keyword__ENCODING__);;} break; case 487: - -/* Line 1806 of yacc.c */ #line 4292 "ripper.y" { #if 0 @@ -10170,12 +9484,10 @@ yyreduce: (yyval.val) = dispatch1(vcall, (yyvsp[(1) - (1)].val)); } - } + ;} break; case 488: - -/* Line 1806 of yacc.c */ #line 4305 "ripper.y" { #if 0 @@ -10183,12 +9495,10 @@ yyreduce: #endif (yyval.val) = dispatch1(var_ref, (yyvsp[(1) - (1)].val)); - } + ;} break; case 489: - -/* Line 1806 of yacc.c */ #line 4315 "ripper.y" { (yyval.val) = assignable((yyvsp[(1) - (1)].val), 0); @@ -10196,12 +9506,10 @@ yyreduce: #endif (yyval.val) = dispatch1(var_field, (yyval.val)); - } + ;} break; case 490: - -/* Line 1806 of yacc.c */ #line 4323 "ripper.y" { (yyval.val) = assignable((yyvsp[(1) - (1)].val), 0); @@ -10209,12 +9517,10 @@ yyreduce: #endif (yyval.val) = dispatch1(var_field, (yyval.val)); - } + ;} break; case 493: - -/* Line 1806 of yacc.c */ #line 4337 "ripper.y" { #if 0 @@ -10222,30 +9528,24 @@ yyreduce: #endif (yyval.val) = Qnil; - } + ;} break; case 494: - -/* Line 1806 of yacc.c */ #line 4345 "ripper.y" { lex_state = EXPR_BEG; - } + ;} break; case 495: - -/* Line 1806 of yacc.c */ #line 4349 "ripper.y" { (yyval.val) = (yyvsp[(3) - (4)].val); - } + ;} break; case 496: - -/* Line 1806 of yacc.c */ #line 4353 "ripper.y" { #if 0 @@ -10255,12 +9555,10 @@ yyreduce: yyerrok; (yyval.val) = Qnil; - } + ;} break; case 497: - -/* Line 1806 of yacc.c */ #line 4365 "ripper.y" { #if 0 @@ -10270,217 +9568,185 @@ yyreduce: lex_state = EXPR_BEG; command_start = TRUE; - } + ;} break; case 498: - -/* Line 1806 of yacc.c */ #line 4375 "ripper.y" { (yyval.val) = (yyvsp[(1) - (2)].val); - } + lex_state = EXPR_BEG; + command_start = TRUE; + ;} break; case 499: - -/* Line 1806 of yacc.c */ -#line 4381 "ripper.y" +#line 4383 "ripper.y" { #if 0 (yyval.val) = new_args((yyvsp[(1) - (6)].val), (yyvsp[(3) - (6)].val), (yyvsp[(5) - (6)].val), 0, (yyvsp[(6) - (6)].val)); #endif (yyval.val) = params_new((yyvsp[(1) - (6)].val), (yyvsp[(3) - (6)].val), (yyvsp[(5) - (6)].val), Qnil, escape_Qundef((yyvsp[(6) - (6)].val))); - } + ;} break; case 500: - -/* Line 1806 of yacc.c */ -#line 4389 "ripper.y" +#line 4391 "ripper.y" { #if 0 (yyval.val) = new_args((yyvsp[(1) - (8)].val), (yyvsp[(3) - (8)].val), (yyvsp[(5) - (8)].val), (yyvsp[(7) - (8)].val), (yyvsp[(8) - (8)].val)); #endif (yyval.val) = params_new((yyvsp[(1) - (8)].val), (yyvsp[(3) - (8)].val), (yyvsp[(5) - (8)].val), (yyvsp[(7) - (8)].val), escape_Qundef((yyvsp[(8) - (8)].val))); - } + ;} break; case 501: - -/* Line 1806 of yacc.c */ -#line 4397 "ripper.y" +#line 4399 "ripper.y" { #if 0 (yyval.val) = new_args((yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val), 0, 0, (yyvsp[(4) - (4)].val)); #endif (yyval.val) = params_new((yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val), Qnil, Qnil, escape_Qundef((yyvsp[(4) - (4)].val))); - } + ;} break; case 502: - -/* Line 1806 of yacc.c */ -#line 4405 "ripper.y" +#line 4407 "ripper.y" { #if 0 (yyval.val) = new_args((yyvsp[(1) - (6)].val), (yyvsp[(3) - (6)].val), 0, (yyvsp[(5) - (6)].val), (yyvsp[(6) - (6)].val)); #endif (yyval.val) = params_new((yyvsp[(1) - (6)].val), (yyvsp[(3) - (6)].val), Qnil, (yyvsp[(5) - (6)].val), escape_Qundef((yyvsp[(6) - (6)].val))); - } + ;} break; case 503: - -/* Line 1806 of yacc.c */ -#line 4413 "ripper.y" +#line 4415 "ripper.y" { #if 0 (yyval.val) = new_args((yyvsp[(1) - (4)].val), 0, (yyvsp[(3) - (4)].val), 0, (yyvsp[(4) - (4)].val)); #endif (yyval.val) = params_new((yyvsp[(1) - (4)].val), Qnil, (yyvsp[(3) - (4)].val), Qnil, escape_Qundef((yyvsp[(4) - (4)].val))); - } + ;} break; case 504: - -/* Line 1806 of yacc.c */ -#line 4421 "ripper.y" +#line 4423 "ripper.y" { #if 0 (yyval.val) = new_args((yyvsp[(1) - (6)].val), 0, (yyvsp[(3) - (6)].val), (yyvsp[(5) - (6)].val), (yyvsp[(6) - (6)].val)); #endif (yyval.val) = params_new((yyvsp[(1) - (6)].val), Qnil, (yyvsp[(3) - (6)].val), (yyvsp[(5) - (6)].val), escape_Qundef((yyvsp[(6) - (6)].val))); - } + ;} break; case 505: - -/* Line 1806 of yacc.c */ -#line 4429 "ripper.y" +#line 4431 "ripper.y" { #if 0 (yyval.val) = new_args((yyvsp[(1) - (2)].val), 0, 0, 0, (yyvsp[(2) - (2)].val)); #endif (yyval.val) = params_new((yyvsp[(1) - (2)].val), Qnil, Qnil, Qnil,escape_Qundef((yyvsp[(2) - (2)].val))); - } + ;} break; case 506: - -/* Line 1806 of yacc.c */ -#line 4437 "ripper.y" +#line 4439 "ripper.y" { #if 0 (yyval.val) = new_args(0, (yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val), 0, (yyvsp[(4) - (4)].val)); #endif (yyval.val) = params_new(Qnil, (yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val), Qnil, escape_Qundef((yyvsp[(4) - (4)].val))); - } + ;} break; case 507: - -/* Line 1806 of yacc.c */ -#line 4445 "ripper.y" +#line 4447 "ripper.y" { #if 0 (yyval.val) = new_args(0, (yyvsp[(1) - (6)].val), (yyvsp[(3) - (6)].val), (yyvsp[(5) - (6)].val), (yyvsp[(6) - (6)].val)); #endif (yyval.val) = params_new(Qnil, (yyvsp[(1) - (6)].val), (yyvsp[(3) - (6)].val), (yyvsp[(5) - (6)].val), escape_Qundef((yyvsp[(6) - (6)].val))); - } + ;} break; case 508: - -/* Line 1806 of yacc.c */ -#line 4453 "ripper.y" +#line 4455 "ripper.y" { #if 0 (yyval.val) = new_args(0, (yyvsp[(1) - (2)].val), 0, 0, (yyvsp[(2) - (2)].val)); #endif (yyval.val) = params_new(Qnil, (yyvsp[(1) - (2)].val), Qnil, Qnil,escape_Qundef((yyvsp[(2) - (2)].val))); - } + ;} break; case 509: - -/* Line 1806 of yacc.c */ -#line 4461 "ripper.y" +#line 4463 "ripper.y" { #if 0 (yyval.val) = new_args(0, (yyvsp[(1) - (4)].val), 0, (yyvsp[(3) - (4)].val), (yyvsp[(4) - (4)].val)); #endif (yyval.val) = params_new(Qnil, (yyvsp[(1) - (4)].val), Qnil, (yyvsp[(3) - (4)].val), escape_Qundef((yyvsp[(4) - (4)].val))); - } + ;} break; case 510: - -/* Line 1806 of yacc.c */ -#line 4469 "ripper.y" +#line 4471 "ripper.y" { #if 0 (yyval.val) = new_args(0, 0, (yyvsp[(1) - (2)].val), 0, (yyvsp[(2) - (2)].val)); #endif (yyval.val) = params_new(Qnil, Qnil, (yyvsp[(1) - (2)].val), Qnil,escape_Qundef((yyvsp[(2) - (2)].val))); - } + ;} break; case 511: - -/* Line 1806 of yacc.c */ -#line 4477 "ripper.y" +#line 4479 "ripper.y" { #if 0 (yyval.val) = new_args(0, 0, (yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val), (yyvsp[(4) - (4)].val)); #endif (yyval.val) = params_new(Qnil, Qnil, (yyvsp[(1) - (4)].val), (yyvsp[(3) - (4)].val), escape_Qundef((yyvsp[(4) - (4)].val))); - } + ;} break; case 512: - -/* Line 1806 of yacc.c */ -#line 4485 "ripper.y" +#line 4487 "ripper.y" { #if 0 (yyval.val) = new_args(0, 0, 0, 0, (yyvsp[(1) - (1)].val)); #endif (yyval.val) = params_new(Qnil, Qnil, Qnil, Qnil, (yyvsp[(1) - (1)].val)); - } + ;} break; case 513: - -/* Line 1806 of yacc.c */ -#line 4493 "ripper.y" +#line 4495 "ripper.y" { #if 0 (yyval.val) = new_args(0, 0, 0, 0, 0); #endif (yyval.val) = params_new(Qnil, Qnil, Qnil, Qnil, Qnil); - } + ;} break; case 514: - -/* Line 1806 of yacc.c */ -#line 4503 "ripper.y" +#line 4505 "ripper.y" { #if 0 yyerror("formal argument cannot be a constant"); @@ -10488,13 +9754,11 @@ yyreduce: #endif (yyval.val) = dispatch1(param_error, (yyvsp[(1) - (1)].val)); - } + ;} break; case 515: - -/* Line 1806 of yacc.c */ -#line 4512 "ripper.y" +#line 4514 "ripper.y" { #if 0 yyerror("formal argument cannot be an instance variable"); @@ -10502,13 +9766,11 @@ yyreduce: #endif (yyval.val) = dispatch1(param_error, (yyvsp[(1) - (1)].val)); - } + ;} break; case 516: - -/* Line 1806 of yacc.c */ -#line 4521 "ripper.y" +#line 4523 "ripper.y" { #if 0 yyerror("formal argument cannot be a global variable"); @@ -10516,13 +9778,11 @@ yyreduce: #endif (yyval.val) = dispatch1(param_error, (yyvsp[(1) - (1)].val)); - } + ;} break; case 517: - -/* Line 1806 of yacc.c */ -#line 4530 "ripper.y" +#line 4532 "ripper.y" { #if 0 yyerror("formal argument cannot be a class variable"); @@ -10530,23 +9790,19 @@ yyreduce: #endif (yyval.val) = dispatch1(param_error, (yyvsp[(1) - (1)].val)); - } + ;} break; case 519: - -/* Line 1806 of yacc.c */ -#line 4542 "ripper.y" +#line 4544 "ripper.y" { formal_argument(get_id((yyvsp[(1) - (1)].val))); (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 520: - -/* Line 1806 of yacc.c */ -#line 4549 "ripper.y" +#line 4551 "ripper.y" { arg_var(get_id((yyvsp[(1) - (1)].val))); #if 0 @@ -10554,13 +9810,11 @@ yyreduce: #endif (yyval.val) = get_value((yyvsp[(1) - (1)].val)); - } + ;} break; case 521: - -/* Line 1806 of yacc.c */ -#line 4558 "ripper.y" +#line 4560 "ripper.y" { ID tid = internal_id(); arg_var(tid); @@ -10576,22 +9830,18 @@ yyreduce: #endif (yyval.val) = dispatch1(mlhs_paren, (yyvsp[(2) - (3)].val)); - } + ;} break; case 522: - -/* Line 1806 of yacc.c */ -#line 4579 "ripper.y" +#line 4581 "ripper.y" { (yyval.val) = rb_ary_new3(1, (yyvsp[(1) - (1)].val)); - } + ;} break; case 523: - -/* Line 1806 of yacc.c */ -#line 4584 "ripper.y" +#line 4586 "ripper.y" { #if 0 (yyval.val) = (yyvsp[(1) - (3)].val); @@ -10601,13 +9851,11 @@ yyreduce: #endif (yyval.val) = rb_ary_push((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 524: - -/* Line 1806 of yacc.c */ -#line 4597 "ripper.y" +#line 4599 "ripper.y" { arg_var(formal_argument(get_id((yyvsp[(1) - (3)].val)))); (yyval.val) = assignable((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); @@ -10616,13 +9864,11 @@ yyreduce: #endif (yyval.val) = rb_assoc_new((yyval.val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 525: - -/* Line 1806 of yacc.c */ -#line 4609 "ripper.y" +#line 4611 "ripper.y" { arg_var(formal_argument(get_id((yyvsp[(1) - (3)].val)))); (yyval.val) = assignable((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); @@ -10631,26 +9877,22 @@ yyreduce: #endif (yyval.val) = rb_assoc_new((yyval.val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 526: - -/* Line 1806 of yacc.c */ -#line 4621 "ripper.y" +#line 4623 "ripper.y" { #if 0 (yyval.val) = (yyvsp[(1) - (1)].val); #endif (yyval.val) = rb_ary_new3(1, (yyvsp[(1) - (1)].val)); - } + ;} break; case 527: - -/* Line 1806 of yacc.c */ -#line 4629 "ripper.y" +#line 4631 "ripper.y" { #if 0 NODE *opts = (yyvsp[(1) - (3)].val); @@ -10663,26 +9905,22 @@ yyreduce: #endif (yyval.val) = rb_ary_push((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 528: - -/* Line 1806 of yacc.c */ -#line 4645 "ripper.y" +#line 4647 "ripper.y" { #if 0 (yyval.val) = (yyvsp[(1) - (1)].val); #endif (yyval.val) = rb_ary_new3(1, (yyvsp[(1) - (1)].val)); - } + ;} break; case 529: - -/* Line 1806 of yacc.c */ -#line 4653 "ripper.y" +#line 4655 "ripper.y" { #if 0 NODE *opts = (yyvsp[(1) - (3)].val); @@ -10695,13 +9933,11 @@ yyreduce: #endif (yyval.val) = rb_ary_push((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 532: - -/* Line 1806 of yacc.c */ -#line 4673 "ripper.y" +#line 4675 "ripper.y" { #if 0 if (!is_local_id((yyvsp[(2) - (2)].val))) @@ -10713,13 +9949,11 @@ yyreduce: #endif (yyval.val) = dispatch1(rest_param, (yyvsp[(2) - (2)].val)); - } + ;} break; case 533: - -/* Line 1806 of yacc.c */ -#line 4686 "ripper.y" +#line 4688 "ripper.y" { #if 0 (yyval.val) = internal_id(); @@ -10727,13 +9961,11 @@ yyreduce: #endif (yyval.val) = dispatch1(rest_param, Qnil); - } + ;} break; case 536: - -/* Line 1806 of yacc.c */ -#line 4701 "ripper.y" +#line 4703 "ripper.y" { #if 0 if (!is_local_id((yyvsp[(2) - (2)].val))) @@ -10747,35 +9979,29 @@ yyreduce: #endif (yyval.val) = dispatch1(blockarg, (yyvsp[(2) - (2)].val)); - } + ;} break; case 537: - -/* Line 1806 of yacc.c */ -#line 4718 "ripper.y" +#line 4720 "ripper.y" { (yyval.val) = (yyvsp[(2) - (2)].val); - } + ;} break; case 538: - -/* Line 1806 of yacc.c */ -#line 4722 "ripper.y" +#line 4724 "ripper.y" { #if 0 (yyval.val) = 0; #endif (yyval.val) = Qundef; - } + ;} break; case 539: - -/* Line 1806 of yacc.c */ -#line 4732 "ripper.y" +#line 4734 "ripper.y" { #if 0 value_expr((yyvsp[(1) - (1)].val)); @@ -10784,20 +10010,16 @@ yyreduce: #endif (yyval.val) = (yyvsp[(1) - (1)].val); - } + ;} break; case 540: - -/* Line 1806 of yacc.c */ -#line 4741 "ripper.y" - {lex_state = EXPR_BEG;} +#line 4743 "ripper.y" + {lex_state = EXPR_BEG;;} break; case 541: - -/* Line 1806 of yacc.c */ -#line 4742 "ripper.y" +#line 4744 "ripper.y" { #if 0 if ((yyvsp[(3) - (4)].val) == 0) { @@ -10823,128 +10045,96 @@ yyreduce: #endif (yyval.val) = dispatch1(paren, (yyvsp[(3) - (4)].val)); - } + ;} break; case 543: - -/* Line 1806 of yacc.c */ -#line 4772 "ripper.y" +#line 4774 "ripper.y" { #if 0 (yyval.val) = (yyvsp[(1) - (2)].val); #endif (yyval.val) = dispatch1(assoclist_from_args, (yyvsp[(1) - (2)].val)); - } + ;} break; case 544: - -/* Line 1806 of yacc.c */ -#line 4784 "ripper.y" +#line 4786 "ripper.y" { (yyval.val) = rb_ary_new3(1, (yyvsp[(1) - (1)].val)); - } + ;} break; case 545: - -/* Line 1806 of yacc.c */ -#line 4789 "ripper.y" +#line 4791 "ripper.y" { #if 0 (yyval.val) = list_concat((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); #endif (yyval.val) = rb_ary_push((yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 546: - -/* Line 1806 of yacc.c */ -#line 4799 "ripper.y" +#line 4801 "ripper.y" { #if 0 (yyval.val) = list_append(NEW_LIST((yyvsp[(1) - (3)].val)), (yyvsp[(3) - (3)].val)); #endif (yyval.val) = dispatch2(assoc_new, (yyvsp[(1) - (3)].val), (yyvsp[(3) - (3)].val)); - } + ;} break; case 547: - -/* Line 1806 of yacc.c */ -#line 4807 "ripper.y" +#line 4809 "ripper.y" { #if 0 (yyval.val) = list_append(NEW_LIST(NEW_LIT(ID2SYM((yyvsp[(1) - (2)].val)))), (yyvsp[(2) - (2)].val)); #endif (yyval.val) = dispatch2(assoc_new, (yyvsp[(1) - (2)].val), (yyvsp[(2) - (2)].val)); - } + ;} break; case 558: - -/* Line 1806 of yacc.c */ -#line 4835 "ripper.y" - { (yyval.val) = (yyvsp[(1) - (1)].val); } +#line 4837 "ripper.y" + { (yyval.val) = (yyvsp[(1) - (1)].val); ;} break; case 559: - -/* Line 1806 of yacc.c */ -#line 4840 "ripper.y" - { (yyval.val) = (yyvsp[(1) - (1)].val); } +#line 4842 "ripper.y" + { (yyval.val) = (yyvsp[(1) - (1)].val); ;} break; case 569: - -/* Line 1806 of yacc.c */ -#line 4863 "ripper.y" - {yyerrok;} +#line 4865 "ripper.y" + {yyerrok;;} break; case 572: - -/* Line 1806 of yacc.c */ -#line 4868 "ripper.y" - {yyerrok;} +#line 4870 "ripper.y" + {yyerrok;;} break; case 573: - -/* Line 1806 of yacc.c */ -#line 4872 "ripper.y" +#line 4874 "ripper.y" { #if 0 (yyval.val) = 0; #endif (yyval.val) = Qundef; - } + ;} break; - -/* Line 1806 of yacc.c */ -#line 10933 "parse.c" +/* Line 1267 of yacc.c. */ +#line 10134 "parse.c" default: break; } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action invokes - YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or - if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an - incorrect destructor might then be invoked immediately. In the - case of YYERROR or YYBACKUP, subsequent parser actions might lead - to an incorrect destructor call or verbose syntax error message - before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -10953,6 +10143,7 @@ yyreduce: *++yyvsp = yyval; + /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -10972,10 +10163,6 @@ yyreduce: | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -10983,36 +10170,37 @@ yyerrlab: #if ! YYERROR_VERBOSE parser_yyerror (parser, YY_("syntax error")); #else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - parser_yyerror (parser, yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + parser_yyerror (parser, yymsg); + } + else + { + parser_yyerror (parser, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } } -# undef YYSYNTAX_ERROR #endif } @@ -11020,7 +10208,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse lookahead token after an + /* If just tried and failed to reuse look-ahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -11037,7 +10225,7 @@ yyerrlab: } } - /* Else will try to reuse lookahead token after shifting the error + /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1; @@ -11071,7 +10259,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (!yypact_value_is_default (yyn)) + if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) @@ -11094,6 +10282,9 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } + if (yyn == YYFINAL) + YYACCEPT; + *++yyvsp = yylval; @@ -11118,7 +10309,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined(yyoverflow) || YYERROR_VERBOSE +#ifndef yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -11129,14 +10320,9 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE (yychar); - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, parser); - } + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, parser); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -11160,9 +10346,7 @@ yyreturn: } - -/* Line 2067 of yacc.c */ -#line 4880 "ripper.y" +#line 4882 "ripper.y" # undef parser # undef yylex @@ -12212,7 +11396,7 @@ parser_tokadd_string(struct parser_params *parser, default: if (c == -1) return -1; if (!ISASCII(c)) { - tokadd('\\'); + if ((func & STR_FUNC_EXPAND) == 0) tokadd('\\'); goto non_ascii; } if (func & STR_FUNC_REGEXP) { @@ -12269,6 +11453,25 @@ parser_tokadd_string(struct parser_params *parser, #define NEW_STRTERM(func, term, paren) \ rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0) +#ifdef RIPPER +static void +ripper_flush_string_content(struct parser_params *parser, rb_encoding *enc) +{ + if (!NIL_P(parser->delayed)) { + ptrdiff_t len = lex_p - parser->tokp; + if (len > 0) { + rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc); + } + ripper_dispatch_delayed_token(parser, tSTRING_CONTENT); + parser->tokp = lex_p; + } +} + +#define flush_string_content(enc) ripper_flush_string_content(parser, (enc)) +#else +#define flush_string_content(enc) ((void)(enc)) +#endif + static int parser_parse_string(struct parser_params *parser, NODE *quote) { @@ -12327,17 +11530,7 @@ parser_parse_string(struct parser_params *parser, NODE *quote) tokfix(); set_yylval_str(STR_NEW3(tok(), toklen(), enc, func)); - -#ifdef RIPPER - if (!NIL_P(parser->delayed)) { - ptrdiff_t len = lex_p - parser->tokp; - if (len > 0) { - rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc); - } - ripper_dispatch_delayed_token(parser, tSTRING_CONTENT); - parser->tokp = lex_p; - } -#endif + flush_string_content(enc); return tSTRING_CONTENT; } @@ -12542,6 +11735,7 @@ parser_here_document(struct parser_params *parser, NODE *here) } if (c != '\n') { set_yylval_str(STR_NEW3(tok(), toklen(), enc, func)); + flush_string_content(enc); return tSTRING_CONTENT; } tokadd(nextc()); @@ -12819,6 +12013,7 @@ parser_magic_comment(struct parser_params *parser, const char *str, long len) } } while (++p < magic_comments + numberof(magic_comments)); #else + str_copy(val, vbeg, vend - vbeg); dispatch2(magic_comment, name, val); #endif } @@ -13301,7 +12496,6 @@ parser_yylex(struct parser_params *parser) } else if (!lex_eol_p() && !(c = *lex_p, ISASCII(c))) { nextc(); - tokadd('\\'); if (tokadd_mbchar(c) == -1) return 0; } else { @@ -14198,7 +13392,8 @@ parser_yylex(struct parser_params *parser) ID ident = TOK_INTERN(!ENC_SINGLE(mb)); set_yylval_name(ident); - if (last_state != EXPR_DOT && is_local_id(ident) && lvar_defined(ident)) { + if (last_state != EXPR_DOT && last_state != EXPR_FNAME && + is_local_id(ident) && lvar_defined(ident)) { lex_state = EXPR_END; } } diff --git a/ext/ripper/ripper.y b/ext/ripper/ripper.y index dbaf40c..0ffe293 100644 --- a/ext/ripper/ripper.y +++ b/ext/ripper/ripper.y @@ -2,7 +2,7 @@ parse.y - - $Author: nobu $ + $Author: usa $ created at: Fri May 28 18:02:42 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -4374,6 +4374,8 @@ f_arglist : '(' f_args rparen | f_args term { $$ = $1; + lex_state = EXPR_BEG; + command_start = TRUE; } ; @@ -5926,7 +5928,7 @@ parser_tokadd_string(struct parser_params *parser, default: if (c == -1) return -1; if (!ISASCII(c)) { - tokadd('\\'); + if ((func & STR_FUNC_EXPAND) == 0) tokadd('\\'); goto non_ascii; } if (func & STR_FUNC_REGEXP) { @@ -5983,6 +5985,25 @@ parser_tokadd_string(struct parser_params *parser, #define NEW_STRTERM(func, term, paren) \ rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0) +#ifdef RIPPER +static void +ripper_flush_string_content(struct parser_params *parser, rb_encoding *enc) +{ + if (!NIL_P(parser->delayed)) { + ptrdiff_t len = lex_p - parser->tokp; + if (len > 0) { + rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc); + } + ripper_dispatch_delayed_token(parser, tSTRING_CONTENT); + parser->tokp = lex_p; + } +} + +#define flush_string_content(enc) ripper_flush_string_content(parser, (enc)) +#else +#define flush_string_content(enc) ((void)(enc)) +#endif + static int parser_parse_string(struct parser_params *parser, NODE *quote) { @@ -6041,17 +6062,7 @@ parser_parse_string(struct parser_params *parser, NODE *quote) tokfix(); set_yylval_str(STR_NEW3(tok(), toklen(), enc, func)); - -#ifdef RIPPER - if (!NIL_P(parser->delayed)) { - ptrdiff_t len = lex_p - parser->tokp; - if (len > 0) { - rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc); - } - ripper_dispatch_delayed_token(parser, tSTRING_CONTENT); - parser->tokp = lex_p; - } -#endif + flush_string_content(enc); return tSTRING_CONTENT; } @@ -6256,6 +6267,7 @@ parser_here_document(struct parser_params *parser, NODE *here) } if (c != '\n') { set_yylval_str(STR_NEW3(tok(), toklen(), enc, func)); + flush_string_content(enc); return tSTRING_CONTENT; } tokadd(nextc()); @@ -6533,6 +6545,7 @@ parser_magic_comment(struct parser_params *parser, const char *str, long len) } } while (++p < magic_comments + numberof(magic_comments)); #else + str_copy(val, vbeg, vend - vbeg); dispatch2(magic_comment, name, val); #endif } @@ -7015,7 +7028,6 @@ parser_yylex(struct parser_params *parser) } else if (!lex_eol_p() && !(c = *lex_p, ISASCII(c))) { nextc(); - tokadd('\\'); if (tokadd_mbchar(c) == -1) return 0; } else { @@ -7912,7 +7924,8 @@ parser_yylex(struct parser_params *parser) ID ident = TOK_INTERN(!ENC_SINGLE(mb)); set_yylval_name(ident); - if (last_state != EXPR_DOT && is_local_id(ident) && lvar_defined(ident)) { + if (last_state != EXPR_DOT && last_state != EXPR_FNAME && + is_local_id(ident) && lvar_defined(ident)) { lex_state = EXPR_END; } } diff --git a/ext/ripper/y.output b/ext/ripper/y.output index 1024974..075ddb7 100644 --- a/ext/ripper/y.output +++ b/ext/ripper/y.output @@ -1,4 +1,4 @@ -Terminals unused in grammar +Terminals which are not used tRPAREN idNULL @@ -18,9 +18,9 @@ Grammar 0 $accept: program $end - 1 $@1: /* empty */ + 1 @1: /* empty */ - 2 program: $@1 top_compstmt + 2 program: @1 top_compstmt 3 top_compstmt: top_stmts opt_terms @@ -31,9 +31,9 @@ Grammar 8 top_stmt: stmt - 9 $@2: /* empty */ + 9 @2: /* empty */ - 10 top_stmt: keyword_BEGIN $@2 '{' top_compstmt '}' + 10 top_stmt: keyword_BEGIN @2 '{' top_compstmt '}' 11 bodystmt: compstmt opt_rescue opt_else opt_ensure @@ -44,9 +44,9 @@ Grammar 15 | stmts terms stmt 16 | error stmt - 17 $@3: /* empty */ + 17 @3: /* empty */ - 18 stmt: keyword_alias fitem $@3 fitem + 18 stmt: keyword_alias fitem @3 fitem 19 | keyword_alias tGVAR tGVAR 20 | keyword_alias tGVAR tBACK_REF 21 | keyword_alias tGVAR tNTH_REF @@ -173,9 +173,9 @@ Grammar 121 undef_list: fitem - 122 $@5: /* empty */ + 122 @5: /* empty */ - 123 undef_list: undef_list ',' $@5 fitem + 123 undef_list: undef_list ',' @5 fitem 124 op: '|' 125 | '^' @@ -292,9 +292,9 @@ Grammar 234 | arg tANDOP arg 235 | arg tOROP arg - 236 $@6: /* empty */ + 236 @6: /* empty */ - 237 arg: keyword_defined opt_nl $@6 arg + 237 arg: keyword_defined opt_nl @6 arg 238 | arg '?' arg opt_nl ':' arg 239 | primary @@ -354,9 +354,9 @@ Grammar 280 primary: k_begin @8 bodystmt k_end - 281 $@9: /* empty */ + 281 @9: /* empty */ - 282 primary: tLPAREN_ARG expr $@9 rparen + 282 primary: tLPAREN_ARG expr @9 rparen 283 | tLPAREN compstmt ')' 284 | primary_value tCOLON2 tCONSTANT 285 | tCOLON3 tCONSTANT @@ -367,9 +367,9 @@ Grammar 290 | keyword_yield '(' rparen 291 | keyword_yield - 292 $@10: /* empty */ + 292 @10: /* empty */ - 293 primary: keyword_defined opt_nl '(' $@10 expr rparen + 293 primary: keyword_defined opt_nl '(' @10 expr rparen 294 | keyword_not '(' expr rparen 295 | keyword_not '(' rparen 296 | operation brace_block @@ -379,25 +379,25 @@ Grammar 300 | k_if expr_value then compstmt if_tail k_end 301 | k_unless expr_value then compstmt opt_else k_end - 302 $@11: /* empty */ + 302 @11: /* empty */ - 303 $@12: /* empty */ + 303 @12: /* empty */ - 304 primary: k_while $@11 expr_value do $@12 compstmt k_end + 304 primary: k_while @11 expr_value do @12 compstmt k_end - 305 $@13: /* empty */ + 305 @13: /* empty */ - 306 $@14: /* empty */ + 306 @14: /* empty */ - 307 primary: k_until $@13 expr_value do $@14 compstmt k_end + 307 primary: k_until @13 expr_value do @14 compstmt k_end 308 | k_case expr_value opt_terms case_body k_end 309 | k_case opt_terms case_body k_end - 310 $@15: /* empty */ + 310 @15: /* empty */ - 311 $@16: /* empty */ + 311 @16: /* empty */ - 312 primary: k_for for_var keyword_in $@15 expr_value do $@16 compstmt k_end + 312 primary: k_for for_var keyword_in @15 expr_value do @16 compstmt k_end 313 @17: /* empty */ @@ -417,11 +417,11 @@ Grammar 321 primary: k_def fname @21 f_arglist bodystmt k_end - 322 $@22: /* empty */ + 322 @22: /* empty */ - 323 $@23: /* empty */ + 323 @23: /* empty */ - 324 primary: k_def singleton dot_or_colon $@22 fname $@23 f_arglist bodystmt k_end + 324 primary: k_def singleton dot_or_colon @22 fname @23 f_arglist bodystmt k_end 325 | keyword_break 326 | keyword_next 327 | keyword_redo @@ -667,9 +667,9 @@ Grammar 492 superclass: term - 493 $@32: /* empty */ + 493 @32: /* empty */ - 494 superclass: '<' $@32 expr_value term + 494 superclass: '<' @32 expr_value term 495 | error term 496 f_arglist: '(' f_args rparen @@ -731,9 +731,9 @@ Grammar 538 singleton: var_ref - 539 $@33: /* empty */ + 539 @33: /* empty */ - 540 singleton: '(' $@33 expr rparen + 540 singleton: '(' @33 expr rparen 541 assoc_list: none 542 | assocs trailer @@ -948,7 +948,7 @@ $accept (148) on left: 0 program (149) on left: 2, on right: 0 -$@1 (150) +@1 (150) on left: 1, on right: 2 top_compstmt (151) on left: 3, on right: 2 10 @@ -956,7 +956,7 @@ top_stmts (152) on left: 4 5 6 7, on right: 3 6 top_stmt (153) on left: 8 10, on right: 5 6 7 -$@2 (154) +@2 (154) on left: 9, on right: 10 bodystmt (155) on left: 11, on right: 280 314 317 319 321 324 @@ -968,7 +968,7 @@ stmts (157) stmt (158) on left: 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41, on right: 8 14 15 16 23 24 25 26 27 -$@3 (159) +@3 (159) on left: 17, on right: 18 command_asgn (160) on left: 42 43, on right: 29 43 @@ -1017,12 +1017,12 @@ fitem (180) on left: 119 120, on right: 18 121 123 undef_list (181) on left: 121 123, on right: 22 123 -$@5 (182) +@5 (182) on left: 122, on right: 123 op (183) on left: 124 125 126 127 128 129 130 131 132 133 134 135 136 137 - 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152, on right: - 115 553 556 + 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152, + on right: 115 553 556 reswords (184) on left: 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 @@ -1030,11 +1030,11 @@ reswords (184) arg (185) on left: 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 - 224 225 226 227 228 229 230 231 232 233 234 235 237 238 239, on right: - 49 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 - 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 - 225 226 227 228 229 230 231 232 233 234 235 237 238 240 -$@6 (186) + 224 225 226 227 228 229 230 231 232 233 234 235 237 238 239, + on right: 49 194 195 196 197 198 199 200 201 202 203 204 205 206 + 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 + 223 224 225 226 227 228 229 230 231 232 233 234 235 237 238 240 +@6 (186) on left: 236, on right: 237 arg_value (187) on left: 240, on right: 39 260 263 264 265 266 267 268 269 421 @@ -1065,25 +1065,25 @@ mrhs (198) primary (199) on left: 270 271 272 273 274 275 276 277 278 280 282 283 284 285 286 287 288 289 290 291 293 294 295 296 297 298 299 300 301 304 - 307 308 309 312 314 317 319 321 324 325 326 327 328, on right: - 239 329 + 307 308 309 312 314 317 319 321 324 325 326 327 328, + on right: 239 329 @8 (200) on left: 279, on right: 280 -$@9 (201) +@9 (201) on left: 281, on right: 282 -$@10 (202) +@10 (202) on left: 292, on right: 293 -$@11 (203) +@11 (203) on left: 302, on right: 304 -$@12 (204) +@12 (204) on left: 303, on right: 304 -$@13 (205) +@13 (205) on left: 305, on right: 307 -$@14 (206) +@14 (206) on left: 306, on right: 307 -$@15 (207) +@15 (207) on left: 310, on right: 312 -$@16 (208) +@16 (208) on left: 311, on right: 312 @17 (209) on left: 313, on right: 314 @@ -1095,9 +1095,9 @@ $@16 (208) on left: 318, on right: 319 @21 (213) on left: 320, on right: 321 -$@22 (214) +@22 (214) on left: 322, on right: 324 -$@23 (215) +@23 (215) on left: 323, on right: 324 primary_value (216) on left: 329, on right: 32 33 34 35 36 60 61 62 63 91 92 93 94 @@ -1249,7 +1249,7 @@ backref (287) on left: 490 491, on right: 37 97 106 204 277 463 superclass (288) on left: 492 494 495, on right: 314 -$@32 (289) +@32 (289) on left: 493, on right: 494 f_arglist (290) on left: 496 497, on right: 321 324 @@ -1288,7 +1288,7 @@ opt_f_block_arg (304) 510 singleton (305) on left: 538 540, on right: 324 -$@33 (306) +@33 (306) on left: 539, on right: 540 assoc_list (307) on left: 541 542, on right: 287 @@ -1329,10 +1329,10 @@ state 0 0 $accept: . program $end - $default reduce using rule 1 ($@1) + $default reduce using rule 1 (@1) program go to state 1 - $@1 go to state 2 + @1 go to state 2 state 1 @@ -1344,7 +1344,7 @@ state 1 state 2 - 2 program: $@1 . top_compstmt + 2 program: @1 . top_compstmt error shift, and go to state 4 keyword_class shift, and go to state 5 @@ -2254,7 +2254,7 @@ state 27 state 28 - 18 stmt: keyword_alias . fitem $@3 fitem + 18 stmt: keyword_alias . fitem @3 fitem 19 | keyword_alias . tGVAR tGVAR 20 | keyword_alias . tGVAR tBACK_REF 21 | keyword_alias . tGVAR tNTH_REF @@ -2346,8 +2346,8 @@ state 28 state 29 - 237 arg: keyword_defined . opt_nl $@6 arg - 293 primary: keyword_defined . opt_nl '(' $@10 expr rparen + 237 arg: keyword_defined . opt_nl @6 arg + 293 primary: keyword_defined . opt_nl '(' @10 expr rparen '\n' shift, and go to state 224 @@ -2358,11 +2358,11 @@ state 29 state 30 - 10 top_stmt: keyword_BEGIN . $@2 '{' top_compstmt '}' + 10 top_stmt: keyword_BEGIN . @2 '{' top_compstmt '}' - $default reduce using rule 9 ($@2) + $default reduce using rule 9 (@2) - $@2 go to state 229 + @2 go to state 229 state 31 @@ -2968,7 +2968,7 @@ state 49 state 50 - 282 primary: tLPAREN_ARG . expr $@9 rparen + 282 primary: tLPAREN_ARG . expr @9 rparen keyword_class shift, and go to state 5 keyword_module shift, and go to state 6 @@ -3717,7 +3717,7 @@ state 63 state 64 - 2 program: $@1 top_compstmt . + 2 program: @1 top_compstmt . $default reduce using rule 2 (program) @@ -4264,20 +4264,20 @@ state 84 state 85 - 304 primary: k_while . $@11 expr_value do $@12 compstmt k_end + 304 primary: k_while . @11 expr_value do @12 compstmt k_end - $default reduce using rule 302 ($@11) + $default reduce using rule 302 (@11) - $@11 go to state 341 + @11 go to state 341 state 86 - 307 primary: k_until . $@13 expr_value do $@14 compstmt k_end + 307 primary: k_until . @13 expr_value do @14 compstmt k_end - $default reduce using rule 305 ($@13) + $default reduce using rule 305 (@13) - $@13 go to state 342 + @13 go to state 342 state 87 @@ -4389,7 +4389,7 @@ state 87 state 88 - 312 primary: k_for . for_var keyword_in $@15 expr_value do $@16 compstmt k_end + 312 primary: k_for . for_var keyword_in @15 expr_value do @16 compstmt k_end keyword_class shift, and go to state 5 keyword_module shift, and go to state 6 @@ -4662,7 +4662,7 @@ state 90 state 91 321 primary: k_def . fname @21 f_arglist bodystmt k_end - 324 | k_def . singleton dot_or_colon $@22 fname $@23 f_arglist bodystmt k_end + 324 | k_def . singleton dot_or_colon @22 fname @23 f_arglist bodystmt k_end keyword_class shift, and go to state 113 keyword_module shift, and go to state 114 @@ -5485,7 +5485,7 @@ state 188 state 189 22 stmt: keyword_undef undef_list . - 123 undef_list: undef_list . ',' $@5 fitem + 123 undef_list: undef_list . ',' @5 fitem ',' shift, and go to state 389 @@ -6810,28 +6810,28 @@ state 226 state 227 - 18 stmt: keyword_alias fitem . $@3 fitem + 18 stmt: keyword_alias fitem . @3 fitem - $default reduce using rule 17 ($@3) + $default reduce using rule 17 (@3) - $@3 go to state 421 + @3 go to state 421 state 228 - 237 arg: keyword_defined opt_nl . $@6 arg - 293 primary: keyword_defined opt_nl . '(' $@10 expr rparen + 237 arg: keyword_defined opt_nl . @6 arg + 293 primary: keyword_defined opt_nl . '(' @10 expr rparen '(' shift, and go to state 422 - $default reduce using rule 236 ($@6) + $default reduce using rule 236 (@6) - $@6 go to state 423 + @6 go to state 423 state 229 - 10 top_stmt: keyword_BEGIN $@2 . '{' top_compstmt '}' + 10 top_stmt: keyword_BEGIN @2 . '{' top_compstmt '}' '{' shift, and go to state 424 @@ -7420,14 +7420,14 @@ state 249 45 expr: expr . keyword_and expr 46 | expr . keyword_or expr - 282 primary: tLPAREN_ARG expr . $@9 rparen + 282 primary: tLPAREN_ARG expr . @9 rparen keyword_and shift, and go to state 298 keyword_or shift, and go to state 299 - $default reduce using rule 281 ($@9) + $default reduce using rule 281 (@9) - $@9 go to state 435 + @9 go to state 435 state 250 @@ -7508,7 +7508,7 @@ state 257 state 258 - 293 primary: keyword_defined . opt_nl '(' $@10 expr rparen + 293 primary: keyword_defined . opt_nl '(' @10 expr rparen '\n' shift, and go to state 224 @@ -12024,7 +12024,7 @@ state 340 state 341 - 304 primary: k_while $@11 . expr_value do $@12 compstmt k_end + 304 primary: k_while @11 . expr_value do @12 compstmt k_end keyword_class shift, and go to state 5 keyword_module shift, and go to state 6 @@ -12123,7 +12123,7 @@ state 341 state 342 - 307 primary: k_until $@13 . expr_value do $@14 compstmt k_end + 307 primary: k_until @13 . expr_value do @14 compstmt k_end keyword_class shift, and go to state 5 keyword_module shift, and go to state 6 @@ -12303,7 +12303,7 @@ state 349 state 350 - 312 primary: k_for for_var . keyword_in $@15 expr_value do $@16 compstmt k_end + 312 primary: k_for for_var . keyword_in @15 expr_value do @16 compstmt k_end keyword_in shift, and go to state 554 @@ -12638,11 +12638,11 @@ state 373 state 374 - 540 singleton: '(' . $@33 expr rparen + 540 singleton: '(' . @33 expr rparen - $default reduce using rule 539 ($@33) + $default reduce using rule 539 (@33) - $@33 go to state 567 + @33 go to state 567 state 375 @@ -12663,7 +12663,7 @@ state 376 state 377 - 324 primary: k_def singleton . dot_or_colon $@22 fname $@23 f_arglist bodystmt k_end + 324 primary: k_def singleton . dot_or_colon @22 fname @23 f_arglist bodystmt k_end tCOLON2 shift, and go to state 569 '.' shift, and go to state 570 @@ -13012,11 +13012,11 @@ state 388 state 389 - 123 undef_list: undef_list ',' . $@5 fitem + 123 undef_list: undef_list ',' . @5 fitem - $default reduce using rule 122 ($@5) + $default reduce using rule 122 (@5) - $@5 go to state 584 + @5 go to state 584 state 390 @@ -14007,7 +14007,7 @@ state 420 state 421 - 18 stmt: keyword_alias fitem $@3 . fitem + 18 stmt: keyword_alias fitem @3 . fitem keyword_class shift, and go to state 113 keyword_module shift, and go to state 114 @@ -14095,16 +14095,16 @@ state 421 state 422 - 293 primary: keyword_defined opt_nl '(' . $@10 expr rparen + 293 primary: keyword_defined opt_nl '(' . @10 expr rparen - $default reduce using rule 292 ($@10) + $default reduce using rule 292 (@10) - $@10 go to state 604 + @10 go to state 604 state 423 - 237 arg: keyword_defined opt_nl $@6 . arg + 237 arg: keyword_defined opt_nl @6 . arg keyword_class shift, and go to state 5 keyword_module shift, and go to state 6 @@ -14197,7 +14197,7 @@ state 423 state 424 - 10 top_stmt: keyword_BEGIN $@2 '{' . top_compstmt '}' + 10 top_stmt: keyword_BEGIN @2 '{' . top_compstmt '}' error shift, and go to state 4 keyword_class shift, and go to state 5 @@ -14684,7 +14684,7 @@ state 434 state 435 - 282 primary: tLPAREN_ARG expr $@9 . rparen + 282 primary: tLPAREN_ARG expr @9 . rparen '\n' shift, and go to state 224 @@ -14940,7 +14940,7 @@ state 443 state 444 - 293 primary: keyword_defined opt_nl . '(' $@10 expr rparen + 293 primary: keyword_defined opt_nl . '(' @10 expr rparen '(' shift, and go to state 422 @@ -18000,7 +18000,7 @@ state 544 state 545 - 304 primary: k_while $@11 expr_value . do $@12 compstmt k_end + 304 primary: k_while @11 expr_value . do @12 compstmt k_end keyword_do_cond shift, and go to state 685 ';' shift, and go to state 288 @@ -18012,7 +18012,7 @@ state 545 state 546 - 307 primary: k_until $@13 expr_value . do $@14 compstmt k_end + 307 primary: k_until @13 expr_value . do @14 compstmt k_end keyword_do_cond shift, and go to state 685 ';' shift, and go to state 288 @@ -18357,11 +18357,11 @@ state 553 state 554 - 312 primary: k_for for_var keyword_in . $@15 expr_value do $@16 compstmt k_end + 312 primary: k_for for_var keyword_in . @15 expr_value do @16 compstmt k_end - $default reduce using rule 310 ($@15) + $default reduce using rule 310 (@15) - $@15 go to state 697 + @15 go to state 697 state 555 @@ -18415,11 +18415,11 @@ state 559 state 560 - 494 superclass: '<' . $@32 expr_value term + 494 superclass: '<' . @32 expr_value term - $default reduce using rule 493 ($@32) + $default reduce using rule 493 (@32) - $@32 go to state 700 + @32 go to state 700 state 561 @@ -18761,7 +18761,7 @@ state 566 state 567 - 540 singleton: '(' $@33 . expr rparen + 540 singleton: '(' @33 . expr rparen keyword_class shift, and go to state 5 keyword_module shift, and go to state 6 @@ -18905,11 +18905,11 @@ state 570 state 571 - 324 primary: k_def singleton dot_or_colon . $@22 fname $@23 f_arglist bodystmt k_end + 324 primary: k_def singleton dot_or_colon . @22 fname @23 f_arglist bodystmt k_end - $default reduce using rule 322 ($@22) + $default reduce using rule 322 (@22) - $@22 go to state 711 + @22 go to state 711 state 572 @@ -19184,7 +19184,7 @@ state 583 state 584 - 123 undef_list: undef_list ',' $@5 . fitem + 123 undef_list: undef_list ',' @5 . fitem keyword_class shift, and go to state 113 keyword_module shift, and go to state 114 @@ -19888,14 +19888,14 @@ state 602 state 603 - 18 stmt: keyword_alias fitem $@3 fitem . + 18 stmt: keyword_alias fitem @3 fitem . $default reduce using rule 18 (stmt) state 604 - 293 primary: keyword_defined opt_nl '(' $@10 . expr rparen + 293 primary: keyword_defined opt_nl '(' @10 . expr rparen keyword_class shift, and go to state 5 keyword_module shift, and go to state 6 @@ -20018,7 +20018,7 @@ state 605 233 | arg . tRSHFT arg 234 | arg . tANDOP arg 235 | arg . tOROP arg - 237 | keyword_defined opt_nl $@6 arg . + 237 | keyword_defined opt_nl @6 arg . 238 | arg . '?' arg opt_nl ':' arg tPOW shift, and go to state 308 @@ -20053,7 +20053,7 @@ state 605 state 606 - 10 top_stmt: keyword_BEGIN $@2 '{' top_compstmt . '}' + 10 top_stmt: keyword_BEGIN @2 '{' top_compstmt . '}' '}' shift, and go to state 730 @@ -20178,7 +20178,7 @@ state 612 state 613 - 282 primary: tLPAREN_ARG expr $@9 rparen . + 282 primary: tLPAREN_ARG expr @9 rparen . $default reduce using rule 282 (primary) @@ -21935,11 +21935,11 @@ state 685 state 686 - 304 primary: k_while $@11 expr_value do . $@12 compstmt k_end + 304 primary: k_while @11 expr_value do . @12 compstmt k_end - $default reduce using rule 303 ($@12) + $default reduce using rule 303 (@12) - $@12 go to state 800 + @12 go to state 800 state 687 @@ -21951,11 +21951,11 @@ state 687 state 688 - 307 primary: k_until $@13 expr_value do . $@14 compstmt k_end + 307 primary: k_until @13 expr_value do . @14 compstmt k_end - $default reduce using rule 306 ($@14) + $default reduce using rule 306 (@14) - $@14 go to state 801 + @14 go to state 801 state 689 @@ -22053,7 +22053,7 @@ state 696 state 697 - 312 primary: k_for for_var keyword_in $@15 . expr_value do $@16 compstmt k_end + 312 primary: k_for for_var keyword_in @15 . expr_value do @16 compstmt k_end keyword_class shift, and go to state 5 keyword_module shift, and go to state 6 @@ -22169,7 +22169,7 @@ state 699 state 700 - 494 superclass: '<' $@32 . expr_value term + 494 superclass: '<' @32 . expr_value term keyword_class shift, and go to state 5 keyword_module shift, and go to state 6 @@ -22447,7 +22447,7 @@ state 707 45 expr: expr . keyword_and expr 46 | expr . keyword_or expr - 540 singleton: '(' $@33 expr . rparen + 540 singleton: '(' @33 expr . rparen keyword_and shift, and go to state 298 keyword_or shift, and go to state 299 @@ -22622,7 +22622,7 @@ state 710 state 711 - 324 primary: k_def singleton dot_or_colon $@22 . fname $@23 f_arglist bodystmt k_end + 324 primary: k_def singleton dot_or_colon @22 . fname @23 f_arglist bodystmt k_end keyword_class shift, and go to state 113 keyword_module shift, and go to state 114 @@ -23074,7 +23074,7 @@ state 719 state 720 - 123 undef_list: undef_list ',' $@5 fitem . + 123 undef_list: undef_list ',' @5 fitem . $default reduce using rule 123 (undef_list) @@ -23495,7 +23495,7 @@ state 729 45 expr: expr . keyword_and expr 46 | expr . keyword_or expr - 293 primary: keyword_defined opt_nl '(' $@10 expr . rparen + 293 primary: keyword_defined opt_nl '(' @10 expr . rparen keyword_and shift, and go to state 298 keyword_or shift, and go to state 299 @@ -23509,7 +23509,7 @@ state 729 state 730 - 10 top_stmt: keyword_BEGIN $@2 '{' top_compstmt '}' . + 10 top_stmt: keyword_BEGIN @2 '{' top_compstmt '}' . $default reduce using rule 10 (top_stmt) @@ -25326,7 +25326,7 @@ state 799 state 800 - 304 primary: k_while $@11 expr_value do $@12 . compstmt k_end + 304 primary: k_while @11 expr_value do @12 . compstmt k_end error shift, and go to state 241 keyword_class shift, and go to state 5 @@ -25443,7 +25443,7 @@ state 800 state 801 - 307 primary: k_until $@13 expr_value do $@14 . compstmt k_end + 307 primary: k_until @13 expr_value do @14 . compstmt k_end error shift, and go to state 241 keyword_class shift, and go to state 5 @@ -25793,7 +25793,7 @@ state 805 state 806 - 312 primary: k_for for_var keyword_in $@15 expr_value . do $@16 compstmt k_end + 312 primary: k_for for_var keyword_in @15 expr_value . do @16 compstmt k_end keyword_do_cond shift, and go to state 685 ';' shift, and go to state 288 @@ -25814,7 +25814,7 @@ state 807 state 808 - 494 superclass: '<' $@32 expr_value . term + 494 superclass: '<' @32 expr_value . term ';' shift, and go to state 288 '\n' shift, and go to state 289 @@ -25847,7 +25847,7 @@ state 811 state 812 - 540 singleton: '(' $@33 expr rparen . + 540 singleton: '(' @33 expr rparen . $default reduce using rule 540 (singleton) @@ -25882,11 +25882,11 @@ state 815 state 816 - 324 primary: k_def singleton dot_or_colon $@22 fname . $@23 f_arglist bodystmt k_end + 324 primary: k_def singleton dot_or_colon @22 fname . @23 f_arglist bodystmt k_end - $default reduce using rule 323 ($@23) + $default reduce using rule 323 (@23) - $@23 go to state 880 + @23 go to state 880 state 817 @@ -26277,7 +26277,7 @@ state 822 state 823 - 293 primary: keyword_defined opt_nl '(' $@10 expr rparen . + 293 primary: keyword_defined opt_nl '(' @10 expr rparen . $default reduce using rule 293 (primary) @@ -27133,7 +27133,7 @@ state 869 state 870 - 304 primary: k_while $@11 expr_value do $@12 compstmt . k_end + 304 primary: k_while @11 expr_value do @12 compstmt . k_end keyword_end shift, and go to state 677 @@ -27142,7 +27142,7 @@ state 870 state 871 - 307 primary: k_until $@13 expr_value do $@14 compstmt . k_end + 307 primary: k_until @13 expr_value do @14 compstmt . k_end keyword_end shift, and go to state 677 @@ -27173,11 +27173,11 @@ state 873 state 874 - 312 primary: k_for for_var keyword_in $@15 expr_value do . $@16 compstmt k_end + 312 primary: k_for for_var keyword_in @15 expr_value do . @16 compstmt k_end - $default reduce using rule 311 ($@16) + $default reduce using rule 311 (@16) - $@16 go to state 926 + @16 go to state 926 state 875 @@ -27303,7 +27303,7 @@ state 875 state 876 - 494 superclass: '<' $@32 expr_value term . + 494 superclass: '<' @32 expr_value term . $default reduce using rule 494 (superclass) @@ -27331,7 +27331,7 @@ state 879 state 880 - 324 primary: k_def singleton dot_or_colon $@22 fname $@23 . f_arglist bodystmt k_end + 324 primary: k_def singleton dot_or_colon @22 fname @23 . f_arglist bodystmt k_end tIDENTIFIER shift, and go to state 622 tGVAR shift, and go to state 623 @@ -28038,14 +28038,14 @@ state 920 state 921 - 304 primary: k_while $@11 expr_value do $@12 compstmt k_end . + 304 primary: k_while @11 expr_value do @12 compstmt k_end . $default reduce using rule 304 (primary) state 922 - 307 primary: k_until $@13 expr_value do $@14 compstmt k_end . + 307 primary: k_until @13 expr_value do @14 compstmt k_end . $default reduce using rule 307 (primary) @@ -28073,7 +28073,7 @@ state 925 state 926 - 312 primary: k_for for_var keyword_in $@15 expr_value do $@16 . compstmt k_end + 312 primary: k_for for_var keyword_in @15 expr_value do @16 . compstmt k_end error shift, and go to state 241 keyword_class shift, and go to state 5 @@ -28199,7 +28199,7 @@ state 927 state 928 - 324 primary: k_def singleton dot_or_colon $@22 fname $@23 f_arglist . bodystmt k_end + 324 primary: k_def singleton dot_or_colon @22 fname @23 f_arglist . bodystmt k_end error shift, and go to state 241 keyword_class shift, and go to state 5 @@ -28842,7 +28842,7 @@ state 954 state 955 - 312 primary: k_for for_var keyword_in $@15 expr_value do $@16 compstmt . k_end + 312 primary: k_for for_var keyword_in @15 expr_value do @16 compstmt . k_end keyword_end shift, and go to state 677 @@ -28858,7 +28858,7 @@ state 956 state 957 - 324 primary: k_def singleton dot_or_colon $@22 fname $@23 f_arglist bodystmt . k_end + 324 primary: k_def singleton dot_or_colon @22 fname @23 f_arglist bodystmt . k_end keyword_end shift, and go to state 677 @@ -29089,14 +29089,14 @@ state 977 state 978 - 312 primary: k_for for_var keyword_in $@15 expr_value do $@16 compstmt k_end . + 312 primary: k_for for_var keyword_in @15 expr_value do @16 compstmt k_end . $default reduce using rule 312 (primary) state 979 - 324 primary: k_def singleton dot_or_colon $@22 fname $@23 f_arglist bodystmt k_end . + 324 primary: k_def singleton dot_or_colon @22 fname @23 f_arglist bodystmt k_end . $default reduce using rule 324 (primary) diff --git a/ext/socket/basicsocket.c b/ext/socket/basicsocket.c index b997043..6f942e3 100644 --- a/ext/socket/basicsocket.c +++ b/ext/socket/basicsocket.c @@ -358,11 +358,13 @@ bsock_getsockname(VALUE sock) { struct sockaddr_storage buf; socklen_t len = (socklen_t)sizeof buf; + socklen_t len0 = len; rb_io_t *fptr; GetOpenFile(sock, fptr); if (getsockname(fptr->fd, (struct sockaddr*)&buf, &len) < 0) rb_sys_fail("getsockname(2)"); + if (len0 < len) len = len0; return rb_str_new((char*)&buf, len); } @@ -387,11 +389,13 @@ bsock_getpeername(VALUE sock) { struct sockaddr_storage buf; socklen_t len = (socklen_t)sizeof buf; + socklen_t len0 = len; rb_io_t *fptr; GetOpenFile(sock, fptr); if (getpeername(fptr->fd, (struct sockaddr*)&buf, &len) < 0) rb_sys_fail("getpeername(2)"); + if (len0 < len) len = len0; return rb_str_new((char*)&buf, len); } @@ -475,11 +479,13 @@ bsock_local_address(VALUE sock) { struct sockaddr_storage buf; socklen_t len = (socklen_t)sizeof buf; + socklen_t len0 = len; rb_io_t *fptr; GetOpenFile(sock, fptr); if (getsockname(fptr->fd, (struct sockaddr*)&buf, &len) < 0) rb_sys_fail("getsockname(2)"); + if (len0 < len) len = len0; return rsock_fd_socket_addrinfo(fptr->fd, (struct sockaddr *)&buf, len); } @@ -507,11 +513,13 @@ bsock_remote_address(VALUE sock) { struct sockaddr_storage buf; socklen_t len = (socklen_t)sizeof buf; + socklen_t len0 = len; rb_io_t *fptr; GetOpenFile(sock, fptr); if (getpeername(fptr->fd, (struct sockaddr*)&buf, &len) < 0) rb_sys_fail("getpeername(2)"); + if (len0 < len) len = len0; return rsock_fd_socket_addrinfo(fptr->fd, (struct sockaddr *)&buf, len); } diff --git a/ext/socket/extconf.rb b/ext/socket/extconf.rb index 380b3ec..5c29876 100644 --- a/ext/socket/extconf.rb +++ b/ext/socket/extconf.rb @@ -24,6 +24,12 @@ else have_library("socket", "socket") end +if /darwin/ =~ RUBY_PLATFORM + # For IPv6 extension header access on OS X 10.7+ [Bug #8517] + $CFLAGS << " -D__APPLE_USE_RFC_3542" +end + +headers = [] unless $mswin or $bccwin or $mingw headers = %w<sys/types.h netdb.h string.h sys/socket.h netinet/in.h> end diff --git a/ext/socket/init.c b/ext/socket/init.c index 0a23658..54452e4 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -448,6 +448,7 @@ VALUE rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, socklen_t *len) { int fd2; + socklen_t len0 = len ? *len : 0; rb_secure(3); rb_io_set_nonblock(fptr); @@ -466,6 +467,7 @@ rsock_s_accept_nonblock(VALUE klass, rb_io_t *fptr, struct sockaddr *sockaddr, s } rb_sys_fail("accept(2)"); } + if (len && len0 < *len) *len = len0; rb_update_max_fd(fd2); make_fd_nonblock(fd2); return rsock_init_sock(rb_obj_alloc(klass), fd2); @@ -481,7 +483,12 @@ static VALUE accept_blocking(void *data) { struct accept_arg *arg = data; - return (VALUE)accept(arg->fd, arg->sockaddr, arg->len); + int ret; + socklen_t len0 = 0; + if (arg->len) len0 = *arg->len; + ret = accept(arg->fd, arg->sockaddr, arg->len); + if (arg->len && len0 < *arg->len) *arg->len = len0; + return (VALUE)ret; } VALUE diff --git a/ext/socket/lib/socket.rb b/ext/socket/lib/socket.rb index d311eed..66ff548 100644 --- a/ext/socket/lib/socket.rb +++ b/ext/socket/lib/socket.rb @@ -716,12 +716,14 @@ class Socket < BasicSocket # } # def self.unix_server_socket(path) - begin - st = File.lstat(path) - rescue Errno::ENOENT - end - if st && st.socket? && st.owned? - File.unlink path + if !unix_socket_abstract_name?(path) + begin + st = File.lstat(path) + rescue Errno::ENOENT + end + if st && st.socket? && st.owned? + File.unlink path + end end s = Addrinfo.unix(path).listen if block_given? @@ -729,13 +731,23 @@ class Socket < BasicSocket yield s ensure s.close if !s.closed? - File.unlink path + if !unix_socket_abstract_name?(path) + File.unlink path + end end else s end end + class << self + private + + def unix_socket_abstract_name?(path) + /linux/ =~ RUBY_PLATFORM && /\A(\0|\z)/ =~ path + end + end + # creates a UNIX socket server on _path_. # It calls the block for each socket accepted. # diff --git a/ext/socket/raddrinfo.c b/ext/socket/raddrinfo.c index 2229269..80e59a0 100644 --- a/ext/socket/raddrinfo.c +++ b/ext/socket/raddrinfo.c @@ -421,20 +421,46 @@ rsock_ipaddr(struct sockaddr *sockaddr, int norevlookup) } #ifdef HAVE_SYS_UN_H -const char* -rsock_unixpath(struct sockaddr_un *sockaddr, socklen_t len) +VALUE +rsock_unixpath_str(struct sockaddr_un *sockaddr, socklen_t len) { - if (sockaddr->sun_path < (char*)sockaddr + len) - return sockaddr->sun_path; + char *s, *e; + s = sockaddr->sun_path; + e = (char *)sockaddr + len; + while (s < e && *(e-1) == '\0') + e--; + if (s <= e) + return rb_str_new(s, e-s); else - return ""; + return rb_str_new2(""); } VALUE rsock_unixaddr(struct sockaddr_un *sockaddr, socklen_t len) { return rb_assoc_new(rb_str_new2("AF_UNIX"), - rb_str_new2(rsock_unixpath(sockaddr, len))); + rsock_unixpath_str(sockaddr, len)); +} + +socklen_t +rsock_unix_sockaddr_len(VALUE path) +{ +#ifdef __linux__ + if (RSTRING_LEN(path) == 0) { + /* autobind; see unix(7) for details. */ + return (socklen_t) sizeof(sa_family_t); + } + else if (RSTRING_PTR(path)[0] == '\0') { + /* abstract namespace; see unix(7) for details. */ + return (socklen_t) offsetof(struct sockaddr_un, sun_path) + + RSTRING_LEN(path); + } + else { +#endif + return (socklen_t) sizeof(struct sockaddr_un); +#ifdef __linux__ + } +#endif } #endif @@ -763,19 +789,22 @@ static void init_unix_addrinfo(rb_addrinfo_t *rai, VALUE path, int socktype) { struct sockaddr_un un; + socklen_t len; StringValue(path); - if (sizeof(un.sun_path) <= (size_t)RSTRING_LEN(path)) - rb_raise(rb_eArgError, "too long unix socket path (max: %dbytes)", - (int)sizeof(un.sun_path)-1); + if (sizeof(un.sun_path) < (size_t)RSTRING_LEN(path)) + rb_raise(rb_eArgError, + "too long unix socket path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)", + (size_t)RSTRING_LEN(path), sizeof(un.sun_path)); MEMZERO(&un, struct sockaddr_un, 1); un.sun_family = AF_UNIX; memcpy((void*)&un.sun_path, RSTRING_PTR(path), RSTRING_LEN(path)); - init_addrinfo(rai, (struct sockaddr *)&un, (socklen_t)sizeof(un), + len = rsock_unix_sockaddr_len(path); + init_addrinfo(rai, (struct sockaddr *)&un, len, PF_UNIX, socktype, 0, Qnil, Qnil); } #endif @@ -996,9 +1025,11 @@ inspect_sockaddr(VALUE addrinfo, VALUE ret) case AF_UNIX: { struct sockaddr_un *addr = (struct sockaddr_un *)&rai->addr; - char *p, *s, *t, *e; + char *p, *s, *e; s = addr->sun_path; e = (char*)addr + rai->sockaddr_len; + while (s < e && *(e-1) == '\0') + e--; if (e < s) rb_str_cat2(ret, "too-short-AF_UNIX-sockaddr"); else if (s == e) @@ -1006,28 +1037,17 @@ inspect_sockaddr(VALUE addrinfo, VALUE ret) else { int printable_only = 1; p = s; - while (p < e && *p != '\0') { + while (p < e) { printable_only = printable_only && ISPRINT(*p) && !ISSPACE(*p); p++; } - t = p; - while (p < e && *p == '\0') - p++; - if (printable_only && /* only printable, no space */ - t < e && /* NUL terminated */ - p == e) { /* no data after NUL */ - if (s == t) - rb_str_cat2(ret, "empty-path-AF_UNIX-sockaddr"); - else if (s[0] == '/') /* absolute path */ - rb_str_cat2(ret, s); - else - rb_str_catf(ret, "AF_UNIX %s", s); + if (printable_only) { /* only printable, no space */ + if (s[0] != '/') /* relative path */ + rb_str_cat2(ret, "AF_UNIX "); + rb_str_cat(ret, s, p - s); } else { rb_str_cat2(ret, "AF_UNIX"); - e = (char *)addr->sun_path + sizeof(addr->sun_path); - while (s < e && *(e-1) == '\0') - e--; while (s < e) rb_str_catf(ret, ":%02x", (unsigned char)*s++); } @@ -1201,7 +1221,7 @@ addrinfo_mdump(VALUE self) struct sockaddr_un *su = (struct sockaddr_un *)&rai->addr; char *s, *e; s = su->sun_path; - e = (char*)s + sizeof(su->sun_path); + e = (char*)su + rai->sockaddr_len; while (s < e && *(e-1) == '\0') e--; sockaddr = rb_str_new(s, e-s); @@ -1298,12 +1318,14 @@ addrinfo_mload(VALUE self, VALUE ary) case AF_UNIX: { struct sockaddr_un uaddr; - memset(&uaddr, 0, sizeof(uaddr)); + MEMZERO(&uaddr, struct sockaddr_un, 1); uaddr.sun_family = AF_UNIX; StringValue(v); - if (sizeof(uaddr.sun_path) <= (size_t)RSTRING_LEN(v)) - rb_raise(rb_eSocket, "too long AF_UNIX path"); + if (sizeof(uaddr.sun_path) < (size_t)RSTRING_LEN(v)) + rb_raise(rb_eSocket, + "too long AF_UNIX path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)", + (size_t)RSTRING_LEN(v), sizeof(uaddr.sun_path)); memcpy(uaddr.sun_path, RSTRING_PTR(v), RSTRING_LEN(v)); len = (socklen_t)sizeof(uaddr); memcpy(&ss, &uaddr, len); diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h index 4c0efdb..ab05270 100644 --- a/ext/socket/rubysocket.h +++ b/ext/socket/rubysocket.h @@ -233,8 +233,9 @@ VALUE rsock_make_hostent(VALUE host, struct addrinfo *addr, VALUE (*ipaddr)(stru int rsock_revlookup_flag(VALUE revlookup, int *norevlookup); #ifdef HAVE_SYS_UN_H -const char* rsock_unixpath(struct sockaddr_un *sockaddr, socklen_t len); +VALUE rsock_unixpath_str(struct sockaddr_un *sockaddr, socklen_t len); VALUE rsock_unixaddr(struct sockaddr_un *sockaddr, socklen_t len); +socklen_t rsock_unix_sockaddr_len(VALUE path); #endif int rsock_socket(int domain, int type, int proto); diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 4613892..bfe2edb 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -954,13 +954,12 @@ sock_s_gethostbyaddr(int argc, VALUE *argv) { VALUE addr, family; struct hostent *h; - struct sockaddr *sa; char **pch; VALUE ary, names; int t = AF_INET; rb_scan_args(argc, argv, "11", &addr, &family); - sa = (struct sockaddr*)StringValuePtr(addr); + StringValue(addr); if (!NIL_P(family)) { t = rsock_family_arg(family); } @@ -1371,18 +1370,17 @@ static VALUE sock_s_pack_sockaddr_un(VALUE self, VALUE path) { struct sockaddr_un sockaddr; - char *sun_path; VALUE addr; + StringValue(path); MEMZERO(&sockaddr, struct sockaddr_un, 1); sockaddr.sun_family = AF_UNIX; - sun_path = StringValueCStr(path); - if (sizeof(sockaddr.sun_path) <= strlen(sun_path)) { - rb_raise(rb_eArgError, "too long unix socket path (max: %dbytes)", - (int)sizeof(sockaddr.sun_path)-1); + if (sizeof(sockaddr.sun_path) < (size_t)RSTRING_LEN(path)) { + rb_raise(rb_eArgError, "too long unix socket path (%"PRIuSIZE" bytes given but %"PRIuSIZE" bytes max)", + (size_t)RSTRING_LEN(path), sizeof(sockaddr.sun_path)); } - strncpy(sockaddr.sun_path, sun_path, sizeof(sockaddr.sun_path)-1); - addr = rb_str_new((char*)&sockaddr, sizeof(sockaddr)); + memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path)); + addr = rb_str_new((char*)&sockaddr, rsock_unix_sockaddr_len(path)); OBJ_INFECT(addr, path); return addr; @@ -1404,7 +1402,6 @@ static VALUE sock_s_unpack_sockaddr_un(VALUE self, VALUE addr) { struct sockaddr_un * sockaddr; - const char *sun_path; VALUE path; sockaddr = (struct sockaddr_un*)SockAddrStringValuePtr(addr); @@ -1420,13 +1417,7 @@ sock_s_unpack_sockaddr_un(VALUE self, VALUE addr) rb_raise(rb_eTypeError, "too long sockaddr_un - %ld longer than %d", RSTRING_LEN(addr), (int)sizeof(struct sockaddr_un)); } - sun_path = rsock_unixpath(sockaddr, RSTRING_LENINT(addr)); - if (sizeof(struct sockaddr_un) == RSTRING_LEN(addr) && - sun_path == sockaddr->sun_path && - sun_path + strlen(sun_path) == RSTRING_PTR(addr) + RSTRING_LEN(addr)) { - rb_raise(rb_eArgError, "sockaddr_un.sun_path not NUL terminated"); - } - path = rb_str_new2(sun_path); + path = rsock_unixpath_str(sockaddr, RSTRING_LENINT(addr)); OBJ_INFECT(path, addr); return path; } diff --git a/ext/socket/unixsocket.c b/ext/socket/unixsocket.c index 26822e5..3c30e92 100644 --- a/ext/socket/unixsocket.c +++ b/ext/socket/unixsocket.c @@ -13,6 +13,7 @@ #ifdef HAVE_SYS_UN_H struct unixsock_arg { struct sockaddr_un *sockaddr; + socklen_t sockaddrlen; int fd; }; @@ -21,13 +22,14 @@ unixsock_connect_internal(VALUE a) { struct unixsock_arg *arg = (struct unixsock_arg *)a; return (VALUE)rsock_connect(arg->fd, (struct sockaddr*)arg->sockaddr, - (socklen_t)sizeof(*arg->sockaddr), 0); + arg->sockaddrlen, 0); } VALUE rsock_init_unixsock(VALUE sock, VALUE path, int server) { struct sockaddr_un sockaddr; + socklen_t sockaddrlen; int fd, status; rb_io_t *fptr; @@ -39,19 +41,21 @@ rsock_init_unixsock(VALUE sock, VALUE path, int server) MEMZERO(&sockaddr, struct sockaddr_un, 1); sockaddr.sun_family = AF_UNIX; - if (sizeof(sockaddr.sun_path) <= (size_t)RSTRING_LEN(path)) { - rb_raise(rb_eArgError, "too long unix socket path (max: %dbytes)", - (int)sizeof(sockaddr.sun_path)-1); + if (sizeof(sockaddr.sun_path) < (size_t)RSTRING_LEN(path)) { + rb_raise(rb_eArgError, "too long unix socket path (%ldbytes given but %dbytes max)", + RSTRING_LEN(path), (int)sizeof(sockaddr.sun_path)); } memcpy(sockaddr.sun_path, RSTRING_PTR(path), RSTRING_LEN(path)); + sockaddrlen = rsock_unix_sockaddr_len(path); if (server) { - status = bind(fd, (struct sockaddr*)&sockaddr, (socklen_t)sizeof(sockaddr)); + status = bind(fd, (struct sockaddr*)&sockaddr, sockaddrlen); } else { int prot; struct unixsock_arg arg; arg.sockaddr = &sockaddr; + arg.sockaddrlen = sockaddrlen; arg.fd = fd; status = (int)rb_protect(unixsock_connect_internal, (VALUE)&arg, &prot); if (prot) { @@ -62,7 +66,7 @@ rsock_init_unixsock(VALUE sock, VALUE path, int server) if (status < 0) { close(fd); - rb_sys_fail(sockaddr.sun_path); + rb_sys_fail_str(rb_inspect(path)); } if (server) { @@ -116,9 +120,11 @@ unix_path(VALUE sock) if (NIL_P(fptr->pathv)) { struct sockaddr_un addr; socklen_t len = (socklen_t)sizeof(addr); + socklen_t len0 = len; if (getsockname(fptr->fd, (struct sockaddr*)&addr, &len) < 0) rb_sys_fail(0); - fptr->pathv = rb_obj_freeze(rb_str_new_cstr(rsock_unixpath(&addr, len))); + if (len0 < len) len = len0; + fptr->pathv = rb_obj_freeze(rsock_unixpath_str(&addr, len)); } return rb_str_dup(fptr->pathv); } @@ -445,11 +451,13 @@ unix_peeraddr(VALUE sock) rb_io_t *fptr; struct sockaddr_un addr; socklen_t len = (socklen_t)sizeof addr; + socklen_t len0 = len; GetOpenFile(sock, fptr); if (getpeername(fptr->fd, (struct sockaddr*)&addr, &len) < 0) rb_sys_fail("getpeername(2)"); + if (len0 < len) len = len0; return rsock_unixaddr(&addr, len); } diff --git a/ext/syslog/syslog.c b/ext/syslog/syslog.c index 76aef9c..3e704bd 100644 --- a/ext/syslog/syslog.c +++ b/ext/syslog/syslog.c @@ -5,7 +5,7 @@ * Documented by mathew <meta@pobox.com> * * $RoughId: syslog.c,v 1.21 2002/02/25 12:21:17 knu Exp $ - * $Id: syslog.c 31234 2011-04-03 13:58:32Z nagachika $ + * $Id: syslog.c 35740 2012-05-21 07:24:34Z knu $ */ #include "ruby/ruby.h" @@ -315,6 +315,8 @@ static VALUE mSyslog_inspect(VALUE self) { char buf[1024]; + Check_Type(self, T_MODULE); + if (syslog_opened) { snprintf(buf, sizeof(buf), "<#%s: opened=true, ident=\"%s\", options=%d, facility=%d, mask=%d>", diff --git a/ext/tk/extconf.rb b/ext/tk/extconf.rb index 2f68d01..2b5c8c4 100644 --- a/ext/tk/extconf.rb +++ b/ext/tk/extconf.rb @@ -114,7 +114,7 @@ def is_macosx? end def maybe_64bit? - /64|universal/ =~ RUBY_PLATFORM + /64|universal|s390x/ =~ RUBY_PLATFORM end def check_tcltk_version(version) @@ -313,7 +313,9 @@ def find_macosx_framework paths.reverse! unless TkLib_Config["ActiveTcl"] # system has higher priority paths.map{|dir| dir.strip.chomp('/')}.each{|dir| + next unless File.exist?(File.join(dir, "Tcl.framework", "Headers")) next unless File.directory?(tcldir = File.join(dir, "Tcl.framework")) + next unless File.exist?(File.join(dir, "Tk.framework"), "Headers") next unless File.directory?(tkdir = File.join(dir, "Tk.framework")) TkLib_Config["tcltk-framework"] = dir return [tcldir, tkdir] diff --git a/ext/tk/lib/tk/canvas.rb b/ext/tk/lib/tk/canvas.rb index 7d3d716..af40421 100644 --- a/ext/tk/lib/tk/canvas.rb +++ b/ext/tk/lib/tk/canvas.rb @@ -85,11 +85,16 @@ class Tk::Canvas<TkWindow # create a canvas item without creating a TkcItem object def create(type, *args) - type = TkcItem.type2class(type.to_s) unless type.kind_of?(TkcItem) + if type.kind_of?(Class) && type < TkcItem + # do nothing + elsif TkcItem.type2class(type.to_s) + type = TkcItem.type2class(type.to_s) + else + fail ArgumentError, "type must a subclass of TkcItem class, or a string in CItemTypeToClass" + end type.create(self, *args) end - def addtag(tag, mode, *args) mode = mode.to_s if args[0] && mode =~ /^(above|below|with(tag)?)$/ diff --git a/ext/tk/sample/demos-en/tree.rb b/ext/tk/sample/demos-en/tree.rb index cd62ba8..69154ee 100644 --- a/ext/tk/sample/demos-en/tree.rb +++ b/ext/tk/sample/demos-en/tree.rb @@ -67,7 +67,7 @@ def populate_tree(tree, node) path = tree.get(node, :fullpath) tree.delete(tree.children(node)) Dir.glob("#{path}/*").sort.each{|f| - type = File.ftype(f) + type = File.ftype(f) rescue nil id = tree.insert(node, :end, :text=>File.basename(f), :values=>[f, type]).id if type == 'directory' diff --git a/ext/tk/sample/demos-en/widget b/ext/tk/sample/demos-en/widget index e6510c7..3778929 100644 --- a/ext/tk/sample/demos-en/widget +++ b/ext/tk/sample/demos-en/widget @@ -683,7 +683,7 @@ def eval_samplecode(code, file=nil) end } } - Tk.update + Tk.update rescue nil end # invoke -- @@ -699,7 +699,7 @@ def invoke(txt, idx) cursor = txt.cget('cursor') txt.cursor('watch') - Tk.update + Tk.update rescue nil # eval(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, _null_binding) # Tk.update eval_samplecode(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, tag[5..-1] + '.rb') @@ -1058,7 +1058,7 @@ if ARGV[0] == '-n' no_launcher = true if ARGV.size > 0 else # show the root widget to make it lower then demo windows - Tk.update + Tk.update rescue nil end ARGV.each{|cmd| if cmd =~ /(.*).rb/ diff --git a/ext/tk/sample/demos-jp/tree.rb b/ext/tk/sample/demos-jp/tree.rb index 00d7152..f685544 100644 --- a/ext/tk/sample/demos-jp/tree.rb +++ b/ext/tk/sample/demos-jp/tree.rb @@ -68,7 +68,7 @@ def populate_tree(tree, node) path = tree.get(node, :fullpath) tree.delete(tree.children(node)) Dir.glob("#{path}/*").sort.each{|f| - type = File.ftype(f) + type = File.ftype(f) rescue nil id = tree.insert(node, :end, :text=>File.basename(f), :values=>[f, type]).id if type == 'directory' diff --git a/ext/tk/sample/demos-jp/widget b/ext/tk/sample/demos-jp/widget index fc3c084..ae91031 100644 --- a/ext/tk/sample/demos-jp/widget +++ b/ext/tk/sample/demos-jp/widget @@ -740,7 +740,7 @@ def eval_samplecode(code, file=nil) end } } - Tk.update + Tk.update rescue nil end # ¥Æ¥¥¹¥È¾å¤Ç¤Î click ¤ËÂФ¹¤ëÆ°ºî @@ -750,7 +750,7 @@ def invoke(txt, idx) cursor = txt.cget('cursor') txt.cursor('watch') - Tk.update + Tk.update rescue nil # eval(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, _null_binding) # Tk.update eval_samplecode(IO.readlines("#{[$demo_dir, tag[5..-1]].join(File::Separator)}.rb").join, tag[5..-1] + '.rb') @@ -1094,7 +1094,7 @@ if ARGV[0] == '-n' no_launcher = true if ARGV.size > 0 else # show the root widget to make it lower then demo windows - Tk.update + Tk.update rescue nil end ARGV.each{|cmd| if cmd =~ /(.*).rb/ diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb index 0838cfc..3442a3f 100644 --- a/ext/zlib/extconf.rb +++ b/ext/zlib/extconf.rb @@ -1,7 +1,7 @@ # # extconf.rb # -# $Id: extconf.rb 26353 2010-01-19 05:14:29Z usa $ +# $Id: extconf.rb 37561 2012-11-08 08:34:18Z usa $ # require 'mkmf' @@ -10,7 +10,7 @@ require 'rbconfig' dir_config 'zlib' -if %w'z libz zlib1 zlib zdll'.find {|z| have_library(z, 'deflateReset')} and +if %w'z libz zlib1 zlib zdll zlibwapi'.find {|z| have_library(z, 'deflateReset')} and have_header('zlib.h') then defines = [] @@ -48,8 +48,7 @@ if %w'z libz zlib1 zlib zdll'.find {|z| have_library(z, 'deflateReset')} and 'OS_UNKNOWN' => 'Unknown', } unless OS_NAMES.key? os_code then - puts "invalid OS_CODE `#{os_code}'" - exit + raise "invalid OS_CODE `#{os_code}'" end message "#{OS_NAMES[os_code]}\n" defines << "OS_CODE=#{os_code}" @@ -58,6 +57,7 @@ if %w'z libz zlib1 zlib zdll'.find {|z| have_library(z, 'deflateReset')} and have_func('crc32_combine', 'zlib.h') have_func('adler32_combine', 'zlib.h') + have_type('z_crc_t', 'zlib.h') create_makefile('zlib') diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index 5607162..b5495a2 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -3,7 +3,7 @@ * * Copyright (C) UENO Katsuhiro 2000-2003 * - * $Id: zlib.c 34544 2012-02-10 18:37:45Z naruse $ + * $Id: zlib.c 36939 2012-09-09 14:01:53Z naruse $ */ #include <ruby.h> @@ -464,7 +464,11 @@ rb_zlib_crc32_combine(VALUE klass, VALUE crc1, VALUE crc2, VALUE len2) static VALUE rb_zlib_crc_table(VALUE obj) { - const unsigned long *crctbl; +#if !defined(HAVE_TYPE_Z_CRC_T) + /* z_crc_t is defined since zlib-1.2.7. */ + typedef unsigned long z_crc_t; +#endif + const z_crc_t *crctbl; VALUE dst; int i; @@ -1732,7 +1736,7 @@ do_inflate(struct zstream *z, VALUE src) return; } StringValue(src); - if (RSTRING_LEN(src) > 0) { /* prevent Z_BUF_ERROR */ + if (RSTRING_LEN(src) > 0 || z->stream.avail_in > 0) { /* prevent Z_BUF_ERROR */ zstream_run(z, (Bytef*)RSTRING_PTR(src), RSTRING_LEN(src), Z_SYNC_FLUSH); } } @@ -1749,7 +1753,23 @@ do_inflate(struct zstream *z, VALUE src) * * Raises a Zlib::NeedDict exception if a preset dictionary is needed to * decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then - * call this method again with an empty string. (<i>???</i>) + * call this method again with an empty string to flush the stream: + * + * inflater = Zlib::Inflate.new + * + * begin + * out = inflater.inflate compressed + * rescue Zlib::NeedDict + * # ensure the dictionary matches the stream's required dictionary + * raise unless inflater.adler == Zlib.adler32(dictionary) + * + * inflater.set_dictionary dictionary + * inflater.inflate '' + * end + * + * # ... + * + * inflater.close * * See also Zlib::Inflate.new */ @@ -2,7 +2,7 @@ file.c - - $Author: naruse $ + $Author: usa $ created at: Mon Nov 15 12:24:34 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -17,6 +17,7 @@ #ifdef __CYGWIN__ #include <windows.h> #include <sys/cygwin.h> +#include <wchar.h> #endif #include "ruby/ruby.h" @@ -67,6 +68,10 @@ int flock(int, int); #include <fcntl.h> #endif +#if defined(HAVE_SYS_TIME_H) +#include <sys/time.h> +#endif + #if !defined HAVE_LSTAT && !defined lstat #define lstat stat #endif @@ -138,8 +143,10 @@ file_path_convert(VALUE name) if (rb_default_internal_encoding() != NULL && rb_usascii_encoding() != fname_encoding && rb_ascii8bit_encoding() != fname_encoding - && (fs_encoding = rb_filesystem_encoding()) != fname_encoding) { + && (fs_encoding = rb_filesystem_encoding()) != fname_encoding + && !rb_enc_str_asciionly_p(name)) { /* Don't call rb_filesystem_encoding() before US-ASCII and ASCII-8BIT */ + /* fs_encoding should be ascii compatible */ name = rb_str_conv_enc(name, fname_encoding, fs_encoding); } #endif @@ -174,6 +181,9 @@ rb_get_path_check(VALUE obj, int level) rb_raise(rb_eEncCompatError, "path name must be ASCII-compatible (%s): %s", rb_enc_name(enc), RSTRING_PTR(tmp)); } + + StringValueCStr(tmp); + return rb_str_new4(tmp); } @@ -2425,6 +2435,8 @@ rb_file_s_symlink(VALUE klass, VALUE from, VALUE to) #endif #ifdef HAVE_READLINK +static VALUE rb_readlink(VALUE path); + /* * call-seq: * File.readlink(link_name) -> file_name @@ -2439,6 +2451,12 @@ rb_file_s_symlink(VALUE klass, VALUE from, VALUE to) static VALUE rb_file_s_readlink(VALUE klass, VALUE path) { + return rb_readlink(path); +} + +static VALUE +rb_readlink(VALUE path) +{ char *buf; int size = 100; ssize_t rv; @@ -2604,9 +2622,8 @@ static const char file_alt_separator[] = {FILE_ALT_SEPARATOR, '\0'}; #define istrailinggarbage(x) 0 #endif -#ifndef CharNext /* defined as CharNext[AW] on Windows. */ -# define CharNext(p) ((p) + 1) -#endif +#define Next(p, e, enc) ((p) + rb_enc_mbclen((p), (e), (enc))) +#define Inc(p, e, enc) ((p) = Next((p), (e), (enc))) #if defined(DOSISH_UNC) #define has_unc(buf) (isdirsep((buf)[0]) && isdirsep((buf)[1])) @@ -2668,40 +2685,40 @@ not_same_drive(VALUE path, int drive) #endif static inline char * -skiproot(const char *path) +skiproot(const char *path, const char *end, rb_encoding *enc) { #ifdef DOSISH_DRIVE_LETTER - if (has_drive_letter(path)) path += 2; + if (path + 2 <= end && has_drive_letter(path)) path += 2; #endif - while (isdirsep(*path)) path++; + while (path < end && isdirsep(*path)) path++; return (char *)path; } -#define nextdirsep rb_path_next +#define nextdirsep rb_enc_path_next char * -rb_path_next(const char *s) +rb_enc_path_next(const char *s, const char *e, rb_encoding *enc) { - while (*s && !isdirsep(*s)) { - s = CharNext(s); + while (s < e && !isdirsep(*s)) { + Inc(s, e, enc); } return (char *)s; } #if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER) -#define skipprefix rb_path_skip_prefix +#define skipprefix rb_enc_path_skip_prefix #else -#define skipprefix(path) (path) +#define skipprefix(path, end, enc) (path) #endif char * -rb_path_skip_prefix(const char *path) +rb_enc_path_skip_prefix(const char *path, const char *end, rb_encoding *enc) { #if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER) #ifdef DOSISH_UNC - if (isdirsep(path[0]) && isdirsep(path[1])) { + if (path + 2 <= end && isdirsep(path[0]) && isdirsep(path[1])) { path += 2; - while (isdirsep(*path)) path++; - if (*(path = nextdirsep(path)) && path[1] && !isdirsep(path[1])) - path = nextdirsep(path + 1); + while (path < end && isdirsep(*path)) path++; + if ((path = rb_enc_path_next(path, end, enc)) < end && path[0] && path[1] && !isdirsep(path[1])) + path = rb_enc_path_next(path + 1, end, enc); return (char *)path; } #endif @@ -2714,78 +2731,78 @@ rb_path_skip_prefix(const char *path) } static inline char * -skipprefixroot(const char *path) +skipprefixroot(const char *path, const char *end, rb_encoding *enc) { #if defined(DOSISH_UNC) || defined(DOSISH_DRIVE_LETTER) - char *p = skipprefix(path); + char *p = skipprefix(path, end, enc); while (isdirsep(*p)) p++; return p; #else - return skiproot(path); + return skiproot(path, end, enc); #endif } -#define strrdirsep rb_path_last_separator +#define strrdirsep rb_enc_path_last_separator char * -rb_path_last_separator(const char *path) +rb_enc_path_last_separator(const char *path, const char *end, rb_encoding *enc) { char *last = NULL; - while (*path) { + while (path < end) { if (isdirsep(*path)) { const char *tmp = path++; - while (isdirsep(*path)) path++; - if (!*path) break; + while (path < end && isdirsep(*path)) path++; + if (path >= end) break; last = (char *)tmp; } else { - path = CharNext(path); + Inc(path, end, enc); } } return last; } static char * -chompdirsep(const char *path) +chompdirsep(const char *path, const char *end, rb_encoding *enc) { - while (*path) { + while (path < end) { if (isdirsep(*path)) { const char *last = path++; - while (isdirsep(*path)) path++; - if (!*path) return (char *)last; + while (path < end && isdirsep(*path)) path++; + if (path >= end) return (char *)last; } else { - path = CharNext(path); + Inc(path, end, enc); } } return (char *)path; } char * -rb_path_end(const char *path) +rb_enc_path_end(const char *path, const char *end, rb_encoding *enc) { - if (isdirsep(*path)) path++; - return chompdirsep(path); + if (path < end && isdirsep(*path)) path++; + return chompdirsep(path, end, enc); } #if USE_NTFS static char * -ntfs_tail(const char *path) +ntfs_tail(const char *path, const char *end, rb_encoding *enc) { - while (*path == '.') path++; - while (*path && *path != ':') { + while (path < end && *path == '.') path++; + while (path < end && *path != ':') { if (istrailinggarbage(*path)) { const char *last = path++; - while (istrailinggarbage(*path)) path++; - if (!*path || *path == ':') return (char *)last; + while (path < end && istrailinggarbage(*path)) path++; + if (path >= end || *path == ':') return (char *)last; } else if (isdirsep(*path)) { const char *last = path++; - while (isdirsep(*path)) path++; - if (!*path) return (char *)last; + while (path < end && isdirsep(*path)) path++; + if (path >= end) return (char *)last; if (*path == ':') path++; } else { - path = CharNext(path); + Inc(path, end, enc); } } return (char *)path; @@ -2814,9 +2831,10 @@ rb_home_dir(const char *user, VALUE result) const char *dir; char *buf; #if defined DOSISH || defined __CYGWIN__ - char *p; + char *p, *bend; #endif long dirlen; + rb_encoding *enc; if (!user || !*user) { if (!(dir = getenv("HOME"))) { @@ -2835,32 +2853,55 @@ rb_home_dir(const char *user, VALUE result) } dirlen = strlen(pwPtr->pw_dir); rb_str_resize(result, dirlen); - strcpy(buf = RSTRING_PTR(result), pwPtr->pw_dir); + memcpy(buf = RSTRING_PTR(result), pwPtr->pw_dir, dirlen + 1); endpwent(); #else return Qnil; #endif } + enc = rb_filesystem_encoding(); + rb_enc_associate(result, enc); #if defined DOSISH || defined __CYGWIN__ - for (p = buf; *p; p = CharNext(p)) { + for (bend = (p = buf) + dirlen; p < bend; Inc(p, bend, enc)) { if (*p == '\\') { *p = '/'; } } #endif - rb_enc_associate_index(result, rb_filesystem_encindex()); return result; } -static VALUE -file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) +#ifndef _WIN32 +static char * +append_fspath(VALUE result, VALUE fname, char *dir, rb_encoding **enc, rb_encoding *fsenc) { - const char *s, *b; + char *buf, *cwdp = dir; + VALUE dirname = Qnil; + size_t dirlen = strlen(dir), buflen = rb_str_capacity(result); + + *enc = fsenc; + do {buflen *= 2;} while (dirlen > buflen); + rb_str_resize(result, buflen); + buf = RSTRING_PTR(result); + memcpy(buf, cwdp, dirlen); + xfree(dir); + if (!NIL_P(dirname)) rb_str_resize(dirname, 0); + rb_enc_associate(result, *enc); + return buf + dirlen; +} + +VALUE +rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_name, VALUE result) +{ + const char *s, *b, *fend; char *buf, *p, *pend, *root; - size_t buflen, dirlen, bdiff; + size_t buflen, bdiff; int tainted; + rb_encoding *enc, *fsenc = rb_filesystem_encoding(); s = StringValuePtr(fname); + fend = s + RSTRING_LEN(fname); + enc = rb_enc_get(fname); BUFINIT(); tainted = OBJ_TAINTED(fname); @@ -2874,7 +2915,7 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) if (*++s) ++s; } else { - s = nextdirsep(b = s); + s = nextdirsep(b = s, fend, enc); userlen = s - b; BUFCHECK(bdiff + userlen >= buflen); memcpy(p, b, userlen); @@ -2912,7 +2953,7 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) /* specified drive, but not full path */ int same = 0; if (!NIL_P(dname) && !not_same_drive(dname, s[0])) { - file_expand_path(dname, Qnil, abs_mode, result); + rb_file_expand_path_internal(dname, Qnil, abs_mode, long_name, result); BUFINIT(); if (has_drive_letter(p) && TOLOWER(p[0]) == TOLOWER(s[0])) { /* ok, same drive */ @@ -2920,47 +2961,42 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) } } if (!same) { - char *dir = getcwdofdrv(*s); - + char *e = append_fspath(result, fname, getcwdofdrv(*s), &enc, fsenc); tainted = 1; - dirlen = strlen(dir); - BUFCHECK(dirlen > buflen); - strcpy(buf, dir); - xfree(dir); - rb_enc_associate_index(result, rb_filesystem_encindex()); + BUFINIT(); + p = e; } - else - rb_enc_associate(result, rb_enc_check(result, fname)); - p = chompdirsep(skiproot(buf)); + else { + rb_enc_associate(result, enc = rb_enc_check(result, fname)); + p = pend; + } + p = chompdirsep(skiproot(buf, p, enc), p, enc); s += 2; } } #endif else if (!rb_is_absolute_path(s)) { if (!NIL_P(dname)) { - file_expand_path(dname, Qnil, abs_mode, result); - BUFINIT(); + rb_file_expand_path_internal(dname, Qnil, abs_mode, long_name, result); rb_enc_associate(result, rb_enc_check(result, fname)); + BUFINIT(); + p = pend; } else { - char *dir = my_getcwd(); - + char *e = append_fspath(result, fname, my_getcwd(), &enc, fsenc); tainted = 1; - dirlen = strlen(dir); - BUFCHECK(dirlen > buflen); - strcpy(buf, dir); - xfree(dir); - rb_enc_associate_index(result, rb_filesystem_encindex()); + BUFINIT(); + p = e; } #if defined DOSISH || defined __CYGWIN__ if (isdirsep(*s)) { /* specified full path, but not drive letter nor UNC */ /* we need to get the drive letter or UNC share name */ - p = skipprefix(buf); + p = skipprefix(buf, p, enc); } else #endif - p = chompdirsep(skiproot(buf)); + p = chompdirsep(skiproot(buf, p, enc), p, enc); } else { size_t len; @@ -2984,7 +3020,7 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) rb_str_set_len(result, p-buf+1); BUFCHECK(bdiff + 1 >= buflen); p[1] = 0; - root = skipprefix(buf); + root = skipprefix(buf, p+1, enc); b = s; while (*s) { @@ -3000,7 +3036,7 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) /* We must go back to the parent */ char *n; *p = '\0'; - if (!(n = strrdirsep(root))) { + if (!(n = strrdirsep(root, p, enc))) { *p = '/'; } else { @@ -3030,7 +3066,7 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) --s; case ' ': { const char *e = s; - while (istrailinggarbage(*s)) s++; + while (s < fend && istrailinggarbage(*s)) s++; if (!*s) { s = e; goto endpath; @@ -3055,7 +3091,7 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) b = ++s; break; default: - s = CharNext(s); + Inc(s, fend, enc); break; } } @@ -3080,14 +3116,18 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) BUFCHECK(bdiff + (s-b) >= buflen); memcpy(++p, b, s-b); p += s-b; + rb_str_set_len(result, p-buf); } - if (p == skiproot(buf) - 1) p++; + if (p == skiproot(buf, p + !!*p, enc) - 1) p++; #if USE_NTFS *p = '\0'; - if ((s = strrdirsep(b = buf)) != 0 && !strpbrk(s, "*?")) { + if ((s = strrdirsep(b = buf, p, enc)) != 0 && !strpbrk(s, "*?")) { + VALUE tmp, v; size_t len; - WIN32_FIND_DATA wfd; + rb_encoding *enc; + WCHAR *wstr; + WIN32_FIND_DATAW wfd; HANDLE h; #ifdef __CYGWIN__ #ifdef HAVE_CYGWIN_CONV_PATH @@ -3137,21 +3177,43 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) } *p = '/'; #endif - h = FindFirstFile(b, &wfd); + rb_str_set_len(result, p - buf + strlen(p)); + enc = rb_enc_get(result); + tmp = result; + if (enc != rb_utf8_encoding() && rb_enc_str_coderange(result) != ENC_CODERANGE_7BIT) { + tmp = rb_str_encode_ospath(result); + } + len = MultiByteToWideChar(CP_UTF8, 0, RSTRING_PTR(tmp), -1, NULL, 0); + wstr = ALLOCV_N(WCHAR, v, len); + MultiByteToWideChar(CP_UTF8, 0, RSTRING_PTR(tmp), -1, wstr, len); + if (tmp != result) rb_str_resize(tmp, 0); + h = FindFirstFileW(wstr, &wfd); + ALLOCV_END(v); if (h != INVALID_HANDLE_VALUE) { + size_t wlen; FindClose(h); - len = strlen(wfd.cFileName); + len = lstrlenW(wfd.cFileName); #ifdef __CYGWIN__ if (lnk_added && len > 4 && - STRCASECMP(wfd.cFileName + len - 4, ".lnk") == 0) { - wfd.cFileName[len -= 4] = '\0'; + wcscasecmp(wfd.cFileName + len - 4, L".lnk") == 0) { + wfd.cFileName[len -= 4] = L'\0'; } #else p = (char *)s; #endif ++p; + wlen = (int)len; + len = WideCharToMultiByte(CP_UTF8, 0, wfd.cFileName, wlen, NULL, 0, NULL, NULL); BUFCHECK(bdiff + len >= buflen); - memcpy(p, wfd.cFileName, len + 1); + WideCharToMultiByte(CP_UTF8, 0, wfd.cFileName, wlen, p, len + 1, NULL, NULL); + if (tmp != result) { + rb_str_buf_cat(tmp, p, len); + tmp = rb_str_encode(tmp, rb_enc_from_encoding(enc), 0, Qnil); + len = RSTRING_LEN(tmp); + BUFCHECK(bdiff + len >= buflen); + memcpy(p, RSTRING_PTR(tmp), len); + rb_str_resize(tmp, 0); + } p += len; } #ifdef __CYGWIN__ @@ -3168,8 +3230,9 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) ENC_CODERANGE_CLEAR(result); return result; } +#endif /* _WIN32 */ -#define EXPAND_PATH_BUFFER() rb_usascii_str_new(0, MAXPATHLEN + 2) +#define EXPAND_PATH_BUFFER() rb_enc_str_new(0, MAXPATHLEN + 2, rb_filesystem_encoding()) #define check_expand_path_args(fname, dname) \ (((fname) = rb_get_path(fname)), \ @@ -3178,14 +3241,21 @@ file_expand_path(VALUE fname, VALUE dname, int abs_mode, VALUE result) static VALUE file_expand_path_1(VALUE fname) { - return file_expand_path(fname, Qnil, 0, EXPAND_PATH_BUFFER()); + return rb_file_expand_path_internal(fname, Qnil, 0, 0, EXPAND_PATH_BUFFER()); } VALUE rb_file_expand_path(VALUE fname, VALUE dname) { check_expand_path_args(fname, dname); - return file_expand_path(fname, dname, 0, EXPAND_PATH_BUFFER()); + return rb_file_expand_path_internal(fname, dname, 0, 1, EXPAND_PATH_BUFFER()); +} + +VALUE +rb_file_expand_path_fast(VALUE fname, VALUE dname) +{ + check_expand_path_args(fname, dname); + return rb_file_expand_path_internal(fname, dname, 0, 0, EXPAND_PATH_BUFFER()); } /* @@ -3222,7 +3292,7 @@ VALUE rb_file_absolute_path(VALUE fname, VALUE dname) { check_expand_path_args(fname, dname); - return file_expand_path(fname, dname, 1, EXPAND_PATH_BUFFER()); + return rb_file_expand_path_internal(fname, dname, 1, 1, EXPAND_PATH_BUFFER()); } /* @@ -3252,23 +3322,27 @@ rb_file_s_absolute_path(int argc, VALUE *argv) } static void -realpath_rec(long *prefixlenp, VALUE *resolvedp, char *unresolved, VALUE loopcheck, int strict, int last) +realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved, VALUE loopcheck, int strict, int last) { + const char *pend = unresolved + strlen(unresolved); + rb_encoding *enc = rb_enc_get(*resolvedp); ID resolving; CONST_ID(resolving, "resolving"); - while (*unresolved) { - char *testname = unresolved; - char *unresolved_firstsep = rb_path_next(unresolved); - long testnamelen = unresolved_firstsep - unresolved; - char *unresolved_nextname = unresolved_firstsep; - while (isdirsep(*unresolved_nextname)) unresolved_nextname++; + while (unresolved < pend) { + const char *testname = unresolved; + const char *unresolved_firstsep = rb_enc_path_next(unresolved, pend, enc); + long testnamelen = unresolved_firstsep - unresolved; + const char *unresolved_nextname = unresolved_firstsep; + while (unresolved_nextname < pend && isdirsep(*unresolved_nextname)) + unresolved_nextname++; unresolved = unresolved_nextname; if (testnamelen == 1 && testname[0] == '.') { } else if (testnamelen == 2 && testname[0] == '.' && testname[1] == '.') { if (*prefixlenp < RSTRING_LEN(*resolvedp)) { - char *resolved_names = RSTRING_PTR(*resolvedp) + *prefixlenp; - char *lastsep = rb_path_last_separator(resolved_names); + const char *resolved_str = RSTRING_PTR(*resolvedp); + const char *resolved_names = resolved_str + *prefixlenp; + const char *lastsep = strrdirsep(resolved_names, resolved_str + RSTRING_LEN(*resolvedp), enc); long len = lastsep ? lastsep - resolved_names : 0; rb_str_resize(*resolvedp, *prefixlenp + len); } @@ -3307,23 +3381,27 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, char *unresolved, VALUE loopche } #ifdef HAVE_READLINK if (S_ISLNK(sbuf.st_mode)) { - volatile VALUE link; - char *link_prefix, *link_names; + VALUE link; + volatile VALUE link_orig = Qnil; + const char *link_prefix, *link_names; long link_prefixlen; rb_hash_aset(loopcheck, testpath, ID2SYM(resolving)); - link = rb_file_s_readlink(rb_cFile, testpath); + link = rb_readlink(testpath); link_prefix = RSTRING_PTR(link); - link_names = skipprefixroot(link_prefix); - link_prefixlen = link_names - link_prefix; - if (link_prefixlen == 0) { - realpath_rec(prefixlenp, resolvedp, link_names, loopcheck, strict, *unresolved_firstsep == '\0'); - } - else { - *resolvedp = rb_str_new(link_prefix, link_prefixlen); - *prefixlenp = link_prefixlen; - realpath_rec(prefixlenp, resolvedp, link_names, loopcheck, strict, *unresolved_firstsep == '\0'); - } - rb_hash_aset(loopcheck, testpath, rb_str_dup_frozen(*resolvedp)); + link_names = skipprefixroot(link_prefix, link_prefix + RSTRING_LEN(link), rb_enc_get(link)); + link_prefixlen = link_names - link_prefix; + if (link_prefixlen > 0) { + rb_encoding *enc, *linkenc = rb_enc_get(link); + link_orig = link; + link = rb_str_subseq(link, 0, link_prefixlen); + enc = rb_enc_check(*resolvedp, link); + if (enc != linkenc) link = rb_str_conv_enc(link, linkenc, enc); + *resolvedp = link; + *prefixlenp = link_prefixlen; + } + realpath_rec(prefixlenp, resolvedp, link_names, loopcheck, strict, *unresolved_firstsep == '\0'); + RB_GC_GUARD(link_orig); + rb_hash_aset(loopcheck, testpath, rb_str_dup_frozen(*resolvedp)); } else #endif @@ -3346,8 +3424,10 @@ rb_realpath_internal(VALUE basedir, VALUE path, int strict) VALUE loopcheck; volatile VALUE curdir = Qnil; + rb_encoding *enc; char *path_names = NULL, *basedir_names = NULL, *curdir_names = NULL; - char *ptr, *prefixptr = NULL; + char *ptr, *prefixptr = NULL, *pend; + long len; rb_secure(2); @@ -3359,34 +3439,33 @@ rb_realpath_internal(VALUE basedir, VALUE path, int strict) basedir = rb_str_dup_frozen(basedir); } - ptr = RSTRING_PTR(unresolved_path); - path_names = skipprefixroot(ptr); + RSTRING_GETMEM(unresolved_path, ptr, len); + path_names = skipprefixroot(ptr, ptr + len, rb_enc_get(unresolved_path)); if (ptr != path_names) { - resolved = rb_enc_str_new(ptr, path_names - ptr, - rb_enc_get(unresolved_path)); + resolved = rb_str_subseq(unresolved_path, 0, path_names - ptr); goto root_found; } if (!NIL_P(basedir)) { - ptr = RSTRING_PTR(basedir); - basedir_names = skipprefixroot(ptr); + RSTRING_GETMEM(basedir, ptr, len); + basedir_names = skipprefixroot(ptr, ptr + len, rb_enc_get(basedir)); if (ptr != basedir_names) { - resolved = rb_enc_str_new(ptr, basedir_names - ptr, - rb_enc_get(basedir)); - goto root_found; + resolved = rb_str_subseq(basedir, 0, basedir_names - ptr); + goto root_found; } } curdir = rb_dir_getwd(); - ptr = RSTRING_PTR(curdir); - curdir_names = skipprefixroot(ptr); - resolved = rb_enc_str_new(ptr, curdir_names - ptr, rb_enc_get(curdir)); + RSTRING_GETMEM(curdir, ptr, len); + curdir_names = skipprefixroot(ptr, ptr + len, rb_enc_get(curdir)); + resolved = rb_str_subseq(curdir, 0, curdir_names - ptr); root_found: - prefixptr = RSTRING_PTR(resolved); - prefixlen = RSTRING_LEN(resolved); - ptr = chompdirsep(prefixptr); - if (*ptr) { + RSTRING_GETMEM(resolved, prefixptr, prefixlen); + pend = prefixptr + prefixlen; + enc = rb_enc_get(resolved); + ptr = chompdirsep(prefixptr, pend, enc); + if (ptr < pend) { prefixlen = ++ptr - prefixptr; rb_str_set_len(resolved, prefixlen); } @@ -3395,7 +3474,7 @@ rb_realpath_internal(VALUE basedir, VALUE path, int strict) if (*prefixptr == FILE_ALT_SEPARATOR) { *prefixptr = '/'; } - prefixptr = CharNext(prefixptr); + Inc(prefixptr, pend, enc); } #endif @@ -3452,44 +3531,52 @@ rb_file_s_realdirpath(int argc, VALUE *argv, VALUE klass) } static size_t -rmext(const char *p, long l0, long l1, const char *e) +rmext(const char *p, long l0, long l1, const char *e, long l2, rb_encoding *enc) { - long l2; + int len1, len2; + unsigned int c; + const char *s, *last; - if (!e) return 0; + if (!e || !l2) return 0; - l2 = strlen(e); - if (l2 == 2 && e[1] == '*') { - unsigned char c = *e; + c = rb_enc_codepoint_len(e, e + l2, &len1, enc); + if (rb_enc_ascget(e + len1, e + l2, &len2, enc) == '*' && len1 + len2 == l2) { + if (c == '.') return l0; + s = p; e = p + l1; - do { - if (e <= p + l0) return 0; - } while (*--e != c); - return e - p; + last = e; + while (s < e) { + if (rb_enc_codepoint_len(s, e, &len1, enc) == c) last = s; + s += len1; + } + return last - p; } if (l1 < l2) return l1; + s = p+l1-l2; + if (rb_enc_left_char_head(p, s, p+l1, enc) != s) return 0; #if CASEFOLD_FILESYSTEM #define fncomp strncasecmp #else #define fncomp strncmp #endif - if (fncomp(p+l1-l2, e, l2) == 0) { + if (fncomp(s, e, l2) == 0) { return l1-l2; } return 0; } const char * -ruby_find_basename(const char *name, long *baselen, long *alllen) +ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc) { - const char *p, *q, *e; + const char *p, *q, *e, *end; #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC const char *root; #endif long f = 0, n = -1; - name = skipprefix(name); + end = name + *alllen; + name = skipprefix(name, end, enc); #if defined DOSISH_DRIVE_LETTER || defined DOSISH_UNC root = name; #endif @@ -3516,19 +3603,19 @@ ruby_find_basename(const char *name, long *baselen, long *alllen) #endif } else { - if (!(p = strrdirsep(name))) { + if (!(p = strrdirsep(name, end, enc))) { p = name; } else { while (isdirsep(*p)) p++; /* skip last / */ } #if USE_NTFS - n = ntfs_tail(p) - p; + n = ntfs_tail(p, end, enc) - p; #else - n = chompdirsep(p) - p; + n = chompdirsep(p, end, enc) - p; #endif for (q = p; q - p < n && *q == '.'; q++); - for (e = 0; q - p < n; q = CharNext(q)) { + for (e = 0; q - p < n; Inc(q, end, enc)) { if (*q == '.') e = q; } if (e) f = e - p; @@ -3562,6 +3649,7 @@ rb_file_s_basename(int argc, VALUE *argv) VALUE fname, fext, basename; const char *name, *p; long f, n; + rb_encoding *enc; if (rb_scan_args(argc, argv, "11", &fname, &fext) == 2) { rb_encoding *enc; @@ -3572,15 +3660,29 @@ rb_file_s_basename(int argc, VALUE *argv) } } FilePathStringValue(fname); - if (!NIL_P(fext)) rb_enc_check(fname, fext); - if (RSTRING_LEN(fname) == 0 || !*(name = RSTRING_PTR(fname))) + if (!NIL_P(fext)) enc = rb_enc_check(fname, fext); + else enc = rb_enc_get(fname); + if ((n = RSTRING_LEN(fname)) == 0 || !*(name = RSTRING_PTR(fname))) return rb_str_new_shared(fname); - p = ruby_find_basename(name, &f, &n); + p = ruby_enc_find_basename(name, &f, &n, enc); if (n >= 0) { - if (NIL_P(fext) || !(f = rmext(p, f, n, StringValueCStr(fext)))) { + if (NIL_P(fext)) { f = n; } + else { + rb_encoding *fenc = rb_enc_get(fext); + const char *fp; + if (enc != fenc && + rb_enc_str_coderange(fext) != ENC_CODERANGE_7BIT) { + fext = rb_str_conv_enc(fext, fenc, enc); + } + fp = StringValueCStr(fext); + if (!(f = rmext(p, f, n, fp, RSTRING_LEN(fext), enc))) { + f = n; + } + RB_GC_GUARD(fext); + } if (f == RSTRING_LEN(fname)) return rb_str_new_shared(fname); } @@ -3611,20 +3713,23 @@ rb_file_s_dirname(VALUE klass, VALUE fname) VALUE rb_file_dirname(VALUE fname) { - const char *name, *root, *p; + const char *name, *root, *p, *end; VALUE dirname; + rb_encoding *enc; FilePathStringValue(fname); name = StringValueCStr(fname); - root = skiproot(name); + end = name + RSTRING_LEN(fname); + enc = rb_enc_get(fname); + root = skiproot(name, end, enc); #ifdef DOSISH_UNC if (root > name + 1 && isdirsep(*name)) - root = skipprefix(name = root - 2); + root = skipprefix(name = root - 2, end, enc); #else if (root > name + 1) name = root - 1; #endif - p = strrdirsep(root); + p = strrdirsep(root, end, enc); if (!p) { p = root; } @@ -3632,7 +3737,7 @@ rb_file_dirname(VALUE fname) return rb_usascii_str_new2("."); #ifdef DOSISH_DRIVE_LETTER if (has_drive_letter(name) && isdirsep(*(name + 2))) { - const char *top = skiproot(name + 2); + const char *top = skiproot(name + 2, end, enc); dirname = rb_str_new(name, 3); rb_str_cat(dirname, top, p - top); } @@ -3661,11 +3766,11 @@ rb_file_dirname(VALUE fname) * */ const char * -ruby_find_extname(const char *name, long *len) +ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc) { - const char *p, *e; + const char *p, *e, *end = name + (len ? *len : (long)strlen(name)); - p = strrdirsep(name); /* get the last path component */ + p = strrdirsep(name, end, enc); /* get the last path component */ if (!p) p = name; else @@ -3698,7 +3803,7 @@ ruby_find_extname(const char *name, long *len) #endif else if (isdirsep(*p)) break; - p = CharNext(p); + Inc(p, end, enc); } if (len) { @@ -3736,11 +3841,11 @@ rb_file_s_extname(VALUE klass, VALUE fname) FilePathStringValue(fname); name = StringValueCStr(fname); - e = ruby_find_extname(name, &len); + len = RSTRING_LEN(fname); + e = ruby_enc_find_extname(name, &len, rb_enc_get(fname)); if (len <= 1) return rb_str_new(0, 0); - extname = rb_str_new(e, len); /* keep the dot, too! */ - rb_enc_copy(extname, fname); + extname = rb_str_subseq(fname, e - name, len); /* keep the dot, too! */ OBJ_INFECT(extname, fname); return extname; } @@ -3803,8 +3908,9 @@ rb_file_join(VALUE ary, VALUE sep) len = 1; for (i=0; i<RARRAY_LEN(ary); i++) { - if (TYPE(RARRAY_PTR(ary)[i]) == T_STRING) { - len += RSTRING_LEN(RARRAY_PTR(ary)[i]); + tmp = RARRAY_PTR(ary)[i]; + if (RB_TYPE_P(tmp, T_STRING)) { + len += RSTRING_LEN(tmp); } else { len += 10; @@ -3837,11 +3943,12 @@ rb_file_join(VALUE ary, VALUE sep) FilePathStringValue(tmp); } name = StringValueCStr(result); + len = RSTRING_LEN(result); if (i == 0) { rb_enc_copy(result, tmp); } else if (!NIL_P(sep)) { - tail = chompdirsep(name); + tail = chompdirsep(name, name + len, rb_enc_get(result)); if (RSTRING_PTR(tmp) && isdirsep(RSTRING_PTR(tmp)[0])) { rb_str_set_len(result, tail - name); } @@ -4977,6 +5084,8 @@ path_check_0(VALUE path, int execpath) { struct stat st; const char *p0 = StringValueCStr(path); + const char *e0; + rb_encoding *enc; char *p = 0, *s; if (!rb_is_absolute_path(p0)) { @@ -4991,6 +5100,8 @@ path_check_0(VALUE path, int execpath) path = newpath; p0 = RSTRING_PTR(path); } + e0 = p0 + RSTRING_LEN(path); + enc = rb_enc_get(path); for (;;) { #ifndef S_IWOTH # define S_IWOTH 002 @@ -5007,10 +5118,11 @@ path_check_0(VALUE path, int execpath) RB_GC_GUARD(path); return 0; } - s = strrdirsep(p0); + s = strrdirsep(p0, e0, enc); if (p) *p = '/'; if (!s || s == p0) return 1; p = s; + e0 = p; *p = '\0'; } } @@ -5049,8 +5161,9 @@ rb_path_check(const char *path) return 1; } -static int -file_load_ok(const char *path) +#ifndef _WIN32 +int +rb_file_load_ok(const char *path) { int ret = 1; int fd = open(path, O_RDONLY); @@ -5067,12 +5180,7 @@ file_load_ok(const char *path) (void)close(fd); return ret; } - -int -rb_file_load_ok(const char *path) -{ - return file_load_ok(path); -} +#endif static int is_explicit_relative(const char *path) @@ -5124,7 +5232,7 @@ rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int safe_level) fnlen = RSTRING_LEN(fname); for (i=0; ext[i]; i++) { rb_str_cat2(fname, ext[i]); - if (file_load_ok(RSTRING_PTR(fname))) { + if (rb_file_load_ok(RSTRING_PTR(fname))) { *filep = copy_path_class(fname, *filep); return (int)(i+1); } @@ -5144,6 +5252,7 @@ rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int safe_level) RBASIC(fname)->klass = 0; fnlen = RSTRING_LEN(fname); tmp = rb_str_tmp_new(MAXPATHLEN + 2); + rb_enc_associate_index(tmp, rb_usascii_encindex()); for (j=0; ext[j]; j++) { rb_str_cat2(fname, ext[j]); for (i = 0; i < RARRAY_LEN(load_path); i++) { @@ -5151,8 +5260,8 @@ rb_find_file_ext_safe(VALUE *filep, const char *const *ext, int safe_level) RB_GC_GUARD(str) = rb_get_path_check(str, safe_level); if (RSTRING_LEN(str) == 0) continue; - file_expand_path(fname, str, 0, tmp); - if (file_load_ok(RSTRING_PTR(tmp))) { + rb_file_expand_path_internal(fname, str, 0, 0, tmp); + if (rb_file_load_ok(RSTRING_PTR(tmp))) { *filep = copy_path_class(tmp, *filep); return (int)(j+1); } @@ -5191,7 +5300,7 @@ rb_find_file_safe(VALUE path, int safe_level) if (safe_level >= 1 && !fpath_check(path)) { rb_raise(rb_eSecurityError, "loading from unsafe path %s", f); } - if (!file_load_ok(f)) return 0; + if (!rb_file_load_ok(f)) return 0; if (!expanded) path = copy_path_class(file_expand_path_1(path), path); return path; @@ -5206,13 +5315,14 @@ rb_find_file_safe(VALUE path, int safe_level) long i; tmp = rb_str_tmp_new(MAXPATHLEN + 2); + rb_enc_associate_index(tmp, rb_usascii_encindex()); for (i = 0; i < RARRAY_LEN(load_path); i++) { VALUE str = RARRAY_PTR(load_path)[i]; RB_GC_GUARD(str) = rb_get_path_check(str, safe_level); if (RSTRING_LEN(str) > 0) { - file_expand_path(path, str, 0, tmp); + rb_file_expand_path_internal(path, str, 0, 0, tmp); f = RSTRING_PTR(tmp); - if (file_load_ok(f)) goto found; + if (rb_file_load_ok(f)) goto found; } } return 0; @@ -5445,4 +5555,8 @@ Init_File(void) rb_define_method(rb_cStat, "setuid?", rb_stat_suid, 0); rb_define_method(rb_cStat, "setgid?", rb_stat_sgid, 0); rb_define_method(rb_cStat, "sticky?", rb_stat_sticky, 0); + +#ifdef _WIN32 + rb_w32_init_file(); +#endif } @@ -2,7 +2,7 @@ gc.c - - $Author: naruse $ + $Author: usa $ created at: Tue Oct 5 09:44:46 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -21,9 +21,11 @@ #include "internal.h" #include "gc.h" #include "constant.h" +#include "ruby_atomic.h" #include <stdio.h> #include <setjmp.h> #include <sys/types.h> +#include <assert.h> #ifdef HAVE_SYS_TIME_H #include <sys/time.h> @@ -98,7 +100,16 @@ ruby_gc_params_t initial_params = { #define nomem_error GET_VM()->special_exceptions[ruby_error_nomemory] -#define MARK_STACK_MAX 1024 +#if SIZEOF_LONG == SIZEOF_VOIDP +# define nonspecial_obj_id(obj) (VALUE)((SIGNED_VALUE)(obj)|FIXNUM_FLAG) +# define obj_id_to_ref(objid) ((objid) ^ FIXNUM_FLAG) /* unset FIXNUM_FLAG */ +#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP +# define nonspecial_obj_id(obj) LL2NUM((SIGNED_VALUE)(obj) / 2) +# define obj_id_to_ref(objid) (FIXNUM_P(objid) ? \ + ((objid) ^ FIXNUM_FLAG) : (NUM2PTR(objid) << 1)) +#else +# error not supported +#endif int ruby_gc_debug_indent = 0; @@ -319,6 +330,22 @@ struct gc_list { struct gc_list *next; }; +#define STACK_CHUNK_SIZE 500 + +typedef struct stack_chunk { + VALUE data[STACK_CHUNK_SIZE]; + struct stack_chunk *next; +} stack_chunk_t; + +typedef struct mark_stack { + stack_chunk_t *chunk; + stack_chunk_t *cache; + size_t index; + size_t limit; + size_t cache_size; + size_t unused_cache_size; +} mark_stack_t; + #define CALC_EXACT_MALLOC_SIZE 0 typedef struct rb_objspace { @@ -355,11 +382,7 @@ typedef struct rb_objspace { st_table *table; RVALUE *deferred; } final; - struct { - VALUE buffer[MARK_STACK_MAX]; - VALUE *ptr; - int overflow; - } markstack; + mark_stack_t mark_stack; struct { int run; gc_profile_record *record; @@ -394,9 +417,6 @@ int *ruby_initial_gc_stress_ptr = &rb_objspace.gc_stress; #define during_gc objspace->flags.during_gc #define finalizer_table objspace->final.table #define deferred_final_list objspace->final.deferred -#define mark_stack objspace->markstack.buffer -#define mark_stack_ptr objspace->markstack.ptr -#define mark_stack_overflow objspace->markstack.overflow #define global_List objspace->global_list #define ruby_gc_stress objspace->gc_stress #define initial_malloc_limit initial_params.initial_malloc_limit @@ -419,6 +439,7 @@ rb_objspace_alloc(void) #endif static void initial_expand_heap(rb_objspace_t *objspace); +static void init_mark_stack(mark_stack_t *stack); void rb_gc_set_params(void) @@ -465,6 +486,7 @@ rb_gc_set_params(void) static void gc_sweep(rb_objspace_t *); static void slot_sweep(rb_objspace_t *, struct heaps_slot *); static void rest_sweep(rb_objspace_t *); +static void free_stack_chunks(mark_stack_t *); void rb_objspace_free(rb_objspace_t *objspace) @@ -491,6 +513,7 @@ rb_objspace_free(rb_objspace_t *objspace) heaps_used = 0; heaps = 0; } + free_stack_chunks(&objspace->mark_stack); free(objspace); } #endif @@ -616,7 +639,7 @@ static VALUE gc_profile_enable_get(VALUE self) { rb_objspace_t *objspace = &rb_objspace; - return objspace->profile.run; + return objspace->profile.run ? Qtrue : Qfalse; } /* @@ -1100,6 +1123,7 @@ static void init_heap(rb_objspace_t *objspace) { add_heap_slots(objspace, HEAP_MIN_SLOTS / HEAP_OBJ_LIMIT); + init_mark_stack(&objspace->mark_stack); #ifdef USE_SIGALTSTACK { /* altstack of another threads are allocated in another place */ @@ -1296,8 +1320,136 @@ ruby_get_stack_grow_direction(volatile VALUE *addr) } #endif -#define GC_LEVEL_MAX 250 -#define STACKFRAME_FOR_GC_MARK (GC_LEVEL_MAX * GC_MARK_STACKFRAME_WORD) +/* Marking stack */ + +static void push_mark_stack(mark_stack_t *, VALUE); +static int pop_mark_stack(mark_stack_t *, VALUE *); +static void shrink_stack_chunk_cache(mark_stack_t *stack); + +static stack_chunk_t * +stack_chunk_alloc(void) +{ + stack_chunk_t *res; + + res = malloc(sizeof(stack_chunk_t)); + if (!res) + rb_memerror(); + + return res; +} + +static inline int +is_mark_stask_empty(mark_stack_t *stack) +{ + return stack->chunk == NULL; +} + +static void +add_stack_chunk_cache(mark_stack_t *stack, stack_chunk_t *chunk) +{ + chunk->next = stack->cache; + stack->cache = chunk; + stack->cache_size++; +} + +static void +shrink_stack_chunk_cache(mark_stack_t *stack) +{ + stack_chunk_t *chunk; + + if (stack->unused_cache_size > (stack->cache_size/2)) { + chunk = stack->cache; + stack->cache = stack->cache->next; + stack->cache_size--; + free(chunk); + } + stack->unused_cache_size = stack->cache_size; +} + +static void +push_mark_stack_chunk(mark_stack_t *stack) +{ + stack_chunk_t *next; + + if (stack->cache_size > 0) { + next = stack->cache; + stack->cache = stack->cache->next; + stack->cache_size--; + if (stack->unused_cache_size > stack->cache_size) + stack->unused_cache_size = stack->cache_size; + } + else { + next = stack_chunk_alloc(); + } + next->next = stack->chunk; + stack->chunk = next; + stack->index = 0; +} + +static void +pop_mark_stack_chunk(mark_stack_t *stack) +{ + stack_chunk_t *prev; + + prev = stack->chunk->next; + add_stack_chunk_cache(stack, stack->chunk); + stack->chunk = prev; + stack->index = stack->limit; +} + +#if defined(ENABLE_VM_OBJSPACE) && ENABLE_VM_OBJSPACE +static void +free_stack_chunks(mark_stack_t *stack) +{ + stack_chunk_t *chunk = stack->chunk; + stack_chunk_t *next = NULL; + + while (chunk != NULL) { + next = chunk->next; + free(chunk); + chunk = next; + } +} +#endif + +static void +push_mark_stack(mark_stack_t *stack, VALUE data) +{ + if (stack->index == stack->limit) { + push_mark_stack_chunk(stack); + } + stack->chunk->data[stack->index++] = data; +} + +static int +pop_mark_stack(mark_stack_t *stack, VALUE *data) +{ + if (is_mark_stask_empty(stack)) { + return FALSE; + } + if (stack->index == 1) { + *data = stack->chunk->data[--stack->index]; + pop_mark_stack_chunk(stack); + return TRUE; + } + *data = stack->chunk->data[--stack->index]; + return TRUE; +} + +static void +init_mark_stack(mark_stack_t *stack) +{ + int i; + + push_mark_stack_chunk(stack); + stack->limit = STACK_CHUNK_SIZE; + + for(i=0; i < 4; i++) { + add_stack_chunk_cache(stack, stack_chunk_alloc()); + } + stack->unused_cache_size = stack->cache_size; +} + size_t ruby_stack_length(VALUE **p) @@ -1308,6 +1460,7 @@ ruby_stack_length(VALUE **p) return STACK_LENGTH; } +#if !(defined(POSIX_SIGNAL) && defined(SIGSEGV) && defined(HAVE_SIGALTSTACK)) static int stack_check(int water_mark) { @@ -1323,6 +1476,7 @@ stack_check(int water_mark) #endif return ret; } +#endif #define STACKFRAME_FOR_CALL_CFUNC 512 @@ -1336,51 +1490,22 @@ ruby_stack_check(void) #endif } -static void -init_mark_stack(rb_objspace_t *objspace) -{ - mark_stack_overflow = 0; - mark_stack_ptr = mark_stack; -} - #define MARK_STACK_EMPTY (mark_stack_ptr == mark_stack) -static void gc_mark(rb_objspace_t *objspace, VALUE ptr, int lev); -static void gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev); - -static void -gc_mark_all(rb_objspace_t *objspace) -{ - RVALUE *p, *pend; - size_t i; - - init_mark_stack(objspace); - for (i = 0; i < heaps_used; i++) { - p = objspace->heap.sorted[i].start; pend = objspace->heap.sorted[i].end; - while (p < pend) { - if ((p->as.basic.flags & FL_MARK) && - (p->as.basic.flags != FL_MARK)) { - gc_mark_children(objspace, (VALUE)p, 0); - } - p++; - } - } -} +static void gc_mark(rb_objspace_t *objspace, VALUE ptr); +static void gc_mark_children(rb_objspace_t *objspace, VALUE ptr); static void -gc_mark_rest(rb_objspace_t *objspace) +gc_mark_stacked_objects(rb_objspace_t *objspace) { - VALUE tmp_arry[MARK_STACK_MAX]; - VALUE *p; + mark_stack_t *mstack = &objspace->mark_stack; + VALUE obj = 0; - p = (mark_stack_ptr - mark_stack) + tmp_arry; - MEMCPY(tmp_arry, mark_stack, VALUE, p - tmp_arry); - - init_mark_stack(objspace); - while (p != tmp_arry) { - p--; - gc_mark_children(objspace, *p, 0); + if (!mstack->index) return; + while (pop_mark_stack(mstack, &obj)) { + gc_mark_children(objspace, obj); } + shrink_stack_chunk_cache(mstack); } static inline int @@ -1419,7 +1544,7 @@ mark_locations_array(rb_objspace_t *objspace, register VALUE *x, register long n v = *x; VALGRIND_MAKE_MEM_DEFINED(&v, sizeof(v)); if (is_pointer_to_heap(objspace, (void *)v)) { - gc_mark(objspace, v, 0); + gc_mark(objspace, v); } x++; } @@ -1445,24 +1570,22 @@ rb_gc_mark_locations(VALUE *start, VALUE *end) struct mark_tbl_arg { rb_objspace_t *objspace; - int lev; }; static int mark_entry(ID key, VALUE value, st_data_t data) { struct mark_tbl_arg *arg = (void*)data; - gc_mark(arg->objspace, value, arg->lev); + gc_mark(arg->objspace, value); return ST_CONTINUE; } static void -mark_tbl(rb_objspace_t *objspace, st_table *tbl, int lev) +mark_tbl(rb_objspace_t *objspace, st_table *tbl) { struct mark_tbl_arg arg; if (!tbl || tbl->num_entries == 0) return; arg.objspace = objspace; - arg.lev = lev; st_foreach(tbl, mark_entry, (st_data_t)&arg); } @@ -1470,68 +1593,66 @@ static int mark_key(VALUE key, VALUE value, st_data_t data) { struct mark_tbl_arg *arg = (void*)data; - gc_mark(arg->objspace, key, arg->lev); + gc_mark(arg->objspace, key); return ST_CONTINUE; } static void -mark_set(rb_objspace_t *objspace, st_table *tbl, int lev) +mark_set(rb_objspace_t *objspace, st_table *tbl) { struct mark_tbl_arg arg; if (!tbl) return; arg.objspace = objspace; - arg.lev = lev; st_foreach(tbl, mark_key, (st_data_t)&arg); } void rb_mark_set(st_table *tbl) { - mark_set(&rb_objspace, tbl, 0); + mark_set(&rb_objspace, tbl); } static int mark_keyvalue(VALUE key, VALUE value, st_data_t data) { struct mark_tbl_arg *arg = (void*)data; - gc_mark(arg->objspace, key, arg->lev); - gc_mark(arg->objspace, value, arg->lev); + gc_mark(arg->objspace, key); + gc_mark(arg->objspace, value); return ST_CONTINUE; } static void -mark_hash(rb_objspace_t *objspace, st_table *tbl, int lev) +mark_hash(rb_objspace_t *objspace, st_table *tbl) { struct mark_tbl_arg arg; if (!tbl) return; arg.objspace = objspace; - arg.lev = lev; st_foreach(tbl, mark_keyvalue, (st_data_t)&arg); } void rb_mark_hash(st_table *tbl) { - mark_hash(&rb_objspace, tbl, 0); + mark_hash(&rb_objspace, tbl); } static void -mark_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me, int lev) +mark_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me) { const rb_method_definition_t *def = me->def; - gc_mark(objspace, me->klass, lev); + gc_mark(objspace, me->klass); if (!def) return; switch (def->type) { case VM_METHOD_TYPE_ISEQ: - gc_mark(objspace, def->body.iseq->self, lev); + gc_mark(objspace, def->body.iseq->self); break; case VM_METHOD_TYPE_BMETHOD: - gc_mark(objspace, def->body.proc, lev); + gc_mark(objspace, def->body.proc); break; case VM_METHOD_TYPE_ATTRSET: case VM_METHOD_TYPE_IVAR: - gc_mark(objspace, def->body.attr.location, lev); + gc_mark(objspace, def->body.attr.location); break; default: break; /* ignore */ @@ -1541,31 +1662,32 @@ mark_method_entry(rb_objspace_t *objspace, const rb_method_entry_t *me, int lev) void rb_mark_method_entry(const rb_method_entry_t *me) { - mark_method_entry(&rb_objspace, me, 0); + mark_method_entry(&rb_objspace, me); } static int mark_method_entry_i(ID key, const rb_method_entry_t *me, st_data_t data) { struct mark_tbl_arg *arg = (void*)data; - mark_method_entry(arg->objspace, me, arg->lev); + mark_method_entry(arg->objspace, me); return ST_CONTINUE; } static void -mark_m_tbl(rb_objspace_t *objspace, st_table *tbl, int lev) +mark_m_tbl(rb_objspace_t *objspace, st_table *tbl) { struct mark_tbl_arg arg; if (!tbl) return; arg.objspace = objspace; - arg.lev = lev; st_foreach(tbl, mark_method_entry_i, (st_data_t)&arg); } static int free_method_entry_i(ID key, rb_method_entry_t *me, st_data_t data) { - rb_free_method_entry(me); + if (!me->mark) { + rb_free_method_entry(me); + } return ST_CONTINUE; } @@ -1580,17 +1702,16 @@ static int mark_const_entry_i(ID key, const rb_const_entry_t *ce, st_data_t data) { struct mark_tbl_arg *arg = (void*)data; - gc_mark(arg->objspace, ce->value, arg->lev); + gc_mark(arg->objspace, ce->value); return ST_CONTINUE; } static void -mark_const_tbl(rb_objspace_t *objspace, st_table *tbl, int lev) +mark_const_tbl(rb_objspace_t *objspace, st_table *tbl) { struct mark_tbl_arg arg; if (!tbl) return; arg.objspace = objspace; - arg.lev = lev; st_foreach(tbl, mark_const_entry_i, (st_data_t)&arg); } @@ -1611,19 +1732,19 @@ rb_free_const_table(st_table *tbl) void rb_mark_tbl(st_table *tbl) { - mark_tbl(&rb_objspace, tbl, 0); + mark_tbl(&rb_objspace, tbl); } void rb_gc_mark_maybe(VALUE obj) { if (is_pointer_to_heap(&rb_objspace, (void *)obj)) { - gc_mark(&rb_objspace, obj, 0); + gc_mark(&rb_objspace, obj); } } static void -gc_mark(rb_objspace_t *objspace, VALUE ptr, int lev) +gc_mark(rb_objspace_t *objspace, VALUE ptr) { register RVALUE *obj; @@ -1634,29 +1755,17 @@ gc_mark(rb_objspace_t *objspace, VALUE ptr, int lev) obj->as.basic.flags |= FL_MARK; objspace->heap.live_num++; - if (lev > GC_LEVEL_MAX || (lev == 0 && stack_check(STACKFRAME_FOR_GC_MARK))) { - if (!mark_stack_overflow) { - if (mark_stack_ptr - mark_stack < MARK_STACK_MAX) { - *mark_stack_ptr = ptr; - mark_stack_ptr++; - } - else { - mark_stack_overflow = 1; - } - } - return; - } - gc_mark_children(objspace, ptr, lev+1); + push_mark_stack(&objspace->mark_stack, ptr); } void rb_gc_mark(VALUE ptr) { - gc_mark(&rb_objspace, ptr, 0); + gc_mark(&rb_objspace, ptr); } static void -gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) +gc_mark_children(rb_objspace_t *objspace, VALUE ptr) { register RVALUE *obj = RANY(ptr); @@ -1692,7 +1801,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) case NODE_RESBODY: case NODE_CLASS: case NODE_BLOCK_PASS: - gc_mark(objspace, (VALUE)obj->as.node.u2.node, lev); + gc_mark(objspace, (VALUE)obj->as.node.u2.node); /* fall through */ case NODE_BLOCK: /* 1,3 */ case NODE_OPTBLOCK: @@ -1706,7 +1815,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) case NODE_DEFS: case NODE_OP_ASGN1: case NODE_ARGS: - gc_mark(objspace, (VALUE)obj->as.node.u1.node, lev); + gc_mark(objspace, (VALUE)obj->as.node.u1.node); /* fall through */ case NODE_SUPER: /* 3 */ case NODE_FCALL: @@ -1733,7 +1842,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) case NODE_ALIAS: case NODE_VALIAS: case NODE_ARGSCAT: - gc_mark(objspace, (VALUE)obj->as.node.u1.node, lev); + gc_mark(objspace, (VALUE)obj->as.node.u1.node); /* fall through */ case NODE_GASGN: /* 2 */ case NODE_LASGN: @@ -1769,7 +1878,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) case NODE_SCOPE: /* 2,3 */ case NODE_CDECL: case NODE_OPT_ARG: - gc_mark(objspace, (VALUE)obj->as.node.u3.node, lev); + gc_mark(objspace, (VALUE)obj->as.node.u3.node); ptr = (VALUE)obj->as.node.u2.node; goto again; @@ -1801,26 +1910,26 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) default: /* unlisted NODE */ if (is_pointer_to_heap(objspace, obj->as.node.u1.node)) { - gc_mark(objspace, (VALUE)obj->as.node.u1.node, lev); + gc_mark(objspace, (VALUE)obj->as.node.u1.node); } if (is_pointer_to_heap(objspace, obj->as.node.u2.node)) { - gc_mark(objspace, (VALUE)obj->as.node.u2.node, lev); + gc_mark(objspace, (VALUE)obj->as.node.u2.node); } if (is_pointer_to_heap(objspace, obj->as.node.u3.node)) { - gc_mark(objspace, (VALUE)obj->as.node.u3.node, lev); + gc_mark(objspace, (VALUE)obj->as.node.u3.node); } } return; /* no need to mark class. */ } - gc_mark(objspace, obj->as.basic.klass, lev); + gc_mark(objspace, obj->as.basic.klass); switch (BUILTIN_TYPE(obj)) { case T_ICLASS: case T_CLASS: case T_MODULE: - mark_m_tbl(objspace, RCLASS_M_TBL(obj), lev); - mark_tbl(objspace, RCLASS_IV_TBL(obj), lev); - mark_const_tbl(objspace, RCLASS_CONST_TBL(obj), lev); + mark_m_tbl(objspace, RCLASS_M_TBL(obj)); + mark_tbl(objspace, RCLASS_IV_TBL(obj)); + mark_const_tbl(objspace, RCLASS_CONST_TBL(obj)); ptr = RCLASS_SUPER(obj); goto again; @@ -1833,13 +1942,13 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) long i, len = RARRAY_LEN(obj); VALUE *ptr = RARRAY_PTR(obj); for (i=0; i < len; i++) { - gc_mark(objspace, *ptr++, lev); + gc_mark(objspace, *ptr++); } } break; case T_HASH: - mark_hash(objspace, obj->as.hash.ntbl, lev); + mark_hash(objspace, obj->as.hash.ntbl); ptr = obj->as.hash.ifnone; goto again; @@ -1866,25 +1975,25 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) long i, len = ROBJECT_NUMIV(obj); VALUE *ptr = ROBJECT_IVPTR(obj); for (i = 0; i < len; i++) { - gc_mark(objspace, *ptr++, lev); + gc_mark(objspace, *ptr++); } } break; case T_FILE: if (obj->as.file.fptr) { - gc_mark(objspace, obj->as.file.fptr->pathv, lev); - gc_mark(objspace, obj->as.file.fptr->tied_io_for_writing, lev); - gc_mark(objspace, obj->as.file.fptr->writeconv_asciicompat, lev); - gc_mark(objspace, obj->as.file.fptr->writeconv_pre_ecopts, lev); - gc_mark(objspace, obj->as.file.fptr->encs.ecopts, lev); - gc_mark(objspace, obj->as.file.fptr->write_lock, lev); + gc_mark(objspace, obj->as.file.fptr->pathv); + gc_mark(objspace, obj->as.file.fptr->tied_io_for_writing); + gc_mark(objspace, obj->as.file.fptr->writeconv_asciicompat); + gc_mark(objspace, obj->as.file.fptr->writeconv_pre_ecopts); + gc_mark(objspace, obj->as.file.fptr->encs.ecopts); + gc_mark(objspace, obj->as.file.fptr->write_lock); } break; case T_REGEXP: - gc_mark(objspace, obj->as.regexp.src, lev); - break; + ptr = obj->as.regexp.src; + goto again; case T_FLOAT: case T_BIGNUM: @@ -1892,7 +2001,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) break; case T_MATCH: - gc_mark(objspace, obj->as.match.regexp, lev); + gc_mark(objspace, obj->as.match.regexp); if (obj->as.match.str) { ptr = obj->as.match.str; goto again; @@ -1900,14 +2009,14 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) break; case T_RATIONAL: - gc_mark(objspace, obj->as.rational.num, lev); - gc_mark(objspace, obj->as.rational.den, lev); - break; + gc_mark(objspace, obj->as.rational.num); + ptr = obj->as.rational.den; + goto again; case T_COMPLEX: - gc_mark(objspace, obj->as.complex.real, lev); - gc_mark(objspace, obj->as.complex.imag, lev); - break; + gc_mark(objspace, obj->as.complex.real); + ptr = obj->as.complex.imag; + goto again; case T_STRUCT: { @@ -1915,7 +2024,7 @@ gc_mark_children(rb_objspace_t *objspace, VALUE ptr, int lev) VALUE *ptr = RSTRUCT_PTR(obj); while (len--) { - gc_mark(objspace, *ptr++, lev); + gc_mark(objspace, *ptr++); } } break; @@ -2441,11 +2550,9 @@ gc_marks(rb_objspace_t *objspace) SET_STACK_END; - init_mark_stack(objspace); - th->vm->self ? rb_gc_mark(th->vm->self) : rb_vm_mark(th->vm); - mark_tbl(objspace, finalizer_table, 0); + mark_tbl(objspace, finalizer_table); mark_current_machine_context(objspace, th); rb_gc_mark_symbols(); @@ -2458,7 +2565,7 @@ gc_marks(rb_objspace_t *objspace) rb_mark_end_proc(); rb_gc_mark_global_tbl(); - mark_tbl(objspace, rb_class_tbl, 0); + mark_tbl(objspace, rb_class_tbl); /* mark generic instance variables for special constants */ rb_mark_generic_ivar_tbl(); @@ -2467,15 +2574,9 @@ gc_marks(rb_objspace_t *objspace) rb_gc_mark_unlinked_live_method_entries(th->vm); - /* gc_mark objects whose marking are not completed*/ - while (!MARK_STACK_EMPTY) { - if (mark_stack_overflow) { - gc_mark_all(objspace); - } - else { - gc_mark_rest(objspace); - } - } + /* marking-loop */ + gc_mark_stacked_objects(objspace); + GC_PROF_MARK_TIMER_STOP; } @@ -2955,21 +3056,6 @@ rb_gc_finalize_deferred(void) finalize_deferred(&rb_objspace); } -static int -chain_finalized_object(st_data_t key, st_data_t val, st_data_t arg) -{ - RVALUE *p = (RVALUE *)key, **final_list = (RVALUE **)arg; - if ((p->as.basic.flags & (FL_FINALIZE|FL_MARK)) == FL_FINALIZE) { - if (BUILTIN_TYPE(p) != T_ZOMBIE) { - p->as.free.flags = FL_MARK | T_ZOMBIE; /* remain marked */ - RDATA(p)->dfree = 0; - } - p->as.free.next = *final_list; - *final_list = p; - } - return ST_CONTINUE; -} - struct force_finalize_list { VALUE obj; VALUE table; @@ -3001,17 +3087,12 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace) RVALUE *final_list = 0; size_t i; - /* run finalizers */ rest_sweep(objspace); - do { - /* XXX: this loop will make no sense */ - /* because mark will not be removed */ - finalize_deferred(objspace); - mark_tbl(objspace, finalizer_table, 0); - st_foreach(finalizer_table, chain_finalized_object, - (st_data_t)&deferred_final_list); - } while (deferred_final_list); + /* run finalizers */ + finalize_deferred(objspace); + assert(deferred_final_list == 0); + /* force to run finalizer */ while (finalizer_table->num_entries) { struct force_finalize_list *list = 0; @@ -3110,7 +3191,7 @@ id2ref(VALUE obj, VALUE objid) if (ptr == Qfalse) return Qfalse; if (ptr == Qnil) return Qnil; if (FIXNUM_P(ptr)) return (VALUE)ptr; - ptr = objid ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */ + ptr = obj_id_to_ref(objid); if ((ptr % sizeof(RVALUE)) == (4 << 2)) { ID symid = ptr / sizeof(RVALUE); @@ -3193,7 +3274,7 @@ rb_obj_id(VALUE obj) if (SPECIAL_CONST_P(obj)) { return LONG2NUM((SIGNED_VALUE)obj); } - return (VALUE)((SIGNED_VALUE)obj|FIXNUM_FLAG); + return nonspecial_obj_id(obj); } static int @@ -3,9 +3,9 @@ #define RUBY_GC_H 1 #if defined(__x86_64__) && defined(__GNUC__) -#define SET_MACHINE_STACK_END(p) __asm__("movq\t%%rsp, %0" : "=r" (*(p))) +#define SET_MACHINE_STACK_END(p) __asm__ volatile ("movq\t%%rsp, %0" : "=r" (*(p))) #elif defined(__i386) && defined(__GNUC__) -#define SET_MACHINE_STACK_END(p) __asm__("movl\t%%esp, %0" : "=r" (*(p))) +#define SET_MACHINE_STACK_END(p) __asm__ volatile ("movl\t%%esp, %0" : "=r" (*(p))) #else NOINLINE(void rb_gc_set_stack_end(VALUE **stack_end_p)); #define SET_MACHINE_STACK_END(p) rb_gc_set_stack_end(p) @@ -81,6 +81,7 @@ int ruby_get_stack_grow_direction(volatile VALUE *addr); #define STACK_GROW_DIR_DETECTION VALUE stack_grow_dir_detection #define STACK_DIR_UPPER(a,b) STACK_UPPER(&stack_grow_dir_detection, (a), (b)) #endif +#define IS_STACK_DIR_UPPER() STACK_DIR_UPPER(1,0) #if defined __GNUC__ && __GNUC__ >= 4 #pragma GCC visibility push(default) @@ -2,7 +2,7 @@ hash.c - - $Author: nobu $ + $Author: usa $ created at: Mon Nov 22 18:51:18 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -824,18 +824,6 @@ struct shift_var { }; static int -shift_i(VALUE key, VALUE value, VALUE arg) -{ - struct shift_var *var = (struct shift_var *)arg; - - if (key == Qundef) return ST_CONTINUE; - if (var->key != Qundef) return ST_STOP; - var->key = key; - var->val = value; - return ST_DELETE; -} - -static int shift_i_safe(VALUE key, VALUE value, VALUE arg) { struct shift_var *var = (struct shift_var *)arg; @@ -866,16 +854,20 @@ rb_hash_shift(VALUE hash) rb_hash_modify(hash); var.key = Qundef; - rb_hash_foreach(hash, RHASH(hash)->iter_lev > 0 ? shift_i_safe : shift_i, - (VALUE)&var); + if (RHASH(hash)->iter_lev == 0) { + if (st_shift(RHASH(hash)->ntbl, &var.key, &var.val)) { + return rb_assoc_new(var.key, var.val); + } + } + else { + rb_hash_foreach(hash, shift_i_safe, (VALUE)&var); - if (var.key != Qundef) { - if (RHASH(hash)->iter_lev > 0) { + if (var.key != Qundef) { rb_hash_delete_key(hash, var.key); + return rb_assoc_new(var.key, var.val); } - return rb_assoc_new(var.key, var.val); } - else if (FL_TEST(hash, HASH_PROC_DEFAULT)) { + if (FL_TEST(hash, HASH_PROC_DEFAULT)) { return rb_funcall(RHASH_IFNONE(hash), id_yield, 2, hash, Qnil); } else { @@ -2,7 +2,7 @@ id.c - - $Author: nobu $ + $Author: usa $ created at: Thu Jul 12 04:37:51 2007 Copyright (C) 2004-2007 Koichi Sasada @@ -35,6 +35,7 @@ Init_id(void) REGISTER_SYMID(idEach, "each"); REGISTER_SYMID(idLength, "length"); REGISTER_SYMID(idSize, "size"); + REGISTER_SYMID(idProc, "proc"); REGISTER_SYMID(idLambda, "lambda"); REGISTER_SYMID(idIntern, "intern"); REGISTER_SYMID(idGets, "gets"); @@ -3,7 +3,7 @@ id.h - - $Author: akr $ + $Author: usa $ created at: Sun Oct 19 21:12:51 2008 Copyright (C) 2007 Koichi Sasada @@ -104,6 +104,7 @@ enum ruby_method_ids { tGets, tSucc, tEach, + tProc, tLambda, tSend, t__send__, @@ -126,6 +127,7 @@ enum ruby_method_ids { TOKEN2ID(Gets), TOKEN2ID(Succ), TOKEN2ID(Each), + TOKEN2ID(Proc), TOKEN2ID(Lambda), TOKEN2ID(Send), TOKEN2ID(__send__), diff --git a/include/ruby/backward/rubysig.h b/include/ruby/backward/rubysig.h index 60a67ec..7dd18dd 100644 --- a/include/ruby/backward/rubysig.h +++ b/include/ruby/backward/rubysig.h @@ -2,8 +2,8 @@ rubysig.h - - $Author: akr $ - $Date: 2009-10-02 21:04:37 +0900 (Fri, 02 Oct 2009) $ + $Author: usa $ + $Date: 2012-12-11 17:52:48 +0900 (Tue, 11 Dec 2012) $ created at: Wed Aug 16 01:15:38 JST 1995 Copyright (C) 1993-2008 Yukihiro Matsumoto @@ -27,6 +27,10 @@ extern "C" { #endif #endif +#if defined __GNUC__ && __GNUC__ >= 4 +#pragma GCC visibility push(default) +#endif + struct rb_blocking_region_buffer; DEPRECATED(RUBY_EXTERN struct rb_blocking_region_buffer *rb_thread_blocking_region_begin(void)); DEPRECATED(RUBY_EXTERN void rb_thread_blocking_region_end(struct rb_blocking_region_buffer *)); @@ -38,6 +42,10 @@ DEPRECATED(RUBY_EXTERN void rb_thread_blocking_region_end(struct rb_blocking_reg #define ALLOW_INTS do {CHECK_INTS;} while (0) #define CHECK_INTS rb_thread_check_ints() +#if defined __GNUC__ && __GNUC__ >= 4 +#pragma GCC visibility pop +#endif + #if defined(__cplusplus) #if 0 { /* satisfy cc-mode */ diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index 058462f..cced3d2 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -211,6 +211,12 @@ void rb_enc_set_default_external(VALUE encoding); void rb_enc_set_default_internal(VALUE encoding); VALUE rb_locale_charmap(VALUE klass); long rb_memsearch(const void*,long,const void*,long,rb_encoding*); +char *rb_enc_path_next(const char *,const char *,rb_encoding*); +char *rb_enc_path_skip_prefix(const char *,const char *,rb_encoding*); +char *rb_enc_path_last_separator(const char *,const char *,rb_encoding*); +char *rb_enc_path_end(const char *,const char *,rb_encoding*); +const char *ruby_enc_find_basename(const char *name, long *baselen, long *alllen, rb_encoding *enc); +const char *ruby_enc_find_extname(const char *name, long *len, rb_encoding *enc); RUBY_EXTERN VALUE rb_cEncoding; #define ENC_DUMMY_FLAG (1<<24) diff --git a/include/ruby/intern.h b/include/ruby/intern.h index fffd108..13db2af 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -2,7 +2,7 @@ intern.h - - $Author: nobu $ + $Author: usa $ created at: Thu Jun 10 14:22:17 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -31,6 +31,15 @@ extern "C" { #else # include <varargs.h> #endif + +#if defined(HAVE_SYS_TYPES_H) +#include <sys/types.h> +#endif + +#if defined(HAVE_SYS_TIME_H) +#include <sys/time.h> +#endif + #include "ruby/st.h" #if defined __GNUC__ && __GNUC__ >= 4 @@ -122,6 +131,7 @@ VALUE rb_dbl2big(double); double rb_big2dbl(VALUE); VALUE rb_big_cmp(VALUE, VALUE); VALUE rb_big_eq(VALUE, VALUE); +VALUE rb_big_eql(VALUE, VALUE); VALUE rb_big_plus(VALUE, VALUE); VALUE rb_big_minus(VALUE, VALUE); VALUE rb_big_mul(VALUE, VALUE); @@ -160,7 +170,6 @@ VALUE rb_Complex(VALUE, VALUE); VALUE rb_class_boot(VALUE); VALUE rb_class_new(VALUE); VALUE rb_mod_init_copy(VALUE, VALUE); -VALUE rb_class_init_copy(VALUE, VALUE); VALUE rb_singleton_class_clone(VALUE); void rb_singleton_class_attached(VALUE,VALUE); VALUE rb_make_metaclass(VALUE, VALUE); @@ -341,7 +350,7 @@ VALUE rb_require_safe(VALUE, int); void rb_obj_call_init(VALUE, int, VALUE*); VALUE rb_class_new_instance(int, VALUE*, VALUE); VALUE rb_block_proc(void); -VALUE rb_f_lambda(void); +VALUE rb_block_lambda(void); VALUE rb_proc_new(VALUE (*)(ANYARGS/* VALUE yieldarg[, VALUE procarg] */), VALUE); VALUE rb_obj_is_proc(VALUE); VALUE rb_proc_call(VALUE, VALUE); @@ -352,6 +361,7 @@ VALUE rb_binding_new(void); VALUE rb_obj_method(VALUE, VALUE); VALUE rb_obj_is_method(VALUE); VALUE rb_method_call(int, VALUE*, VALUE); +VALUE rb_method_call_with_block(int, VALUE *, VALUE, VALUE); int rb_mod_method_arity(VALUE, ID); int rb_obj_method_arity(VALUE, ID); VALUE rb_protect(VALUE (*)(VALUE), VALUE, int*); @@ -402,15 +412,9 @@ int rb_find_file_ext_safe(VALUE*, const char* const*, int); VALUE rb_find_file_safe(VALUE, int); int rb_find_file_ext(VALUE*, const char* const*); VALUE rb_find_file(VALUE); -char *rb_path_next(const char *); -char *rb_path_skip_prefix(const char *); -char *rb_path_last_separator(const char *); -char *rb_path_end(const char *); VALUE rb_file_directory_p(VALUE,VALUE); VALUE rb_str_encode_ospath(VALUE); int rb_is_absolute_path(const char *); -const char *ruby_find_basename(const char *name, long *baselen, long *alllen); -const char *ruby_find_extname(const char *name, long *len); /* gc.c */ void ruby_set_stack_size(size_t); NORETURN(void rb_memerror(void)); @@ -492,7 +496,7 @@ VALUE rb_marshal_dump(VALUE, VALUE); VALUE rb_marshal_load(VALUE); void rb_marshal_define_compat(VALUE newclass, VALUE oldclass, VALUE (*dumper)(VALUE), VALUE (*loader)(VALUE, VALUE)); /* numeric.c */ -void rb_num_zerodiv(void); +NORETURN(void rb_num_zerodiv(void)); #define RB_NUM_COERCE_FUNCS_NEED_OPID 1 VALUE rb_num_coerce_bin(VALUE, VALUE, ID); VALUE rb_num_coerce_cmp(VALUE, VALUE, ID); diff --git a/include/ruby/missing.h b/include/ruby/missing.h index 13503d4..25543ec 100644 --- a/include/ruby/missing.h +++ b/include/ruby/missing.h @@ -3,7 +3,7 @@ missing.h - prototype for *.c in ./missing, and for missing timeval struct - $Author: naruse $ + $Author: usa $ created at: Sat May 11 23:46:03 JST 2002 ************************************************/ @@ -24,18 +24,21 @@ extern "C" { #include RUBY_EXTCONF_H #endif +#if !defined(HAVE_STRUCT_TIMEVAL) || !defined(HAVE_STRUCT_TIMESPEC) +#if defined(HAVE_TIME_H) +# include <time.h> +#endif #if defined(HAVE_SYS_TIME_H) -# include <sys/time.h> -#elif !defined(_WIN32) -# define time_t long +# include <sys/time.h> +#endif +#endif + +#if !defined(HAVE_STRUCT_TIMEVAL) struct timeval { time_t tv_sec; /* seconds */ long tv_usec; /* microseconds */ }; -#endif -#if defined(HAVE_SYS_TYPES_H) -# include <sys/types.h> -#endif +#endif /* HAVE_STRUCT_TIMEVAL */ #if !defined(HAVE_STRUCT_TIMESPEC) struct timespec { @@ -51,11 +54,6 @@ struct timezone { }; #endif -#if defined(HAVE___SYSCALL) && defined(__APPLE__) -/* Mac OS X has __syscall but doen't defined in headers */ -off_t __syscall(quad_t number, ...); -#endif - #ifdef RUBY_EXPORT #undef RUBY_EXTERN #endif diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index 3b72f8c..a90e215 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -2,7 +2,7 @@ ruby/ruby.h - - $Author: naruse $ + $Author: usa $ created at: Thu Jun 10 14:26:32 JST 1993 Copyright (C) 1993-2008 Yukihiro Matsumoto @@ -1153,6 +1153,7 @@ VALUE rb_funcall(VALUE, ID, int, ...); VALUE rb_funcall2(VALUE, ID, int, const VALUE*); VALUE rb_funcall3(VALUE, ID, int, const VALUE*); VALUE rb_funcall_passing_block(VALUE, ID, int, const VALUE*); +VALUE rb_funcall_with_block(VALUE, ID, int, const VALUE*, VALUE); int rb_scan_args(int, const VALUE*, const char*, ...); VALUE rb_call_super(int, const VALUE*); diff --git a/include/ruby/st.h b/include/ruby/st.h index 50f2a75..68cc511 100644 --- a/include/ruby/st.h +++ b/include/ruby/st.h @@ -109,6 +109,7 @@ st_table *st_init_strcasetable(void); st_table *st_init_strcasetable_with_size(st_index_t); int st_delete(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */ int st_delete_safe(st_table *, st_data_t *, st_data_t *, st_data_t); +int st_shift(st_table *, st_data_t *, st_data_t *); /* returns 0:notfound 1:deleted */ int st_insert(st_table *, st_data_t, st_data_t); int st_insert2(st_table *, st_data_t, st_data_t, st_data_t (*)(st_data_t)); int st_lookup(st_table *, st_data_t, st_data_t *); diff --git a/include/ruby/util.h b/include/ruby/util.h index c56d3f2..4d66879 100644 --- a/include/ruby/util.h +++ b/include/ruby/util.h @@ -2,7 +2,7 @@ util.h - - $Author: akr $ + $Author: usa $ created at: Thu Mar 9 11:55:53 JST 1995 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -54,10 +54,6 @@ unsigned long ruby_scan_oct(const char *, size_t, size_t *); #define scan_hex(s,l,e) ((int)ruby_scan_hex((s),(l),(e))) unsigned long ruby_scan_hex(const char *, size_t, size_t *); -#if defined(__CYGWIN32__) || defined(_WIN32) -void ruby_add_suffix(VALUE str, const char *suffix); -#endif - void ruby_qsort(void *, const size_t, const size_t, int (*)(const void *, const void *, void *), void *); diff --git a/include/ruby/win32.h b/include/ruby/win32.h index 3d15742..99382f4 100644 --- a/include/ruby/win32.h +++ b/include/ruby/win32.h @@ -126,6 +126,7 @@ extern DWORD rb_w32_osid(void); #undef fputchar #undef utime #undef lseek +#undef stat #undef fstat #define getc(_stream) rb_w32_getc(_stream) #define getchar() rb_w32_getc(stdin) @@ -149,6 +150,7 @@ extern DWORD rb_w32_osid(void); #define getppid() rb_w32_getppid() #define sleep(x) rb_w32_Sleep((x)*1000) #define Sleep(msec) (void)rb_w32_Sleep(msec) +#define fstati64(fd,st) rb_w32_fstati64(fd,st) #ifdef __BORLANDC__ #define creat(p, m) _creat(p, m) #define eof() _eof() @@ -157,7 +159,6 @@ extern DWORD rb_w32_osid(void); #define tell(h) _tell(h) #define _open _sopen #define sopen _sopen -#define _fstati64(fd,st) rb_w32_fstati64(fd,st) #undef fopen #define fopen(p, m) rb_w32_fopen(p, m) #undef fdopen @@ -184,7 +185,7 @@ extern DWORD rb_w32_osid(void); #if SIZEOF_OFF_T == 8 #define off_t __int64 #define stat stati64 -#define fstat(fd,st) _fstati64(fd,st) +#define fstat(fd,st) fstati64(fd,st) #if defined(__BORLANDC__) #define stati64(path, st) rb_w32_stati64(path, st) #elif !defined(_MSC_VER) || RT_VER < 80 @@ -195,7 +196,6 @@ extern DWORD rb_w32_osid(void); #else #define stati64 _stat64 #define _stat64(path, st) rb_w32_stati64(path, st) -#define _fstati64 _fstat64 #endif #else #define stat(path,st) rb_w32_stat(path,st) @@ -234,7 +234,7 @@ struct msghdr { extern int rb_w32_cmdvector(const char *, char ***); extern rb_pid_t rb_w32_pipe_exec(const char *, const char *, int, int *, int *); extern int flock(int fd, int oper); -extern int rb_w32_has_cancel_io(void); +extern int rb_w32_io_cancelable_p(int); extern int rb_w32_is_socket(int); extern int WSAAPI rb_w32_accept(int, struct sockaddr *, int *); extern int WSAAPI rb_w32_bind(int, const struct sockaddr *, int); @@ -305,9 +305,9 @@ extern int rb_w32_ustati64(const char *, struct stati64 *); extern int rb_w32_access(const char *, int); extern int rb_w32_uaccess(const char *, int); extern char rb_w32_fd_is_text(int); +extern int rb_w32_fstati64(int, struct stati64 *); #ifdef __BORLANDC__ -extern int rb_w32_fstati64(int, struct stati64 *); extern off_t _lseeki64(int, off_t, int); extern FILE *rb_w32_fopen(const char *, const char *); extern FILE *rb_w32_fdopen(int, const char *); @@ -575,7 +575,22 @@ extern char *rb_w32_strerror(int); #define O_NONBLOCK 1 #undef FD_SET -#define FD_SET(f, s) rb_w32_fdset(f, s) +#define FD_SET(fd, set) do {\ + unsigned int i;\ + SOCKET s = _get_osfhandle(fd);\ +\ + for (i = 0; i < (set)->fd_count; i++) {\ + if ((set)->fd_array[i] == s) {\ + break;\ + }\ + }\ + if (i == (set)->fd_count) {\ + if ((set)->fd_count < FD_SETSIZE) {\ + (set)->fd_array[i] = s;\ + (set)->fd_count++;\ + }\ + }\ +} while(0) #undef FD_CLR #define FD_CLR(f, s) rb_w32_fdclr(f, s) @@ -741,4 +756,18 @@ uintptr_t rb_w32_asynchronize(asynchronous_func_t func, uintptr_t self, int argc } /* extern "C" { */ #endif +#ifdef __MINGW64__ +/* + * Use powl() instead of broken pow() of x86_64-w64-mingw32. + * This workaround will fix test failures in test_bignum.rb, + * test_fixnum.rb and test_float.rb etc. + */ +static inline double +rb_w32_pow(double x, double y) +{ + return powl(x, y); +} +#define pow rb_w32_pow +#endif + #endif /* RUBY_WIN32_H */ @@ -79,7 +79,7 @@ setlocal */ DEFINE_INSN getspecial -(VALUE key, rb_num_t type) +(rb_num_t key, rb_num_t type) () (VALUE val) { @@ -93,7 +93,7 @@ getspecial */ DEFINE_INSN setspecial -(VALUE key) +(rb_num_t key) (VALUE obj) () { @@ -533,6 +533,9 @@ splatarray if (NIL_P(tmp)) { tmp = rb_ary_new3(1, ary); } + else if (RTEST(flag)) { + tmp = rb_ary_dup(tmp); + } obj = tmp; } @@ -628,7 +631,7 @@ pop (VALUE val) () { - val = val; + (void)val; /* none */ } diff --git a/insns_info.inc b/insns_info.inc index f254d2c..fb74f90 100644 --- a/insns_info.inc +++ b/insns_info.inc @@ -9,18 +9,18 @@ or insns2vm.rb */ -#define TS_VALUE 'V' +#define TS_ISEQ 'S' #define TS_GENTRY 'G' +#define TS_OFFSET 'O' #define TS_DINDEX 'D' #define TS_VARIABLE '.' #define TS_CDHASH 'H' #define TS_IC 'C' #define TS_ID 'I' -#define TS_LINDEX 'L' #define TS_FUNCPTR 'F' -#define TS_ISEQ 'S' +#define TS_VALUE 'V' +#define TS_LINDEX 'L' #define TS_NUM 'N' -#define TS_OFFSET 'O' static const char *const insn_name_info[] = { "nop", @@ -110,8 +110,8 @@ static const char *const insn_operand_info[] = { "", "L", "L", - "VN", - "V", + "NN", + "N", "DN", "DN", "IC", @@ -92,8 +92,15 @@ void rb_call_end_proc(VALUE data); /* file.c */ VALUE rb_home_dir(const char *user, VALUE result); VALUE rb_realpath_internal(VALUE basedir, VALUE path, int strict); +VALUE rb_file_expand_path_fast(VALUE, VALUE); +VALUE rb_file_expand_path_internal(VALUE, VALUE, int, int, VALUE); void Init_File(void); +#ifdef _WIN32 +/* file.c, win32/file.c */ +void rb_w32_init_file(void); +#endif + /* gc.c */ void Init_heap(void); @@ -2,7 +2,7 @@ io.c - - $Author: naruse $ + $Author: usa $ created at: Fri Oct 15 18:08:59 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -35,10 +35,6 @@ # define NO_SAFE_RENAME #endif -#if defined(__CYGWIN__) || defined(_WIN32) -# define NO_LONG_FNAME -#endif - #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) || defined(sun) || defined(_nec_ews) # define USE_SETVBUF #endif @@ -106,6 +102,11 @@ # endif #endif +#if defined(HAVE___SYSCALL) && (defined(__APPLE__) || defined(__OpenBSD__)) +/* Mac OS X and OpenBSD have __syscall but don't define it in headers */ +off_t __syscall(quad_t number, ...); +#endif + #define numberof(array) (int)(sizeof(array) / sizeof((array)[0])) #define IO_RBUF_CAPA_MIN 8192 @@ -161,6 +162,65 @@ rb_update_max_fd(int fd) if (max_file_descriptor < fd) max_file_descriptor = fd; } +void +rb_maygvl_fd_fix_cloexec(int fd) +{ + /* MinGW don't have F_GETFD and FD_CLOEXEC. [ruby-core:40281] */ +#ifdef F_GETFD + int flags, flags2, ret; + flags = fcntl(fd, F_GETFD); /* should not fail except EBADF. */ + if (flags == -1) { + rb_bug("rb_maygvl_fd_fix_cloexec: fcntl(%d, F_GETFD) failed: %s", fd, strerror(errno)); + } + if (fd <= 2) + flags2 = flags & ~FD_CLOEXEC; /* Clear CLOEXEC for standard file descriptors: 0, 1, 2. */ + else + flags2 = flags | FD_CLOEXEC; /* Set CLOEXEC for non-standard file descriptors: 3, 4, 5, ... */ + if (flags != flags2) { + ret = fcntl(fd, F_SETFD, flags2); + if (ret == -1) { + rb_bug("rb_maygvl_fd_fix_cloexec: fcntl(%d, F_SETFD, %d) failed: %s", fd, flags2, strerror(errno)); + } + } +#endif +} + +int +rb_cloexec_fcntl_dupfd(int fd, int minfd) +{ + int ret; + +#if defined(HAVE_FCNTL) && defined(F_DUPFD_CLOEXEC) + static int try_dupfd_cloexec = 1; + if (try_dupfd_cloexec) { + ret = fcntl(fd, F_DUPFD_CLOEXEC, minfd); + if (ret != -1) { + if (ret <= 2) + rb_maygvl_fd_fix_cloexec(ret); + return ret; + } + /* F_DUPFD_CLOEXEC is available since Linux 2.6.24. Linux 2.6.18 fails with EINVAL */ + if (errno == EINVAL) { + ret = fcntl(fd, F_DUPFD, minfd); + if (ret != -1) { + try_dupfd_cloexec = 0; + } + } + } + else { + ret = fcntl(fd, F_DUPFD, minfd); + } +#elif defined(F_DUPFD) + ret = fcntl(fd, F_DUPFD, minfd); +#else + ret = -1; + errno = EINVAL; +#endif + if (ret == -1) return -1; + rb_maygvl_fd_fix_cloexec(ret); + return ret; +} + #define argf_of(obj) (*(struct argf *)DATA_PTR(obj)) #define ARGF argf_of(argf) @@ -193,7 +253,7 @@ rb_update_max_fd(int fd) #if defined(_WIN32) #define WAIT_FD_IN_WIN32(fptr) \ - (rb_w32_has_cancel_io() ? 0 : rb_thread_wait_fd((fptr)->fd)) + (rb_w32_io_cancelable_p((fptr)->fd) ? 0 : rb_thread_wait_fd((fptr)->fd)) #else #define WAIT_FD_IN_WIN32(fptr) #endif @@ -302,6 +362,12 @@ io_unread(rb_io_t *fptr) /* add extra offset for removed '\r' in rbuf */ extra_max = (long)(pos - fptr->rbuf.len); p = fptr->rbuf.ptr + fptr->rbuf.off; + + /* if the end of rbuf is '\r', rbuf doesn't have '\r' within rbuf.len */ + if (*(fptr->rbuf.ptr + fptr->rbuf.capa - 1) == '\r') { + newlines++; + } + for (i = 0; i < fptr->rbuf.len; i++) { if (*p == '\n') newlines++; if (extra_max == newlines) break; @@ -360,10 +426,10 @@ set_binary_mode_with_seek_cur(rb_io_t *fptr) # define DEFAULT_TEXTMODE 0 #define NEED_READCONV(fptr) ((fptr)->encs.enc2 != NULL || NEED_NEWLINE_DECORATOR_ON_READ(fptr)) #define NEED_WRITECONV(fptr) (((fptr)->encs.enc != NULL && (fptr)->encs.enc != rb_ascii8bit_encoding()) || NEED_NEWLINE_DECORATOR_ON_WRITE(fptr) || ((fptr)->encs.ecflags & (ECONV_DECORATOR_MASK|ECONV_STATEFUL_DECORATOR_MASK))) -#define SET_BINARY_MODE(fptr) 0 -#define NEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr) 0 -#define SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2(enc2, ecflags) 0 -#define SET_BINARY_MODE_WITH_SEEK_CUR(fptr) 0 +#define SET_BINARY_MODE(fptr) (void)(fptr) +#define NEED_NEWLINE_DECORATOR_ON_READ_CHECK(fptr) (void)(fptr) +#define SET_UNIVERSAL_NEWLINE_DECORATOR_IF_ENC2(enc2, ecflags) ((void)(enc2), (void)(ecflags)) +#define SET_BINARY_MODE_WITH_SEEK_CUR(fptr) (void)(fptr) #endif #if !defined HAVE_SHUTDOWN && !defined shutdown @@ -3085,7 +3151,11 @@ io_getc(rb_io_t *fptr, rb_encoding *enc) } else { io_shift_cbuf(fptr, MBCLEN_CHARFOUND_LEN(r), &str); - cr = ISASCII(r) ? ENC_CODERANGE_7BIT : ENC_CODERANGE_VALID; + cr = ENC_CODERANGE_VALID; + if (MBCLEN_CHARFOUND_LEN(r) == 1 && rb_enc_asciicompat(read_enc) && + ISASCII(RSTRING_PTR(str)[0])) { + cr = ENC_CODERANGE_7BIT; + } } str = io_enc_str(str, fptr); ENC_CODERANGE_SET(str, cr); @@ -4694,7 +4764,7 @@ rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, vmode_handle: if (NIL_P(vmode)) { - fmode = FMODE_READABLE | DEFAULT_TEXTMODE; + fmode = FMODE_READABLE; oflags = O_RDONLY; } else if (!NIL_P(intmode = rb_check_to_integer(vmode, "to_int"))) { @@ -4741,6 +4811,11 @@ rb_io_extract_modeenc(VALUE *vmode_p, VALUE *vperm_p, VALUE opthash, if (fmode & FMODE_BINMODE) oflags |= O_BINARY; #endif +#if DEFAULT_TEXTMODE + else if (NIL_P(vmode)) { + fmode |= DEFAULT_TEXTMODE; + } +#endif if (!has_vmode) { v = rb_hash_aref(opthash, sym_mode); if (!NIL_P(v)) { @@ -4894,65 +4969,63 @@ static void io_encoding_set(rb_io_t *, VALUE, VALUE, VALUE); static int io_strip_bom(VALUE io) { - int b1, b2, b3, b4; - switch (b1 = FIX2INT(rb_io_getbyte(io))) { - case 0xEF: - b2 = FIX2INT(rb_io_getbyte(io)); - if (b2 == 0xBB) { - b3 = FIX2INT(rb_io_getbyte(io)); - if (b3 == 0xBF) { + VALUE b1, b2, b3, b4; + + if (NIL_P(b1 = rb_io_getbyte(io))) return 0; + switch (b1) { + case INT2FIX(0xEF): + if (NIL_P(b2 = rb_io_getbyte(io))) break; + if (b2 == INT2FIX(0xBB) && !NIL_P(b3 = rb_io_getbyte(io))) { + if (b3 == INT2FIX(0xBF)) { return rb_utf8_encindex(); } - rb_io_ungetbyte(io, INT2FIX(b3)); + rb_io_ungetbyte(io, b3); } - rb_io_ungetbyte(io, INT2FIX(b2)); + rb_io_ungetbyte(io, b2); break; - case 0xFE: - b2 = FIX2INT(rb_io_getbyte(io)); - if (b2 == 0xFF) { + case INT2FIX(0xFE): + if (NIL_P(b2 = rb_io_getbyte(io))) break; + if (b2 == INT2FIX(0xFF)) { return rb_enc_find_index("UTF-16BE"); } - rb_io_ungetbyte(io, INT2FIX(b2)); + rb_io_ungetbyte(io, b2); break; - case 0xFF: - b2 = FIX2INT(rb_io_getbyte(io)); - if (b2 == 0xFE) { - b3 = FIX2INT(rb_io_getbyte(io)); - if (b3 == 0) { - b4 = FIX2INT(rb_io_getbyte(io)); - if (b4 == 0) { + case INT2FIX(0xFF): + if (NIL_P(b2 = rb_io_getbyte(io))) break; + if (b2 == INT2FIX(0xFE)) { + b3 = rb_io_getbyte(io); + if (b3 == INT2FIX(0) && !NIL_P(b4 = rb_io_getbyte(io))) { + if (b4 == INT2FIX(0)) { return rb_enc_find_index("UTF-32LE"); } - rb_io_ungetbyte(io, INT2FIX(b4)); + rb_io_ungetbyte(io, b4); + rb_io_ungetbyte(io, b3); } else { - rb_io_ungetbyte(io, INT2FIX(b3)); + rb_io_ungetbyte(io, b3); return rb_enc_find_index("UTF-16LE"); } - rb_io_ungetbyte(io, INT2FIX(b3)); } - rb_io_ungetbyte(io, INT2FIX(b2)); + rb_io_ungetbyte(io, b2); break; - case 0: - b2 = FIX2INT(rb_io_getbyte(io)); - if (b2 == 0) { - b3 = FIX2INT(rb_io_getbyte(io)); - if (b3 == 0xFE) { - b4 = FIX2INT(rb_io_getbyte(io)); - if (b4 == 0xFF) { + case INT2FIX(0): + if (NIL_P(b2 = rb_io_getbyte(io))) break; + if (b2 == INT2FIX(0) && !NIL_P(b3 = rb_io_getbyte(io))) { + if (b3 == INT2FIX(0xFE) && !NIL_P(b4 = rb_io_getbyte(io))) { + if (b4 == INT2FIX(0xFF)) { return rb_enc_find_index("UTF-32BE"); } - rb_io_ungetbyte(io, INT2FIX(b4)); + rb_io_ungetbyte(io, b4); } - rb_io_ungetbyte(io, INT2FIX(b3)); + rb_io_ungetbyte(io, b3); } - rb_io_ungetbyte(io, INT2FIX(b2)); + rb_io_ungetbyte(io, b2); break; } - rb_io_ungetbyte(io, INT2FIX(b1)); + rb_io_ungetbyte(io, b1); return 0; } @@ -7130,15 +7203,15 @@ argf_next_argv(VALUE argf) fstat(fr, &st); if (*ARGF.inplace) { str = rb_str_new2(fn); -#ifdef NO_LONG_FNAME - ruby_add_suffix(str, ARGF.inplace); -#else rb_str_cat2(str, ARGF.inplace); -#endif #ifdef NO_SAFE_RENAME (void)close(fr); (void)unlink(RSTRING_PTR(str)); - (void)rename(fn, RSTRING_PTR(str)); + if (rename(fn, RSTRING_PTR(str)) < 0) { + rb_warn("Can't rename %s to %s: %s, skipping file", + fn, RSTRING_PTR(str), strerror(errno)); + goto retry; + } fr = rb_sysopen(str, O_RDONLY, 0); #else if (rename(fn, RSTRING_PTR(str)) < 0) { @@ -7918,60 +7991,227 @@ rb_f_select(int argc, VALUE *argv, VALUE obj) return rb_ensure(select_call, (VALUE)&args, select_end, (VALUE)&args); } -struct io_cntl_arg { +#if defined(__linux__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__APPLE__) + typedef unsigned long ioctl_req_t; + #define NUM2IOCTLREQ(num) NUM2ULONG(num) +#else + typedef int ioctl_req_t; + #define NUM2IOCTLREQ(num) NUM2INT(num) +#endif + +struct ioctl_arg { int fd; - int cmd; + ioctl_req_t cmd; long narg; - int io_p; }; -static VALUE nogvl_io_cntl(void *ptr) +static VALUE nogvl_ioctl(void *ptr) { - struct io_cntl_arg *arg = ptr; + struct ioctl_arg *arg = ptr; - if (arg->io_p) - return (VALUE)ioctl(arg->fd, arg->cmd, arg->narg); - else - return (VALUE)fcntl(arg->fd, arg->cmd, arg->narg); + return (VALUE)ioctl(arg->fd, arg->cmd, arg->narg); } static int -io_cntl(int fd, int cmd, long narg, int io_p) +do_ioctl(int fd, ioctl_req_t cmd, long narg) { int retval; - struct io_cntl_arg arg; - -#ifndef HAVE_FCNTL - if (!io_p) { - rb_notimplement(); - } -#endif + struct ioctl_arg arg; arg.fd = fd; arg.cmd = cmd; arg.narg = narg; - arg.io_p = io_p; - retval = (int)rb_thread_io_blocking_region(nogvl_io_cntl, &arg, fd); -#if defined(F_DUPFD) - if (!io_p && retval != -1 && cmd == F_DUPFD) { - rb_update_max_fd(retval); + retval = (int)rb_thread_io_blocking_region(nogvl_ioctl, &arg, fd); + + return retval; +} + +#define DEFULT_IOCTL_NARG_LEN (256) + +#ifdef __linux__ +static long +linux_iocparm_len(ioctl_req_t cmd) +{ + long len; + + if ((cmd & 0xFFFF0000) == 0) { + /* legacy and unstructured ioctl number. */ + return DEFULT_IOCTL_NARG_LEN; } + + len = _IOC_SIZE(cmd); + + /* paranoia check for silly drivers which don't keep ioctl convention */ + if (len < DEFULT_IOCTL_NARG_LEN) + len = DEFULT_IOCTL_NARG_LEN; + + return len; +} #endif - return retval; +static long +ioctl_narg_len(ioctl_req_t cmd) +{ + long len; + +#ifdef IOCPARM_MASK +#ifndef IOCPARM_LEN +#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) +#endif +#endif +#ifdef IOCPARM_LEN + len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */ +#elif defined(__linux__) + len = linux_iocparm_len(cmd); +#else + /* otherwise guess at what's safe */ + len = DEFULT_IOCTL_NARG_LEN; +#endif + + return len; } -static VALUE -rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p) +#ifdef HAVE_FCNTL +#ifdef __linux__ +typedef long fcntl_arg_t; +#else +/* posix */ +typedef int fcntl_arg_t; +#endif + +static long +fcntl_narg_len(int cmd) { - int cmd = NUM2INT(req); - rb_io_t *fptr; - long len = 0; - long narg = 0; - int retval; + long len; - rb_secure(2); + switch (cmd) { +#ifdef F_DUPFD + case F_DUPFD: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_DUP2FD /* bsd specific */ + case F_DUP2FD: + len = sizeof(int); + break; +#endif +#ifdef F_DUPFD_CLOEXEC /* linux specific */ + case F_DUPFD_CLOEXEC: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_GETFD + case F_GETFD: + len = 1; + break; +#endif +#ifdef F_SETFD + case F_SETFD: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_GETFL + case F_GETFL: + len = 1; + break; +#endif +#ifdef F_SETFL + case F_SETFL: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_GETOWN + case F_GETOWN: + len = 1; + break; +#endif +#ifdef F_SETOWN + case F_SETOWN: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_GETOWN_EX /* linux specific */ + case F_GETOWN_EX: + len = sizeof(struct f_owner_ex); + break; +#endif +#ifdef F_SETOWN_EX /* linux specific */ + case F_SETOWN_EX: + len = sizeof(struct f_owner_ex); + break; +#endif +#ifdef F_GETLK + case F_GETLK: + len = sizeof(struct flock); + break; +#endif +#ifdef F_SETLK + case F_SETLK: + len = sizeof(struct flock); + break; +#endif +#ifdef F_SETLKW + case F_SETLKW: + len = sizeof(struct flock); + break; +#endif +#ifdef F_READAHEAD /* bsd specific */ + case F_READAHEAD: + len = sizeof(int); + break; +#endif +#ifdef F_RDAHEAD /* Darwin specific */ + case F_RDAHEAD: + len = sizeof(int); + break; +#endif +#ifdef F_GETSIG /* linux specific */ + case F_GETSIG: + len = 1; + break; +#endif +#ifdef F_SETSIG /* linux specific */ + case F_SETSIG: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_GETLEASE /* linux specific */ + case F_GETLEASE: + len = 1; + break; +#endif +#ifdef F_SETLEASE /* linux specific */ + case F_SETLEASE: + len = sizeof(fcntl_arg_t); + break; +#endif +#ifdef F_NOTIFY /* linux specific */ + case F_NOTIFY: + len = sizeof(fcntl_arg_t); + break; +#endif + + default: + len = 256; + break; + } + + return len; +} +#else /* HAVE_FCNTL */ +static long +fcntl_narg_len(int cmd) +{ + return 0; +} +#endif /* HAVE_FCNTL */ + +static long +setup_narg(ioctl_req_t cmd, VALUE *argp, int io_p) +{ + long narg = 0; + VALUE arg = *argp; if (NIL_P(arg) || arg == Qfalse) { narg = 0; @@ -7989,50 +8229,50 @@ rb_io_ctl(VALUE io, VALUE req, VALUE arg, int io_p) narg = NUM2LONG(arg); } else { - arg = tmp; -#ifdef IOCPARM_MASK -#ifndef IOCPARM_LEN -#define IOCPARM_LEN(x) (((x) >> 16) & IOCPARM_MASK) -#endif -#endif -#ifdef IOCPARM_LEN - len = IOCPARM_LEN(cmd); /* on BSDish systems we're safe */ -#else - len = 256; /* otherwise guess at what's safe */ -#endif + long len; + + *argp = arg = tmp; + if (io_p) + len = ioctl_narg_len(cmd); + else + len = fcntl_narg_len((int)cmd); rb_str_modify(arg); - if (len <= RSTRING_LEN(arg)) { - len = RSTRING_LEN(arg); - } - if (RSTRING_LEN(arg) < len) { + /* expand for data + sentinel. */ + if (RSTRING_LEN(arg) < len+1) { rb_str_resize(arg, len+1); } - RSTRING_PTR(arg)[len] = 17; /* a little sanity check here */ + /* a little sanity check here */ + RSTRING_PTR(arg)[RSTRING_LEN(arg) - 1] = 17; narg = (long)(SIGNED_VALUE)RSTRING_PTR(arg); } } - GetOpenFile(io, fptr); - retval = io_cntl(fptr->fd, cmd, narg, io_p); - if (retval < 0) rb_sys_fail_path(fptr->pathv); - if (TYPE(arg) == T_STRING && RSTRING_PTR(arg)[len] != 17) { - rb_raise(rb_eArgError, "return value overflowed string"); + return narg; } - if (!io_p && cmd == F_SETFL) { - if (narg & O_NONBLOCK) { - fptr->mode |= FMODE_WSPLIT_INITIALIZED; - fptr->mode &= ~FMODE_WSPLIT; - } - else { - fptr->mode &= ~(FMODE_WSPLIT_INITIALIZED|FMODE_WSPLIT); - } +static VALUE +rb_ioctl(VALUE io, VALUE req, VALUE arg) +{ + ioctl_req_t cmd = NUM2IOCTLREQ(req); + rb_io_t *fptr; + long narg; + int retval; + + rb_secure(2); + + narg = setup_narg(cmd, &arg, 1); + GetOpenFile(io, fptr); + retval = do_ioctl(fptr->fd, cmd, narg); + if (retval < 0) rb_sys_fail_path(fptr->pathv); + if (RB_TYPE_P(arg, T_STRING)) { + if (RSTRING_PTR(arg)[RSTRING_LEN(arg)-1] != 17) + rb_raise(rb_eArgError, "return value overflowed string"); + RSTRING_PTR(arg)[RSTRING_LEN(arg)-1] = '\0'; } return INT2NUM(retval); } - /* * call-seq: * ios.ioctl(integer_cmd, arg) -> integer @@ -8051,10 +8291,80 @@ rb_io_ioctl(int argc, VALUE *argv, VALUE io) VALUE req, arg; rb_scan_args(argc, argv, "11", &req, &arg); - return rb_io_ctl(io, req, arg, 1); + return rb_ioctl(io, req, arg); } #ifdef HAVE_FCNTL +struct fcntl_arg { + int fd; + int cmd; + long narg; +}; + +static VALUE nogvl_fcntl(void *ptr) +{ + struct fcntl_arg *arg = ptr; + +#if defined(F_DUPFD) + if (arg->cmd == F_DUPFD) + return (VALUE)rb_cloexec_fcntl_dupfd(arg->fd, (int)arg->narg); +#endif + return (VALUE)fcntl(arg->fd, arg->cmd, arg->narg); +} + +static int +do_fcntl(int fd, int cmd, long narg) +{ + int retval; + struct fcntl_arg arg; + + arg.fd = fd; + arg.cmd = cmd; + arg.narg = narg; + + retval = (int)rb_thread_io_blocking_region(nogvl_fcntl, &arg, fd); +#if defined(F_DUPFD) + if (retval != -1 && cmd == F_DUPFD) { + rb_update_max_fd(retval); + } +#endif + + return retval; +} + +static VALUE +rb_fcntl(VALUE io, VALUE req, VALUE arg) +{ + int cmd = NUM2INT(req); + rb_io_t *fptr; + long narg; + int retval; + + rb_secure(2); + + narg = setup_narg(cmd, &arg, 0); + GetOpenFile(io, fptr); + retval = do_fcntl(fptr->fd, cmd, narg); + if (retval < 0) rb_sys_fail_path(fptr->pathv); + if (RB_TYPE_P(arg, T_STRING)) { + if (RSTRING_PTR(arg)[RSTRING_LEN(arg)-1] != 17) + rb_raise(rb_eArgError, "return value overflowed string"); + RSTRING_PTR(arg)[RSTRING_LEN(arg)-1] = '\0'; + } + + if (cmd == F_SETFL) { + if (narg & O_NONBLOCK) { + fptr->mode |= FMODE_WSPLIT_INITIALIZED; + fptr->mode &= ~FMODE_WSPLIT; + } + else { + fptr->mode &= ~(FMODE_WSPLIT_INITIALIZED|FMODE_WSPLIT); + } + } + + return INT2NUM(retval); +} + /* * call-seq: * ios.fcntl(integer_cmd, arg) -> integer @@ -8074,7 +8384,7 @@ rb_io_fcntl(int argc, VALUE *argv, VALUE io) VALUE req, arg; rb_scan_args(argc, argv, "11", &req, &arg); - return rb_io_ctl(io, req, arg, 0); + return rb_fcntl(io, req, arg); } #else #define rb_io_fcntl rb_f_notimplement @@ -10264,6 +10574,36 @@ argf_each_char(VALUE argf) /* * call-seq: + * ARGF.codepoints {|codepoint| block } -> ARGF + * ARGF.codepoints -> an_enumerator + * + * ARGF.each_codepoint {|codepoint| block } -> ARGF + * ARGF.each_codepoint -> an_enumerator + * + * Iterates over each codepoint of each file in +ARGF+. + * + * This method allows you to treat the files supplied on the command line as + * a single file consisting of the concatenation of each named file. After + * the last codepoint of the first file has been returned, the first + * codepoint of the second file is returned. The +ARGF.filename+ method can + * be used to determine the name of the file in which the current codepoint + * appears. + * + * If no block is given, an enumerator is returned instead. + */ +static VALUE +argf_each_codepoint(VALUE argf) +{ + RETURN_ENUMERATOR(argf, 0, 0); + for (;;) { + if (!next_argv()) return argf; + rb_block_call(ARGF.current_file, rb_intern("each_codepoint"), 0, 0, 0, 0); + ARGF.next_p = 1; + } +} + +/* + * call-seq: * ARGF.filename -> String * ARGF.path -> String * @@ -10990,9 +11330,11 @@ Init_IO(void) rb_define_method(rb_cARGF, "each_line", argf_each_line, -1); rb_define_method(rb_cARGF, "each_byte", argf_each_byte, 0); rb_define_method(rb_cARGF, "each_char", argf_each_char, 0); + rb_define_method(rb_cARGF, "each_codepoint", argf_each_codepoint, 0); rb_define_method(rb_cARGF, "lines", argf_each_line, -1); rb_define_method(rb_cARGF, "bytes", argf_each_byte, 0); rb_define_method(rb_cARGF, "chars", argf_each_char, 0); + rb_define_method(rb_cARGF, "codepoints", argf_each_codepoint, 0); rb_define_method(rb_cARGF, "read", argf_read, -1); rb_define_method(rb_cARGF, "readpartial", argf_readpartial, -1); @@ -2,7 +2,7 @@ iseq.c - - $Author: naruse $ + $Author: usa $ created at: 2006-07-11(Tue) 09:00:03 +0900 Copyright (C) 2006 Koichi Sasada @@ -216,6 +216,10 @@ set_relation(rb_iseq_t *iseq, const VALUE parent) GetISeqPtr(parent, piseq); iseq->parent_iseq = piseq; } + + if (type == ISEQ_TYPE_MAIN) { + iseq->local_iseq = iseq; + } } static VALUE @@ -2,7 +2,7 @@ iseq.h - - $Author: akr $ + $Author: usa $ created at: 04/01/01 23:36:57 JST Copyright (C) 2004-2008 Koichi Sasada @@ -94,7 +94,6 @@ struct iseq_compile_data { struct iseq_compile_data_storage *storage_current; int last_line; int last_coverable_line; - int flip_cnt; int label_no; int node_level; const rb_compile_option_t *option; @@ -118,6 +117,8 @@ enum defined_type { DEFINED_FUNC }; +#define DEFAULT_SPECIAL_VAR_COUNT 2 + #if defined __GNUC__ && __GNUC__ >= 4 #pragma GCC visibility pop #endif diff --git a/lib/drb/extservm.rb b/lib/drb/extservm.rb index 216fe8d..8a7fc31 100644 --- a/lib/drb/extservm.rb +++ b/lib/drb/extservm.rb @@ -79,7 +79,15 @@ module DRb @servers[name] = false end uri = @uri || DRb.uri - Process.detach spawn("#{command} #{uri} #{name}") + if command.respond_to? :to_ary + command = command.to_ary + [uri, name] + pid = spawn(*command) + else + pid = spawn("#{command} #{uri} #{name}") + end + th = Process.detach(pid) + th[:drb_service] = name + th end end end diff --git a/lib/drb/ssl.rb b/lib/drb/ssl.rb index 17e2a73..2b6a237 100644 --- a/lib/drb/ssl.rb +++ b/lib/drb/ssl.rb @@ -54,7 +54,7 @@ module DRb return end - rsa = OpenSSL::PKey::RSA.new(512){|p, n| + rsa = OpenSSL::PKey::RSA.new(1024){|p, n| next unless self[:verbose] case p when 0; $stderr.putc "." # BN_generate_prime @@ -177,7 +177,11 @@ module DRb break if (@acl ? @acl.allow_socket?(soc) : true) soc.close end - ssl = @config.accept(soc) + begin + ssl = @config.accept(soc) + ensure + soc.close if $! + end self.class.new(uri, ssl, @config, true) rescue OpenSSL::SSL::SSLError warn("#{__FILE__}:#{__LINE__}: warning: #{$!.message} (#{$!.class})") if @config[:verbose] diff --git a/lib/drb/unix.rb b/lib/drb/unix.rb index 549ff8c..6de5052 100644 --- a/lib/drb/unix.rb +++ b/lib/drb/unix.rb @@ -100,7 +100,7 @@ module DRb end def set_sockopt(soc) - soc.fcntl(Fcntl::F_SETFL, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC + soc.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) if defined? Fcntl::FD_CLOEXEC end end @@ -254,7 +254,7 @@ # Rails, the web application framework, uses ERB to create views. # class ERB - Revision = '$Date:: 2011-05-25 08:24:32 +0900#$' #' + Revision = '$Date:: 2012-12-13 14:24:26 +0900#$' #' # Returns revision information for the erb.rb module. def self.version diff --git a/lib/ipaddr.rb b/lib/ipaddr.rb index 1a1a6fb..ad817e4 100644 --- a/lib/ipaddr.rb +++ b/lib/ipaddr.rb @@ -2,12 +2,12 @@ # ipaddr.rb - A class to manipulate an IP address # # Copyright (c) 2002 Hajimu UMEMOTO <ume@mahoroba.org>. -# Copyright (c) 2007 Akinori MUSHA <knu@iDaemons.org>. +# Copyright (c) 2007, 2009, 2012 Akinori MUSHA <knu@iDaemons.org>. # All rights reserved. # # You can redistribute and/or modify it under the same terms as Ruby. # -# $Id: ipaddr.rb 31686 2011-05-22 02:21:56Z drbrain $ +# $Id: ipaddr.rb 40231 2013-04-11 02:31:05Z nobu $ # # Contact: # - Akinori MUSHA <knu@iDaemons.org> (current maintainer) @@ -17,61 +17,6 @@ # require 'socket' -unless Socket.const_defined? "AF_INET6" - class Socket < BasicSocket - # IPv6 protocol family - AF_INET6 = Object.new - end - - class << IPSocket - # Returns +true+ if +addr+ is a valid IPv4 address. - def valid_v4?(addr) - if /\A(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\Z/ =~ addr - return $~.captures.all? {|i| i.to_i < 256} - end - return false - end - - # Returns +true+ if +addr+ is a valid IPv6 address. - def valid_v6?(addr) - # IPv6 (normal) - return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*\Z/ =~ addr - return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*)?\Z/ =~ addr - return true if /\A::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*)?\Z/ =~ addr - # IPv6 (IPv4 compat) - return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:/ =~ addr && valid_v4?($') - return true if /\A[\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?/ =~ addr && valid_v4?($') - return true if /\A::([\dA-Fa-f]{1,4}(:[\dA-Fa-f]{1,4})*:)?/ =~ addr && valid_v4?($') - - false - end - - # Returns +true+ if +addr+ is either a valid IPv4 or IPv6 address. - def valid?(addr) - valid_v4?(addr) || valid_v6?(addr) - end - - alias getaddress_orig getaddress - - # Returns a +String+ based representation of a valid DNS hostname, - # IPv4 or IPv6 address. - # - # IPSocket.getaddress 'localhost' #=> "::1" - # IPSocket.getaddress 'broadcasthost' #=> "255.255.255.255" - # IPSocket.getaddress 'www.ruby-lang.org' #=> "221.186.184.68" - # IPSocket.getaddress 'www.ccc.de' #=> "2a00:1328:e102:ccc0::122" - def getaddress(s) - if valid?(s) - s - elsif /\A[-A-Za-z\d.]+\Z/ =~ s - getaddress_orig(s) - else - raise ArgumentError, "invalid address" - end - end - end -end - # IPAddr provides a set of methods to manipulate an IP address. Both IPv4 and # IPv6 are supported. # @@ -99,9 +44,44 @@ class IPAddr IN4MASK = 0xffffffff # 128 bit mask for IPv4 IN6MASK = 0xffffffffffffffffffffffffffffffff - # Formatstring for IPv6 + # Format string for IPv6 IN6FORMAT = (["%.4x"] * 8).join(':') + # Regexp _internally_ used for parsing IPv4 address. + RE_IPV4ADDRLIKE = %r{ + \A + (\d+) \. (\d+) \. (\d+) \. (\d+) + \z + }x + + # Regexp _internally_ used for parsing IPv6 address. + RE_IPV6ADDRLIKE_FULL = %r{ + \A + (?: + (?: [\da-f]{1,4} : ){7} [\da-f]{1,4} + | + ( (?: [\da-f]{1,4} : ){6} ) + (\d+) \. (\d+) \. (\d+) \. (\d+) + ) + \z + }xi + + # Regexp _internally_ used for parsing IPv6 address. + RE_IPV6ADDRLIKE_COMPRESSED = %r{ + \A + ( (?: (?: [\da-f]{1,4} : )* [\da-f]{1,4} )? ) + :: + ( (?: + ( (?: [\da-f]{1,4} : )* ) + (?: + [\da-f]{1,4} + | + (\d+) \. (\d+) \. (\d+) \. (\d+) + ) + )? ) + \z + }xi + # Returns the address family of this IP address. attr_reader :family @@ -212,7 +192,7 @@ class IPAddr str.gsub!(/\b0{1,3}([\da-f]+)\b/i, '\1') loop do - break if str.sub!(/\A0:0:0:0:0:0:0:0\Z/, '::') + break if str.sub!(/\A0:0:0:0:0:0:0:0\z/, '::') break if str.sub!(/\b0:0:0:0:0:0:0\b/, ':') break if str.sub!(/\b0:0:0:0:0:0\b/, ':') break if str.sub!(/\b0:0:0:0:0\b/, ':') @@ -223,7 +203,7 @@ class IPAddr end str.sub!(/:{3,}/, '::') - if /\A::(ffff:)?([\da-f]{1,4}):([\da-f]{1,4})\Z/i =~ str + if /\A::(ffff:)?([\da-f]{1,4}):([\da-f]{1,4})\z/i =~ str str = sprintf('::%s%d.%d.%d.%d', $1, $2.hex / 256, $2.hex % 256, $3.hex / 256, $3.hex % 256) end @@ -412,7 +392,7 @@ class IPAddr return self end - # Set current netmask to given mask. + # Set current netmask to given mask. def mask!(mask) if mask.kind_of?(String) if mask =~ /^\d+$/ @@ -490,11 +470,6 @@ class IPAddr # It seems AI_NUMERICHOST doesn't do the job. #Socket.getaddrinfo(left, nil, Socket::AF_INET6, Socket::SOCK_STREAM, nil, # Socket::AI_NUMERICHOST) - begin - IPSocket.getaddress(prefix) # test if address is valid - rescue - raise ArgumentError, "invalid address" - end @addr = @family = nil if family == Socket::AF_UNSPEC || family == Socket::AF_INET @addr = in_addr(prefix) @@ -528,26 +503,45 @@ class IPAddr end def in_addr(addr) - if addr =~ /^\d+\.\d+\.\d+\.\d+$/ - return addr.split('.').inject(0) { |i, s| - i << 8 | s.to_i - } + case addr + when Array + octets = addr + else + m = RE_IPV4ADDRLIKE.match(addr) or return nil + octets = m.captures end - return nil + octets.inject(0) { |i, s| + (n = s.to_i) < 256 or raise ArgumentError, "invalid address" + s.match(/\A0./) and raise ArgumentError, "zero-filled number is ambiguous" + i << 8 | n + } end def in6_addr(left) case left - when /^::ffff:(\d+\.\d+\.\d+\.\d+)$/i - return in_addr($1) + 0xffff00000000 - when /^::(\d+\.\d+\.\d+\.\d+)$/i - return in_addr($1) - when /[^0-9a-f:]/i - raise ArgumentError, "invalid address" - when /^(.*)::(.*)$/ - left, right = $1, $2 - else + when RE_IPV6ADDRLIKE_FULL + if $2 + addr = in_addr($~[2,4]) + left = $1 + ':' + else + addr = 0 + end right = '' + when RE_IPV6ADDRLIKE_COMPRESSED + if $4 + left.count(':') <= 6 or raise ArgumentError, "invalid address" + addr = in_addr($~[4,4]) + left = $1 + right = $3 + '0:0' + else + left.count(':') <= ($1.empty? || $2.empty? ? 8 : 7) or + raise InvalidAddressError, "invalid address" + left = $1 + right = $2 + addr = 0 + end + else + raise ArgumentError, "invalid address" end l = left.split(':') r = right.split(':') @@ -555,9 +549,9 @@ class IPAddr if rest < 0 return nil end - return (l + Array.new(rest, '0') + r).inject(0) { |i, s| + (l + Array.new(rest, '0') + r).inject(0) { |i, s| i << 16 | s.hex - } + } | addr end def addr_mask(addr) @@ -599,6 +593,55 @@ class IPAddr end +unless Socket.const_defined? "AF_INET6" + class Socket < BasicSocket + # IPv6 protocol family + AF_INET6 = Object.new + end + + class << IPSocket + private + + def valid_v6?(addr) + case addr + when IPAddr::RE_IPV6ADDRLIKE_FULL + if $2 + $~[2,4].all? {|i| i.to_i < 256 } + else + true + end + when IPAddr::RE_IPV6ADDRLIKE_COMPRESSED + if $4 + addr.count(':') <= 6 && $~[4,4].all? {|i| i.to_i < 256} + else + addr.count(':') <= 7 + end + else + false + end + end + + alias getaddress_orig getaddress + + public + + # Returns a +String+ based representation of a valid DNS hostname, + # IPv4 or IPv6 address. + # + # IPSocket.getaddress 'localhost' #=> "::1" + # IPSocket.getaddress 'broadcasthost' #=> "255.255.255.255" + # IPSocket.getaddress 'www.ruby-lang.org' #=> "221.186.184.68" + # IPSocket.getaddress 'www.ccc.de' #=> "2a00:1328:e102:ccc0::122" + def getaddress(s) + if valid_v6?(s) + s + else + getaddress_orig(s) + end + end + end +end + if $0 == __FILE__ eval DATA.read, nil, $0, __LINE__+4 end @@ -609,10 +652,17 @@ require 'test/unit' class TC_IPAddr < Test::Unit::TestCase def test_s_new - assert_nothing_raised { - IPAddr.new("3FFE:505:ffff::/48") - IPAddr.new("0:0:0:1::") - IPAddr.new("2001:200:300::/48") + [ + ["3FFE:505:ffff::/48"], + ["0:0:0:1::"], + ["2001:200:300::/48"], + ["2001:200:300::192.168.1.2/48"], + ["1:2:3:4:5:6:7::"], + ["::2:3:4:5:6:7:8"], + ].each { |args| + assert_nothing_raised { + IPAddr.new(*args) + } } a = IPAddr.new @@ -665,11 +715,14 @@ class TC_IPAddr < Test::Unit::TestCase assert_equal("2001:200:300::", IPAddr.new("2001:200:300::/48").to_s) assert_equal("2001:200:300::", IPAddr.new("[2001:200:300::]/48").to_s) + assert_equal("1:2:3:4:5:6:7:0", IPAddr.new("1:2:3:4:5:6:7::").to_s) + assert_equal("0:2:3:4:5:6:7:8", IPAddr.new("::2:3:4:5:6:7:8").to_s) [ + ["192.168.0.256"], + ["192.168.0.011"], ["fe80::1%fxp0"], ["::1/255.255.255.0"], - ["::1:192.168.1.2/120"], [IPAddr.new("::1").to_i], ["::ffff:192.168.1.2/120", Socket::AF_INET], ["[192.168.1.2]/120"], @@ -811,7 +864,9 @@ class TC_Operator < Test::Unit::TestCase end def test_equal - assert_equal(true, @a == IPAddr.new("3ffe:505:2::")) + assert_equal(true, @a == IPAddr.new("3FFE:505:2::")) + assert_equal(true, @a == IPAddr.new("3ffe:0505:0002::")) + assert_equal(true, @a == IPAddr.new("3ffe:0505:0002:0:0:0:0:0")) assert_equal(false, @a == IPAddr.new("3ffe:505:3::")) assert_equal(true, @a != IPAddr.new("3ffe:505:3::")) assert_equal(false, @a != IPAddr.new("3ffe:505:2::")) diff --git a/lib/irb/magic-file.rb b/lib/irb/magic-file.rb index 8612620..339ed60 100644 --- a/lib/irb/magic-file.rb +++ b/lib/irb/magic-file.rb @@ -8,9 +8,10 @@ module IRB line = io.gets line = io.gets if line[0,2] == "#!" encoding = detect_encoding(line) + internal_encoding = encoding encoding ||= default_src_encoding io.rewind - io.set_encoding(encoding, nil) + io.set_encoding(encoding, internal_encoding) if block_given? begin diff --git a/lib/mkmf.rb b/lib/mkmf.rb index 8254cd3..8f4e69e 100644 --- a/lib/mkmf.rb +++ b/lib/mkmf.rb @@ -619,14 +619,14 @@ def try_func(func, libs, headers = nil, &b) try_link(<<"SRC", libs, &b) or #{headers} /*top*/ -#{MAIN_DOES_NOTHING} int t() { #{decltype["volatile p"]}; p = (#{decltype[]})#{func}; return 0; } +#{MAIN_DOES_NOTHING "t"} SRC call && try_link(<<"SRC", libs, &b) #{headers} /*top*/ -#{MAIN_DOES_NOTHING} int t() { #{func}(); return 0; } +#{MAIN_DOES_NOTHING "t"} SRC end @@ -636,8 +636,8 @@ def try_var(var, headers = nil, &b) try_compile(<<"SRC", &b) #{headers} /*top*/ -#{MAIN_DOES_NOTHING} int t() { const volatile void *volatile p; p = &(&#{var})[0]; return 0; } +#{MAIN_DOES_NOTHING "t"} SRC end @@ -1002,8 +1002,8 @@ def have_struct_member(type, member, headers = nil, &b) if try_compile(<<"SRC", &b) #{cpp_include(headers)} /*top*/ -#{MAIN_DOES_NOTHING} int s = (char *)&((#{type}*)0)->#{member} - (char *)0; +#{MAIN_DOES_NOTHING "s"} SRC $defs.push(format("-DHAVE_%s_%s", type.tr_cpp, member.tr_cpp)) $defs.push(format("-DHAVE_ST_%s", member.tr_cpp)) # backward compatibility @@ -1243,8 +1243,8 @@ def scalar_ptr_type?(type, member = nil, headers = nil, &b) #{cpp_include(headers)} /*top*/ volatile #{type} conftestval; -#{MAIN_DOES_NOTHING} int t() {return (int)(1-*(conftestval#{member ? ".#{member}" : ""}));} +#{MAIN_DOES_NOTHING "t"} SRC end @@ -1255,8 +1255,8 @@ def scalar_type?(type, member = nil, headers = nil, &b) #{cpp_include(headers)} /*top*/ volatile #{type} conftestval; -#{MAIN_DOES_NOTHING} int t() {return (int)(1-(conftestval#{member ? ".#{member}" : ""}));} +#{MAIN_DOES_NOTHING "t"} SRC end @@ -1526,7 +1526,7 @@ def dir_config(target, idefault=nil, ldefault=nil) idir = with_config(target + "-include", idefault) $arg_config.last[1] ||= "${#{target}-dir}/include" ldir = with_config(target + "-lib", ldefault) - $arg_config.last[1] ||= "${#{target}-dir}/lib" + $arg_config.last[1] ||= "${#{target}-dir}/#{@libdir_basename}" idirs = idir ? Array === idir ? idir.dup : idir.split(File::PATH_SEPARATOR) : [] if defaults @@ -1543,7 +1543,7 @@ def dir_config(target, idefault=nil, ldefault=nil) ldirs = ldir ? Array === ldir ? ldir.dup : ldir.split(File::PATH_SEPARATOR) : [] if defaults - ldirs.concat(defaults.collect {|d| d + "/lib"}) + ldirs.concat(defaults.collect {|d| "#{d}/#{@libdir_basename}"}) ldir = ([ldir] + ldirs).compact.join(File::PATH_SEPARATOR) end $LIBPATH = ldirs | $LIBPATH @@ -1687,8 +1687,9 @@ LIBRUBY = #{CONFIG['LIBRUBY']} LIBRUBY_A = #{CONFIG['LIBRUBY_A']} LIBRUBYARG_SHARED = #$LIBRUBYARG_SHARED LIBRUBYARG_STATIC = #$LIBRUBYARG_STATIC -OUTFLAG = #{OUTFLAG} -COUTFLAG = #{COUTFLAG} +empty = +OUTFLAG = #{OUTFLAG}$(empty) +COUTFLAG = #{COUTFLAG}$(empty) RUBY_EXTCONF_H = #{$extconf_h} cflags = #{CONFIG['cflags']} @@ -1701,7 +1702,7 @@ DEFS = #{CONFIG['DEFS']} CPPFLAGS = #{extconf_h}#{$CPPFLAGS} CXXFLAGS = $(CFLAGS) #{CONFIG['CXXFLAGS']} ldflags = #{$LDFLAGS} -dldflags = #{$DLDFLAGS} +dldflags = #{$DLDFLAGS} #{CONFIG['EXTDLDFLAGS']} ARCH_FLAG = #{$ARCH_FLAG} DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG) LDSHARED = #{CONFIG['LDSHARED']} @@ -1725,6 +1726,7 @@ INSTALL = #{config_string('INSTALL', &possible_command) || '@$(RUBY) -run -e ins INSTALL_PROG = #{config_string('INSTALL_PROG') || '$(INSTALL) -m 0755'} INSTALL_DATA = #{config_string('INSTALL_DATA') || '$(INSTALL) -m 0644'} COPY = #{config_string('CP', &possible_command) || '@$(RUBY) -run -e cp -- -v'} +TOUCH = exit > #### End of system configuration section. #### @@ -1741,6 +1743,11 @@ preload = #{defined?($preload) && $preload ? $preload.join(' ') : ''} end mk end + +def timestamp_file(name) + name = name.gsub(/(\$[({]|[})])|(\/+)|[^-.\w]+/) {$1 ? "" : $2 ? ".-." : "_"} + "./.#{name}.time" +end # :startdoc: # creates a stub Makefile. @@ -1918,7 +1925,7 @@ def create_makefile(target, srcprefix = nil) makedef = %{-pe "$_.sub!(/^(?=\\w)/,'#{EXPORT_PREFIX}') unless 1../^EXPORTS$/i"} end else - makedef = %{-e "puts 'EXPORTS', '#{EXPORT_PREFIX}' + 'Init_$(TARGET)'.sub(/\\..*\\z/,'')"} + makedef = %{-e "puts 'EXPORTS', '$(TARGET_ENTRY)'"} end if makedef $cleanfiles << '$(DEFFILE)' @@ -1962,6 +1969,8 @@ LIBS = #{$LIBRUBYARG} #{$libs} #{$LIBS} SRCS = #{srcs.collect(&File.method(:basename)).join(' ')} OBJS = #{$objs.join(" ")} TARGET = #{target} +TARGET_NAME = #{target && target[/\A\w+/]} +TARGET_ENTRY = #{EXPORT_PREFIX || ''}Init_$(TARGET_NAME) DLLIB = #{dllib} EXTSTATIC = #{$static || ""} STATIC_LIB = #{staticlib unless $static.nil?} @@ -2002,18 +2011,20 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""} if target f = "$(DLLIB)" dest = "#{dir}/#{f}" - mfile.puts dir, "install-so: #{dest}" + mfile.puts dest if $extout mfile.print "clean-so::\n" - mfile.print "\t@-$(RM) #{fseprepl[dest]}\n" - mfile.print "\t@-$(RMDIRS) #{fseprepl[dir]}#{$ignore_error}\n" + mfile.print "\t-$(Q)$(RM) #{fseprepl[dest]}\n" + mfile.print "\t-$(Q)$(RMDIRS) #{fseprepl[dir]}#{$ignore_error}\n" else - mfile.print "#{dest}: #{f}\n\t@-$(MAKEDIRS) $(@D#{sep})\n" + mfile.print "#{dest}: #{f}\n\t-$(Q)$(MAKEDIRS) $(@D#{sep})\n" mfile.print "\t$(INSTALL_PROG) #{fseprepl[f]} $(@D#{sep})\n" if defined?($installed_list) mfile.print "\t@echo #{dir}/#{File.basename(f)}>>$(INSTALLED_LIST)\n" end end + mfile.print "clean-static::\n" + mfile.print "\t-$(Q)$(RM) $(STATIC_LIB)\n" else mfile.puts "Makefile" end @@ -2026,7 +2037,7 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""} for dir, *files in files unless dirs.include?(dir) dirs << dir - mfile.print "pre-install-rb#{sfx}: #{dir}\n" + mfile.print "pre-install-rb#{sfx}: #{timestamp_file(dir)}\n" end for f in files dest = "#{dir}/#{File.basename(f)}" @@ -2055,7 +2066,10 @@ static: $(STATIC_LIB)#{$extout ? " install-rb" : ""} end end dirs.unshift(sodir) if target and !dirs.include?(sodir) - dirs.each {|d| mfile.print "#{d}:\n\t$(Q) $(MAKEDIRS) $@\n"} + dirs.each do |d| + t = timestamp_file(d) + mfile.print "#{t}:\n\t$(Q) $(MAKEDIRS) #{d}\n\t$(Q) $(TOUCH) $@\n" + end mfile.print <<-SITEINSTALL @@ -2088,10 +2102,11 @@ site-install-rb: install-rb mfile.print "$(RUBYARCHDIR)/" if $extout mfile.print "$(DLLIB): " mfile.print "$(DEFFILE) " if makedef - mfile.print "$(OBJS) Makefile\n" + mfile.print "$(OBJS) Makefile" + mfile.print " #{timestamp_file('$(RUBYARCHDIR)')}" if $extout + mfile.print "\n" mfile.print "\t$(ECHO) linking shared-object #{target_prefix.sub(/\A\/(.*)/, '\1/')}$(DLLIB)\n" - mfile.print "\t@-$(RM) $(@#{sep})\n" - mfile.print "\t@-$(MAKEDIRS) $(@D)\n" if $extout + mfile.print "\t-$(Q)$(RM) $(@#{sep})\n" link_so = LINK_SO.gsub(/^/, "\t$(Q) ") if srcs.any?(&%r"\.(?:#{CXX_EXT.join('|')})\z".method(:===)) link_so = link_so.sub(/\bLDSHARED\b/, '\&XX') @@ -2185,6 +2200,8 @@ def init_mkmf(config = CONFIG, rbconfig = RbConfig::CONFIG) $extout ||= nil $extout_prefix ||= nil + @libdir_basename = config["libdir"] && config["libdir"][/\A\$\(exec_prefix\)\/(.*)/, 1] or "lib" + $arg_config.clear dir_config("opt") end @@ -2209,6 +2226,19 @@ def mkmf_failed(path) end end +def MAIN_DOES_NOTHING(*refs) + src = MAIN_DOES_NOTHING + unless refs.empty? + src = src.sub(/\{/) do + $& + + "\n if (argc > 1000000) {\n" + + refs.map {|n|" printf(\"%p\", &#{n});\n"}.join("") + + " }\n" + end + end + src +end + # :startdoc: init_mkmf @@ -2275,17 +2305,18 @@ LINK_SO = config_string('LINK_SO') || LIBPATHFLAG = config_string('LIBPATHFLAG') || ' -L"%s"' RPATHFLAG = config_string('RPATHFLAG') || '' LIBARG = config_string('LIBARG') || '-l%s' -MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || 'int main() {return 0;}' +MAIN_DOES_NOTHING = config_string('MAIN_DOES_NOTHING') || "int main(int argc, char **argv)\n{\n return 0;\n}" UNIVERSAL_INTS = config_string('UNIVERSAL_INTS') {|s| Shellwords.shellwords(s)} || %w[int short long long\ long] sep = config_string('BUILD_FILE_SEPARATOR') {|s| ":/=#{s}" if s != "/"} || "" CLEANINGS = " +clean-static:: clean-rb-default:: clean-rb:: clean-so:: -clean: clean-so clean-rb-default clean-rb -\t\t@-$(RM) $(CLEANLIBS#{sep}) $(CLEANOBJS#{sep}) $(CLEANFILES#{sep}) +clean: clean-so clean-static clean-rb-default clean-rb +\t\t-$(Q)$(RM) $(CLEANLIBS#{sep}) $(CLEANOBJS#{sep}) $(CLEANFILES#{sep}) .*.time distclean-rb-default:: distclean-rb:: diff --git a/lib/net/http.rb b/lib/net/http.rb index 1432a8f..a30204b 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -361,7 +361,7 @@ module Net #:nodoc: class HTTP < Protocol # :stopdoc: - Revision = %q$Revision: 33089 $.split[1] + Revision = %q$Revision: 40712 $.split[1] HTTPVersion = '1.1' begin require 'zlib' @@ -623,13 +623,13 @@ module Net #:nodoc: # Number of seconds to wait for the connection to open. Any number # may be used, including Floats for fractional seconds. If the HTTP # object cannot open a connection in this many seconds, it raises a - # TimeoutError exception. + # TimeoutError exception. The default value is +nil+. attr_accessor :open_timeout # Number of seconds to wait for one block to be read (via one read(2) # call). Any number may be used, including Floats for fractional # seconds. If the HTTP object cannot read data in this many seconds, - # it raises a TimeoutError exception. + # it raises a TimeoutError exception. The default value is 60 seconds. attr_reader :read_timeout # Setter for the read_timeout attribute. @@ -638,8 +638,9 @@ module Net #:nodoc: @read_timeout = sec end - # Seconds to wait for 100 Continue response. If the HTTP object does not - # receive a response in this many seconds it sends the request body. + # Seconds to wait for 100 Continue response. If the HTTP object does not + # receive a response in this many seconds it sends the request body. The + # default value is +nil+. attr_reader :continue_timeout # Setter for the continue_timeout attribute. diff --git a/lib/net/imap.rb b/lib/net/imap.rb index e0815a1..df9ee8c 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -1725,7 +1725,7 @@ module Net # rights:: The access rights the indicated user has to the # mailbox. # - MailboxACLItem = Struct.new(:user, :rights) + MailboxACLItem = Struct.new(:user, :rights, :mailbox) # Net::IMAP::StatusData represents contents of the STATUS response. # @@ -2722,6 +2722,7 @@ module Net token = match(T_ATOM) name = token.value.upcase match(T_SPACE) + mailbox = astring data = [] token = lookahead if token.symbol == T_SPACE @@ -2737,8 +2738,7 @@ module Net user = astring match(T_SPACE) rights = astring - ##XXX data.push([user, rights]) - data.push(MailboxACLItem.new(user, rights)) + data.push(MailboxACLItem.new(user, rights, mailbox)) end end return UntaggedResponse.new(name, data, @str) @@ -2869,6 +2869,7 @@ module Net break when T_SPACE shift_token + next end data.push(atom.upcase) end diff --git a/lib/net/pop.rb b/lib/net/pop.rb index dd6d81f..5728d6b 100644 --- a/lib/net/pop.rb +++ b/lib/net/pop.rb @@ -15,7 +15,7 @@ # NOTE: You can find Japanese version of this document at: # http://www.ruby-lang.org/ja/man/html/net_pop.html # -# $Id: pop.rb 31728 2011-05-25 00:30:04Z drbrain $ +# $Id: pop.rb 40712 2013-05-14 01:33:34Z usa $ # # See Net::POP3 for documentation. # @@ -197,7 +197,7 @@ module Net class POP3 < Protocol # svn revision of this library - Revision = %q$Revision: 31728 $.split[1] + Revision = %q$Revision: 40712 $.split[1] # # Class Parameters @@ -498,12 +498,12 @@ module Net # Seconds to wait until a connection is opened. # If the POP3 object cannot open a connection within this time, - # it raises a TimeoutError exception. + # it raises a TimeoutError exception. The default value is 30 seconds. attr_accessor :open_timeout # Seconds to wait until reading one block (by one read(1) call). # If the POP3 object cannot complete a read() within this time, - # it raises a TimeoutError exception. + # it raises a TimeoutError exception. The default value is 60 seconds. attr_reader :read_timeout # Set the read timeout. diff --git a/lib/net/protocol.rb b/lib/net/protocol.rb index 230b80a..668a4bd 100644 --- a/lib/net/protocol.rb +++ b/lib/net/protocol.rb @@ -11,7 +11,7 @@ # modify this program under the same terms as Ruby itself, # Ruby Distribute License or GNU General Public License. # -# $Id: protocol.rb 31860 2011-05-31 08:10:42Z nahi $ +# $Id: protocol.rb 38830 2013-01-15 07:23:48Z usa $ #++ # # WARNING: This file is going to remove. @@ -310,7 +310,7 @@ module Net # :nodoc: def each_crlf_line(src) buffer_filling(@wbuf, src) do - while line = @wbuf.slice!(/\A.*(?:\n|\r\n|\r(?!\z))/n) + while line = @wbuf.slice!(/\A[^\r\n]*(?:\n|\r(?:\n|(?!\z)))/) yield line.chomp("\n") + "\r\n" end end diff --git a/lib/net/smtp.rb b/lib/net/smtp.rb index 0ec07e8..58db6a1 100644 --- a/lib/net/smtp.rb +++ b/lib/net/smtp.rb @@ -14,7 +14,7 @@ # NOTE: You can find Japanese version of this document at: # http://www.ruby-lang.org/ja/man/html/net_smtp.html # -# $Id: smtp.rb 31710 2011-05-23 00:21:10Z drbrain $ +# $Id: smtp.rb 40712 2013-05-14 01:33:34Z usa $ # # See Net::SMTP for documentation. # @@ -172,7 +172,7 @@ module Net # class SMTP - Revision = %q$Revision: 31710 $.split[1] + Revision = %q$Revision: 40712 $.split[1] # The default SMTP port number, 25. def SMTP.default_port @@ -364,12 +364,12 @@ module Net # Seconds to wait while attempting to open a connection. # If the connection cannot be opened within this time, a - # TimeoutError is raised. + # TimeoutError is raised. The default value is 30 seconds. attr_accessor :open_timeout # Seconds to wait while reading one block (by one read(2) call). # If the read(2) call does not complete within this time, a - # TimeoutError is raised. + # TimeoutError is raised. The default value is 60 seconds. attr_reader :read_timeout # Set the number of seconds to wait until timing-out a read(2) diff --git a/lib/optparse.rb b/lib/optparse.rb index 85fbd19..68969d9 100644 --- a/lib/optparse.rb +++ b/lib/optparse.rb @@ -209,7 +209,7 @@ # class OptionParser # :stopdoc: - RCSID = %w$Id: optparse.rb 34316 2012-01-16 07:42:01Z nobu $[1..-1].each {|s| s.freeze}.freeze + RCSID = %w$Id: optparse.rb 35469 2012-04-24 20:57:07Z nobu $[1..-1].each {|s| s.freeze}.freeze Version = (RCSID[1].split('.').collect {|s| s.to_i}.extend(Comparable).freeze if RCSID[1]) LastModified = (Time.gm(*RCSID[2, 2].join('-').scan(/\d+/).collect {|s| s.to_i}) if RCSID[2]) Release = RCSID[2] @@ -1065,13 +1065,13 @@ XXX # # Returns option summary string. # - def help; summarize(banner.to_s.sub(/\n?\z/, "\n")) end + def help; summarize("#{banner}".sub(/\n?\z/, "\n")) end alias to_s help # # Returns option summary list. # - def to_a; summarize(banner.to_a.dup) end + def to_a; summarize("#{banner}".split(/^/)) end # # Checks if an argument is given twice, in which case an ArgumentError is diff --git a/lib/rdoc.rb b/lib/rdoc.rb index aaa1aaa..50f3f54 100644 --- a/lib/rdoc.rb +++ b/lib/rdoc.rb @@ -104,7 +104,7 @@ module RDoc ## # RDoc version you are using - VERSION = '3.9.4' + VERSION = '3.9.5' ## # Method visibilities diff --git a/lib/rdoc/generator/template/darkfish/js/darkfish.js b/lib/rdoc/generator/template/darkfish/js/darkfish.js index 84565c1..7a2f44c 100644 --- a/lib/rdoc/generator/template/darkfish/js/darkfish.js +++ b/lib/rdoc/generator/template/darkfish/js/darkfish.js @@ -73,13 +73,15 @@ function hookQuickSearch() { function highlightTarget( anchor ) { console.debug( "Highlighting target '%s'.", anchor ); - $("a[name=" + anchor + "]").each( function() { - if ( !$(this).parent().parent().hasClass('target-section') ) { - console.debug( "Wrapping the target-section" ); - $('div.method-detail').unwrap( 'div.target-section' ); - $(this).parent().wrap( '<div class="target-section"></div>' ); - } else { - console.debug( "Already wrapped." ); + $("a[name]").each( function() { + if ( $(this).attr("name") == anchor ) { + if ( !$(this).parent().parent().hasClass('target-section') ) { + console.debug( "Wrapping the target-section" ); + $('div.method-detail').unwrap( 'div.target-section' ); + $(this).parent().wrap( '<div class="target-section"></div>' ); + } else { + console.debug( "Already wrapped." ); + } } }); }; diff --git a/lib/rexml/document.rb b/lib/rexml/document.rb index 96db53b..b945a5b 100644 --- a/lib/rexml/document.rb +++ b/lib/rexml/document.rb @@ -217,6 +217,20 @@ module REXML return @@entity_expansion_limit end + # Set the entity expansion limit. By default the limit is set to 10240. + # + # Deprecated. Use REXML.entity_expansion_text_limit= instead. + def Document::entity_expansion_text_limit=( val ) + REXML.entity_expansion_text_limit = val + end + + # Get the entity expansion limit. By default the limit is set to 10000. + # + # Deprecated. Use REXML.entity_expansion_text_limit instead. + def Document::entity_expansion_text_limit + return REXML.entity_expansion_text_limit + end + attr_reader :entity_expansion_count def record_entity_expansion diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb index 95afd7a..2df26b8 100644 --- a/lib/rexml/parsers/baseparser.rb +++ b/lib/rexml/parsers/baseparser.rb @@ -342,7 +342,7 @@ module REXML md = @source.match( COMMENT_PATTERN, true ) case md[1] - when /--/, /-$/ + when /--/, /-\z/ raise REXML::ParseException.new("Malformed comment", @source) end diff --git a/lib/rexml/rexml.rb b/lib/rexml/rexml.rb index 2353584..d2ad254 100644 --- a/lib/rexml/rexml.rb +++ b/lib/rexml/rexml.rb @@ -24,8 +24,20 @@ module REXML COPYRIGHT = "Copyright © 2001-2008 Sean Russell <ser@germane-software.com>" DATE = "2008/019" VERSION = "3.1.7.3" - REVISION = %w$Revision: 26193 $[1] || '' + REVISION = %w$Revision: 39977 $[1] || '' Copyright = COPYRIGHT Version = VERSION + + @@entity_expansion_text_limit = 10_240 + + # Set the entity expansion limit. By default the limit is set to 10240. + def self.entity_expansion_text_limit=( val ) + @@entity_expansion_text_limit = val + end + + # Get the entity expansion limit. By default the limit is set to 10240. + def self.entity_expansion_text_limit + return @@entity_expansion_text_limit + end end diff --git a/lib/rexml/text.rb b/lib/rexml/text.rb index 6623c0c..7b00b0f 100644 --- a/lib/rexml/text.rb +++ b/lib/rexml/text.rb @@ -1,3 +1,4 @@ +require 'rexml/rexml' require 'rexml/entity' require 'rexml/doctype' require 'rexml/child' @@ -380,25 +381,35 @@ module REXML # Unescapes all possible entities def Text::unnormalize( string, doctype=nil, filter=nil, illegal=nil ) + sum = 0 string.gsub( /\r\n?/, "\n" ).gsub( REFERENCE ) { - ref = $& - if ref[1] == ?# - if ref[2] == ?x - [ref[3...-1].to_i(16)].pack('U*') - else - [ref[2...-1].to_i].pack('U*') - end - elsif ref == '&' - '&' - elsif filter and filter.include?( ref[1...-1] ) - ref - elsif doctype - doctype.entity( ref[1...-1] ) or ref + s = Text.expand($&, doctype, filter) + if sum + s.bytesize > REXML.entity_expansion_text_limit + raise "entity expansion has grown too large" else - entity_value = DocType::DEFAULT_ENTITIES[ ref[1...-1] ] - entity_value ? entity_value.value : ref + sum += s.bytesize end + s } end + + def Text.expand(ref, doctype, filter) + if ref[1] == ?# + if ref[2] == ?x + [ref[3...-1].to_i(16)].pack('U*') + else + [ref[2...-1].to_i].pack('U*') + end + elsif ref == '&' + '&' + elsif filter and filter.include?( ref[1...-1] ) + ref + elsif doctype + doctype.entity( ref[1...-1] ) or ref + else + entity_value = DocType::DEFAULT_ENTITIES[ ref[1...-1] ] + entity_value ? entity_value.value : ref + end + end end end diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb index 31fb120..514316f 100644 --- a/lib/rubygems/installer.rb +++ b/lib/rubygems/installer.rb @@ -435,7 +435,13 @@ class Gem::Installer def check_that_user_bin_dir_is_in_path user_bin_dir = @bin_dir || Gem.bindir(gem_home) user_bin_dir.gsub!(File::SEPARATOR, File::ALT_SEPARATOR) if File::ALT_SEPARATOR - unless ENV['PATH'].split(File::PATH_SEPARATOR).include? user_bin_dir then + path = ENV['PATH'] + if Gem.win_platform? then + path = path.downcase + user_bin_dir = user_bin_dir.downcase + end + + unless path.split(File::PATH_SEPARATOR).include? user_bin_dir then unless self.class.path_warning then alert_warning "You don't have #{user_bin_dir} in your PATH,\n\t gem executables will not run." self.class.path_warning = true diff --git a/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem b/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem deleted file mode 100644 index 580158f..0000000 --- a/lib/rubygems/ssl_certs/AddTrustExternalCARoot.pem +++ /dev/null @@ -1,90 +0,0 @@ -This CA certificate is for verifying HTTPS connection to; - - https://rubygems.org/ (obtained by RubyGems team) - -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 1 (0x1) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=SE, O=AddTrust AB, OU=AddTrust External TTP Network, CN=AddTrust External CA Root - Validity - Not Before: May 30 10:48:38 2000 GMT - Not After : May 30 10:48:38 2020 GMT - Subject: C=SE, O=AddTrust AB, OU=AddTrust External TTP Network, CN=AddTrust External CA Root - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (2048 bit) - Modulus: - 00:b7:f7:1a:33:e6:f2:00:04:2d:39:e0:4e:5b:ed: - 1f:bc:6c:0f:cd:b5:fa:23:b6:ce:de:9b:11:33:97: - a4:29:4c:7d:93:9f:bd:4a:bc:93:ed:03:1a:e3:8f: - cf:e5:6d:50:5a:d6:97:29:94:5a:80:b0:49:7a:db: - 2e:95:fd:b8:ca:bf:37:38:2d:1e:3e:91:41:ad:70: - 56:c7:f0:4f:3f:e8:32:9e:74:ca:c8:90:54:e9:c6: - 5f:0f:78:9d:9a:40:3c:0e:ac:61:aa:5e:14:8f:9e: - 87:a1:6a:50:dc:d7:9a:4e:af:05:b3:a6:71:94:9c: - 71:b3:50:60:0a:c7:13:9d:38:07:86:02:a8:e9:a8: - 69:26:18:90:ab:4c:b0:4f:23:ab:3a:4f:84:d8:df: - ce:9f:e1:69:6f:bb:d7:42:d7:6b:44:e4:c7:ad:ee: - 6d:41:5f:72:5a:71:08:37:b3:79:65:a4:59:a0:94: - 37:f7:00:2f:0d:c2:92:72:da:d0:38:72:db:14:a8: - 45:c4:5d:2a:7d:b7:b4:d6:c4:ee:ac:cd:13:44:b7: - c9:2b:dd:43:00:25:fa:61:b9:69:6a:58:23:11:b7: - a7:33:8f:56:75:59:f5:cd:29:d7:46:b7:0a:2b:65: - b6:d3:42:6f:15:b2:b8:7b:fb:ef:e9:5d:53:d5:34: - 5a:27 - Exponent: 65537 (0x10001) - X509v3 extensions: - X509v3 Subject Key Identifier: - AD:BD:98:7A:34:B4:26:F7:FA:C4:26:54:EF:03:BD:E0:24:CB:54:1A - X509v3 Key Usage: - Certificate Sign, CRL Sign - X509v3 Basic Constraints: critical - CA:TRUE - X509v3 Authority Key Identifier: - keyid:AD:BD:98:7A:34:B4:26:F7:FA:C4:26:54:EF:03:BD:E0:24:CB:54:1A - DirName:/C=SE/O=AddTrust AB/OU=AddTrust External TTP Network/CN=AddTrust External CA Root - serial:01 - - Signature Algorithm: sha1WithRSAEncryption - b0:9b:e0:85:25:c2:d6:23:e2:0f:96:06:92:9d:41:98:9c:d9: - 84:79:81:d9:1e:5b:14:07:23:36:65:8f:b0:d8:77:bb:ac:41: - 6c:47:60:83:51:b0:f9:32:3d:e7:fc:f6:26:13:c7:80:16:a5: - bf:5a:fc:87:cf:78:79:89:21:9a:e2:4c:07:0a:86:35:bc:f2: - de:51:c4:d2:96:b7:dc:7e:4e:ee:70:fd:1c:39:eb:0c:02:51: - 14:2d:8e:bd:16:e0:c1:df:46:75:e7:24:ad:ec:f4:42:b4:85: - 93:70:10:67:ba:9d:06:35:4a:18:d3:2b:7a:cc:51:42:a1:7a: - 63:d1:e6:bb:a1:c5:2b:c2:36:be:13:0d:e6:bd:63:7e:79:7b: - a7:09:0d:40:ab:6a:dd:8f:8a:c3:f6:f6:8c:1a:42:05:51:d4: - 45:f5:9f:a7:62:21:68:15:20:43:3c:99:e7:7c:bd:24:d8:a9: - 91:17:73:88:3f:56:1b:31:38:18:b4:71:0f:9a:cd:c8:0e:9e: - 8e:2e:1b:e1:8c:98:83:cb:1f:31:f1:44:4c:c6:04:73:49:76: - 60:0f:c7:f8:bd:17:80:6b:2e:e9:cc:4c:0e:5a:9a:79:0f:20: - 0a:2e:d5:9e:63:26:1e:55:92:94:d8:82:17:5a:7b:d0:bc:c7: - 8f:4e:86:04 - ------BEGIN CERTIFICATE----- -MIIENjCCAx6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBvMQswCQYDVQQGEwJTRTEU -MBIGA1UEChMLQWRkVHJ1c3QgQUIxJjAkBgNVBAsTHUFkZFRydXN0IEV4dGVybmFs -IFRUUCBOZXR3b3JrMSIwIAYDVQQDExlBZGRUcnVzdCBFeHRlcm5hbCBDQSBSb290 -MB4XDTAwMDUzMDEwNDgzOFoXDTIwMDUzMDEwNDgzOFowbzELMAkGA1UEBhMCU0Ux -FDASBgNVBAoTC0FkZFRydXN0IEFCMSYwJAYDVQQLEx1BZGRUcnVzdCBFeHRlcm5h -bCBUVFAgTmV0d29yazEiMCAGA1UEAxMZQWRkVHJ1c3QgRXh0ZXJuYWwgQ0EgUm9v -dDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALf3GjPm8gAELTngTlvt -H7xsD821+iO2zt6bETOXpClMfZOfvUq8k+0DGuOPz+VtUFrWlymUWoCwSXrbLpX9 -uMq/NzgtHj6RQa1wVsfwTz/oMp50ysiQVOnGXw94nZpAPA6sYapeFI+eh6FqUNzX -mk6vBbOmcZSccbNQYArHE504B4YCqOmoaSYYkKtMsE8jqzpPhNjfzp/haW+710LX -a0Tkx63ubUFfclpxCDezeWWkWaCUN/cALw3CknLa0Dhy2xSoRcRdKn23tNbE7qzN -E0S3ySvdQwAl+mG5aWpYIxG3pzOPVnVZ9c0p10a3CitlttNCbxWyuHv77+ldU9U0 -WicCAwEAAaOB3DCB2TAdBgNVHQ4EFgQUrb2YejS0Jvf6xCZU7wO94CTLVBowCwYD -VR0PBAQDAgEGMA8GA1UdEwEB/wQFMAMBAf8wgZkGA1UdIwSBkTCBjoAUrb2YejS0 -Jvf6xCZU7wO94CTLVBqhc6RxMG8xCzAJBgNVBAYTAlNFMRQwEgYDVQQKEwtBZGRU -cnVzdCBBQjEmMCQGA1UECxMdQWRkVHJ1c3QgRXh0ZXJuYWwgVFRQIE5ldHdvcmsx -IjAgBgNVBAMTGUFkZFRydXN0IEV4dGVybmFsIENBIFJvb3SCAQEwDQYJKoZIhvcN -AQEFBQADggEBALCb4IUlwtYj4g+WBpKdQZic2YR5gdkeWxQHIzZlj7DYd7usQWxH -YINRsPkyPef89iYTx4AWpb9a/IfPeHmJIZriTAcKhjW88t5RxNKWt9x+Tu5w/Rw5 -6wwCURQtjr0W4MHfRnXnJK3s9EK0hZNwEGe6nQY1ShjTK3rMUUKhemPR5ruhxSvC -Nr4TDea9Y355e6cJDUCrat2PisP29owaQgVR1EX1n6diIWgVIEM8med8vSTYqZEX -c4g/VhsxOBi0cQ+azcgOno4uG+GMmIPLHzHxREzGBHNJdmAPx/i9F4BrLunMTA5a -mnkPIAou1Z5jJh5VkpTYghdae9C8x49OhgQ= ------END CERTIFICATE----- diff --git a/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem b/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem deleted file mode 100644 index b48d9cd..0000000 --- a/lib/rubygems/ssl_certs/Entrust_net-Secure-Server-Certification-Authority.pem +++ /dev/null @@ -1,90 +0,0 @@ -This CA certificate is for verifying HTTPS connection to; - - https://d2chzxaqi4y7f8.cloudfront.net/ (prepared by AWS) - -Certificate: - Data: - Version: 3 (0x2) - Serial Number: 927650371 (0x374ad243) - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=US, O=Entrust.net, OU=www.entrust.net/CPS incorp. by ref. (limits liab.), OU=(c) 1999 Entrust.net Limited, CN=Entrust.net Secure Server Certification Authority - Validity - Not Before: May 25 16:09:40 1999 GMT - Not After : May 25 16:39:40 2019 GMT - Subject: C=US, O=Entrust.net, OU=www.entrust.net/CPS incorp. by ref. (limits liab.), OU=(c) 1999 Entrust.net Limited, CN=Entrust.net Secure Server Certification Authority - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (1024 bit) - Modulus: - 00:cd:28:83:34:54:1b:89:f3:0f:af:37:91:31:ff: - af:31:60:c9:a8:e8:b2:10:68:ed:9f:e7:93:36:f1: - 0a:64:bb:47:f5:04:17:3f:23:47:4d:c5:27:19:81: - 26:0c:54:72:0d:88:2d:d9:1f:9a:12:9f:bc:b3:71: - d3:80:19:3f:47:66:7b:8c:35:28:d2:b9:0a:df:24: - da:9c:d6:50:79:81:7a:5a:d3:37:f7:c2:4a:d8:29: - 92:26:64:d1:e4:98:6c:3a:00:8a:f5:34:9b:65:f8: - ed:e3:10:ff:fd:b8:49:58:dc:a0:de:82:39:6b:81: - b1:16:19:61:b9:54:b6:e6:43 - Exponent: 3 (0x3) - X509v3 extensions: - Netscape Cert Type: - SSL CA, S/MIME CA, Object Signing CA - X509v3 CRL Distribution Points: - - Full Name: - DirName: C = US, O = Entrust.net, OU = www.entrust.net/CPS incorp. by ref. (limits liab.), OU = (c) 1999 Entrust.net Limited, CN = Entrust.net Secure Server Certification Authority, CN = CRL1 - - Full Name: - URI:http://www.entrust.net/CRL/net1.crl - - X509v3 Private Key Usage Period: - Not Before: May 25 16:09:40 1999 GMT, Not After: May 25 16:09:40 2019 GMT - X509v3 Key Usage: - Certificate Sign, CRL Sign - X509v3 Authority Key Identifier: - keyid:F0:17:62:13:55:3D:B3:FF:0A:00:6B:FB:50:84:97:F3:ED:62:D0:1A - - X509v3 Subject Key Identifier: - F0:17:62:13:55:3D:B3:FF:0A:00:6B:FB:50:84:97:F3:ED:62:D0:1A - X509v3 Basic Constraints: - CA:TRUE - 1.2.840.113533.7.65.0: - 0 -..V4.0.... - Signature Algorithm: sha1WithRSAEncryption - 90:dc:30:02:fa:64:74:c2:a7:0a:a5:7c:21:8d:34:17:a8:fb: - 47:0e:ff:25:7c:8d:13:0a:fb:e4:98:b5:ef:8c:f8:c5:10:0d: - f7:92:be:f1:c3:d5:d5:95:6a:04:bb:2c:ce:26:36:65:c8:31: - c6:e7:ee:3f:e3:57:75:84:7a:11:ef:46:4f:18:f4:d3:98:bb: - a8:87:32:ba:72:f6:3c:e2:3d:9f:d7:1d:d9:c3:60:43:8c:58: - 0e:22:96:2f:62:a3:2c:1f:ba:ad:05:ef:ab:32:78:87:a0:54: - 73:19:b5:5c:05:f9:52:3e:6d:2d:45:0b:f7:0a:93:ea:ed:06: - f9:b2 - ------BEGIN CERTIFICATE----- -MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UEBhMC -VVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50cnVzdC5u -ZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc -KGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVzdC5u -ZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAeFw05OTA1 -MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQswCQYDVQQGEwJVUzEUMBIGA1UE -ChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5j -b3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBF -bnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUg -U2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUA -A4GLADCBhwKBgQDNKIM0VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/ -I0dNxScZgSYMVHINiC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3 -wkrYKZImZNHkmGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OC -AdcwggHTMBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHb -oIHYpIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5 -BgNVBAsTMnd3dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1p -dHMgbGlhYi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVk -MTowOAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp -b24gQXV0aG9yaXR5MQ0wCwYDVQQDEwRDUkwxMCmgJ6AlhiNodHRwOi8vd3d3LmVu -dHJ1c3QubmV0L0NSTC9uZXQxLmNybDArBgNVHRAEJDAigA8xOTk5MDUyNTE2MDk0 -MFqBDzIwMTkwNTI1MTYwOTQwWjALBgNVHQ8EBAMCAQYwHwYDVR0jBBgwFoAU8Bdi -E1U9s/8KAGv7UISX8+1i0BowHQYDVR0OBBYEFPAXYhNVPbP/CgBr+1CEl/PtYtAa -MAwGA1UdEwQFMAMBAf8wGQYJKoZIhvZ9B0EABAwwChsEVjQuMAMCBJAwDQYJKoZI -hvcNAQEFBQADgYEAkNwwAvpkdMKnCqV8IY00F6j7Rw7/JXyNEwr75Ji174z4xRAN -95K+8cPV1ZVqBLssziY2ZcgxxufuP+NXdYR6Ee9GTxj005i7qIcyunL2POI9n9cd -2cNgQ4xYDiKWL2KjLB+6rQXvqzJ4h6BUcxm1XAX5Uj5tLUUL9wqT6u0G+bI= ------END CERTIFICATE----- diff --git a/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem b/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem deleted file mode 100644 index 43bad3e..0000000 --- a/lib/rubygems/ssl_certs/VerisignClass3PublicPrimaryCertificationAuthority-G2.pem +++ /dev/null @@ -1,57 +0,0 @@ -This CA certificate is for verifying HTTPS connection to; - - https://s3.amazon.com/ (prepared by AWS) - -Certificate: - Data: - Version: 1 (0x0) - Serial Number: - 7d:d9:fe:07:cf:a8:1e:b7:10:79:67:fb:a7:89:34:c6 - Signature Algorithm: sha1WithRSAEncryption - Issuer: C=US, O=VeriSign, Inc., OU=Class 3 Public Primary Certification Authority - G2, OU=(c) 1998 VeriSign, Inc. - For authorized use only, OU=VeriSign Trust Network - Validity - Not Before: May 18 00:00:00 1998 GMT - Not After : Aug 1 23:59:59 2028 GMT - Subject: C=US, O=VeriSign, Inc., OU=Class 3 Public Primary Certification Authority - G2, OU=(c) 1998 VeriSign, Inc. - For authorized use only, OU=VeriSign Trust Network - Subject Public Key Info: - Public Key Algorithm: rsaEncryption - Public-Key: (1024 bit) - Modulus: - 00:cc:5e:d1:11:5d:5c:69:d0:ab:d3:b9:6a:4c:99: - 1f:59:98:30:8e:16:85:20:46:6d:47:3f:d4:85:20: - 84:e1:6d:b3:f8:a4:ed:0c:f1:17:0f:3b:f9:a7:f9: - 25:d7:c1:cf:84:63:f2:7c:63:cf:a2:47:f2:c6:5b: - 33:8e:64:40:04:68:c1:80:b9:64:1c:45:77:c7:d8: - 6e:f5:95:29:3c:50:e8:34:d7:78:1f:a8:ba:6d:43: - 91:95:8f:45:57:5e:7e:c5:fb:ca:a4:04:eb:ea:97: - 37:54:30:6f:bb:01:47:32:33:cd:dc:57:9b:64:69: - 61:f8:9b:1d:1c:89:4f:5c:67 - Exponent: 65537 (0x10001) - Signature Algorithm: sha1WithRSAEncryption - 51:4d:cd:be:5c:cb:98:19:9c:15:b2:01:39:78:2e:4d:0f:67: - 70:70:99:c6:10:5a:94:a4:53:4d:54:6d:2b:af:0d:5d:40:8b: - 64:d3:d7:ee:de:56:61:92:5f:a6:c4:1d:10:61:36:d3:2c:27: - 3c:e8:29:09:b9:11:64:74:cc:b5:73:9f:1c:48:a9:bc:61:01: - ee:e2:17:a6:0c:e3:40:08:3b:0e:e7:eb:44:73:2a:9a:f1:69: - 92:ef:71:14:c3:39:ac:71:a7:91:09:6f:e4:71:06:b3:ba:59: - 57:26:79:00:f6:f8:0d:a2:33:30:28:d4:aa:58:a0:9d:9d:69: - 91:fd - ------BEGIN CERTIFICATE----- -MIIDAjCCAmsCEH3Z/gfPqB63EHln+6eJNMYwDQYJKoZIhvcNAQEFBQAwgcExCzAJ -BgNVBAYTAlVTMRcwFQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xh -c3MgMyBQdWJsaWMgUHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcy -MTowOAYDVQQLEzEoYykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3Jp -emVkIHVzZSBvbmx5MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMB4X -DTk4MDUxODAwMDAwMFoXDTI4MDgwMTIzNTk1OVowgcExCzAJBgNVBAYTAlVTMRcw -FQYDVQQKEw5WZXJpU2lnbiwgSW5jLjE8MDoGA1UECxMzQ2xhc3MgMyBQdWJsaWMg -UHJpbWFyeSBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eSAtIEcyMTowOAYDVQQLEzEo -YykgMTk5OCBWZXJpU2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5 -MR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMIGfMA0GCSqGSIb3DQEB -AQUAA4GNADCBiQKBgQDMXtERXVxp0KvTuWpMmR9ZmDCOFoUgRm1HP9SFIIThbbP4 -pO0M8RcPO/mn+SXXwc+EY/J8Y8+iR/LGWzOOZEAEaMGAuWQcRXfH2G71lSk8UOg0 -13gfqLptQ5GVj0VXXn7F+8qkBOvqlzdUMG+7AUcyM83cV5tkaWH4mx0ciU9cZwID -AQABMA0GCSqGSIb3DQEBBQUAA4GBAFFNzb5cy5gZnBWyATl4Lk0PZ3BwmcYQWpSk -U01UbSuvDV1Ai2TT1+7eVmGSX6bEHRBhNtMsJzzoKQm5EWR0zLVznxxIqbxhAe7i -F6YM40AIOw7n60RzKprxaZLvcRTDOaxxp5EJb+RxBrO6WVcmeQD2+A2iMzAo1KpY -oJ2daZH9 ------END CERTIFICATE----- diff --git a/lib/securerandom.rb b/lib/securerandom.rb index 04e8bc2..d4ab947 100644 --- a/lib/securerandom.rb +++ b/lib/securerandom.rb @@ -54,7 +54,7 @@ module SecureRandom # If secure random number generator is not available, # NotImplementedError is raised. def self.random_bytes(n=nil) - n ||= 16 + n = n ? n.to_int : 16 if defined? OpenSSL::Random @pid = 0 if !defined?(@pid) @@ -80,7 +80,7 @@ module SecureRandom @has_urandom = true ret = f.readpartial(n) if ret.length != n - raise NotImplementedError, "Unexpected partial read from random device" + raise NotImplementedError, "Unexpected partial read from random device: only #{ret.length} for #{n} bytes" end return ret } diff --git a/lib/test/unit/parallel.rb b/lib/test/unit/parallel.rb index 7a7c73d..bb95a54 100644 --- a/lib/test/unit/parallel.rb +++ b/lib/test/unit/parallel.rb @@ -152,6 +152,10 @@ if $0 == __FILE__ end end end + require 'rubygems' + class Gem::TestCase < MiniTest::Unit::TestCase + @@project_dir = File.expand_path('../../../..', __FILE__) + end Test::Unit::Worker.new.run(ARGV) end diff --git a/lib/timeout.rb b/lib/timeout.rb index 91d120a..16a168d 100644 --- a/lib/timeout.rb +++ b/lib/timeout.rb @@ -33,11 +33,12 @@ module Timeout CALLER_OFFSET = ((c = caller[0]) && THIS_FILE =~ c) ? 1 : 0 # :startdoc: - # Perform an operation in a block, timing it out if it takes longer - # than +sec+ seconds to complete. + # Perform an operation in a block, raising an error if it takes longer than + # +sec+ seconds to complete. # # +sec+:: Number of seconds to wait for the block to terminate. Any number - # may be used, including Floats to specify fractional seconds. + # may be used, including Floats to specify fractional seconds. A + # value of 0 or +nil+ will execute the block without any timeout. # +klass+:: Exception Class to raise if the block fails to terminate # in +sec+ seconds. Omitting will use the default, Timeout::Error # diff --git a/lib/uri/ftp.rb b/lib/uri/ftp.rb index 061920f..ee4b1e6 100644 --- a/lib/uri/ftp.rb +++ b/lib/uri/ftp.rb @@ -2,7 +2,7 @@ # # Author:: Akira Yamada <akira@ruby-lang.org> # License:: You can redistribute it and/or modify it under the same term as Ruby. -# Revision:: $Id: ftp.rb 31573 2011-05-15 11:55:52Z nobu $ +# Revision:: $Id: ftp.rb 36857 2012-08-30 16:21:44Z naruse $ # # See URI for general documentation # @@ -135,6 +135,7 @@ module URI # +opaque+, +query+ and +fragment+, in that order. # def initialize(*arg) + raise InvalidURIError unless arg[5] arg[5] = arg[5].sub(/^\//,'').sub(/^%2F/,'/') super(*arg) @typecode = nil diff --git a/lib/webrick/utils.rb b/lib/webrick/utils.rb index 983ac9f..157c530 100644 --- a/lib/webrick/utils.rb +++ b/lib/webrick/utils.rb @@ -33,7 +33,7 @@ module WEBrick # Sets the close on exec flag for +io+ def set_close_on_exec(io) if defined?(Fcntl::FD_CLOEXEC) - io.fcntl(Fcntl::FD_CLOEXEC, 1) + io.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) end end module_function :set_close_on_exec diff --git a/lib/yaml.rb b/lib/yaml.rb index ff9e1a6..3461f68 100644 --- a/lib/yaml.rb +++ b/lib/yaml.rb @@ -1,18 +1,46 @@ -## -# The YAML module allows you to use one of the two YAML engines that ship with -# ruby. By default Psych is used but the old and unmaintained Syck may be -# chosen. +# YAML Ain't Markup Language # -# See Psych or Syck for usage and documentation. +# This module provides a Ruby interface for data serialization in YAML format. # -# To set the YAML engine to syck: +# You can choose from one of two YAML engines that ship with Ruby 1.9. By +# default Psych is used but the old unmaintained Syck may chosen. # -# YAML::ENGINE.yamler = 'syck' +# == Usage +# +# Working with YAML can be very simple, for example: +# +# require 'yaml' # STEP ONE, REQUIRE YAML! +# # Parse a YAML string +# YAML.load("--- foo") #=> "foo" +# +# # Emit some YAML +# YAML.dump("foo") # => "--- foo\n...\n" +# { :a => 'b'}.to_yaml # => "---\n:a: b\n" +# +# == Security +# +# Do not use YAML to load untrusted data. Doing so is unsafe and could allow +# malicious input to execute arbitrary code inside your application. Please see +# doc/security.rdoc for more information. +# +# == Syck # -# To set the YAML engine back to psych: +# Syck was the original for YAML implementation in Ruby's standard library +# developed by why the lucky stiff. # +# If you prefer, you can still use Syck by changing the YAML::ENGINE like so: +# +# YAML::ENGINE.yamler = 'syck' +# # switch back to the default Psych # YAML::ENGINE.yamler = 'psych' - +# +# In older Ruby versions, ie. <= 1.9, Syck is still provided, however it was +# completely removed with the release of Ruby 2.0.0. +# +# == More info +# +# For more advanced details on the implementation see Psych, and also check out +# http://yaml.org for spec details and other helpful information. module YAML class EngineManager # :nodoc: attr_reader :yamler @@ -45,7 +73,7 @@ module YAML ## # Allows changing the current YAML engine. See YAML for details. - ENGINE = YAML::EngineManager.new + ENGINE = YAML::EngineManager.new # :nodoc: end if defined?(Psych) @@ -65,11 +93,11 @@ else end end -module Syck +module Syck # :nodoc: ENGINE = YAML::ENGINE end -module Psych +module Psych # :nodoc: ENGINE = YAML::ENGINE end @@ -43,7 +43,7 @@ rb_get_expanded_load_path(void) ary = rb_ary_new2(RARRAY_LEN(load_path)); for (i = 0; i < RARRAY_LEN(load_path); ++i) { - VALUE path = rb_file_expand_path(RARRAY_PTR(load_path)[i], Qnil); + VALUE path = rb_file_expand_path_fast(RARRAY_PTR(load_path)[i], Qnil); rb_str_freeze(path); rb_ary_push(ary, path); } @@ -233,7 +233,7 @@ rb_feature_provided(const char *feature, const char **loading) if (*feature == '.' && (feature[1] == '/' || strncmp(feature+1, "./", 2) == 0)) { - fullpath = rb_file_expand_path(rb_str_new2(feature), Qnil); + fullpath = rb_file_expand_path_fast(rb_str_new2(feature), Qnil); feature = RSTRING_PTR(fullpath); } if (ext && !strchr(ext, '/')) { @@ -319,7 +319,8 @@ rb_load_internal(VALUE fname, int wrap) th->top_self = self; th->top_wrapper = wrapper; - if (!loaded) { + if (!loaded && !FIXNUM_P(GET_THREAD()->errinfo)) { + /* an error on loading don't include INT2FIX(TAG_FATAL) see r35625 */ rb_exc_raise(GET_THREAD()->errinfo); } if (state) { @@ -497,7 +498,7 @@ search_required(VALUE fname, volatile VALUE *path, int safe_level) if (ext && !strchr(ext, '/')) { if (IS_RBEXT(ext)) { if (rb_feature_p(ftptr, ext, TRUE, FALSE, &loading)) { - if (loading) *path = rb_str_new2(loading); + if (loading) *path = rb_filesystem_str_new_cstr(loading); return 'r'; } if ((tmp = rb_find_file_safe(fname, safe_level)) != 0) { @@ -510,10 +511,10 @@ search_required(VALUE fname, volatile VALUE *path, int safe_level) } else if (IS_SOEXT(ext)) { if (rb_feature_p(ftptr, ext, FALSE, FALSE, &loading)) { - if (loading) *path = rb_str_new2(loading); + if (loading) *path = rb_filesystem_str_new_cstr(loading); return 's'; } - tmp = rb_str_new(RSTRING_PTR(fname), ext - RSTRING_PTR(fname)); + tmp = rb_str_subseq(fname, 0, ext - RSTRING_PTR(fname)); #ifdef DLEXT2 OBJ_FREEZE(tmp); if (rb_find_file_ext_safe(&tmp, loadable_ext + 1, safe_level)) { @@ -535,7 +536,7 @@ search_required(VALUE fname, volatile VALUE *path, int safe_level) } else if (IS_DLEXT(ext)) { if (rb_feature_p(ftptr, ext, FALSE, FALSE, &loading)) { - if (loading) *path = rb_str_new2(loading); + if (loading) *path = rb_filesystem_str_new_cstr(loading); return 's'; } if ((tmp = rb_find_file_safe(fname, safe_level)) != 0) { @@ -547,7 +548,7 @@ search_required(VALUE fname, volatile VALUE *path, int safe_level) } } else if ((ft = rb_feature_p(ftptr, 0, FALSE, FALSE, &loading)) == 'r') { - if (loading) *path = rb_str_new2(loading); + if (loading) *path = rb_filesystem_str_new_cstr(loading); return 'r'; } tmp = fname; @@ -2,7 +2,7 @@ marshal.c - - $Author: drbrain $ + $Author: usa $ created at: Thu Apr 27 16:30:01 JST 1995 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -1214,7 +1214,8 @@ r_entry0(VALUE v, st_index_t num, struct load_arg *arg) else { st_insert(arg->data, num, (st_data_t)v); } - if (arg->infection) { + if (arg->infection && + TYPE(v) != T_CLASS && TYPE(v) != T_MODULE) { FL_SET(v, arg->infection); if ((VALUE)real_obj != Qundef) FL_SET((VALUE)real_obj, arg->infection); diff --git a/missing/setproctitle.c b/missing/setproctitle.c index 169ba8b..d35e70d 100644 --- a/missing/setproctitle.c +++ b/missing/setproctitle.c @@ -48,6 +48,12 @@ #endif #include <string.h> +#if defined(__APPLE__) +#include <crt_externs.h> +#undef environ +#define environ (*_NSGetEnviron()) +#endif + #define SPT_NONE 0 /* don't use it at all */ #define SPT_PSTAT 1 /* use pstat(PSTAT_SETCMD, ...) */ #define SPT_REUSEARGV 2 /* cover argv with title information */ @@ -2,7 +2,7 @@ numeric.c - - $Author: naruse $ + $Author: usa $ created at: Fri Aug 13 18:33:09 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -814,18 +814,18 @@ flodivmod(double x, double y, double *divp, double *modp) double div, mod; if (y == 0.0) rb_num_zerodiv(); -#ifdef HAVE_FMOD - mod = fmod(x, y); -#else if((x == 0.0) || (isinf(y) && !isinf(x))) mod = x; else { +#ifdef HAVE_FMOD + mod = fmod(x, y); +#else double z; modf(x/y, &z); mod = x - z * y; - } #endif + } if (isinf(x) && !isinf(y) && !isnan(y)) div = x; else @@ -2,7 +2,7 @@ object.c - - $Author: naruse $ + $Author: usa $ created at: Thu Jul 15 12:01:24 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -112,7 +112,14 @@ VALUE rb_obj_hash(VALUE obj) { VALUE oid = rb_obj_id(obj); - st_index_t h = rb_hash_end(rb_hash_start(NUM2LONG(oid))); +#if SIZEOF_LONG == SIZEOF_VOIDP + st_index_t index = NUM2LONG(oid); +#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP + st_index_t index = NUM2LL(oid); +#else +# error not supported +#endif + st_index_t h = rb_hash_end(rb_hash_start(index)); return LONG2FIX(h); } @@ -2696,11 +2703,11 @@ Init_Object(void) rb_define_method(rb_mKernel, "to_s", rb_any_to_s, 0); rb_define_method(rb_mKernel, "inspect", rb_obj_inspect, 0); - rb_define_method(rb_mKernel, "methods", rb_obj_methods, -1); + rb_define_method(rb_mKernel, "methods", rb_obj_methods, -1); /* in class.c */ rb_define_method(rb_mKernel, "singleton_methods", rb_obj_singleton_methods, -1); /* in class.c */ - rb_define_method(rb_mKernel, "protected_methods", rb_obj_protected_methods, -1); - rb_define_method(rb_mKernel, "private_methods", rb_obj_private_methods, -1); - rb_define_method(rb_mKernel, "public_methods", rb_obj_public_methods, -1); + rb_define_method(rb_mKernel, "protected_methods", rb_obj_protected_methods, -1); /* in class.c */ + rb_define_method(rb_mKernel, "private_methods", rb_obj_private_methods, -1); /* in class.c */ + rb_define_method(rb_mKernel, "public_methods", rb_obj_public_methods, -1); /* in class.c */ rb_define_method(rb_mKernel, "instance_variables", rb_obj_instance_variables, 0); /* in variable.c */ rb_define_method(rb_mKernel, "instance_variable_get", rb_obj_ivar_get, 1); rb_define_method(rb_mKernel, "instance_variable_set", rb_obj_ivar_set, 2); @@ -2791,7 +2798,6 @@ Init_Object(void) rb_define_method(rb_cClass, "allocate", rb_obj_alloc, 0); rb_define_method(rb_cClass, "new", rb_class_new_instance, -1); rb_define_method(rb_cClass, "initialize", rb_class_initialize, -1); - rb_define_method(rb_cClass, "initialize_copy", rb_class_init_copy, 1); /* in class.c */ rb_define_method(rb_cClass, "superclass", rb_class_superclass, 0); rb_define_alloc_func(rb_cClass, rb_class_s_alloc); rb_undef_method(rb_cClass, "extend_object"); @@ -2,7 +2,7 @@ pack.c - - $Author: nobu $ + $Author: naruse $ created at: Thu Feb 10 15:17:05 JST 1994 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -2003,7 +2003,7 @@ pack_unpack(VALUE str, VALUE fmt) case 'M': { VALUE buf = infected_str_new(0, send - s, str); - char *ptr = RSTRING_PTR(buf); + char *ptr = RSTRING_PTR(buf), *ss = s; int c1, c2; while (s < send) { @@ -2022,8 +2022,10 @@ pack_unpack(VALUE str, VALUE fmt) *ptr++ = *s; } s++; + ss = s; } rb_str_set_len(buf, ptr - RSTRING_PTR(buf)); + rb_str_buf_cat(buf, ss, send-ss); ENCODING_CODERANGE_SET(buf, rb_ascii8bit_encindex(), ENC_CODERANGE_VALID); UNPACK_PUSH(buf); } @@ -1,21 +1,24 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.3. */ -/* Bison implementation for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - + the Free Software Foundation; either version 2, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -26,7 +29,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -44,7 +47,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.5" +#define YYBISON_VERSION "2.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -52,20 +55,261 @@ /* Pure parsers. */ #define YYPURE 1 -/* Push parsers. */ -#define YYPUSH 0 - -/* Pull parsers. */ -#define YYPULL 1 - /* Using locations. */ #define YYLSP_NEEDED 0 -/* Copy the first part of user declarations. */ +/* Tokens. */ +#ifndef YYTOKENTYPE +# define YYTOKENTYPE + /* Put the tokens into the symbol table, so that GDB and other debuggers + know about them. */ + enum yytokentype { + keyword_class = 258, + keyword_module = 259, + keyword_def = 260, + keyword_undef = 261, + keyword_begin = 262, + keyword_rescue = 263, + keyword_ensure = 264, + keyword_end = 265, + keyword_if = 266, + keyword_unless = 267, + keyword_then = 268, + keyword_elsif = 269, + keyword_else = 270, + keyword_case = 271, + keyword_when = 272, + keyword_while = 273, + keyword_until = 274, + keyword_for = 275, + keyword_break = 276, + keyword_next = 277, + keyword_redo = 278, + keyword_retry = 279, + keyword_in = 280, + keyword_do = 281, + keyword_do_cond = 282, + keyword_do_block = 283, + keyword_do_LAMBDA = 284, + keyword_return = 285, + keyword_yield = 286, + keyword_super = 287, + keyword_self = 288, + keyword_nil = 289, + keyword_true = 290, + keyword_false = 291, + keyword_and = 292, + keyword_or = 293, + keyword_not = 294, + modifier_if = 295, + modifier_unless = 296, + modifier_while = 297, + modifier_until = 298, + modifier_rescue = 299, + keyword_alias = 300, + keyword_defined = 301, + keyword_BEGIN = 302, + keyword_END = 303, + keyword__LINE__ = 304, + keyword__FILE__ = 305, + keyword__ENCODING__ = 306, + tIDENTIFIER = 307, + tFID = 308, + tGVAR = 309, + tIVAR = 310, + tCONSTANT = 311, + tCVAR = 312, + tLABEL = 313, + tINTEGER = 314, + tFLOAT = 315, + tSTRING_CONTENT = 316, + tCHAR = 317, + tNTH_REF = 318, + tBACK_REF = 319, + tREGEXP_END = 320, + tUPLUS = 321, + tUMINUS = 322, + tPOW = 323, + tCMP = 324, + tEQ = 325, + tEQQ = 326, + tNEQ = 327, + tGEQ = 328, + tLEQ = 329, + tANDOP = 330, + tOROP = 331, + tMATCH = 332, + tNMATCH = 333, + tDOT2 = 334, + tDOT3 = 335, + tAREF = 336, + tASET = 337, + tLSHFT = 338, + tRSHFT = 339, + tCOLON2 = 340, + tCOLON3 = 341, + tOP_ASGN = 342, + tASSOC = 343, + tLPAREN = 344, + tLPAREN_ARG = 345, + tRPAREN = 346, + tLBRACK = 347, + tLBRACE = 348, + tLBRACE_ARG = 349, + tSTAR = 350, + tAMPER = 351, + tLAMBDA = 352, + tSYMBEG = 353, + tSTRING_BEG = 354, + tXSTRING_BEG = 355, + tREGEXP_BEG = 356, + tWORDS_BEG = 357, + tQWORDS_BEG = 358, + tSTRING_DBEG = 359, + tSTRING_DVAR = 360, + tSTRING_END = 361, + tLAMBEG = 362, + tLOWEST = 363, + tUMINUS_NUM = 364, + idNULL = 365, + idRespond_to = 366, + idIFUNC = 367, + idCFUNC = 368, + id_core_set_method_alias = 369, + id_core_set_variable_alias = 370, + id_core_undef_method = 371, + id_core_define_method = 372, + id_core_define_singleton_method = 373, + id_core_set_postexe = 374, + tLAST_TOKEN = 375 + }; +#endif +/* Tokens. */ +#define keyword_class 258 +#define keyword_module 259 +#define keyword_def 260 +#define keyword_undef 261 +#define keyword_begin 262 +#define keyword_rescue 263 +#define keyword_ensure 264 +#define keyword_end 265 +#define keyword_if 266 +#define keyword_unless 267 +#define keyword_then 268 +#define keyword_elsif 269 +#define keyword_else 270 +#define keyword_case 271 +#define keyword_when 272 +#define keyword_while 273 +#define keyword_until 274 +#define keyword_for 275 +#define keyword_break 276 +#define keyword_next 277 +#define keyword_redo 278 +#define keyword_retry 279 +#define keyword_in 280 +#define keyword_do 281 +#define keyword_do_cond 282 +#define keyword_do_block 283 +#define keyword_do_LAMBDA 284 +#define keyword_return 285 +#define keyword_yield 286 +#define keyword_super 287 +#define keyword_self 288 +#define keyword_nil 289 +#define keyword_true 290 +#define keyword_false 291 +#define keyword_and 292 +#define keyword_or 293 +#define keyword_not 294 +#define modifier_if 295 +#define modifier_unless 296 +#define modifier_while 297 +#define modifier_until 298 +#define modifier_rescue 299 +#define keyword_alias 300 +#define keyword_defined 301 +#define keyword_BEGIN 302 +#define keyword_END 303 +#define keyword__LINE__ 304 +#define keyword__FILE__ 305 +#define keyword__ENCODING__ 306 +#define tIDENTIFIER 307 +#define tFID 308 +#define tGVAR 309 +#define tIVAR 310 +#define tCONSTANT 311 +#define tCVAR 312 +#define tLABEL 313 +#define tINTEGER 314 +#define tFLOAT 315 +#define tSTRING_CONTENT 316 +#define tCHAR 317 +#define tNTH_REF 318 +#define tBACK_REF 319 +#define tREGEXP_END 320 +#define tUPLUS 321 +#define tUMINUS 322 +#define tPOW 323 +#define tCMP 324 +#define tEQ 325 +#define tEQQ 326 +#define tNEQ 327 +#define tGEQ 328 +#define tLEQ 329 +#define tANDOP 330 +#define tOROP 331 +#define tMATCH 332 +#define tNMATCH 333 +#define tDOT2 334 +#define tDOT3 335 +#define tAREF 336 +#define tASET 337 +#define tLSHFT 338 +#define tRSHFT 339 +#define tCOLON2 340 +#define tCOLON3 341 +#define tOP_ASGN 342 +#define tASSOC 343 +#define tLPAREN 344 +#define tLPAREN_ARG 345 +#define tRPAREN 346 +#define tLBRACK 347 +#define tLBRACE 348 +#define tLBRACE_ARG 349 +#define tSTAR 350 +#define tAMPER 351 +#define tLAMBDA 352 +#define tSYMBEG 353 +#define tSTRING_BEG 354 +#define tXSTRING_BEG 355 +#define tREGEXP_BEG 356 +#define tWORDS_BEG 357 +#define tQWORDS_BEG 358 +#define tSTRING_DBEG 359 +#define tSTRING_DVAR 360 +#define tSTRING_END 361 +#define tLAMBEG 362 +#define tLOWEST 363 +#define tUMINUS_NUM 364 +#define idNULL 365 +#define idRespond_to 366 +#define idIFUNC 367 +#define idCFUNC 368 +#define id_core_set_method_alias 369 +#define id_core_set_variable_alias 370 +#define id_core_undef_method 371 +#define id_core_define_method 372 +#define id_core_define_singleton_method 373 +#define id_core_set_postexe 374 +#define tLAST_TOKEN 375 + + -/* Line 268 of yacc.c */ + +/* Copy the first part of user declarations. */ #line 12 "parse.y" @@ -668,9 +912,6 @@ static void token_info_pop(struct parser_params*, const char *token); #endif -/* Line 268 of yacc.c */ -#line 673 "parse.c" - /* Enabling traces. */ #ifndef YYDEBUG # define YYDEBUG 0 @@ -689,165 +930,31 @@ static void token_info_pop(struct parser_params*, const char *token); # define YYTOKEN_TABLE 0 #endif - -/* Tokens. */ -#ifndef YYTOKENTYPE -# define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - keyword_class = 258, - keyword_module = 259, - keyword_def = 260, - keyword_undef = 261, - keyword_begin = 262, - keyword_rescue = 263, - keyword_ensure = 264, - keyword_end = 265, - keyword_if = 266, - keyword_unless = 267, - keyword_then = 268, - keyword_elsif = 269, - keyword_else = 270, - keyword_case = 271, - keyword_when = 272, - keyword_while = 273, - keyword_until = 274, - keyword_for = 275, - keyword_break = 276, - keyword_next = 277, - keyword_redo = 278, - keyword_retry = 279, - keyword_in = 280, - keyword_do = 281, - keyword_do_cond = 282, - keyword_do_block = 283, - keyword_do_LAMBDA = 284, - keyword_return = 285, - keyword_yield = 286, - keyword_super = 287, - keyword_self = 288, - keyword_nil = 289, - keyword_true = 290, - keyword_false = 291, - keyword_and = 292, - keyword_or = 293, - keyword_not = 294, - modifier_if = 295, - modifier_unless = 296, - modifier_while = 297, - modifier_until = 298, - modifier_rescue = 299, - keyword_alias = 300, - keyword_defined = 301, - keyword_BEGIN = 302, - keyword_END = 303, - keyword__LINE__ = 304, - keyword__FILE__ = 305, - keyword__ENCODING__ = 306, - tIDENTIFIER = 307, - tFID = 308, - tGVAR = 309, - tIVAR = 310, - tCONSTANT = 311, - tCVAR = 312, - tLABEL = 313, - tINTEGER = 314, - tFLOAT = 315, - tSTRING_CONTENT = 316, - tCHAR = 317, - tNTH_REF = 318, - tBACK_REF = 319, - tREGEXP_END = 320, - tUPLUS = 321, - tUMINUS = 322, - tPOW = 323, - tCMP = 324, - tEQ = 325, - tEQQ = 326, - tNEQ = 327, - tGEQ = 328, - tLEQ = 329, - tANDOP = 330, - tOROP = 331, - tMATCH = 332, - tNMATCH = 333, - tDOT2 = 334, - tDOT3 = 335, - tAREF = 336, - tASET = 337, - tLSHFT = 338, - tRSHFT = 339, - tCOLON2 = 340, - tCOLON3 = 341, - tOP_ASGN = 342, - tASSOC = 343, - tLPAREN = 344, - tLPAREN_ARG = 345, - tRPAREN = 346, - tLBRACK = 347, - tLBRACE = 348, - tLBRACE_ARG = 349, - tSTAR = 350, - tAMPER = 351, - tLAMBDA = 352, - tSYMBEG = 353, - tSTRING_BEG = 354, - tXSTRING_BEG = 355, - tREGEXP_BEG = 356, - tWORDS_BEG = 357, - tQWORDS_BEG = 358, - tSTRING_DBEG = 359, - tSTRING_DVAR = 360, - tSTRING_END = 361, - tLAMBEG = 362, - tLOWEST = 363, - tUMINUS_NUM = 364, - idNULL = 365, - idRespond_to = 366, - idIFUNC = 367, - idCFUNC = 368, - id_core_set_method_alias = 369, - id_core_set_variable_alias = 370, - id_core_undef_method = 371, - id_core_define_method = 372, - id_core_define_singleton_method = 373, - id_core_set_postexe = 374, - tLAST_TOKEN = 375 - }; -#endif - - - #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE -{ - -/* Line 293 of yacc.c */ #line 616 "parse.y" - +{ VALUE val; NODE *node; ID id; int num; const struct vtable *vars; - - - -/* Line 293 of yacc.c */ -#line 839 "parse.c" -} YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 +} +/* Line 187 of yacc.c. */ +#line 945 "parse.c" + YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 #endif + /* Copy the second part of user declarations. */ -/* Line 343 of yacc.c */ -#line 851 "parse.c" +/* Line 216 of yacc.c. */ +#line 958 "parse.c" #ifdef short # undef short @@ -897,7 +1004,7 @@ typedef short int yytype_int16; #define YYSIZE_MAXIMUM ((YYSIZE_T) -1) #ifndef YY_ -# if defined YYENABLE_NLS && YYENABLE_NLS +# if YYENABLE_NLS # if ENABLE_NLS # include <libintl.h> /* INFRINGES ON USER NAME SPACE */ # define YY_(msgid) dgettext ("bison-runtime", msgid) @@ -922,14 +1029,14 @@ typedef short int yytype_int16; #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static int -YYID (int yyi) +YYID (int i) #else static int -YYID (yyi) - int yyi; +YYID (i) + int i; #endif { - return yyi; + return i; } #endif @@ -950,11 +1057,11 @@ YYID (yyi) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 +# ifndef _STDLIB_H +# define _STDLIB_H 1 # endif # endif # endif @@ -977,24 +1084,24 @@ YYID (yyi) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined EXIT_SUCCESS \ +# if (defined __cplusplus && ! defined _STDLIB_H \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ -# ifndef EXIT_SUCCESS -# define EXIT_SUCCESS 0 +# ifndef _STDLIB_H +# define _STDLIB_H 1 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif @@ -1010,9 +1117,9 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ /* A type that is properly aligned for any stack member. */ union yyalloc { - yytype_int16 yyss_alloc; - YYSTYPE yyvs_alloc; -}; + yytype_int16 yyss; + YYSTYPE yyvs; + }; /* The size of the maximum gap between one aligned stack and the next. */ # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) @@ -1023,27 +1130,6 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) -# define YYCOPY_NEEDED 1 - -/* Relocate STACK from its old location to the new one. The - local variables YYSIZE and YYSTACKSIZE give the old and new number of - elements in the stack, and YYPTR gives the new location of the - stack. Advance YYPTR to a properly aligned location for the next - stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) - -#endif - -#if defined YYCOPY_NEEDED && YYCOPY_NEEDED /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY @@ -1061,7 +1147,24 @@ union yyalloc while (YYID (0)) # endif # endif -#endif /* !YYCOPY_NEEDED */ + +/* Relocate STACK from its old location to the new one. The + local variables YYSIZE and YYSTACKSIZE give the old and new number of + elements in the stack, and YYPTR gives the new location of the + stack. Advance YYPTR to a properly aligned location for the next + stack. */ +# define YYSTACK_RELOCATE(Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack, Stack, yysize); \ + Stack = &yyptr->Stack; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (YYID (0)) + +#endif /* YYFINAL -- State number of the termination state. */ #define YYFINAL 3 @@ -1426,15 +1529,15 @@ static const yytype_uint16 yyrline[] = 4155, 4181, 4189, 4197, 4205, 4208, 4219, 4220, 4221, 4222, 4225, 4255, 4256, 4257, 4265, 4275, 4276, 4277, 4278, 4279, 4282, 4283, 4284, 4285, 4286, 4287, 4288, 4291, 4304, 4314, - 4322, 4332, 4333, 4336, 4345, 4344, 4352, 4364, 4374, 4380, - 4388, 4396, 4404, 4412, 4420, 4428, 4436, 4444, 4452, 4460, - 4468, 4476, 4484, 4493, 4502, 4511, 4520, 4529, 4540, 4541, - 4548, 4557, 4576, 4583, 4596, 4608, 4620, 4628, 4644, 4652, - 4668, 4669, 4672, 4685, 4696, 4697, 4700, 4717, 4721, 4731, - 4741, 4741, 4770, 4771, 4781, 4788, 4798, 4806, 4816, 4817, - 4818, 4821, 4822, 4823, 4824, 4827, 4828, 4829, 4832, 4837, - 4844, 4845, 4848, 4849, 4852, 4855, 4858, 4859, 4860, 4863, - 4864, 4867, 4868, 4872 + 4322, 4332, 4333, 4336, 4345, 4344, 4352, 4364, 4374, 4382, + 4390, 4398, 4406, 4414, 4422, 4430, 4438, 4446, 4454, 4462, + 4470, 4478, 4486, 4495, 4504, 4513, 4522, 4531, 4542, 4543, + 4550, 4559, 4578, 4585, 4598, 4610, 4622, 4630, 4646, 4654, + 4670, 4671, 4674, 4687, 4698, 4699, 4702, 4719, 4723, 4733, + 4743, 4743, 4772, 4773, 4783, 4790, 4800, 4808, 4818, 4819, + 4820, 4823, 4824, 4825, 4826, 4829, 4830, 4831, 4834, 4839, + 4846, 4847, 4850, 4851, 4854, 4857, 4860, 4861, 4862, 4865, + 4866, 4869, 4870, 4874 }; #endif @@ -1472,35 +1575,34 @@ static const char *const yytname[] = "id_core_define_method", "id_core_define_singleton_method", "id_core_set_postexe", "tLAST_TOKEN", "'{'", "'}'", "'['", "'.'", "','", "'`'", "'('", "')'", "']'", "';'", "' '", "'\\n'", "$accept", "program", - "$@1", "top_compstmt", "top_stmts", "top_stmt", "$@2", "bodystmt", - "compstmt", "stmts", "stmt", "$@3", "command_asgn", "expr", "expr_value", + "@1", "top_compstmt", "top_stmts", "top_stmt", "@2", "bodystmt", + "compstmt", "stmts", "stmt", "@3", "command_asgn", "expr", "expr_value", "command_call", "block_command", "cmd_brace_block", "@4", "command", "mlhs", "mlhs_inner", "mlhs_basic", "mlhs_item", "mlhs_head", "mlhs_post", "mlhs_node", "lhs", "cname", "cpath", "fname", "fsym", - "fitem", "undef_list", "$@5", "op", "reswords", "arg", "$@6", - "arg_value", "aref_args", "paren_args", "opt_paren_args", - "opt_call_args", "call_args", "command_args", "@7", "block_arg", - "opt_block_arg", "args", "mrhs", "primary", "@8", "$@9", "$@10", "$@11", - "$@12", "$@13", "$@14", "$@15", "$@16", "@17", "@18", "@19", "@20", - "@21", "$@22", "$@23", "primary_value", "k_begin", "k_if", "k_unless", - "k_while", "k_until", "k_case", "k_for", "k_class", "k_module", "k_def", - "k_end", "then", "do", "if_tail", "opt_else", "for_var", "f_marg", - "f_marg_list", "f_margs", "block_param", "opt_block_param", - "block_param_def", "opt_bv_decl", "bv_decls", "bvar", "lambda", "@24", - "@25", "f_larglist", "lambda_body", "do_block", "@26", "block_call", - "method_call", "brace_block", "@27", "@28", "case_body", "cases", - "opt_rescue", "exc_list", "exc_var", "opt_ensure", "literal", "strings", - "string", "string1", "xstring", "regexp", "words", "word_list", "word", - "qwords", "qword_list", "string_contents", "xstring_contents", - "regexp_contents", "string_content", "@29", "@30", "@31", "string_dvar", - "symbol", "sym", "dsym", "numeric", "user_variable", "keyword_variable", - "var_ref", "var_lhs", "backref", "superclass", "$@32", "f_arglist", - "f_args", "f_bad_arg", "f_norm_arg", "f_arg_item", "f_arg", "f_opt", - "f_block_opt", "f_block_optarg", "f_optarg", "restarg_mark", - "f_rest_arg", "blkarg_mark", "f_block_arg", "opt_f_block_arg", - "singleton", "$@33", "assoc_list", "assocs", "assoc", "operation", - "operation2", "operation3", "dot_or_colon", "opt_terms", "opt_nl", - "rparen", "rbracket", "trailer", "term", "terms", "none", 0 + "fitem", "undef_list", "@5", "op", "reswords", "arg", "@6", "arg_value", + "aref_args", "paren_args", "opt_paren_args", "opt_call_args", + "call_args", "command_args", "@7", "block_arg", "opt_block_arg", "args", + "mrhs", "primary", "@8", "@9", "@10", "@11", "@12", "@13", "@14", "@15", + "@16", "@17", "@18", "@19", "@20", "@21", "@22", "@23", "primary_value", + "k_begin", "k_if", "k_unless", "k_while", "k_until", "k_case", "k_for", + "k_class", "k_module", "k_def", "k_end", "then", "do", "if_tail", + "opt_else", "for_var", "f_marg", "f_marg_list", "f_margs", "block_param", + "opt_block_param", "block_param_def", "opt_bv_decl", "bv_decls", "bvar", + "lambda", "@24", "@25", "f_larglist", "lambda_body", "do_block", "@26", + "block_call", "method_call", "brace_block", "@27", "@28", "case_body", + "cases", "opt_rescue", "exc_list", "exc_var", "opt_ensure", "literal", + "strings", "string", "string1", "xstring", "regexp", "words", + "word_list", "word", "qwords", "qword_list", "string_contents", + "xstring_contents", "regexp_contents", "string_content", "@29", "@30", + "@31", "string_dvar", "symbol", "sym", "dsym", "numeric", + "user_variable", "keyword_variable", "var_ref", "var_lhs", "backref", + "superclass", "@32", "f_arglist", "f_args", "f_bad_arg", "f_norm_arg", + "f_arg_item", "f_arg", "f_opt", "f_block_opt", "f_block_optarg", + "f_optarg", "restarg_mark", "f_rest_arg", "blkarg_mark", "f_block_arg", + "opt_f_block_arg", "singleton", "@33", "assoc_list", "assocs", "assoc", + "operation", "operation2", "operation3", "dot_or_colon", "opt_terms", + "opt_nl", "rparen", "rbracket", "trailer", "term", "terms", "none", 0 }; #endif @@ -1653,8 +1755,8 @@ static const yytype_uint8 yyr2[] = 1, 1, 2, 0 }; -/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. - Performed when YYTABLE doesn't specify something else to do. Zero +/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state + STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint16 yydefact[] = { @@ -1915,7 +2017,8 @@ static const yytype_int16 yypgoto[] = /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If YYTABLE_NINF, syntax error. */ + number is the opposite. If zero, do what YYDEFACT says. + If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -574 static const yytype_int16 yytable[] = { @@ -2996,12 +3099,6 @@ static const yytype_int16 yytable[] = 325, 326, 327, 328, 329, 330, 331, 332, 333 }; -#define yypact_value_is_default(yystate) \ - ((yystate) == (-747)) - -#define yytable_value_is_error(yytable_value) \ - ((yytable_value) == (-574)) - static const yytype_int16 yycheck[] = { 2, 55, 340, 28, 2, 454, 4, 52, 593, 16, @@ -4199,18 +4296,9 @@ static const yytype_uint16 yystos[] = /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ + Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif #define YYRECOVERING() (!!yyerrstatus) @@ -4220,6 +4308,7 @@ do \ { \ yychar = (Token); \ yylval = (Value); \ + yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ @@ -4261,10 +4350,19 @@ while (YYID (0)) #endif -/* This macro is provided for backward compatibility. */ +/* YY_LOCATION_PRINT -- Print the location on the stream. + This macro was not mandated originally: define only if we know + we won't break user code: when these are the locations we know. */ #ifndef YY_LOCATION_PRINT -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# if YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + fprintf (File, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +# else +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +# endif #endif @@ -4371,20 +4469,17 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, parser) #if (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) #else static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; +yy_stack_print (bottom, top) + yytype_int16 *bottom; + yytype_int16 *top; #endif { YYFPRINTF (stderr, "Stack now"); - for (; yybottom <= yytop; yybottom++) - { - int yybot = *yybottom; - YYFPRINTF (stderr, " %d", yybot); - } + for (; bottom <= top; ++bottom) + YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } @@ -4419,11 +4514,11 @@ yy_reduce_print (yyvsp, yyrule, parser) /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { - YYFPRINTF (stderr, " $%d = ", yyi + 1); + fprintf (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], &(yyvsp[(yyi + 1) - (yynrhs)]) , parser); - YYFPRINTF (stderr, "\n"); + fprintf (stderr, "\n"); } } @@ -4462,6 +4557,7 @@ int yydebug; # define YYMAXDEPTH 10000 #endif + #if YYERROR_VERBOSE @@ -4564,142 +4660,115 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message - about the unexpected token YYTOKEN for the state stack whose top is - YYSSP. - - Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is - not large enough to hold the message. In that case, also set - *YYMSG_ALLOC to the required number of bytes. Return 2 if the - required number of bytes is too large to store. */ -static int -yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, - yytype_int16 *yyssp, int yytoken) +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) { - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - /* Internationalized format string. */ - const char *yyformat = 0; - /* Arguments of yyformat. */ - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - /* Number of reported tokens (one for the "unexpected", one per - "expected"). */ - int yycount = 0; - - /* There are many possibilities here to consider: - - Assume YYFAIL is not used. It's too flawed to consider. See - <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html> - for details. YYERROR is fine as it does not invoke this - function. - - If this state is a consistent state with a default action, then - the only way this function was invoked is if the default action - is an error action. In that case, don't check for expected - tokens because there are none. - - The only way there can be no lookahead present (in yychar) is if - this state is a consistent state with a default action. Thus, - detecting the absence of a lookahead is sufficient to determine - that there is no unexpected or expected token to report. In that - case, just report a simple "syntax error". - - Don't assume there isn't a lookahead just because this state is a - consistent state with a default action. There might have been a - previous inconsistent state, consistent state with a non-default - action, or user semantic action that manipulated yychar. - - Of course, the expected token list depends on states to have - correct lookahead information, and it depends on the parser not - to perform extra reductions after fetching a lookahead from the - scanner and before detecting a syntax error. Thus, state merging - (from LALR or IELR) and default reductions corrupt the expected - token list. However, the list is correct for canonical LR with - one exception: it will still contain any token that will not be - accepted due to an error action in a later state. - */ - if (yytoken != YYEMPTY) - { - int yyn = yypact[*yyssp]; - yyarg[yycount++] = yytname[yytoken]; - if (!yypact_value_is_default (yyn)) - { - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. In other words, skip the first -YYN actions for - this state because they are default actions. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yyx; - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yytable_value_is_error (yytable[yyx + yyn])) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - if (! (yysize <= yysize1 - && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; - } - } - } + int yyn = yypact[yystate]; - switch (yycount) - { -# define YYCASE_(N, S) \ - case N: \ - yyformat = S; \ - break - YYCASE_(0, YY_("syntax error")); - YYCASE_(1, YY_("syntax error, unexpected %s")); - YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); - YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); - YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); - YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); -# undef YYCASE_ - } + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; + else + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; - yysize1 = yysize + yystrlen (yyformat); - if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) - return 2; - yysize = yysize1; +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } - if (*yymsg_alloc < yysize) - { - *yymsg_alloc = 2 * yysize; - if (! (yysize <= *yymsg_alloc - && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) - *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; - return 1; - } + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - { - char *yyp = *yymsg; - int yyi = 0; - while ((*yyp = *yyformat) != '\0') - if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyformat += 2; - } - else - { - yyp++; - yyformat++; - } - } - return 0; + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; + } } #endif /* YYERROR_VERBOSE */ + /*-----------------------------------------------. | Release the memory associated to this symbol. | @@ -4733,9 +4802,10 @@ yydestruct (yymsg, yytype, yyvaluep, parser) break; } } - + /* Prevent warnings from -Wmissing-prototypes. */ + #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); @@ -4751,6 +4821,10 @@ int yyparse (); #endif /* ! YYPARSE_PARAM */ + + + + /*----------. | yyparse. | `----------*/ @@ -4777,46 +4851,22 @@ yyparse (parser) #endif #endif { -/* The lookahead symbol. */ + /* The look-ahead symbol. */ int yychar; -/* The semantic value of the lookahead symbol. */ +/* The semantic value of the look-ahead symbol. */ YYSTYPE yylval; - /* Number of syntax errors so far. */ - int yynerrs; - - int yystate; - /* Number of tokens to shift before error messages enabled. */ - int yyerrstatus; - - /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. - - Refer to the stacks thru separate pointers, to allow yyoverflow - to reallocate them elsewhere. */ - - /* The state stack. */ - yytype_int16 yyssa[YYINITDEPTH]; - yytype_int16 *yyss; - yytype_int16 *yyssp; - - /* The semantic value stack. */ - YYSTYPE yyvsa[YYINITDEPTH]; - YYSTYPE *yyvs; - YYSTYPE *yyvsp; - - YYSIZE_T yystacksize; +/* Number of syntax errors so far. */ +int yynerrs; + int yystate; int yyn; int yyresult; - /* Lookahead token as an internal (translated) token number. */ - int yytoken; - /* The variables used to return semantic value and location from the - action routines. */ - YYSTYPE yyval; - + /* Number of tokens to shift before error messages enabled. */ + int yyerrstatus; + /* Look-ahead token as an internal (translated) token number. */ + int yytoken = 0; #if YYERROR_VERBOSE /* Buffer for error messages, and its allocated size. */ char yymsgbuf[128]; @@ -4824,28 +4874,51 @@ YYSTYPE yylval; YYSIZE_T yymsg_alloc = sizeof yymsgbuf; #endif + /* Three stacks and their tools: + `yyss': related to states, + `yyvs': related to semantic values, + `yyls': related to locations. + + Refer to the stacks thru separate pointers, to allow yyoverflow + to reallocate them elsewhere. */ + + /* The state stack. */ + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; + + /* The semantic value stack. */ + YYSTYPE yyvsa[YYINITDEPTH]; + YYSTYPE *yyvs = yyvsa; + YYSTYPE *yyvsp; + + + #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) + YYSIZE_T yystacksize = YYINITDEPTH; + + /* The variables used to return semantic value and location from the + action routines. */ + YYSTYPE yyval; + + /* The number of symbols on the RHS of the reduced rule. Keep to zero when no symbol should be popped. */ int yylen = 0; - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; - yystacksize = YYINITDEPTH; - YYDPRINTF ((stderr, "Starting parse\n")); yystate = 0; yyerrstatus = 0; yynerrs = 0; - yychar = YYEMPTY; /* Cause a token to be read. */ + yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ + yyssp = yyss; yyvsp = yyvs; @@ -4875,6 +4948,7 @@ YYSTYPE yylval; YYSTYPE *yyvs1 = yyvs; yytype_int16 *yyss1 = yyss; + /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might @@ -4882,6 +4956,7 @@ YYSTYPE yylval; yyoverflow (YY_("memory exhausted"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); yyss = yyss1; @@ -4904,8 +4979,9 @@ YYSTYPE yylval; (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + YYSTACK_RELOCATE (yyss); + YYSTACK_RELOCATE (yyvs); + # undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); @@ -4916,6 +4992,7 @@ YYSTYPE yylval; yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; + YYDPRINTF ((stderr, "Stack size increased to %lu\n", (unsigned long int) yystacksize)); @@ -4925,9 +5002,6 @@ YYSTYPE yylval; YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - if (yystate == YYFINAL) - YYACCEPT; - goto yybackup; /*-----------. @@ -4936,16 +5010,16 @@ YYSTYPE yylval; yybackup: /* Do appropriate processing given the current state. Read a - lookahead token if we need one and don't already have one. */ + look-ahead token if we need one and don't already have one. */ - /* First try to decide what to do without reference to lookahead token. */ + /* First try to decide what to do without reference to look-ahead token. */ yyn = yypact[yystate]; - if (yypact_value_is_default (yyn)) + if (yyn == YYPACT_NINF) goto yydefault; - /* Not known => get a lookahead token if don't already have one. */ + /* Not known => get a look-ahead token if don't already have one. */ - /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ + /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); @@ -4971,22 +5045,26 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yytable_value_is_error (yyn)) - goto yyerrlab; + if (yyn == 0 || yyn == YYTABLE_NINF) + goto yyerrlab; yyn = -yyn; goto yyreduce; } + if (yyn == YYFINAL) + YYACCEPT; + /* Count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; - /* Shift the lookahead token. */ + /* Shift the look-ahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the shifted token. */ - yychar = YYEMPTY; + /* Discard the shifted token unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; yystate = yyn; *++yyvsp = yylval; @@ -5026,8 +5104,6 @@ yyreduce: switch (yyn) { case 2: - -/* Line 1806 of yacc.c */ #line 782 "parse.y" { lex_state = EXPR_BEG; @@ -5036,12 +5112,10 @@ yyreduce: /*% local_push(0); %*/ - } + ;} break; case 3: - -/* Line 1806 of yacc.c */ #line 791 "parse.y" { /*%%%*/ @@ -5062,12 +5136,10 @@ yyreduce: parser->result = dispatch1(program, $$); %*/ local_pop(); - } + ;} break; case 4: - -/* Line 1806 of yacc.c */ #line 814 "parse.y" { /*%%%*/ @@ -5076,12 +5148,10 @@ yyreduce: /*% %*/ (yyval.node) = (yyvsp[(1) - (2)].node); - } + ;} break; case 5: - -/* Line 1806 of yacc.c */ #line 825 "parse.y" { /*%%%*/ @@ -5090,12 +5160,10 @@ yyreduce: $$ = dispatch2(stmts_add, dispatch0(stmts_new), dispatch0(void_stmt)); %*/ - } + ;} break; case 6: - -/* Line 1806 of yacc.c */ #line 834 "parse.y" { /*%%%*/ @@ -5103,12 +5171,10 @@ yyreduce: /*% $$ = dispatch2(stmts_add, dispatch0(stmts_new), $1); %*/ - } + ;} break; case 7: - -/* Line 1806 of yacc.c */ #line 842 "parse.y" { /*%%%*/ @@ -5116,21 +5182,17 @@ yyreduce: /*% $$ = dispatch2(stmts_add, $1, $3); %*/ - } + ;} break; case 8: - -/* Line 1806 of yacc.c */ #line 850 "parse.y" { (yyval.node) = remove_begin((yyvsp[(2) - (2)].node)); - } + ;} break; case 10: - -/* Line 1806 of yacc.c */ #line 857 "parse.y" { if (in_def || in_single) { @@ -5140,12 +5202,10 @@ yyreduce: /* local_push(0); */ /*% %*/ - } + ;} break; case 11: - -/* Line 1806 of yacc.c */ #line 867 "parse.y" { /*%%%*/ @@ -5157,12 +5217,10 @@ yyreduce: /*% $$ = dispatch1(BEGIN, $4); %*/ - } + ;} break; case 12: - -/* Line 1806 of yacc.c */ #line 884 "parse.y" { /*%%%*/ @@ -5190,12 +5248,10 @@ yyreduce: escape_Qundef($3), escape_Qundef($4)); %*/ - } + ;} break; case 13: - -/* Line 1806 of yacc.c */ #line 914 "parse.y" { /*%%%*/ @@ -5204,12 +5260,10 @@ yyreduce: /*% %*/ (yyval.node) = (yyvsp[(1) - (2)].node); - } + ;} break; case 14: - -/* Line 1806 of yacc.c */ #line 925 "parse.y" { /*%%%*/ @@ -5218,12 +5272,10 @@ yyreduce: $$ = dispatch2(stmts_add, dispatch0(stmts_new), dispatch0(void_stmt)); %*/ - } + ;} break; case 15: - -/* Line 1806 of yacc.c */ #line 934 "parse.y" { /*%%%*/ @@ -5231,12 +5283,10 @@ yyreduce: /*% $$ = dispatch2(stmts_add, dispatch0(stmts_new), $1); %*/ - } + ;} break; case 16: - -/* Line 1806 of yacc.c */ #line 942 "parse.y" { /*%%%*/ @@ -5244,28 +5294,22 @@ yyreduce: /*% $$ = dispatch2(stmts_add, $1, $3); %*/ - } + ;} break; case 17: - -/* Line 1806 of yacc.c */ #line 950 "parse.y" { (yyval.node) = remove_begin((yyvsp[(2) - (2)].node)); - } + ;} break; case 18: - -/* Line 1806 of yacc.c */ #line 955 "parse.y" - {lex_state = EXPR_FNAME;} + {lex_state = EXPR_FNAME;;} break; case 19: - -/* Line 1806 of yacc.c */ #line 956 "parse.y" { /*%%%*/ @@ -5273,12 +5317,10 @@ yyreduce: /*% $$ = dispatch2(alias, $2, $4); %*/ - } + ;} break; case 20: - -/* Line 1806 of yacc.c */ #line 964 "parse.y" { /*%%%*/ @@ -5286,12 +5328,10 @@ yyreduce: /*% $$ = dispatch2(var_alias, $2, $3); %*/ - } + ;} break; case 21: - -/* Line 1806 of yacc.c */ #line 972 "parse.y" { /*%%%*/ @@ -5302,12 +5342,10 @@ yyreduce: /*% $$ = dispatch2(var_alias, $2, $3); %*/ - } + ;} break; case 22: - -/* Line 1806 of yacc.c */ #line 983 "parse.y" { /*%%%*/ @@ -5317,12 +5355,10 @@ yyreduce: $$ = dispatch2(var_alias, $2, $3); $$ = dispatch1(alias_error, $$); %*/ - } + ;} break; case 23: - -/* Line 1806 of yacc.c */ #line 993 "parse.y" { /*%%%*/ @@ -5330,12 +5366,10 @@ yyreduce: /*% $$ = dispatch1(undef, $2); %*/ - } + ;} break; case 24: - -/* Line 1806 of yacc.c */ #line 1001 "parse.y" { /*%%%*/ @@ -5344,12 +5378,10 @@ yyreduce: /*% $$ = dispatch2(if_mod, $3, $1); %*/ - } + ;} break; case 25: - -/* Line 1806 of yacc.c */ #line 1010 "parse.y" { /*%%%*/ @@ -5358,12 +5390,10 @@ yyreduce: /*% $$ = dispatch2(unless_mod, $3, $1); %*/ - } + ;} break; case 26: - -/* Line 1806 of yacc.c */ #line 1019 "parse.y" { /*%%%*/ @@ -5376,12 +5406,10 @@ yyreduce: /*% $$ = dispatch2(while_mod, $3, $1); %*/ - } + ;} break; case 27: - -/* Line 1806 of yacc.c */ #line 1032 "parse.y" { /*%%%*/ @@ -5394,12 +5422,10 @@ yyreduce: /*% $$ = dispatch2(until_mod, $3, $1); %*/ - } + ;} break; case 28: - -/* Line 1806 of yacc.c */ #line 1045 "parse.y" { /*%%%*/ @@ -5408,12 +5434,10 @@ yyreduce: /*% $$ = dispatch2(rescue_mod, $1, $3); %*/ - } + ;} break; case 29: - -/* Line 1806 of yacc.c */ #line 1054 "parse.y" { if (in_def || in_single) { @@ -5425,12 +5449,10 @@ yyreduce: /*% $$ = dispatch1(END, $3); %*/ - } + ;} break; case 31: - -/* Line 1806 of yacc.c */ #line 1067 "parse.y" { /*%%%*/ @@ -5440,12 +5462,10 @@ yyreduce: /*% $$ = dispatch2(massign, $1, $3); %*/ - } + ;} break; case 32: - -/* Line 1806 of yacc.c */ #line 1077 "parse.y" { /*%%%*/ @@ -5474,12 +5494,10 @@ yyreduce: /*% $$ = dispatch3(opassign, $1, $2, $3); %*/ - } + ;} break; case 33: - -/* Line 1806 of yacc.c */ #line 1106 "parse.y" { /*%%%*/ @@ -5500,12 +5518,10 @@ yyreduce: $$ = dispatch2(aref_field, $1, escape_Qundef($3)); $$ = dispatch3(opassign, $$, $5, $6); %*/ - } + ;} break; case 34: - -/* Line 1806 of yacc.c */ #line 1127 "parse.y" { /*%%%*/ @@ -5522,12 +5538,10 @@ yyreduce: $$ = dispatch3(field, $1, ripper_id2sym('.'), $3); $$ = dispatch3(opassign, $$, $4, $5); %*/ - } + ;} break; case 35: - -/* Line 1806 of yacc.c */ #line 1144 "parse.y" { /*%%%*/ @@ -5544,12 +5558,10 @@ yyreduce: $$ = dispatch3(field, $1, ripper_id2sym('.'), $3); $$ = dispatch3(opassign, $$, $4, $5); %*/ - } + ;} break; case 36: - -/* Line 1806 of yacc.c */ #line 1161 "parse.y" { /*%%%*/ @@ -5560,12 +5572,10 @@ yyreduce: $$ = dispatch3(opassign, $$, $4, $5); $$ = dispatch1(assign_error, $$); %*/ - } + ;} break; case 37: - -/* Line 1806 of yacc.c */ #line 1172 "parse.y" { /*%%%*/ @@ -5582,12 +5592,10 @@ yyreduce: $$ = dispatch3(field, $1, ripper_intern("::"), $3); $$ = dispatch3(opassign, $$, $4, $5); %*/ - } + ;} break; case 38: - -/* Line 1806 of yacc.c */ #line 1189 "parse.y" { /*%%%*/ @@ -5597,12 +5605,10 @@ yyreduce: $$ = dispatch2(assign, dispatch1(var_field, $1), $3); $$ = dispatch1(assign_error, $$); %*/ - } + ;} break; case 39: - -/* Line 1806 of yacc.c */ #line 1199 "parse.y" { /*%%%*/ @@ -5611,12 +5617,10 @@ yyreduce: /*% $$ = dispatch2(assign, $1, $3); %*/ - } + ;} break; case 40: - -/* Line 1806 of yacc.c */ #line 1208 "parse.y" { /*%%%*/ @@ -5625,12 +5629,10 @@ yyreduce: /*% $$ = dispatch2(massign, $1, $3); %*/ - } + ;} break; case 41: - -/* Line 1806 of yacc.c */ #line 1217 "parse.y" { /*%%%*/ @@ -5639,12 +5641,10 @@ yyreduce: /*% $$ = dispatch2(massign, $1, $3); %*/ - } + ;} break; case 43: - -/* Line 1806 of yacc.c */ #line 1229 "parse.y" { /*%%%*/ @@ -5653,12 +5653,10 @@ yyreduce: /*% $$ = dispatch2(assign, $1, $3); %*/ - } + ;} break; case 44: - -/* Line 1806 of yacc.c */ #line 1238 "parse.y" { /*%%%*/ @@ -5667,12 +5665,10 @@ yyreduce: /*% $$ = dispatch2(assign, $1, $3); %*/ - } + ;} break; case 46: - -/* Line 1806 of yacc.c */ #line 1251 "parse.y" { /*%%%*/ @@ -5680,12 +5676,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("and"), $3); %*/ - } + ;} break; case 47: - -/* Line 1806 of yacc.c */ #line 1259 "parse.y" { /*%%%*/ @@ -5693,12 +5687,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("or"), $3); %*/ - } + ;} break; case 48: - -/* Line 1806 of yacc.c */ #line 1267 "parse.y" { /*%%%*/ @@ -5706,12 +5698,10 @@ yyreduce: /*% $$ = dispatch2(unary, ripper_intern("not"), $3); %*/ - } + ;} break; case 49: - -/* Line 1806 of yacc.c */ #line 1275 "parse.y" { /*%%%*/ @@ -5719,12 +5709,10 @@ yyreduce: /*% $$ = dispatch2(unary, ripper_id2sym('!'), $2); %*/ - } + ;} break; case 51: - -/* Line 1806 of yacc.c */ #line 1286 "parse.y" { /*%%%*/ @@ -5734,12 +5722,10 @@ yyreduce: /*% $$ = $1; %*/ - } + ;} break; case 55: - -/* Line 1806 of yacc.c */ #line 1303 "parse.y" { /*%%%*/ @@ -5748,12 +5734,10 @@ yyreduce: $$ = dispatch3(call, $1, ripper_id2sym('.'), $3); $$ = method_arg($$, $4); %*/ - } + ;} break; case 56: - -/* Line 1806 of yacc.c */ #line 1312 "parse.y" { /*%%%*/ @@ -5762,12 +5746,10 @@ yyreduce: $$ = dispatch3(call, $1, ripper_intern("::"), $3); $$ = method_arg($$, $4); %*/ - } + ;} break; case 57: - -/* Line 1806 of yacc.c */ #line 1323 "parse.y" { (yyvsp[(1) - (1)].vars) = dyna_push(); @@ -5775,12 +5757,10 @@ yyreduce: (yyval.num) = ruby_sourceline; /*% %*/ - } + ;} break; case 58: - -/* Line 1806 of yacc.c */ #line 1333 "parse.y" { /*%%%*/ @@ -5790,12 +5770,10 @@ yyreduce: $$ = dispatch2(brace_block, escape_Qundef($3), $4); %*/ dyna_pop((yyvsp[(1) - (5)].vars)); - } + ;} break; case 59: - -/* Line 1806 of yacc.c */ #line 1345 "parse.y" { /*%%%*/ @@ -5804,12 +5782,10 @@ yyreduce: /*% $$ = dispatch2(command, $1, $2); %*/ - } + ;} break; case 60: - -/* Line 1806 of yacc.c */ #line 1354 "parse.y" { /*%%%*/ @@ -5821,12 +5797,10 @@ yyreduce: $$ = dispatch2(command, $1, $2); $$ = method_add_block($$, $3); %*/ - } + ;} break; case 61: - -/* Line 1806 of yacc.c */ #line 1366 "parse.y" { /*%%%*/ @@ -5835,12 +5809,10 @@ yyreduce: /*% $$ = dispatch4(command_call, $1, ripper_id2sym('.'), $3, $4); %*/ - } + ;} break; case 62: - -/* Line 1806 of yacc.c */ #line 1375 "parse.y" { /*%%%*/ @@ -5852,12 +5824,10 @@ yyreduce: $$ = dispatch4(command_call, $1, ripper_id2sym('.'), $3, $4); $$ = method_add_block($$, $5); %*/ - } + ;} break; case 63: - -/* Line 1806 of yacc.c */ #line 1387 "parse.y" { /*%%%*/ @@ -5866,12 +5836,10 @@ yyreduce: /*% $$ = dispatch4(command_call, $1, ripper_intern("::"), $3, $4); %*/ - } + ;} break; case 64: - -/* Line 1806 of yacc.c */ #line 1396 "parse.y" { /*%%%*/ @@ -5883,12 +5851,10 @@ yyreduce: $$ = dispatch4(command_call, $1, ripper_intern("::"), $3, $4); $$ = method_add_block($$, $5); %*/ - } + ;} break; case 65: - -/* Line 1806 of yacc.c */ #line 1408 "parse.y" { /*%%%*/ @@ -5897,12 +5863,10 @@ yyreduce: /*% $$ = dispatch1(super, $2); %*/ - } + ;} break; case 66: - -/* Line 1806 of yacc.c */ #line 1417 "parse.y" { /*%%%*/ @@ -5911,12 +5875,10 @@ yyreduce: /*% $$ = dispatch1(yield, $2); %*/ - } + ;} break; case 67: - -/* Line 1806 of yacc.c */ #line 1426 "parse.y" { /*%%%*/ @@ -5924,12 +5886,10 @@ yyreduce: /*% $$ = dispatch1(return, $2); %*/ - } + ;} break; case 68: - -/* Line 1806 of yacc.c */ #line 1434 "parse.y" { /*%%%*/ @@ -5937,12 +5897,10 @@ yyreduce: /*% $$ = dispatch1(break, $2); %*/ - } + ;} break; case 69: - -/* Line 1806 of yacc.c */ #line 1442 "parse.y" { /*%%%*/ @@ -5950,12 +5908,10 @@ yyreduce: /*% $$ = dispatch1(next, $2); %*/ - } + ;} break; case 71: - -/* Line 1806 of yacc.c */ #line 1453 "parse.y" { /*%%%*/ @@ -5963,12 +5919,10 @@ yyreduce: /*% $$ = dispatch1(mlhs_paren, $2); %*/ - } + ;} break; case 73: - -/* Line 1806 of yacc.c */ #line 1464 "parse.y" { /*%%%*/ @@ -5976,12 +5930,10 @@ yyreduce: /*% $$ = dispatch1(mlhs_paren, $2); %*/ - } + ;} break; case 74: - -/* Line 1806 of yacc.c */ #line 1474 "parse.y" { /*%%%*/ @@ -5989,12 +5941,10 @@ yyreduce: /*% $$ = $1; %*/ - } + ;} break; case 75: - -/* Line 1806 of yacc.c */ #line 1482 "parse.y" { /*%%%*/ @@ -6002,12 +5952,10 @@ yyreduce: /*% $$ = mlhs_add($1, $2); %*/ - } + ;} break; case 76: - -/* Line 1806 of yacc.c */ #line 1490 "parse.y" { /*%%%*/ @@ -6015,12 +5963,10 @@ yyreduce: /*% $$ = mlhs_add_star($1, $3); %*/ - } + ;} break; case 77: - -/* Line 1806 of yacc.c */ #line 1498 "parse.y" { /*%%%*/ @@ -6029,12 +5975,10 @@ yyreduce: $1 = mlhs_add_star($1, $3); $$ = mlhs_add($1, $5); %*/ - } + ;} break; case 78: - -/* Line 1806 of yacc.c */ #line 1507 "parse.y" { /*%%%*/ @@ -6042,12 +5986,10 @@ yyreduce: /*% $$ = mlhs_add_star($1, Qnil); %*/ - } + ;} break; case 79: - -/* Line 1806 of yacc.c */ #line 1515 "parse.y" { /*%%%*/ @@ -6056,12 +5998,10 @@ yyreduce: $1 = mlhs_add_star($1, Qnil); $$ = mlhs_add($1, $4); %*/ - } + ;} break; case 80: - -/* Line 1806 of yacc.c */ #line 1524 "parse.y" { /*%%%*/ @@ -6069,12 +6009,10 @@ yyreduce: /*% $$ = mlhs_add_star(mlhs_new(), $2); %*/ - } + ;} break; case 81: - -/* Line 1806 of yacc.c */ #line 1532 "parse.y" { /*%%%*/ @@ -6083,12 +6021,10 @@ yyreduce: $2 = mlhs_add_star(mlhs_new(), $2); $$ = mlhs_add($2, $4); %*/ - } + ;} break; case 82: - -/* Line 1806 of yacc.c */ #line 1541 "parse.y" { /*%%%*/ @@ -6096,12 +6032,10 @@ yyreduce: /*% $$ = mlhs_add_star(mlhs_new(), Qnil); %*/ - } + ;} break; case 83: - -/* Line 1806 of yacc.c */ #line 1549 "parse.y" { /*%%%*/ @@ -6110,12 +6044,10 @@ yyreduce: $$ = mlhs_add_star(mlhs_new(), Qnil); $$ = mlhs_add($$, $3); %*/ - } + ;} break; case 85: - -/* Line 1806 of yacc.c */ #line 1561 "parse.y" { /*%%%*/ @@ -6123,12 +6055,10 @@ yyreduce: /*% $$ = dispatch1(mlhs_paren, $2); %*/ - } + ;} break; case 86: - -/* Line 1806 of yacc.c */ #line 1571 "parse.y" { /*%%%*/ @@ -6136,12 +6066,10 @@ yyreduce: /*% $$ = mlhs_add(mlhs_new(), $1); %*/ - } + ;} break; case 87: - -/* Line 1806 of yacc.c */ #line 1579 "parse.y" { /*%%%*/ @@ -6149,12 +6077,10 @@ yyreduce: /*% $$ = mlhs_add($1, $2); %*/ - } + ;} break; case 88: - -/* Line 1806 of yacc.c */ #line 1589 "parse.y" { /*%%%*/ @@ -6162,12 +6088,10 @@ yyreduce: /*% $$ = mlhs_add(mlhs_new(), $1); %*/ - } + ;} break; case 89: - -/* Line 1806 of yacc.c */ #line 1597 "parse.y" { /*%%%*/ @@ -6175,30 +6099,24 @@ yyreduce: /*% $$ = mlhs_add($1, $3); %*/ - } + ;} break; case 90: - -/* Line 1806 of yacc.c */ #line 1607 "parse.y" { (yyval.node) = assignable((yyvsp[(1) - (1)].id), 0); - } + ;} break; case 91: - -/* Line 1806 of yacc.c */ #line 1611 "parse.y" { (yyval.node) = assignable((yyvsp[(1) - (1)].id), 0); - } + ;} break; case 92: - -/* Line 1806 of yacc.c */ #line 1615 "parse.y" { /*%%%*/ @@ -6206,12 +6124,10 @@ yyreduce: /*% $$ = dispatch2(aref_field, $1, escape_Qundef($3)); %*/ - } + ;} break; case 93: - -/* Line 1806 of yacc.c */ #line 1623 "parse.y" { /*%%%*/ @@ -6219,12 +6135,10 @@ yyreduce: /*% $$ = dispatch3(field, $1, ripper_id2sym('.'), $3); %*/ - } + ;} break; case 94: - -/* Line 1806 of yacc.c */ #line 1631 "parse.y" { /*%%%*/ @@ -6232,12 +6146,10 @@ yyreduce: /*% $$ = dispatch2(const_path_field, $1, $3); %*/ - } + ;} break; case 95: - -/* Line 1806 of yacc.c */ #line 1639 "parse.y" { /*%%%*/ @@ -6245,12 +6157,10 @@ yyreduce: /*% $$ = dispatch3(field, $1, ripper_id2sym('.'), $3); %*/ - } + ;} break; case 96: - -/* Line 1806 of yacc.c */ #line 1647 "parse.y" { /*%%%*/ @@ -6262,12 +6172,10 @@ yyreduce: yyerror("dynamic constant assignment"); $$ = dispatch2(const_path_field, $1, $3); %*/ - } + ;} break; case 97: - -/* Line 1806 of yacc.c */ #line 1659 "parse.y" { /*%%%*/ @@ -6277,12 +6185,10 @@ yyreduce: /*% $$ = dispatch1(top_const_field, $2); %*/ - } + ;} break; case 98: - -/* Line 1806 of yacc.c */ #line 1669 "parse.y" { /*%%%*/ @@ -6292,12 +6198,10 @@ yyreduce: $$ = dispatch1(var_field, $1); $$ = dispatch1(assign_error, $$); %*/ - } + ;} break; case 99: - -/* Line 1806 of yacc.c */ #line 1681 "parse.y" { (yyval.node) = assignable((yyvsp[(1) - (1)].id), 0); @@ -6306,12 +6210,10 @@ yyreduce: /*% $$ = dispatch1(var_field, $$); %*/ - } + ;} break; case 100: - -/* Line 1806 of yacc.c */ #line 1690 "parse.y" { (yyval.node) = assignable((yyvsp[(1) - (1)].id), 0); @@ -6320,12 +6222,10 @@ yyreduce: /*% $$ = dispatch1(var_field, $$); %*/ - } + ;} break; case 101: - -/* Line 1806 of yacc.c */ #line 1699 "parse.y" { /*%%%*/ @@ -6333,12 +6233,10 @@ yyreduce: /*% $$ = dispatch2(aref_field, $1, escape_Qundef($3)); %*/ - } + ;} break; case 102: - -/* Line 1806 of yacc.c */ #line 1707 "parse.y" { /*%%%*/ @@ -6346,12 +6244,10 @@ yyreduce: /*% $$ = dispatch3(field, $1, ripper_id2sym('.'), $3); %*/ - } + ;} break; case 103: - -/* Line 1806 of yacc.c */ #line 1715 "parse.y" { /*%%%*/ @@ -6359,12 +6255,10 @@ yyreduce: /*% $$ = dispatch3(field, $1, ripper_intern("::"), $3); %*/ - } + ;} break; case 104: - -/* Line 1806 of yacc.c */ #line 1723 "parse.y" { /*%%%*/ @@ -6372,12 +6266,10 @@ yyreduce: /*% $$ = dispatch3(field, $1, ripper_id2sym('.'), $3); %*/ - } + ;} break; case 105: - -/* Line 1806 of yacc.c */ #line 1731 "parse.y" { /*%%%*/ @@ -6390,12 +6282,10 @@ yyreduce: $$ = dispatch1(assign_error, $$); } %*/ - } + ;} break; case 106: - -/* Line 1806 of yacc.c */ #line 1744 "parse.y" { /*%%%*/ @@ -6408,12 +6298,10 @@ yyreduce: $$ = dispatch1(assign_error, $$); } %*/ - } + ;} break; case 107: - -/* Line 1806 of yacc.c */ #line 1757 "parse.y" { /*%%%*/ @@ -6422,12 +6310,10 @@ yyreduce: /*% $$ = dispatch1(assign_error, $1); %*/ - } + ;} break; case 108: - -/* Line 1806 of yacc.c */ #line 1768 "parse.y" { /*%%%*/ @@ -6435,12 +6321,10 @@ yyreduce: /*% $$ = dispatch1(class_name_error, $1); %*/ - } + ;} break; case 110: - -/* Line 1806 of yacc.c */ #line 1779 "parse.y" { /*%%%*/ @@ -6448,12 +6332,10 @@ yyreduce: /*% $$ = dispatch1(top_const_ref, $2); %*/ - } + ;} break; case 111: - -/* Line 1806 of yacc.c */ #line 1787 "parse.y" { /*%%%*/ @@ -6461,12 +6343,10 @@ yyreduce: /*% $$ = dispatch1(const_ref, $1); %*/ - } + ;} break; case 112: - -/* Line 1806 of yacc.c */ #line 1795 "parse.y" { /*%%%*/ @@ -6474,22 +6354,18 @@ yyreduce: /*% $$ = dispatch2(const_path_ref, $1, $3); %*/ - } + ;} break; case 116: - -/* Line 1806 of yacc.c */ #line 1808 "parse.y" { lex_state = EXPR_ENDFN; (yyval.id) = (yyvsp[(1) - (1)].id); - } + ;} break; case 117: - -/* Line 1806 of yacc.c */ #line 1813 "parse.y" { lex_state = EXPR_ENDFN; @@ -6498,12 +6374,10 @@ yyreduce: /*% $$ = $1; %*/ - } + ;} break; case 120: - -/* Line 1806 of yacc.c */ #line 1828 "parse.y" { /*%%%*/ @@ -6511,12 +6385,10 @@ yyreduce: /*% $$ = dispatch1(symbol_literal, $1); %*/ - } + ;} break; case 122: - -/* Line 1806 of yacc.c */ #line 1839 "parse.y" { /*%%%*/ @@ -6524,19 +6396,15 @@ yyreduce: /*% $$ = rb_ary_new3(1, $1); %*/ - } + ;} break; case 123: - -/* Line 1806 of yacc.c */ #line 1846 "parse.y" - {lex_state = EXPR_FNAME;} + {lex_state = EXPR_FNAME;;} break; case 124: - -/* Line 1806 of yacc.c */ #line 1847 "parse.y" { /*%%%*/ @@ -6544,215 +6412,155 @@ yyreduce: /*% rb_ary_push($1, $4); %*/ - } + ;} break; case 125: - -/* Line 1806 of yacc.c */ #line 1856 "parse.y" - { ifndef_ripper((yyval.id) = '|'); } + { ifndef_ripper((yyval.id) = '|'); ;} break; case 126: - -/* Line 1806 of yacc.c */ #line 1857 "parse.y" - { ifndef_ripper((yyval.id) = '^'); } + { ifndef_ripper((yyval.id) = '^'); ;} break; case 127: - -/* Line 1806 of yacc.c */ #line 1858 "parse.y" - { ifndef_ripper((yyval.id) = '&'); } + { ifndef_ripper((yyval.id) = '&'); ;} break; case 128: - -/* Line 1806 of yacc.c */ #line 1859 "parse.y" - { ifndef_ripper((yyval.id) = tCMP); } + { ifndef_ripper((yyval.id) = tCMP); ;} break; case 129: - -/* Line 1806 of yacc.c */ #line 1860 "parse.y" - { ifndef_ripper((yyval.id) = tEQ); } + { ifndef_ripper((yyval.id) = tEQ); ;} break; case 130: - -/* Line 1806 of yacc.c */ #line 1861 "parse.y" - { ifndef_ripper((yyval.id) = tEQQ); } + { ifndef_ripper((yyval.id) = tEQQ); ;} break; case 131: - -/* Line 1806 of yacc.c */ #line 1862 "parse.y" - { ifndef_ripper((yyval.id) = tMATCH); } + { ifndef_ripper((yyval.id) = tMATCH); ;} break; case 132: - -/* Line 1806 of yacc.c */ #line 1863 "parse.y" - { ifndef_ripper((yyval.id) = tNMATCH); } + { ifndef_ripper((yyval.id) = tNMATCH); ;} break; case 133: - -/* Line 1806 of yacc.c */ #line 1864 "parse.y" - { ifndef_ripper((yyval.id) = '>'); } + { ifndef_ripper((yyval.id) = '>'); ;} break; case 134: - -/* Line 1806 of yacc.c */ #line 1865 "parse.y" - { ifndef_ripper((yyval.id) = tGEQ); } + { ifndef_ripper((yyval.id) = tGEQ); ;} break; case 135: - -/* Line 1806 of yacc.c */ #line 1866 "parse.y" - { ifndef_ripper((yyval.id) = '<'); } + { ifndef_ripper((yyval.id) = '<'); ;} break; case 136: - -/* Line 1806 of yacc.c */ #line 1867 "parse.y" - { ifndef_ripper((yyval.id) = tLEQ); } + { ifndef_ripper((yyval.id) = tLEQ); ;} break; case 137: - -/* Line 1806 of yacc.c */ #line 1868 "parse.y" - { ifndef_ripper((yyval.id) = tNEQ); } + { ifndef_ripper((yyval.id) = tNEQ); ;} break; case 138: - -/* Line 1806 of yacc.c */ #line 1869 "parse.y" - { ifndef_ripper((yyval.id) = tLSHFT); } + { ifndef_ripper((yyval.id) = tLSHFT); ;} break; case 139: - -/* Line 1806 of yacc.c */ #line 1870 "parse.y" - { ifndef_ripper((yyval.id) = tRSHFT); } + { ifndef_ripper((yyval.id) = tRSHFT); ;} break; case 140: - -/* Line 1806 of yacc.c */ #line 1871 "parse.y" - { ifndef_ripper((yyval.id) = '+'); } + { ifndef_ripper((yyval.id) = '+'); ;} break; case 141: - -/* Line 1806 of yacc.c */ #line 1872 "parse.y" - { ifndef_ripper((yyval.id) = '-'); } + { ifndef_ripper((yyval.id) = '-'); ;} break; case 142: - -/* Line 1806 of yacc.c */ #line 1873 "parse.y" - { ifndef_ripper((yyval.id) = '*'); } + { ifndef_ripper((yyval.id) = '*'); ;} break; case 143: - -/* Line 1806 of yacc.c */ #line 1874 "parse.y" - { ifndef_ripper((yyval.id) = '*'); } + { ifndef_ripper((yyval.id) = '*'); ;} break; case 144: - -/* Line 1806 of yacc.c */ #line 1875 "parse.y" - { ifndef_ripper((yyval.id) = '/'); } + { ifndef_ripper((yyval.id) = '/'); ;} break; case 145: - -/* Line 1806 of yacc.c */ #line 1876 "parse.y" - { ifndef_ripper((yyval.id) = '%'); } + { ifndef_ripper((yyval.id) = '%'); ;} break; case 146: - -/* Line 1806 of yacc.c */ #line 1877 "parse.y" - { ifndef_ripper((yyval.id) = tPOW); } + { ifndef_ripper((yyval.id) = tPOW); ;} break; case 147: - -/* Line 1806 of yacc.c */ #line 1878 "parse.y" - { ifndef_ripper((yyval.id) = '!'); } + { ifndef_ripper((yyval.id) = '!'); ;} break; case 148: - -/* Line 1806 of yacc.c */ #line 1879 "parse.y" - { ifndef_ripper((yyval.id) = '~'); } + { ifndef_ripper((yyval.id) = '~'); ;} break; case 149: - -/* Line 1806 of yacc.c */ #line 1880 "parse.y" - { ifndef_ripper((yyval.id) = tUPLUS); } + { ifndef_ripper((yyval.id) = tUPLUS); ;} break; case 150: - -/* Line 1806 of yacc.c */ #line 1881 "parse.y" - { ifndef_ripper((yyval.id) = tUMINUS); } + { ifndef_ripper((yyval.id) = tUMINUS); ;} break; case 151: - -/* Line 1806 of yacc.c */ #line 1882 "parse.y" - { ifndef_ripper((yyval.id) = tAREF); } + { ifndef_ripper((yyval.id) = tAREF); ;} break; case 152: - -/* Line 1806 of yacc.c */ #line 1883 "parse.y" - { ifndef_ripper((yyval.id) = tASET); } + { ifndef_ripper((yyval.id) = tASET); ;} break; case 153: - -/* Line 1806 of yacc.c */ #line 1884 "parse.y" - { ifndef_ripper((yyval.id) = '`'); } + { ifndef_ripper((yyval.id) = '`'); ;} break; case 195: - -/* Line 1806 of yacc.c */ #line 1902 "parse.y" { /*%%%*/ @@ -6761,12 +6569,10 @@ yyreduce: /*% $$ = dispatch2(assign, $1, $3); %*/ - } + ;} break; case 196: - -/* Line 1806 of yacc.c */ #line 1911 "parse.y" { /*%%%*/ @@ -6776,12 +6582,10 @@ yyreduce: /*% $$ = dispatch2(assign, $1, dispatch2(rescue_mod, $3, $5)); %*/ - } + ;} break; case 197: - -/* Line 1806 of yacc.c */ #line 1921 "parse.y" { /*%%%*/ @@ -6810,12 +6614,10 @@ yyreduce: /*% $$ = dispatch3(opassign, $1, $2, $3); %*/ - } + ;} break; case 198: - -/* Line 1806 of yacc.c */ #line 1950 "parse.y" { /*%%%*/ @@ -6846,12 +6648,10 @@ yyreduce: $3 = dispatch2(rescue_mod, $3, $5); $$ = dispatch3(opassign, $1, $2, $3); %*/ - } + ;} break; case 199: - -/* Line 1806 of yacc.c */ #line 1981 "parse.y" { /*%%%*/ @@ -6877,12 +6677,10 @@ yyreduce: $1 = dispatch2(aref_field, $1, escape_Qundef($3)); $$ = dispatch3(opassign, $1, $5, $6); %*/ - } + ;} break; case 200: - -/* Line 1806 of yacc.c */ #line 2007 "parse.y" { /*%%%*/ @@ -6899,12 +6697,10 @@ yyreduce: $1 = dispatch3(field, $1, ripper_id2sym('.'), $3); $$ = dispatch3(opassign, $1, $4, $5); %*/ - } + ;} break; case 201: - -/* Line 1806 of yacc.c */ #line 2024 "parse.y" { /*%%%*/ @@ -6921,12 +6717,10 @@ yyreduce: $1 = dispatch3(field, $1, ripper_id2sym('.'), $3); $$ = dispatch3(opassign, $1, $4, $5); %*/ - } + ;} break; case 202: - -/* Line 1806 of yacc.c */ #line 2041 "parse.y" { /*%%%*/ @@ -6943,12 +6737,10 @@ yyreduce: $1 = dispatch3(field, $1, ripper_intern("::"), $3); $$ = dispatch3(opassign, $1, $4, $5); %*/ - } + ;} break; case 203: - -/* Line 1806 of yacc.c */ #line 2058 "parse.y" { /*%%%*/ @@ -6959,12 +6751,10 @@ yyreduce: $$ = dispatch3(opassign, $$, $4, $5); $$ = dispatch1(assign_error, $$); %*/ - } + ;} break; case 204: - -/* Line 1806 of yacc.c */ #line 2069 "parse.y" { /*%%%*/ @@ -6975,12 +6765,10 @@ yyreduce: $$ = dispatch3(opassign, $$, $3, $4); $$ = dispatch1(assign_error, $$); %*/ - } + ;} break; case 205: - -/* Line 1806 of yacc.c */ #line 2080 "parse.y" { /*%%%*/ @@ -6991,12 +6779,10 @@ yyreduce: $$ = dispatch3(opassign, $$, $2, $3); $$ = dispatch1(assign_error, $$); %*/ - } + ;} break; case 206: - -/* Line 1806 of yacc.c */ #line 2091 "parse.y" { /*%%%*/ @@ -7010,12 +6796,10 @@ yyreduce: /*% $$ = dispatch2(dot2, $1, $3); %*/ - } + ;} break; case 207: - -/* Line 1806 of yacc.c */ #line 2105 "parse.y" { /*%%%*/ @@ -7029,12 +6813,10 @@ yyreduce: /*% $$ = dispatch2(dot3, $1, $3); %*/ - } + ;} break; case 208: - -/* Line 1806 of yacc.c */ #line 2119 "parse.y" { /*%%%*/ @@ -7042,12 +6824,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ID2SYM('+'), $3); %*/ - } + ;} break; case 209: - -/* Line 1806 of yacc.c */ #line 2127 "parse.y" { /*%%%*/ @@ -7055,12 +6835,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ID2SYM('-'), $3); %*/ - } + ;} break; case 210: - -/* Line 1806 of yacc.c */ #line 2135 "parse.y" { /*%%%*/ @@ -7068,12 +6846,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ID2SYM('*'), $3); %*/ - } + ;} break; case 211: - -/* Line 1806 of yacc.c */ #line 2143 "parse.y" { /*%%%*/ @@ -7081,12 +6857,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ID2SYM('/'), $3); %*/ - } + ;} break; case 212: - -/* Line 1806 of yacc.c */ #line 2151 "parse.y" { /*%%%*/ @@ -7094,12 +6868,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ID2SYM('%'), $3); %*/ - } + ;} break; case 213: - -/* Line 1806 of yacc.c */ #line 2159 "parse.y" { /*%%%*/ @@ -7107,12 +6879,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("**"), $3); %*/ - } + ;} break; case 214: - -/* Line 1806 of yacc.c */ #line 2167 "parse.y" { /*%%%*/ @@ -7121,12 +6891,10 @@ yyreduce: $$ = dispatch3(binary, $2, ripper_intern("**"), $4); $$ = dispatch2(unary, ripper_intern("-@"), $$); %*/ - } + ;} break; case 215: - -/* Line 1806 of yacc.c */ #line 2176 "parse.y" { /*%%%*/ @@ -7135,12 +6903,10 @@ yyreduce: $$ = dispatch3(binary, $2, ripper_intern("**"), $4); $$ = dispatch2(unary, ripper_intern("-@"), $$); %*/ - } + ;} break; case 216: - -/* Line 1806 of yacc.c */ #line 2185 "parse.y" { /*%%%*/ @@ -7148,12 +6914,10 @@ yyreduce: /*% $$ = dispatch2(unary, ripper_intern("+@"), $2); %*/ - } + ;} break; case 217: - -/* Line 1806 of yacc.c */ #line 2193 "parse.y" { /*%%%*/ @@ -7161,12 +6925,10 @@ yyreduce: /*% $$ = dispatch2(unary, ripper_intern("-@"), $2); %*/ - } + ;} break; case 218: - -/* Line 1806 of yacc.c */ #line 2201 "parse.y" { /*%%%*/ @@ -7174,12 +6936,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ID2SYM('|'), $3); %*/ - } + ;} break; case 219: - -/* Line 1806 of yacc.c */ #line 2209 "parse.y" { /*%%%*/ @@ -7187,12 +6947,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ID2SYM('^'), $3); %*/ - } + ;} break; case 220: - -/* Line 1806 of yacc.c */ #line 2217 "parse.y" { /*%%%*/ @@ -7200,12 +6958,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ID2SYM('&'), $3); %*/ - } + ;} break; case 221: - -/* Line 1806 of yacc.c */ #line 2225 "parse.y" { /*%%%*/ @@ -7213,12 +6969,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("<=>"), $3); %*/ - } + ;} break; case 222: - -/* Line 1806 of yacc.c */ #line 2233 "parse.y" { /*%%%*/ @@ -7226,12 +6980,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ID2SYM('>'), $3); %*/ - } + ;} break; case 223: - -/* Line 1806 of yacc.c */ #line 2241 "parse.y" { /*%%%*/ @@ -7239,12 +6991,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern(">="), $3); %*/ - } + ;} break; case 224: - -/* Line 1806 of yacc.c */ #line 2249 "parse.y" { /*%%%*/ @@ -7252,12 +7002,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ID2SYM('<'), $3); %*/ - } + ;} break; case 225: - -/* Line 1806 of yacc.c */ #line 2257 "parse.y" { /*%%%*/ @@ -7265,12 +7013,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("<="), $3); %*/ - } + ;} break; case 226: - -/* Line 1806 of yacc.c */ #line 2265 "parse.y" { /*%%%*/ @@ -7278,12 +7024,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("=="), $3); %*/ - } + ;} break; case 227: - -/* Line 1806 of yacc.c */ #line 2273 "parse.y" { /*%%%*/ @@ -7291,12 +7035,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("==="), $3); %*/ - } + ;} break; case 228: - -/* Line 1806 of yacc.c */ #line 2281 "parse.y" { /*%%%*/ @@ -7304,12 +7046,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("!="), $3); %*/ - } + ;} break; case 229: - -/* Line 1806 of yacc.c */ #line 2289 "parse.y" { /*%%%*/ @@ -7320,12 +7060,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("=~"), $3); %*/ - } + ;} break; case 230: - -/* Line 1806 of yacc.c */ #line 2300 "parse.y" { /*%%%*/ @@ -7333,12 +7071,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("!~"), $3); %*/ - } + ;} break; case 231: - -/* Line 1806 of yacc.c */ #line 2308 "parse.y" { /*%%%*/ @@ -7346,12 +7082,10 @@ yyreduce: /*% $$ = dispatch2(unary, ID2SYM('!'), $2); %*/ - } + ;} break; case 232: - -/* Line 1806 of yacc.c */ #line 2316 "parse.y" { /*%%%*/ @@ -7359,12 +7093,10 @@ yyreduce: /*% $$ = dispatch2(unary, ID2SYM('~'), $2); %*/ - } + ;} break; case 233: - -/* Line 1806 of yacc.c */ #line 2324 "parse.y" { /*%%%*/ @@ -7372,12 +7104,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("<<"), $3); %*/ - } + ;} break; case 234: - -/* Line 1806 of yacc.c */ #line 2332 "parse.y" { /*%%%*/ @@ -7385,12 +7115,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern(">>"), $3); %*/ - } + ;} break; case 235: - -/* Line 1806 of yacc.c */ #line 2340 "parse.y" { /*%%%*/ @@ -7398,12 +7126,10 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("&&"), $3); %*/ - } + ;} break; case 236: - -/* Line 1806 of yacc.c */ #line 2348 "parse.y" { /*%%%*/ @@ -7411,19 +7137,15 @@ yyreduce: /*% $$ = dispatch3(binary, $1, ripper_intern("||"), $3); %*/ - } + ;} break; case 237: - -/* Line 1806 of yacc.c */ #line 2355 "parse.y" - {in_defined = 1;} + {in_defined = 1;;} break; case 238: - -/* Line 1806 of yacc.c */ #line 2356 "parse.y" { /*%%%*/ @@ -7433,12 +7155,10 @@ yyreduce: in_defined = 0; $$ = dispatch1(defined, $4); %*/ - } + ;} break; case 239: - -/* Line 1806 of yacc.c */ #line 2366 "parse.y" { /*%%%*/ @@ -7448,21 +7168,17 @@ yyreduce: /*% $$ = dispatch3(ifop, $1, $3, $6); %*/ - } + ;} break; case 240: - -/* Line 1806 of yacc.c */ #line 2376 "parse.y" { (yyval.node) = (yyvsp[(1) - (1)].node); - } + ;} break; case 241: - -/* Line 1806 of yacc.c */ #line 2382 "parse.y" { /*%%%*/ @@ -7472,21 +7188,17 @@ yyreduce: /*% $$ = $1; %*/ - } + ;} break; case 243: - -/* Line 1806 of yacc.c */ #line 2395 "parse.y" { (yyval.node) = (yyvsp[(1) - (2)].node); - } + ;} break; case 244: - -/* Line 1806 of yacc.c */ #line 2399 "parse.y" { /*%%%*/ @@ -7494,12 +7206,10 @@ yyreduce: /*% $$ = arg_add_assocs($1, $3); %*/ - } + ;} break; case 245: - -/* Line 1806 of yacc.c */ #line 2407 "parse.y" { /*%%%*/ @@ -7507,12 +7217,10 @@ yyreduce: /*% $$ = arg_add_assocs(arg_new(), $1); %*/ - } + ;} break; case 246: - -/* Line 1806 of yacc.c */ #line 2417 "parse.y" { /*%%%*/ @@ -7520,21 +7228,17 @@ yyreduce: /*% $$ = dispatch1(arg_paren, escape_Qundef($2)); %*/ - } + ;} break; case 251: - -/* Line 1806 of yacc.c */ #line 2433 "parse.y" { (yyval.node) = (yyvsp[(1) - (2)].node); - } + ;} break; case 252: - -/* Line 1806 of yacc.c */ #line 2437 "parse.y" { /*%%%*/ @@ -7542,12 +7246,10 @@ yyreduce: /*% $$ = arg_add_assocs($1, $3); %*/ - } + ;} break; case 253: - -/* Line 1806 of yacc.c */ #line 2445 "parse.y" { /*%%%*/ @@ -7555,12 +7257,10 @@ yyreduce: /*% $$ = arg_add_assocs(arg_new(), $1); %*/ - } + ;} break; case 254: - -/* Line 1806 of yacc.c */ #line 2455 "parse.y" { /*%%%*/ @@ -7569,12 +7269,10 @@ yyreduce: /*% $$ = arg_add(arg_new(), $1); %*/ - } + ;} break; case 255: - -/* Line 1806 of yacc.c */ #line 2464 "parse.y" { /*%%%*/ @@ -7582,12 +7280,10 @@ yyreduce: /*% $$ = arg_add_optblock($1, $2); %*/ - } + ;} break; case 256: - -/* Line 1806 of yacc.c */ #line 2472 "parse.y" { /*%%%*/ @@ -7597,12 +7293,10 @@ yyreduce: $$ = arg_add_assocs(arg_new(), $1); $$ = arg_add_optblock($$, $2); %*/ - } + ;} break; case 257: - -/* Line 1806 of yacc.c */ #line 2482 "parse.y" { /*%%%*/ @@ -7611,33 +7305,27 @@ yyreduce: /*% $$ = arg_add_optblock(arg_add_assocs($1, $3), $4); %*/ - } + ;} break; case 259: - -/* Line 1806 of yacc.c */ #line 2499 "parse.y" { (yyval.val) = cmdarg_stack; CMDARG_PUSH(1); - } + ;} break; case 260: - -/* Line 1806 of yacc.c */ #line 2504 "parse.y" { /* CMDARG_POP() */ cmdarg_stack = (yyvsp[(1) - (2)].val); (yyval.node) = (yyvsp[(2) - (2)].node); - } + ;} break; case 261: - -/* Line 1806 of yacc.c */ #line 2512 "parse.y" { /*%%%*/ @@ -7645,30 +7333,24 @@ yyreduce: /*% $$ = $2; %*/ - } + ;} break; case 262: - -/* Line 1806 of yacc.c */ #line 2522 "parse.y" { (yyval.node) = (yyvsp[(2) - (2)].node); - } + ;} break; case 263: - -/* Line 1806 of yacc.c */ #line 2526 "parse.y" { (yyval.node) = 0; - } + ;} break; case 264: - -/* Line 1806 of yacc.c */ #line 2532 "parse.y" { /*%%%*/ @@ -7676,12 +7358,10 @@ yyreduce: /*% $$ = arg_add(arg_new(), $1); %*/ - } + ;} break; case 265: - -/* Line 1806 of yacc.c */ #line 2540 "parse.y" { /*%%%*/ @@ -7689,12 +7369,10 @@ yyreduce: /*% $$ = arg_add_star(arg_new(), $2); %*/ - } + ;} break; case 266: - -/* Line 1806 of yacc.c */ #line 2548 "parse.y" { /*%%%*/ @@ -7708,12 +7386,10 @@ yyreduce: /*% $$ = arg_add($1, $3); %*/ - } + ;} break; case 267: - -/* Line 1806 of yacc.c */ #line 2562 "parse.y" { /*%%%*/ @@ -7727,12 +7403,10 @@ yyreduce: /*% $$ = arg_add_star($1, $4); %*/ - } + ;} break; case 268: - -/* Line 1806 of yacc.c */ #line 2578 "parse.y" { /*%%%*/ @@ -7746,12 +7420,10 @@ yyreduce: /*% $$ = mrhs_add(args2mrhs($1), $3); %*/ - } + ;} break; case 269: - -/* Line 1806 of yacc.c */ #line 2592 "parse.y" { /*%%%*/ @@ -7766,12 +7438,10 @@ yyreduce: /*% $$ = mrhs_add_star(args2mrhs($1), $4); %*/ - } + ;} break; case 270: - -/* Line 1806 of yacc.c */ #line 2607 "parse.y" { /*%%%*/ @@ -7779,12 +7449,10 @@ yyreduce: /*% $$ = mrhs_add_star(mrhs_new(), $2); %*/ - } + ;} break; case 279: - -/* Line 1806 of yacc.c */ #line 2625 "parse.y" { /*%%%*/ @@ -7792,24 +7460,20 @@ yyreduce: /*% $$ = method_arg(dispatch1(fcall, $1), arg_new()); %*/ - } + ;} break; case 280: - -/* Line 1806 of yacc.c */ #line 2633 "parse.y" { /*%%%*/ (yyval.num) = ruby_sourceline; /*% %*/ - } + ;} break; case 281: - -/* Line 1806 of yacc.c */ #line 2641 "parse.y" { /*%%%*/ @@ -7826,19 +7490,15 @@ yyreduce: /*% $$ = dispatch1(begin, $3); %*/ - } + ;} break; case 282: - -/* Line 1806 of yacc.c */ #line 2657 "parse.y" - {lex_state = EXPR_ENDARG;} + {lex_state = EXPR_ENDARG;;} break; case 283: - -/* Line 1806 of yacc.c */ #line 2658 "parse.y" { rb_warning0("(...) interpreted as grouped expression"); @@ -7847,12 +7507,10 @@ yyreduce: /*% $$ = dispatch1(paren, $2); %*/ - } + ;} break; case 284: - -/* Line 1806 of yacc.c */ #line 2667 "parse.y" { /*%%%*/ @@ -7860,12 +7518,10 @@ yyreduce: /*% $$ = dispatch1(paren, $2); %*/ - } + ;} break; case 285: - -/* Line 1806 of yacc.c */ #line 2675 "parse.y" { /*%%%*/ @@ -7873,12 +7529,10 @@ yyreduce: /*% $$ = dispatch2(const_path_ref, $1, $3); %*/ - } + ;} break; case 286: - -/* Line 1806 of yacc.c */ #line 2683 "parse.y" { /*%%%*/ @@ -7886,12 +7540,10 @@ yyreduce: /*% $$ = dispatch1(top_const_ref, $2); %*/ - } + ;} break; case 287: - -/* Line 1806 of yacc.c */ #line 2691 "parse.y" { /*%%%*/ @@ -7904,12 +7556,10 @@ yyreduce: /*% $$ = dispatch1(array, escape_Qundef($2)); %*/ - } + ;} break; case 288: - -/* Line 1806 of yacc.c */ #line 2704 "parse.y" { /*%%%*/ @@ -7917,12 +7567,10 @@ yyreduce: /*% $$ = dispatch1(hash, escape_Qundef($2)); %*/ - } + ;} break; case 289: - -/* Line 1806 of yacc.c */ #line 2712 "parse.y" { /*%%%*/ @@ -7930,12 +7578,10 @@ yyreduce: /*% $$ = dispatch0(return0); %*/ - } + ;} break; case 290: - -/* Line 1806 of yacc.c */ #line 2720 "parse.y" { /*%%%*/ @@ -7943,12 +7589,10 @@ yyreduce: /*% $$ = dispatch1(yield, dispatch1(paren, $3)); %*/ - } + ;} break; case 291: - -/* Line 1806 of yacc.c */ #line 2728 "parse.y" { /*%%%*/ @@ -7956,12 +7600,10 @@ yyreduce: /*% $$ = dispatch1(yield, dispatch1(paren, arg_new())); %*/ - } + ;} break; case 292: - -/* Line 1806 of yacc.c */ #line 2736 "parse.y" { /*%%%*/ @@ -7969,19 +7611,15 @@ yyreduce: /*% $$ = dispatch0(yield0); %*/ - } + ;} break; case 293: - -/* Line 1806 of yacc.c */ #line 2743 "parse.y" - {in_defined = 1;} + {in_defined = 1;;} break; case 294: - -/* Line 1806 of yacc.c */ #line 2744 "parse.y" { /*%%%*/ @@ -7991,12 +7629,10 @@ yyreduce: in_defined = 0; $$ = dispatch1(defined, $5); %*/ - } + ;} break; case 295: - -/* Line 1806 of yacc.c */ #line 2754 "parse.y" { /*%%%*/ @@ -8004,12 +7640,10 @@ yyreduce: /*% $$ = dispatch2(unary, ripper_intern("not"), $3); %*/ - } + ;} break; case 296: - -/* Line 1806 of yacc.c */ #line 2762 "parse.y" { /*%%%*/ @@ -8017,12 +7651,10 @@ yyreduce: /*% $$ = dispatch2(unary, ripper_intern("not"), Qnil); %*/ - } + ;} break; case 297: - -/* Line 1806 of yacc.c */ #line 2770 "parse.y" { /*%%%*/ @@ -8033,12 +7665,10 @@ yyreduce: $$ = method_arg(dispatch1(fcall, $1), arg_new()); $$ = method_add_block($$, $2); %*/ - } + ;} break; case 299: - -/* Line 1806 of yacc.c */ #line 2782 "parse.y" { /*%%%*/ @@ -8049,21 +7679,17 @@ yyreduce: /*% $$ = method_add_block($1, $2); %*/ - } + ;} break; case 300: - -/* Line 1806 of yacc.c */ #line 2793 "parse.y" { (yyval.node) = (yyvsp[(2) - (2)].node); - } + ;} break; case 301: - -/* Line 1806 of yacc.c */ #line 2800 "parse.y" { /*%%%*/ @@ -8072,12 +7698,10 @@ yyreduce: /*% $$ = dispatch3(if, $2, $4, escape_Qundef($5)); %*/ - } + ;} break; case 302: - -/* Line 1806 of yacc.c */ #line 2812 "parse.y" { /*%%%*/ @@ -8086,26 +7710,20 @@ yyreduce: /*% $$ = dispatch3(unless, $2, $4, escape_Qundef($5)); %*/ - } + ;} break; case 303: - -/* Line 1806 of yacc.c */ #line 2820 "parse.y" - {COND_PUSH(1);} + {COND_PUSH(1);;} break; case 304: - -/* Line 1806 of yacc.c */ #line 2820 "parse.y" - {COND_POP();} + {COND_POP();;} break; case 305: - -/* Line 1806 of yacc.c */ #line 2823 "parse.y" { /*%%%*/ @@ -8114,26 +7732,20 @@ yyreduce: /*% $$ = dispatch2(while, $3, $6); %*/ - } + ;} break; case 306: - -/* Line 1806 of yacc.c */ #line 2831 "parse.y" - {COND_PUSH(1);} + {COND_PUSH(1);;} break; case 307: - -/* Line 1806 of yacc.c */ #line 2831 "parse.y" - {COND_POP();} + {COND_POP();;} break; case 308: - -/* Line 1806 of yacc.c */ #line 2834 "parse.y" { /*%%%*/ @@ -8142,12 +7754,10 @@ yyreduce: /*% $$ = dispatch2(until, $3, $6); %*/ - } + ;} break; case 309: - -/* Line 1806 of yacc.c */ #line 2845 "parse.y" { /*%%%*/ @@ -8156,12 +7766,10 @@ yyreduce: /*% $$ = dispatch2(case, $2, $4); %*/ - } + ;} break; case 310: - -/* Line 1806 of yacc.c */ #line 2854 "parse.y" { /*%%%*/ @@ -8169,26 +7777,20 @@ yyreduce: /*% $$ = dispatch2(case, Qnil, $3); %*/ - } + ;} break; case 311: - -/* Line 1806 of yacc.c */ #line 2862 "parse.y" - {COND_PUSH(1);} + {COND_PUSH(1);;} break; case 312: - -/* Line 1806 of yacc.c */ #line 2864 "parse.y" - {COND_POP();} + {COND_POP();;} break; case 313: - -/* Line 1806 of yacc.c */ #line 2867 "parse.y" { /*%%%*/ @@ -8249,12 +7851,10 @@ yyreduce: /*% $$ = dispatch3(for, $2, $5, $8); %*/ - } + ;} break; case 314: - -/* Line 1806 of yacc.c */ #line 2928 "parse.y" { if (in_def || in_single) @@ -8264,12 +7864,10 @@ yyreduce: (yyval.num) = ruby_sourceline; /*% %*/ - } + ;} break; case 315: - -/* Line 1806 of yacc.c */ #line 2939 "parse.y" { /*%%%*/ @@ -8279,33 +7877,27 @@ yyreduce: $$ = dispatch3(class, $2, $3, $5); %*/ local_pop(); - } + ;} break; case 316: - -/* Line 1806 of yacc.c */ #line 2949 "parse.y" { (yyval.num) = in_def; in_def = 0; - } + ;} break; case 317: - -/* Line 1806 of yacc.c */ #line 2954 "parse.y" { (yyval.num) = in_single; in_single = 0; local_push(0); - } + ;} break; case 318: - -/* Line 1806 of yacc.c */ #line 2961 "parse.y" { /*%%%*/ @@ -8317,12 +7909,10 @@ yyreduce: local_pop(); in_def = (yyvsp[(4) - (8)].num); in_single = (yyvsp[(6) - (8)].num); - } + ;} break; case 319: - -/* Line 1806 of yacc.c */ #line 2973 "parse.y" { if (in_def || in_single) @@ -8332,12 +7922,10 @@ yyreduce: (yyval.num) = ruby_sourceline; /*% %*/ - } + ;} break; case 320: - -/* Line 1806 of yacc.c */ #line 2984 "parse.y" { /*%%%*/ @@ -8347,24 +7935,20 @@ yyreduce: $$ = dispatch2(module, $2, $4); %*/ local_pop(); - } + ;} break; case 321: - -/* Line 1806 of yacc.c */ #line 2994 "parse.y" { (yyval.id) = cur_mid; cur_mid = (yyvsp[(2) - (2)].id); in_def++; local_push(0); - } + ;} break; case 322: - -/* Line 1806 of yacc.c */ #line 3003 "parse.y" { /*%%%*/ @@ -8378,30 +7962,24 @@ yyreduce: local_pop(); in_def--; cur_mid = (yyvsp[(3) - (6)].id); - } + ;} break; case 323: - -/* Line 1806 of yacc.c */ #line 3016 "parse.y" - {lex_state = EXPR_FNAME;} + {lex_state = EXPR_FNAME;;} break; case 324: - -/* Line 1806 of yacc.c */ #line 3017 "parse.y" { in_single++; lex_state = EXPR_ENDFN; /* force for args */ local_push(0); - } + ;} break; case 325: - -/* Line 1806 of yacc.c */ #line 3025 "parse.y" { /*%%%*/ @@ -8414,12 +7992,10 @@ yyreduce: %*/ local_pop(); in_single--; - } + ;} break; case 326: - -/* Line 1806 of yacc.c */ #line 3038 "parse.y" { /*%%%*/ @@ -8427,12 +8003,10 @@ yyreduce: /*% $$ = dispatch1(break, arg_new()); %*/ - } + ;} break; case 327: - -/* Line 1806 of yacc.c */ #line 3046 "parse.y" { /*%%%*/ @@ -8440,12 +8014,10 @@ yyreduce: /*% $$ = dispatch1(next, arg_new()); %*/ - } + ;} break; case 328: - -/* Line 1806 of yacc.c */ #line 3054 "parse.y" { /*%%%*/ @@ -8453,12 +8025,10 @@ yyreduce: /*% $$ = dispatch0(redo); %*/ - } + ;} break; case 329: - -/* Line 1806 of yacc.c */ #line 3062 "parse.y" { /*%%%*/ @@ -8466,12 +8036,10 @@ yyreduce: /*% $$ = dispatch0(retry); %*/ - } + ;} break; case 330: - -/* Line 1806 of yacc.c */ #line 3072 "parse.y" { /*%%%*/ @@ -8481,93 +8049,73 @@ yyreduce: /*% $$ = $1; %*/ - } + ;} break; case 331: - -/* Line 1806 of yacc.c */ #line 3084 "parse.y" { token_info_push("begin"); - } + ;} break; case 332: - -/* Line 1806 of yacc.c */ #line 3090 "parse.y" { token_info_push("if"); - } + ;} break; case 333: - -/* Line 1806 of yacc.c */ #line 3096 "parse.y" { token_info_push("unless"); - } + ;} break; case 334: - -/* Line 1806 of yacc.c */ #line 3102 "parse.y" { token_info_push("while"); - } + ;} break; case 335: - -/* Line 1806 of yacc.c */ #line 3108 "parse.y" { token_info_push("until"); - } + ;} break; case 336: - -/* Line 1806 of yacc.c */ #line 3114 "parse.y" { token_info_push("case"); - } + ;} break; case 337: - -/* Line 1806 of yacc.c */ #line 3120 "parse.y" { token_info_push("for"); - } + ;} break; case 338: - -/* Line 1806 of yacc.c */ #line 3126 "parse.y" { token_info_push("class"); - } + ;} break; case 339: - -/* Line 1806 of yacc.c */ #line 3132 "parse.y" { token_info_push("module"); - } + ;} break; case 340: - -/* Line 1806 of yacc.c */ #line 3138 "parse.y" { token_info_push("def"); @@ -8575,21 +8123,17 @@ yyreduce: (yyval.num) = ruby_sourceline; /*% %*/ - } + ;} break; case 341: - -/* Line 1806 of yacc.c */ #line 3148 "parse.y" { token_info_pop("end"); - } + ;} break; case 348: - -/* Line 1806 of yacc.c */ #line 3178 "parse.y" { /*%%%*/ @@ -8598,12 +8142,10 @@ yyreduce: /*% $$ = dispatch3(elsif, $2, $4, escape_Qundef($5)); %*/ - } + ;} break; case 350: - -/* Line 1806 of yacc.c */ #line 3190 "parse.y" { /*%%%*/ @@ -8611,12 +8153,10 @@ yyreduce: /*% $$ = dispatch1(else, $2); %*/ - } + ;} break; case 353: - -/* Line 1806 of yacc.c */ #line 3204 "parse.y" { (yyval.node) = assignable((yyvsp[(1) - (1)].id), 0); @@ -8624,12 +8164,10 @@ yyreduce: /*% $$ = dispatch1(mlhs_paren, $$); %*/ - } + ;} break; case 354: - -/* Line 1806 of yacc.c */ #line 3212 "parse.y" { /*%%%*/ @@ -8637,12 +8175,10 @@ yyreduce: /*% $$ = dispatch1(mlhs_paren, $2); %*/ - } + ;} break; case 355: - -/* Line 1806 of yacc.c */ #line 3222 "parse.y" { /*%%%*/ @@ -8650,12 +8186,10 @@ yyreduce: /*% $$ = mlhs_add(mlhs_new(), $1); %*/ - } + ;} break; case 356: - -/* Line 1806 of yacc.c */ #line 3230 "parse.y" { /*%%%*/ @@ -8663,12 +8197,10 @@ yyreduce: /*% $$ = mlhs_add($1, $3); %*/ - } + ;} break; case 357: - -/* Line 1806 of yacc.c */ #line 3240 "parse.y" { /*%%%*/ @@ -8676,12 +8208,10 @@ yyreduce: /*% $$ = $1; %*/ - } + ;} break; case 358: - -/* Line 1806 of yacc.c */ #line 3248 "parse.y" { (yyval.node) = assignable((yyvsp[(4) - (4)].id), 0); @@ -8690,12 +8220,10 @@ yyreduce: /*% $$ = mlhs_add_star($1, $$); %*/ - } + ;} break; case 359: - -/* Line 1806 of yacc.c */ #line 3257 "parse.y" { (yyval.node) = assignable((yyvsp[(4) - (6)].id), 0); @@ -8704,12 +8232,10 @@ yyreduce: /*% $$ = mlhs_add_star($1, $$); %*/ - } + ;} break; case 360: - -/* Line 1806 of yacc.c */ #line 3266 "parse.y" { /*%%%*/ @@ -8717,12 +8243,10 @@ yyreduce: /*% $$ = mlhs_add_star($1, Qnil); %*/ - } + ;} break; case 361: - -/* Line 1806 of yacc.c */ #line 3274 "parse.y" { /*%%%*/ @@ -8730,12 +8254,10 @@ yyreduce: /*% $$ = mlhs_add_star($1, $5); %*/ - } + ;} break; case 362: - -/* Line 1806 of yacc.c */ #line 3282 "parse.y" { (yyval.node) = assignable((yyvsp[(2) - (2)].id), 0); @@ -8744,12 +8266,10 @@ yyreduce: /*% $$ = mlhs_add_star(mlhs_new(), $$); %*/ - } + ;} break; case 363: - -/* Line 1806 of yacc.c */ #line 3291 "parse.y" { (yyval.node) = assignable((yyvsp[(2) - (4)].id), 0); @@ -8761,12 +8281,10 @@ yyreduce: #endif $$ = mlhs_add_star($$, $4); %*/ - } + ;} break; case 364: - -/* Line 1806 of yacc.c */ #line 3303 "parse.y" { /*%%%*/ @@ -8774,12 +8292,10 @@ yyreduce: /*% $$ = mlhs_add_star(mlhs_new(), Qnil); %*/ - } + ;} break; case 365: - -/* Line 1806 of yacc.c */ #line 3311 "parse.y" { /*%%%*/ @@ -8787,12 +8303,10 @@ yyreduce: /*% $$ = mlhs_add_star(mlhs_new(), Qnil); %*/ - } + ;} break; case 366: - -/* Line 1806 of yacc.c */ #line 3321 "parse.y" { /*%%%*/ @@ -8800,12 +8314,10 @@ yyreduce: /*% $$ = params_new($1, $3, $5, Qnil, escape_Qundef($6)); %*/ - } + ;} break; case 367: - -/* Line 1806 of yacc.c */ #line 3329 "parse.y" { /*%%%*/ @@ -8813,12 +8325,10 @@ yyreduce: /*% $$ = params_new($1, $3, $5, $7, escape_Qundef($8)); %*/ - } + ;} break; case 368: - -/* Line 1806 of yacc.c */ #line 3337 "parse.y" { /*%%%*/ @@ -8826,12 +8336,10 @@ yyreduce: /*% $$ = params_new($1, $3, Qnil, Qnil, escape_Qundef($4)); %*/ - } + ;} break; case 369: - -/* Line 1806 of yacc.c */ #line 3345 "parse.y" { /*%%%*/ @@ -8839,12 +8347,10 @@ yyreduce: /*% $$ = params_new($1, $3, Qnil, $5, escape_Qundef($6)); %*/ - } + ;} break; case 370: - -/* Line 1806 of yacc.c */ #line 3353 "parse.y" { /*%%%*/ @@ -8852,12 +8358,10 @@ yyreduce: /*% $$ = params_new($1, Qnil, $3, Qnil, escape_Qundef($4)); %*/ - } + ;} break; case 371: - -/* Line 1806 of yacc.c */ #line 3361 "parse.y" { /*%%%*/ @@ -8866,12 +8370,10 @@ yyreduce: $$ = params_new($1, Qnil, Qnil, Qnil, Qnil); dispatch1(excessed_comma, $$); %*/ - } + ;} break; case 372: - -/* Line 1806 of yacc.c */ #line 3370 "parse.y" { /*%%%*/ @@ -8879,12 +8381,10 @@ yyreduce: /*% $$ = params_new($1, Qnil, $3, $5, escape_Qundef($6)); %*/ - } + ;} break; case 373: - -/* Line 1806 of yacc.c */ #line 3378 "parse.y" { /*%%%*/ @@ -8892,12 +8392,10 @@ yyreduce: /*% $$ = params_new($1, Qnil,Qnil, Qnil, escape_Qundef($2)); %*/ - } + ;} break; case 374: - -/* Line 1806 of yacc.c */ #line 3386 "parse.y" { /*%%%*/ @@ -8905,12 +8403,10 @@ yyreduce: /*% $$ = params_new(Qnil, $1, $3, Qnil, escape_Qundef($4)); %*/ - } + ;} break; case 375: - -/* Line 1806 of yacc.c */ #line 3394 "parse.y" { /*%%%*/ @@ -8918,12 +8414,10 @@ yyreduce: /*% $$ = params_new(Qnil, $1, $3, $5, escape_Qundef($6)); %*/ - } + ;} break; case 376: - -/* Line 1806 of yacc.c */ #line 3402 "parse.y" { /*%%%*/ @@ -8931,12 +8425,10 @@ yyreduce: /*% $$ = params_new(Qnil, $1, Qnil, Qnil,escape_Qundef($2)); %*/ - } + ;} break; case 377: - -/* Line 1806 of yacc.c */ #line 3410 "parse.y" { /*%%%*/ @@ -8944,12 +8436,10 @@ yyreduce: /*% $$ = params_new(Qnil, $1, Qnil, $3, escape_Qundef($4)); %*/ - } + ;} break; case 378: - -/* Line 1806 of yacc.c */ #line 3418 "parse.y" { /*%%%*/ @@ -8957,12 +8447,10 @@ yyreduce: /*% $$ = params_new(Qnil, Qnil, $1, Qnil, escape_Qundef($2)); %*/ - } + ;} break; case 379: - -/* Line 1806 of yacc.c */ #line 3426 "parse.y" { /*%%%*/ @@ -8970,12 +8458,10 @@ yyreduce: /*% $$ = params_new(Qnil, Qnil, $1, $3, escape_Qundef($4)); %*/ - } + ;} break; case 380: - -/* Line 1806 of yacc.c */ #line 3434 "parse.y" { /*%%%*/ @@ -8983,21 +8469,17 @@ yyreduce: /*% $$ = params_new(Qnil, Qnil, Qnil, Qnil, $1); %*/ - } + ;} break; case 382: - -/* Line 1806 of yacc.c */ #line 3445 "parse.y" { command_start = TRUE; - } + ;} break; case 383: - -/* Line 1806 of yacc.c */ #line 3451 "parse.y" { /*%%%*/ @@ -9006,12 +8488,10 @@ yyreduce: $$ = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil), escape_Qundef($2)); %*/ - } + ;} break; case 384: - -/* Line 1806 of yacc.c */ #line 3460 "parse.y" { /*%%%*/ @@ -9020,12 +8500,10 @@ yyreduce: $$ = blockvar_new(params_new(Qnil,Qnil,Qnil,Qnil,Qnil), Qnil); %*/ - } + ;} break; case 385: - -/* Line 1806 of yacc.c */ #line 3469 "parse.y" { /*%%%*/ @@ -9033,12 +8511,10 @@ yyreduce: /*% $$ = blockvar_new(escape_Qundef($2), escape_Qundef($3)); %*/ - } + ;} break; case 387: - -/* Line 1806 of yacc.c */ #line 3481 "parse.y" { /*%%%*/ @@ -9046,12 +8522,10 @@ yyreduce: /*% $$ = $2; %*/ - } + ;} break; case 390: - -/* Line 1806 of yacc.c */ #line 3507 "parse.y" { new_bv(get_id((yyvsp[(1) - (1)].id))); @@ -9059,40 +8533,32 @@ yyreduce: /*% $$ = get_value($1); %*/ - } + ;} break; case 391: - -/* Line 1806 of yacc.c */ #line 3515 "parse.y" { (yyval.node) = 0; - } + ;} break; case 392: - -/* Line 1806 of yacc.c */ #line 3520 "parse.y" { (yyval.vars) = dyna_push(); - } + ;} break; case 393: - -/* Line 1806 of yacc.c */ #line 3523 "parse.y" { (yyval.num) = lpar_beg; lpar_beg = ++paren_nest; - } + ;} break; case 394: - -/* Line 1806 of yacc.c */ #line 3529 "parse.y" { lpar_beg = (yyvsp[(2) - (4)].num); @@ -9103,12 +8569,10 @@ yyreduce: $$ = dispatch2(lambda, $3, $4); %*/ dyna_pop((yyvsp[(1) - (4)].vars)); - } + ;} break; case 395: - -/* Line 1806 of yacc.c */ #line 3542 "parse.y" { /*%%%*/ @@ -9116,12 +8580,10 @@ yyreduce: /*% $$ = dispatch1(paren, $2); %*/ - } + ;} break; case 396: - -/* Line 1806 of yacc.c */ #line 3550 "parse.y" { /*%%%*/ @@ -9129,42 +8591,34 @@ yyreduce: /*% $$ = $1; %*/ - } + ;} break; case 397: - -/* Line 1806 of yacc.c */ #line 3560 "parse.y" { (yyval.node) = (yyvsp[(2) - (3)].node); - } + ;} break; case 398: - -/* Line 1806 of yacc.c */ #line 3564 "parse.y" { (yyval.node) = (yyvsp[(2) - (3)].node); - } + ;} break; case 399: - -/* Line 1806 of yacc.c */ #line 3570 "parse.y" { (yyvsp[(1) - (1)].vars) = dyna_push(); /*%%%*/ (yyval.num) = ruby_sourceline; /*% %*/ - } + ;} break; case 400: - -/* Line 1806 of yacc.c */ #line 3579 "parse.y" { /*%%%*/ @@ -9174,12 +8628,10 @@ yyreduce: $$ = dispatch2(do_block, escape_Qundef($3), $4); %*/ dyna_pop((yyvsp[(1) - (5)].vars)); - } + ;} break; case 401: - -/* Line 1806 of yacc.c */ #line 3591 "parse.y" { /*%%%*/ @@ -9195,12 +8647,10 @@ yyreduce: /*% $$ = method_add_block($1, $2); %*/ - } + ;} break; case 402: - -/* Line 1806 of yacc.c */ #line 3607 "parse.y" { /*%%%*/ @@ -9209,12 +8659,10 @@ yyreduce: $$ = dispatch3(call, $1, ripper_id2sym('.'), $3); $$ = method_optarg($$, $4); %*/ - } + ;} break; case 403: - -/* Line 1806 of yacc.c */ #line 3616 "parse.y" { /*%%%*/ @@ -9223,12 +8671,10 @@ yyreduce: $$ = dispatch3(call, $1, ripper_intern("::"), $3); $$ = method_optarg($$, $4); %*/ - } + ;} break; case 404: - -/* Line 1806 of yacc.c */ #line 3627 "parse.y" { /*%%%*/ @@ -9237,12 +8683,10 @@ yyreduce: /*% $$ = method_arg(dispatch1(fcall, $1), $2); %*/ - } + ;} break; case 405: - -/* Line 1806 of yacc.c */ #line 3636 "parse.y" { /*%%%*/ @@ -9252,12 +8696,10 @@ yyreduce: $$ = dispatch3(call, $1, ripper_id2sym('.'), $3); $$ = method_optarg($$, $4); %*/ - } + ;} break; case 406: - -/* Line 1806 of yacc.c */ #line 3646 "parse.y" { /*%%%*/ @@ -9267,12 +8709,10 @@ yyreduce: $$ = dispatch3(call, $1, ripper_id2sym('.'), $3); $$ = method_optarg($$, $4); %*/ - } + ;} break; case 407: - -/* Line 1806 of yacc.c */ #line 3656 "parse.y" { /*%%%*/ @@ -9280,12 +8720,10 @@ yyreduce: /*% $$ = dispatch3(call, $1, ripper_intern("::"), $3); %*/ - } + ;} break; case 408: - -/* Line 1806 of yacc.c */ #line 3664 "parse.y" { /*%%%*/ @@ -9296,12 +8734,10 @@ yyreduce: ripper_intern("call")); $$ = method_optarg($$, $3); %*/ - } + ;} break; case 409: - -/* Line 1806 of yacc.c */ #line 3675 "parse.y" { /*%%%*/ @@ -9312,12 +8748,10 @@ yyreduce: ripper_intern("call")); $$ = method_optarg($$, $3); %*/ - } + ;} break; case 410: - -/* Line 1806 of yacc.c */ #line 3686 "parse.y" { /*%%%*/ @@ -9325,12 +8759,10 @@ yyreduce: /*% $$ = dispatch1(super, $2); %*/ - } + ;} break; case 411: - -/* Line 1806 of yacc.c */ #line 3694 "parse.y" { /*%%%*/ @@ -9338,12 +8770,10 @@ yyreduce: /*% $$ = dispatch0(zsuper); %*/ - } + ;} break; case 412: - -/* Line 1806 of yacc.c */ #line 3702 "parse.y" { /*%%%*/ @@ -9355,12 +8785,10 @@ yyreduce: /*% $$ = dispatch2(aref, $1, escape_Qundef($3)); %*/ - } + ;} break; case 413: - -/* Line 1806 of yacc.c */ #line 3716 "parse.y" { (yyvsp[(1) - (1)].vars) = dyna_push(); @@ -9368,12 +8796,10 @@ yyreduce: (yyval.num) = ruby_sourceline; /*% %*/ - } + ;} break; case 414: - -/* Line 1806 of yacc.c */ #line 3725 "parse.y" { /*%%%*/ @@ -9383,12 +8809,10 @@ yyreduce: $$ = dispatch2(brace_block, escape_Qundef($3), $4); %*/ dyna_pop((yyvsp[(1) - (5)].vars)); - } + ;} break; case 415: - -/* Line 1806 of yacc.c */ #line 3735 "parse.y" { (yyvsp[(1) - (1)].vars) = dyna_push(); @@ -9396,12 +8820,10 @@ yyreduce: (yyval.num) = ruby_sourceline; /*% %*/ - } + ;} break; case 416: - -/* Line 1806 of yacc.c */ #line 3744 "parse.y" { /*%%%*/ @@ -9411,12 +8833,10 @@ yyreduce: $$ = dispatch2(do_block, escape_Qundef($3), $4); %*/ dyna_pop((yyvsp[(1) - (5)].vars)); - } + ;} break; case 417: - -/* Line 1806 of yacc.c */ #line 3758 "parse.y" { /*%%%*/ @@ -9424,12 +8844,10 @@ yyreduce: /*% $$ = dispatch3(when, $2, $4, escape_Qundef($5)); %*/ - } + ;} break; case 420: - -/* Line 1806 of yacc.c */ #line 3774 "parse.y" { /*%%%*/ @@ -9446,12 +8864,10 @@ yyreduce: escape_Qundef($5), escape_Qundef($6)); %*/ - } + ;} break; case 422: - -/* Line 1806 of yacc.c */ #line 3794 "parse.y" { /*%%%*/ @@ -9459,12 +8875,10 @@ yyreduce: /*% $$ = rb_ary_new3(1, $1); %*/ - } + ;} break; case 423: - -/* Line 1806 of yacc.c */ #line 3802 "parse.y" { /*%%%*/ @@ -9472,21 +8886,17 @@ yyreduce: /*% $$ = $1; %*/ - } + ;} break; case 425: - -/* Line 1806 of yacc.c */ #line 3813 "parse.y" { (yyval.node) = (yyvsp[(2) - (2)].node); - } + ;} break; case 427: - -/* Line 1806 of yacc.c */ #line 3820 "parse.y" { /*%%%*/ @@ -9494,12 +8904,10 @@ yyreduce: /*% $$ = dispatch1(ensure, $2); %*/ - } + ;} break; case 430: - -/* Line 1806 of yacc.c */ #line 3832 "parse.y" { /*%%%*/ @@ -9507,12 +8915,10 @@ yyreduce: /*% $$ = dispatch1(symbol_literal, $1); %*/ - } + ;} break; case 432: - -/* Line 1806 of yacc.c */ #line 3843 "parse.y" { /*%%%*/ @@ -9527,12 +8933,10 @@ yyreduce: /*% $$ = $1; %*/ - } + ;} break; case 435: - -/* Line 1806 of yacc.c */ #line 3862 "parse.y" { /*%%%*/ @@ -9540,12 +8944,10 @@ yyreduce: /*% $$ = dispatch2(string_concat, $1, $2); %*/ - } + ;} break; case 436: - -/* Line 1806 of yacc.c */ #line 3872 "parse.y" { /*%%%*/ @@ -9553,12 +8955,10 @@ yyreduce: /*% $$ = dispatch1(string_literal, $2); %*/ - } + ;} break; case 437: - -/* Line 1806 of yacc.c */ #line 3882 "parse.y" { /*%%%*/ @@ -9583,12 +8983,10 @@ yyreduce: /*% $$ = dispatch1(xstring_literal, $2); %*/ - } + ;} break; case 438: - -/* Line 1806 of yacc.c */ #line 3909 "parse.y" { /*%%%*/ @@ -9651,12 +9049,10 @@ yyreduce: /*% $$ = dispatch2(regexp_literal, $2, $3); %*/ - } + ;} break; case 439: - -/* Line 1806 of yacc.c */ #line 3974 "parse.y" { /*%%%*/ @@ -9665,12 +9061,10 @@ yyreduce: $$ = dispatch0(words_new); $$ = dispatch1(array, $$); %*/ - } + ;} break; case 440: - -/* Line 1806 of yacc.c */ #line 3983 "parse.y" { /*%%%*/ @@ -9678,12 +9072,10 @@ yyreduce: /*% $$ = dispatch1(array, $2); %*/ - } + ;} break; case 441: - -/* Line 1806 of yacc.c */ #line 3993 "parse.y" { /*%%%*/ @@ -9691,12 +9083,10 @@ yyreduce: /*% $$ = dispatch0(words_new); %*/ - } + ;} break; case 442: - -/* Line 1806 of yacc.c */ #line 4001 "parse.y" { /*%%%*/ @@ -9704,12 +9094,10 @@ yyreduce: /*% $$ = dispatch2(words_add, $1, $2); %*/ - } + ;} break; case 444: - -/* Line 1806 of yacc.c */ #line 4019 "parse.y" { /*%%%*/ @@ -9717,12 +9105,10 @@ yyreduce: /*% $$ = dispatch2(word_add, $1, $2); %*/ - } + ;} break; case 445: - -/* Line 1806 of yacc.c */ #line 4029 "parse.y" { /*%%%*/ @@ -9731,12 +9117,10 @@ yyreduce: $$ = dispatch0(qwords_new); $$ = dispatch1(array, $$); %*/ - } + ;} break; case 446: - -/* Line 1806 of yacc.c */ #line 4038 "parse.y" { /*%%%*/ @@ -9744,12 +9128,10 @@ yyreduce: /*% $$ = dispatch1(array, $2); %*/ - } + ;} break; case 447: - -/* Line 1806 of yacc.c */ #line 4048 "parse.y" { /*%%%*/ @@ -9757,12 +9139,10 @@ yyreduce: /*% $$ = dispatch0(qwords_new); %*/ - } + ;} break; case 448: - -/* Line 1806 of yacc.c */ #line 4056 "parse.y" { /*%%%*/ @@ -9770,12 +9150,10 @@ yyreduce: /*% $$ = dispatch2(qwords_add, $1, $2); %*/ - } + ;} break; case 449: - -/* Line 1806 of yacc.c */ #line 4066 "parse.y" { /*%%%*/ @@ -9783,12 +9161,10 @@ yyreduce: /*% $$ = dispatch0(string_content); %*/ - } + ;} break; case 450: - -/* Line 1806 of yacc.c */ #line 4074 "parse.y" { /*%%%*/ @@ -9796,12 +9172,10 @@ yyreduce: /*% $$ = dispatch2(string_add, $1, $2); %*/ - } + ;} break; case 451: - -/* Line 1806 of yacc.c */ #line 4084 "parse.y" { /*%%%*/ @@ -9809,12 +9183,10 @@ yyreduce: /*% $$ = dispatch0(xstring_new); %*/ - } + ;} break; case 452: - -/* Line 1806 of yacc.c */ #line 4092 "parse.y" { /*%%%*/ @@ -9822,12 +9194,10 @@ yyreduce: /*% $$ = dispatch2(xstring_add, $1, $2); %*/ - } + ;} break; case 453: - -/* Line 1806 of yacc.c */ #line 4102 "parse.y" { /*%%%*/ @@ -9835,12 +9205,10 @@ yyreduce: /*% $$ = dispatch0(regexp_new); %*/ - } + ;} break; case 454: - -/* Line 1806 of yacc.c */ #line 4110 "parse.y" { /*%%%*/ @@ -9867,23 +9235,19 @@ yyreduce: /*% $$ = dispatch2(regexp_add, $1, $2); %*/ - } + ;} break; case 456: - -/* Line 1806 of yacc.c */ #line 4140 "parse.y" { (yyval.node) = lex_strterm; lex_strterm = 0; lex_state = EXPR_BEG; - } + ;} break; case 457: - -/* Line 1806 of yacc.c */ #line 4146 "parse.y" { /*%%%*/ @@ -9893,35 +9257,29 @@ yyreduce: lex_strterm = $<node>2; $$ = dispatch1(string_dvar, $3); %*/ - } + ;} break; case 458: - -/* Line 1806 of yacc.c */ #line 4156 "parse.y" { (yyvsp[(1) - (1)].val) = cond_stack; (yyval.val) = cmdarg_stack; cond_stack = 0; cmdarg_stack = 0; - } + ;} break; case 459: - -/* Line 1806 of yacc.c */ #line 4162 "parse.y" { (yyval.node) = lex_strterm; lex_strterm = 0; lex_state = EXPR_BEG; - } + ;} break; case 460: - -/* Line 1806 of yacc.c */ #line 4168 "parse.y" { cond_stack = (yyvsp[(1) - (5)].val); @@ -9933,12 +9291,10 @@ yyreduce: /*% $$ = dispatch1(string_embexpr, $4); %*/ - } + ;} break; case 461: - -/* Line 1806 of yacc.c */ #line 4182 "parse.y" { /*%%%*/ @@ -9946,12 +9302,10 @@ yyreduce: /*% $$ = dispatch1(var_ref, $1); %*/ - } + ;} break; case 462: - -/* Line 1806 of yacc.c */ #line 4190 "parse.y" { /*%%%*/ @@ -9959,12 +9313,10 @@ yyreduce: /*% $$ = dispatch1(var_ref, $1); %*/ - } + ;} break; case 463: - -/* Line 1806 of yacc.c */ #line 4198 "parse.y" { /*%%%*/ @@ -9972,12 +9324,10 @@ yyreduce: /*% $$ = dispatch1(var_ref, $1); %*/ - } + ;} break; case 465: - -/* Line 1806 of yacc.c */ #line 4209 "parse.y" { lex_state = EXPR_END; @@ -9986,12 +9336,10 @@ yyreduce: /*% $$ = dispatch1(symbol, $2); %*/ - } + ;} break; case 470: - -/* Line 1806 of yacc.c */ #line 4226 "parse.y" { lex_state = EXPR_END; @@ -10019,12 +9367,10 @@ yyreduce: /*% $$ = dispatch1(dyna_symbol, $2); %*/ - } + ;} break; case 473: - -/* Line 1806 of yacc.c */ #line 4258 "parse.y" { /*%%%*/ @@ -10032,12 +9378,10 @@ yyreduce: /*% $$ = dispatch2(unary, ripper_intern("-@"), $2); %*/ - } + ;} break; case 474: - -/* Line 1806 of yacc.c */ #line 4266 "parse.y" { /*%%%*/ @@ -10045,61 +9389,45 @@ yyreduce: /*% $$ = dispatch2(unary, ripper_intern("-@"), $2); %*/ - } + ;} break; case 480: - -/* Line 1806 of yacc.c */ #line 4282 "parse.y" - {ifndef_ripper((yyval.id) = keyword_nil);} + {ifndef_ripper((yyval.id) = keyword_nil);;} break; case 481: - -/* Line 1806 of yacc.c */ #line 4283 "parse.y" - {ifndef_ripper((yyval.id) = keyword_self);} + {ifndef_ripper((yyval.id) = keyword_self);;} break; case 482: - -/* Line 1806 of yacc.c */ #line 4284 "parse.y" - {ifndef_ripper((yyval.id) = keyword_true);} + {ifndef_ripper((yyval.id) = keyword_true);;} break; case 483: - -/* Line 1806 of yacc.c */ #line 4285 "parse.y" - {ifndef_ripper((yyval.id) = keyword_false);} + {ifndef_ripper((yyval.id) = keyword_false);;} break; case 484: - -/* Line 1806 of yacc.c */ #line 4286 "parse.y" - {ifndef_ripper((yyval.id) = keyword__FILE__);} + {ifndef_ripper((yyval.id) = keyword__FILE__);;} break; case 485: - -/* Line 1806 of yacc.c */ #line 4287 "parse.y" - {ifndef_ripper((yyval.id) = keyword__LINE__);} + {ifndef_ripper((yyval.id) = keyword__LINE__);;} break; case 486: - -/* Line 1806 of yacc.c */ #line 4288 "parse.y" - {ifndef_ripper((yyval.id) = keyword__ENCODING__);} + {ifndef_ripper((yyval.id) = keyword__ENCODING__);;} break; case 487: - -/* Line 1806 of yacc.c */ #line 4292 "parse.y" { /*%%%*/ @@ -10112,12 +9440,10 @@ yyreduce: $$ = dispatch1(vcall, $1); } %*/ - } + ;} break; case 488: - -/* Line 1806 of yacc.c */ #line 4305 "parse.y" { /*%%%*/ @@ -10125,12 +9451,10 @@ yyreduce: /*% $$ = dispatch1(var_ref, $1); %*/ - } + ;} break; case 489: - -/* Line 1806 of yacc.c */ #line 4315 "parse.y" { (yyval.node) = assignable((yyvsp[(1) - (1)].id), 0); @@ -10138,12 +9462,10 @@ yyreduce: /*% $$ = dispatch1(var_field, $$); %*/ - } + ;} break; case 490: - -/* Line 1806 of yacc.c */ #line 4323 "parse.y" { (yyval.node) = assignable((yyvsp[(1) - (1)].id), 0); @@ -10151,12 +9473,10 @@ yyreduce: /*% $$ = dispatch1(var_field, $$); %*/ - } + ;} break; case 493: - -/* Line 1806 of yacc.c */ #line 4337 "parse.y" { /*%%%*/ @@ -10164,30 +9484,24 @@ yyreduce: /*% $$ = Qnil; %*/ - } + ;} break; case 494: - -/* Line 1806 of yacc.c */ #line 4345 "parse.y" { lex_state = EXPR_BEG; - } + ;} break; case 495: - -/* Line 1806 of yacc.c */ #line 4349 "parse.y" { (yyval.node) = (yyvsp[(3) - (4)].node); - } + ;} break; case 496: - -/* Line 1806 of yacc.c */ #line 4353 "parse.y" { /*%%%*/ @@ -10197,12 +9511,10 @@ yyreduce: yyerrok; $$ = Qnil; %*/ - } + ;} break; case 497: - -/* Line 1806 of yacc.c */ #line 4365 "parse.y" { /*%%%*/ @@ -10212,217 +9524,185 @@ yyreduce: %*/ lex_state = EXPR_BEG; command_start = TRUE; - } + ;} break; case 498: - -/* Line 1806 of yacc.c */ #line 4375 "parse.y" { (yyval.node) = (yyvsp[(1) - (2)].node); - } + lex_state = EXPR_BEG; + command_start = TRUE; + ;} break; case 499: - -/* Line 1806 of yacc.c */ -#line 4381 "parse.y" +#line 4383 "parse.y" { /*%%%*/ (yyval.node) = new_args((yyvsp[(1) - (6)].node), (yyvsp[(3) - (6)].node), (yyvsp[(5) - (6)].id), 0, (yyvsp[(6) - (6)].id)); /*% $$ = params_new($1, $3, $5, Qnil, escape_Qundef($6)); %*/ - } + ;} break; case 500: - -/* Line 1806 of yacc.c */ -#line 4389 "parse.y" +#line 4391 "parse.y" { /*%%%*/ (yyval.node) = new_args((yyvsp[(1) - (8)].node), (yyvsp[(3) - (8)].node), (yyvsp[(5) - (8)].id), (yyvsp[(7) - (8)].node), (yyvsp[(8) - (8)].id)); /*% $$ = params_new($1, $3, $5, $7, escape_Qundef($8)); %*/ - } + ;} break; case 501: - -/* Line 1806 of yacc.c */ -#line 4397 "parse.y" +#line 4399 "parse.y" { /*%%%*/ (yyval.node) = new_args((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].node), 0, 0, (yyvsp[(4) - (4)].id)); /*% $$ = params_new($1, $3, Qnil, Qnil, escape_Qundef($4)); %*/ - } + ;} break; case 502: - -/* Line 1806 of yacc.c */ -#line 4405 "parse.y" +#line 4407 "parse.y" { /*%%%*/ (yyval.node) = new_args((yyvsp[(1) - (6)].node), (yyvsp[(3) - (6)].node), 0, (yyvsp[(5) - (6)].node), (yyvsp[(6) - (6)].id)); /*% $$ = params_new($1, $3, Qnil, $5, escape_Qundef($6)); %*/ - } + ;} break; case 503: - -/* Line 1806 of yacc.c */ -#line 4413 "parse.y" +#line 4415 "parse.y" { /*%%%*/ (yyval.node) = new_args((yyvsp[(1) - (4)].node), 0, (yyvsp[(3) - (4)].id), 0, (yyvsp[(4) - (4)].id)); /*% $$ = params_new($1, Qnil, $3, Qnil, escape_Qundef($4)); %*/ - } + ;} break; case 504: - -/* Line 1806 of yacc.c */ -#line 4421 "parse.y" +#line 4423 "parse.y" { /*%%%*/ (yyval.node) = new_args((yyvsp[(1) - (6)].node), 0, (yyvsp[(3) - (6)].id), (yyvsp[(5) - (6)].node), (yyvsp[(6) - (6)].id)); /*% $$ = params_new($1, Qnil, $3, $5, escape_Qundef($6)); %*/ - } + ;} break; case 505: - -/* Line 1806 of yacc.c */ -#line 4429 "parse.y" +#line 4431 "parse.y" { /*%%%*/ (yyval.node) = new_args((yyvsp[(1) - (2)].node), 0, 0, 0, (yyvsp[(2) - (2)].id)); /*% $$ = params_new($1, Qnil, Qnil, Qnil,escape_Qundef($2)); %*/ - } + ;} break; case 506: - -/* Line 1806 of yacc.c */ -#line 4437 "parse.y" +#line 4439 "parse.y" { /*%%%*/ (yyval.node) = new_args(0, (yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].id), 0, (yyvsp[(4) - (4)].id)); /*% $$ = params_new(Qnil, $1, $3, Qnil, escape_Qundef($4)); %*/ - } + ;} break; case 507: - -/* Line 1806 of yacc.c */ -#line 4445 "parse.y" +#line 4447 "parse.y" { /*%%%*/ (yyval.node) = new_args(0, (yyvsp[(1) - (6)].node), (yyvsp[(3) - (6)].id), (yyvsp[(5) - (6)].node), (yyvsp[(6) - (6)].id)); /*% $$ = params_new(Qnil, $1, $3, $5, escape_Qundef($6)); %*/ - } + ;} break; case 508: - -/* Line 1806 of yacc.c */ -#line 4453 "parse.y" +#line 4455 "parse.y" { /*%%%*/ (yyval.node) = new_args(0, (yyvsp[(1) - (2)].node), 0, 0, (yyvsp[(2) - (2)].id)); /*% $$ = params_new(Qnil, $1, Qnil, Qnil,escape_Qundef($2)); %*/ - } + ;} break; case 509: - -/* Line 1806 of yacc.c */ -#line 4461 "parse.y" +#line 4463 "parse.y" { /*%%%*/ (yyval.node) = new_args(0, (yyvsp[(1) - (4)].node), 0, (yyvsp[(3) - (4)].node), (yyvsp[(4) - (4)].id)); /*% $$ = params_new(Qnil, $1, Qnil, $3, escape_Qundef($4)); %*/ - } + ;} break; case 510: - -/* Line 1806 of yacc.c */ -#line 4469 "parse.y" +#line 4471 "parse.y" { /*%%%*/ (yyval.node) = new_args(0, 0, (yyvsp[(1) - (2)].id), 0, (yyvsp[(2) - (2)].id)); /*% $$ = params_new(Qnil, Qnil, $1, Qnil,escape_Qundef($2)); %*/ - } + ;} break; case 511: - -/* Line 1806 of yacc.c */ -#line 4477 "parse.y" +#line 4479 "parse.y" { /*%%%*/ (yyval.node) = new_args(0, 0, (yyvsp[(1) - (4)].id), (yyvsp[(3) - (4)].node), (yyvsp[(4) - (4)].id)); /*% $$ = params_new(Qnil, Qnil, $1, $3, escape_Qundef($4)); %*/ - } + ;} break; case 512: - -/* Line 1806 of yacc.c */ -#line 4485 "parse.y" +#line 4487 "parse.y" { /*%%%*/ (yyval.node) = new_args(0, 0, 0, 0, (yyvsp[(1) - (1)].id)); /*% $$ = params_new(Qnil, Qnil, Qnil, Qnil, $1); %*/ - } + ;} break; case 513: - -/* Line 1806 of yacc.c */ -#line 4493 "parse.y" +#line 4495 "parse.y" { /*%%%*/ (yyval.node) = new_args(0, 0, 0, 0, 0); /*% $$ = params_new(Qnil, Qnil, Qnil, Qnil, Qnil); %*/ - } + ;} break; case 514: - -/* Line 1806 of yacc.c */ -#line 4503 "parse.y" +#line 4505 "parse.y" { /*%%%*/ yyerror("formal argument cannot be a constant"); @@ -10430,13 +9710,11 @@ yyreduce: /*% $$ = dispatch1(param_error, $1); %*/ - } + ;} break; case 515: - -/* Line 1806 of yacc.c */ -#line 4512 "parse.y" +#line 4514 "parse.y" { /*%%%*/ yyerror("formal argument cannot be an instance variable"); @@ -10444,13 +9722,11 @@ yyreduce: /*% $$ = dispatch1(param_error, $1); %*/ - } + ;} break; case 516: - -/* Line 1806 of yacc.c */ -#line 4521 "parse.y" +#line 4523 "parse.y" { /*%%%*/ yyerror("formal argument cannot be a global variable"); @@ -10458,13 +9734,11 @@ yyreduce: /*% $$ = dispatch1(param_error, $1); %*/ - } + ;} break; case 517: - -/* Line 1806 of yacc.c */ -#line 4530 "parse.y" +#line 4532 "parse.y" { /*%%%*/ yyerror("formal argument cannot be a class variable"); @@ -10472,23 +9746,19 @@ yyreduce: /*% $$ = dispatch1(param_error, $1); %*/ - } + ;} break; case 519: - -/* Line 1806 of yacc.c */ -#line 4542 "parse.y" +#line 4544 "parse.y" { formal_argument(get_id((yyvsp[(1) - (1)].id))); (yyval.id) = (yyvsp[(1) - (1)].id); - } + ;} break; case 520: - -/* Line 1806 of yacc.c */ -#line 4549 "parse.y" +#line 4551 "parse.y" { arg_var(get_id((yyvsp[(1) - (1)].id))); /*%%%*/ @@ -10496,13 +9766,11 @@ yyreduce: /*% $$ = get_value($1); %*/ - } + ;} break; case 521: - -/* Line 1806 of yacc.c */ -#line 4558 "parse.y" +#line 4560 "parse.y" { ID tid = internal_id(); arg_var(tid); @@ -10518,13 +9786,11 @@ yyreduce: /*% $$ = dispatch1(mlhs_paren, $2); %*/ - } + ;} break; case 523: - -/* Line 1806 of yacc.c */ -#line 4584 "parse.y" +#line 4586 "parse.y" { /*%%%*/ (yyval.node) = (yyvsp[(1) - (3)].node); @@ -10534,13 +9800,11 @@ yyreduce: /*% $$ = rb_ary_push($1, $3); %*/ - } + ;} break; case 524: - -/* Line 1806 of yacc.c */ -#line 4597 "parse.y" +#line 4599 "parse.y" { arg_var(formal_argument(get_id((yyvsp[(1) - (3)].id)))); (yyval.node) = assignable((yyvsp[(1) - (3)].id), (yyvsp[(3) - (3)].node)); @@ -10549,13 +9813,11 @@ yyreduce: /*% $$ = rb_assoc_new($$, $3); %*/ - } + ;} break; case 525: - -/* Line 1806 of yacc.c */ -#line 4609 "parse.y" +#line 4611 "parse.y" { arg_var(formal_argument(get_id((yyvsp[(1) - (3)].id)))); (yyval.node) = assignable((yyvsp[(1) - (3)].id), (yyvsp[(3) - (3)].node)); @@ -10564,26 +9826,22 @@ yyreduce: /*% $$ = rb_assoc_new($$, $3); %*/ - } + ;} break; case 526: - -/* Line 1806 of yacc.c */ -#line 4621 "parse.y" +#line 4623 "parse.y" { /*%%%*/ (yyval.node) = (yyvsp[(1) - (1)].node); /*% $$ = rb_ary_new3(1, $1); %*/ - } + ;} break; case 527: - -/* Line 1806 of yacc.c */ -#line 4629 "parse.y" +#line 4631 "parse.y" { /*%%%*/ NODE *opts = (yyvsp[(1) - (3)].node); @@ -10596,26 +9854,22 @@ yyreduce: /*% $$ = rb_ary_push($1, $3); %*/ - } + ;} break; case 528: - -/* Line 1806 of yacc.c */ -#line 4645 "parse.y" +#line 4647 "parse.y" { /*%%%*/ (yyval.node) = (yyvsp[(1) - (1)].node); /*% $$ = rb_ary_new3(1, $1); %*/ - } + ;} break; case 529: - -/* Line 1806 of yacc.c */ -#line 4653 "parse.y" +#line 4655 "parse.y" { /*%%%*/ NODE *opts = (yyvsp[(1) - (3)].node); @@ -10628,13 +9882,11 @@ yyreduce: /*% $$ = rb_ary_push($1, $3); %*/ - } + ;} break; case 532: - -/* Line 1806 of yacc.c */ -#line 4673 "parse.y" +#line 4675 "parse.y" { /*%%%*/ if (!is_local_id((yyvsp[(2) - (2)].id))) @@ -10646,13 +9898,11 @@ yyreduce: /*% $$ = dispatch1(rest_param, $2); %*/ - } + ;} break; case 533: - -/* Line 1806 of yacc.c */ -#line 4686 "parse.y" +#line 4688 "parse.y" { /*%%%*/ (yyval.id) = internal_id(); @@ -10660,13 +9910,11 @@ yyreduce: /*% $$ = dispatch1(rest_param, Qnil); %*/ - } + ;} break; case 536: - -/* Line 1806 of yacc.c */ -#line 4701 "parse.y" +#line 4703 "parse.y" { /*%%%*/ if (!is_local_id((yyvsp[(2) - (2)].id))) @@ -10680,35 +9928,29 @@ yyreduce: /*% $$ = dispatch1(blockarg, $2); %*/ - } + ;} break; case 537: - -/* Line 1806 of yacc.c */ -#line 4718 "parse.y" +#line 4720 "parse.y" { (yyval.id) = (yyvsp[(2) - (2)].id); - } + ;} break; case 538: - -/* Line 1806 of yacc.c */ -#line 4722 "parse.y" +#line 4724 "parse.y" { /*%%%*/ (yyval.id) = 0; /*% $$ = Qundef; %*/ - } + ;} break; case 539: - -/* Line 1806 of yacc.c */ -#line 4732 "parse.y" +#line 4734 "parse.y" { /*%%%*/ value_expr((yyvsp[(1) - (1)].node)); @@ -10717,20 +9959,16 @@ yyreduce: /*% $$ = $1; %*/ - } + ;} break; case 540: - -/* Line 1806 of yacc.c */ -#line 4741 "parse.y" - {lex_state = EXPR_BEG;} +#line 4743 "parse.y" + {lex_state = EXPR_BEG;;} break; case 541: - -/* Line 1806 of yacc.c */ -#line 4742 "parse.y" +#line 4744 "parse.y" { /*%%%*/ if ((yyvsp[(3) - (4)].node) == 0) { @@ -10756,105 +9994,79 @@ yyreduce: /*% $$ = dispatch1(paren, $3); %*/ - } + ;} break; case 543: - -/* Line 1806 of yacc.c */ -#line 4772 "parse.y" +#line 4774 "parse.y" { /*%%%*/ (yyval.node) = (yyvsp[(1) - (2)].node); /*% $$ = dispatch1(assoclist_from_args, $1); %*/ - } + ;} break; case 545: - -/* Line 1806 of yacc.c */ -#line 4789 "parse.y" +#line 4791 "parse.y" { /*%%%*/ (yyval.node) = list_concat((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); /*% $$ = rb_ary_push($1, $3); %*/ - } + ;} break; case 546: - -/* Line 1806 of yacc.c */ -#line 4799 "parse.y" +#line 4801 "parse.y" { /*%%%*/ (yyval.node) = list_append(NEW_LIST((yyvsp[(1) - (3)].node)), (yyvsp[(3) - (3)].node)); /*% $$ = dispatch2(assoc_new, $1, $3); %*/ - } + ;} break; case 547: - -/* Line 1806 of yacc.c */ -#line 4807 "parse.y" +#line 4809 "parse.y" { /*%%%*/ (yyval.node) = list_append(NEW_LIST(NEW_LIT(ID2SYM((yyvsp[(1) - (2)].id)))), (yyvsp[(2) - (2)].node)); /*% $$ = dispatch2(assoc_new, $1, $2); %*/ - } + ;} break; case 569: - -/* Line 1806 of yacc.c */ -#line 4863 "parse.y" - {yyerrok;} +#line 4865 "parse.y" + {yyerrok;;} break; case 572: - -/* Line 1806 of yacc.c */ -#line 4868 "parse.y" - {yyerrok;} +#line 4870 "parse.y" + {yyerrok;;} break; case 573: - -/* Line 1806 of yacc.c */ -#line 4872 "parse.y" +#line 4874 "parse.y" { /*%%%*/ (yyval.node) = 0; /*% $$ = Qundef; %*/ - } + ;} break; - -/* Line 1806 of yacc.c */ -#line 10843 "parse.c" +/* Line 1267 of yacc.c. */ +#line 10066 "parse.c" default: break; } - /* User semantic actions sometimes alter yychar, and that requires - that yytoken be updated with the new translation. We take the - approach of translating immediately before every use of yytoken. - One alternative is translating here after every semantic action, - but that translation would be missed if the semantic action invokes - YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or - if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an - incorrect destructor might then be invoked immediately. In the - case of YYERROR or YYBACKUP, subsequent parser actions might lead - to an incorrect destructor call or verbose syntax error message - before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -10863,6 +10075,7 @@ yyreduce: *++yyvsp = yyval; + /* Now `shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -10882,10 +10095,6 @@ yyreduce: | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); - /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -10893,36 +10102,37 @@ yyerrlab: #if ! YYERROR_VERBOSE parser_yyerror (parser, YY_("syntax error")); #else -# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ - yyssp, yytoken) { - char const *yymsgp = YY_("syntax error"); - int yysyntax_error_status; - yysyntax_error_status = YYSYNTAX_ERROR; - if (yysyntax_error_status == 0) - yymsgp = yymsg; - else if (yysyntax_error_status == 1) - { - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); - if (!yymsg) - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - yysyntax_error_status = 2; - } - else - { - yysyntax_error_status = YYSYNTAX_ERROR; - yymsgp = yymsg; - } - } - parser_yyerror (parser, yymsgp); - if (yysyntax_error_status == 2) - goto yyexhaustedlab; + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + } + } + + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + parser_yyerror (parser, yymsg); + } + else + { + parser_yyerror (parser, YY_("syntax error")); + if (yysize != 0) + goto yyexhaustedlab; + } } -# undef YYSYNTAX_ERROR #endif } @@ -10930,7 +10140,7 @@ yyerrlab: if (yyerrstatus == 3) { - /* If just tried and failed to reuse lookahead token after an + /* If just tried and failed to reuse look-ahead token after an error, discard it. */ if (yychar <= YYEOF) @@ -10947,7 +10157,7 @@ yyerrlab: } } - /* Else will try to reuse lookahead token after shifting the error + /* Else will try to reuse look-ahead token after shifting the error token. */ goto yyerrlab1; @@ -10981,7 +10191,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (!yypact_value_is_default (yyn)) + if (yyn != YYPACT_NINF) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) @@ -11004,6 +10214,9 @@ yyerrlab1: YY_STACK_PRINT (yyss, yyssp); } + if (yyn == YYFINAL) + YYACCEPT; + *++yyvsp = yylval; @@ -11028,7 +10241,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined(yyoverflow) || YYERROR_VERBOSE +#ifndef yyoverflow /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -11039,14 +10252,9 @@ yyexhaustedlab: #endif yyreturn: - if (yychar != YYEMPTY) - { - /* Make sure we have latest lookahead translation. See comments at - user semantic actions for why this is necessary. */ - yytoken = YYTRANSLATE (yychar); - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval, parser); - } + if (yychar != YYEOF && yychar != YYEMPTY) + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval, parser); /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); @@ -11070,9 +10278,7 @@ yyreturn: } - -/* Line 2067 of yacc.c */ -#line 4880 "parse.y" +#line 4882 "parse.y" # undef parser # undef yylex @@ -12122,7 +11328,7 @@ parser_tokadd_string(struct parser_params *parser, default: if (c == -1) return -1; if (!ISASCII(c)) { - tokadd('\\'); + if ((func & STR_FUNC_EXPAND) == 0) tokadd('\\'); goto non_ascii; } if (func & STR_FUNC_REGEXP) { @@ -12179,6 +11385,25 @@ parser_tokadd_string(struct parser_params *parser, #define NEW_STRTERM(func, term, paren) \ rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0) +#ifdef RIPPER +static void +ripper_flush_string_content(struct parser_params *parser, rb_encoding *enc) +{ + if (!NIL_P(parser->delayed)) { + ptrdiff_t len = lex_p - parser->tokp; + if (len > 0) { + rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc); + } + ripper_dispatch_delayed_token(parser, tSTRING_CONTENT); + parser->tokp = lex_p; + } +} + +#define flush_string_content(enc) ripper_flush_string_content(parser, (enc)) +#else +#define flush_string_content(enc) ((void)(enc)) +#endif + static int parser_parse_string(struct parser_params *parser, NODE *quote) { @@ -12237,17 +11462,7 @@ parser_parse_string(struct parser_params *parser, NODE *quote) tokfix(); set_yylval_str(STR_NEW3(tok(), toklen(), enc, func)); - -#ifdef RIPPER - if (!NIL_P(parser->delayed)) { - ptrdiff_t len = lex_p - parser->tokp; - if (len > 0) { - rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc); - } - ripper_dispatch_delayed_token(parser, tSTRING_CONTENT); - parser->tokp = lex_p; - } -#endif + flush_string_content(enc); return tSTRING_CONTENT; } @@ -12452,6 +11667,7 @@ parser_here_document(struct parser_params *parser, NODE *here) } if (c != '\n') { set_yylval_str(STR_NEW3(tok(), toklen(), enc, func)); + flush_string_content(enc); return tSTRING_CONTENT; } tokadd(nextc()); @@ -12729,6 +11945,7 @@ parser_magic_comment(struct parser_params *parser, const char *str, long len) } } while (++p < magic_comments + numberof(magic_comments)); #else + str_copy(val, vbeg, vend - vbeg); dispatch2(magic_comment, name, val); #endif } @@ -13211,7 +12428,6 @@ parser_yylex(struct parser_params *parser) } else if (!lex_eol_p() && !(c = *lex_p, ISASCII(c))) { nextc(); - tokadd('\\'); if (tokadd_mbchar(c) == -1) return 0; } else { @@ -14108,7 +13324,8 @@ parser_yylex(struct parser_params *parser) ID ident = TOK_INTERN(!ENC_SINGLE(mb)); set_yylval_name(ident); - if (last_state != EXPR_DOT && is_local_id(ident) && lvar_defined(ident)) { + if (last_state != EXPR_DOT && last_state != EXPR_FNAME && + is_local_id(ident) && lvar_defined(ident)) { lex_state = EXPR_END; } } @@ -1,21 +1,24 @@ -/* A Bison parser, made by GNU Bison 2.5. */ +/* A Bison parser, made by GNU Bison 2.3. */ -/* Bison interface for Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. - - This program is free software: you can redistribute it and/or modify +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - + the Free Software Foundation; either version 2, or (at your option) + any later version. + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. */ + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. */ /* As a special exception, you may create a larger work that contains part or all of the Bison parser skeleton and distribute that work @@ -26,11 +29,10 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ - /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -157,30 +159,144 @@ tLAST_TOKEN = 375 }; #endif +/* Tokens. */ +#define keyword_class 258 +#define keyword_module 259 +#define keyword_def 260 +#define keyword_undef 261 +#define keyword_begin 262 +#define keyword_rescue 263 +#define keyword_ensure 264 +#define keyword_end 265 +#define keyword_if 266 +#define keyword_unless 267 +#define keyword_then 268 +#define keyword_elsif 269 +#define keyword_else 270 +#define keyword_case 271 +#define keyword_when 272 +#define keyword_while 273 +#define keyword_until 274 +#define keyword_for 275 +#define keyword_break 276 +#define keyword_next 277 +#define keyword_redo 278 +#define keyword_retry 279 +#define keyword_in 280 +#define keyword_do 281 +#define keyword_do_cond 282 +#define keyword_do_block 283 +#define keyword_do_LAMBDA 284 +#define keyword_return 285 +#define keyword_yield 286 +#define keyword_super 287 +#define keyword_self 288 +#define keyword_nil 289 +#define keyword_true 290 +#define keyword_false 291 +#define keyword_and 292 +#define keyword_or 293 +#define keyword_not 294 +#define modifier_if 295 +#define modifier_unless 296 +#define modifier_while 297 +#define modifier_until 298 +#define modifier_rescue 299 +#define keyword_alias 300 +#define keyword_defined 301 +#define keyword_BEGIN 302 +#define keyword_END 303 +#define keyword__LINE__ 304 +#define keyword__FILE__ 305 +#define keyword__ENCODING__ 306 +#define tIDENTIFIER 307 +#define tFID 308 +#define tGVAR 309 +#define tIVAR 310 +#define tCONSTANT 311 +#define tCVAR 312 +#define tLABEL 313 +#define tINTEGER 314 +#define tFLOAT 315 +#define tSTRING_CONTENT 316 +#define tCHAR 317 +#define tNTH_REF 318 +#define tBACK_REF 319 +#define tREGEXP_END 320 +#define tUPLUS 321 +#define tUMINUS 322 +#define tPOW 323 +#define tCMP 324 +#define tEQ 325 +#define tEQQ 326 +#define tNEQ 327 +#define tGEQ 328 +#define tLEQ 329 +#define tANDOP 330 +#define tOROP 331 +#define tMATCH 332 +#define tNMATCH 333 +#define tDOT2 334 +#define tDOT3 335 +#define tAREF 336 +#define tASET 337 +#define tLSHFT 338 +#define tRSHFT 339 +#define tCOLON2 340 +#define tCOLON3 341 +#define tOP_ASGN 342 +#define tASSOC 343 +#define tLPAREN 344 +#define tLPAREN_ARG 345 +#define tRPAREN 346 +#define tLBRACK 347 +#define tLBRACE 348 +#define tLBRACE_ARG 349 +#define tSTAR 350 +#define tAMPER 351 +#define tLAMBDA 352 +#define tSYMBEG 353 +#define tSTRING_BEG 354 +#define tXSTRING_BEG 355 +#define tREGEXP_BEG 356 +#define tWORDS_BEG 357 +#define tQWORDS_BEG 358 +#define tSTRING_DBEG 359 +#define tSTRING_DVAR 360 +#define tSTRING_END 361 +#define tLAMBEG 362 +#define tLOWEST 363 +#define tUMINUS_NUM 364 +#define idNULL 365 +#define idRespond_to 366 +#define idIFUNC 367 +#define idCFUNC 368 +#define id_core_set_method_alias 369 +#define id_core_set_variable_alias 370 +#define id_core_undef_method 371 +#define id_core_define_method 372 +#define id_core_define_singleton_method 373 +#define id_core_set_postexe 374 +#define tLAST_TOKEN 375 + #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { - -/* Line 2068 of yacc.c */ - VALUE val; NODE *node; ID id; int num; const struct vtable *vars; - - - -/* Line 2068 of yacc.c */ -} YYSTYPE; -# define YYSTYPE_IS_TRIVIAL 1 +} +/* Line 1489 of yacc.c. */ + YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 +# define YYSTYPE_IS_TRIVIAL 1 #endif - @@ -2,7 +2,7 @@ parse.y - - $Author: nobu $ + $Author: usa $ created at: Fri May 28 18:02:42 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -4374,6 +4374,8 @@ f_arglist : '(' f_args rparen | f_args term { $$ = $1; + lex_state = EXPR_BEG; + command_start = TRUE; } ; @@ -5926,7 +5928,7 @@ parser_tokadd_string(struct parser_params *parser, default: if (c == -1) return -1; if (!ISASCII(c)) { - tokadd('\\'); + if ((func & STR_FUNC_EXPAND) == 0) tokadd('\\'); goto non_ascii; } if (func & STR_FUNC_REGEXP) { @@ -5983,6 +5985,25 @@ parser_tokadd_string(struct parser_params *parser, #define NEW_STRTERM(func, term, paren) \ rb_node_newnode(NODE_STRTERM, (func), (term) | ((paren) << (CHAR_BIT * 2)), 0) +#ifdef RIPPER +static void +ripper_flush_string_content(struct parser_params *parser, rb_encoding *enc) +{ + if (!NIL_P(parser->delayed)) { + ptrdiff_t len = lex_p - parser->tokp; + if (len > 0) { + rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc); + } + ripper_dispatch_delayed_token(parser, tSTRING_CONTENT); + parser->tokp = lex_p; + } +} + +#define flush_string_content(enc) ripper_flush_string_content(parser, (enc)) +#else +#define flush_string_content(enc) ((void)(enc)) +#endif + static int parser_parse_string(struct parser_params *parser, NODE *quote) { @@ -6041,17 +6062,7 @@ parser_parse_string(struct parser_params *parser, NODE *quote) tokfix(); set_yylval_str(STR_NEW3(tok(), toklen(), enc, func)); - -#ifdef RIPPER - if (!NIL_P(parser->delayed)) { - ptrdiff_t len = lex_p - parser->tokp; - if (len > 0) { - rb_enc_str_buf_cat(parser->delayed, parser->tokp, len, enc); - } - ripper_dispatch_delayed_token(parser, tSTRING_CONTENT); - parser->tokp = lex_p; - } -#endif + flush_string_content(enc); return tSTRING_CONTENT; } @@ -6256,6 +6267,7 @@ parser_here_document(struct parser_params *parser, NODE *here) } if (c != '\n') { set_yylval_str(STR_NEW3(tok(), toklen(), enc, func)); + flush_string_content(enc); return tSTRING_CONTENT; } tokadd(nextc()); @@ -6533,6 +6545,7 @@ parser_magic_comment(struct parser_params *parser, const char *str, long len) } } while (++p < magic_comments + numberof(magic_comments)); #else + str_copy(val, vbeg, vend - vbeg); dispatch2(magic_comment, name, val); #endif } @@ -7015,7 +7028,6 @@ parser_yylex(struct parser_params *parser) } else if (!lex_eol_p() && !(c = *lex_p, ISASCII(c))) { nextc(); - tokadd('\\'); if (tokadd_mbchar(c) == -1) return 0; } else { @@ -7912,7 +7924,8 @@ parser_yylex(struct parser_params *parser) ID ident = TOK_INTERN(!ENC_SINGLE(mb)); set_yylval_name(ident); - if (last_state != EXPR_DOT && is_local_id(ident) && lvar_defined(ident)) { + if (last_state != EXPR_DOT && last_state != EXPR_FNAME && + is_local_id(ident) && lvar_defined(ident)) { lex_state = EXPR_END; } } @@ -2,7 +2,7 @@ proc.c - Proc, Binding, Env - $Author: kosaki $ + $Author: usa $ created at: Wed Jan 17 12:13:14 2007 Copyright (C) 2004-2007 Koichi Sasada @@ -27,7 +27,7 @@ VALUE rb_cMethod; VALUE rb_cBinding; VALUE rb_cProc; -static VALUE bmcall(VALUE, VALUE); +static VALUE bmcall(VALUE, VALUE, int, VALUE *, VALUE); static int method_arity(VALUE); /* Proc */ @@ -417,7 +417,6 @@ proc_new(VALUE klass, int is_lambda) } procval = rb_vm_make_proc(th, block, klass); - rb_vm_rewrite_dfp_in_errinfo(th, cfp); if (is_lambda) { rb_proc_t *proc; @@ -466,6 +465,14 @@ rb_block_proc(void) return proc_new(rb_cProc, FALSE); } +/* + * call-seq: + * lambda { |...| block } -> a_proc + * + * Equivalent to <code>Proc.new</code>, except the resulting Proc objects + * check the number of parameters passed when called. + */ + VALUE rb_block_lambda(void) { @@ -479,20 +486,6 @@ rb_f_lambda(void) return rb_block_lambda(); } -/* - * call-seq: - * lambda { |...| block } -> a_proc - * - * Equivalent to <code>Proc.new</code>, except the resulting Proc objects - * check the number of parameters passed when called. - */ - -static VALUE -proc_lambda(void) -{ - return rb_block_lambda(); -} - /* Document-method: === * * call-seq: @@ -1414,6 +1407,13 @@ method_clone(VALUE self) VALUE rb_method_call(int argc, VALUE *argv, VALUE method) { + VALUE proc = rb_block_given_p() ? rb_block_proc() : Qnil; + return rb_method_call_with_block(argc, argv, method, proc); +} + +VALUE +rb_method_call_with_block(int argc, VALUE *argv, VALUE method, VALUE pass_procval) +{ VALUE result = Qnil; /* OK */ struct METHOD *data; int state; @@ -1432,8 +1432,15 @@ rb_method_call(int argc, VALUE *argv, VALUE method) } if ((state = EXEC_TAG()) == 0) { rb_thread_t *th = GET_THREAD(); + rb_block_t *block = 0; + + if (!NIL_P(pass_procval)) { + rb_proc_t *pass_proc; + GetProcPtr(pass_procval, pass_proc); + block = &pass_proc->block; + } - PASS_PASSED_BLOCK_TH(th); + th->passed_block = block; result = rb_vm_call(th, data->recv, data->id, argc, argv, data->me); } POP_TAG(); @@ -1799,21 +1806,20 @@ method_inspect(VALUE method) static VALUE mproc(VALUE method) { - return rb_funcall(Qnil, rb_intern("proc"), 0); + return rb_funcall2(rb_mRubyVMFrozenCore, idProc, 0, 0); } static VALUE mlambda(VALUE method) { - return rb_funcall(Qnil, rb_intern("lambda"), 0); + return rb_funcall(rb_mRubyVMFrozenCore, idLambda, 0, 0); } static VALUE -bmcall(VALUE args, VALUE method) +bmcall(VALUE args, VALUE method, int argc, VALUE *argv, VALUE passed_proc) { volatile VALUE a; VALUE ret; - int argc; if (CLASS_OF(args) != rb_cArray) { args = rb_ary_new3(1, args); @@ -1822,7 +1828,7 @@ bmcall(VALUE args, VALUE method) else { argc = check_argc(RARRAY_LEN(args)); } - ret = rb_method_call(argc, RARRAY_PTR(args), method); + ret = rb_method_call_with_block(argc, RARRAY_PTR(args), method, passed_proc); RB_GC_GUARD(a) = args; return ret; } @@ -2152,7 +2158,7 @@ Init_Proc(void) /* utility functions */ rb_define_global_function("proc", rb_block_proc, 0); - rb_define_global_function("lambda", proc_lambda, 0); + rb_define_global_function("lambda", rb_block_lambda, 0); /* Method */ rb_cMethod = rb_define_class("Method", rb_cObject); @@ -2,7 +2,7 @@ random.c - - $Author: akr $ + $Author: usa $ created at: Fri Dec 24 16:39:21 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -73,6 +73,9 @@ The original copyright notice follows. #endif #include <math.h> #include <errno.h> +#if defined(HAVE_SYS_TIME_H) +#include <sys/time.h> +#endif #ifdef _WIN32 # if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0400 @@ -1255,10 +1258,32 @@ rb_f_rand(int argc, VALUE *argv, VALUE obj) static VALUE random_s_rand(int argc, VALUE *argv, VALUE obj) { + rand_start(&default_rand); return random_rand(argc, argv, rb_Random_DEFAULT); } +#define SIP_HASH_STREAMING 0 +#define sip_hash24 ruby_sip_hash24 +#if !defined _WIN32 && !defined BYTE_ORDER +# ifdef WORDS_BIGENDIAN +# define BYTE_ORDER BIG_ENDIAN +# else +# define BYTE_ORDER LITTLE_ENDIAN +# endif +# ifndef LITTLE_ENDIAN +# define LITTLE_ENDIAN 1234 +# endif +# ifndef BIG_ENDIAN +# define BIG_ENDIAN 4321 +# endif +#endif +#include "siphash.c" + static st_index_t hashseed; +static union { + uint8_t key[16]; + uint32_t u32[(16 * sizeof(uint8_t) - 1) / sizeof(uint32_t)]; +} sipseed; static VALUE init_randomseed(struct MT *mt, unsigned int initial[DEFAULT_SEED_CNT]) @@ -1278,6 +1303,7 @@ Init_RandomSeed(void) unsigned int initial[DEFAULT_SEED_CNT]; struct MT *mt = &r->mt; VALUE seed = init_randomseed(mt, initial); + int i; hashseed = genrand_int32(mt); #if SIZEOF_ST_INDEX_T*CHAR_BIT > 4*8 @@ -1293,6 +1319,9 @@ Init_RandomSeed(void) hashseed |= genrand_int32(mt); #endif + for (i = 0; i < numberof(sipseed.u32); ++i) + sipseed.u32[i] = genrand_int32(mt); + rb_global_variable(&r->seed); r->seed = seed; } @@ -1303,6 +1332,17 @@ rb_hash_start(st_index_t h) return st_hash_start(hashseed + h); } +st_index_t +rb_memhash(const void *ptr, long len) +{ + sip_uint64_t h = sip_hash24(sipseed.key, ptr, len); +#ifdef HAVE_UINT64_T + return (st_index_t)h; +#else + return (st_index_t)(h.u32[0] ^ h.u32[1]); +#endif +} + static void Init_RandomSeed2(void) { @@ -4735,6 +4735,7 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) case ANCHOR_END_BUF: case ANCHOR_SEMI_END_BUF: case ANCHOR_END_LINE: + case ANCHOR_LOOK_BEHIND: /* just for (?<=x).* */ add_opt_anc_info(&opt->anc, NANCHOR(node)->type); break; @@ -4758,7 +4759,6 @@ optimize_node_left(Node* node, NodeOptInfo* opt, OptEnv* env) break; case ANCHOR_PREC_READ_NOT: - case ANCHOR_LOOK_BEHIND: /* Sorry, I can't make use of it. */ case ANCHOR_LOOK_BEHIND_NOT: break; } @@ -5010,7 +5010,8 @@ set_optimize_info_from_tree(Node* node, regex_t* reg, ScanEnv* scan_env) if (r) return r; reg->anchor = opt.anc.left_anchor & (ANCHOR_BEGIN_BUF | - ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML); + ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_STAR | ANCHOR_ANYCHAR_STAR_ML | + ANCHOR_LOOK_BEHIND); reg->anchor |= opt.anc.right_anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF); @@ -3515,15 +3515,14 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, start = min_semi_end - reg->anchor_dmax; if (start < end) start = onigenc_get_right_adjust_char_head(reg->enc, str, start, end); - else { /* match with empty at end */ - start = onigenc_get_prev_char_head(reg->enc, str, end, end); - } } if ((OnigDistance )(max_semi_end - (range - 1)) < reg->anchor_dmin) { range = max_semi_end - reg->anchor_dmin + 1; } - if (start >= range) goto mismatch_no_msa; + if (start > range) goto mismatch_no_msa; + /* If start == range, match with empty at end. + Backward search is used. */ } else { if ((OnigDistance )(min_semi_end - range) > reg->anchor_dmax) { @@ -3560,7 +3559,9 @@ onig_search(regex_t* reg, const UChar* str, const UChar* end, } } else if ((reg->anchor & ANCHOR_ANYCHAR_STAR_ML)) { - goto begin_position; + if (!(reg->anchor & ANCHOR_LOOK_BEHIND)) { + goto begin_position; + } } } else if (str == end) { /* empty string */ @@ -579,7 +579,7 @@ onig_number_of_names(regex_t* reg) NameTable* t = (NameTable* )reg->name_table; if (IS_NOT_NULL(t)) - return t->num_entries; + return (int)t->num_entries; else return 0; } @@ -4491,7 +4491,7 @@ parse_char_class(Node** np, OnigToken* tok, UChar** src, UChar* end, if (IS_SYNTAX_BV(env->syntax, ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC)) { CC_ESC_WARN(env, (UChar* )"-"); - goto sb_char; /* [0-9-a] is allowed as [0-9\-a] */ + goto range_end_val; /* [0-9-a] is allowed as [0-9\-a] */ } r = ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS; goto err; @@ -1 +1 @@ -#define RUBY_REVISION 35410 +#define RUBY_REVISION 41675 @@ -2,7 +2,7 @@ ruby.c - - $Author: kosaki $ + $Author: usa $ created at: Tue Aug 10 12:47:31 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -410,9 +410,21 @@ ruby_init_loadpath_safe(int safe_level) #endif p = strrchr(libpath, '/'); if (p) { + static const char bindir[] = "/bin"; +#ifdef LIBDIR_BASENAME + static const char libdir[] = "/"LIBDIR_BASENAME; +#else + static const char libdir[] = "/lib"; +#endif + const ptrdiff_t bindir_len = (ptrdiff_t)sizeof(bindir) - 1; + const ptrdiff_t libdir_len = (ptrdiff_t)sizeof(libdir) - 1; *p = 0; - if (p - libpath > 3 && !(STRCASECMP(p - 4, "/bin") && strcmp(p - 4, "/lib"))) { - p -= 4; + if (p - libpath >= bindir_len && !STRCASECMP(p - bindir_len, bindir)) { + p -= bindir_len; + *p = 0; + } + else if (p - libpath >= libdir_len && !STRCASECMP(p - libdir_len, libdir)) { + p -= libdir_len; *p = 0; } } @@ -464,12 +476,15 @@ static void add_modules(VALUE *req_list, const char *mod) { VALUE list = *req_list; + VALUE feature; if (!list) { *req_list = list = rb_ary_new(); RBASIC(list)->klass = 0; } - rb_ary_push(list, rb_obj_freeze(rb_str_new2(mod))); + feature = rb_str_new2(mod); + RBASIC(feature)->klass = 0; + rb_ary_push(list, feature); } static void @@ -480,6 +495,7 @@ require_libraries(VALUE *req_list) ID require; rb_thread_t *th = GET_THREAD(); rb_block_t *prev_base_block = th->base_block; + rb_encoding *extenc = rb_default_external_encoding(); int prev_parse_in_eval = th->parse_in_eval; th->base_block = 0; th->parse_in_eval = 0; @@ -488,6 +504,9 @@ require_libraries(VALUE *req_list) CONST_ID(require, "require"); while (list && RARRAY_LEN(list) > 0) { VALUE feature = rb_ary_shift(list); + rb_enc_associate(feature, extenc); + RBASIC(feature)->klass = rb_cString; + OBJ_FREEZE(feature); rb_funcall2(self, require, 1, &feature); } *req_list = 0; @@ -1159,7 +1178,7 @@ rb_f_sub(argc, argv) int argc; VALUE *argv; { - VALUE str = rb_funcall3(uscore_get(), rb_intern("sub"), argc, argv); + VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("sub"), argc, argv); rb_lastline_set(str); return str; } @@ -1180,7 +1199,7 @@ rb_f_gsub(argc, argv) int argc; VALUE *argv; { - VALUE str = rb_funcall3(uscore_get(), rb_intern("gsub"), argc, argv); + VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("gsub"), argc, argv); rb_lastline_set(str); return str; } @@ -1198,7 +1217,7 @@ rb_f_gsub(argc, argv) static VALUE rb_f_chop(void) { - VALUE str = rb_funcall3(uscore_get(), rb_intern("chop"), 0, 0); + VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("chop"), 0, 0); rb_lastline_set(str); return str; } @@ -1220,7 +1239,7 @@ rb_f_chomp(argc, argv) int argc; VALUE *argv; { - VALUE str = rb_funcall3(uscore_get(), rb_intern("chomp"), argc, argv); + VALUE str = rb_funcall_passing_block(uscore_get(), rb_intern("chomp"), argc, argv); rb_lastline_set(str); return str; } diff --git a/ruby_atomic.h b/ruby_atomic.h new file mode 100644 index 0000000..920c304 --- /dev/null +++ b/ruby_atomic.h @@ -0,0 +1,115 @@ +#ifndef RUBY_ATOMIC_H +#define RUBY_ATOMIC_H + +#if 0 +#elif defined HAVE_GCC_ATOMIC_BUILTINS +/* @shyouhei hack to support atomic operations in case of gcc. Gcc + * has its own pseudo-insns to support them. See info, or + * http://gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html */ + +typedef unsigned int rb_atomic_t; /* Anything OK */ +# define ATOMIC_SET(var, val) (void)__sync_lock_test_and_set(&(var), (val)) +# define ATOMIC_INC(var) __sync_fetch_and_add(&(var), 1) +# define ATOMIC_DEC(var) __sync_fetch_and_sub(&(var), 1) +# define ATOMIC_OR(var, val) __sync_or_and_fetch(&(var), (val)) +# define ATOMIC_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val)) + +# define ATOMIC_SIZE_ADD(var, val) __sync_fetch_and_add(&(var), (val)) +# define ATOMIC_SIZE_SUB(var, val) __sync_fetch_and_sub(&(var), (val)) +# define ATOMIC_SIZE_INC(var) __sync_fetch_and_add(&(var), 1) +# define ATOMIC_SIZE_DEC(var) __sync_fetch_and_sub(&(var), 1) +# define ATOMIC_SIZE_EXCHANGE(var, val) __sync_lock_test_and_set(&(var), (val)) + +#elif defined _WIN32 +#if defined _MSC_VER && _MSC_VER > 1200 +#pragma intrinsic(_InterlockedOr) +#endif +typedef LONG rb_atomic_t; + +# define ATOMIC_SET(var, val) InterlockedExchange(&(var), (val)) +# define ATOMIC_INC(var) InterlockedIncrement(&(var)) +# define ATOMIC_DEC(var) InterlockedDecrement(&(var)) +#if defined __GNUC__ +# define ATOMIC_OR(var, val) __asm__("lock\n\t" "orl\t%1, %0" : "=m"(var) : "Ir"(val)) +#elif defined _MSC_VER && _MSC_VER <= 1200 +# define ATOMIC_OR(var, val) rb_w32_atomic_or(&(var), (val)) +static inline void +rb_w32_atomic_or(volatile rb_atomic_t *var, rb_atomic_t val) +{ +#ifdef _M_IX86 + __asm mov eax, var; + __asm mov ecx, val; + __asm lock or [eax], ecx; +#else +#error unsupported architecture +#endif +} +#else +# define ATOMIC_OR(var, val) _InterlockedOr(&(var), (val)) +#endif +# define ATOMIC_EXCHANGE(var, val) InterlockedExchange(&(var), (val)) + +# ifdef _M_AMD64 +# define ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd64(&(var), (val)) +# define ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd64(&(var), -(val)) +# define ATOMIC_SIZE_INC(var) InterlockedIncrement64(&(var)) +# define ATOMIC_SIZE_DEC(var) InterlockedDecrement64(&(var)) +# define ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange64(&(var), (val)) +# else +# define ATOMIC_SIZE_ADD(var, val) InterlockedExchangeAdd((LONG *)&(var), (val)) +# define ATOMIC_SIZE_SUB(var, val) InterlockedExchangeAdd((LONG *)&(var), -(val)) +# define ATOMIC_SIZE_INC(var) InterlockedIncrement((LONG *)&(var)) +# define ATOMIC_SIZE_DEC(var) InterlockedDecrement((LONG *)&(var)) +# define ATOMIC_SIZE_EXCHANGE(var, val) InterlockedExchange((LONG *)&(var), (val)) +# endif + +#elif defined(__sun) && defined(HAVE_ATOMIC_H) +#include <atomic.h> +typedef unsigned int rb_atomic_t; + +# define ATOMIC_SET(var, val) (void)atomic_swap_uint(&(var), (val)) +# define ATOMIC_INC(var) atomic_inc_uint(&(var)) +# define ATOMIC_DEC(var) atomic_dec_uint(&(var)) +# define ATOMIC_OR(var, val) atomic_or_uint(&(var), (val)) +# define ATOMIC_EXCHANGE(var, val) atomic_swap_uint(&(var), (val)) + +# if SIZEOF_SIZE_T == SIZEOF_LONG +# define ATOMIC_SIZE_ADD(var, val) atomic_add_long(&(var), (val)) +# define ATOMIC_SIZE_SUB(var, val) atomic_add_long(&(var), -(val)) +# define ATOMIC_SIZE_INC(var) atomic_inc_ulong(&(var)) +# define ATOMIC_SIZE_DEC(var) atomic_dec_ulong(&(var)) +# define ATOMIC_SIZE_EXCHANGE(var, val) atomic_swap_ulong(&(var), (val)) +# else +# define ATOMIC_SIZE_ADD(var, val) atomic_add_int(&(var), (val)) +# define ATOMIC_SIZE_SUB(var, val) atomic_add_int(&(var), -(val)) +# define ATOMIC_SIZE_INC(var) atomic_inc_uint(&(var)) +# define ATOMIC_SIZE_DEC(var) atomic_dec_uint(&(var)) +# define ATOMIC_SIZE_EXCHANGE(var, val) atomic_swap_uint(&(var), (val)) +# endif + +#else +typedef int rb_atomic_t; +#define NEED_RUBY_ATOMIC_EXCHANGE +extern rb_atomic_t ruby_atomic_exchange(rb_atomic_t *ptr, rb_atomic_t val); + +# define ATOMIC_SET(var, val) (void)((var) = (val)) +# define ATOMIC_INC(var) ((var)++) +# define ATOMIC_DEC(var) ((var)--) +# define ATOMIC_OR(var, val) ((var) |= (val)) +# define ATOMIC_EXCHANGE(var, val) ruby_atomic_exchange(&(var), (val)) + +# define ATOMIC_SIZE_ADD(var, val) (void)((var) += (val)) +# define ATOMIC_SIZE_SUB(var, val) (void)((var) -= (val)) +# define ATOMIC_SIZE_INC(var) ((var)++) +# define ATOMIC_SIZE_DEC(var) ((var)--) +# define ATOMIC_SIZE_EXCHANGE(var, val) atomic_size_exchange(&(var), (val)) +static inline size_t +atomic_size_exchange(size_t *ptr, size_t val) +{ + size_t old = *ptr; + *ptr = val; + return old; +} +#endif + +#endif /* RUBY_ATOMIC_H */ @@ -2,7 +2,7 @@ signal.c - - $Author: kosaki $ + $Author: usa $ created at: Tue Dec 20 10:13:44 JST 1994 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -16,7 +16,10 @@ #include <signal.h> #include <stdio.h> #include <errno.h> -#include "atomic.h" +#include "ruby_atomic.h" +#ifdef HAVE_UNISTD_H +# include <unistd.h> +#endif #if !defined(_WIN32) && !defined(HAVE_GCC_ATOMIC_BUILTINS) rb_atomic_t @@ -564,6 +567,23 @@ rb_get_next_signal(void) return sig; } + +#ifdef USE_SIGALTSTACK +static void +check_stack_overflow(const void *addr) +{ + int ruby_stack_overflowed_p(const rb_thread_t *, const void *); + NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th)); + rb_thread_t *th = GET_THREAD(); + if (ruby_stack_overflowed_p(th, addr)) { + ruby_thread_stack_overflow(th); + } +} +#define CHECK_STACK_OVERFLOW() check_stack_overflow(info->si_addr) +#else +#define CHECK_STACK_OVERFLOW() (void)0 +#endif + #ifdef SIGBUS static RETSIGTYPE sigbus(int sig SIGINFO_ARG) @@ -573,41 +593,44 @@ sigbus(int sig SIGINFO_ARG) * and it's delivered as SIGBUS instaed of SIGSEGV to userland. It's crazy * wrong IMHO. but anyway we have to care it. Sigh. */ -#if defined __MACH__ && defined __APPLE__ && defined USE_SIGALTSTACK - int ruby_stack_overflowed_p(const rb_thread_t *, const void *); - NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th)); - rb_thread_t *th = GET_THREAD(); - if (ruby_stack_overflowed_p(th, info->si_addr)) { - ruby_thread_stack_overflow(th); - } +#if defined __APPLE__ + CHECK_STACK_OVERFLOW(); #endif rb_bug("Bus Error"); } #endif #ifdef SIGSEGV +static void ruby_abort(void) +{ +#ifdef __sun + /* Solaris's abort() is async signal unsafe. Of course, it is not + * POSIX compliant. + */ + raise(SIGABRT); +#else + abort(); +#endif + +} + static int segv_received = 0; +extern int ruby_disable_gc_stress; + static RETSIGTYPE sigsegv(int sig SIGINFO_ARG) { -#ifdef USE_SIGALTSTACK - int ruby_stack_overflowed_p(const rb_thread_t *, const void *); - NORETURN(void ruby_thread_stack_overflow(rb_thread_t *th)); - rb_thread_t *th = GET_THREAD(); - if (ruby_stack_overflowed_p(th, info->si_addr)) { - ruby_thread_stack_overflow(th); - } -#endif if (segv_received) { - fprintf(stderr, "SEGV received in SEGV handler\n"); - abort(); - } - else { - extern int ruby_disable_gc_stress; - segv_received = 1; - ruby_disable_gc_stress = 1; - rb_bug("Segmentation fault"); + char msg[] = "SEGV received in SEGV handler\n"; + write(2, msg, sizeof(msg)); + ruby_abort(); } + + CHECK_STACK_OVERFLOW(); + + segv_received = 1; + ruby_disable_gc_stress = 1; + rb_bug("Segmentation fault"); } #endif diff --git a/siphash.c b/siphash.c new file mode 100644 index 0000000..c100b14 --- /dev/null +++ b/siphash.c @@ -0,0 +1,483 @@ +#include <string.h> +#include <stdio.h> +#include "siphash.h" +#ifndef SIP_HASH_STREAMING + #define SIP_HASH_STREAMING 1 +#endif + +#ifdef _WIN32 + #define BYTE_ORDER __LITTLE_ENDIAN +#elif !defined BYTE_ORDER + #include <endian.h> +#endif +#ifndef LITTLE_ENDIAN +#define LITTLE_ENDIAN __LITTLE_ENDIAN +#endif +#ifndef BIG_ENDIAN +#define BIG_ENDIAN __BIG_ENDIAN +#endif + +#if BYTE_ORDER == LITTLE_ENDIAN + #define lo u32[0] + #define hi u32[1] +#elif BYTE_ORDER == BIG_ENDIAN + #define hi u32[0] + #define lo u32[1] +#else + #error "Only strictly little or big endian supported" +#endif + +#ifndef UNALIGNED_WORD_ACCESS +# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \ + defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD86) || \ + defined(__mc68020__) +# define UNALIGNED_WORD_ACCESS 1 +# endif +#endif +#ifndef UNALIGNED_WORD_ACCESS +# define UNALIGNED_WORD_ACCESS 0 +#endif + +#define U8TO32_LE(p) \ + (((uint32_t)((p)[0]) ) | ((uint32_t)((p)[1]) << 8) | \ + ((uint32_t)((p)[2]) << 16) | ((uint32_t)((p)[3]) << 24)) \ + +#define U32TO8_LE(p, v) \ +do { \ + (p)[0] = (uint8_t)((v) ); \ + (p)[1] = (uint8_t)((v) >> 8); \ + (p)[2] = (uint8_t)((v) >> 16); \ + (p)[3] = (uint8_t)((v) >> 24); \ +} while (0) + +#ifdef HAVE_UINT64_T +#define U8TO64_LE(p) \ + ((uint64_t)U8TO32_LE(p) | ((uint64_t)U8TO32_LE((p) + 4)) << 32 ) + +#define U64TO8_LE(p, v) \ +do { \ + U32TO8_LE((p), (uint32_t)((v) )); \ + U32TO8_LE((p) + 4, (uint32_t)((v) >> 32)); \ +} while (0) + +#define ROTL64(v, s) \ + ((v) << (s)) | ((v) >> (64 - (s))) + +#define ROTL64_TO(v, s) ((v) = ROTL64((v), (s))) + +#define ADD64_TO(v, s) ((v) += (s)) +#define XOR64_TO(v, s) ((v) ^= (s)) +#define XOR64_INT(v, x) ((v) ^= (x)) +#else +#define U8TO64_LE(p) u8to64_le(p) +static inline uint64_t +u8to64_le(const uint8_t *p) +{ + uint64_t ret; + ret.lo = U8TO32_LE(p); + ret.hi = U8TO32_LE(p + 4); + return ret; +} + +#define U64TO8_LE(p, v) u64to8_le(p, v) +static inline void +u64to8_le(uint8_t *p, uint64_t v) +{ + U32TO8_LE(p, v.lo); + U32TO8_LE(p + 4, v.hi); +} + +#define ROTL64_TO(v, s) ((s) > 32 ? rotl64_swap(rotl64_to(&(v), (s) - 32)) : \ + (s) == 32 ? rotl64_swap(&(v)) : rotl64_to(&(v), (s))) +static inline uint64_t * +rotl64_to(uint64_t *v, unsigned int s) +{ + uint32_t uhi = (v->hi << s) | (v->lo >> (32 - s)); + uint32_t ulo = (v->lo << s) | (v->hi >> (32 - s)); + v->hi = uhi; + v->lo = ulo; + return v; +} + +static inline uint64_t * +rotl64_swap(uint64_t *v) +{ + uint32_t t = v->lo; + v->lo = v->hi; + v->hi = t; + return v; +} + +#define ADD64_TO(v, s) add64_to(&(v), (s)) +static inline uint64_t * +add64_to(uint64_t *v, const uint64_t s) +{ + v->lo += s.lo; + v->hi += s.hi; + if (v->lo < s.lo) v->hi++; + return v; +} + +#define XOR64_TO(v, s) xor64_to(&(v), (s)) +static inline uint64_t * +xor64_to(uint64_t *v, const uint64_t s) +{ + v->lo ^= s.lo; + v->hi ^= s.hi; + return v; +} + +#define XOR64_INT(v, x) ((v).lo ^= (x)) +#endif + +static const union { + char bin[32]; + uint64_t u64[4]; +} sip_init_state_bin = {"uespemos""modnarod""arenegyl""setybdet"}; +#define sip_init_state sip_init_state_bin.u64 + +#if SIP_HASH_STREAMING +struct sip_interface_st { + void (*init)(sip_state *s, const uint8_t *key); + void (*update)(sip_state *s, const uint8_t *data, size_t len); + void (*final)(sip_state *s, uint64_t *digest); +}; + +static void int_sip_init(sip_state *state, const uint8_t *key); +static void int_sip_update(sip_state *state, const uint8_t *data, size_t len); +static void int_sip_final(sip_state *state, uint64_t *digest); + +static const sip_interface sip_methods = { + int_sip_init, + int_sip_update, + int_sip_final +}; +#endif /* SIP_HASH_STREAMING */ + +#define SIP_COMPRESS(v0, v1, v2, v3) \ +do { \ + ADD64_TO((v0), (v1)); \ + ADD64_TO((v2), (v3)); \ + ROTL64_TO((v1), 13); \ + ROTL64_TO((v3), 16); \ + XOR64_TO((v1), (v0)); \ + XOR64_TO((v3), (v2)); \ + ROTL64_TO((v0), 32); \ + ADD64_TO((v2), (v1)); \ + ADD64_TO((v0), (v3)); \ + ROTL64_TO((v1), 17); \ + ROTL64_TO((v3), 21); \ + XOR64_TO((v1), (v2)); \ + XOR64_TO((v3), (v0)); \ + ROTL64_TO((v2), 32); \ +} while(0) + +#if SIP_HASH_STREAMING +static void +int_sip_dump(sip_state *state) +{ + int v; + + for (v = 0; v < 4; v++) { +#if HAVE_UINT64_T + printf("v%d: %" PRIx64 "\n", v, state->v[v]); +#else + printf("v%d: %" PRIx32 "%.8" PRIx32 "\n", v, state->v[v].hi, state->v[v].lo); +#endif + } +} + +static void +int_sip_init(sip_state *state, const uint8_t key[16]) +{ + uint64_t k0, k1; + + k0 = U8TO64_LE(key); + k1 = U8TO64_LE(key + sizeof(uint64_t)); + + state->v[0] = k0; XOR64_TO(state->v[0], sip_init_state[0]); + state->v[1] = k1; XOR64_TO(state->v[1], sip_init_state[1]); + state->v[2] = k0; XOR64_TO(state->v[2], sip_init_state[2]); + state->v[3] = k1; XOR64_TO(state->v[3], sip_init_state[3]); +} + +static inline void +int_sip_round(sip_state *state, int n) +{ + int i; + + for (i = 0; i < n; i++) { + SIP_COMPRESS(state->v[0], state->v[1], state->v[2], state->v[3]); + } +} + +static inline void +int_sip_update_block(sip_state *state, uint64_t m) +{ + XOR64_TO(state->v[3], m); + int_sip_round(state, state->c); + XOR64_TO(state->v[0], m); +} + +static inline void +int_sip_pre_update(sip_state *state, const uint8_t **pdata, size_t *plen) +{ + int to_read; + uint64_t m; + + if (!state->buflen) return; + + to_read = sizeof(uint64_t) - state->buflen; + memcpy(state->buf + state->buflen, *pdata, to_read); + m = U8TO64_LE(state->buf); + int_sip_update_block(state, m); + *pdata += to_read; + *plen -= to_read; + state->buflen = 0; +} + +static inline void +int_sip_post_update(sip_state *state, const uint8_t *data, size_t len) +{ + uint8_t r = len % sizeof(uint64_t); + if (r) { + memcpy(state->buf, data + len - r, r); + state->buflen = r; + } +} + +static void +int_sip_update(sip_state *state, const uint8_t *data, size_t len) +{ + uint64_t *end; + uint64_t *data64; + + state->msglen_byte = state->msglen_byte + (len % 256); + data64 = (uint64_t *) data; + + int_sip_pre_update(state, &data, &len); + + end = data64 + (len / sizeof(uint64_t)); + +#if BYTE_ORDER == LITTLE_ENDIAN + while (data64 != end) { + int_sip_update_block(state, *data64++); + } +#elif BYTE_ORDER == BIG_ENDIAN + { + uint64_t m; + uint8_t *data8 = data; + for (; data8 != (uint8_t *) end; data8 += sizeof(uint64_t)) { + m = U8TO64_LE(data8); + int_sip_update_block(state, m); + } + } +#endif + + int_sip_post_update(state, data, len); +} + +static inline void +int_sip_pad_final_block(sip_state *state) +{ + int i; + /* pad with 0's and finalize with msg_len mod 256 */ + for (i = state->buflen; i < sizeof(uint64_t); i++) { + state->buf[i] = 0x00; + } + state->buf[sizeof(uint64_t) - 1] = state->msglen_byte; +} + +static void +int_sip_final(sip_state *state, uint64_t *digest) +{ + uint64_t m; + + int_sip_pad_final_block(state); + + m = U8TO64_LE(state->buf); + int_sip_update_block(state, m); + + XOR64_INT(state->v[2], 0xff); + + int_sip_round(state, state->d); + + *digest = state->v[0]; + XOR64_TO(*digest, state->v[1]); + XOR64_TO(*digest, state->v[2]); + XOR64_TO(*digest, state->v[3]); +} + +sip_hash * +sip_hash_new(const uint8_t key[16], int c, int d) +{ + sip_hash *h = NULL; + + if (!(h = (sip_hash *) malloc(sizeof(sip_hash)))) return NULL; + return sip_hash_init(h, key, c, d); +} + +sip_hash * +sip_hash_init(sip_hash *h, const uint8_t key[16], int c, int d) +{ + h->state->c = c; + h->state->d = d; + h->state->buflen = 0; + h->state->msglen_byte = 0; + h->methods = &sip_methods; + h->methods->init(h->state, key); + return h; +} + +int +sip_hash_update(sip_hash *h, const uint8_t *msg, size_t len) +{ + h->methods->update(h->state, msg, len); + return 1; +} + +int +sip_hash_final(sip_hash *h, uint8_t **digest, size_t* len) +{ + uint64_t digest64; + uint8_t *ret; + + h->methods->final(h->state, &digest64); + if (!(ret = (uint8_t *)malloc(sizeof(uint64_t)))) return 0; + U64TO8_LE(ret, digest64); + *len = sizeof(uint64_t); + *digest = ret; + + return 1; +} + +int +sip_hash_final_integer(sip_hash *h, uint64_t *digest) +{ + h->methods->final(h->state, digest); + return 1; +} + +int +sip_hash_digest(sip_hash *h, const uint8_t *data, size_t data_len, uint8_t **digest, size_t *digest_len) +{ + if (!sip_hash_update(h, data, data_len)) return 0; + return sip_hash_final(h, digest, digest_len); +} + +int +sip_hash_digest_integer(sip_hash *h, const uint8_t *data, size_t data_len, uint64_t *digest) +{ + if (!sip_hash_update(h, data, data_len)) return 0; + return sip_hash_final_integer(h, digest); +} + +void +sip_hash_free(sip_hash *h) +{ + free(h); +} + +void +sip_hash_dump(sip_hash *h) +{ + int_sip_dump(h->state); +} +#endif /* SIP_HASH_STREAMING */ + +#define SIP_2_ROUND(m, v0, v1, v2, v3) \ +do { \ + XOR64_TO((v3), (m)); \ + SIP_COMPRESS(v0, v1, v2, v3); \ + SIP_COMPRESS(v0, v1, v2, v3); \ + XOR64_TO((v0), (m)); \ +} while (0) + +uint64_t +sip_hash24(const uint8_t key[16], const uint8_t *data, size_t len) +{ + uint64_t k0, k1; + uint64_t v0, v1, v2, v3; + uint64_t m, last; + const uint8_t *end = data + len - (len % sizeof(uint64_t)); + + k0 = U8TO64_LE(key); + k1 = U8TO64_LE(key + sizeof(uint64_t)); + + v0 = k0; XOR64_TO(v0, sip_init_state[0]); + v1 = k1; XOR64_TO(v1, sip_init_state[1]); + v2 = k0; XOR64_TO(v2, sip_init_state[2]); + v3 = k1; XOR64_TO(v3, sip_init_state[3]); + +#if BYTE_ORDER == LITTLE_ENDIAN && UNALIGNED_WORD_ACCESS + { + uint64_t *data64 = (uint64_t *)data; + while (data64 != (uint64_t *) end) { + m = *data64++; + SIP_2_ROUND(m, v0, v1, v2, v3); + } + } +#elif BYTE_ORDER == BIG_ENDIAN + for (; data != end; data += sizeof(uint64_t)) { + m = U8TO64_LE(data); + SIP_2_ROUND(m, v0, v1, v2, v3); + } +#endif + +#ifdef HAVE_UINT64_T + last = (uint64_t)len << 56; +#define OR_BYTE(n) (last |= ((uint64_t) end[n]) << ((n) * 8)) +#else + last.hi = len << 24; + last.lo = 0; +#define OR_BYTE(n) do { \ + if (n >= 4) \ + last.hi |= ((uint32_t) end[n]) << ((n) >= 4 ? (n) * 8 - 32 : 0); \ + else \ + last.lo |= ((uint32_t) end[n]) << ((n) >= 4 ? 0 : (n) * 8); \ + } while (0) +#endif + + switch (len % sizeof(uint64_t)) { + case 7: + OR_BYTE(6); + case 6: + OR_BYTE(5); + case 5: + OR_BYTE(4); + case 4: +#if BYTE_ORDER == LITTLE_ENDIAN && UNALIGNED_WORD_ACCESS + #if HAVE_UINT64_T + last |= (uint64_t) ((uint32_t *) end)[0]; + #else + last.lo |= ((uint32_t *) end)[0]; + #endif + break; +#elif BYTE_ORDER == BIG_ENDIAN + OR_BYTE(3); +#endif + case 3: + OR_BYTE(2); + case 2: + OR_BYTE(1); + case 1: + OR_BYTE(0); + break; + case 0: + break; + } + + SIP_2_ROUND(last, v0, v1, v2, v3); + + XOR64_INT(v2, 0xff); + + SIP_COMPRESS(v0, v1, v2, v3); + SIP_COMPRESS(v0, v1, v2, v3); + SIP_COMPRESS(v0, v1, v2, v3); + SIP_COMPRESS(v0, v1, v2, v3); + + XOR64_TO(v0, v1); + XOR64_TO(v0, v2); + XOR64_TO(v0, v3); + return v0; +} diff --git a/siphash.h b/siphash.h new file mode 100644 index 0000000..3f39884 --- /dev/null +++ b/siphash.h @@ -0,0 +1,48 @@ +#ifndef SIPHASH_H +#define SIPHASH_H 1 +#include <stdlib.h> +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif + +#ifndef HAVE_UINT64_T +typedef struct { + uint32_t u32[2]; +} sip_uint64_t; +#define uint64_t sip_uint64_t +#else +typedef uint64_t sip_uint64_t; +#endif + +typedef struct { + int c; + int d; + uint64_t v[4]; + uint8_t buf[sizeof(uint64_t)]; + uint8_t buflen; + uint8_t msglen_byte; +} sip_state; + +typedef struct sip_interface_st sip_interface; + +typedef struct { + sip_state state[1]; + const sip_interface *methods; +} sip_hash; + +sip_hash *sip_hash_new(const uint8_t key[16], int c, int d); +sip_hash *sip_hash_init(sip_hash *h, const uint8_t key[16], int c, int d); +int sip_hash_update(sip_hash *h, const uint8_t *data, size_t len); +int sip_hash_final(sip_hash *h, uint8_t **digest, size_t *len); +int sip_hash_final_integer(sip_hash *h, uint64_t *digest); +int sip_hash_digest(sip_hash *h, const uint8_t *data, size_t data_len, uint8_t **digest, size_t *digest_len); +int sip_hash_digest_integer(sip_hash *h, const uint8_t *data, size_t data_len, uint64_t *digest); +void sip_hash_free(sip_hash *h); +void sip_hash_dump(sip_hash *h); + +uint64_t sip_hash24(const uint8_t key[16], const uint8_t *data, size_t len); + +#endif @@ -515,7 +515,7 @@ st_add_direct(st_table *table, st_data_t key, st_data_t value) st_index_t hash_val, bin_pos; if (table->entries_packed) { - int i; + st_index_t i; if (MORE_PACKABLE_P(table)) { i = table->num_entries++; table->bins[i*2] = (struct st_table_entry*)key; @@ -695,6 +695,45 @@ st_delete_safe(register st_table *table, register st_data_t *key, st_data_t *val return 0; } +int +st_shift(register st_table *table, register st_data_t *key, st_data_t *value) +{ + st_index_t hash_val; + st_table_entry **prev; + register st_table_entry *ptr; + + if (table->num_entries == 0) { + if (value != 0) *value = 0; + return 0; + } + + if (table->entries_packed) { + if (value != 0) *value = (st_data_t)table->bins[1]; + *key = (st_data_t)table->bins[0]; + table->num_entries--; + memmove(&table->bins[0], &table->bins[2], + sizeof(struct st_table_entry*) * 2*table->num_entries); + return 1; + } + + hash_val = do_hash_bin(table->head->key, table); + prev = &table->bins[hash_val]; + for (;(ptr = *prev) != 0; prev = &ptr->next) { + if (ptr == table->head) { + *prev = ptr->next; + REMOVE_ENTRY(table, ptr); + if (value != 0) *value = ptr->record; + *key = ptr->key; + free(ptr); + return 1; + } + } + + /* if hash is not consistent and need to be rehashed */ + if (value != 0) *value = 0; + return 0; +} + void st_cleanup_safe(st_table *table, st_data_t never) { @@ -182,6 +182,9 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str char padding; enum {LEFT, CHCASE, LOWER, UPPER, LOCALE_O, LOCALE_E}; #define BIT_OF(n) (1U<<(n)) +#ifdef MAILHEADER_EXT + int sign; +#endif /* various tables, useful in North America */ static const char days_l[][10] = { @@ -473,12 +476,16 @@ rb_strftime_with_timespec(char *s, size_t maxsize, const char *format, const str } if (off < 0) { off = -off; - *s++ = '-'; + sign = -1; } else { - *s++ = '+'; + sign = +1; } - i = snprintf(s, endp - s, (padding == ' ' ? "%*ld" : "%.*ld"), precision, off / 3600); + i = snprintf(s, endp - s, (padding == ' ' ? "%+*ld" : "%+.*ld"), + precision + 1, sign * (off / 3600)); if (i < 0) goto err; + if (sign < 0 && off < 3600) { + *(padding == ' ' ? s + i - 2 : s) = '-'; + } s += i; off = off % 3600; if (1 <= colons) @@ -2,7 +2,7 @@ string.c - - $Author: naruse $ + $Author: usa $ created at: Mon Aug 9 17:12:58 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -1909,15 +1909,12 @@ rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len, int str_encindex = ENCODING_GET(str); int res_encindex; int str_cr, res_cr; - int ptr_a8 = ptr_encindex == 0; str_cr = ENC_CODERANGE(str); if (str_encindex == ptr_encindex) { - if (str_cr == ENC_CODERANGE_UNKNOWN || - (ptr_a8 && str_cr != ENC_CODERANGE_7BIT)) { + if (str_cr == ENC_CODERANGE_UNKNOWN) ptr_cr = ENC_CODERANGE_UNKNOWN; - } else if (ptr_cr == ENC_CODERANGE_UNKNOWN) { ptr_cr = coderange_scan(ptr, len, rb_enc_from_index(ptr_encindex)); } @@ -2101,7 +2098,8 @@ rb_str_concat(VALUE str1, VALUE str2) if (enc == rb_usascii_encoding()) { /* US-ASCII automatically extended to ASCII-8BIT */ - char buf[1] = {(char)code}; + char buf[1]; + buf[0] = (char)code; if (code > 0xFF) { rb_raise(rb_eRangeError, "%u out of char range", code); } @@ -2161,12 +2159,6 @@ rb_str_prepend(VALUE str, VALUE str2) } st_index_t -rb_memhash(const void *ptr, long len) -{ - return st_hash(ptr, len, rb_hash_start((st_index_t)len)); -} - -st_index_t rb_str_hash(VALUE str) { int e = ENCODING_GET(str); @@ -4050,10 +4042,29 @@ str_byte_substr(VALUE str, long beg, long len) } else { str2 = rb_str_new5(str, p, len); - rb_enc_cr_str_copy_for_substr(str2, str); - OBJ_INFECT(str2, str); } + str_enc_copy(str2, str); + + if (RSTRING_LEN(str2) == 0) { + if (!rb_enc_asciicompat(STR_ENC_GET(str))) + ENC_CODERANGE_SET(str2, ENC_CODERANGE_VALID); + else + ENC_CODERANGE_SET(str2, ENC_CODERANGE_7BIT); + } + else { + switch (ENC_CODERANGE(str)) { + case ENC_CODERANGE_7BIT: + ENC_CODERANGE_SET(str2, ENC_CODERANGE_7BIT); + break; + default: + ENC_CODERANGE_SET(str2, ENC_CODERANGE_UNKNOWN); + break; + } + } + + OBJ_INFECT(str2, str); + return str2; } @@ -6784,6 +6795,7 @@ rb_str_crypt(VALUE str, VALUE salt) extern char *crypt(const char *, const char *); VALUE result; const char *s, *saltp; + char *res; #ifdef BROKEN_CRYPT char salt_8bit_clean[3]; #endif @@ -6803,7 +6815,11 @@ rb_str_crypt(VALUE str, VALUE salt) saltp = salt_8bit_clean; } #endif - result = rb_str_new2(crypt(s, saltp)); + res = crypt(s, saltp); + if (!res) { + rb_sys_fail("crypt"); + } + result = rb_str_new2(res); OBJ_INFECT(result, str); OBJ_INFECT(result, salt); return result; @@ -7496,7 +7512,7 @@ sym_to_sym(VALUE sym) } static VALUE -sym_call(VALUE args, VALUE sym, int argc, VALUE *argv) +sym_call(VALUE args, VALUE sym, int argc, VALUE *argv, VALUE passed_proc) { VALUE obj; @@ -7504,7 +7520,7 @@ sym_call(VALUE args, VALUE sym, int argc, VALUE *argv) rb_raise(rb_eArgError, "no receiver given"); } obj = argv[0]; - return rb_funcall_passing_block(obj, (ID)sym, argc - 1, argv + 1); + return rb_funcall_with_block(obj, (ID)sym, argc - 1, argv + 1, passed_proc); } /* diff --git a/template/id.h.tmpl b/template/id.h.tmpl index 3fa6a6d..3a254b8 100644 --- a/template/id.h.tmpl +++ b/template/id.h.tmpl @@ -4,7 +4,7 @@ id.h - - $Author: akr $ + $Author: usa $ created at: Sun Oct 19 21:12:51 2008 Copyright (C) 2007 Koichi Sasada @@ -98,6 +98,7 @@ enum ruby_method_ids { tGets, tSucc, tEach, + tProc, tLambda, tSend, t__send__, @@ -120,6 +121,7 @@ enum ruby_method_ids { TOKEN2ID(Gets), TOKEN2ID(Succ), TOKEN2ID(Each), + TOKEN2ID(Proc), TOKEN2ID(Lambda), TOKEN2ID(Send), TOKEN2ID(__send__), diff --git a/template/ruby.pc.in b/template/ruby.pc.in index 2189667..2d6716c 100644 --- a/template/ruby.pc.in +++ b/template/ruby.pc.in @@ -24,6 +24,13 @@ LIBRUBYARG=@LIBRUBYARG@ LIBS=@LIBS@ DLDFLAGS=@DLDFLAGS@ ruby=${bindir}/${RUBY_INSTALL_NAME}@EXEEXT@ +rubylibprefix=@rubylibprefix@ +rubylibdir=${rubylibprefix}/${ruby_version} +vendordir=${rubylibprefix}/vendor_ruby +sitedir=${rubylibprefix}/site_ruby +rubyarchdir=${rubylibdir}/${arch} +vendorarchdir=${vendordir}/${sitearch} +sitearchdir=${sitedir}/${sitearch} rubyhdrdir=@rubyhdrdir@ vendorhdrdir=@vendorhdrdir@ sitehdrdir=@sitehdrdir@ diff --git a/test/-ext-/test_add_suffix.rb b/test/-ext-/test_add_suffix.rb deleted file mode 100644 index 0520bae..0000000 --- a/test/-ext-/test_add_suffix.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'test/unit' -require_relative '../ruby/envutil' -require "-test-/add_suffix/bug" - -class Test_AddSuffix < Test::Unit::TestCase - Dir = "/dev/null/".freeze - Style_1 = (Dir+"foo").freeze - - def test_style_0 - assert_equal("a.x.y", Bug.add_suffix("a.x", ".y")) - end - - def test_style_1 - assert_equal(Style_1+".y", Bug.add_suffix(Style_1+".c", ".y")) - suffix = ".bak".freeze - assert_equal(Style_1+suffix, Bug.add_suffix(Style_1.dup, suffix)) - assert_equal(Style_1+suffix, Bug.add_suffix(Style_1+".bar", suffix)) - assert_equal(Style_1+".$$$", Bug.add_suffix(Style_1+suffix, suffix)) - assert_equal(Style_1+suffix, Bug.add_suffix(Style_1+".$$$", suffix)) - assert_equal(Style_1+".~~~", Bug.add_suffix(Style_1+".$$$", ".$$$")) - assert_equal(Dir+"makefile"+suffix, Bug.add_suffix(Dir+"makefile", suffix)) - end - - def test_style_2 - suffix = "~" - assert_equal(Style_1+"~", Bug.add_suffix(Style_1.dup, suffix)) - assert_equal(Style_1+".c~", Bug.add_suffix(Style_1+".c", suffix)) - assert_equal(Style_1+".c~~", Bug.add_suffix(Style_1+".c~", suffix)) - assert_equal(Style_1+"~.c~~", Bug.add_suffix(Style_1+".c~~", suffix)) - assert_equal(Style_1+"~~.c~~", Bug.add_suffix(Style_1+"~.c~~", suffix)) - assert_equal(Style_1+"~~~~~.cc~", Bug.add_suffix(Style_1+"~~~~~.ccc", suffix)) - assert_equal(Style_1+"~~~~~.$$$", Bug.add_suffix(Style_1+"~~~~~.c~~", suffix)) - assert_equal(Dir+"foo~.pas", Bug.add_suffix(Dir+"foo.pas", suffix)) - assert_equal(Dir+"makefile.~", Bug.add_suffix(Dir+"makefile", suffix)) - assert_equal(Dir+"longname.fi~", Bug.add_suffix(Dir+"longname.fil", suffix)) - assert_equal(Dir+"longnam~.fi~", Bug.add_suffix(Dir+"longname.fi~", suffix)) - assert_equal(Dir+"longnam~.$$$", Bug.add_suffix(Dir+"longnam~.fi~", suffix)) - end - - def test_style_3 - base = "a"*1000 - suffix = "-"+"b"*1000 - assert_equal(base+".~~~", Bug.add_suffix(base, suffix)) - assert_equal(base+".~~~", Bug.add_suffix(base+".$$$", suffix)) - assert_equal(base+".$$$", Bug.add_suffix(base+".~~~", suffix)) - end -end diff --git a/test/-ext-/win32/test_fd_setsize.rb b/test/-ext-/win32/test_fd_setsize.rb new file mode 100644 index 0000000..0881971 --- /dev/null +++ b/test/-ext-/win32/test_fd_setsize.rb @@ -0,0 +1,25 @@ +require 'test/unit' +require_relative '../../ruby/envutil' + +module Bug + module Win32 + class TestFdSetSize < Test::Unit::TestCase + def test_select_with_unmatched_fd_setsize + bug6532 = '[ruby-core:44588]' + assert_in_out_err([], <<-INPUT, %w(:ok), [], bug6532) + require '-test-/win32/fd_setsize' + Bug::Win32.test_select + p :ok + INPUT + end + + def test_fdset_with_unmatched_fd_setsize + bug6532 = '[ruby-core:44588]' + assert_in_out_err([], <<-INPUT, %w(:ok), [], bug6532) + require '-test-/win32/fd_setsize' + p :ok if Bug::Win32.test_fdset + INPUT + end + end + end +end if /mswin|mingw/ =~ RUBY_PLATFORM diff --git a/test/bigdecimal/test_bigdecimal.rb b/test/bigdecimal/test_bigdecimal.rb index bd0739c..055b0ff 100644 --- a/test/bigdecimal/test_bigdecimal.rb +++ b/test/bigdecimal/test_bigdecimal.rb @@ -558,6 +558,10 @@ class TestBigDecimal < Test::Unit::TestCase a, b = BigDecimal("0.11111").coerce(1.quo(3)) assert_equal(BigDecimal("0." + "3"*a.precs[0]), a) + + assert_nothing_raised(TypeError, '#7176') do + BigDecimal.new('1') + Rational(1) + end end def test_uplus @@ -593,6 +597,14 @@ class TestBigDecimal < Test::Unit::TestCase assert_equal(BigDecimal.new((2**100-1).to_s), x - 1) end + def test_sub_with_float + assert_kind_of(BigDecimal, BigDecimal.new("3") - 1.0) + end + + def test_sub_with_rational + assert_kind_of(BigDecimal, BigDecimal.new("3") - 1.quo(3)) + end + def test_mult x = BigDecimal.new((2**100).to_s) assert_equal(BigDecimal.new((2**100 * 3).to_s), (x * 3).to_i) @@ -601,6 +613,14 @@ class TestBigDecimal < Test::Unit::TestCase assert_equal(BigDecimal.new((2**200).to_s), (x * x).to_i) end + def test_mult_with_float + assert_kind_of(BigDecimal, BigDecimal.new("3") * 1.5) + end + + def test_mult_with_rational + assert_kind_of(BigDecimal, BigDecimal.new("3") * 1.quo(3)) + end + def test_div x = BigDecimal.new((2**100).to_s) assert_equal(BigDecimal.new((2**100 / 3).to_s), (x / 3).to_i) @@ -610,6 +630,14 @@ class TestBigDecimal < Test::Unit::TestCase assert_equal(-2, BigDecimal.new("2") / -1) end + def test_div_with_float + assert_kind_of(BigDecimal, BigDecimal.new("3") / 1.5) + end + + def test_div_with_rational + assert_kind_of(BigDecimal, BigDecimal.new("3") / 1.quo(3)) + end + def test_mod x = BigDecimal.new((2**100).to_s) assert_equal(1, x % 3) @@ -618,6 +646,14 @@ class TestBigDecimal < Test::Unit::TestCase assert_equal(-1, (-x) % -3) end + def test_mod_with_float + assert_kind_of(BigDecimal, BigDecimal.new("3") % 1.5) + end + + def test_mod_with_rational + assert_kind_of(BigDecimal, BigDecimal.new("3") % 1.quo(3)) + end + def test_remainder x = BigDecimal.new((2**100).to_s) assert_equal(1, x.remainder(3)) @@ -626,6 +662,14 @@ class TestBigDecimal < Test::Unit::TestCase assert_equal(-1, (-x).remainder(-3)) end + def test_remainder_with_float + assert_kind_of(BigDecimal, BigDecimal.new("3").remainder(1.5)) + end + + def test_remainder_with_rational + assert_kind_of(BigDecimal, BigDecimal.new("3").remainder(1.quo(3))) + end + def test_divmod x = BigDecimal.new((2**100).to_s) assert_equal([(x / 3).floor, 1], x.divmod(3)) @@ -1297,4 +1341,10 @@ class TestBigDecimal < Test::Unit::TestCase code = "exit(BigDecimal.new('10.0') == 10.0.to_d)" assert_ruby_status(%w[-rbigdecimal -rbigdecimal/util -rmathn -], code, bug6093) end + + def test_bug6406 + assert_in_out_err(%w[-rbigdecimal --disable-gems], <<-EOS, [], []) + Thread.current.keys.to_s + EOS + end end diff --git a/test/cgi/test_cgi_session.rb b/test/cgi/test_cgi_session.rb index f3b8e60..7fa7ad7 100644 --- a/test/cgi/test_cgi_session.rb +++ b/test/cgi/test_cgi_session.rb @@ -7,8 +7,7 @@ require 'tmpdir' class CGISessionTest < Test::Unit::TestCase def setup - @session_dir = File.join(File.dirname(__FILE__), 'session_dir') - FileUtils.mkdir_p @session_dir + @session_dir = Dir.mktmpdir(%w'session dir') end def teardown diff --git a/test/csv/test_features.rb b/test/csv/test_features.rb index 0da557e..8610949 100755 --- a/test/csv/test_features.rb +++ b/test/csv/test_features.rb @@ -10,6 +10,7 @@ require "zlib" require_relative "base" +require "tempfile" class TestCSV::Features < TestCSV extend DifferentOFS @@ -208,7 +209,9 @@ class TestCSV::Features < TestCSV end def test_gzip_writer_bug_fix - file = File.join(File.dirname(__FILE__), "temp.gz") + tempfile = Tempfile.new(%w"temp .gz") + tempfile.close + file = tempfile.path zipped = nil assert_nothing_raised(NoMethodError) do zipped = CSV.new(Zlib::GzipWriter.open(file)) @@ -220,7 +223,7 @@ class TestCSV::Features < TestCSV assert( Zlib::GzipReader.open(file) { |f| f.read }. include?($INPUT_RECORD_SEPARATOR), "@row_sep did not default" ) - File.unlink(file) + tempfile.close(true) end def test_inspect_is_smart_about_io_types @@ -230,11 +233,13 @@ class TestCSV::Features < TestCSV str = CSV.new($stderr).inspect assert(str.include?("io_type:$stderr"), "IO type not detected.") - path = File.join(File.dirname(__FILE__), "temp.csv") + tempfile = Tempfile.new(%w"temp .csv") + tempfile.close + path = tempfile.path File.open(path, "w") { |csv| csv << "one,two,three\n1,2,3\n" } str = CSV.open(path) { |csv| csv.inspect } assert(str.include?("io_type:File"), "IO type not detected.") - File.unlink(path) + tempfile.close(true) end def test_inspect_shows_key_attributes diff --git a/test/csv/test_interface.rb b/test/csv/test_interface.rb index 9cdbcec..73e6ca9 100755 --- a/test/csv/test_interface.rb +++ b/test/csv/test_interface.rb @@ -8,13 +8,16 @@ # under the terms of Ruby's license. require_relative "base" +require "tempfile" class TestCSV::Interface < TestCSV extend DifferentOFS def setup super - @path = File.join(File.dirname(__FILE__), "temp_test_data.csv") + @tempfile = Tempfile.new(%w"temp .csv") + @tempfile.close + @path = @tempfile.path File.open(@path, "wb") do |file| file << "1\t2\t3\r\n" @@ -25,7 +28,7 @@ class TestCSV::Interface < TestCSV end def teardown - File.unlink(@path) + @tempfile.close(true) super end @@ -112,7 +115,7 @@ class TestCSV::Interface < TestCSV assert_equal(nil, csv.shift) end end - + def test_enumerators_are_supported CSV.open(@path, col_sep: "\t", row_sep: "\r\n") do |csv| enum = csv.each diff --git a/test/csv/test_serialization.rb b/test/csv/test_serialization.rb index ba19b7a..dafe12b 100755 --- a/test/csv/test_serialization.rb +++ b/test/csv/test_serialization.rb @@ -8,6 +8,7 @@ # under the terms of Ruby's license. require_relative "base" +require "tempfile" # An example of how to provide custom CSV serialization. class Hash @@ -131,7 +132,9 @@ class TestCSV::Serialization < TestCSV def test_io test_class_dump - data_file = File.join(File.dirname(__FILE__), "serialization_test_data.csv") + tempfile = Tempfile.new(%w"serialization .csv") + tempfile.close + data_file = tempfile.path CSV.dump(@names, File.open(data_file, "wb")) assert(File.exist?(data_file)) @@ -145,7 +148,7 @@ class TestCSV::Serialization < TestCSV assert_equal(@names, CSV.load(File.open(data_file))) - File.unlink(data_file) + tempfile.close(true) end def test_custom_dump_and_load diff --git a/test/dl/test_func.rb b/test/dl/test_func.rb index 761ae43..4e69dea 100644 --- a/test/dl/test_func.rb +++ b/test/dl/test_func.rb @@ -9,6 +9,71 @@ module DL assert_equal 'strcpy', f.name end + def test_name_with_block + begin + cb = Function.new(CFunc.new(0, TYPE_INT, '<callback>qsort'), + [TYPE_VOIDP, TYPE_VOIDP]){|x,y| CPtr.new(x)[0] <=> CPtr.new(y)[0]} + assert_equal('<callback>qsort', cb.name) + ensure + cb.unbind if cb # max number of callbacks is limited to MAX_CALLBACK + end + end + + def test_bound + f = Function.new(CFunc.new(0, TYPE_INT, 'test'), [TYPE_INT, TYPE_INT]) + assert_equal false, f.bound? + begin + f.bind { |x,y| x + y } + assert_equal true, f.bound? + ensure + f.unbind # max number of callbacks is limited to MAX_CALLBACK + end + end + + def test_bound_for_callback_closure + begin + f = Function.new(CFunc.new(0, TYPE_INT, 'test'), + [TYPE_INT, TYPE_INT]) { |x,y| x + y } + assert_equal true, f.bound? + ensure + f.unbind if f # max number of callbacks is limited to MAX_CALLBACK + end + end + + def test_unbind + f = Function.new(CFunc.new(0, TYPE_INT, 'test'), [TYPE_INT, TYPE_INT]) + begin + f.bind { |x, y| x + y } + assert_nothing_raised { f.unbind } + assert_equal false, f.bound? + # unbind() after unbind() should not raise error + assert_nothing_raised { f.unbind } + ensure + f.unbind # max number of callbacks is limited to MAX_CALLBACK + end + end + + def test_unbind_normal_function + f = Function.new(CFunc.new(@libc['strcpy'], TYPE_VOIDP, 'strcpy'), + [TYPE_VOIDP, TYPE_VOIDP]) + assert_nothing_raised { f.unbind } + assert_equal false, f.bound? + # unbind() after unbind() should not raise error + assert_nothing_raised { f.unbind } + end + + def test_bind + f = Function.new(CFunc.new(0, TYPE_INT, 'test'), [TYPE_INT, TYPE_INT]) + begin + assert_nothing_raised { + f.bind { |x, y| x + y } + } + assert_equal 579, f.call(123, 456) + ensure + f.unbind # max number of callbacks is limited to MAX_CALLBACK + end + end + def test_to_i cfunc = CFunc.new(@libc['strcpy'], TYPE_VOIDP, 'strcpy') f = Function.new(cfunc, [TYPE_VOIDP, TYPE_VOIDP]) @@ -88,18 +153,22 @@ module DL end def test_qsort1() - cb = Function.new(CFunc.new(0, TYPE_INT, '<callback>qsort'), - [TYPE_VOIDP, TYPE_VOIDP]){|x,y| CPtr.new(x)[0] <=> CPtr.new(y)[0]} - qsort = Function.new(CFunc.new(@libc['qsort'], TYPE_VOID, 'qsort'), - [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP]) - buff = "9341" - qsort.call(buff, buff.size, 1, cb) - assert_equal("1349", buff) + begin + cb = Function.new(CFunc.new(0, TYPE_INT, '<callback>qsort'), + [TYPE_VOIDP, TYPE_VOIDP]){|x,y| CPtr.new(x)[0] <=> CPtr.new(y)[0]} + qsort = Function.new(CFunc.new(@libc['qsort'], TYPE_VOID, 'qsort'), + [TYPE_VOIDP, TYPE_INT, TYPE_INT, TYPE_VOIDP]) + buff = "9341" + qsort.call(buff, buff.size, 1, cb) + assert_equal("1349", buff) - bug4929 = '[ruby-core:37395]' - buff = "9341" - EnvUtil.under_gc_stress {qsort.call(buff, buff.size, 1, cb)} - assert_equal("1349", buff, bug4929) + bug4929 = '[ruby-core:37395]' + buff = "9341" + EnvUtil.under_gc_stress {qsort.call(buff, buff.size, 1, cb)} + assert_equal("1349", buff, bug4929) + ensure + cb.unbind if cb # max number of callbacks is limited to MAX_CALLBACK + end end def test_qsort2() diff --git a/test/drb/drbtest.rb b/test/drb/drbtest.rb index fe39a6e..b9285b5 100644 --- a/test/drb/drbtest.rb +++ b/test/drb/drbtest.rb @@ -11,7 +11,7 @@ class DRbService @@ruby += " -d" if $DEBUG def self.add_service_command(nm) dir = File.dirname(File.expand_path(__FILE__)) - DRb::ExtServManager.command[nm] = "#{@@ruby} \"#{dir}/#{nm}\"" + DRb::ExtServManager.command[nm] = [@@ruby, "#{dir}/#{nm}"] end %w(ut_drb.rb ut_array.rb ut_port.rb ut_large.rb ut_safe1.rb ut_eval.rb ut_eq.rb).each do |nm| @@ -65,12 +65,24 @@ end module DRbCore def setup - @ext = DRbService.ext_service('ut_drb.rb') + @service_name = 'ut_drb.rb' + @ext = DRbService.ext_service(@service_name) @there = @ext.front end def teardown - @ext.stop_service if @ext + @ext.stop_service if defined?(@ext) && @ext + DRbService.manager.unregist(@service_name) + signal = /mswin|mingw/ =~ RUBY_PLATFORM ? :INT : :TERM + Thread.list.each {|th| + if th.respond_to?(:pid) && th[:drb_service] == @service_name + begin + Process.kill signal, th.pid + rescue Errno::ESRCH + end + th.join + end + } end def test_00_DRbObject @@ -271,12 +283,24 @@ end module DRbAry def setup - @ext = DRbService.ext_service('ut_array.rb') + @service_name = 'ut_array.rb' + @ext = DRbService.ext_service(@service_name) @there = @ext.front end def teardown - @ext.stop_service if @ext + @ext.stop_service if defined?(@ext) && @ext + DRbService.manager.unregist(@service_name) + signal = /mswin|mingw/ =~ RUBY_PLATFORM ? :INT : :TERM + Thread.list.each {|th| + if th.respond_to?(:pid) && th[:drb_service] == @service_name + begin + Process.kill signal, th.pid + rescue Errno::ESRCH + end + th.join + end + } end def test_01 diff --git a/test/drb/test_drb.rb b/test/drb/test_drb.rb index 8ab00ec..dc9a47d 100644 --- a/test/drb/test_drb.rb +++ b/test/drb/test_drb.rb @@ -202,7 +202,8 @@ end class TestDRbSafe1 < TestDRbAry def setup - @ext = DRbService.ext_service('ut_safe1.rb') + @service_name = 'ut_safe1.rb' + @ext = DRbService.ext_service(@service_name) @there = @ext.front end end diff --git a/test/drb/test_drbssl.rb b/test/drb/test_drbssl.rb index 8f6c4f2..6322434 100644 --- a/test/drb/test_drbssl.rb +++ b/test/drb/test_drbssl.rb @@ -36,7 +36,8 @@ end class TestDRbSSLCore < Test::Unit::TestCase include DRbCore def setup - @ext = DRbSSLService.ext_service('ut_drb_drbssl.rb') + @service_name = 'ut_drb_drbssl.rb' + @ext = DRbSSLService.ext_service(@service_name) @there = @ext.front end @@ -53,7 +54,8 @@ end class TestDRbSSLAry < Test::Unit::TestCase include DRbAry def setup - @ext = DRbSSLService.ext_service('ut_array_drbssl.rb') + @service_name = 'ut_array_drbssl.rb' + @ext = DRbSSLService.ext_service(@service_name) @there = @ext.front end end diff --git a/test/drb/test_drbunix.rb b/test/drb/test_drbunix.rb index 5b93f52..1fba033 100644 --- a/test/drb/test_drbunix.rb +++ b/test/drb/test_drbunix.rb @@ -20,7 +20,8 @@ end class TestDRbUNIXCore < Test::Unit::TestCase include DRbCore def setup - @ext = DRbUNIXService.ext_service('ut_drb_drbunix.rb') + @service_name = 'ut_drb_drbunix.rb' + @ext = DRbUNIXService.ext_service(@service_name) @there = @ext.front end @@ -37,7 +38,8 @@ end class TestDRbUNIXAry < Test::Unit::TestCase include DRbAry def setup - @ext = DRbUNIXService.ext_service('ut_array_drbunix.rb') + @service_name = 'ut_array_drbunix.rb' + @ext = DRbUNIXService.ext_service(@service_name) @there = @ext.front end end diff --git a/test/etc/test_etc.rb b/test/etc/test_etc.rb index c4db71c..5bc8db4 100644 --- a/test/etc/test_etc.rb +++ b/test/etc/test_etc.rb @@ -28,11 +28,18 @@ class TestEtc < Test::Unit::TestCase end def test_getpwuid - passwd = {} - Etc.passwd {|s| passwd[s.uid] ||= s } - passwd.each_value do |s| - assert_equal(s, Etc.getpwuid(s.uid)) - assert_equal(s, Etc.getpwuid) if Process.euid == s.uid + # password database is not unique on UID, and which entry will be + # returned by getpwuid() is not specified. + passwd = Hash.new {[]} + # on MacOSX, same entries are returned from /etc/passwd and Open + # Directory. + Etc.passwd {|s| passwd[s.uid] |= [s]} + passwd.each_pair do |uid, s| + assert_include(s, Etc.getpwuid(uid)) + end + s = passwd[Process.euid] + unless s.empty? + assert_include(s, Etc.getpwuid) end end diff --git a/test/json/test_json.rb b/test/json/test_json.rb index eafd758..fa96130 100755 --- a/test/json/test_json.rb +++ b/test/json/test_json.rb @@ -4,6 +4,7 @@ require 'test/unit' require File.join(File.dirname(__FILE__), 'setup_variant') require 'stringio' +require 'tempfile' unless Array.method_defined?(:permutation) begin @@ -263,12 +264,12 @@ class TC_JSON < Test::Unit::TestCase def test_generation_of_core_subclasses_with_new_to_json obj = SubHash2["foo" => SubHash2["bar" => true]] obj_json = JSON(obj) - obj_again = JSON(obj_json) + obj_again = JSON.parse(obj_json, :create_additions => true) assert_kind_of SubHash2, obj_again assert_kind_of SubHash2, obj_again['foo'] assert obj_again['foo']['bar'] assert_equal obj, obj_again - assert_equal ["foo"], JSON(JSON(SubArray2["foo"])) + assert_equal ["foo"], JSON(JSON(SubArray2["foo"]), :create_additions => true) end def test_generation_of_core_subclasses_with_default_to_json @@ -414,6 +415,25 @@ EOT JSON.parse('{"foo":"bar", "baz":"quux"}', :symbolize_names => true)) end + def test_load + assert_equal @hash, JSON.load(@json) + tempfile = Tempfile.open('json') + tempfile.write @json + tempfile.rewind + assert_equal @hash, JSON.load(tempfile) + stringio = StringIO.new(@json) + stringio.rewind + assert_equal @hash, JSON.load(stringio) + assert_raise(NoMethodError) { JSON.load(nil) } + assert_raise(JSON::ParserError) {JSON.load('') } + end + + def test_load_with_options + small_hash = JSON("foo" => 'bar') + symbol_hash = { :foo => 'bar' } + assert_equal symbol_hash, JSON.load(small_hash, nil, :symbolize_names => true) + end + def test_load_dump too_deep = '[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]' assert_equal too_deep, JSON.dump(eval(too_deep)) diff --git a/test/json/test_json_addition.rb b/test/json/test_json_addition.rb index cc3820a..37dba6b 100755 --- a/test/json/test_json_addition.rb +++ b/test/json/test_json_addition.rb @@ -69,11 +69,19 @@ class TC_JSONAddition < Test::Unit::TestCase a = A.new(666) assert A.json_creatable? json = generate(a) - a_again = JSON.parse(json) + a_again = JSON.parse(json, :create_additions => true) assert_kind_of a.class, a_again assert_equal a, a_again end + def test_extended_json_default + a = A.new(666) + assert A.json_creatable? + json = generate(a) + a_hash = JSON.parse(json) + assert_kind_of Hash, a_hash + end + def test_extended_json_disabled a = A.new(666) assert A.json_creatable? @@ -100,7 +108,7 @@ class TC_JSONAddition < Test::Unit::TestCase c = C.new assert !C.json_creatable? json = generate(c) - assert_raises(ArgumentError, NameError) { JSON.parse(json) } + assert_raises(ArgumentError, NameError) { JSON.parse(json, :create_additions => true) } end def test_raw_strings @@ -118,7 +126,7 @@ class TC_JSONAddition < Test::Unit::TestCase assert_match(/\A\{.*\}\Z/, json) assert_match(/"json_class":"String"/, json) assert_match(/"raw":\[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255\]/, json) - raw_again = JSON.parse(json) + raw_again = JSON.parse(json, :create_additions => true) assert_equal raw, raw_again end @@ -126,17 +134,17 @@ class TC_JSONAddition < Test::Unit::TestCase def test_core t = Time.now - assert_equal t.inspect, JSON(JSON(t)).inspect + assert_equal t, JSON(JSON(t), :create_additions => true) d = Date.today - assert_equal d, JSON(JSON(d)) + assert_equal d, JSON(JSON(d), :create_additions => true) d = DateTime.civil(2007, 6, 14, 14, 57, 10, Rational(1, 12), 2299161) - assert_equal d, JSON(JSON(d)) - assert_equal 1..10, JSON(JSON(1..10)) - assert_equal 1...10, JSON(JSON(1...10)) - assert_equal "a".."c", JSON(JSON("a".."c")) - assert_equal "a"..."c", JSON(JSON("a"..."c")) + assert_equal d, JSON(JSON(d), :create_additions => true) + assert_equal 1..10, JSON(JSON(1..10), :create_additions => true) + assert_equal 1...10, JSON(JSON(1...10), :create_additions => true) + assert_equal "a".."c", JSON(JSON("a".."c"), :create_additions => true) + assert_equal "a"..."c", JSON(JSON("a"..."c"), :create_additions => true) s = MyJsonStruct.new 4711, 'foot' - assert_equal s, JSON(JSON(s)) + assert_equal s, JSON(JSON(s), :create_additions => true) struct = Struct.new :foo, :bar s = struct.new 4711, 'foot' assert_raises(JSONError) { JSON(s) } @@ -144,24 +152,24 @@ class TC_JSONAddition < Test::Unit::TestCase raise TypeError, "test me" rescue TypeError => e e_json = JSON.generate e - e_again = JSON e_json + e_again = JSON e_json, :create_additions => true assert_kind_of TypeError, e_again assert_equal e.message, e_again.message assert_equal e.backtrace, e_again.backtrace end - assert_equal(/foo/, JSON(JSON(/foo/))) - assert_equal(/foo/i, JSON(JSON(/foo/i))) + assert_equal(/foo/, JSON(JSON(/foo/), :create_additions => true)) + assert_equal(/foo/i, JSON(JSON(/foo/i), :create_additions => true)) end def test_utc_datetime now = Time.now - d = DateTime.parse(now.to_s) # usual case - assert_equal d, JSON.parse(d.to_json) + d = DateTime.parse(now.to_s, :create_additions => true) # usual case + assert_equal d, JSON.parse(d.to_json, :create_additions => true) d = DateTime.parse(now.utc.to_s) # of = 0 - assert_equal d, JSON.parse(d.to_json) + assert_equal d, JSON.parse(d.to_json, :create_additions => true) d = DateTime.civil(2008, 6, 17, 11, 48, 32, Rational(1,24)) - assert_equal d, JSON.parse(d.to_json) + assert_equal d, JSON.parse(d.to_json, :create_additions => true) d = DateTime.civil(2008, 6, 17, 11, 48, 32, Rational(12,24)) - assert_equal d, JSON.parse(d.to_json) + assert_equal d, JSON.parse(d.to_json, :create_additions => true) end end diff --git a/test/json/test_json_string_matching.rb b/test/json/test_json_string_matching.rb index df26a68..7335c0e 100644 --- a/test/json/test_json_string_matching.rb +++ b/test/json/test_json_string_matching.rb @@ -27,14 +27,13 @@ class TestJsonStringMatching < Test::Unit::TestCase t = TestTime.new t_json = [ t ].to_json assert_equal [ t ], - JSON.parse(t_json, - :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime }) + JSON.parse(t_json, :create_additions => true, + :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime }) assert_equal [ t.strftime('%FT%T%z') ], - JSON.parse(t_json, - :match_string => { /\A\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime }) + JSON.parse(t_json, :create_additions => true, + :match_string => { /\A\d{3}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime }) assert_equal [ t.strftime('%FT%T%z') ], JSON.parse(t_json, - :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\Z/ => TestTime }, - :create_additions => false) + :match_string => { /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}[+-]\d{4}\z/ => TestTime }) end end diff --git a/test/logger/test_logger.rb b/test/logger/test_logger.rb index 0736314..8fc02f8 100644 --- a/test/logger/test_logger.rb +++ b/test/logger/test_logger.rb @@ -21,13 +21,6 @@ class TestLogger < Test::Unit::TestCase def setup @logger = Logger.new(nil) - @filename = __FILE__ + ".#{$$}" - end - - def teardown - unless $DEBUG - File.unlink(@filename) if File.exist?(@filename) - end end class Log @@ -279,13 +272,14 @@ class TestLogDevice < Test::Unit::TestCase end def setup - @filename = __FILE__ + ".#{$$}" + @tempfile = Tempfile.new("logger") + @tempfile.close + @filename = @tempfile.path + File.unlink(@filename) end def teardown - unless $DEBUG - File.unlink(@filename) if File.exist?(@filename) - end + @tempfile.close(true) end def d(log, opt = {}) @@ -480,13 +474,14 @@ end class TestLoggerApplication < Test::Unit::TestCase def setup @app = Logger::Application.new('appname') - @filename = __FILE__ + ".#{$$}" + @tempfile = Tempfile.new("logger") + @tempfile.close + @filename = @tempfile.path + File.unlink(@filename) end def teardown - unless $DEBUG - File.unlink(@filename) if File.exist?(@filename) - end + @tempfile.close(true) end def test_initialize diff --git a/test/net/http/test_http.rb b/test/net/http/test_http.rb index a1e57dc..c302e10 100644 --- a/test/net/http/test_http.rb +++ b/test/net/http/test_http.rb @@ -1,4 +1,4 @@ -# $Id: test_http.rb 32192 2011-06-21 17:44:44Z nahi $ +# $Id: test_http.rb 37659 2012-11-15 06:15:17Z usa $ require 'test/unit' require 'net/http' @@ -426,7 +426,7 @@ end class TestNetHTTP_v1_2 < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, } @@ -444,7 +444,7 @@ end class TestNetHTTP_v1_2_chunked < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, 'chunked' => true, @@ -476,7 +476,7 @@ end class TestNetHTTPContinue < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10081, + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, 'chunked' => true, diff --git a/test/net/http/test_https.rb b/test/net/http/test_https.rb index 983ba7f..2f2c699 100644 --- a/test/net/http/test_https.rb +++ b/test/net/http/test_https.rb @@ -24,7 +24,7 @@ class TestNetHTTPS < Test::Unit::TestCase CONFIG = { 'host' => '127.0.0.1', - 'port' => 10082, # different from test_http.rb + 'port' => 0, 'proxy_host' => nil, 'proxy_port' => nil, 'ssl_enable' => true, diff --git a/test/net/http/utils.rb b/test/net/http/utils.rb index 50f616f..db01b18 100644 --- a/test/net/http/utils.rb +++ b/test/net/http/utils.rb @@ -19,7 +19,8 @@ module TestNetHTTPUtils end def config(key) - self.class::CONFIG[key] + @config ||= self.class::CONFIG + @config[key] end def logfile @@ -42,6 +43,7 @@ module TestNetHTTPUtils end def spawn_server + @config = self.class::CONFIG server_config = { :BindAddress => config('host'), :Port => config('port'), @@ -61,6 +63,7 @@ module TestNetHTTPUtils @server = WEBrick::HTTPServer.new(server_config) @server.mount('/', Servlet, config('chunked')) @server.start + @config['port'] = @server[:Port] if @config['port'] == 0 n_try_max = 5 begin TCPSocket.open(config('host'), config('port')).close diff --git a/test/net/imap/test_imap_response_parser.rb b/test/net/imap/test_imap_response_parser.rb index 6a5a117..1547a05 100644 --- a/test/net/imap/test_imap_response_parser.rb +++ b/test/net/imap/test_imap_response_parser.rb @@ -116,4 +116,29 @@ EOF * 1 FETCH (UID 92285 ) EOF end + + # [Bug #8281] + def test_acl + parser = Net::IMAP::ResponseParser.new + response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint) +* ACL "INBOX/share" "imshare2copy1366146467@xxxxxxxxxxxxxxxxxx.com" lrswickxteda +EOF + assert_equal("ACL", response.name) + assert_equal(1, response.data.length) + assert_equal("INBOX/share", response.data[0].mailbox) + assert_equal("imshare2copy1366146467@xxxxxxxxxxxxxxxxxx.com", + response.data[0].user) + assert_equal("lrswickxteda", response.data[0].rights) + end + + # [Bug #8415] + def test_capability + parser = Net::IMAP::ResponseParser.new + response = parser.parse("* CAPABILITY st11p00mm-iscream009 1Q49 XAPPLEPUSHSERVICE IMAP4 IMAP4rev1 SASL-IR AUTH=ATOKEN AUTH=PLAIN\r\n") + assert_equal("CAPABILITY", response.name) + assert_equal("AUTH=PLAIN", response.data.last) + response = parser.parse("* CAPABILITY st11p00mm-iscream009 1Q49 XAPPLEPUSHSERVICE IMAP4 IMAP4rev1 SASL-IR AUTH=ATOKEN AUTH=PLAIN \r\n") + assert_equal("CAPABILITY", response.name) + assert_equal("AUTH=PLAIN", response.data.last) + end end diff --git a/test/net/protocol/test_protocol.rb b/test/net/protocol/test_protocol.rb new file mode 100644 index 0000000..d8f816e --- /dev/null +++ b/test/net/protocol/test_protocol.rb @@ -0,0 +1,20 @@ +# coding: utf-8 +require "test/unit" +require "net/protocol" +require "stringio" + +class TestProtocol < Test::Unit::TestCase + def test_each_crlf_line + assert_output('', '') do + sio = StringIO.new("") + imio = Net::InternetMessageIO.new(sio) + assert_equal(23, imio.write_message("\u3042\r\u3044\n\u3046\r\n\u3048")) + assert_equal("\u3042\r\n\u3044\r\n\u3046\r\n\u3048\r\n.\r\n", sio.string) + + sio = StringIO.new("") + imio = Net::InternetMessageIO.new(sio) + assert_equal(8, imio.write_message("\u3042\r")) + assert_equal("\u3042\r\n.\r\n", sio.string) + end + end +end diff --git a/test/openssl/test_asn1.rb b/test/openssl/test_asn1.rb index 0932476..811fe38 100644 --- a/test/openssl/test_asn1.rb +++ b/test/openssl/test_asn1.rb @@ -198,6 +198,18 @@ class OpenSSL::TestASN1 < Test::Unit::TestCase encode_decode_test(OpenSSL::ASN1::Integer, [72, -127, -128, 128, -1, 0, 1, -(2**12345), 2**12345]) end + def test_encode_nil + m = OpenSSL::ASN1 + [ + m::Boolean, m::Integer, m::BitString, m::OctetString, + m::ObjectId, m::Enumerated, m::UTF8String, m::UTCTime, + m::GeneralizedTime, m::Sequence, m::Set + ].each do |klass| + #Primitives raise TypeError, Constructives NoMethodError + assert_raise(TypeError, NoMethodError) { klass.send(:new, nil).to_der } + end + end + def encode_decode_test(type, values) values.each do |v| assert_equal(v, OpenSSL::ASN1.decode(type.new(v).to_der).value) diff --git a/test/openssl/test_config.rb b/test/openssl/test_config.rb index 77f89b2..1ed455c 100644 --- a/test/openssl/test_config.rb +++ b/test/openssl/test_config.rb @@ -16,9 +16,10 @@ __EOD__ end def test_constants - assert(defined?(OpenSSL::Config::DEFAULT_CONFIG_FILE)) + config_file = OpenSSL::Config::DEFAULT_CONFIG_FILE + skip "DEFAULT_CONFIG_FILE may return a wrong path on your platforms. [Bug #6830]" unless File.readable?(config_file) assert_nothing_raised do - OpenSSL::Config.load(OpenSSL::Config::DEFAULT_CONFIG_FILE) + OpenSSL::Config.load(config_file) end end diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index 5d40a55..58493bf 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -351,6 +351,28 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase } end + def test_verify_certificate_identity + # creating NULL byte SAN certificate + ef = OpenSSL::X509::ExtensionFactory.new + cert = OpenSSL::X509::Certificate.new + cert.subject = OpenSSL::X509::Name.parse "/DC=some/DC=site/CN=Some Site" + ext = ef.create_ext('subjectAltName', 'DNS:placeholder,IP:192.168.7.1,IP:13::17') + ext_asn1 = OpenSSL::ASN1.decode(ext.to_der) + san_list_der = ext_asn1.value.reduce(nil) { |memo,val| val.tag == 4 ? val.value : memo } + san_list_asn1 = OpenSSL::ASN1.decode(san_list_der) + san_list_asn1.value[0].value = 'www.example.com\0.evil.com' + ext_asn1.value[1].value = san_list_asn1.to_der + real_ext = OpenSSL::X509::Extension.new ext_asn1 + cert.add_extension(real_ext) + + assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, 'www.example.com')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity(cert, 'www.example.com\0.evil.com')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '192.168.7.255')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity(cert, '192.168.7.1')) + assert_equal(false, OpenSSL::SSL.verify_certificate_identity(cert, '13::17')) + assert_equal(true, OpenSSL::SSL.verify_certificate_identity(cert, '13:0:0:0:0:0:0:17')) + end + def test_tlsext_hostname return unless OpenSSL::SSL::SSLSocket.instance_methods.include?(:hostname) @@ -438,6 +460,33 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase } end + def test_invalid_shutdown_by_gc + assert_nothing_raised { + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port| + 10.times { + sock = TCPSocket.new("127.0.0.1", port) + ssl = OpenSSL::SSL::SSLSocket.new(sock) + GC.start + ssl.connect + sock.close + } + } + } + end + + def test_close_after_socket_close + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true){|server, port| + sock = TCPSocket.new("127.0.0.1", port) + ssl = OpenSSL::SSL::SSLSocket.new(sock) + ssl.sync_close = true + ssl.connect + sock.close + assert_nothing_raised do + ssl.close + end + } + end + end end diff --git a/test/optparse/test_summary.rb b/test/optparse/test_summary.rb index 0c67d7f..d777173 100644 --- a/test/optparse/test_summary.rb +++ b/test/optparse/test_summary.rb @@ -18,4 +18,21 @@ class TestOptionParser::SummaryTest < TestOptionParser assert_match(/description 2/, s[1]) assert_match(/last-option/, s[-1]) end + + def test_banner + o = OptionParser.new("foo bar") + assert_equal("foo bar", o.banner) + end + + def test_banner_from_progname + o = OptionParser.new + o.program_name = "foobar" + assert_equal("Usage: foobar [options]\n", o.help) + end + + def test_summary + o = OptionParser.new("foo\nbar") + assert_equal("foo\nbar\n", o.to_s) + assert_equal(["foo\n", "bar"], o.to_a) + end end diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 8a8c0d9..61d288d 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -1,5 +1,3 @@ -#!/usr/bin/env ruby - require 'test/unit' require 'pathname' @@ -185,10 +183,8 @@ class TestPathname < Test::Unit::TestCase if DOSISH defassert(:del_trailing_separator, "a", "a\\") - require 'Win32API' - if Win32API.new('kernel32', 'GetACP', nil, 'L').call == 932 - defassert(:del_trailing_separator, "\225\\", "\225\\\\") # SJIS - end + defassert(:del_trailing_separator, "\225\\".force_encoding("cp932"), "\225\\\\".force_encoding("cp932")) + defassert(:del_trailing_separator, "\225".force_encoding("cp437"), "\225\\\\".force_encoding("cp437")) end def test_plus diff --git a/test/psych/test_alias_and_anchor.rb b/test/psych/test_alias_and_anchor.rb index 48771d6..aa4773b 100644 --- a/test/psych/test_alias_and_anchor.rb +++ b/test/psych/test_alias_and_anchor.rb @@ -1,5 +1,13 @@ require 'psych/helper' +class ObjectWithInstanceVariables + attr_accessor :var1, :var2 +end + +class SubStringWithInstanceVariables < String + attr_accessor :var1 +end + module Psych class TestAliasAndAnchor < TestCase def test_mri_compatibility @@ -14,6 +22,40 @@ EOYAML result.each {|el| assert_same(result[0], el) } end + def test_mri_compatibility_object_with_ivars + yaml = <<EOYAML +--- +- &id001 !ruby/object:ObjectWithInstanceVariables + var1: test1 + var2: test2 +- *id001 +- *id001 +EOYAML + + result = Psych.load yaml + result.each do |el| + assert_same(result[0], el) + assert_equal('test1', el.var1) + assert_equal('test2', el.var2) + end + end + + def test_mri_compatibility_substring_with_ivars + yaml = <<EOYAML +--- +- &id001 !str:SubStringWithInstanceVariables + str: test + "@var1": test +- *id001 +- *id001 +EOYAML + result = Psych.load yaml + result.each do |el| + assert_same(result[0], el) + assert_equal('test', el.var1) + end + end + def test_anchor_alias_round_trip o = Object.new original = [o,o,o] @@ -22,5 +64,33 @@ EOYAML result = Psych.load yaml result.each {|el| assert_same(result[0], el) } end + + def test_anchor_alias_round_trip_object_with_ivars + o = ObjectWithInstanceVariables.new + o.var1 = 'test1' + o.var2 = 'test2' + original = [o,o,o] + + yaml = Psych.dump original + result = Psych.load yaml + result.each do |el| + assert_same(result[0], el) + assert_equal('test1', el.var1) + assert_equal('test2', el.var2) + end + end + + def test_anchor_alias_round_trip_substring_with_ivars + o = SubStringWithInstanceVariables.new + o.var1 = 'test' + original = [o,o,o] + + yaml = Psych.dump original + result = Psych.load yaml + result.each do |el| + assert_same(result[0], el) + assert_equal('test', el.var1) + end + end end end diff --git a/test/psych/test_array.rb b/test/psych/test_array.rb index 9eedbb4..747fe95 100644 --- a/test/psych/test_array.rb +++ b/test/psych/test_array.rb @@ -14,6 +14,16 @@ module Psych @list = [{ :a => 'b' }, 'foo'] end + def test_another_subclass_with_attributes + y = Y.new.tap {|y| y.val = 1} + y << "foo" << "bar" + y = Psych.load Psych.dump y + + assert_equal %w{foo bar}, y + assert_equal Y, y.class + assert_equal 1, y.val + end + def test_subclass yaml = Psych.dump X.new assert_match X.name, yaml diff --git a/test/psych/test_omap.rb b/test/psych/test_omap.rb index 53f55f5..34df724 100644 --- a/test/psych/test_omap.rb +++ b/test/psych/test_omap.rb @@ -2,6 +2,13 @@ require 'psych/helper' module Psych class TestOmap < TestCase + def test_parse_as_map + o = Psych.load "--- !!omap\na: 1\nb: 2" + assert_kind_of Psych::Omap, o + assert_equal 1, o['a'] + assert_equal 2, o['b'] + end + def test_self_referential map = Psych::Omap.new map['foo'] = 'bar' diff --git a/test/psych/test_string.rb b/test/psych/test_string.rb index c7d5c60..77aefc6 100644 --- a/test/psych/test_string.rb +++ b/test/psych/test_string.rb @@ -9,6 +9,13 @@ module Psych attr_accessor :val end + def test_another_subclass_with_attributes + y = Psych.load Psych.dump Y.new("foo").tap {|y| y.val = 1} + assert_equal "foo", y + assert_equal Y, y.class + assert_equal 1, y.val + end + def test_backwards_with_syck x = Psych.load "--- !str:#{X.name} foo\n\n" assert_equal X, x.class diff --git a/test/rexml/test_comment.rb b/test/rexml/test_comment.rb new file mode 100644 index 0000000..ebe3eea --- /dev/null +++ b/test/rexml/test_comment.rb @@ -0,0 +1,25 @@ +require "test/unit/testcase" + +require 'rexml/document' + +module REXMLTest + class CommentTester < Test::Unit::TestCase + # Bug #5278 + def test_hyphen_end_line_in_doctype + xml = <<-XML +<?xml version="1.0"?> +<!DOCTYPE root [ +<!-- comment end with hyphen - + here --> +]> +<root/> + XML + document = REXML::Document.new(xml) + comments = document.doctype.children.find_all do |child| + child.is_a?(REXML::Comment) + end + assert_equal([" comment end with hyphen -\n here "], + comments.collect(&:to_s)) + end + end +end diff --git a/test/rexml/test_encoding.rb b/test/rexml/test_encoding.rb index e359914..8b93460 100644 --- a/test/rexml/test_encoding.rb +++ b/test/rexml/test_encoding.rb @@ -3,6 +3,7 @@ require "rexml_test_utils" require 'rexml/source' +require 'rexml/document' class EncodingTester < Test::Unit::TestCase include REXMLTestUtils diff --git a/test/rexml/test_entity.rb b/test/rexml/test_entity.rb index e6d6f29..5900fac 100644 --- a/test/rexml/test_entity.rb +++ b/test/rexml/test_entity.rb @@ -104,6 +104,24 @@ class EntityTester < Test::Unit::TestCase assert_equal source, out end + def test_entity_string_limit + template = '<!DOCTYPE bomb [ <!ENTITY a "^" > ]> <bomb>$</bomb>' + len = 5120 # 5k per entity + template.sub!(/\^/, "B" * len) + + # 10k is OK + entities = '&a;' * 2 # 5k entity * 2 = 10k + xmldoc = REXML::Document.new(template.sub(/\$/, entities)) + assert_equal(len * 2, xmldoc.root.text.bytesize) + + # above 10k explodes + entities = '&a;' * 3 # 5k entity * 2 = 15k + xmldoc = REXML::Document.new(template.sub(/\$/, entities)) + assert_raises(RuntimeError) do + xmldoc.root.text + end + end + def test_raw source = '<!DOCTYPE foo [ <!ENTITY ent "replace"> diff --git a/test/rinda/test_rinda.rb b/test/rinda/test_rinda.rb index 8154b46..e49a685 100644 --- a/test/rinda/test_rinda.rb +++ b/test/rinda/test_rinda.rb @@ -94,7 +94,7 @@ end class TupleSpace def sleep(n) - Time.sleep(n) + Kernel.sleep(n * 0.01) end end @@ -308,70 +308,35 @@ module TupleSpaceTestModule def test_core_03_notify notify1 = @ts.notify(nil, [:req, Integer]) - notify2 = @ts.notify(nil, {"message"=>String, "name"=>String}, 8) + notify2 = @ts.notify(nil, {"message"=>String, "name"=>String}) - @ts.write({"message"=>"first", "name"=>"3"}, 3) - @ts.write({"message"=>"second", "name"=>"1"}, 1) - @ts.write({"message"=>"third", "name"=>"0"}) - @ts.take({"message"=>"third", "name"=>"0"}) - - listener = Thread.new do - lv = 0 - n = 0 - notify1.each do |ev, tuple| - n += 1 - if ev == 'write' - lv = lv + 1 - elsif ev == 'take' - lv = lv - 1 - else - break - end - assert(lv >= 0) - assert_equal([:req, 2], tuple) - end - [lv, n] + 5.times do |n| + @ts.write([:req, 2]) end - taker = Thread.new(5) do |count| - s = 0 - count.times do - tuple = @ts.take([:req, Integer]) - assert_equal(2, tuple[1]) - s += tuple[1] - end - @ts.write([:ans, s]) - s + 5.times do + tuple = @ts.take([:req, Integer]) + assert_equal(2, tuple[1]) end - 5.times do |n| - @ts.write([:req, 2]) + 5.times do + assert_equal(['write', [:req, 2]], notify1.pop) + end + 5.times do + assert_equal(['take', [:req, 2]], notify1.pop) end + @ts.write({"message"=>"first", "name"=>"3"}) + @ts.write({"message"=>"second", "name"=>"1"}) + @ts.write({"message"=>"third", "name"=>"0"}) + @ts.take({"message"=>"third", "name"=>"0"}) @ts.take({"message"=>"first", "name"=>"3"}) - assert_equal(10, thread_join(taker)) - assert_equal([:ans, 10], @ts.take([:ans, 10])) - assert_equal([], @ts.read_all([nil, nil])) - - notify1.cancel - sleep(8) - - assert_equal([0, 11], thread_join(listener)) - - ary = [] - ary.push(["write", {"message"=>"first", "name"=>"3"}]) - ary.push(["write", {"message"=>"second", "name"=>"1"}]) - ary.push(["write", {"message"=>"third", "name"=>"0"}]) - ary.push(["take", {"message"=>"third", "name"=>"0"}]) - ary.push(["take", {"message"=>"first", "name"=>"3"}]) - ary.push(["delete", {"message"=>"second", "name"=>"1"}]) - ary.push(["close"]) - - notify2.each do |ev| - assert_equal(ary.shift, ev) - end - assert_equal([], ary) + assert_equal(["write", {"message"=>"first", "name"=>"3"}], notify2.pop) + assert_equal(["write", {"message"=>"second", "name"=>"1"}], notify2.pop) + assert_equal(["write", {"message"=>"third", "name"=>"0"}], notify2.pop) + assert_equal(["take", {"message"=>"third", "name"=>"0"}], notify2.pop) + assert_equal(["take", {"message"=>"first", "name"=>"3"}], notify2.pop) end def test_cancel_01 diff --git a/test/ripper/test_parser_events.rb b/test/ripper/test_parser_events.rb index e6968e1..af41d3e 100644 --- a/test/ripper/test_parser_events.rb +++ b/test/ripper/test_parser_events.rb @@ -592,8 +592,8 @@ class TestRipper::ParserEvents < Test::Unit::TestCase def test_magic_comment thru_magic_comment = false - parse('# -*- foo:bar -*-', :on_magic_comment) {thru_magic_comment = true} - assert_equal true, thru_magic_comment + parse('# -*- bug-5753: ruby-dev:44984 -*-', :on_magic_comment) {|*x|thru_magic_comment = x} + assert_equal [:on_magic_comment, "bug_5753", "ruby-dev:44984"], thru_magic_comment end def test_method_add_block diff --git a/test/ripper/test_scanner_events.rb b/test/ripper/test_scanner_events.rb index e792ca8..c92ec49 100644 --- a/test/ripper/test_scanner_events.rb +++ b/test/ripper/test_scanner_events.rb @@ -657,6 +657,13 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase scan('tstring_content', "<<EOS\nhere\ndoc \nEOS \n") assert_equal ["heredoc\n\tEOS \n"], scan('tstring_content', "<<-EOS\nheredoc\n\tEOS \n") + bug7255 = '[ruby-core:48703]' + assert_equal ["there\n""heredoc", "\n"], + scan('tstring_content', "<<""EOS\n""there\n""heredoc\#{foo}\nEOS"), + bug7255 + assert_equal ["there\n""heredoc", "\n"], + scan('tstring_content', "<<""EOS\n""there\n""heredoc\#@foo\nEOS"), + bug7255 end def test_heredoc_end diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb index bf6996f..1f82415 100644 --- a/test/ruby/test_argf.rb +++ b/test/ruby/test_argf.rb @@ -201,21 +201,14 @@ class TestArgf < Test::Unit::TestCase t = make_tempfile assert_in_out_err(["-", t.path], <<-INPUT) do |r, e| - ARGF.inplace_mode = '/\\\\' + ARGF.inplace_mode = '/\\\\:' while line = ARGF.gets puts line.chomp + '.new' end INPUT - if no_safe_rename - assert_equal([], e) - assert_equal([], r) - assert_equal("foo.new\nbar.new\nbaz.new\n", File.read(t.path)) - File.unlink(t.path + ".~~~") rescue nil - else - assert_match(/Can't rename .* to .*: .*. skipping file/, e.first) #' - assert_equal([], r) - assert_equal("foo\nbar\nbaz\n", File.read(t.path)) - end + assert_match(/Can't rename .* to .*: .*. skipping file/, e.first) #' + assert_equal([], r) + assert_equal("foo\nbar\nbaz\n", File.read(t.path)) end end @@ -763,4 +756,28 @@ class TestArgf < Test::Unit::TestCase bug5952 = '[ruby-dev:45160]' assert_ruby_status(["-e", "2.times {STDIN.tty?; readlines}"], "", bug5952) end + + def test_bytes + ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f| + print Marshal.dump(ARGF.bytes.to_a) + SRC + assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read)) + end + end + + def test_chars + ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f| + print [Marshal.dump(ARGF.chars.to_a)].pack('m') + SRC + assert_equal(["1", "\n", "2", "\n", "3", "\n", "4", "\n", "5", "\n", "6", "\n"], Marshal.load(f.read.unpack('m').first)) + end + end + + def test_codepoints + ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f| + print Marshal.dump(ARGF.codepoints.to_a) + SRC + assert_equal([49, 10, 50, 10, 51, 10, 52, 10, 53, 10, 54, 10], Marshal.load(f.read)) + end + end end diff --git a/test/ruby/test_basicinstructions.rb b/test/ruby/test_basicinstructions.rb index ff14e4a..7e57530 100644 --- a/test/ruby/test_basicinstructions.rb +++ b/test/ruby/test_basicinstructions.rb @@ -632,7 +632,7 @@ class TestBasicInstructions < Test::Unit::TestCase assert_equal 'i', $~[9] assert_equal 'x', $` assert_equal 'abcdefghi', $& - assert_equal 'y', $' + assert_equal "y", $' assert_equal 'i', $+ assert_equal 'a', $1 assert_equal 'b', $2 @@ -662,15 +662,20 @@ class TestBasicInstructions < Test::Unit::TestCase end def test_array_splat + feature1125 = '[ruby-core:21901]' + a = [] assert_equal [], [*a] assert_equal [1], [1, *a] + assert_not_same(a, [*a], feature1125) a = [2] assert_equal [2], [*a] assert_equal [1, 2], [1, *a] + assert_not_same(a, [*a], feature1125) a = [2, 3] assert_equal [2, 3], [*a] assert_equal [1, 2, 3], [1, *a] + assert_not_same(a, [*a], feature1125) a = nil assert_equal [], [*a] diff --git a/test/ruby/test_beginendblock.rb b/test/ruby/test_beginendblock.rb index 7e460b9..b590835 100644 --- a/test/ruby/test_beginendblock.rb +++ b/test/ruby/test_beginendblock.rb @@ -145,4 +145,17 @@ EOW assert_in_out_err(t.path, "", expected, [], "[ruby-core:35237]") t.close end + + def test_rescue_at_exit + bug5218 = '[ruby-core:43173][Bug #5218]' + cmd = [ + "raise 'X' rescue nil", + "nil", + "exit(42)", + ] + %w[at_exit END].each do |ex| + out, err, status = EnvUtil.invoke_ruby(cmd.map {|s|["-e", "#{ex} {#{s}}"]}.flatten, "", true, true) + assert_equal(["", "", 42], [out, err, status.exitstatus], "#{bug5218}: #{ex}") + end + end end diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb index 264c68b..582a7b2 100644 --- a/test/ruby/test_bignum.rb +++ b/test/ruby/test_bignum.rb @@ -246,6 +246,116 @@ class TestBignum < Test::Unit::TestCase assert_equal(3**7000, (3**5000) * (3**2000)) end + def test_mul_large_numbers + a = %w[ + 32580286268570032115047167942578356789222410206194227403993117616454027392 + 62501901985861926098797067562795526004375784403965882943322008991129440928 + 33855888840298794008677656280486901895499985197580043127115026675632969396 + 55040226415022070581995493731570435346323030715226718346725312551631168110 + 83966158581772380474470605428802018934282425947323171408377505151988776271 + 85865548747366001752375899635539662017095652855537225416899242508164949615 + 96848508410008685252121247181772953744297349638273854170932226446528911938 + 03430429031094465344063914822790537339912760237589085026016396616506014081 + 53557719631183538265614091691713138728177917059624255801026099255450058876 + 97412698978242128457751836011774504753020608663272925708049430557191193188 + 23212591809241860763625985763438355314593186083254640117460724730431447842 + 15432124830037389073162094304199742919767272162759192882136828372588787906 + 96027938532441670018954643423581446981760344524184231299785949158765352788 + 38452309862972527623669323263424418781899966895996672291193305401609553502 + 63893514163147729201340204483973131948541009975283778189609285614445485714 + 63843850089417416331356938086609682943037801440660232801570877143192251897 + 63026816485314923378023904237699794122181407920355722922555234540701118607 + 37971417665315821995516986204709574657462370947443531049033704997194647442 + 13711787319587466437795542850136751816475182349380345341647976135081955799 + 56787050815348701001765730577514591032367920292271016649813170789854524395 + 72571698998841196411826453893352760318867994518757872432266374568779920489 + 55597104558927387008506485038236352630863481679853742412042588244086070827 + 43705456833283086410967648483312972903432798923897357373793064381177468258 + 69131640408147806442422254638590386673344704147156793990832671592488742473 + 31524606724894164324227362735271650556732855509929890983919463699819116427 + ].join.to_i + b = %w[ + 31519454770031243652776765515030872050264386564379909299874378289835540661 + 99756262835346828114038365624177182230027040172583473561802565238817167503 + 85144159132462819032164726177606533272071955542237648482852154879445654746 + 25061253606344846225905712926863168413666058602449408307586532461776530803 + 56810626880722653177544008166119272373179841889454920521993413902672848145 + 77974951972342194855267960390195830413354782136431833731467699250684103370 + 98571305167189174270854698169136844578685346745340041520068176478277580590 + 43810457765638903028049263788987034217272442328962400931269515791911786205 + 15357047519615932249418012945178659435259428163356223753159488306813844040 + 93609959555018799309373542926110109744437994067754004273450659607204900586 + 28878103661124568217617766580438460505513654179249613168352070584906185237 + 34829991855182473813233425492094534396541544295119674419522772382981982574 + 64708442087451070125274285088681225122475041996116377707892328889948526913 + 82239084041628877737628853240361038273348062246951097300286513836140601495 + 63604611754185656404194406869925540477185577643853560887894081047256701731 + 66884554460428760857958761948461476977864005799494946578017758268987123749 + 85937011490156431231903167442071541493304390639100774497107347884381581049 + 85451663323551635322518839895028929788021096587229364219084708576998525298 + 39594168681411529110089531428721005176467479027585291807482375043729783455 + 35827667428080449919778142400266842990117940984804919512360370451936835708 + 76338722049621773169385978521438867493162717866679193103745711403152099047 + 27294943901673885707639094215339506973982546487889199083181789561917985023 + 82368442718514694400160954955539704757794969665555505203532944598698824542 + 00599461848630034847211204029842422678421808487300084850702007663003230882 + 16645745324467830796203354080471008809087072562876681588151822072260738003 + ].join.to_i + c = %w[ + 10269128594368631269792194698469828812223242061960065022209211719149714886 + 03494742299892841188636314745174778237781513956755034582435818316155459882 + 71422025990633195596790290038198841087091600598192959108790192789550336119 + 13849937951116346796903163312950010689963716629093190601532313463306463573 + 64436438673379454947908896258675634478867189655764364639888427350090856831 + 84369949421175534994092429682748078316130135651006102162888937624830856951 + 64818150356583421988135211585954838926347035741143424980258821170351244310 + 33072045488402539147707418016613224788469923473310249137422855065567940804 + 75231970365923936034328561426062696074717204901606475826224235014948198414 + 19979210494282212322919438926816203585575357874850252052656098969732107129 + 30639419804565653489687198910271702181183420960744232756057631336661646896 + 48734093497394719644969417287962767186599484579769717220518657324467736902 + 16947995288312851432262922140679347615046098863974141226499783975470926697 + 95970415188661518504275964397022973192968233221707696639386238428211541334 + 69925631385166494600401675904803418143232703594169525858261988389529181035 + 06048776134746377586210180203524132714354779486439559392942733781343640971 + 02430607931736785273011780813863748280091795277451796799961887248262211653 + 38966967509803488282644299584920109534552889962877144862747797551711984992 + 00726518175235286668236031649728858774545087668286506201943248842967749907 + 05345423019480534625965140632428736051632750698608916592720742728646191514 + 86268964807395494825321744802493138032936406889713953832376411900451422777 + 06372983421062172556566901346288286168790235741528630664513209619789835729 + 36999522461733403414326366959273556098219489572448083984779946889707480205 + 42459898495081687425132939473146331452400120169525968892769310016015870148 + 66821361032541586130017904207971120217385522074967066199941112154460026348 + 07223950375610474071278649031647998546085807777970592429037128484222394216 + 33776560239741740193444702279919018283324070210090106960567819910943036248 + 16660475627526085805165023447934326510232828674828006752369603151390527384 + 16810180735871644266726954590262010744712519045524839388305761859432443670 + 05188791334908140831469790180096209292338569623252372975043915954675335333 + 66614002146554533771788633057869340167604765688639181655208751680821446276 + 75871494160208888666798836473728725968253820774671626436794492530356258709 + 62318715778035246655925307167306434486713879511272648637608703497794724929 + 54912261106702913491290913962825303534484477936036071463820553314826894581 + 36951927032835690160443252405644718368516656317176848748544135126122940034 + 68454782581240953957381976073459570718038035358630417744490242611126043987 + 89191812971310096496208294948623403471433467614886863238916702384858514703 + 24327715474804343531844042107910755966152655912676456945146277848606406879 + 49724219295823540160221752189725460676360350860849986313532861445465771187 + 86822806696323658053947125253562001971534265078959827450518368635828010637 + 91977444206363529864361796188661941906329947840521598310396004328950804758 + 79728679236044038853668859284513594307352133390781441610395116807369310560 + 35193762565748328526426224069629084264376146174383444988110993194030351064 + 29660536743256949099972314033972121470913480844652490838985461134989129492 + 75577567064571716731774820127381261057956083604361635892088585967074514802 + 51958582645785905276289980534832170529946494815794770854644518463332458915 + 77572397432680871220602513555535017751714443325264019171753694163676670792 + 04353584782364068773777058727187323211012094819929720407636607815292764459 + 21851731257845562153822058534043916834839514338448582518847879059020959697 + 90538105704766415685100946308842788321400392381169436435078204622400475281 + ].join.to_i + assert_equal(c, a*b, '[ruby-core:48552]') + end + def test_divrem assert_equal(0, T32 / T64) end @@ -299,6 +409,9 @@ class TestBignum < Test::Unit::TestCase ### rational changes the behavior of Bignum#** #assert_raise(TypeError) { T32**"foo" } assert_raise(TypeError, ArgumentError) { T32**"foo" } + + feature3429 = '[ruby-core:30735]' + assert_instance_of(Bignum, (2 ** 7830457), feature3429) end def test_and @@ -378,7 +491,7 @@ class TestBignum < Test::Unit::TestCase assert_equal(true, (2**32).even?) end - def interrupt + def assert_interrupt time = Time.now start_flag = false end_flag = false @@ -387,14 +500,16 @@ class TestBignum < Test::Unit::TestCase yield end_flag = true end - sleep 1 + Thread.pass until start_flag thread.raise thread.join rescue nil - start_flag && !end_flag && Time.now - time < 10 + time = Time.now - time + assert_equal([true, false], [start_flag, end_flag]) + assert_operator(time, :<, 10) end def test_interrupt - assert(interrupt { (65536 ** 65536).to_s }) + assert_interrupt {(65536 ** 65536).to_s} end def test_too_big_to_s diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 55940a8..3d894da 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -258,4 +258,19 @@ class TestClass < Test::Unit::TestCase END assert_equal(42, PrivateClass.new.foo) end + + def test_cannot_reinitialize_class_with_initialize_copy # [ruby-core:50869] + assert_in_out_err([], <<-RUBY, ["Object"], []) + class Class + def initialize_copy(*); super; end + end + + class A; end + class B; end + + A.send(:initialize_copy, Class.new(B)) rescue nil + + p A.superclass + RUBY + end end diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb index 236fd99..b688cc4 100644 --- a/test/ruby/test_dir.rb +++ b/test/ruby/test_dir.rb @@ -171,6 +171,20 @@ class TestDir < Test::Unit::TestCase assert_raise(Encoding::CompatibilityError) {Dir.glob(m.new)} end + def test_glob_recursive + bug6977 = '[ruby-core:47418]' + Dir.chdir(@root) do + FileUtils.mkdir_p("a/b/c/d/e/f") + assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/e/f"), bug6977) + assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/d/e/f"), bug6977) + assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/d/e/f"), bug6977) + assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/b/c/d/e/f"), bug6977) + assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/?/e/f"), bug6977) + assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/**/d/e/f"), bug6977) + assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/**/d/e/f"), bug6977) + end + end + def test_foreach assert_equal(Dir.foreach(@root).to_a.sort, %w(. ..) + (?a..?z).to_a) end diff --git a/test/ruby/test_dir_m17n.rb b/test/ruby/test_dir_m17n.rb index b376393..2cf1c15 100644 --- a/test/ruby/test_dir_m17n.rb +++ b/test/ruby/test_dir_m17n.rb @@ -11,6 +11,33 @@ class TestDir_M17N < Test::Unit::TestCase } end + def create_and_check_raw_file_name(code, encoding) + with_tmpdir { |dir| + create_file_program = %Q[ + filename = #{code}.chr('UTF-8').force_encoding("#{encoding}") + File.open(filename, "w") {} + opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM + ents = Dir.entries(".", opts) + exit ents.include?(filename) + ] + assert_ruby_status(["-E#{encoding}"], create_file_program, nil, :chdir=>dir) + + test_file_program = %Q[ + filename = #{code}.chr('UTF-8').force_encoding("ASCII-8BIT") + opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM + ents = Dir.entries(".", opts) + expected_filename = #{code}.chr('UTF-8').encode(Encoding.find("filesystem")) rescue expected_filename = "?" + expected_filename = expected_filename.force_encoding("ASCII-8BIT") + result = ents.include?(filename) || (/mswin|mingw/ =~ RUBY_PLATFORM && ents.include?(expected_filename)) + if !result && /mswin|mingw/ =~ RUBY_PLATFORM + exit Dir.entries(".", {:encoding => Encoding.find("filesystem")}).include?(expected_filename) + end + exit result + ] + assert_ruby_status(%w[-EASCII-8BIT], test_file_program, nil, :chdir=>dir) + } + end + ## UTF-8 default_external, no default_internal def test_filename_extutf8 @@ -32,14 +59,14 @@ class TestDir_M17N < Test::Unit::TestCase File.open(filename, "w") {} opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM ents = Dir.entries(".", opts) - exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%FF")) + exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%FF")) EOS assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d) filename = "\xff".force_encoding("UTF-8") # invalid byte sequence as UTF-8 File.open(filename, "w") {} opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM ents = Dir.entries(".", opts) - exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%FF")) + exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%FF")) EOS } end unless /mswin|mingw/ =~ RUBY_PLATFORM @@ -153,7 +180,7 @@ class TestDir_M17N < Test::Unit::TestCase ents = Dir.entries(".", opts) ents.each {|e| e.force_encoding("ASCII-8BIT") } exit ents.include?(filename.force_encoding("ASCII-8BIT")) || - ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("ASCII-8BIT"))) + (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2".force_encoding("ASCII-8BIT"))) EOS } end @@ -165,35 +192,34 @@ class TestDir_M17N < Test::Unit::TestCase File.open(filename, "w") {} opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM ents = Dir.entries(".", opts) - exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("euc-jp"))) + exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2".force_encoding("euc-jp"))) EOS assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d) - filename = "\xA4\xA2" + filename = "\xA4\xA2".force_encoding('ASCII-8BIT') + win_expected_filename = filename.encode(Encoding.find("filesystem"), "euc-jp") rescue "?" opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM ents = Dir.entries(".", opts) - exit ents.include?(filename) || - ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("ASCII-8BIT"))) || - ((RUBY_PLATFORM =~ /mswin|mingw/) != nil && ents.include?("\x82\xA0".force_encoding("ASCII-8BIT"))) + result = ents.include?(filename) || + (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2".force_encoding("ASCII-8BIT"))) || + (/mswin|mingw/ =~ RUBY_PLATFORM && ents.include?(win_expected_filename.force_encoding("ASCII-8BIT"))) + if !result && /mswin|mingw/ =~ RUBY_PLATFORM + exit Dir.entries(".", {:encoding => Encoding.find("filesystem")}).include?(win_expected_filename) + end + exit result EOS } end - def test_filename_utf8_raw_name - with_tmpdir {|d| - assert_ruby_status(%w[-EUTF-8], <<-'EOS', nil, :chdir=>d) - filename = "\u3042".force_encoding("utf-8") - File.open(filename, "w") {} - opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM - ents = Dir.entries(".", opts) - exit ents.include?(filename) - EOS - assert_ruby_status(%w[-EASCII-8BIT], <<-'EOS', nil, :chdir=>d) - filename = "\u3042".force_encoding("ASCII-8BIT") - opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM - ents = Dir.entries(".", opts) - exit ents.include?(filename) || ((RUBY_PLATFORM =~ /mswin|mingw/) != nil && ents.include?("\x82\xA0".force_encoding("ASCII-8BIT"))) - EOS - } + def test_filename_utf8_raw_jp_name + create_and_check_raw_file_name(0x3042, "UTF-8") + end + + def test_filename_utf8_raw_windows_1251_name + create_and_check_raw_file_name(0x0424, "UTF-8") + end + + def test_filename_utf8_raw_windows_1252_name + create_and_check_raw_file_name(0x00c6, "UTF-8") end def test_filename_ext_euc_jp_and_int_utf_8 @@ -203,13 +229,13 @@ class TestDir_M17N < Test::Unit::TestCase File.open(filename, "w") {} opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM ents = Dir.entries(".", opts) - exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2".force_encoding("euc-jp"))) + exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2".force_encoding("euc-jp"))) EOS assert_ruby_status(%w[-EEUC-JP:UTF-8], <<-'EOS', nil, :chdir=>d) filename = "\u3042" opts = {:encoding => Encoding.default_external} if /mswin|mingw/ =~ RUBY_PLATFORM ents = Dir.entries(".", opts) - exit ents.include?(filename) || ((RUBY_PLATFORM =~ /darwin/) != nil && ents.include?("%A4%A2")) + exit ents.include?(filename) || (/darwin/ =~ RUBY_PLATFORM && ents.include?("%A4%A2")) EOS } end diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index 080d027..f667d73 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -1,4 +1,5 @@ require 'test/unit' +require 'envutil' class TestEncodingConverter < Test::Unit::TestCase def check_ec(edst, esrc, eres, dst, src, ec, off, len, opts=nil) @@ -908,4 +909,23 @@ class TestEncodingConverter < Test::Unit::TestCase ec2 = Encoding::Converter.new("", "", newline: :universal) assert_equal(ec1, ec2) end + + def test_default_external + cmd = <<EOS + Encoding.default_external = ext = ARGV[0] + Encoding.default_internal = int ='utf-8' + begin + Encoding::Converter.new(ext, int) + ensure + Marshal.dump($!, STDOUT) + STDOUT.flush + end +EOS + Encoding.list.grep(->(enc) {/^ISO-8859-\d(?:[0-5])?\z/i =~ enc.name}) do |enc| + error = IO.popen([EnvUtil.rubybin, "-e", cmd, enc.name]) do |child| + Marshal.load(child) + end + assert_nil(error) + end + end end diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index b410b70..281dc70 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -92,7 +92,16 @@ class TestException < Test::Unit::TestCase end false }) + end + def test_catch_throw_in_require + bug7185 = '[ruby-dev:46234]' + t = Tempfile.open(["dep", ".rb"]) + t.puts("throw :extdep, 42") + t.close + assert_equal(42, catch(:extdep) {require t.path}, bug7185) + ensure + t.close! if t end def test_else @@ -333,4 +342,54 @@ end.join load(t.path) end end + + def test_to_s_taintness_propagation + for exc in [Exception, NameError] + m = "abcdefg" + e = exc.new(m) + e.taint + s = e.to_s + assert_equal(false, m.tainted?, + "#{exc}#to_s should not propagate taintness") + assert_equal(false, s.tainted?, + "#{exc}#to_s should not propagate taintness") + end + + o = Object.new + def o.to_str + "foo" + end + o.taint + e = NameError.new(o) + s = e.to_s + assert_equal(false, s.tainted?) + end + + def test_exception_to_s_should_not_propagate_untrustedness + favorite_lang = "Ruby" + + for exc in [Exception, NameError] + assert_raise(SecurityError) do + lambda { + $SAFE = 4 + exc.new(favorite_lang).to_s + favorite_lang.replace("Python") + }.call + end + end + + assert_raise(SecurityError) do + lambda { + $SAFE = 4 + o = Object.new + o.singleton_class.send(:define_method, :to_str) { + favorite_lang + } + NameError.new(o).to_s + favorite_lang.replace("Python") + }.call + end + + assert_equal("Ruby", favorite_lang) + end end diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index 765458c..b888233 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -37,6 +37,57 @@ class TestFile < Test::Unit::TestCase include TestEOF::Seek + def test_empty_file_bom + bug6487 = '[ruby-core:45203]' + f = Tempfile.new(__method__.to_s) + f.close + assert File.exist? f.path + assert_nothing_raised(bug6487) {File.read(f.path, mode: 'r:utf-8')} + assert_nothing_raised(bug6487) {File.read(f.path, mode: 'r:bom|utf-8')} + f.close(true) + end + + def assert_bom(bytes, name) + bug6487 = '[ruby-core:45203]' + + f = Tempfile.new(name.to_s) + f.sync = true + expected = "" + result = nil + bytes[0...-1].each do |x| + f.write x + f.write ' ' + f.pos -= 1 + expected << x + assert_nothing_raised(bug6487) {result = File.read(f.path, mode: 'rb:bom|utf-8')} + assert_equal("#{expected} ".force_encoding("utf-8"), result) + end + f.write bytes[-1] + assert_nothing_raised(bug6487) {result = File.read(f.path, mode: 'rb:bom|utf-8')} + assert_equal '', result, "valid bom" + f.close(true) + end + + def test_bom_8 + assert_bom(["\xEF", "\xBB", "\xBF"], __method__) + end + + def test_bom_16be + assert_bom(["\xFE", "\xFF"], __method__) + end + + def test_bom_16le + assert_bom(["\xFF", "\xFE"], __method__) + end + + def test_bom_32be + assert_bom(["\0", "\0", "\xFE", "\xFF"], __method__) + end + + def test_bom_32le + assert_bom(["\xFF\xFE\0", "\0"], __method__) + end + def test_truncate_wbuf f = Tempfile.new("test-truncate") f.print "abc" @@ -181,6 +232,26 @@ class TestFile < Test::Unit::TestCase } end + def test_utime + bug6385 = '[ruby-core:44776]' + + mod_time_contents = Time.at 1306527039 + + file = Tempfile.new("utime") + file.close + path = file.path + + File.utime(File.atime(path), mod_time_contents, path) + stats = File.stat(path) + + file.open + file_mtime = file.mtime + file.close(true) + + assert_equal(mod_time_contents, file_mtime, bug6385) + assert_equal(mod_time_contents, stats.mtime, bug6385) + end + def test_chmod_m17n bug5671 = '[ruby-dev:44898]' Dir.mktmpdir('test-file-chmod-m17n-') do |tmpdir| @@ -189,4 +260,14 @@ class TestFile < Test::Unit::TestCase assert_equal(File.chmod(0666, file), 1, bug5671) end end + + def test_open_nul + Dir.mktmpdir(__method__.to_s) do |tmpdir| + path = File.join(tmpdir, "foo") + assert_raise(ArgumentError) do + open(path + "\0bar", "w") {} + end + refute File.exist?(path) + end + end end diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb index c10b05a..df7140f 100644 --- a/test/ruby/test_file_exhaustive.rb +++ b/test/ruby/test_file_exhaustive.rb @@ -1,8 +1,11 @@ +# -*- coding: us-ascii -*- require "test/unit" require "fileutils" require "tmpdir" class TestFileExhaustive < Test::Unit::TestCase + DRIVE = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i] + def assert_incompatible_encoding d = "\u{3042}\u{3044}".encode("utf-16le") assert_raise(Encoding::CompatibilityError) {yield d} @@ -12,6 +15,7 @@ class TestFileExhaustive < Test::Unit::TestCase def setup @dir = Dir.mktmpdir("rubytest-file") + @rootdir = "#{DRIVE}/" File.chown(-1, Process.gid, @dir) @file = make_tmp_filename("file") @zerofile = make_tmp_filename("zerofile") @@ -400,20 +404,31 @@ class TestFileExhaustive < Test::Unit::TestCase assert_match(/\Ac:\//i, File.expand_path('c:foo', 'd:/bar')) assert_match(%r'\Ac:/bar/foo\z'i, File.expand_path('c:foo', 'c:/bar')) end - if drive = Dir.pwd[%r'\A(?:[a-z]:|//[^/]+/[^/]+)'i] + if DRIVE assert_match(%r"\Az:/foo\z"i, File.expand_path('/foo', "z:/bar")) assert_match(%r"\A//host/share/foo\z"i, File.expand_path('/foo', "//host/share/bar")) - assert_match(%r"\A#{drive}/foo\z"i, File.expand_path('/foo')) + assert_match(%r"\A#{DRIVE}/foo\z"i, File.expand_path('/foo')) else assert_equal("/foo", File.expand_path('/foo')) end + end + + UnknownUserHome = "~foo_bar_baz_unknown_user_wahaha".freeze + + def test_expand_path_home assert_kind_of(String, File.expand_path("~")) if ENV["HOME"] - assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha") } - assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha", "/") } + assert_raise(ArgumentError) { File.expand_path(UnknownUserHome) } + assert_raise(ArgumentError) { File.expand_path(UnknownUserHome, "/") } begin bug3630 = '[ruby-core:31537]' home = ENV["HOME"] + home_drive = ENV["HOMEDRIVE"] + home_path = ENV["HOMEPATH"] + user_profile = ENV["USERPROFILE"] ENV["HOME"] = nil + ENV["HOMEDRIVE"] = nil + ENV["HOMEPATH"] = nil + ENV["USERPROFILE"] = nil assert_raise(ArgumentError) { File.expand_path("~") } ENV["HOME"] = "~" assert_raise(ArgumentError, bug3630) { File.expand_path("~") } @@ -421,8 +436,213 @@ class TestFileExhaustive < Test::Unit::TestCase assert_raise(ArgumentError, bug3630) { File.expand_path("~") } ensure ENV["HOME"] = home + ENV["HOMEDRIVE"] = home_drive + ENV["HOMEPATH"] = home_path + ENV["USERPROFILE"] = user_profile + end + end + + def test_expand_path_home_dir_string + home = ENV["HOME"] + new_home = "#{DRIVE}/UserHome" + ENV["HOME"] = new_home + bug8034 = "[ruby-core:53168]" + + assert_equal File.join(new_home, "foo"), File.expand_path("foo", "~"), bug8034 + assert_equal File.join(new_home, "bar", "foo"), File.expand_path("foo", "~/bar"), bug8034 + + assert_raise(ArgumentError) { File.expand_path(".", UnknownUserHome) } + assert_nothing_raised(ArgumentError) { File.expand_path("#{DRIVE}/", UnknownUserHome) } + ensure + ENV["HOME"] = home + end + + def test_expand_path_remove_trailing_alternative_data + assert_equal File.join(@rootdir, "aaa"), File.expand_path("#{@rootdir}/aaa::$DATA") + assert_equal File.join(@rootdir, "aa:a"), File.expand_path("#{@rootdir}/aa:a:$DATA") + assert_equal File.join(@rootdir, "aaa:$DATA"), File.expand_path("#{@rootdir}/aaa:$DATA") + end if DRIVE + + def test_expand_path_resolve_empty_string_current_directory + assert_equal(Dir.pwd, File.expand_path("")) + end + + def test_expand_path_resolve_dot_current_directory + assert_equal(Dir.pwd, File.expand_path(".")) + end + + def test_expand_path_resolve_file_name_relative_current_directory + assert_equal(File.join(Dir.pwd, "foo"), File.expand_path("foo")) + end + + def test_ignore_nil_dir_string + assert_equal(File.join(Dir.pwd, "foo"), File.expand_path("foo", nil)) + end + + def test_expand_path_resolve_file_name_and_dir_string_relative + assert_equal(File.join(Dir.pwd, "bar", "foo"), + File.expand_path("foo", "bar")) + end + + def test_expand_path_cleanup_dots_file_name + bug = "[ruby-talk:18512]" + + assert_equal(File.join(Dir.pwd, ".a"), File.expand_path(".a"), bug) + assert_equal(File.join(Dir.pwd, "..a"), File.expand_path("..a"), bug) + + if DRIVE + # cleanup dots only on Windows + assert_equal(File.join(Dir.pwd, "a"), File.expand_path("a."), bug) + skip "FIXME" + assert_equal(File.join(Dir.pwd, "a"), File.expand_path("a.."), bug) + else + assert_equal(File.join(Dir.pwd, "a."), File.expand_path("a."), bug) + assert_equal(File.join(Dir.pwd, "a.."), File.expand_path("a.."), bug) + end + end + + def test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_a_complete_path + assert_equal(@dir, File.expand_path("", "#{@dir}")) + assert_equal(File.join(@dir, "a"), File.expand_path("a", "#{@dir}")) + assert_equal(File.join(@dir, "a"), File.expand_path("../a", "#{@dir}/xxx")) + assert_equal(@rootdir, File.expand_path(".", "#{@rootdir}")) + end + + def test_expand_path_ignores_supplied_dir_if_path_contains_a_drive_letter + assert_equal(@rootdir, File.expand_path(@rootdir, "D:/")) + end if DRIVE + + def test_expand_path_removes_trailing_slashes_from_absolute_path + assert_equal(File.join(@rootdir, "foo"), File.expand_path("#{@rootdir}foo/")) + assert_equal(File.join(@rootdir, "foo.rb"), File.expand_path("#{@rootdir}foo.rb/")) + end + + def test_expand_path_removes_trailing_spaces_from_absolute_path + assert_equal(File.join(@rootdir, "a"), File.expand_path("#{@rootdir}a ")) + end if DRIVE + + def test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_dir_s_drive + assert_match(%r"\Az:/foo\z"i, File.expand_path('/foo', "z:/bar")) + end if DRIVE + + def test_expand_path_converts_a_pathname_which_starts_with_a_slash_and_unc_pathname + assert_equal("//foo", File.expand_path('//foo', "//bar")) + assert_equal("//bar/foo", File.expand_path('/foo', "//bar")) + assert_equal("//foo", File.expand_path('//foo', "/bar")) + end if DRIVE + + def test_expand_path_converts_a_dot_with_unc_dir + assert_equal("//", File.expand_path('.', "//")) + end + + def test_expand_path_preserves_unc_path_root + assert_equal("//", File.expand_path("//")) + assert_equal("//", File.expand_path("//.")) + assert_equal("//", File.expand_path("//..")) + end + + def test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_host_share + assert_match(%r"\A//host/share/foo\z"i, File.expand_path('/foo', "//host/share/bar")) + end if DRIVE + + def test_expand_path_converts_a_pathname_which_starts_with_a_slash_using_a_current_drive + assert_match(%r"\A#{DRIVE}/foo\z"i, File.expand_path('/foo')) + end + + def test_expand_path_returns_tainted_strings_or_not + assert_equal(true, File.expand_path('foo').tainted?) + assert_equal(true, File.expand_path('foo'.taint).tainted?) + assert_equal(true, File.expand_path('/foo'.taint).tainted?) + assert_equal(true, File.expand_path('foo', 'bar').tainted?) + assert_equal(true, File.expand_path('foo', '/bar'.taint).tainted?) + assert_equal(true, File.expand_path('foo'.taint, '/bar').tainted?) + assert_equal(true, File.expand_path('~').tainted?) if ENV["HOME"] + + if DRIVE + assert_equal(true, File.expand_path('/foo').tainted?) + assert_equal(false, File.expand_path('//foo').tainted?) + assert_equal(true, File.expand_path('C:/foo'.taint).tainted?) + assert_equal(false, File.expand_path('C:/foo').tainted?) + assert_equal(true, File.expand_path('foo', '/bar').tainted?) + assert_equal(true, File.expand_path('foo', 'C:/bar'.taint).tainted?) + assert_equal(true, File.expand_path('foo'.taint, 'C:/bar').tainted?) + assert_equal(false, File.expand_path('foo', 'C:/bar').tainted?) + assert_equal(false, File.expand_path('C:/foo/../bar').tainted?) + assert_equal(false, File.expand_path('foo', '//bar').tainted?) + else + assert_equal(false, File.expand_path('/foo').tainted?) + assert_equal(false, File.expand_path('foo', '/bar').tainted?) end - assert_incompatible_encoding {|d| File.expand_path(d)} + end + + def test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_home_as_base + old_home = ENV["HOME"] + home = ENV["HOME"] = "#{DRIVE}/UserHome" + assert_equal(home, File.expand_path("~")) + assert_equal(home, File.expand_path("~", "C:/FooBar")) + assert_equal(File.join(home, "a"), File.expand_path("~/a", "C:/FooBar")) + ensure + ENV["HOME"] = old_home + end + + def test_expand_path_converts_a_pathname_to_an_absolute_pathname_using_unc_home + old_home = ENV["HOME"] + unc_home = ENV["HOME"] = "//UserHome" + assert_equal(unc_home, File.expand_path("~")) + ensure + ENV["HOME"] = old_home + end if DRIVE + + def test_expand_path_does_not_modify_a_home_string_argument + old_home = ENV["HOME"] + home = ENV["HOME"] = "#{DRIVE}/UserHome" + str = "~/a" + assert_equal("#{home}/a", File.expand_path(str)) + assert_equal("~/a", str) + ensure + ENV["HOME"] = old_home + end + + def test_expand_path_raises_argument_error_for_any_supplied_username + bug = '[ruby-core:39597]' + assert_raise(ArgumentError, bug) { File.expand_path("~anything") } + end if DRIVE + + def test_expand_path_raises_a_type_error_if_not_passed_a_string_type + assert_raise(TypeError) { File.expand_path(1) } + assert_raise(TypeError) { File.expand_path(nil) } + assert_raise(TypeError) { File.expand_path(true) } + end + + def test_expand_path_expands_dot_dir + assert_equal("#{DRIVE}/dir", File.expand_path("#{DRIVE}/./dir")) + end + + def test_expand_path_does_not_expand_wildcards + assert_equal("#{DRIVE}/*", File.expand_path("./*", "#{DRIVE}/")) + assert_equal("#{Dir.pwd}/*", File.expand_path("./*", Dir.pwd)) + assert_equal("#{DRIVE}/?", File.expand_path("./?", "#{DRIVE}/")) + assert_equal("#{Dir.pwd}/?", File.expand_path("./?", Dir.pwd)) + end if DRIVE + + def test_expand_path_does_not_modify_the_string_argument + str = "./a/b/../c" + assert_equal("#{Dir.pwd}/a/c", File.expand_path(str, Dir.pwd)) + assert_equal("./a/b/../c", str) + end + + def test_expand_path_returns_a_string_when_passed_a_string_subclass + sub = Class.new(String) + str = sub.new "./a/b/../c" + path = File.expand_path(str, Dir.pwd) + assert_equal("#{Dir.pwd}/a/c", path) + assert_instance_of(String, path) + end + + def test_expand_path_accepts_objects_that_have_a_to_path_method + klass = Class.new { def to_path; "a/b/c"; end } + obj = klass.new + assert_equal("#{Dir.pwd}/a/b/c", File.expand_path(obj)) end def test_basename @@ -447,16 +667,31 @@ class TestFileExhaustive < Test::Unit::TestCase assert_equal(basename, File.basename(@file + ".", ".*")) assert_equal(basename, File.basename(@file + "::$DATA", ".*")) end + if File::ALT_SEPARATOR == '\\' + a = "foo/\225\\\\" + [%W"cp437 \225", %W"cp932 \225\\"].each do |cp, expected| + assert_equal(expected.force_encoding(cp), File.basename(a.dup.force_encoding(cp)), cp) + end + end assert_incompatible_encoding {|d| File.basename(d)} assert_incompatible_encoding {|d| File.basename(d, ".*")} assert_raise(Encoding::CompatibilityError) {File.basename("foo.ext", ".*".encode("utf-16le"))} + + s = "foo\x93_a".force_encoding("cp932") + assert_equal(s, File.basename(s, "_a")) end def test_dirname assert(@file.start_with?(File.dirname(@file))) assert_equal(".", File.dirname("")) assert_incompatible_encoding {|d| File.dirname(d)} + if File::ALT_SEPARATOR == '\\' + a = "\225\\\\foo" + [%W"cp437 \225", %W"cp932 \225\\"].each do |cp, expected| + assert_equal(expected.force_encoding(cp), File.dirname(a.dup.force_encoding(cp)), cp) + end + end end def test_extname @@ -500,6 +735,13 @@ class TestFileExhaustive < Test::Unit::TestCase def o.to_path; "foo"; end assert_equal(s, File.join(o, "bar", "baz")) assert_equal(s, File.join("foo" + File::SEPARATOR, "bar", File::SEPARATOR + "baz")) + if File::ALT_SEPARATOR == '\\' + a = "\225\\" + b = "foo" + [%W"cp437 \225\\foo", %W"cp932 \225\\/foo"].each do |cp, expected| + assert_equal(expected.force_encoding(cp), File.join(a.dup.force_encoding(cp), b.dup.force_encoding(cp)), cp) + end + end end def test_truncate @@ -770,6 +1012,13 @@ class TestFileExhaustive < Test::Unit::TestCase assert_equal(0, File::Stat.new(@zerofile).size) end + def test_stat_special_file + # test for special files such as pagefile.sys on Windows + assert_nothing_raised do + Dir::glob("C:/*.sys") {|f| File::Stat.new(f) } + end + end if DRIVE + def test_path_check assert_nothing_raised { ENV["PATH"] } end diff --git a/test/ruby/test_flip.rb b/test/ruby/test_flip.rb new file mode 100644 index 0000000..bd14228 --- /dev/null +++ b/test/ruby/test_flip.rb @@ -0,0 +1,21 @@ +require 'test/unit' +require_relative 'envutil' + +class TestFlip < Test::Unit::TestCase + def test_hidden_key + bug6899 = '[ruby-core:47253]' + foo = "foor" + bar = "bar" + assert_nothing_raised(NotImplementedError, bug6899) do + 2000.times {eval %[(foo..bar) ? 1 : 2]} + end + end + + def test_shared_eval + bug7671 = '[ruby-core:51296]' + vs = (1..9).to_a + vs.select {|n| if n==2..n==16 then 1 end} + v = eval("vs.select {|n| if n==3..n==6 then 1 end}") + assert_equal([*3..6], v, bug7671) + end +end diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index 440fd39..d2cee75 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -196,7 +196,7 @@ class TestFloat < Test::Unit::TestCase end def test_modulo3 - bug6048 = '[ruby-core:42726]' + bug6044 = '[ruby-core:42726]' assert_equal(4.2, 4.2.send(:%, Float::INFINITY)) assert_equal(4.2, 4.2 % Float::INFINITY) assert_is_minus_zero(-0.0 % 4.2) diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index bcc4906..f04e7e0 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -97,4 +97,19 @@ class TestGc < Test::Unit::TestCase assert_in_out_err([env, "-W1", "-e", "exit"], "", [], [], "[ruby-core:39795]") assert_in_out_err([env, "-w", "-e", "exit"], "", [], /heap_min_slots=100000/, "[ruby-core:39795]") end + + def test_profiler_enabled + GC::Profiler.enable + assert_equal(true, GC::Profiler.enabled?) + GC::Profiler.disable + assert_equal(false, GC::Profiler.enabled?) + ensure + GC::Profiler.disable + end + + def test_finalizing_main_thread + assert_in_out_err(%w[--disable-gems], <<-EOS, ["\"finalize\""], [], "[ruby-dev:46647]") + ObjectSpace.define_finalizer(Thread.main) { p 'finalize' } + EOS + end end diff --git a/test/ruby/test_io.rb b/test/ruby/test_io.rb index edf449d..da6c904 100644 --- a/test/ruby/test_io.rb +++ b/test/ruby/test_io.rb @@ -1799,7 +1799,7 @@ End } end ensure - fds.each {|fd| IO.for_fd(fd).close rescue next} + GC.start end def test_flush_in_finalizer2 @@ -1951,15 +1951,18 @@ End def test_open_mode feature4742 = "[ruby-core:36338]" + bug6055 = '[ruby-dev:45268]' mkcdtmpdir do - refute_nil(f = File.open('symbolic', 'w')) + assert_not_nil(f = File.open('symbolic', 'w')) f.close - refute_nil(f = File.open('numeric', File::WRONLY|File::TRUNC|File::CREAT)) + assert_not_nil(f = File.open('numeric', File::WRONLY|File::TRUNC|File::CREAT)) f.close - refute_nil(f = File.open('hash-symbolic', :mode => 'w')) + assert_not_nil(f = File.open('hash-symbolic', :mode => 'w')) f.close - refute_nil(f = File.open('hash-numeric', :mode => File::WRONLY|File::TRUNC|File::CREAT), feature4742) + assert_not_nil(f = File.open('hash-numeric', :mode => File::WRONLY|File::TRUNC|File::CREAT), feature4742) + f.close + assert_nothing_raised(bug6055) {f = File.open('hash-symbolic', binmode: true)} f.close end end @@ -2039,4 +2042,140 @@ End write_file.close file.close! end + + def test_ioctl_linux + return if /linux/ !~ RUBY_PLATFORM + + assert_nothing_raised do + File.open('/dev/urandom'){|f1| + entropy_count = "" + # get entropy count + f1.ioctl(0x80045200, entropy_count) + } + end + + buf = '' + assert_nothing_raised do + fionread = 0x541B + File.open(__FILE__){|f1| + f1.ioctl(fionread, buf) + } + end + assert_equal(File.size(__FILE__), buf.unpack('i!')[0]) + end + + def test_ioctl_linux2 + return if /linux/ !~ RUBY_PLATFORM + return if /^i.?86|^x86_64/ !~ RUBY_PLATFORM + + return unless system('tty', '-s') # stdin is not a terminal + File.open('/dev/tty') { |f| + tiocgwinsz=0x5413 + winsize="" + assert_nothing_raised { + f.ioctl(tiocgwinsz, winsize) + } + } + end + + def test_setpos + mkcdtmpdir { + File.open("tmp.txt", "w") {|f| + f.puts "a" + f.puts "bc" + f.puts "def" + } + pos1 = pos2 = pos3 = nil + File.open("tmp.txt") {|f| + assert_equal("a\n", f.gets) + pos1 = f.pos + assert_equal("bc\n", f.gets) + pos2 = f.pos + assert_equal("def\n", f.gets) + pos3 = f.pos + assert_equal(nil, f.gets) + } + File.open("tmp.txt") {|f| + f.pos = pos1 + assert_equal("bc\n", f.gets) + assert_equal("def\n", f.gets) + assert_equal(nil, f.gets) + } + File.open("tmp.txt") {|f| + f.pos = pos2 + assert_equal("def\n", f.gets) + assert_equal(nil, f.gets) + } + File.open("tmp.txt") {|f| + f.pos = pos3 + assert_equal(nil, f.gets) + } + } + end + + def test_std_fileno + assert_equal(0, STDIN.fileno) + assert_equal(1, STDOUT.fileno) + assert_equal(2, STDERR.fileno) + assert_equal(0, $stdin.fileno) + assert_equal(1, $stdout.fileno) + assert_equal(2, $stderr.fileno) + end + + def test_io_select_with_many_files + bug8080 = '[ruby-core:53349]' + + assert_normal_exit %q{ + require "tempfile" + + # try to raise RLIM_NOFILE to >FD_SETSIZE + # Unfortunately, ruby export FD_SETSIZE. then we assume it's 1024. + fd_setsize = 1024 + + begin + Process.setrlimit(Process::RLIMIT_NOFILE, fd_setsize+10) + rescue =>e + # Process::RLIMIT_NOFILE couldn't be raised. skip the test + exit 0 + end + + tempfiles = [] + (0..fd_setsize+1).map {|i| + tempfiles << Tempfile.open("test_io_select_with_many_files") + } + + IO.select(tempfiles) + }, bug8080 + end + + def test_read_32bit_boundary + bug8431 = '[ruby-core:55098] [Bug #8431]' + make_tempfile {|t| + assert_separately(["-", bug8431, t.path], <<-"end;") + msg = ARGV.shift + f = open(ARGV[0], "rb") + f.seek(0xffff_ffff) + assert_nil(f.read(1), msg) + end; + } + end if /mswin|mingw/ =~ RUBY_PLATFORM + + def test_write_32bit_boundary + bug8431 = '[ruby-core:55098] [Bug #8431]' + make_tempfile {|t| + assert_separately(["-", bug8431, t.path], <<-"end;", timeout: 30) + msg = ARGV.shift + f = open(ARGV[0], "wb") + f.seek(0xffff_ffff) + begin + # this will consume very long time or fail by ENOSPC on a + # filesystem which sparse file is not supported + f.write('1') + rescue SystemCallError + else + assert_equal(0x1_0000_0000, f.tell, msg) + end + end; + } + end if /mswin|mingw/ =~ RUBY_PLATFORM end diff --git a/test/ruby/test_io_m17n.rb b/test/ruby/test_io_m17n.rb index 560cd03..c22f665 100644 --- a/test/ruby/test_io_m17n.rb +++ b/test/ruby/test_io_m17n.rb @@ -2067,7 +2067,17 @@ EOT open("a", "wb") {|f| f.puts "a"} open("a", "rt") {|f| f.getc} } - assert(c.ascii_only?, "should be ascii_only #{bug4557}") + assert(c.ascii_only?, bug4557) + end + + def test_getc_conversion + bug8516 = '[ruby-core:55444] [Bug #8516]' + c = with_tmpdir { + open("a", "wb") {|f| f.putc "\xe1"} + open("a", "r:iso-8859-1:utf-8") {|f| f.getc} + } + refute(c.ascii_only?, bug8516) + assert_equal(1, c.size, bug8516) end def test_default_mode_on_dosish @@ -2363,6 +2373,22 @@ EOT } end if /mswin|mingw/ =~ RUBY_PLATFORM + def test_pos_with_buffer_end_cr + bug6401 = '[ruby-core:44874]' + with_tmpdir { + # Read buffer size is 8191. This generates '\r' at 8191. + lines = ["X" * 8187, "X"] + generate_file("tmp", lines.join("\r\n") + "\r\n") + + open("tmp", "r") do |f| + lines.each do |line| + f.pos + assert_equal(line, f.readline.chomp, bug6401) + end + end + } + end if /mswin|mingw/ =~ RUBY_PLATFORM + def test_read_crlf_and_eof bug6271 = '[ruby-core:44189]' with_tmpdir { diff --git a/test/ruby/test_literal.rb b/test/ruby/test_literal.rb index bb3f50d..e7a7c76 100644 --- a/test/ruby/test_literal.rb +++ b/test/ruby/test_literal.rb @@ -79,9 +79,15 @@ class TestRubyLiteral < Test::Unit::TestCase assert_equal "\x13", "\c\x33" assert_equal "\x13", "\C-\x33" assert_equal "\xB3", "\M-\x33" - assert_equal "\\\u201c", eval(%["\\\u{201c}"]), bug6069 - assert_equal "\\\u201c".encode("euc-jp"), eval(%["\\\u{201c}"].encode("euc-jp")), bug6069 - assert_equal "\\\u201c".encode("iso-8859-13"), eval(%["\\\u{201c}"].encode("iso-8859-13")), bug6069 + assert_equal "\u201c", eval(%["\\\u{201c}"]), bug5262 + assert_equal "\u201c".encode("euc-jp"), eval(%["\\\u{201c}"].encode("euc-jp")), bug5262 + assert_equal "\u201c".encode("iso-8859-13"), eval(%["\\\u{201c}"].encode("iso-8859-13")), bug5262 + assert_equal "\\\u201c", eval(%['\\\u{201c}']), bug6069 + assert_equal "\\\u201c".encode("euc-jp"), eval(%['\\\u{201c}'].encode("euc-jp")), bug6069 + assert_equal "\\\u201c".encode("iso-8859-13"), eval(%['\\\u{201c}'].encode("iso-8859-13")), bug6069 + assert_equal "\u201c", eval(%[?\\\u{201c}]), bug6069 + assert_equal "\u201c".encode("euc-jp"), eval(%[?\\\u{201c}].encode("euc-jp")), bug6069 + assert_equal "\u201c".encode("iso-8859-13"), eval(%[?\\\u{201c}].encode("iso-8859-13")), bug6069 end def test_dstring diff --git a/test/ruby/test_m17n.rb b/test/ruby/test_m17n.rb index 3553f3a..699c815 100644 --- a/test/ruby/test_m17n.rb +++ b/test/ruby/test_m17n.rb @@ -1369,6 +1369,14 @@ class TestM17N < Test::Unit::TestCase assert_equal(true, s.valid_encoding?) s << "\xff".force_encoding("utf-16be") assert_equal(false, s.valid_encoding?, bug4018) + + bug6190 = '[ruby-core:43557]' + s = "\xe9" + s = s.encode("utf-8", "utf-8") + assert_equal(false, s.valid_encoding?, bug6190) + s = "\xe9" + s.encode!("utf-8", "utf-8") + assert_equal(false, s.valid_encoding?, bug6190) end def test_getbyte diff --git a/test/ruby/test_m17n_comb.rb b/test/ruby/test_m17n_comb.rb index 79016af..6eec6a6 100644 --- a/test/ruby/test_m17n_comb.rb +++ b/test/ruby/test_m17n_comb.rb @@ -777,7 +777,17 @@ class TestM17NComb < Test::Unit::TestCase end def test_str_crypt + begin + # glibc 2.16 or later denies salt contained other than [0-9A-Za-z./] #7312 + glibcver = `#{RbConfig::CONFIG["libdir"]}/libc.so.6`[/\AGNU C Library.*version ([0-9.]+)/, 1].split('.').map(&:to_i) + strict_crypt = (glibcver <=> [2, 16]) > -1 + rescue + end + combination(STRINGS, STRINGS) {|str, salt| + if strict_crypt + next unless salt.ascii_only? && /\A[0-9a-zA-Z.\/]+\z/ =~ salt + end if a(salt).length < 2 assert_raise(ArgumentError) { str.crypt(salt) } next diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index 7ec6959..0f3f794 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -483,4 +483,22 @@ class TestMarshal < Test::Unit::TestCase assert_equal(Rational(1, 2), Marshal.load("\x04\bU:\rRational[\ai\x06i\a")) assert_raise(ArgumentError){Marshal.load("\x04\bU:\rRational[\bi\x00i\x00i\x00")} end + + class TestClass + end + + module TestModule + end + + def test_marshal_load_should_not_taint_classes + bug7325 = '[ruby-core:49198]' + for c in [TestClass, TestModule] + assert(!c.tainted?) + assert(!c.untrusted?) + c2 = Marshal.load(Marshal.dump(c).taint.untrust) + assert_same(c, c2) + assert(!c.tainted?, bug7325) + assert(!c.untrusted?, bug7325) + end + end end diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 2cc0de5..ea6c5f2 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -460,4 +460,16 @@ class TestMethod < Test::Unit::TestCase assert_nothing_raised { v.instance_eval { mv2 } } assert_nothing_raised { v.instance_eval { mv3 } } end + + def test_bound_method_entry + bug6171 = '[ruby-core:43383]' + assert_ruby_status([], <<-EOC, bug6171) + class Bug6171 + def initialize(target) + define_singleton_method(:reverse, target.method(:reverse).to_proc) + end + end + 1000.times {p = Bug6171.new('test'); 10000.times {p.reverse}} + EOC + end end diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 6176f48..6673852 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -1220,4 +1220,24 @@ class TestModule < Test::Unit::TestCase INPUT assert_in_out_err([], src, ["NameError"], []) end + + def test_include_module_with_constants_invalidates_method_cache + assert_in_out_err([], <<-RUBY, %w(123 456), []) + A = 123 + + class Foo + def self.a + A + end + end + + module M + A = 456 + end + + puts Foo.a + Foo.send(:include, M) + puts Foo.a + RUBY + end end diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 6ce16a2..c862215 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -612,6 +612,18 @@ class TestPack < Test::Unit::TestCase assert_equal([0x100000000], "\220\200\200\200\000".unpack("w"), [0x100000000]) end + + def test_pack_unpack_M + assert_equal(["pre123after"], "pre=31=32=33after".unpack("M")) + assert_equal(["preafter"], "pre=\nafter".unpack("M")) + assert_equal(["preafter"], "pre=\r\nafter".unpack("M")) + assert_equal(["pre="], "pre=".unpack("M")) + assert_equal(["pre=\r"], "pre=\r".unpack("M")) + assert_equal(["pre=hoge"], "pre=hoge".unpack("M")) + assert_equal(["pre==31after"], "pre==31after".unpack("M")) + assert_equal(["pre===31after"], "pre===31after".unpack("M")) + end + def test_modify_under_safe4 s = "foo" assert_raise(SecurityError) do diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 3cac94a..7560ce9 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -1,4 +1,5 @@ require 'test/unit' +require_relative 'envutil' class TestProc < Test::Unit::TestCase def setup @@ -140,6 +141,14 @@ class TestProc < Test::Unit::TestCase method(:m2).to_proc end + def m1(var) + var + end + + def m_block_given? + m1(block_given?) + end + # [yarv-dev:777] block made by Method#to_proc def test_method_to_proc b = block() @@ -147,6 +156,37 @@ class TestProc < Test::Unit::TestCase assert_instance_of(Binding, b.binding, '[ruby-core:25589]') end + def test_block_given_method + m = method(:m_block_given?) + assert(!m.call, "without block") + assert(m.call {}, "with block") + assert(!m.call, "without block second") + end + + def test_block_given_method_to_proc + bug8341 = '[Bug #8341]' + m = method(:m_block_given?).to_proc + assert(!m.call, "#{bug8341} without block") + assert(m.call {}, "#{bug8341} with block") + assert(!m.call, "#{bug8341} without block second") + end + + def test_block_persist_between_calls + bug8341 = '[Bug #8341]' + o = Object.new + def o.m1(top=true) + if top + [block_given?, @m.call(false)] + else + block_given? + end + end + m = o.method(:m1).to_proc + o.instance_variable_set(:@m, m) + assert_equal([true, false], m.call {}, "#{bug8341} nested with block") + assert_equal([false, false], m.call, "#{bug8341} nested without block") + end + def test_curry b = proc {|x, y, z| (x||0) + (y||0) + (z||0) } assert_equal(6, b.curry[1][2][3]) @@ -818,4 +858,14 @@ class TestProc < Test::Unit::TestCase assert_equal('zot', o.method(:foo).to_proc.() {'zot'}, bug3792) } end + + def test_overriden_lambda + bug8345 = '[ruby-core:54687] [Bug #8345]' + assert_normal_exit('def lambda; end; method(:puts).to_proc', bug8345) + end + + def test_overriden_proc + bug8345 = '[ruby-core:54688] [Bug #8345]' + assert_normal_exit('def proc; end; ->{}.curry', bug8345) + end end diff --git a/test/ruby/test_rand.rb b/test/ruby/test_rand.rb index 67b6df8..c713981 100644 --- a/test/ruby/test_rand.rb +++ b/test/ruby/test_rand.rb @@ -415,14 +415,43 @@ END def test_fork_shuffle pid = fork do - (1..10).to_a.shuffle - raise 'default seed is not set' if srand == 0 + (1..10).to_a.shuffle + raise 'default seed is not set' if srand == 0 end p2, st = Process.waitpid2(pid) assert(st.success?, "#{st.inspect}") rescue NotImplementedError, ArgumentError end + def assert_fork_status(n, mesg, &block) + IO.pipe do |r, w| + (1..n).map do + p1 = fork {w.puts(block.call.to_s)} + _, st = Process.waitpid2(p1) + assert_send([st, :success?], mesg) + r.gets.strip + end + end + end + + def test_rand_reseed_on_fork + bug5661 = '[ruby-core:41209]' + + assert_fork_status(1, bug5661) {Random.rand(4)} + r1, r2 = *assert_fork_status(2, bug5661) {Random.rand} + assert_not_equal(r1, r2, bug5661) + + assert_fork_status(1, bug5661) {rand(4)} + r1, r2 = *assert_fork_status(2, bug5661) {rand} + assert_not_equal(r1, r2, bug5661) + + stable = Random.new + assert_fork_status(1, bug5661) {stable.rand(4)} + r1, r2 = *assert_fork_status(2, bug5661) {stable.rand} + assert_equal(r1, r2, bug5661) + rescue NotImplementedError + end + def test_seed bug3104 = '[ruby-core:29292]' rand_1 = Random.new(-1).rand diff --git a/test/ruby/test_regexp.rb b/test/ruby/test_regexp.rb index 3c1662e..3073a98 100644 --- a/test/ruby/test_regexp.rb +++ b/test/ruby/test_regexp.rb @@ -498,17 +498,17 @@ class TestRegexp < Test::Unit::TestCase assert(m.tainted?) end - def check(re, ss, fs = []) + def check(re, ss, fs = [], msg = nil) re = Regexp.new(re) unless re.is_a?(Regexp) ss = [ss] unless ss.is_a?(Array) ss.each do |e, s| s ||= e - assert_match(re, s) + assert_match(re, s, msg) m = re.match(s) - assert_equal(e, m[0]) + assert_equal(e, m[0], msg) end fs = [fs] unless fs.is_a?(Array) - fs.each {|s| assert_no_match(re, s) } + fs.each {|s| assert_no_match(re, s, msg) } end def failcheck(re) @@ -688,7 +688,7 @@ class TestRegexp < Test::Unit::TestCase check(/\A[a-b-]\z/, %w(a b -), ["", "c"]) check('\A[a-b-&&\w]\z', %w(a b), ["", "-"]) check('\A[a-b-&&\W]\z', "-", ["", "a", "b"]) - check('\A[a-c-e]\z', %w(a b c e), %w(- d)) # is it OK? + check('\A[a-c-e]\z', %w(a b c e -), %w(d)) check(/\A[a-f&&[^b-c]&&[^e]]\z/, %w(a d f), %w(b c e g 0)) check(/\A[[^b-c]&&[^e]&&a-f]\z/, %w(a d f), %w(b c e g 0)) check(/\A[\n\r\t]\z/, ["\n", "\r", "\t"]) @@ -867,4 +867,10 @@ class TestRegexp < Test::Unit::TestCase assert_match(/invalid hex escape/, error.message) assert_equal(1, error.message.scan(/.*invalid .*escape.*/i).size, bug3539) end + + def test_raw_hyphen_and_tk_char_type_after_range + bug6853 = '[ruby-core:47115]' + # use Regexp.new instead of literal to ignore a parser warning. + check(Regexp.new('[0-1-\\s]'), [' ', '-'], ['2', 'a'], bug6853) + end end diff --git a/test/ruby/test_require.rb b/test/ruby/test_require.rb index 96b1551..58a9ee2 100644 --- a/test/ruby/test_require.rb +++ b/test/ruby/test_require.rb @@ -339,4 +339,21 @@ class TestRequire < Test::Unit::TestCase [], /\$LOADED_FEATURES is frozen; cannot append feature \(RuntimeError\)$/, bug3756) end + + def test_loaded_features_encoding + bug6377 = '[ruby-core:44750]' + loadpath = $:.dup + features = $".dup + $".clear + $:.clear + Dir.mktmpdir {|tmp| + $: << tmp + open(File.join(tmp, "foo.rb"), "w") {} + require "foo" + assert_not_equal(Encoding::ASCII_8BIT, $"[0].encoding, bug6377) + } + ensure + $:.replace(loadpath) + $".replace(features) + end end diff --git a/test/ruby/test_rubyoptions.rb b/test/ruby/test_rubyoptions.rb index 339999a..5533ac2 100644 --- a/test/ruby/test_rubyoptions.rb +++ b/test/ruby/test_rubyoptions.rb @@ -489,6 +489,8 @@ class TestRubyOptions < Test::Unit::TestCase assert_in_out_err(["-we", "1.times do\n a=1\nend"], "", [], [], feature3446) assert_in_out_err(["-we", "def foo\n 1.times do\n a=1\n end\nend"], "", [], ["-e:3: warning: assigned but unused variable - a"], feature3446) assert_in_out_err(["-we", "def foo\n"" 1.times do |a| end\n""end"], "", [], []) + bug7408 = '[ruby-core:49659]' + assert_in_out_err(["-we", "def foo\n a=1\n :a\nend"], "", [], ["-e:2: warning: assigned but unused variable - a"], bug7408) end def test_shadowing_variable @@ -553,4 +555,14 @@ class TestRubyOptions < Test::Unit::TestCase assert_in_out_err(["-C", dir, a], "", [], /LoadError/, bug3851) end end + + def test_pflag_gsub + bug7157 = '[ruby-core:47967]' + assert_in_out_err(['-p', '-e', 'gsub(/t.*/){"TEST"}'], %[test], %w[TEST], [], bug7157) + end + + def test_pflag_sub + bug7157 = '[ruby-core:47967]' + assert_in_out_err(['-p', '-e', 'sub(/t.*/){"TEST"}'], %[test], %w[TEST], [], bug7157) + end end diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 4d9d172..6185e23 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -1995,5 +1995,9 @@ class TestString < Test::Unit::TestCase assert_equal(u("\x81\x82"), "\u3042".byteslice(1..2)) assert_equal(u("\x82")+("\u3042"*9), ("\u3042"*10).byteslice(2, 28)) + + bug7954 = '[ruby-dev:47108]' + assert_equal(false, "\u3042".byteslice(0, 2).valid_encoding?) + assert_equal(false, ("\u3042"*10).byteslice(0, 20).valid_encoding?) end end diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb index c98f954..23c50e6 100644 --- a/test/ruby/test_symbol.rb +++ b/test/ruby/test_symbol.rb @@ -33,7 +33,7 @@ class TestSymbol < Test::Unit::TestCase assert_inspect_evaled(':foo') assert_inspect_evaled(':foo!') assert_inspect_evaled(':bar?') - assert_inspect_evaled(':<<') + assert_inspect_evaled(":<<") assert_inspect_evaled(':>>') assert_inspect_evaled(':<=') assert_inspect_evaled(':>=') @@ -102,6 +102,33 @@ class TestSymbol < Test::Unit::TestCase assert_raise(ArgumentError) { :foo.to_proc.call } end + def m_block_given? + block_given? + end + + def m2_block_given?(m = nil) + if m + [block_given?, m.call(self)] + else + block_given? + end + end + + def test_block_given_to_proc + bug8531 = '[Bug #8531]' + m = :m_block_given?.to_proc + assert(!m.call(self), "#{bug8531} without block") + assert(m.call(self) {}, "#{bug8531} with block") + assert(!m.call(self), "#{bug8531} without block second") + end + + def test_block_persist_between_calls + bug8531 = '[Bug #8531]' + m2 = :m2_block_given?.to_proc + assert_equal([true, false], m2.call(self, m2) {}, "#{bug8531} nested with block") + assert_equal([false, false], m2.call(self, m2), "#{bug8531} nested without block") + end + def test_succ assert_equal(:fop, :foo.succ) end diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index bd60c8a..d924679 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -1,21 +1,24 @@ require 'test/unit' class TestSyntax < Test::Unit::TestCase - def valid_syntax?(code, fname) + def assert_valid_syntax(code, fname, mesg = fname) code = code.dup.force_encoding("ascii-8bit") code.sub!(/\A(?:\xef\xbb\xbf)?(\s*\#.*$)*(\n)?/n) { "#$&#{"\n" if $1 && !$2}BEGIN{throw tag, :ok}\n" } code.force_encoding("us-ascii") - catch {|tag| eval(code, binding, fname, 0)} - rescue SyntaxError - false + verbose, $VERBOSE = $VERBOSE, nil + assert_nothing_raised(SyntaxError, mesg) do + assert_equal(:ok, catch {|tag| eval(code, binding, fname, 0)}, mesg) + end + ensure + $VERBOSE = verbose end def test_syntax assert_nothing_raised(Exception) do for script in Dir[File.expand_path("../../../{lib,sample,ext,test}/**/*.rb", __FILE__)].sort - assert(valid_syntax?(IO::read(script), script), script) + assert_valid_syntax(IO::read(script), script) end end end @@ -52,6 +55,11 @@ class TestSyntax < Test::Unit::TestCase f.close! end + def test_reserved_method_no_args + bug6403 = '[ruby-dev:45626]' + assert_valid_syntax("def self; :foo; end", __FILE__, bug6403) + end + private def make_tmpsrc(f, src) diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index a1f060e..0317214 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -14,6 +14,20 @@ class TestTime < Test::Unit::TestCase $VERBOSE = @verbose end + def no_leap_seconds? + # 1972-06-30T23:59:60Z is the first leap second. + Time.utc(1972, 7, 1, 0, 0, 0) - Time.utc(1972, 6, 30, 23, 59, 59) == 1 + end + + def get_t2000 + if no_leap_seconds? + # Sat Jan 01 00:00:00 UTC 2000 + Time.at(946684800).gmtime + else + Time.utc(2000, 1, 1) + end + end + def test_new assert_equal(Time.utc(2000,2,10), Time.new(2000,2,10, 11,0,0, 3600*11)) assert_equal(Time.utc(2000,2,10), Time.new(2000,2,9, 13,0,0, -3600*11)) @@ -324,6 +338,7 @@ class TestTime < Test::Unit::TestCase end assert_raise(ArgumentError) { Time.gm(2000, 1, 1, 0, 0, -(2**31), :foo, :foo) } o = Object.new + def o.to_int; 0; end def o.to_r; nil; end assert_raise(TypeError) { Time.gm(2000, 1, 1, 0, 0, o, :foo, :foo) } def o.to_r; ""; end @@ -377,6 +392,15 @@ class TestTime < Test::Unit::TestCase assert_kind_of(Integer, T2000.hash) end + def test_reinitialize + bug8099 = '[ruby-core:53436] [Bug #8099]' + t2000 = get_t2000 + assert_raise(TypeError, bug8099) { + t2000.send(:initialize, 2013, 03, 14) + } + assert_equal(get_t2000, t2000, bug8099) + end + def test_init_copy assert_equal(T2000, T2000.dup) assert_raise(TypeError) do @@ -659,6 +683,38 @@ class TestTime < Test::Unit::TestCase bug4457 = '[ruby-dev:43285]' assert_raise(Errno::ERANGE, bug4457) {Time.now.strftime('%8192z')} + + bug4458 = '[ruby-dev:43287]' + t = T2000.getlocal("+09:00") + assert_equal(" +900", t.strftime("%_10z"), bug4458) + assert_equal("+000000900", t.strftime("%10z"), bug4458) + assert_equal(" +9:00", t.strftime("%_:10z"), bug4458) + assert_equal("+000009:00", t.strftime("%:10z"), bug4458) + assert_equal(" +9:00:00", t.strftime("%_::10z"), bug4458) + assert_equal("+009:00:00", t.strftime("%::10z"), bug4458) + t = T2000.getlocal("-05:00") + assert_equal(" -500", t.strftime("%_10z"), bug4458) + assert_equal("-000000500", t.strftime("%10z"), bug4458) + assert_equal(" -5:00", t.strftime("%_:10z"), bug4458) + assert_equal("-000005:00", t.strftime("%:10z"), bug4458) + assert_equal(" -5:00:00", t.strftime("%_::10z"), bug4458) + assert_equal("-005:00:00", t.strftime("%::10z"), bug4458) + + bug6323 = '[ruby-core:44447]' + t = T2000.getlocal("+00:36") + assert_equal(" +036", t.strftime("%_10z"), bug6323) + assert_equal("+000000036", t.strftime("%10z"), bug6323) + assert_equal(" +0:36", t.strftime("%_:10z"), bug6323) + assert_equal("+000000:36", t.strftime("%:10z"), bug6323) + assert_equal(" +0:36:00", t.strftime("%_::10z"), bug6323) + assert_equal("+000:36:00", t.strftime("%::10z"), bug6323) + t = T2000.getlocal("-00:55") + assert_equal(" -055", t.strftime("%_10z"), bug6323) + assert_equal("-000000055", t.strftime("%10z"), bug6323) + assert_equal(" -0:55", t.strftime("%_:10z"), bug6323) + assert_equal("-000000:55", t.strftime("%:10z"), bug6323) + assert_equal(" -0:55:00", t.strftime("%_::10z"), bug6323) + assert_equal("-000:55:00", t.strftime("%::10z"), bug6323) end def test_delegate diff --git a/test/rubygems/test_gem_installer.rb b/test/rubygems/test_gem_installer.rb index d40fbc9..9b36120 100644 --- a/test/rubygems/test_gem_installer.rb +++ b/test/rubygems/test_gem_installer.rb @@ -747,7 +747,8 @@ load Gem.bin_path('a', 'executable', version) exe = File.join @gemhome, 'bin', 'executable' - ARGV.unshift "\xE4pfel".force_encoding("UTF-8") + extra_arg = "\xE4pfel".force_encoding("UTF-8") + ARGV.unshift extra_arg begin Gem::Specification.reset @@ -756,7 +757,7 @@ load Gem.bin_path('a', 'executable', version) instance_eval File.read(exe) end ensure - ARGV.shift if ARGV.first == "\xE4pfel" + ARGV.shift if ARGV.first == extra_arg end assert_match(/ran executable/, e.message) diff --git a/test/socket/test_socket.rb b/test/socket/test_socket.rb index f433be8..f693a62 100644 --- a/test/socket/test_socket.rb +++ b/test/socket/test_socket.rb @@ -275,8 +275,32 @@ class TestSocket < Test::Unit::TestCase Socket.udp_server_sockets(0) {|sockets| famlies = {} - sockets.each {|s| famlies[s.local_address.afamily] = true } - ip_addrs.reject! {|ai| !famlies[ai.afamily] } + sockets.each {|s| famlies[s.local_address.afamily] = s } + ip_addrs.reject! {|ai| + s = famlies[ai.afamily] + next true unless s + case RUBY_PLATFORM + when /linux/ + if ai.ip_address.include?('%') and + (`uname -r`[/[0-9.]+/].split('.').map(&:to_i) <=> [2,6,18]) <= 0 + # Cent OS 5.6 (2.6.18-238.19.1.el5xen) doesn't correctly work + # sendmsg with pktinfo for link-local ipv6 addresses + next true + end + when /freebsd/ + if ifr_name = ai.ip_address[/%(.*)/, 1] + # FreeBSD 9.0 with default setting (ipv6_activate_all_interfaces + # is not YES) sets IFDISABLED to interfaces which don't have + # global IPv6 address. + # Link-local IPv6 addresses on those interfaces don't work. + ulSIOCGIFINFO_IN6 = -1068996244 + bIFDISABLED = 4 + in6_ifreq = ifr_name + s.ioctl(ulSIOCGIFINFO_IN6, in6_ifreq) + next true if in6_ifreq.unpack('A16L6').last[bIFDISABLED-1] == 1 + end + end + } skipped = false begin port = sockets.first.local_address.ip_port @@ -290,12 +314,6 @@ class TestSocket < Test::Unit::TestCase } ip_addrs.each {|ai| - if /linux/ =~ RUBY_PLATFORM && ai.ip_address.include?('%') && - (`uname -r`[/[0-9.]+/].split('.').map(&:to_i) <=> [2,6,18]) <= 0 - # Cent OS 5.6 (2.6.18-238.19.1.el5xen) doesn't correctly work - # sendmsg with pktinfo for link-local ipv6 addresses - next - end Addrinfo.udp(ai.ip_address, port).connect {|s| msg1 = "<<<#{ai.inspect}>>>" s.sendmsg msg1 diff --git a/test/socket/test_unix.rb b/test/socket/test_unix.rb index b4c4592..3559eb8 100644 --- a/test/socket/test_unix.rb +++ b/test/socket/test_unix.rb @@ -324,8 +324,11 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase assert_raise(ArgumentError) { UNIXServer.new("a" * 300) } end - def test_nul - assert_raise(ArgumentError) { Socket.sockaddr_un("a\0b") } + def test_abstract_namespace + return if /linux/ !~ RUBY_PLATFORM + addr = Socket.pack_sockaddr_un("\0foo") + assert_match(/\0foo\z/, addr) + assert_equal("\0foo", Socket.unpack_sockaddr_un(addr)) end def test_dgram_pair @@ -507,4 +510,69 @@ class TestSocket_UNIXSocket < Test::Unit::TestCase } end + def test_abstract_unix_server + return if /linux/ !~ RUBY_PLATFORM + name = "\0ruby-test_unix" + s0 = nil + UNIXServer.open(name) {|s| + assert_equal(name, s.local_address.unix_path) + s0 = s + UNIXSocket.open(name) {|c| + sock = s.accept + begin + assert_equal(name, c.remote_address.unix_path) + ensure + sock.close + end + } + } + assert(s0.closed?) + end + + def test_abstract_unix_socket_econnrefused + return if /linux/ !~ RUBY_PLATFORM + name = "\0ruby-test_unix" + assert_raise(Errno::ECONNREFUSED) do + UNIXSocket.open(name) {} + end + end + + def test_abstract_unix_server_socket + return if /linux/ !~ RUBY_PLATFORM + name = "\0ruby-test_unix" + s0 = nil + Socket.unix_server_socket(name) {|s| + assert_equal(name, s.local_address.unix_path) + s0 = s + Socket.unix(name) {|c| + sock, = s.accept + begin + assert_equal(name, c.remote_address.unix_path) + ensure + sock.close + end + } + } + assert(s0.closed?) + end + + def test_autobind + return if /linux/ !~ RUBY_PLATFORM + s0 = nil + Socket.unix_server_socket("") {|s| + name = s.local_address.unix_path + assert_match(/\A\0[0-9a-f]{5}\z/, name) + s0 = s + Socket.unix(name) {|c| + sock, = s.accept + begin + assert_equal(name, c.remote_address.unix_path) + ensure + sock.close + end + } + } + assert(s0.closed?) + end + end if defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM diff --git a/test/uri/test_ftp.rb b/test/uri/test_ftp.rb index 0d76c44..cc6843e 100644 --- a/test/uri/test_ftp.rb +++ b/test/uri/test_ftp.rb @@ -27,6 +27,10 @@ class TestFTP < Test::Unit::TestCase assert_equal('pass', url.password) end + def test_parse_invalid + assert_raise(InvalidURIError){URI.parse('ftp:example')} + end + def test_paths # If you think what's below is wrong, please read RubyForge bug 2055, # RFC 1738 section 3.2.2, and RFC 2396. diff --git a/test/webrick/test_cgi.rb b/test/webrick/test_cgi.rb index 1185316..d930c26 100644 --- a/test/webrick/test_cgi.rb +++ b/test/webrick/test_cgi.rb @@ -14,6 +14,7 @@ class TestWEBrickCGI < Test::Unit::TestCase def req.meta_vars meta = super meta["RUBYLIB"] = $:.join(File::PATH_SEPARATOR) + meta[RbConfig::CONFIG['LIBPATHENV']] = ENV[RbConfig::CONFIG['LIBPATHENV']] if RbConfig::CONFIG['LIBPATHENV'] return meta end }, diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb index bcdb3df..cc27b34 100644 --- a/test/webrick/test_filehandler.rb +++ b/test/webrick/test_filehandler.rb @@ -252,6 +252,7 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase def req.meta_vars meta = super meta["RUBYLIB"] = $:.join(File::PATH_SEPARATOR) + meta[RbConfig::CONFIG['LIBPATHENV']] = ENV[RbConfig::CONFIG['LIBPATHENV']] if RbConfig::CONFIG['LIBPATHENV'] return meta end }, diff --git a/test/win32ole/test_err_in_callback.rb b/test/win32ole/test_err_in_callback.rb index 11c29a8..d39ea12 100644 --- a/test/win32ole/test_err_in_callback.rb +++ b/test/win32ole/test_err_in_callback.rb @@ -9,17 +9,21 @@ rescue LoadError end if defined?(WIN32OLE) require 'mkmf' + require 'pathname' require 'test/unit' + require 'tmpdir' class TestErrInCallBack < Test::Unit::TestCase def setup @ruby = nil if File.exist?("./" + CONFIG["RUBY_INSTALL_NAME"] + CONFIG["EXEEXT"]) sep = File::ALT_SEPARATOR || "/" @ruby = "." + sep + CONFIG["RUBY_INSTALL_NAME"] + cwd = Pathname.new(File.expand_path('.')) @iopt = $:.map {|e| - " -I " + e + " -I " + (Pathname.new(e).relative_path_from(cwd).to_s rescue e) }.join("") - @script = File.join(File.dirname(__FILE__), "err_in_callback.rb") + script = File.join(File.dirname(__FILE__), "err_in_callback.rb") + @script = Pathname.new(script).relative_path_from(cwd).to_s rescue script end end @@ -35,18 +39,17 @@ if defined?(WIN32OLE) def test_err_in_callback skip "'ADODB.Connection' is not available" unless available_adodb? if @ruby - cmd = "#{@ruby} -v #{@iopt} #{@script} > test_err_in_callback.log 2>&1" - system(cmd) - str = "" - open("test_err_in_callback.log") {|ifs| - str = ifs.read - } - assert_match(/NameError/, str) + Dir.mktmpdir do |tmpdir| + logfile = File.join(tmpdir, "test_err_in_callback.log") + cmd = "#{@ruby} -v #{@iopt} #{@script} > #{logfile.gsub(%r(/), '\\')} 2>&1" + result = system(cmd) + str = "" + open(logfile) {|ifs| + str = ifs.read + } + assert_match(/NameError/, str) + end end end - - def teardown - File.unlink("test_err_in_callback.log") if File.exist?("test_err_in_callback.log") - end end end diff --git a/test/win32ole/test_win32ole.rb b/test/win32ole/test_win32ole.rb index 8d72272..5fbfbde 100644 --- a/test/win32ole/test_win32ole.rb +++ b/test/win32ole/test_win32ole.rb @@ -351,8 +351,9 @@ if defined?(WIN32OLE) WIN32OLE.codepage = cp file = fso.opentextfile(fname, 2, true) + test_str = [0x3042].pack("U*").encode("UTF-16LE") begin - file.write [0x3042].pack("U*").force_encoding("UTF-8") + file.write test_str.force_encoding("UTF-16") ensure file.close end @@ -360,7 +361,7 @@ if defined?(WIN32OLE) open(fname, "r:ascii-8bit") {|ifs| str = ifs.read } - assert_equal("\202\240", str) + assert_equal(test_str.force_encoding("ascii-8bit"), str) # This test fail if codepage 20932 (euc) is not installed. begin @@ -371,14 +372,14 @@ if defined?(WIN32OLE) WIN32OLE.codepage = cp file = fso.opentextfile(fname, 2, true) begin - file.write [164, 162].pack("c*").force_encoding("EUC-JP") + file.write [164, 162].pack("c*").force_encoding("UTF-16") ensure file.close end open(fname, "r:ascii-8bit") {|ifs| str = ifs.read } - assert_equal("\202\240", str) + assert_equal("\244\242", str) end ensure diff --git a/test/win32ole/test_win32ole_method.rb b/test/win32ole/test_win32ole_method.rb index e4f38ea..2c24004 100644 --- a/test/win32ole/test_win32ole_method.rb +++ b/test/win32ole/test_win32ole_method.rb @@ -109,7 +109,7 @@ if defined?(WIN32OLE_METHOD) end def is_ruby64? - /mswin64|mingw64/ =~ RUBY_PLATFORM + /mswin64|x64-mingw/ =~ RUBY_PLATFORM end def test_offset_vtbl diff --git a/test/win32ole/test_win32ole_variant.rb b/test/win32ole/test_win32ole_variant.rb index 2b34d27..832d943 100644 --- a/test/win32ole/test_win32ole_variant.rb +++ b/test/win32ole/test_win32ole_variant.rb @@ -12,6 +12,14 @@ end if defined?(WIN32OLE_VARIANT) class TestWIN32OLE_VARIANT < Test::Unit::TestCase + def setup + @orglocale = WIN32OLE.locale + WIN32OLE.locale = 0x0409 # set locale US-Eng + end + + def teardown + WIN32OLE.locale = @orglocale + end def test_s_new obj = WIN32OLE_VARIANT.new('foo') @@ -395,17 +403,13 @@ if defined?(WIN32OLE_VARIANT) def test_conversion_str2cy begin - begin - WIN32OLE.locale = 0x0411 # set locale Japanese - rescue WIN32OLERuntimeError - STDERR.puts("\n#{__FILE__}:#{__LINE__}:#{self.class.name}.test_conversion_str2cy is skipped(Japanese locale is not installed)") - end - if WIN32OLE.locale == 0x0411 - obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY) - assert_equal("10000", obj.value) - end - ensure - WIN32OLE.locale = WIN32OLE::LOCALE_SYSTEM_DEFAULT + WIN32OLE.locale = 0x0411 # set locale Japanese + rescue WIN32OLERuntimeError + skip("Japanese locale is not installed") + end + if WIN32OLE.locale == 0x0411 + obj = WIN32OLE_VARIANT.new("\\10,000", WIN32OLE::VARIANT::VT_CY) + assert_equal("10000", obj.value) end end diff --git a/test/zlib/test_zlib.rb b/test/zlib/test_zlib.rb index 37781bc..529c3f4 100644 --- a/test/zlib/test_zlib.rb +++ b/test/zlib/test_zlib.rb @@ -195,6 +195,29 @@ if defined? Zlib z << "foo" # ??? end + def test_inflate_dictionary + dictionary = "foo" + + deflate = Zlib::Deflate.new + deflate.set_dictionary dictionary + compressed = deflate.deflate "foofoofoo", Zlib::FINISH + deflate.close + + out = nil + inflate = Zlib::Inflate.new + + begin + out = inflate.inflate compressed + + flunk "Zlib::NeedDict was not raised" + rescue Zlib::NeedDict + inflate.set_dictionary dictionary + out = inflate.inflate "" + end + + assert_equal "foofoofoo", out + end + def test_sync z = Zlib::Deflate.new s = z.deflate("foo" * 1000, Zlib::FULL_FLUSH) @@ -2,7 +2,7 @@ thread.c - - $Author: kosaki $ + $Author: usa $ Copyright (C) 2004-2007 Koichi Sasada @@ -42,6 +42,19 @@ */ +/* + * FD_SET, FD_CLR and FD_ISSET have a small sanity check when using glibc + * 2.15 or later and set _FORTIFY_SOURCE > 0. + * However, the implementation is wrong. Even though Linux's select(2) + * support large fd size (>FD_SETSIZE), it wrongly assume fd is always + * less than FD_SETSIZE (i.e. 1024). And then when enabling HAVE_RB_FD_INIT, + * it doesn't work correctly and makes program abort. Therefore we need to + * disable FORTY_SOURCE until glibc fixes it. + */ +#undef _FORTIFY_SOURCE +#undef __USE_FORTIFY_LEVEL +#define __USE_FORTIFY_LEVEL 0 + /* for model 2 */ #include "eval_intern.h" @@ -2161,7 +2174,7 @@ thread_keys_i(ID key, VALUE value, VALUE ary) static int vm_living_thread_num(rb_vm_t *vm) { - return vm->living_threads->num_entries; + return (int)vm->living_threads->num_entries; } int @@ -3532,6 +3545,13 @@ lock_interrupt(void *ptr) } /* + * At maximum, only one thread can use cond_timedwait and watch deadlock + * periodically. Multiple polling thread (i.e. concurrent deadlock check) + * introduces new race conditions. [Bug #6278] [ruby-core:44275] + */ +rb_thread_t *patrol_thread = NULL; + +/* * call-seq: * mutex.lock -> self * @@ -3568,14 +3588,20 @@ rb_mutex_lock(VALUE self) * vm->sleepr is unstable value. we have to avoid both deadlock * and busy loop. */ - if (vm_living_thread_num(th->vm) == th->vm->sleeper) { + if ((vm_living_thread_num(th->vm) == th->vm->sleeper) && + !patrol_thread) { timeout_ms = 100; + patrol_thread = th; } + GVL_UNLOCK_BEGIN(); interrupted = lock_func(th, mutex, timeout_ms); native_mutex_unlock(&mutex->lock); GVL_UNLOCK_END(); + if (patrol_thread == th) + patrol_thread = NULL; + reset_unblock_function(th, &oldubf); th->locking_mutex = Qfalse; @@ -3842,17 +3868,24 @@ recursive_list_access(void) static VALUE recursive_check(VALUE list, VALUE obj_id, VALUE paired_obj_id) { +#if SIZEOF_LONG == SIZEOF_VOIDP + #define OBJ_ID_EQL(obj_id, other) ((obj_id) == (other)) +#elif SIZEOF_LONG_LONG == SIZEOF_VOIDP + #define OBJ_ID_EQL(obj_id, other) (RB_TYPE_P((obj_id), T_BIGNUM) ? \ + rb_big_eql((obj_id), (other)) : ((obj_id) == (other))) +#endif + VALUE pair_list = rb_hash_lookup2(list, obj_id, Qundef); if (pair_list == Qundef) return Qfalse; if (paired_obj_id) { if (TYPE(pair_list) != T_HASH) { - if (pair_list != paired_obj_id) - return Qfalse; + if (!OBJ_ID_EQL(paired_obj_id, pair_list)) + return Qfalse; } else { - if (NIL_P(rb_hash_lookup(pair_list, paired_obj_id))) - return Qfalse; + if (NIL_P(rb_hash_lookup(pair_list, paired_obj_id))) + return Qfalse; } } return Qtrue; @@ -4040,7 +4073,7 @@ enum { EVENT_RUNNING_EVENT_MASK = EVENT_RUNNING_VM|EVENT_RUNNING_THREAD }; -static VALUE thread_suppress_tracing(rb_thread_t *th, int ev, VALUE (*func)(VALUE, int), VALUE arg, int always); +static VALUE thread_suppress_tracing(rb_thread_t *th, int ev, VALUE (*func)(VALUE, int), VALUE arg, int always, int pop_p); struct event_call_args { rb_thread_t *th; @@ -4179,7 +4212,7 @@ thread_exec_event_hooks(VALUE args, int running) } void -rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass) +rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass, int pop_p) { const VALUE errinfo = th->errinfo; struct event_call_args args; @@ -4189,7 +4222,7 @@ rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, args.id = id; args.klass = klass; args.proc = 0; - thread_suppress_tracing(th, EVENT_RUNNING_EVENT_MASK, thread_exec_event_hooks, (VALUE)&args, FALSE); + thread_suppress_tracing(th, EVENT_RUNNING_EVENT_MASK, thread_exec_event_hooks, (VALUE)&args, FALSE, pop_p); th->errinfo = errinfo; } @@ -4538,11 +4571,11 @@ VALUE ruby_suppress_tracing(VALUE (*func)(VALUE, int), VALUE arg, int always) { rb_thread_t *th = GET_THREAD(); - return thread_suppress_tracing(th, EVENT_RUNNING_TRACE, func, arg, always); + return thread_suppress_tracing(th, EVENT_RUNNING_TRACE, func, arg, always, 0); } static VALUE -thread_suppress_tracing(rb_thread_t *th, int ev, VALUE (*func)(VALUE, int), VALUE arg, int always) +thread_suppress_tracing(rb_thread_t *th, int ev, VALUE (*func)(VALUE, int), VALUE arg, int always, int pop_p) { int state, tracing = th->tracing, running = tracing & ev; volatile int raised; @@ -4572,6 +4605,9 @@ thread_suppress_tracing(rb_thread_t *th, int ev, VALUE (*func)(VALUE, int), VALU th->tracing = tracing; if (state) { + if (pop_p) { + th->cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(th->cfp); + } JUMP_TAG(state); } th->state = outer_state; @@ -4780,6 +4816,7 @@ rb_check_deadlock(rb_vm_t *vm) if (vm_living_thread_num(vm) > vm->sleeper) return; if (vm_living_thread_num(vm) < vm->sleeper) rb_bug("sleeper must not be more than vm_living_thread_num(vm)"); + if (patrol_thread && patrol_thread != GET_THREAD()) return; st_foreach(vm->living_threads, check_deadlock_i, (st_data_t)&found); diff --git a/thread_pthread.c b/thread_pthread.c index 2c826bc..eb1509e 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -3,7 +3,7 @@ thread_pthread.c - - $Author: naruse $ + $Author: usa $ Copyright (C) 2004-2007 Koichi Sasada @@ -24,6 +24,9 @@ #elif HAVE_SYS_FCNTL_H #include <sys/fcntl.h> #endif +#if defined(HAVE_SYS_TIME_H) +#include <sys/time.h> +#endif static void native_mutex_lock(pthread_mutex_t *lock); static void native_mutex_unlock(pthread_mutex_t *lock); @@ -140,6 +143,7 @@ gvl_init(rb_vm_t *vm) vm->gvl.acquired = 0; vm->gvl.waiting = 0; vm->gvl.need_yield = 0; + vm->gvl.wait_yield = 0; } static void @@ -248,6 +252,7 @@ native_cond_initialize(rb_thread_cond_t *cond, int flags) #endif r = pthread_cond_init(&cond->cond, &attr); + pthread_condattr_destroy(&attr); if (r != 0) { rb_bug_errno("pthread_cond_init", r); } @@ -477,41 +482,38 @@ get_stack(void **addr, size_t *size) { #define CHECK_ERR(expr) \ {int err = (expr); if (err) return err;} -#if defined HAVE_PTHREAD_GETATTR_NP || defined HAVE_PTHREAD_ATTR_GET_NP || \ - (defined HAVE_PTHREAD_GET_STACKADDR_NP && defined HAVE_PTHREAD_GET_STACKSIZE_NP) +#ifdef HAVE_PTHREAD_GETATTR_NP /* Linux */ pthread_attr_t attr; size_t guard = 0; - -# ifdef HAVE_PTHREAD_GETATTR_NP /* Linux */ STACK_GROW_DIR_DETECTION; CHECK_ERR(pthread_getattr_np(pthread_self(), &attr)); -# ifdef HAVE_PTHREAD_ATTR_GETSTACK +# ifdef HAVE_PTHREAD_ATTR_GETSTACK CHECK_ERR(pthread_attr_getstack(&attr, addr, size)); STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size)); -# else +# else CHECK_ERR(pthread_attr_getstackaddr(&attr, addr)); CHECK_ERR(pthread_attr_getstacksize(&attr, size)); -# endif -# elif defined HAVE_PTHREAD_ATTR_GET_NP /* FreeBSD, DragonFly BSD, NetBSD */ +# endif + CHECK_ERR(pthread_attr_getguardsize(&attr, &guard)); + *size -= guard; + pthread_attr_destroy(&attr); +#elif defined HAVE_PTHREAD_ATTR_GET_NP /* FreeBSD, DragonFly BSD, NetBSD */ + pthread_attr_t attr; CHECK_ERR(pthread_attr_init(&attr)); CHECK_ERR(pthread_attr_get_np(pthread_self(), &attr)); -# ifdef HAVE_PTHREAD_ATTR_GETSTACK +# ifdef HAVE_PTHREAD_ATTR_GETSTACK CHECK_ERR(pthread_attr_getstack(&attr, addr, size)); STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size)); -# else +# else CHECK_ERR(pthread_attr_getstackaddr(&attr, addr)); CHECK_ERR(pthread_attr_getstacksize(&attr, size)); STACK_DIR_UPPER((void)0, (void)(*addr = (char *)*addr + *size)); -# endif -# else /* MacOS X */ +# endif + pthread_attr_destroy(&attr); +#elif (defined HAVE_PTHREAD_GET_STACKADDR_NP && defined HAVE_PTHREAD_GET_STACKSIZE_NP) /* MacOS X */ pthread_t th = pthread_self(); *addr = pthread_get_stackaddr_np(th); *size = pthread_get_stacksize_np(th); - CHECK_ERR(pthread_attr_init(&attr)); -# endif - CHECK_ERR(pthread_attr_getguardsize(&attr, &guard)); - *size -= guard; - pthread_attr_destroy(&attr); #elif defined HAVE_THR_STKSEGMENT || defined HAVE_PTHREAD_STACKSEG_NP stack_t stk; # if defined HAVE_THR_STKSEGMENT /* Solaris */ @@ -581,16 +583,18 @@ ruby_init_stack(volatile VALUE *addr { size_t size = 0; size_t space = 0; -#if defined(HAVE_PTHREAD_ATTR_GET_NP) - void* addr; - get_stack(&addr, &size); +#if defined(STACKADDR_AVAILABLE) + void* stackaddr; + STACK_GROW_DIR_DETECTION; + get_stack(&stackaddr, &size); + space = STACK_DIR_UPPER((char *)addr - (char *)stackaddr, (char *)stackaddr - (char *)addr); #elif defined(HAVE_GETRLIMIT) struct rlimit rlim; if (getrlimit(RLIMIT_STACK, &rlim) == 0) { size = (size_t)rlim.rlim_cur; } -#endif space = size > 5 * 1024 * 1024 ? 1024 * 1024 : size / 5; +#endif native_main_thread.stack_maxsize = size - space; } } @@ -1310,7 +1314,7 @@ ruby_stack_overflowed_p(const rb_thread_t *th, const void *addr) } size /= 5; if (size > water_mark) size = water_mark; - if (STACK_DIR_UPPER(1, 0)) { + if (IS_STACK_DIR_UPPER()) { if (size > ~(size_t)base+1) size = ~(size_t)base+1; if (addr > base && addr <= (void *)((char *)base + size)) return 1; } @@ -2,7 +2,7 @@ time.c - - $Author: ayumin $ + $Author: usa $ created at: Tue Dec 28 14:31:59 JST 1993 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -27,6 +27,10 @@ #include <strings.h> #endif +#if defined(HAVE_SYS_TIME_H) +#include <sys/time.h> +#endif + #include "timev.h" static ID id_divmod, id_mul, id_submicro, id_nano_num, id_nano_den, id_offset; @@ -679,7 +683,9 @@ num_exact(VALUE v) default: if ((tmp = rb_check_funcall(v, rb_intern("to_r"), 0, NULL)) != Qundef) { - if (rb_respond_to(v, rb_intern("to_str"))) goto typeerror; + /* test to_int method availability to reject non-Numeric + * objects such as String, Time, etc which have to_r method. */ + if (!rb_respond_to(v, rb_intern("to_int"))) goto typeerror; v = tmp; break; } @@ -1803,10 +1809,11 @@ struct time_object { int tm_got; }; -#define GetTimeval(obj, tobj) \ - TypedData_Get_Struct((obj), struct time_object, &time_data_type, (tobj)) +#define GetTimeval(obj, tobj) ((tobj) = get_timeval(obj)) +#define GetNewTimeval(obj, tobj) ((tobj) = get_new_timeval(obj)) #define IsTimeval(obj) rb_typeddata_is_kind_of((obj), &time_data_type) +#define TIME_INIT_P(tobj) ((tobj)->gmt != -1) #define TIME_UTC_P(tobj) ((tobj)->gmt == 1) #define TIME_SET_UTC(tobj) ((tobj)->gmt = 1) @@ -1869,12 +1876,35 @@ time_s_alloc(VALUE klass) struct time_object *tobj; obj = TypedData_Make_Struct(klass, struct time_object, &time_data_type, tobj); + tobj->gmt = -1; tobj->tm_got=0; tobj->timew = WINT2FIXWV(0); return obj; } +static struct time_object * +get_timeval(VALUE obj) +{ + struct time_object *tobj; + TypedData_Get_Struct(obj, struct time_object, &time_data_type, tobj); + if (!TIME_INIT_P(tobj)) { + rb_raise(rb_eTypeError, "uninitialized %"PRIiVALUE, CLASS_OF(obj)); + } + return tobj; +} + +static struct time_object * +get_new_timeval(VALUE obj) +{ + struct time_object *tobj; + TypedData_Get_Struct(obj, struct time_object, &time_data_type, tobj); + if (TIME_INIT_P(tobj)) { + rb_raise(rb_eTypeError, "already initialized %"PRIiVALUE, CLASS_OF(obj)); + } + return tobj; +} + static void time_modify(VALUE time) { @@ -1941,7 +1971,8 @@ time_init_0(VALUE time) struct timespec ts; time_modify(time); - GetTimeval(time, tobj); + GetNewTimeval(time, tobj); + tobj->gmt = 0; tobj->tm_got=0; tobj->timew = WINT2FIXWV(0); #ifdef HAVE_CLOCK_GETTIME @@ -2182,7 +2213,8 @@ time_init_1(int argc, VALUE *argv, VALUE time) validate_vtm(&vtm); time_modify(time); - GetTimeval(time, tobj); + GetNewTimeval(time, tobj); + tobj->gmt = 0; tobj->tm_got=0; tobj->timew = WINT2FIXWV(0); @@ -2298,7 +2330,8 @@ time_new_timew(VALUE klass, wideval_t timew) VALUE time = time_s_alloc(klass); struct time_object *tobj; - GetTimeval(time, tobj); + tobj = DATA_PTR(time); /* skip type check */ + tobj->gmt = 0; tobj->timew = timew; return time; @@ -3424,7 +3457,7 @@ time_init_copy(VALUE copy, VALUE time) if (copy == time) return copy; time_modify(copy); GetTimeval(time, tobj); - GetTimeval(copy, tcopy); + GetNewTimeval(copy, tcopy); MEMCPY(tcopy, tobj, struct time_object, 1); return copy; @@ -4801,7 +4834,8 @@ end_submicro: ; timew = timegmw(&vtm); } - GetTimeval(time, tobj); + GetNewTimeval(time, tobj); + tobj->gmt = 0; tobj->tm_got = 0; tobj->timew = timew; if (gmt) { diff --git a/tool/mkconfig.rb b/tool/mkconfig.rb index b707c4b..6d87511 100755 --- a/tool/mkconfig.rb +++ b/tool/mkconfig.rb @@ -39,6 +39,7 @@ win32 = /mswin/ =~ arch universal = /universal.*darwin/ =~ arch v_fast = [] v_others = [] +v_runtime = {} vars = {} continued_name = nil continued_line = nil @@ -112,8 +113,15 @@ File.foreach "config.status" do |line| end end if name == "configure_args" - val.gsub!(/ +(?!-)/, "=") if win32 + if win32 + val.gsub!(/\G(--[-a-z0-9]+)((=\S+)|(?:\s+(?!-)\S+)+)?(\s*)/) { + _, opt, list, arg, sep = *$~ + "#{opt}#{arg || list && list.sub(/^\s+/, '=').tr_s(' ', ',')}#{sep}" + } + end val.gsub!(/--with-out-ext/, "--without-ext") + elsif name == "libdir" + v_runtime[:libdir] = val[/\$(\(exec_prefix\)|\{exec_prefix\})\/(.*)/, 2] end val = val.gsub(/\$(?:\$|\{?(\w+)\}?)/) {$1 ? "$(#{$1})" : $&}.dump case name @@ -145,7 +153,7 @@ end drive = File::PATH_SEPARATOR == ';' -prefix = "/lib/ruby/#{version}/#{arch}" +prefix = "/#{v_runtime[:libdir] || 'lib'}/ruby/#{version}/#{arch}" print " TOPDIR = File.dirname(__FILE__).chomp!(#{prefix.dump})\n" print " DESTDIR = ", (drive ? "TOPDIR && TOPDIR[/\\A[a-z]:/i] || " : ""), "'' unless defined? DESTDIR\n" print <<'ARCH' if universal diff --git a/tool/ytab.sed b/tool/ytab.sed index f956c06..46317db 100755 --- a/tool/ytab.sed +++ b/tool/ytab.sed @@ -5,6 +5,12 @@ i\ a\ #endif } +/^extern int yydebug;/{ +i\ +#ifndef yydebug +a\ +#endif +} /^yydestruct.*yymsg/,/#endif/{ /^yydestruct/{ /parser/!{ diff --git a/transcode.c b/transcode.c index 0ff6877..adf7f2c 100644 --- a/transcode.c +++ b/transcode.c @@ -2,7 +2,7 @@ transcode.c - - $Author: naruse $ + $Author: usa $ created at: Tue Oct 30 16:10:22 JST 2007 Copyright (C) 2007 Martin Duerst @@ -2805,6 +2805,10 @@ str_encode_bang(int argc, VALUE *argv, VALUE str) encidx = str_transcode(argc, argv, &newstr); if (encidx < 0) return str; + if (newstr == str) { + rb_enc_associate_index(str, encidx); + return str; + } rb_str_shared_replace(str, newstr); return str_encode_associate(str, encidx); } @@ -2831,6 +2835,10 @@ static VALUE encoded_dup(VALUE newstr, VALUE str, int encidx); * in the source encoding. The last form by default does not raise * exceptions but uses replacement strings. * + * Please note that conversion from an encoding +enc+ to the + * same encoding +enc+ is a no-op, i.e. the receiver is returned without + * any changes, and no exceptions are raised, even if there are invalid bytes. + * * The +options+ Hash gives details for conversion and can have the following * keys: * @@ -2891,6 +2899,8 @@ encoded_dup(VALUE newstr, VALUE str, int encidx) if (encidx < 0) return rb_str_dup(str); if (newstr == str) { newstr = rb_str_dup(str); + rb_enc_associate_index(newstr, encidx); + return newstr; } else { RBASIC(newstr)->klass = rb_obj_class(str); @@ -2,7 +2,7 @@ util.c - - $Author: kosaki $ + $Author: usa $ created at: Fri Mar 10 17:22:34 JST 1995 Copyright (C) 1993-2008 Yukihiro Matsumoto @@ -184,184 +184,6 @@ ruby_strtoul(const char *str, char **endptr, int base) # define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) #endif -#if defined(__CYGWIN32__) || defined(_WIN32) -/* - * Copyright (c) 1993, Intergraph Corporation - * - * You may distribute under the terms of either the GNU General Public - * License or the Artistic License, as specified in the perl README file. - * - * Various Unix compatibility functions and NT specific functions. - * - * Some of this code was derived from the MSDOS port(s) and the OS/2 port. - * - */ - - -/* - * Suffix appending for in-place editing under MS-DOS and OS/2 (and now NT!). - * - * Here are the rules: - * - * Style 0: Append the suffix exactly as standard perl would do it. - * If the filesystem groks it, use it. (HPFS will always - * grok it. So will NTFS. FAT will rarely accept it.) - * - * Style 1: The suffix begins with a '.'. The extension is replaced. - * If the name matches the original name, use the fallback method. - * - * Style 2: The suffix is a single character, not a '.'. Try to add the - * suffix to the following places, using the first one that works. - * [1] Append to extension. - * [2] Append to filename, - * [3] Replace end of extension, - * [4] Replace end of filename. - * If the name matches the original name, use the fallback method. - * - * Style 3: Any other case: Ignore the suffix completely and use the - * fallback method. - * - * Fallback method: Change the extension to ".$$$". If that matches the - * original name, then change the extension to ".~~~". - * - * If filename is more than 1000 characters long, we die a horrible - * death. Sorry. - * - * The filename restriction is a cheat so that we can use buf[] to store - * assorted temporary goo. - * - * Examples, assuming style 0 failed. - * - * suffix = ".bak" (style 1) - * foo.bar => foo.bak - * foo.bak => foo.$$$ (fallback) - * makefile => makefile.bak - * suffix = ".$$$" (style 1) - * foo.$$$ => foo.~~~ (fallback) - * - * suffix = "~" (style 2) - * foo.c => foo.c~ - * foo.c~ => foo.c~~ - * foo.c~~ => foo~.c~~ - * foo~.c~~ => foo~~.c~~ - * foo~~~~~.c~~ => foo~~~~~.$$$ (fallback) - * - * foo.pas => foo~.pas - * makefile => makefile.~ - * longname.fil => longname.fi~ - * longname.fi~ => longnam~.fi~ - * longnam~.fi~ => longnam~.$$$ - * - */ - - -static int valid_filename(const char *s); - -static const char suffix1[] = ".$$$"; -static const char suffix2[] = ".~~~"; - -#define strEQ(s1,s2) (strcmp((s1),(s2)) == 0) - -void -ruby_add_suffix(VALUE str, const char *suffix) -{ - long baselen; - long extlen = strlen(suffix); - long slen; - char buf[1024]; - const char *name; - const char *ext; - long len; - - name = StringValueCStr(str); - slen = strlen(name); - if (slen > (long)(sizeof(buf) - 1)) - rb_fatal("Cannot do inplace edit on long filename (%ld characters)", - slen); - - /* Style 0 */ - rb_str_cat(str, suffix, extlen); - if (valid_filename(RSTRING_PTR(str))) return; - - /* Fooey, style 0 failed. Fix str before continuing. */ - rb_str_resize(str, slen); - name = StringValueCStr(str); - ext = ruby_find_extname(name, &len); - - if (*suffix == '.') { /* Style 1 */ - if (ext) { - if (strEQ(ext, suffix)) { - extlen = sizeof(suffix1) - 1; /* suffix2 must be same length */ - suffix = strEQ(suffix, suffix1) ? suffix2 : suffix1; - } - slen = ext - name; - } - rb_str_resize(str, slen); - rb_str_cat(str, suffix, extlen); - } - else { - char *p = buf, *q; - strncpy(buf, name, slen); - if (ext) - p += (ext - name); - else - p += slen; - p[len] = '\0'; - if (suffix[1] == '\0') { /* Style 2 */ - q = (char *)ruby_find_basename(buf, &baselen, 0); - if (len <= 3) { - if (len == 0 && baselen >= 8 && p + 3 <= buf + sizeof(buf)) p[len++] = '.'; /* DOSISH */ - p[len] = *suffix; - p[++len] = '\0'; - } - else if (q && baselen < 8) { - q += baselen; - *q++ = *suffix; - if (ext) { - strncpy(q, ext, ext - name); - q[ext - name + 1] = '\0'; - } - else - *q = '\0'; - } - else if (len == 4 && p[3] != *suffix) - p[3] = *suffix; - else if (baselen == 8 && q[7] != *suffix) - q[7] = *suffix; - else - goto fallback; - } - else { /* Style 3: Panic */ - fallback: - (void)memcpy(p, !ext || strEQ(ext, suffix1) ? suffix2 : suffix1, 5); - } - rb_str_resize(str, strlen(buf)); - memcpy(RSTRING_PTR(str), buf, RSTRING_LEN(str)); - } -} - -static int -valid_filename(const char *s) -{ - int fd; - - /* - // It doesn't exist, so see if we can open it. - */ - - if ((fd = open(s, O_CREAT|O_EXCL, 0666)) >= 0) { - close(fd); - unlink(s); /* don't leave it laying around */ - return 1; - } - else if (errno == EEXIST) { - /* if the file exists, then it's a valid filename! */ - return 1; - } - return 0; -} -#endif - /* mm.c */ @@ -1,10 +1,10 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 194 +#define RUBY_PATCHLEVEL 448 -#define RUBY_RELEASE_DATE "2012-04-20" -#define RUBY_RELEASE_YEAR 2012 -#define RUBY_RELEASE_MONTH 4 -#define RUBY_RELEASE_DAY 20 +#define RUBY_RELEASE_DATE "2013-06-27" +#define RUBY_RELEASE_YEAR 2013 +#define RUBY_RELEASE_MONTH 6 +#define RUBY_RELEASE_DAY 27 #include "ruby/version.h" @@ -2,7 +2,7 @@ vm.c - - $Author: naruse $ + $Author: usa $ Copyright (C) 2004-2007 Koichi Sasada @@ -424,8 +424,6 @@ vm_make_env_each(rb_thread_t * const th, rb_control_frame_t * const cfp, if (!RUBY_VM_NORMAL_ISEQ_P(cfp->iseq)) { /* TODO */ env->block.iseq = 0; - } else { - rb_vm_rewrite_dfp_in_errinfo(th, cfp); } return envval; } @@ -469,17 +467,41 @@ vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary) } } +static VALUE vm_make_proc_from_block(rb_thread_t *th, rb_block_t *block); +static VALUE vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp, VALUE *blockprocptr); + VALUE rb_vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp) { + VALUE blockprocval; + return vm_make_env_object(th, cfp, &blockprocval); +} + +static VALUE +vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp, VALUE *blockprocptr) +{ VALUE envval; + VALUE *lfp; + rb_block_t *blockptr; if (VM_FRAME_TYPE(cfp) == VM_FRAME_MAGIC_FINISH) { /* for method_missing */ cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } + lfp = cfp->lfp; + blockptr = GC_GUARDED_PTR_REF(lfp[0]); + + if (blockptr && !(lfp[0] & 0x02)) { + VALUE blockprocval = vm_make_proc_from_block(th, blockptr); + rb_proc_t *p; + GetProcPtr(blockprocval, p); + lfp[0] = GC_GUARDED_PTR(&p->block); + *blockprocptr = blockprocval; + } + envval = vm_make_env_each(th, cfp, cfp->dfp, cfp->lfp); + rb_vm_rewrite_dfp_in_errinfo(th); if (PROCDEBUG) { check_env_value(envval); @@ -489,24 +511,28 @@ rb_vm_make_env_object(rb_thread_t * th, rb_control_frame_t *cfp) } void -rb_vm_rewrite_dfp_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp) -{ - /* rewrite dfp in errinfo to point to heap */ - if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) && - (cfp->iseq->type == ISEQ_TYPE_RESCUE || - cfp->iseq->type == ISEQ_TYPE_ENSURE)) { - VALUE errinfo = cfp->dfp[-2]; /* #$! */ - if (RB_TYPE_P(errinfo, T_NODE)) { - VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(errinfo); - if (! ENV_IN_HEAP_P(th, escape_dfp)) { - VALUE dfpval = *escape_dfp; - if (CLASS_OF(dfpval) == rb_cEnv) { - rb_env_t *dfpenv; - GetEnvPtr(dfpval, dfpenv); - SET_THROWOBJ_CATCH_POINT(errinfo, (VALUE)(dfpenv->env + dfpenv->local_size)); +rb_vm_rewrite_dfp_in_errinfo(rb_thread_t *th) +{ + rb_control_frame_t *cfp = th->cfp; + while (!RUBY_VM_CONTROL_FRAME_STACK_OVERFLOW_P(th, cfp)) { + /* rewrite dfp in errinfo to point to heap */ + if (RUBY_VM_NORMAL_ISEQ_P(cfp->iseq) && + (cfp->iseq->type == ISEQ_TYPE_RESCUE || + cfp->iseq->type == ISEQ_TYPE_ENSURE)) { + VALUE errinfo = cfp->dfp[-2]; /* #$! */ + if (RB_TYPE_P(errinfo, T_NODE)) { + VALUE *escape_dfp = GET_THROWOBJ_CATCH_POINT(errinfo); + if (! ENV_IN_HEAP_P(th, escape_dfp)) { + VALUE dfpval = *escape_dfp; + if (CLASS_OF(dfpval) == rb_cEnv) { + rb_env_t *dfpenv; + GetEnvPtr(dfpval, dfpenv); + SET_THROWOBJ_CATCH_POINT(errinfo, (VALUE)(dfpenv->env + dfpenv->local_size)); + } } } } + cfp = RUBY_VM_PREVIOUS_CONTROL_FRAME(cfp); } } @@ -542,17 +568,7 @@ rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass) rb_bug("rb_vm_make_proc: Proc value is already created."); } - if (GC_GUARDED_PTR_REF(cfp->lfp[0])) { - rb_proc_t *p; - - blockprocval = vm_make_proc_from_block( - th, (rb_block_t *)GC_GUARDED_PTR_REF(*cfp->lfp)); - - GetProcPtr(blockprocval, p); - *cfp->lfp = GC_GUARDED_PTR(&p->block); - } - - envval = rb_vm_make_env_object(th, cfp); + envval = vm_make_env_object(th, cfp, &blockprocval); if (PROCDEBUG) { check_env_value(envval); @@ -996,7 +1012,7 @@ rb_vm_jump_tag_but_local_jump(int state, VALUE val) { if (val != Qnil) { VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, val); - rb_exc_raise(exc); + if (!NIL_P(exc)) rb_exc_raise(exc); } JUMP_TAG(state); } @@ -1354,6 +1370,7 @@ vm_exec(rb_thread_t *th) *th->cfp->sp++ = (GET_THROWOBJ_VAL(err)); #endif } + th->state = 0; th->errinfo = Qnil; goto vm_loop_start; } @@ -1408,10 +1425,10 @@ vm_exec(rb_thread_t *th) switch (VM_FRAME_TYPE(th->cfp)) { case VM_FRAME_MAGIC_METHOD: - EXEC_EVENT_HOOK(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_RETURN, th->cfp->self, 0, 0); break; case VM_FRAME_MAGIC_CLASS: - EXEC_EVENT_HOOK(th, RUBY_EVENT_END, th->cfp->self, 0, 0); + EXEC_EVENT_HOOK_AND_POP_FRAME(th, RUBY_EVENT_END, th->cfp->self, 0, 0); break; } @@ -2092,6 +2109,8 @@ Init_VM(void) rb_define_method_id(klass, id_core_define_method, m_core_define_method, 3); rb_define_method_id(klass, id_core_define_singleton_method, m_core_define_singleton_method, 3); rb_define_method_id(klass, id_core_set_postexe, m_core_set_postexe, 1); + rb_define_method_id(klass, idProc, rb_block_proc, 0); + rb_define_method_id(klass, idLambda, rb_block_lambda, 0); rb_obj_freeze(fcore); rb_gc_register_mark_object(fcore); rb_mRubyVMFrozenCore = fcore; @@ -88,7 +88,7 @@ INSN_ENTRY(getspecial){ { VALUE val; rb_num_t type = (rb_num_t)GET_OPERAND(2); - VALUE key = (VALUE)GET_OPERAND(1); + rb_num_t key = (rb_num_t)GET_OPERAND(1); DEBUG_ENTER_INSN("getspecial"); ADD_PC(1+2); @@ -114,7 +114,7 @@ INSN_ENTRY(getspecial){ END_INSN(getspecial);}}} INSN_ENTRY(setspecial){ { - VALUE key = (VALUE)GET_OPERAND(1); + rb_num_t key = (rb_num_t)GET_OPERAND(1); VALUE obj = TOPN(0); DEBUG_ENTER_INSN("setspecial"); ADD_PC(1+1); @@ -795,7 +795,7 @@ INSN_ENTRY(concatarray){ INSN_ENTRY(splatarray){ { VALUE obj; - + VALUE flag = (VALUE)GET_OPERAND(1); VALUE ary = TOPN(0); DEBUG_ENTER_INSN("splatarray"); ADD_PC(1+1); @@ -813,9 +813,12 @@ INSN_ENTRY(splatarray){ if (NIL_P(tmp)) { tmp = rb_ary_new3(1, ary); } + else if (RTEST(flag)) { + tmp = rb_ary_dup(tmp); + } obj = tmp; -#line 819 "vm.inc" +#line 822 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(obj); #undef CURRENT_INSN_splatarray @@ -840,7 +843,7 @@ INSN_ENTRY(checkincludearray){ USAGE_ANALYSIS_INSN(BIN(checkincludearray)); USAGE_ANALYSIS_OPERAND(BIN(checkincludearray), 0, flag); { -#line 550 "insns.def" +#line 553 "insns.def" int i; result = Qfalse; @@ -869,7 +872,7 @@ INSN_ENTRY(checkincludearray){ } } -#line 873 "vm.inc" +#line 876 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 2); PUSH(obj); PUSH(result); @@ -893,7 +896,7 @@ INSN_ENTRY(newhash){ USAGE_ANALYSIS_INSN(BIN(newhash)); USAGE_ANALYSIS_OPERAND(BIN(newhash), 0, num); { -#line 591 "insns.def" +#line 594 "insns.def" rb_num_t i; val = rb_hash_new(); @@ -904,7 +907,7 @@ INSN_ENTRY(newhash){ } POPN(num); -#line 908 "vm.inc" +#line 911 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_newhash @@ -929,10 +932,10 @@ INSN_ENTRY(newrange){ USAGE_ANALYSIS_INSN(BIN(newrange)); USAGE_ANALYSIS_OPERAND(BIN(newrange), 0, flag); { -#line 613 "insns.def" +#line 616 "insns.def" val = rb_range_new(low, high, (int)flag); -#line 936 "vm.inc" +#line 939 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_newrange @@ -954,11 +957,11 @@ INSN_ENTRY(pop){ #define LABEL_IS_SC(lab) LABEL_##lab##_##t USAGE_ANALYSIS_INSN(BIN(pop)); { -#line 631 "insns.def" - val = val; +#line 634 "insns.def" + (void)val; /* none */ -#line 962 "vm.inc" +#line 965 "vm.inc" #undef CURRENT_INSN_pop #undef INSN_IS_SC #undef INSN_LABEL @@ -980,10 +983,10 @@ INSN_ENTRY(dup){ #define LABEL_IS_SC(lab) LABEL_##lab##_##t USAGE_ANALYSIS_INSN(BIN(dup)); { -#line 646 "insns.def" +#line 649 "insns.def" val1 = val2 = val; -#line 987 "vm.inc" +#line 990 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 2); PUSH(val1); PUSH(val2); @@ -1006,7 +1009,7 @@ INSN_ENTRY(dupn){ USAGE_ANALYSIS_INSN(BIN(dupn)); USAGE_ANALYSIS_OPERAND(BIN(dupn), 0, n); { -#line 660 "insns.def" +#line 663 "insns.def" rb_num_t i; VALUE *sp = STACK_ADDR_FROM_TOP(n); for (i = 0; i < n; i++) { @@ -1014,7 +1017,7 @@ INSN_ENTRY(dupn){ } INC_SP(n); -#line 1018 "vm.inc" +#line 1021 "vm.inc" #undef CURRENT_INSN_dupn #undef INSN_IS_SC #undef INSN_LABEL @@ -1035,10 +1038,10 @@ INSN_ENTRY(swap){ #define LABEL_IS_SC(lab) LABEL_##lab##_##t USAGE_ANALYSIS_INSN(BIN(swap)); { -#line 680 "insns.def" +#line 683 "insns.def" /* none */ -#line 1042 "vm.inc" +#line 1045 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 2); PUSH(obj); PUSH(val); @@ -1061,10 +1064,10 @@ INSN_ENTRY(reput){ #define LABEL_IS_SC(lab) LABEL_##lab##_##t USAGE_ANALYSIS_INSN(BIN(reput)); { -#line 694 "insns.def" +#line 697 "insns.def" /* none */ -#line 1068 "vm.inc" +#line 1071 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_reput @@ -1087,10 +1090,10 @@ INSN_ENTRY(topn){ USAGE_ANALYSIS_INSN(BIN(topn)); USAGE_ANALYSIS_OPERAND(BIN(topn), 0, n); { -#line 708 "insns.def" +#line 711 "insns.def" val = TOPN(n); -#line 1094 "vm.inc" +#line 1097 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_topn @@ -1113,10 +1116,10 @@ INSN_ENTRY(setn){ USAGE_ANALYSIS_INSN(BIN(setn)); USAGE_ANALYSIS_OPERAND(BIN(setn), 0, n); { -#line 722 "insns.def" +#line 725 "insns.def" TOPN(n-1) = val; -#line 1120 "vm.inc" +#line 1123 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_setn @@ -1138,10 +1141,10 @@ INSN_ENTRY(adjuststack){ USAGE_ANALYSIS_INSN(BIN(adjuststack)); USAGE_ANALYSIS_OPERAND(BIN(adjuststack), 0, n); { -#line 736 "insns.def" +#line 739 "insns.def" DEC_SP(n); -#line 1145 "vm.inc" +#line 1148 "vm.inc" #undef CURRENT_INSN_adjuststack #undef INSN_IS_SC #undef INSN_LABEL @@ -1167,7 +1170,7 @@ INSN_ENTRY(defined){ USAGE_ANALYSIS_OPERAND(BIN(defined), 1, obj); USAGE_ANALYSIS_OPERAND(BIN(defined), 2, needstr); { -#line 755 "insns.def" +#line 758 "insns.def" VALUE klass; const char *expr_type = 0; enum defined_type type = (enum defined_type)op_type; @@ -1274,7 +1277,7 @@ INSN_ENTRY(defined){ } } -#line 1278 "vm.inc" +#line 1281 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_defined @@ -1296,12 +1299,12 @@ INSN_ENTRY(trace){ USAGE_ANALYSIS_INSN(BIN(trace)); USAGE_ANALYSIS_OPERAND(BIN(trace), 0, nf); { -#line 873 "insns.def" +#line 876 "insns.def" rb_event_flag_t flag = (rb_event_flag_t)nf; EXEC_EVENT_HOOK(th, flag, GET_SELF(), 0, 0 /* TODO: id, klass */); -#line 1305 "vm.inc" +#line 1308 "vm.inc" #undef CURRENT_INSN_trace #undef INSN_IS_SC #undef INSN_LABEL @@ -1328,7 +1331,7 @@ INSN_ENTRY(defineclass){ USAGE_ANALYSIS_OPERAND(BIN(defineclass), 1, class_iseq); USAGE_ANALYSIS_OPERAND(BIN(defineclass), 2, define_type); { -#line 897 "insns.def" +#line 900 "insns.def" VALUE klass; switch ((int)define_type) { @@ -1412,7 +1415,7 @@ INSN_ENTRY(defineclass){ INC_VM_STATE_VERSION(); NEXT_INSN(); -#line 1416 "vm.inc" +#line 1419 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_defineclass @@ -1443,7 +1446,7 @@ INSN_ENTRY(send){ USAGE_ANALYSIS_OPERAND(BIN(send), 3, op_flag); USAGE_ANALYSIS_OPERAND(BIN(send), 4, ic); { -#line 1003 "insns.def" +#line 1006 "insns.def" const rb_method_entry_t *me; VALUE recv, klass; rb_block_t *blockptr = 0; @@ -1458,7 +1461,7 @@ INSN_ENTRY(send){ me = vm_method_search(id, klass, ic); CALL_METHOD(num, blockptr, flag, id, me, recv); -#line 1462 "vm.inc" +#line 1465 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_send @@ -1485,7 +1488,7 @@ INSN_ENTRY(invokesuper){ USAGE_ANALYSIS_OPERAND(BIN(invokesuper), 1, blockiseq); USAGE_ANALYSIS_OPERAND(BIN(invokesuper), 2, op_flag); { -#line 1031 "insns.def" +#line 1034 "insns.def" rb_block_t *blockptr = !(op_flag & VM_CALL_ARGS_BLOCKARG_BIT) ? GET_BLOCK_PTR() : 0; VALUE flag = op_flag; int num = caller_setup_args(th, GET_CFP(), flag, @@ -1508,7 +1511,7 @@ INSN_ENTRY(invokesuper){ CALL_METHOD(num, blockptr, flag, id, me, recv); -#line 1512 "vm.inc" +#line 1515 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_invokesuper @@ -1533,14 +1536,14 @@ INSN_ENTRY(invokeblock){ USAGE_ANALYSIS_OPERAND(BIN(invokeblock), 0, num); USAGE_ANALYSIS_OPERAND(BIN(invokeblock), 1, flag); { -#line 1066 "insns.def" +#line 1069 "insns.def" val = vm_invoke_block(th, GET_CFP(), num, flag); if (val == Qundef) { RESTORE_REGS(); NEXT_INSN(); } -#line 1544 "vm.inc" +#line 1547 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_invokeblock @@ -1562,7 +1565,7 @@ INSN_ENTRY(leave){ #define LABEL_IS_SC(lab) LABEL_##lab##_##t USAGE_ANALYSIS_INSN(BIN(leave)); { -#line 1084 "insns.def" +#line 1087 "insns.def" if (OPT_CHECKED_RUN) { if (reg_cfp->sp != reg_cfp->bp) { rb_bug("Stack consistency error (sp: %"PRIdPTRDIFF", bp: %"PRIdPTRDIFF")", @@ -1574,7 +1577,7 @@ INSN_ENTRY(leave){ vm_pop_frame(th); RESTORE_REGS(); -#line 1578 "vm.inc" +#line 1581 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_leave @@ -1596,7 +1599,7 @@ INSN_ENTRY(finish){ #define LABEL_IS_SC(lab) LABEL_##lab##_##t USAGE_ANALYSIS_INSN(BIN(finish)); { -#line 1107 "insns.def" +#line 1110 "insns.def" #if OPT_CALL_THREADED_CODE rb_bug("unused instruction on OPT_CALL_THREADED_CODE"); #else @@ -1604,7 +1607,7 @@ INSN_ENTRY(finish){ return val; #endif -#line 1608 "vm.inc" +#line 1611 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_finish @@ -1628,13 +1631,13 @@ INSN_ENTRY(throw){ USAGE_ANALYSIS_INSN(BIN(throw)); USAGE_ANALYSIS_OPERAND(BIN(throw), 0, throw_state); { -#line 1130 "insns.def" +#line 1133 "insns.def" RUBY_VM_CHECK_INTS(); val = vm_throw(th, GET_CFP(), throw_state, throwobj); THROW_EXCEPTION(val); /* unreachable */ -#line 1638 "vm.inc" +#line 1641 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_throw @@ -1656,11 +1659,11 @@ INSN_ENTRY(jump){ USAGE_ANALYSIS_INSN(BIN(jump)); USAGE_ANALYSIS_OPERAND(BIN(jump), 0, dst); { -#line 1151 "insns.def" +#line 1154 "insns.def" RUBY_VM_CHECK_INTS(); JUMP(dst); -#line 1664 "vm.inc" +#line 1667 "vm.inc" #undef CURRENT_INSN_jump #undef INSN_IS_SC #undef INSN_LABEL @@ -1681,13 +1684,13 @@ INSN_ENTRY(branchif){ USAGE_ANALYSIS_INSN(BIN(branchif)); USAGE_ANALYSIS_OPERAND(BIN(branchif), 0, dst); { -#line 1166 "insns.def" +#line 1169 "insns.def" if (RTEST(val)) { RUBY_VM_CHECK_INTS(); JUMP(dst); } -#line 1691 "vm.inc" +#line 1694 "vm.inc" #undef CURRENT_INSN_branchif #undef INSN_IS_SC #undef INSN_LABEL @@ -1708,13 +1711,13 @@ INSN_ENTRY(branchunless){ USAGE_ANALYSIS_INSN(BIN(branchunless)); USAGE_ANALYSIS_OPERAND(BIN(branchunless), 0, dst); { -#line 1183 "insns.def" +#line 1186 "insns.def" if (!RTEST(val)) { RUBY_VM_CHECK_INTS(); JUMP(dst); } -#line 1718 "vm.inc" +#line 1721 "vm.inc" #undef CURRENT_INSN_branchunless #undef INSN_IS_SC #undef INSN_LABEL @@ -1737,7 +1740,7 @@ INSN_ENTRY(getinlinecache){ USAGE_ANALYSIS_OPERAND(BIN(getinlinecache), 0, dst); USAGE_ANALYSIS_OPERAND(BIN(getinlinecache), 1, ic); { -#line 1205 "insns.def" +#line 1208 "insns.def" if (ic->ic_vmstat == GET_VM_STATE_VERSION()) { val = ic->ic_value.value; JUMP(dst); @@ -1747,7 +1750,7 @@ INSN_ENTRY(getinlinecache){ val = Qnil; } -#line 1751 "vm.inc" +#line 1754 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_getinlinecache @@ -1772,7 +1775,7 @@ INSN_ENTRY(onceinlinecache){ USAGE_ANALYSIS_OPERAND(BIN(onceinlinecache), 0, dst); USAGE_ANALYSIS_OPERAND(BIN(onceinlinecache), 1, ic); { -#line 1226 "insns.def" +#line 1229 "insns.def" retry: if (ic->ic_vmstat) { val = ic->ic_value.value; @@ -1790,7 +1793,7 @@ INSN_ENTRY(onceinlinecache){ val = Qnil; } -#line 1794 "vm.inc" +#line 1797 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_onceinlinecache @@ -1813,7 +1816,7 @@ INSN_ENTRY(setinlinecache){ USAGE_ANALYSIS_INSN(BIN(setinlinecache)); USAGE_ANALYSIS_OPERAND(BIN(setinlinecache), 0, ic); { -#line 1255 "insns.def" +#line 1258 "insns.def" if (ic->ic_value.value == Qundef) { rb_ary_push(GET_ISEQ()->mark_ary, val); } @@ -1821,7 +1824,7 @@ INSN_ENTRY(setinlinecache){ ic->ic_vmstat = GET_VM_STATE_VERSION() - ruby_vm_const_missing_count; ruby_vm_const_missing_count = 0; -#line 1825 "vm.inc" +#line 1828 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_setinlinecache @@ -1846,7 +1849,7 @@ INSN_ENTRY(opt_case_dispatch){ USAGE_ANALYSIS_OPERAND(BIN(opt_case_dispatch), 0, hash); USAGE_ANALYSIS_OPERAND(BIN(opt_case_dispatch), 1, else_offset); { -#line 1274 "insns.def" +#line 1277 "insns.def" switch(TYPE(key)) { case T_FLOAT: { double ival; @@ -1872,7 +1875,7 @@ INSN_ENTRY(opt_case_dispatch){ break; } -#line 1876 "vm.inc" +#line 1879 "vm.inc" #undef CURRENT_INSN_opt_case_dispatch #undef INSN_IS_SC #undef INSN_LABEL @@ -1891,7 +1894,7 @@ INSN_ENTRY(opt_checkenv){ #define LABEL_IS_SC(lab) LABEL_##lab##_##t USAGE_ANALYSIS_INSN(BIN(opt_checkenv)); { -#line 1311 "insns.def" +#line 1314 "insns.def" if (GET_CFP()->bp != GET_DFP() + 1) { VALUE *new_dfp = GET_CFP()->bp - 1; /* TODO: copy env and clean stack at creating env? */ @@ -1899,7 +1902,7 @@ INSN_ENTRY(opt_checkenv){ SET_DFP(new_dfp); } -#line 1903 "vm.inc" +#line 1906 "vm.inc" #undef CURRENT_INSN_opt_checkenv #undef INSN_IS_SC #undef INSN_LABEL @@ -1922,7 +1925,7 @@ INSN_ENTRY(opt_plus){ USAGE_ANALYSIS_INSN(BIN(opt_plus)); USAGE_ANALYSIS_OPERAND(BIN(opt_plus), 0, ic); { -#line 1333 "insns.def" +#line 1336 "insns.def" if (0) { } @@ -1987,7 +1990,7 @@ INSN_ENTRY(opt_plus){ CALL_SIMPLE_METHOD(1, idPLUS, recv); } -#line 1991 "vm.inc" +#line 1994 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_plus @@ -2012,7 +2015,7 @@ INSN_ENTRY(opt_minus){ USAGE_ANALYSIS_INSN(BIN(opt_minus)); USAGE_ANALYSIS_OPERAND(BIN(opt_minus), 0, ic); { -#line 1409 "insns.def" +#line 1412 "insns.def" if (FIXNUM_2_P(recv, obj) && BASIC_OP_UNREDEFINED_P(BOP_MINUS)) { long a, b, c; @@ -2050,7 +2053,7 @@ INSN_ENTRY(opt_minus){ CALL_SIMPLE_METHOD(1, idMINUS, recv); } -#line 2054 "vm.inc" +#line 2057 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_minus @@ -2075,7 +2078,7 @@ INSN_ENTRY(opt_mult){ USAGE_ANALYSIS_INSN(BIN(opt_mult)); USAGE_ANALYSIS_OPERAND(BIN(opt_mult), 0, ic); { -#line 1458 "insns.def" +#line 1461 "insns.def" if (FIXNUM_2_P(recv, obj) && BASIC_OP_UNREDEFINED_P(BOP_MULT)) { long a, b; @@ -2118,7 +2121,7 @@ INSN_ENTRY(opt_mult){ CALL_SIMPLE_METHOD(1, idMULT, recv); } -#line 2122 "vm.inc" +#line 2125 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_mult @@ -2143,7 +2146,7 @@ INSN_ENTRY(opt_div){ USAGE_ANALYSIS_INSN(BIN(opt_div)); USAGE_ANALYSIS_OPERAND(BIN(opt_div), 0, ic); { -#line 1512 "insns.def" +#line 1515 "insns.def" if (FIXNUM_2_P(recv, obj) && BASIC_OP_UNREDEFINED_P(BOP_DIV)) { long x, y, div; @@ -2196,7 +2199,7 @@ INSN_ENTRY(opt_div){ CALL_SIMPLE_METHOD(1, idDIV, recv); } -#line 2200 "vm.inc" +#line 2203 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_div @@ -2221,7 +2224,7 @@ INSN_ENTRY(opt_mod){ USAGE_ANALYSIS_INSN(BIN(opt_mod)); USAGE_ANALYSIS_OPERAND(BIN(opt_mod), 0, ic); { -#line 1576 "insns.def" +#line 1579 "insns.def" if (FIXNUM_2_P(recv, obj) && BASIC_OP_UNREDEFINED_P(BOP_MOD)) { long x, y, mod; @@ -2273,7 +2276,7 @@ INSN_ENTRY(opt_mod){ CALL_SIMPLE_METHOD(1, idMOD, recv); } -#line 2277 "vm.inc" +#line 2280 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_mod @@ -2298,7 +2301,7 @@ INSN_ENTRY(opt_eq){ USAGE_ANALYSIS_INSN(BIN(opt_eq)); USAGE_ANALYSIS_OPERAND(BIN(opt_eq), 0, ic); { -#line 1639 "insns.def" +#line 1642 "insns.def" val = opt_eq_func(recv, obj, ic); if (val == Qundef) { @@ -2308,7 +2311,7 @@ INSN_ENTRY(opt_eq){ CALL_SIMPLE_METHOD(1, idEq, recv); } -#line 2312 "vm.inc" +#line 2315 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_eq @@ -2335,7 +2338,7 @@ INSN_ENTRY(opt_neq){ USAGE_ANALYSIS_OPERAND(BIN(opt_neq), 0, ic); USAGE_ANALYSIS_OPERAND(BIN(opt_neq), 1, ic_eq); { -#line 1660 "insns.def" +#line 1663 "insns.def" extern VALUE rb_obj_not_equal(VALUE obj1, VALUE obj2); const rb_method_entry_t *me = vm_method_search(idNeq, CLASS_OF(recv), ic); val = Qundef; @@ -2355,7 +2358,7 @@ INSN_ENTRY(opt_neq){ CALL_SIMPLE_METHOD(1, idNeq, recv); } -#line 2359 "vm.inc" +#line 2362 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_neq @@ -2380,7 +2383,7 @@ INSN_ENTRY(opt_lt){ USAGE_ANALYSIS_INSN(BIN(opt_lt)); USAGE_ANALYSIS_OPERAND(BIN(opt_lt), 0, ic); { -#line 1691 "insns.def" +#line 1694 "insns.def" if (FIXNUM_2_P(recv, obj) && BASIC_OP_UNREDEFINED_P(BOP_LT)) { SIGNED_VALUE a = recv, b = obj; @@ -2419,7 +2422,7 @@ INSN_ENTRY(opt_lt){ CALL_SIMPLE_METHOD(1, idLT, recv); } -#line 2423 "vm.inc" +#line 2426 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_lt @@ -2444,7 +2447,7 @@ INSN_ENTRY(opt_le){ USAGE_ANALYSIS_INSN(BIN(opt_le)); USAGE_ANALYSIS_OPERAND(BIN(opt_le), 0, ic); { -#line 1741 "insns.def" +#line 1744 "insns.def" if (FIXNUM_2_P(recv, obj) && BASIC_OP_UNREDEFINED_P(BOP_LE)) { SIGNED_VALUE a = recv, b = obj; @@ -2463,7 +2466,7 @@ INSN_ENTRY(opt_le){ CALL_SIMPLE_METHOD(1, idLE, recv); } -#line 2467 "vm.inc" +#line 2470 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_le @@ -2488,7 +2491,7 @@ INSN_ENTRY(opt_gt){ USAGE_ANALYSIS_INSN(BIN(opt_gt)); USAGE_ANALYSIS_OPERAND(BIN(opt_gt), 0, ic); { -#line 1771 "insns.def" +#line 1774 "insns.def" if (FIXNUM_2_P(recv, obj) && BASIC_OP_UNREDEFINED_P(BOP_GT)) { SIGNED_VALUE a = recv, b = obj; @@ -2527,7 +2530,7 @@ INSN_ENTRY(opt_gt){ CALL_SIMPLE_METHOD(1, idGT, recv); } -#line 2531 "vm.inc" +#line 2534 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_gt @@ -2552,7 +2555,7 @@ INSN_ENTRY(opt_ge){ USAGE_ANALYSIS_INSN(BIN(opt_ge)); USAGE_ANALYSIS_OPERAND(BIN(opt_ge), 0, ic); { -#line 1821 "insns.def" +#line 1824 "insns.def" if (FIXNUM_2_P(recv, obj) && BASIC_OP_UNREDEFINED_P(BOP_GE)) { SIGNED_VALUE a = recv, b = obj; @@ -2570,7 +2573,7 @@ INSN_ENTRY(opt_ge){ CALL_SIMPLE_METHOD(1, idGE, recv); } -#line 2574 "vm.inc" +#line 2577 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_ge @@ -2595,7 +2598,7 @@ INSN_ENTRY(opt_ltlt){ USAGE_ANALYSIS_INSN(BIN(opt_ltlt)); USAGE_ANALYSIS_OPERAND(BIN(opt_ltlt), 0, ic); { -#line 1850 "insns.def" +#line 1853 "insns.def" if (!SPECIAL_CONST_P(recv)) { if (0) { } @@ -2618,7 +2621,7 @@ INSN_ENTRY(opt_ltlt){ CALL_SIMPLE_METHOD(1, idLTLT, recv); } -#line 2622 "vm.inc" +#line 2625 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_ltlt @@ -2643,7 +2646,7 @@ INSN_ENTRY(opt_aref){ USAGE_ANALYSIS_INSN(BIN(opt_aref)); USAGE_ANALYSIS_OPERAND(BIN(opt_aref), 0, ic); { -#line 1884 "insns.def" +#line 1887 "insns.def" if (!SPECIAL_CONST_P(recv) && BASIC_OP_UNREDEFINED_P(BOP_AREF)) { if (HEAP_CLASS_OF(recv) == rb_cArray && FIXNUM_P(obj)) { val = rb_ary_entry(recv, FIX2LONG(obj)); @@ -2662,7 +2665,7 @@ INSN_ENTRY(opt_aref){ CALL_SIMPLE_METHOD(1, idAREF, recv); } -#line 2666 "vm.inc" +#line 2669 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_aref @@ -2688,7 +2691,7 @@ INSN_ENTRY(opt_aset){ USAGE_ANALYSIS_INSN(BIN(opt_aset)); USAGE_ANALYSIS_OPERAND(BIN(opt_aset), 0, ic); { -#line 1914 "insns.def" +#line 1917 "insns.def" if (!SPECIAL_CONST_P(recv) && BASIC_OP_UNREDEFINED_P(BOP_ASET)) { if (HEAP_CLASS_OF(recv) == rb_cArray && FIXNUM_P(obj)) { @@ -2711,7 +2714,7 @@ INSN_ENTRY(opt_aset){ CALL_SIMPLE_METHOD(2, idASET, recv); } -#line 2715 "vm.inc" +#line 2718 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_aset @@ -2735,7 +2738,7 @@ INSN_ENTRY(opt_length){ USAGE_ANALYSIS_INSN(BIN(opt_length)); USAGE_ANALYSIS_OPERAND(BIN(opt_length), 0, ic); { -#line 1948 "insns.def" +#line 1951 "insns.def" if (LIKELY(!SPECIAL_CONST_P(recv) && BASIC_OP_UNREDEFINED_P(BOP_LENGTH))) { if (HEAP_CLASS_OF(recv) == rb_cString) { @@ -2757,7 +2760,7 @@ INSN_ENTRY(opt_length){ CALL_SIMPLE_METHOD(0, idLength, recv); } -#line 2761 "vm.inc" +#line 2764 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_length @@ -2781,7 +2784,7 @@ INSN_ENTRY(opt_size){ USAGE_ANALYSIS_INSN(BIN(opt_size)); USAGE_ANALYSIS_OPERAND(BIN(opt_size), 0, ic); { -#line 1981 "insns.def" +#line 1984 "insns.def" if (LIKELY(BASIC_OP_UNREDEFINED_P(BOP_SIZE) && !SPECIAL_CONST_P(recv))) { if (HEAP_CLASS_OF(recv) == rb_cString) { @@ -2803,7 +2806,7 @@ INSN_ENTRY(opt_size){ CALL_SIMPLE_METHOD(0, idSize, recv); } -#line 2807 "vm.inc" +#line 2810 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_size @@ -2827,7 +2830,7 @@ INSN_ENTRY(opt_succ){ USAGE_ANALYSIS_INSN(BIN(opt_succ)); USAGE_ANALYSIS_OPERAND(BIN(opt_succ), 0, ic); { -#line 2014 "insns.def" +#line 2017 "insns.def" if (SPECIAL_CONST_P(recv)) { if (FIXNUM_P(recv) && BASIC_OP_UNREDEFINED_P(BOP_SUCC)) { @@ -2863,7 +2866,7 @@ INSN_ENTRY(opt_succ){ CALL_SIMPLE_METHOD(0, idSucc, recv); } -#line 2867 "vm.inc" +#line 2870 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_succ @@ -2887,7 +2890,7 @@ INSN_ENTRY(opt_not){ USAGE_ANALYSIS_INSN(BIN(opt_not)); USAGE_ANALYSIS_OPERAND(BIN(opt_not), 0, ic); { -#line 2061 "insns.def" +#line 2064 "insns.def" extern VALUE rb_obj_not(VALUE obj); const rb_method_entry_t *me = vm_method_search(idNot, CLASS_OF(recv), ic); @@ -2899,7 +2902,7 @@ INSN_ENTRY(opt_not){ CALL_SIMPLE_METHOD(0, idNot, recv); } -#line 2903 "vm.inc" +#line 2906 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_not @@ -2923,10 +2926,10 @@ INSN_ENTRY(opt_regexpmatch1){ USAGE_ANALYSIS_INSN(BIN(opt_regexpmatch1)); USAGE_ANALYSIS_OPERAND(BIN(opt_regexpmatch1), 0, r); { -#line 2085 "insns.def" +#line 2088 "insns.def" val = rb_reg_match(r, obj); -#line 2930 "vm.inc" +#line 2933 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_regexpmatch1 @@ -2950,7 +2953,7 @@ INSN_ENTRY(opt_regexpmatch2){ #define LABEL_IS_SC(lab) LABEL_##lab##_##t USAGE_ANALYSIS_INSN(BIN(opt_regexpmatch2)); { -#line 2099 "insns.def" +#line 2102 "insns.def" if (TYPE(obj2) == T_STRING) { val = rb_reg_match(obj1, obj2); } @@ -2958,7 +2961,7 @@ INSN_ENTRY(opt_regexpmatch2){ val = rb_funcall(obj2, idEqTilde, 1, obj1); } -#line 2962 "vm.inc" +#line 2965 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(val); #undef CURRENT_INSN_opt_regexpmatch2 @@ -2980,7 +2983,7 @@ INSN_ENTRY(opt_call_c_function){ USAGE_ANALYSIS_INSN(BIN(opt_call_c_function)); USAGE_ANALYSIS_OPERAND(BIN(opt_call_c_function), 0, funcptr); { -#line 2118 "insns.def" +#line 2121 "insns.def" reg_cfp = (funcptr)(th, reg_cfp); if (reg_cfp == 0) { @@ -2992,7 +2995,7 @@ INSN_ENTRY(opt_call_c_function){ RESTORE_REGS(); NEXT_INSN(); -#line 2996 "vm.inc" +#line 2999 "vm.inc" #undef CURRENT_INSN_opt_call_c_function #undef INSN_IS_SC #undef INSN_LABEL @@ -3012,10 +3015,10 @@ INSN_ENTRY(bitblt){ #define LABEL_IS_SC(lab) LABEL_##lab##_##t USAGE_ANALYSIS_INSN(BIN(bitblt)); { -#line 2141 "insns.def" +#line 2144 "insns.def" ret = rb_str_new2("a bit of bacon, lettuce and tomato"); -#line 3019 "vm.inc" +#line 3022 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(ret); #undef CURRENT_INSN_bitblt @@ -3037,10 +3040,10 @@ INSN_ENTRY(answer){ #define LABEL_IS_SC(lab) LABEL_##lab##_##t USAGE_ANALYSIS_INSN(BIN(answer)); { -#line 2155 "insns.def" +#line 2158 "insns.def" ret = INT2FIX(42); -#line 3044 "vm.inc" +#line 3047 "vm.inc" CHECK_STACK_OVERFLOW(REG_CFP, 1); PUSH(ret); #undef CURRENT_INSN_answer @@ -2,7 +2,7 @@ vm_core.h - - $Author: marcandre $ + $Author: usa $ created at: 04/01/01 19:41:38 JST Copyright (C) 2004-2007 Koichi Sasada @@ -22,7 +22,7 @@ #include "vm_opts.h" #include "id.h" #include "method.h" -#include "atomic.h" +#include "ruby_atomic.h" #if defined(_WIN32) #include "thread_win32.h" @@ -252,6 +252,7 @@ struct rb_iseq_struct { /* misc */ ID defined_method_id; /* for define_method */ + rb_num_t flip_cnt; /* used at compile time */ struct iseq_compile_data *compile_data; @@ -651,7 +652,7 @@ VALUE rb_vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self, int argc, const VALUE *argv, const rb_block_t *blockptr); VALUE rb_vm_make_proc(rb_thread_t *th, const rb_block_t *block, VALUE klass); VALUE rb_vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp); -void rb_vm_rewrite_dfp_in_errinfo(rb_thread_t *th, rb_control_frame_t *cfp); +void rb_vm_rewrite_dfp_in_errinfo(rb_thread_t *th); void rb_vm_inc_const_missing_count(void); void rb_vm_gvl_destroy(rb_vm_t *vm); VALUE rb_vm_call(rb_thread_t *th, VALUE recv, VALUE id, int argc, @@ -728,17 +729,23 @@ void rb_thread_lock_destroy(rb_thread_lock_t *); /* tracer */ void -rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass); +rb_threadptr_exec_event_hooks(rb_thread_t *th, rb_event_flag_t flag, VALUE self, ID id, VALUE klass, int pop_p); -#define EXEC_EVENT_HOOK(th, flag, self, id, klass) do { \ +#define EXEC_EVENT_HOOK_ORIG(th, flag, self, id, klass, pop_p) do { \ rb_event_flag_t wait_event__ = (th)->event_flags; \ if (UNLIKELY(wait_event__)) { \ if (wait_event__ & ((flag) | RUBY_EVENT_VM)) { \ - rb_threadptr_exec_event_hooks((th), (flag), (self), (id), (klass)); \ + rb_threadptr_exec_event_hooks((th), (flag), (self), (id), (klass), (pop_p)); \ } \ } \ } while (0) +#define EXEC_EVENT_HOOK(th, flag, self, id, klass) \ + EXEC_EVENT_HOOK_ORIG(th, flag, self, id, klass, 0) + +#define EXEC_EVENT_HOOK_AND_POP_FRAME(th, flag, self, id, klass) \ + EXEC_EVENT_HOOK_ORIG(th, flag, self, id, klass, 1) + #if defined __GNUC__ && __GNUC__ >= 4 #pragma GCC visibility push(default) #endif @@ -2,7 +2,7 @@ vm_eval.c - - $Author: nobu $ + $Author: usa $ created at: Sat May 24 16:02:32 JST 2008 Copyright (C) 1993-2007 Yukihiro Matsumoto @@ -694,6 +694,23 @@ rb_funcall_passing_block(VALUE recv, ID mid, int argc, const VALUE *argv) return rb_call(recv, mid, argc, argv, CALL_PUBLIC); } +VALUE +rb_funcall_with_block(VALUE recv, ID mid, int argc, const VALUE *argv, VALUE pass_procval) +{ + if (!NIL_P(pass_procval)) { + rb_thread_t *th = GET_THREAD(); + rb_block_t *block = 0; + + rb_proc_t *pass_proc; + GetProcPtr(pass_procval, pass_proc); + block = &pass_proc->block; + + th->passed_block = block; + } + + return rb_call(recv, mid, argc, argv, CALL_PUBLIC); +} + static VALUE send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope) { @@ -1212,7 +1229,7 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int level) POP_TAG(); rb_set_safe_level_force(safe); - if (state) rb_vm_jump_tag_but_local_jump(state, val); + if (state) JUMP_TAG(state); return val; } @@ -2,7 +2,7 @@ vm.h - - $Author: akr $ + $Author: usa $ created at: 04/01/01 16:56:59 JST Copyright (C) 2004-2007 Koichi Sasada @@ -15,7 +15,7 @@ typedef long OFFSET; typedef unsigned long lindex_t; typedef unsigned long dindex_t; -typedef rb_num_t GENTRY; +typedef VALUE GENTRY; typedef rb_iseq_t *ISEQ; #ifdef COLLECT_USAGE_ANALYSIS diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 8e7fe94..1354a24 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2,7 +2,7 @@ vm_insnhelper.c - instruction helper functions. - $Author: kosaki $ + $Author: usa $ Copyright (C) 2007 Koichi Sasada @@ -406,10 +406,6 @@ vm_call_cfunc(rb_thread_t *th, rb_control_frame_t *reg_cfp, if (reg_cfp != th->cfp + 1) { rb_bug("cfp consistency error - send"); } -#ifdef __llvm__ -#define RB_LLVM_GUARD(v) RB_GC_GUARD(v) - RB_LLVM_GUARD(reg_cfp); -#endif vm_pop_frame(th); @@ -981,7 +977,7 @@ lfp_svar_place(rb_thread_t *th, VALUE *lfp) } static VALUE -lfp_svar_get(rb_thread_t *th, VALUE *lfp, VALUE key) +lfp_svar_get(rb_thread_t *th, VALUE *lfp, rb_num_t key) { NODE *svar = lfp_svar_place(th, lfp); @@ -991,20 +987,20 @@ lfp_svar_get(rb_thread_t *th, VALUE *lfp, VALUE key) case 1: return svar->u2.value; default: { - const VALUE hash = svar->u3.value; + const VALUE ary = svar->u3.value; - if (hash == Qnil) { + if (NIL_P(ary)) { return Qnil; } else { - return rb_hash_lookup(hash, key); + return rb_ary_entry(ary, key - DEFAULT_SPECIAL_VAR_COUNT); } } } } static void -lfp_svar_set(rb_thread_t *th, VALUE *lfp, VALUE key, VALUE val) +lfp_svar_set(rb_thread_t *th, VALUE *lfp, rb_num_t key, VALUE val) { NODE *svar = lfp_svar_place(th, lfp); @@ -1016,27 +1012,23 @@ lfp_svar_set(rb_thread_t *th, VALUE *lfp, VALUE key, VALUE val) svar->u2.value = val; return; default: { - VALUE hash = svar->u3.value; + VALUE ary = svar->u3.value; - if (hash == Qnil) { - svar->u3.value = hash = rb_hash_new(); + if (NIL_P(ary)) { + svar->u3.value = ary = rb_ary_new(); } - rb_hash_aset(hash, key, val); + rb_ary_store(ary, key - DEFAULT_SPECIAL_VAR_COUNT, val); } } } static inline VALUE -vm_getspecial(rb_thread_t *th, VALUE *lfp, VALUE key, rb_num_t type) +vm_getspecial(rb_thread_t *th, VALUE *lfp, rb_num_t key, rb_num_t type) { VALUE val; if (type == 0) { - VALUE k = key; - if (FIXNUM_P(key)) { - k = FIX2INT(key); - } - val = lfp_svar_get(th, lfp, k); + val = lfp_svar_get(th, lfp, key); } else { VALUE backref = lfp_svar_get(th, lfp, 1); diff --git a/vm_method.c b/vm_method.c index 6e33603..85cb30c 100644 --- a/vm_method.c +++ b/vm_method.c @@ -99,7 +99,7 @@ void rb_gc_mark_unlinked_live_method_entries(void *pvm) { rb_vm_t *vm = pvm; - struct unlinked_method_entry_list_entry *ume = vm->unlinked_method_entry_list, *prev_ume = 0, *curr_ume; + struct unlinked_method_entry_list_entry *ume = vm->unlinked_method_entry_list; while (ume) { if (ume->me->mark) { diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 3733dc8..135c2db 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -74,6 +74,7 @@ RM = $(COMSPEC) /C $(srcdir:/=\)\win32\rm.bat RMDIR = $(COMSPEC) /C $(srcdir:/=\)\win32\rmdirs.bat RMDIRS = $(COMSPEC) /C $(srcdir:/=\)\win32\rmdirs.bat RMALL = $(COMSPEC) /C $(srcdir:/=\)\win32\rmall.bat +MAKEDIRS = $(COMSPEC) /E:ON /C $(srcdir:/=\)\win32\makedirs.bat CP = copy > nul MV = move > nul !if !defined(BASERUBY) @@ -122,6 +123,9 @@ PLATFORM = mswin32 !ifdef NTVER ARCHDEFS = -D_WIN32_WINNT=$(NTVER) $(ARCHDEFS) !endif +!if !defined(PLATFORM_DIR) +PLATFORM_DIR = win32 +!endif arch = $(ARCH)-$(PLATFORM) sitearch = $(ARCH)-$(RT) @@ -219,13 +223,13 @@ RFLAGS = -r EXTLIBS = !endif !if !defined(LIBS) -LIBS = oldnames.lib user32.lib advapi32.lib shell32.lib ws2_32.lib imagehlp.lib $(EXTLIBS) +LIBS = oldnames.lib user32.lib advapi32.lib shell32.lib ws2_32.lib imagehlp.lib shlwapi.lib $(EXTLIBS) !endif !if "$(ENABLE_WIN95)" == "yes" LIBS = unicows.lib $(LIBS) !endif !if !defined(MISSING) -MISSING = acosh.obj cbrt.obj crypt.obj erf.obj ffs.obj langinfo.obj lgamma_r.obj strlcat.obj strlcpy.obj tgamma.obj win32.obj setproctitle.obj +MISSING = acosh.obj cbrt.obj crypt.obj erf.obj ffs.obj langinfo.obj lgamma_r.obj strlcat.obj strlcpy.obj tgamma.obj win32/win32.obj win32/file.obj setproctitle.obj !endif ARFLAGS = -machine:$(MACHINE) -out: @@ -286,8 +290,6 @@ DEFAULT_PRELUDES = $(NO_GEM_PRELUDE) DEFAULT_PRELUDES = $(YES_GEM_PRELUDE) !endif -MAKEDIRS = $(MINIRUBY) -run -e mkdir -- -p - !if !defined(STACK) !if "$(ARCH)" == "x64" || "$(ARCH)" == "ia64" STACK = 0x400000 @@ -535,11 +537,13 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub #define HAVE_FCNTL_H 1 #define HAVE_SYS_UTIME_H 1 #define HAVE_FLOAT_H 1 +#define HAVE_TIME_H 1 #define rb_pid_t int #define rb_gid_t int #define rb_uid_t int #define HAVE_STRUCT_STAT_ST_RDEV 1 #define HAVE_ST_RDEV 1 +#define HAVE_STRUCT_TIMEVAL 1 !if $(MSC_VER) >= 1600 #define HAVE_STDINT_H 1 !else @@ -593,7 +597,6 @@ $(CONFIG_H): $(MKFILES) $(srcdir)/win32/Makefile.sub $(win_srcdir)/Makefile.sub #define GETGROUPS_T int #define RETSIGTYPE void #define TYPEOF_TIMEVAL_TV_SEC long -#define GC_MARK_STACKFRAME_WORD 30 #define HAVE_ALLOCA 1 #define HAVE_DUP2 1 #define HAVE_MEMCMP 1 @@ -920,6 +923,10 @@ clean-rdoc distclean-rdoc realclean-rdoc: clean-capi distclean-capi realclean-capi: -$(Q)$(RMALL) $(CAPIOUT:/=\) +clean-platform: + $(Q)$(RM) $(PLATFORM_D:/=\) + -$(Q)$(RMDIR) $(PLATFORM_DIR:/=\) + clean-ext distclean-ext realclean-ext:: !if "$(EXTS)" != "" @for %I in ($(EXTS)) \ @@ -993,7 +1000,7 @@ $(ruby_pc): $(RBCONFIG) {$(win_srcdir)/sys}.c.obj: $(ECHO) compiling $(<:\=/) $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c -Tc$(<:\=/) -{$(srcdir)}.c.obj: +{$(srcdir)}.c{}.obj: $(ECHO) compiling $(<:\=/) $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c -Tc$(<:\=/) .c.obj: @@ -1040,7 +1047,7 @@ enc/unicode/name2ctype.h: {$(srcdir)}enc/unicode/name2ctype.h.blt $(OBJS): {$(hdrdir)/ruby}win32.h -dir.$(OBJEXT) win32.$(OBJEXT): {$(srcdir)}win32/dir.h +dir.$(OBJEXT) win32/win32.$(OBJEXT): {$(srcdir)}win32/dir.h ext/extinit.obj: ext/extinit.c $(SETUP) $(ECHO) compiling ext/extinit.c diff --git a/win32/README.win32 b/win32/README.win32 index 0737f1b..f6a9a71 100644 --- a/win32/README.win32 +++ b/win32/README.win32 @@ -25,7 +25,11 @@ * sed * ruby 1.8 -(5) If you want built binaries to run on Windows 95 series (including +(5) Enable Command Extension of your command line. It's the default behavior + of cmd.exe. If you want to enable it explicitly, run cmd.exe with /E:ON + option. + +(6) If you want built binaries to run on Windows 95 series (including 98 and Me), you need unicows.lib at compile time, and unicows.dll at run time. diff --git a/win32/file.c b/win32/file.c new file mode 100644 index 0000000..350f8da --- /dev/null +++ b/win32/file.c @@ -0,0 +1,715 @@ +#include "ruby/ruby.h" +#include "ruby/encoding.h" +#include <winbase.h> +#include <wchar.h> +#include <shlwapi.h> + +#ifndef INVALID_FILE_ATTRIBUTES +# define INVALID_FILE_ATTRIBUTES ((DWORD)-1) +#endif + +/* cache 'encoding name' => 'code page' into a hash */ +static VALUE rb_code_page; + +#define IS_DIR_SEPARATOR_P(c) (c == L'\\' || c == L'/') +#define IS_DIR_UNC_P(c) (IS_DIR_SEPARATOR_P(c[0]) && IS_DIR_SEPARATOR_P(c[1])) + +/* MultiByteToWideChar() doesn't work with code page 51932 */ +#define INVALID_CODE_PAGE 51932 +#define PATH_BUFFER_SIZE MAX_PATH * 2 + +#define insecure_obj_p(obj, level) ((level) >= 4 || ((level) > 0 && OBJ_TAINTED(obj))) + +static inline void +replace_wchar(wchar_t *s, int find, int replace) +{ + while (*s != 0) { + if (*s == find) + *s = replace; + s++; + } +} + +/* Convert str from multibyte char to wchar with specified code page */ +static inline void +convert_mb_to_wchar(VALUE str, wchar_t **wstr, wchar_t **wstr_pos, size_t *wstr_len, UINT code_page) +{ + size_t len; + + if (NIL_P(str)) + return; + + len = MultiByteToWideChar(code_page, 0, RSTRING_PTR(str), -1, NULL, 0) + 1; + *wstr = (wchar_t *)xmalloc(len * sizeof(wchar_t)); + if (wstr_pos) + *wstr_pos = *wstr; + + MultiByteToWideChar(code_page, 0, RSTRING_PTR(str), -1, *wstr, len); + *wstr_len = len - 2; +} + +static inline void +convert_wchar_to_mb(const wchar_t *wstr, char **str, size_t *str_len, UINT code_page) +{ + size_t len; + + len = WideCharToMultiByte(code_page, 0, wstr, -1, NULL, 0, NULL, NULL); + *str = (char *)xmalloc(len * sizeof(char)); + WideCharToMultiByte(code_page, 0, wstr, -1, *str, len, NULL, NULL); + + /* do not count terminator as part of the string length */ + *str_len = len - 1; +} + +/* + Return user's home directory using environment variables combinations. + Memory allocated by this function should be manually freed afterwards. + + Try: + HOME, HOMEDRIVE + HOMEPATH and USERPROFILE environment variables + TODO: Special Folders - Profile and Personal +*/ +static wchar_t * +home_dir(void) +{ + wchar_t *buffer = NULL; + size_t buffer_len = 0, len = 0; + size_t home_env = 0; + + /* + GetEnvironmentVariableW when used with NULL will return the required + buffer size and its terminating character. + http://msdn.microsoft.com/en-us/library/windows/desktop/ms683188(v=vs.85).aspx + */ + + if (len = GetEnvironmentVariableW(L"HOME", NULL, 0)) { + buffer_len = len; + home_env = 1; + } + else if (len = GetEnvironmentVariableW(L"HOMEDRIVE", NULL, 0)) { + buffer_len = len; + if (len = GetEnvironmentVariableW(L"HOMEPATH", NULL, 0)) { + buffer_len += len; + home_env = 2; + } + else { + buffer_len = 0; + } + } + else if (len = GetEnvironmentVariableW(L"USERPROFILE", NULL, 0)) { + buffer_len = len; + home_env = 3; + } + + /* allocate buffer */ + if (home_env) + buffer = (wchar_t *)xmalloc(buffer_len * sizeof(wchar_t)); + + switch (home_env) { + case 1: + /* HOME */ + GetEnvironmentVariableW(L"HOME", buffer, buffer_len); + break; + case 2: + /* HOMEDRIVE + HOMEPATH */ + len = GetEnvironmentVariableW(L"HOMEDRIVE", buffer, buffer_len); + GetEnvironmentVariableW(L"HOMEPATH", buffer + len, buffer_len - len); + break; + case 3: + /* USERPROFILE */ + GetEnvironmentVariableW(L"USERPROFILE", buffer, buffer_len); + break; + default: + break; + } + + if (home_env) { + /* sanitize backslashes with forwardslashes */ + replace_wchar(buffer, L'\\', L'/'); + + return buffer; + } + + return NULL; +} + +/* Remove trailing invalid ':$DATA' of the path. */ +static inline size_t +remove_invalid_alternative_data(wchar_t *wfullpath, size_t size) +{ + static const wchar_t prime[] = L":$DATA"; + enum { prime_len = (sizeof(prime) / sizeof(wchar_t)) -1 }; + + if (size <= prime_len || _wcsnicmp(wfullpath + size - prime_len, prime, prime_len) != 0) + return size; + + /* alias of stream */ + /* get rid of a bug of x64 VC++ */ + if (wfullpath[size - (prime_len + 1)] == ':') { + /* remove trailing '::$DATA' */ + size -= prime_len + 1; /* prime */ + wfullpath[size] = L'\0'; + } + else { + /* remove trailing ':$DATA' of paths like '/aa:a:$DATA' */ + wchar_t *pos = wfullpath + size - (prime_len + 1); + while (!IS_DIR_SEPARATOR_P(*pos) && pos != wfullpath) { + if (*pos == L':') { + size -= prime_len; /* alternative */ + wfullpath[size] = L'\0'; + break; + } + pos--; + } + } + return size; +} + +/* Return system code page. */ +static inline UINT +system_code_page(void) +{ + return AreFileApisANSI() ? CP_ACP : CP_OEMCP; +} + +/* + Return code page number of the encoding. + Cache code page into a hash for performance since finding the code page in + Encoding#names is slow. +*/ +static UINT +code_page(rb_encoding *enc) +{ + VALUE code_page_value, name_key; + VALUE encoding, names_ary = Qundef, name; + char *enc_name; + struct RString fake_str; + ID names; + long i; + + if (!enc) + return system_code_page(); + + enc_name = (char *)rb_enc_name(enc); + + fake_str.basic.flags = T_STRING|RSTRING_NOEMBED; + fake_str.basic.klass = rb_cString; + fake_str.as.heap.len = strlen(enc_name); + fake_str.as.heap.ptr = enc_name; + fake_str.as.heap.aux.capa = fake_str.as.heap.len; + name_key = (VALUE)&fake_str; + ENCODING_CODERANGE_SET(name_key, rb_usascii_encindex(), ENC_CODERANGE_7BIT); + + code_page_value = rb_hash_lookup(rb_code_page, name_key); + if (code_page_value != Qnil) + return (UINT)FIX2INT(code_page_value); + + name_key = rb_usascii_str_new2(enc_name); + + encoding = rb_enc_from_encoding(enc); + if (!NIL_P(encoding)) { + CONST_ID(names, "names"); + names_ary = rb_funcall(encoding, names, 0); + } + + /* map US-ASCII and ASCII-8bit as code page 20127 (us-ascii) */ + if (enc == rb_usascii_encoding() || enc == rb_ascii8bit_encoding()) { + UINT code_page = 20127; + rb_hash_aset(rb_code_page, name_key, INT2FIX(code_page)); + return code_page; + } + + if (names_ary != Qundef) { + for (i = 0; i < RARRAY_LEN(names_ary); i++) { + name = RARRAY_PTR(names_ary)[i]; + if (strncmp("CP", RSTRING_PTR(name), 2) == 0) { + int code_page = atoi(RSTRING_PTR(name) + 2); + if (code_page != 0) { + rb_hash_aset(rb_code_page, name_key, INT2FIX(code_page)); + return (UINT)code_page; + } + } + } + } + + rb_hash_aset(rb_code_page, name_key, INT2FIX(INVALID_CODE_PAGE)); + return INVALID_CODE_PAGE; +} + +static inline VALUE +fix_string_encoding(VALUE str, rb_encoding *encoding) +{ + VALUE result, tmp; + + tmp = rb_enc_str_new(RSTRING_PTR(str), RSTRING_LEN(str), encoding); + result = rb_str_encode(tmp, rb_enc_from_encoding(rb_utf8_encoding()), 0, Qnil); + + return result; +} + +/* + Replace the last part of the path to long name. + We try to avoid to call FindFirstFileW() since it takes long time. +*/ +static inline size_t +replace_to_long_name(wchar_t **wfullpath, size_t size, int heap) +{ + WIN32_FIND_DATAW find_data; + HANDLE find_handle; + + /* + Skip long name conversion if the path is already long name. + Short name is 8.3 format. + http://en.wikipedia.org/wiki/8.3_filename + This check can be skipped for directory components that have file + extensions longer than 3 characters, or total lengths longer than + 12 characters. + http://msdn.microsoft.com/en-us/library/windows/desktop/aa364980(v=vs.85).aspx + */ + size_t const max_short_name_size = 8 + 1 + 3; + size_t const max_extension_size = 3; + size_t path_len = 1, extension_len = 0; + wchar_t *pos = *wfullpath; + + if (size == 3 && pos[1] == L':' && pos[2] == L'\\' && pos[3] == L'\0') { + /* root path doesn't need short name expansion */ + return size; + } + + /* skip long name conversion if path contains wildcard characters */ + if (wcspbrk(pos, L"*?")) { + return size; + } + + pos = *wfullpath + size - 1; + while (!IS_DIR_SEPARATOR_P(*pos) && pos != *wfullpath) { + if (!extension_len && *pos == L'.') { + extension_len = path_len - 1; + } + if (path_len > max_short_name_size || extension_len > max_extension_size) { + return size; + } + path_len++; + pos--; + } + + find_handle = FindFirstFileW(*wfullpath, &find_data); + if (find_handle != INVALID_HANDLE_VALUE) { + size_t trail_pos = wcslen(*wfullpath); + size_t file_len = wcslen(find_data.cFileName); + + FindClose(find_handle); + while (trail_pos > 0) { + if (IS_DIR_SEPARATOR_P((*wfullpath)[trail_pos])) + break; + trail_pos--; + } + size = trail_pos + 1 + file_len; + if ((size + 1) > sizeof(*wfullpath) / sizeof((*wfullpath)[0])) { + wchar_t *buf = (wchar_t *)xmalloc((size + 1) * sizeof(wchar_t)); + wcsncpy(buf, *wfullpath, trail_pos + 1); + if (heap) + xfree(*wfullpath); + *wfullpath = buf; + } + wcsncpy(*wfullpath + trail_pos + 1, find_data.cFileName, file_len + 1); + } + return size; +} + +static inline VALUE +get_user_from_path(wchar_t **wpath, int offset, UINT cp, UINT path_cp, rb_encoding *path_encoding) +{ + VALUE result, tmp; + wchar_t *wuser = *wpath + offset; + wchar_t *pos = wuser; + char *user; + size_t size; + + while (!IS_DIR_SEPARATOR_P(*pos) && *pos != '\0') + pos++; + + *pos = '\0'; + convert_wchar_to_mb(wuser, &user, &size, cp); + + /* convert to VALUE and set the path encoding */ + if (path_cp == INVALID_CODE_PAGE) { + tmp = rb_enc_str_new(user, size, rb_utf8_encoding()); + result = rb_str_encode(tmp, rb_enc_from_encoding(path_encoding), 0, Qnil); + rb_str_resize(tmp, 0); + } + else { + result = rb_enc_str_new(user, size, path_encoding); + } + + if (user) + xfree(user); + + return result; +} + +VALUE +rb_file_expand_path_internal(VALUE fname, VALUE dname, int abs_mode, int long_name, VALUE result) +{ + size_t size = 0, wpath_len = 0, wdir_len = 0, whome_len = 0; + size_t buffer_len = 0; + char *fullpath = NULL; + wchar_t *wfullpath = NULL, *wpath = NULL, *wpath_pos = NULL; + wchar_t *wdir = NULL, *wdir_pos = NULL; + wchar_t *whome = NULL, *buffer = NULL, *buffer_pos = NULL; + UINT path_cp, cp; + VALUE path = fname, dir = dname; + wchar_t wfullpath_buffer[PATH_BUFFER_SIZE]; + wchar_t path_drive = L'\0', dir_drive = L'\0'; + int ignore_dir = 0; + rb_encoding *path_encoding; + int tainted = 0; + + /* tainted if path is tainted */ + tainted = OBJ_TAINTED(path); + + /* get path encoding */ + if (NIL_P(dir)) { + path_encoding = rb_enc_get(path); + } + else { + path_encoding = rb_enc_check(path, dir); + } + + cp = path_cp = code_page(path_encoding); + + /* workaround invalid codepage */ + if (path_cp == INVALID_CODE_PAGE) { + cp = CP_UTF8; + if (!NIL_P(path)) { + path = fix_string_encoding(path, path_encoding); + } + } + + /* convert char * to wchar_t */ + convert_mb_to_wchar(path, &wpath, &wpath_pos, &wpath_len, cp); + + /* determine if we need the user's home directory */ + /* expand '~' only if NOT rb_file_absolute_path() where `abs_mode` is 1 */ + if (abs_mode == 0 && wpath_len > 0 && wpath_pos[0] == L'~' && + (wpath_len == 1 || IS_DIR_SEPARATOR_P(wpath_pos[1]))) { + /* tainted if expanding '~' */ + tainted = 1; + + whome = home_dir(); + if (whome == NULL) { + xfree(wpath); + rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `~'"); + } + whome_len = wcslen(whome); + + if (PathIsRelativeW(whome) && !(whome_len >= 2 && IS_DIR_UNC_P(whome))) { + xfree(wpath); + rb_raise(rb_eArgError, "non-absolute home"); + } + + /* use filesystem encoding if expanding home dir */ + path_encoding = rb_filesystem_encoding(); + cp = path_cp = system_code_page(); + + /* ignores dir since we are expading home */ + ignore_dir = 1; + + /* exclude ~ from the result */ + wpath_pos++; + wpath_len--; + + /* exclude separator if present */ + if (wpath_len && IS_DIR_SEPARATOR_P(wpath_pos[0])) { + wpath_pos++; + wpath_len--; + } + } + else if (wpath_len >= 2 && wpath_pos[1] == L':') { + if (wpath_len >= 3 && IS_DIR_SEPARATOR_P(wpath_pos[2])) { + /* ignore dir since path contains a drive letter and a root slash */ + ignore_dir = 1; + } + else { + /* determine if we ignore dir or not later */ + path_drive = wpath_pos[0]; + } + } + else if (abs_mode == 0 && wpath_len >= 2 && wpath_pos[0] == L'~') { + result = get_user_from_path(&wpath_pos, 1, cp, path_cp, path_encoding); + + if (wpath) + xfree(wpath); + + rb_raise(rb_eArgError, "can't find user %s", StringValuePtr(result)); + } + + /* convert dir */ + if (!ignore_dir && !NIL_P(dir)) { + /* fix string encoding */ + if (path_cp == INVALID_CODE_PAGE) { + dir = fix_string_encoding(dir, path_encoding); + } + + /* convert char * to wchar_t */ + convert_mb_to_wchar(dir, &wdir, &wdir_pos, &wdir_len, cp); + + if (abs_mode == 0 && wdir_len > 0 && wdir_pos[0] == L'~' && + (wdir_len == 1 || IS_DIR_SEPARATOR_P(wdir_pos[1]))) { + /* tainted if expanding '~' */ + tainted = 1; + + whome = home_dir(); + if (whome == NULL) { + xfree(wpath); + xfree(wdir); + rb_raise(rb_eArgError, "couldn't find HOME environment -- expanding `~'"); + } + whome_len = wcslen(whome); + + if (PathIsRelativeW(whome) && !(whome_len >= 2 && IS_DIR_UNC_P(whome))) { + xfree(wpath); + xfree(wdir); + rb_raise(rb_eArgError, "non-absolute home"); + } + + /* exclude ~ from the result */ + wdir_pos++; + wdir_len--; + + /* exclude separator if present */ + if (wdir_len && IS_DIR_SEPARATOR_P(wdir_pos[0])) { + wdir_pos++; + wdir_len--; + } + } + else if (wdir_len >= 2 && wdir[1] == L':') { + dir_drive = wdir[0]; + if (wpath_len && IS_DIR_SEPARATOR_P(wpath_pos[0])) { + wdir_len = 2; + } + } + else if (wdir_len >= 2 && IS_DIR_UNC_P(wdir)) { + /* UNC path */ + if (wpath_len && IS_DIR_SEPARATOR_P(wpath_pos[0])) { + /* cut the UNC path tail to '//host/share' */ + size_t separators = 0; + size_t pos = 2; + while (pos < wdir_len && separators < 2) { + if (IS_DIR_SEPARATOR_P(wdir[pos])) { + separators++; + } + pos++; + } + if (separators == 2) + wdir_len = pos - 1; + } + } + else if (abs_mode == 0 && wdir_len >= 2 && wdir_pos[0] == L'~') { + result = get_user_from_path(&wdir_pos, 1, cp, path_cp, path_encoding); + if (wpath) + xfree(wpath); + + if (wdir) + xfree(wdir); + + rb_raise(rb_eArgError, "can't find user %s", StringValuePtr(result)); + } + } + + /* determine if we ignore dir or not */ + if (!ignore_dir && path_drive && dir_drive) { + if (towupper(path_drive) == towupper(dir_drive)) { + /* exclude path drive letter to use dir */ + wpath_pos += 2; + wpath_len -= 2; + } + else { + /* ignore dir since path drive is different from dir drive */ + ignore_dir = 1; + wdir_len = 0; + } + } + + if (!ignore_dir && wpath_len >= 2 && IS_DIR_UNC_P(wpath)) { + /* ignore dir since path has UNC root */ + ignore_dir = 1; + wdir_len = 0; + } + else if (!ignore_dir && wpath_len >= 1 && IS_DIR_SEPARATOR_P(wpath[0]) && + !dir_drive && !(wdir_len >= 2 && IS_DIR_UNC_P(wdir))) { + /* ignore dir since path has root slash and dir doesn't have drive or UNC root */ + ignore_dir = 1; + wdir_len = 0; + } + + buffer_len = wpath_len + 1 + wdir_len + 1 + whome_len + 1; + + buffer = buffer_pos = (wchar_t *)xmalloc((buffer_len + 1) * sizeof(wchar_t)); + + /* add home */ + if (whome_len) { + wcsncpy(buffer_pos, whome, whome_len); + buffer_pos += whome_len; + } + + /* Add separator if required */ + if (whome_len && wcsrchr(L"\\/:", buffer_pos[-1]) == NULL) { + buffer_pos[0] = L'\\'; + buffer_pos++; + } + + if (wdir_len) { + /* tainted if dir is used and dir is tainted */ + if (!tainted && OBJ_TAINTED(dir)) + tainted = 1; + + wcsncpy(buffer_pos, wdir_pos, wdir_len); + buffer_pos += wdir_len; + } + + /* add separator if required */ + if (wdir_len && wcsrchr(L"\\/:", buffer_pos[-1]) == NULL) { + buffer_pos[0] = L'\\'; + buffer_pos++; + } + + /* now deal with path */ + if (wpath_len) { + wcsncpy(buffer_pos, wpath_pos, wpath_len); + buffer_pos += wpath_len; + } + + /* GetFullPathNameW requires at least "." to determine current directory */ + if (wpath_len == 0) { + buffer_pos[0] = L'.'; + buffer_pos++; + } + + /* Ensure buffer is NULL terminated */ + buffer_pos[0] = L'\0'; + + /* tainted if path is relative */ + if (!tainted && PathIsRelativeW(buffer) && !(buffer_len >= 2 && IS_DIR_UNC_P(buffer))) + tainted = 1; + + /* FIXME: Make this more robust */ + /* Determine require buffer size */ + size = GetFullPathNameW(buffer, PATH_BUFFER_SIZE, wfullpath_buffer, NULL); + if (size > PATH_BUFFER_SIZE) { + /* allocate more memory than alloted originally by PATH_BUFFER_SIZE */ + wfullpath = (wchar_t *)xmalloc(size * sizeof(wchar_t)); + size = GetFullPathNameW(buffer, size, wfullpath, NULL); + } + else { + wfullpath = wfullpath_buffer; + } + + /* Remove any trailing slashes */ + if (IS_DIR_SEPARATOR_P(wfullpath[size - 1]) && + wfullpath[size - 2] != L':' && + !(size == 2 && IS_DIR_UNC_P(wfullpath))) { + size -= 1; + wfullpath[size] = L'\0'; + } + + /* Remove any trailing dot */ + if (wfullpath[size - 1] == L'.') { + size -= 1; + wfullpath[size] = L'\0'; + } + + /* removes trailing invalid ':$DATA' */ + size = remove_invalid_alternative_data(wfullpath, size); + + /* Replace the trailing path to long name */ + if (long_name) + size = replace_to_long_name(&wfullpath, size, (wfullpath != wfullpath_buffer)); + + /* sanitize backslashes with forwardslashes */ + replace_wchar(wfullpath, L'\\', L'/'); + + /* convert to char * */ + size = WideCharToMultiByte(cp, 0, wfullpath, size, NULL, 0, NULL, NULL); + if (size > (size_t)RSTRING_LEN(result)) { + rb_str_modify(result); + rb_str_resize(result, size); + } + + WideCharToMultiByte(cp, 0, wfullpath, size, RSTRING_PTR(result), size, NULL, NULL); + rb_str_set_len(result, size); + + /* convert to VALUE and set the path encoding */ + if (path_cp == INVALID_CODE_PAGE) { + VALUE tmp; + size_t len; + + rb_enc_associate(result, rb_utf8_encoding()); + ENC_CODERANGE_CLEAR(result); + tmp = rb_str_encode(result, rb_enc_from_encoding(path_encoding), 0, Qnil); + len = RSTRING_LEN(tmp); + rb_str_modify(result); + rb_str_resize(result, len); + memcpy(RSTRING_PTR(result), RSTRING_PTR(tmp), len); + rb_str_resize(tmp, 0); + } + rb_enc_associate(result, path_encoding); + ENC_CODERANGE_CLEAR(result); + + /* makes the result object tainted if expanding tainted strings or returning modified path */ + if (tainted) + OBJ_TAINT(result); + + /* TODO: better cleanup */ + if (buffer) + xfree(buffer); + + if (wpath) + xfree(wpath); + + if (wdir) + xfree(wdir); + + if (whome) + xfree(whome); + + if (wfullpath && wfullpath != wfullpath_buffer) + xfree(wfullpath); + + if (fullpath) + xfree(fullpath); + + return result; +} + +int +rb_file_load_ok(const char *path) +{ + int ret = 1; + DWORD attr = GetFileAttributes(path); + if (attr == INVALID_FILE_ATTRIBUTES || + attr & FILE_ATTRIBUTE_DIRECTORY) { + ret = 0; + } + else { + HANDLE h = CreateFile(path, GENERIC_READ, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (h != INVALID_HANDLE_VALUE) { + CloseHandle(h); + } + else { + ret = 0; + } + } + return ret; +} + +void +rb_w32_init_file(void) +{ + rb_code_page = rb_hash_new(); + + /* prevent GC removing rb_code_page */ + rb_gc_register_mark_object(rb_code_page); +} diff --git a/win32/makedirs.bat b/win32/makedirs.bat new file mode 100755 index 0000000..13740d8 --- /dev/null +++ b/win32/makedirs.bat @@ -0,0 +1,3 @@ +@echo off
+setlocal EnableExtensions
+for %%I in (%*) do if not exist "%%~I/." mkdir "%%~I"
diff --git a/win32/mkexports.rb b/win32/mkexports.rb index 9b45051..cc3dcf2 100755 --- a/win32/mkexports.rb +++ b/win32/mkexports.rb @@ -111,8 +111,8 @@ class Exports::Mswin < Exports next unless l.sub!(/.*?\s(\(\)\s+)?External\s+\|\s+/, '') is_data = !$1 if noprefix or /^[@_]/ =~ l - next if /(?!^)@.*@/ =~ l || /@[[:xdigit:]]{8,16}$/ =~ l || - /^_(?:Init_|.*_threadptr_|DllMain@)/ =~ l + next if /(?!^)@.*@/ =~ l || /@[[:xdigit:]]{8,32}$/ =~ l || + /^_?(?:Init_|.*_threadptr_|DllMain\b)/ =~ l l.sub!(/^[@_]/, '') if /@\d+$/ !~ l elsif !l.sub!(/^(\S+) \([^@?\`\']*\)$/, '\1') next @@ -146,7 +146,7 @@ class Exports::Cygwin < Exports def each_export(objs) symprefix = RbConfig::CONFIG["SYMBOL_PREFIX"] symprefix.strip! if symprefix - re = /\s(?:(T)|[[:upper:]])\s#{symprefix}((?!Init_|.*_threadptr_|DllMain@).*)$/ + re = /\s(?:(T)|[[:upper:]])\s#{symprefix}((?!Init_|.*_threadptr_|DllMain\b).*)$/ objdump(objs) do |l| next if /@.*@/ =~ l yield $2, !$1 if re =~ l diff --git a/win32/rmall.bat b/win32/rmall.bat index f49a168..f49a168 100644..100755 --- a/win32/rmall.bat +++ b/win32/rmall.bat diff --git a/win32/win32.c b/win32/win32.c index 6ea6888..fbf3566 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -578,12 +578,6 @@ init_env(void) typedef BOOL (WINAPI *cancel_io_t)(HANDLE); static cancel_io_t cancel_io = NULL; -int -rb_w32_has_cancel_io(void) -{ - return cancel_io != NULL; -} - static void init_func(void) { @@ -674,6 +668,8 @@ rb_w32_sysinit(int *argc, char ***argv) _set_invalid_parameter_handler(invalid_parameter); _RTC_SetErrorFunc(rtc_error_handler); set_pioinfo_extra(); +#else + SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX); #endif get_version(); @@ -1379,6 +1375,7 @@ has_redirection(const char *cmd) case '>': case '<': case '|': + case '&': case '\n': if (!quote) return TRUE; @@ -2086,6 +2083,15 @@ set_pioinfo_extra(void) #define FDEV 0x40 /* file handle refers to device */ #define FTEXT 0x80 /* file handle is in text mode */ +static int is_socket(SOCKET); +static int is_console(SOCKET); + +int +rb_w32_io_cancelable_p(int fd) +{ + return cancel_io != NULL && (is_socket(TO_SOCKET(fd)) || !is_console(TO_SOCKET(fd))); +} + static int rb_w32_open_osfhandle(intptr_t osfhandle, int flags) { @@ -2316,25 +2322,10 @@ ioctl(int i, int u, ...) return -1; } -#undef FD_SET - void rb_w32_fdset(int fd, fd_set *set) { - unsigned int i; - SOCKET s = TO_SOCKET(fd); - - for (i = 0; i < set->fd_count; i++) { - if (set->fd_array[i] == s) { - return; - } - } - if (i == set->fd_count) { - if (set->fd_count < FD_SETSIZE) { - set->fd_array[i] = s; - set->fd_count++; - } - } + FD_SET(fd, set); } #undef FD_CLR @@ -2718,14 +2709,19 @@ rb_w32_select_with_thread(int nfds, fd_set *rd, fd_set *wr, fd_set *ex, fd_set orig_rd; fd_set orig_wr; fd_set orig_ex; - if (rd) orig_rd = *rd; - if (wr) orig_wr = *wr; - if (ex) orig_ex = *ex; + + FD_ZERO(&orig_rd); + FD_ZERO(&orig_wr); + FD_ZERO(&orig_ex); + + if (rd) copy_fd(&orig_rd, rd); + if (wr) copy_fd(&orig_wr, wr); + if (ex) copy_fd(&orig_ex, ex); r = do_select(nfds, rd, wr, ex, &zero); // polling if (r != 0) break; // signaled or error - if (rd) *rd = orig_rd; - if (wr) *wr = orig_wr; - if (ex) *ex = orig_ex; + if (rd) copy_fd(rd, &orig_rd); + if (wr) copy_fd(wr, &orig_wr); + if (ex) copy_fd(ex, &orig_ex); if (timeout) { struct timeval now; @@ -4131,7 +4127,8 @@ isUNCRoot(const WCHAR *path) (dest).st_ctime = (src).st_ctime; \ } while (0) -#ifdef __BORLANDC__ +static time_t filetime_to_unixtime(const FILETIME *ft); + #undef fstat int rb_w32_fstat(int fd, struct stat *st) @@ -4140,10 +4137,18 @@ rb_w32_fstat(int fd, struct stat *st) int ret = fstat(fd, st); if (ret) return ret; +#ifdef __BORLANDC__ st->st_mode &= ~(S_IWGRP | S_IWOTH); - if (GetFileInformationByHandle((HANDLE)_get_osfhandle(fd), &info) && - !(info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) { - st->st_mode |= S_IWUSR; +#endif + if (GetFileInformationByHandle((HANDLE)_get_osfhandle(fd), &info)) { +#ifdef __BORLANDC__ + if (!(info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) { + st->st_mode |= S_IWUSR; + } +#endif + st->st_atime = filetime_to_unixtime(&info.ftLastAccessTime); + st->st_mtime = filetime_to_unixtime(&info.ftLastWriteTime); + st->st_ctime = filetime_to_unixtime(&info.ftCreationTime); } return ret; } @@ -4156,17 +4161,23 @@ rb_w32_fstati64(int fd, struct stati64 *st) int ret = fstat(fd, &tmp); if (ret) return ret; +#ifdef __BORLANDC__ tmp.st_mode &= ~(S_IWGRP | S_IWOTH); +#endif COPY_STAT(tmp, *st, +); if (GetFileInformationByHandle((HANDLE)_get_osfhandle(fd), &info)) { +#ifdef __BORLANDC__ if (!(info.dwFileAttributes & FILE_ATTRIBUTE_READONLY)) { st->st_mode |= S_IWUSR; } +#endif st->st_size = ((__int64)info.nFileSizeHigh << 32) | info.nFileSizeLow; + st->st_atime = filetime_to_unixtime(&info.ftLastAccessTime); + st->st_mtime = filetime_to_unixtime(&info.ftLastWriteTime); + st->st_ctime = filetime_to_unixtime(&info.ftCreationTime); } return ret; } -#endif static time_t filetime_to_unixtime(const FILETIME *ft) @@ -4224,7 +4235,14 @@ static int check_valid_dir(const WCHAR *path) { WIN32_FIND_DATAW fd; - HANDLE fh = open_dir_handle(path, &fd); + HANDLE fh; + + /* GetFileAttributes() determines "..." as directory. */ + /* We recheck it by FindFirstFile(). */ + if (wcsstr(path, L"...") == NULL) + return 0; + + fh = open_dir_handle(path, &fd); if (fh == INVALID_HANDLE_VALUE) return -1; FindClose(fh); @@ -4236,6 +4254,7 @@ winnt_stat(const WCHAR *path, struct stati64 *st) { HANDLE h; WIN32_FIND_DATAW wfd; + WIN32_FILE_ATTRIBUTE_DATA wfa; memset(st, 0, sizeof(*st)); st->st_nlink = 1; @@ -4244,27 +4263,43 @@ winnt_stat(const WCHAR *path, struct stati64 *st) errno = ENOENT; return -1; } - h = FindFirstFileW(path, &wfd); - if (h != INVALID_HANDLE_VALUE) { - FindClose(h); - st->st_mode = fileattr_to_unixmode(wfd.dwFileAttributes, path); - st->st_atime = filetime_to_unixtime(&wfd.ftLastAccessTime); - st->st_mtime = filetime_to_unixtime(&wfd.ftLastWriteTime); - st->st_ctime = filetime_to_unixtime(&wfd.ftCreationTime); - st->st_size = ((__int64)wfd.nFileSizeHigh << 32) | wfd.nFileSizeLow; + if (GetFileAttributesExW(path, GetFileExInfoStandard, (void*)&wfa)) { + if (wfa.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + if (check_valid_dir(path)) return -1; + st->st_size = 0; + } + else { + st->st_size = ((__int64)wfa.nFileSizeHigh << 32) | wfa.nFileSizeLow; + } + st->st_mode = fileattr_to_unixmode(wfa.dwFileAttributes, path); + st->st_atime = filetime_to_unixtime(&wfa.ftLastAccessTime); + st->st_mtime = filetime_to_unixtime(&wfa.ftLastWriteTime); + st->st_ctime = filetime_to_unixtime(&wfa.ftCreationTime); } else { - // If runtime stat(2) is called for network shares, it fails on WinNT. - // Because GetDriveType returns 1 for network shares. (Win98 returns 4) - DWORD attr = GetFileAttributesW(path); - if (attr == (DWORD)-1L) { - errno = map_errno(GetLastError()); + /* GetFileAttributesEx failed; check why. */ + int e = GetLastError(); + + if ((e == ERROR_FILE_NOT_FOUND) || (e == ERROR_INVALID_NAME) + || (e == ERROR_PATH_NOT_FOUND || (e == ERROR_BAD_NETPATH))) { + errno = map_errno(e); return -1; } - if (attr & FILE_ATTRIBUTE_DIRECTORY) { - if (check_valid_dir(path)) return -1; + + /* Fall back to FindFirstFile for ERROR_SHARING_VIOLATION */ + h = FindFirstFileW(path, &wfd); + if (h != INVALID_HANDLE_VALUE) { + FindClose(h); + st->st_mode = fileattr_to_unixmode(wfd.dwFileAttributes, path); + st->st_atime = filetime_to_unixtime(&wfd.ftLastAccessTime); + st->st_mtime = filetime_to_unixtime(&wfd.ftLastWriteTime); + st->st_ctime = filetime_to_unixtime(&wfd.ftCreationTime); + st->st_size = ((__int64)wfd.nFileSizeHigh << 32) | wfd.nFileSizeLow; + } + else { + errno = map_errno(GetLastError()); + return -1; } - st->st_mode = fileattr_to_unixmode(attr, path); } st->st_dev = st->st_rdev = (iswalpha(path[0]) && path[1] == L':') ? @@ -5145,6 +5180,49 @@ rb_w32_close(int fd) return 0; } +static int +setup_overlapped(OVERLAPPED *ol, int fd) +{ + memset(ol, 0, sizeof(*ol)); + if (!(_osfile(fd) & (FDEV | FPIPE))) { + LONG high = 0; + DWORD method = _osfile(fd) & FAPPEND ? FILE_END : FILE_CURRENT; + DWORD low = SetFilePointer((HANDLE)_osfhnd(fd), 0, &high, method); +#ifndef INVALID_SET_FILE_POINTER +#define INVALID_SET_FILE_POINTER ((DWORD)-1) +#endif + if (low == INVALID_SET_FILE_POINTER) { + DWORD err = GetLastError(); + if (err != NO_ERROR) { + errno = map_errno(err); + return -1; + } + } + ol->Offset = low; + ol->OffsetHigh = high; + } + ol->hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); + if (!ol->hEvent) { + errno = map_errno(GetLastError()); + return -1; + } + return 0; +} + +static void +finish_overlapped(OVERLAPPED *ol, int fd, DWORD size) +{ + CloseHandle(ol->hEvent); + + if (!(_osfile(fd) & (FDEV | FPIPE))) { + LONG high = ol->OffsetHigh; + DWORD low = ol->Offset + size; + if (low < ol->Offset) + ++high; + SetFilePointer((HANDLE)_osfhnd(fd), low, &high, FILE_BEGIN); + } +} + #undef read ssize_t rb_w32_read(int fd, void *buf, size_t size) @@ -5181,7 +5259,7 @@ rb_w32_read(int fd, void *buf, size_t size) } ret = 0; - isconsole = is_console(_osfhnd(fd)); + isconsole = is_console(_osfhnd(fd)) && (osver.dwMajorVersion < 6 || (osver.dwMajorVersion == 6 && osver.dwMinorVersion < 2)); if (isconsole) { DWORD mode; GetConsoleMode((HANDLE)_osfhnd(fd),&mode); @@ -5203,25 +5281,7 @@ rb_w32_read(int fd, void *buf, size_t size) /* if have cancel_io, use Overlapped I/O */ if (cancel_io) { - memset(&ol, 0, sizeof(ol)); - if (!(_osfile(fd) & (FDEV | FPIPE))) { - LONG high = 0; - DWORD low = SetFilePointer((HANDLE)_osfhnd(fd), 0, &high, - FILE_CURRENT); -#ifndef INVALID_SET_FILE_POINTER -#define INVALID_SET_FILE_POINTER ((DWORD)-1) -#endif - if (low == INVALID_SET_FILE_POINTER) { - errno = map_errno(GetLastError()); - MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock)); - return -1; - } - ol.Offset = low; - ol.OffsetHigh = high; - } - ol.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); - if (!ol.hEvent) { - errno = map_errno(GetLastError()); + if (setup_overlapped(&ol, fd)) { MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock)); return -1; } @@ -5275,15 +5335,7 @@ rb_w32_read(int fd, void *buf, size_t size) } if (pol) { - CloseHandle(ol.hEvent); - - if (!(_osfile(fd) & (FDEV | FPIPE))) { - LONG high = ol.OffsetHigh; - DWORD low = ol.Offset + read; - if (low < ol.Offset) - ++high; - SetFilePointer((HANDLE)_osfhnd(fd), low, &high, FILE_BEGIN); - } + finish_overlapped(&ol, fd, read); } ret += read; @@ -5341,25 +5393,7 @@ rb_w32_write(int fd, const void *buf, size_t size) /* if have cancel_io, use Overlapped I/O */ if (cancel_io) { - memset(&ol, 0, sizeof(ol)); - if (!(_osfile(fd) & (FDEV | FPIPE))) { - LONG high = 0; - DWORD method = _osfile(fd) & FAPPEND ? FILE_END : FILE_CURRENT; - DWORD low = SetFilePointer((HANDLE)_osfhnd(fd), 0, &high, method); -#ifndef INVALID_SET_FILE_POINTER -#define INVALID_SET_FILE_POINTER ((DWORD)-1) -#endif - if (low == INVALID_SET_FILE_POINTER) { - errno = map_errno(GetLastError()); - MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock)); - return -1; - } - ol.Offset = low; - ol.OffsetHigh = high; - } - ol.hEvent = CreateEvent(NULL, TRUE, TRUE, NULL); - if (!ol.hEvent) { - errno = map_errno(GetLastError()); + if (setup_overlapped(&ol, fd)) { MTHREAD_ONLY(LeaveCriticalSection(&_pioinfo(fd)->lock)); return -1; } @@ -5405,15 +5439,7 @@ rb_w32_write(int fd, const void *buf, size_t size) } if (pol) { - CloseHandle(ol.hEvent); - - if (!(_osfile(fd) & (FDEV | FPIPE))) { - LONG high = ol.OffsetHigh; - DWORD low = ol.Offset + written; - if (low < ol.Offset) - ++high; - SetFilePointer((HANDLE)_osfhnd(fd), low, &high, FILE_BEGIN); - } + finish_overlapped(&ol, fd, written); } ret += written; @@ -5456,27 +5482,11 @@ rb_w32_write_console(uintptr_t strarg, int fd) static int unixtime_to_filetime(time_t time, FILETIME *ft) { - struct tm *tm; - SYSTEMTIME st; - FILETIME lt; + ULARGE_INTEGER tmp; - tm = localtime(&time); - if (!tm) { - return -1; - } - st.wYear = tm->tm_year + 1900; - st.wMonth = tm->tm_mon + 1; - st.wDayOfWeek = tm->tm_wday; - st.wDay = tm->tm_mday; - st.wHour = tm->tm_hour; - st.wMinute = tm->tm_min; - st.wSecond = tm->tm_sec; - st.wMilliseconds = 0; - if (!SystemTimeToFileTime(&st, <) || - !LocalFileTimeToFileTime(<, ft)) { - errno = map_errno(GetLastError()); - return -1; - } + tmp.QuadPart = ((LONG_LONG)time + (LONG_LONG)((1970-1601)*365.2425) * 24 * 60 * 60) * 10 * 1000 * 1000; + ft->dwLowDateTime = tmp.LowPart; + ft->dwHighDateTime = tmp.HighPart; return 0; } |