summaryrefslogtreecommitdiff
path: root/spec/ruby/core/time/now_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/time/now_spec.rb')
0 files changed, 0 insertions, 0 deletions
.4%;'/> -rw-r--r--bignum.c21
-rw-r--r--class.c50
-rw-r--r--configure.in61
-rw-r--r--defines.h8
-rw-r--r--dln.c41
-rw-r--r--eval.c34
-rw-r--r--ext/Win32API/lib/win32/registry.rb2
-rw-r--r--ext/Win32API/lib/win32/resolv.rb2
-rw-r--r--ext/bigdecimal/bigdecimal.c59
-rw-r--r--ext/bigdecimal/extconf.rb10
-rw-r--r--ext/dl/ptr.c36
-rw-r--r--ext/iconv/iconv.c36
-rw-r--r--ext/pty/lib/expect.rb2
-rw-r--r--ext/readline/extconf.rb7
-rw-r--r--ext/readline/readline.c19
-rw-r--r--ext/syck/rubyext.c1
-rw-r--r--ext/zlib/extconf.rb4
-rw-r--r--ext/zlib/zlib.c13
-rw-r--r--file.c87
-rw-r--r--gc.c16
-rw-r--r--intern.h1
-rw-r--r--io.c46
-rw-r--r--lib/benchmark.rb7
-rw-r--r--lib/cgi.rb8
-rw-r--r--lib/date.rb4
-rw-r--r--lib/delegate.rb30
-rw-r--r--lib/erb.rb29
-rw-r--r--lib/irb.rb18
-rw-r--r--lib/mkmf.rb2
-rw-r--r--lib/net/pop.rb2
-rw-r--r--lib/net/telnet.rb13
-rw-r--r--lib/resolv.rb3
-rw-r--r--lib/singleton.rb3
-rw-r--r--lib/timeout.rb23
-rw-r--r--lib/uri/common.rb2
-rw-r--r--lib/uri/generic.rb3
-rw-r--r--lib/xmlrpc/server.rb6
-rw-r--r--lib/yaml.rb4
-rw-r--r--lib/yaml/basenode.rb2
-rw-r--r--lib/yaml/rubytypes.rb18
-rw-r--r--lib/yaml/types.rb8
-rw-r--r--marshal.c46
-rw-r--r--misc/ruby-mode.el2
-rw-r--r--missing/strftime.c56
-rw-r--r--numeric.c32
-rw-r--r--object.c1
-rw-r--r--parse.y35
-rw-r--r--process.c3
-rw-r--r--re.c7
-rw-r--r--regex.c4
-rw-r--r--signal.c22
-rw-r--r--sprintf.c15
-rw-r--r--string.c72
-rw-r--r--struct.c13
-rw-r--r--test/erb/hello.erb4
-rw-r--r--test/erb/test_erb.rb384
-rw-r--r--test/ruby/test_beginendblock.rb12
-rw-r--r--test/ruby/test_bignum.rb8
-rw-r--r--test/yaml/test_yaml.rb8
-rw-r--r--time.c6
-rw-r--r--util.c3411
-rw-r--r--version.h8
-rw-r--r--win32/win32.c276
-rw-r--r--win32/win32.h1
66 files changed, 762 insertions, 5043 deletions
diff --git a/ChangeLog b/ChangeLog
index f47a29a9ba..5dce6cf23a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,523 +1,3 @@
-Fri Jun 27 17:38:21 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/zlib/zlib.c (rb_deflate_initialize, Init_zlib): Fix up
- initialize_copy; [ruby-list:45016], [ruby-list:45018].
-
-Fri Jun 27 17:28:39 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * io.c (rb_open_file, rb_io_s_sysopen): fmode should be unsigned int.
- fixed [ruby-dev:34979]
-
-Fri Jun 27 17:20:40 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.h: include ws2tcpip.h. fixed [ruby-Bugs-20528]
-
-Fri Jun 27 15:57:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/iconv/iconv.c (iconv_iconv): fixed backport miss.
- [ruby-core:17115]
-
-Fri Jun 27 15:57:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/iconv/iconv.c (iconv_iconv): fix for length argument and now
- allows range. [ruby-core:17092]
-
-Tue Jun 24 15:38:52 2008 Masatoshi SEKI <m_seki@mva.biglobe.ne.jp>
-
- * lib/erb.rb (ERB::Compiler::TrimScanner#explicit_trim_line): Fix
- without strscan problems. [ruby_core:17028].
-
- * test/erb/test_erb.rb (TestERBCoreWOStrScan): Add test class for
- without strscan.
-
-Sun Jun 22 00:09:20 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/delegate.rb (DelegateClass, Delegator#respond_to?):
- respond_to? should now take optional second argument; submitted
- by Jeremy Kemper <jeremy at bitsweat.net> in [ruby-core:17045].
-
-Fri Jun 20 18:24:18 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * string.c (rb_str_buf_append): should infect.
-
-Fri Jun 20 15:52:30 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (rb_ary_store, rb_ary_splice): not depend on unspecified
- behavior at integer overflow.
-
- * string.c (str_buf_cat): ditto.
-
-Wed Jun 18 22:25:10 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
-
- * array.c (ary_new, rb_ary_initialize, rb_ary_store,
- rb_ary_aplice, rb_ary_times): integer overflows should be
- checked. based on patches from Drew Yao <ayao at apple.com>
- fixed CVE-2008-2726
-
- * string.c (rb_str_buf_append): fixed unsafe use of alloca,
- which led memory corruption. based on a patch from Drew Yao
- <ayao at apple.com> fixed CVE-2008-2726
-
- * sprintf.c (rb_str_format): backported from trunk.
-
- * intern.h: ditto.
-
-Fri Jun 20 01:40:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * array.c (rb_ary_equal, rb_ary_eql, rb_ary_hash, rb_ary_cmp):
- Make Array#eql?, #hash, #== and #<=> use rb_protect_inspect() and
- handle recursive data properly. [ruby-dev:35181]
-
-Wed Jun 18 15:20:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * marshal.c (w_object, marshal_dump, r_object0, marshal_load): search
- public methods only. [ruby-core:17283]
-
- * object.c (convert_type): ditto.
-
- * lib/singleton.rb (Singleton#_dump): conversion method should be
- public.
-
-Wed Jun 18 13:19:55 2008 URABE Shyouhei <shyouhei@ruby-lang.org>
-
- * file.c: fixes to compile on mswin32. Patch from U. Nakamura
- <usa at garbagecollect.jp>. [ruby-dev:35127]
-
-Tue Jun 17 22:16:44 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (LIBPATHFLAG, RPATHFLAG): no needs to be quoted,
- it is done by libpathflag in mkmf.rb.
-
-Mon Jun 16 15:43:07 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * proc.c (proc_dup): should copy safe_level from src proc
- properly. a patch from Keita Yamaguchi
- <keita.yamaguchi at gmail.com>
-
-Sun Jun 15 23:31:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/zlib/extconf.rb: search zlib1, and regard mswin32 later than VC6
- as WIN32. [ruby-core:16984]
-
-Sun Jun 15 23:28:15 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * marshal.c (w_object, marshal_dump, r_object0, marshal_load): search
- private methods too. [ruby-dev:34671]
-
- * object.c (convert_type): ditto.
-
-Sun Jun 15 23:26:50 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * numeric.c (flo_divmod): Revert the behavior change; do not
- suppress an exception when div is NaN or Inf. [ruby-dev:34857]
-
-Sun Jun 15 23:24:32 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * file.c (BUFCHECK): wrong condition. [ruby-core:16921]
-
- * file.c (file_expand_buf): shouldn't use buflen for length of string.
-
-Sun Jun 15 23:21:22 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * marshal.c (r_object0, Init_marshal): Fix the garbled s_call
- definition; fixes [ruby-dev:34843].
-
-Sun Jun 15 23:19:53 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * object.c (rb_cstr_to_dbl): should clear errno before calling
- strtod(3). [ruby-dev:34834]
-
-Sun Jun 15 23:18:15 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (marshal_load): should initialize arg.data used for
- reentrant check. [ruby-dev:34837]
-
-Sun Jun 15 23:13:23 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * parse.y (top_local_setup): fixed memory leak bug based on a
- patch from Roger Pack <rogerpack2005 at gmail.com> in
- [ruby-core:16610].
-Sun Jun 15 23:16:26 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (reentrant_check): check reentrance via callcc.
- [ruby-dev:34802]
-
-
-Sun Jun 15 23:09:00 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * sprintf.c (rb_f_sprintf): fixed SEGV on win32 with "% 0e" % 1.0/0.0.
-
-Sun Jun 15 23:07:46 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * process.c (rb_f_system): set last_status when status == -1 because
- there is no path to set it on win32. this patch is derived from
- [ruby-core:16787], submitted by Luis Lavena <luislavena at gmail.com>
-
-Sun Jun 15 23:02:12 2008 GOTOU Yuuzou <gotoyuzo@notwork.org>
-
- * lib/webrick/httpservlet/filehandler.rb: should normalize path
- name in path_info to prevent script disclosure vulnerability on
- DOSISH filesystems. (fix: CVE-2008-1891)
- Note: NTFS/FAT filesystem should not be published by the platforms
- other than Windows. Pathname interpretation (including short
- filename) is less than perfect.
-
- * lib/webrick/httpservlet/abstract.rb
- (WEBrick::HTTPServlet::AbstracServlet#redirect_to_directory_uri):
- should escape the value of Location: header.
-
- * lib/webrick/httpservlet/cgi_runner.rb: accept interpreter
- command line arguments.
-
-Sun Jun 15 23:02:12 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * file.c (file_expand_path): support for alternative data stream
- and ignored trailing garbages of NTFS.
-
- * file.c (rb_file_s_basename): ditto.
-
- * file.c (rb_file_s_extname): ditto.
-
-Sun Jun 15 22:53:20 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * string.c (rb_str_cat): fixed buffer overrun reported by
- Christopher Thompson <cthompson at nexopia.com> in [ruby-core:16746]
-
-Sun Jun 15 22:51:24 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * eval.c (is_defined): add NODE_OP_ASGN_{OR,AND}. "defined?(a||=1)"
- should not operate assignment. [ruby-dev:34645]
-
-Sun Jun 15 22:49:45 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * win32/win32.c (rb_w32_select): backport from trunk.
- [ruby-talk:300743]
-
-Sun Jun 15 22:48:26 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/delegate.rb (SimpleDelegator::dup): removed needless argument.
- [ruby-list:44910]
-
- * lib/delegate.rb (clone, dup): keep relationship with the target
- object.
-
-Sun Jun 15 22:46:34 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * util.c (ruby_strtod): backported from 1.9. a patch from Satoshi
- Nakagawa <psychs at limechat.net> in [ruby-dev:34625].
- fixed: [ruby-dev:34623]
-
-Sun Jun 15 22:44:25 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * struct.c (rb_struct_s_def): to_str should be called only once.
- [ruby-core:16647]
-
-Sun Jun 15 22:42:54 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/zlib/zlib.c (gzreader_gets): may cause infinite loop.
- a patch from Kouya <kouyataifu4 at gmail.com> in
- [ruby-reference-manual:762].
-
-Sun Jun 15 22:34:09 2008 James Edward Gray II <jeg2@ruby-lang.org>
-
- Merged 16241 from trunk.
-
- * lib/net/telnet.rb: Fixing a bug where line endings would not be properly
- escaped when the two character ending was broken up into separate TCP
- packets. Issue reported and patched by Brian Candler.
-
-Sun Jun 15 22:31:47 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * re.c (rb_reg_search): use local variable. a patch from wanabe
- <s.wanabe AT gmail.com> in [ruby-dev:34537]. [ruby-dev:34492]
-
-Sun Jun 15 22:20:45 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * sprintf.c (rb_f_sprintf): should protect temporary string from
- GC. [ruby-dev:34480]
-
-Sun Jun 15 22:18:30 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * regex.c (re_search): string might be NULL. [ruby-core:16478]
-
-Sun Jun 15 22:16:21 2008 NAKAMURA Usaku <usa@ruby-lang.org>
-
- * time.c (rb_strftime): check errno to detect strftime(3)'s error.
- this is workaround for recent version of MSVCRT.
- [ruby-dev:34456]
-
-Sun Jun 15 22:12:07 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * lib/yaml/types.rb: Likewise, pass self to YAML::quick_emit;
- merged from 1.9.
-
- * lib/yaml.rb (quick_emit): use combination of object_id and hash to
- identify repeated object references, since GC will reuse memory of
- objects during output of YAML. [ruby-Bugs-8548] [ruby-Bugs-3698];
- merged from 1.9.
-
-Sun Jun 15 22:09:02 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * ext/syck/rubyext.c: Node#value defined twice.
-
- * lib/yaml/: several method redefinitions causing warnings.
-
-Sun Jun 15 22:04:44 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * marshal.c (w_object): add volatile to avoid potential GC bug. a
- patch from Tomoyuki Chikanaga <chikanag at nippon-control-system.co.jp>
- in [ruby-dev:34311].
-
-Sun Jun 15 21:59:22 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * re.c (rb_reg_quote): should always copy the quoting string.
- [ruby-core:16235]
-
-Sun Jun 15 21:27:46 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/net/pop.rb (Net::POP3::do_finish): clear @n_mails and
- @n_bytes as well. [ruby-core:16144]
-
-Sun Jun 15 21:08:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/resolv.rb (Resolv::Config.default_config_hash): requires
- win32/resolv to use Win32::Resolv. [ruby-dev:34138]
-
-Sun Jun 15 20:54:07 2008 Akinori MUSHA <knu@iDaemons.org>
-
- * parse.y (yycompile): Always prepare a new array for each file's
- SCRIPT_LINES__ storage, instead of appending source lines every
- time a file is re-loaded; submitted by Rocky Bernstein in
- #18517.
-
-Sun Jun 15 20:30:01 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/resolv.rb (Resolv::Hosts): should not use win32/resolv on cygwin.
- [ruby-dev:29945], [ruby-dev:34095]
-
- * lib/win32/registry.rb (Win32::Registry.expand_environ): try upcased
- name too for cygwin. [ruby-dev:29945]
-
- * lib/win32/resolv.rb (Win32::Resolv.get_hosts_path): use expand_path.
-
-Sun Jun 15 20:27:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * misc/ruby-mode.el (ruby-mode): should use `run-mode-hooks' instead
- of calling `run-hooks' directly to run the mode hook. patch from
- Chiyuan Zhang <pluskid AT gmail.com> in [ruby-core:15915]
-
-Sun Jun 15 20:20:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * numeric.c (fix_coerce): try conversion before type check.
- [ruby-core:15838]
-
-Sun Jun 15 19:56:53 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (BIGZEROP): fix for longer Bignum zeros. [ruby-Bugs-17454]
-
-Sun Jun 15 19:54:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (big2str_find_n1): check integer overflow.
-
-Sun Jun 15 19:52:20 2008 Tanaka Akira <akr@fsij.org>
-
- * gc.c (STACK_LENGTH) [SPARC] : 0x80 offset removed. [ruby-dev:33857]
-
-Sun Jun 15 19:50:20 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/readline/readline.c (readline_event): prevent polling. based on
- a patch from error errorsson in [ruby-Bugs-17675].
-
-Sun Jun 15 19:44:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (yycompile): clear ruby_eval_tree_begin if parse failed.
-
-Sun Jun 15 19:44:52 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (yycompile): clear ruby_eval_tree_begin too before parse.
-
-Sun Jun 15 19:22:21 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/pty/lib/expect.rb (IO#expect): check if peer is closed.
- [ruby-Bugs-17940]
-
-Sun Jun 15 19:20:13 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/iconv/iconv.c (iconv_convert): check upper bound. a patch from
- Daniel Luz at [ruby-Bugs-17910].
-
-Sun Jun 15 19:13:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (ftruncate): check if available.
-
- * file.c (rb_file_truncate): check if ftruncate instead of truncate.
-
-Sun Jun 15 19:02:46 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (sigsetmask): check when signal semantics is not POSIX.
-
- * signal.c (USE_TRAP_MASK): set true if sigprocmask or sigsetmask is
- available.
-
-Sat Jun 14 16:49:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/timeout.rb (Timeout::timeout): made sensitive to location on the
- stack. [ruby-core:15458]
-
-Fri Jun 13 13:14:31 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * ext/dl/ptr.c (dlmem_each_i): typo fixed. a patch from IKOMA
-Sun Jun 15 21:06:12 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * class.c (clone_method): should copy cref as well.
- [ruby-core:15833]
-
- Yoshiki <ikoma@mb.i-chubu.ne.jp> in [ruby-dev:33776].
-
-Fri Jun 13 13:13:23 2008 URABE Shyouhei <shyouhei@ice.uec.ac.jp>
-
- * gc.c (rb_newobj): prohibit call of rb_newobj() during gc.
- Submitted by Sylvain Joyeux [ruby-core:12099].
-
- * ext/dl/ptr.c: do not use LONG2NUM() inside dlptr_free().
- Slightly modified fix bassed on a patch by Sylvain Joyeux
- [ruby-core:12099] [ ruby-bugs-11859 ] [ ruby-bugs-11882 ]
- [ ruby-patches-13151 ].
-
-Fri Jun 13 12:10:13 2008 NARUSE, Yui <naruse@ruby-lang.org>
-
- * lib/benchmark.rb (Job::Benchmark#item): fix typo.
-
-Fri Jun 13 12:06:17 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * ext/bigdecimal/bigdecimal.c (BigDecimal_to_f): use strtod() for more
- precision. [ruby-talk:290296]
-
- * ext/bigdecimal/bigdecimal.c (BASE_FIG): made constant.
-
- * ext/bigdecimal/extconf.rb: ditto. [ruby-dev:33658]
-
-Fri Jun 13 12:01:57 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/irb.rb (IRB::Irb::eval_input): rescues Interrupt and other than
- SystemExit and SignalException. [ruby-core:15359]
-
-Fri Jun 13 11:57:46 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * lib/benchmark.rb (Benchmark::realtime): make Benchmark#realtime
- a bit faster. a patch from Alexander Dymo <dymo@ukrpost.ua> in
- [ruby-core:15337].
-
-Fri Jun 13 11:50:59 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
-
- * io.c (rb_open_file): should check NUL in path.
- <http://www.rubyist.net/~matz/20080125.html#c01>.
-
- * io.c (rb_io_s_popen): ditto.
-
- * io.c (rb_io_reopen): ditto.
-
- * io.c (next_argv): ditto.
-
- * io.c (rb_io_s_foreach): ditto.
-
- * io.c (rb_io_s_readlines): ditto.
-
- * io.c (rb_io_s_read): ditto.
-
-Wed Jun 11 15:23:13 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/uri/generic.rb (URI::Generic::inspect): use Kernel#to_s instead
- object_id with printf. [ruby-dev:33347]
-
-Wed Jun 11 15:00:55 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in: Remove wrong assumptions about Cygwin. a patch from
- Corinna Vinschen in [ruby-Bugs-17018].
-
-Mon Jun 9 18:09:20 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (eval): check if backtrace is empty. [ruby-core:15040]
-
-Sun Jun 8 06:08:26 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (rb_define_alloc_func, rb_undef_alloc_func): should
- define/undef on a signleton class. [ruby-core:09959]
-
-Sun Jun 8 06:04:41 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * time.c (time_arg): use converted object. [ruby-core:14759]
-
-Sun Jun 8 06:02:11 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * io.c (fptr_finalize): clear errno first. [ruby-talk:284492]
-
-Sun Jun 8 05:59:36 2008 Tadayoshi Funaba <tadf@dotrb.org>
-
- * lib/date.rb: don't freeze nil even if 1.8 will not be aware of
- the issue. [ruby-dev:32677]
-
-Sun Jun 8 05:54:44 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (TIMEZONE_VOID): check whether timezone requires zero
- arguments. [ruby-dev:32631]
-
-Sun Jun 8 05:37:10 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (f_rest_arg): check if duplicated. [ruby-core:14140]
-
-Sun Jun 8 05:32:45 2008 Tanaka Akira <akr@fsij.org>
-
- * gc.c (stack_end_address): use local variable address instead of
- __builtin_frame_address(0) to avoid SEGV on SunOS 5.11 on x86 with
- gcc (GCC) 3.4.3 (csl-sol210-3_4-20050802).
-
-Sun Jun 8 05:24:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * configure.in (RUBY_CHECK_VARTYPE): check if a variable is defined
- and its type.
-
- * configure.in (timezone, altzone): check for recent cygwin.
-
- * missing/strftime.c (strftime): fix for timezone. [ruby-dev:32536]
-
- * lib/mkmf.rb (try_var): should fail for functions.
-
- * ext/readline/extconf.rb: should use have_func for functions instead
- of have_var.
-
-Sun Jun 8 05:08:35 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * lib/cgi.rb (read_multipart): exclude blanks from header values.
- [ruby-list:44327]
-
-Sun Jun 8 05:02:25 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * bignum.c (rb_cstr_to_inum): trailing spaces may exist at sqeezing
- preceeding 0s. [ruby-core:13873]
-
-Sun Jun 8 04:58:05 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * eval.c (error_print): put newline unless multiple line message ends
- with a newline. [ruby-dev:32429]
-
-Sun Jun 8 04:55:26 2008 James Edward Gray II <jeg2@ruby-lang.org>
-
- Merged 14070 from trunk.
-
- * lib/xmlrpc/server.rb (XMLRPC::Server#server): Improve signal handling so
- pressing control-c in the controlling terminal or sending SIGTERM stops
- the XML-RPC server.
-
-Sun Jun 8 04:49:43 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (newline_node): set line from outermost node before removing
- NODE_BEGIN. [ruby-dev:32406]
-
-Sun Jun 8 04:37:34 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
-
- * parse.y (stmt): remove unnecessary NODE_BEGIN. [ruby-core:13814]
-
Sun Jun 8 04:16:35 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_alias): do not call hook functions until initialization
diff --git a/array.c b/array.c
index c5261044da..fbca3c193e 100644
--- a/array.c
+++ b/array.c
@@ -20,7 +20,6 @@ VALUE rb_cArray;
static ID id_cmp;
#define ARY_DEFAULT_SIZE 16
-#define ARY_MAX_SIZE (LONG_MAX / sizeof(VALUE))
void
rb_mem_clear(mem, size)
@@ -121,7 +120,7 @@ ary_new(klass, len)
if (len < 0) {
rb_raise(rb_eArgError, "negative array size (or size too big)");
}
- if (len > ARY_MAX_SIZE) {
+ if (len > 0 && len * sizeof(VALUE) <= len) {
rb_raise(rb_eArgError, "array size too big");
}
if (len == 0) len++;
@@ -294,7 +293,7 @@ rb_ary_initialize(argc, argv, ary)
if (len < 0) {
rb_raise(rb_eArgError, "negative array size");
}
- if (len > ARY_MAX_SIZE) {
+ if (len > 0 && len * (long)sizeof(VALUE) <= len) {
rb_raise(rb_eArgError, "array size too big");
}
if (len > RARRAY(ary)->aux.capa) {
@@ -359,9 +358,6 @@ rb_ary_store(ary, idx, val)
idx - RARRAY(ary)->len);
}
}
- else if (idx >= ARY_MAX_SIZE) {
- rb_raise(rb_eIndexError, "index %ld too big", idx);
- }
rb_ary_modify(ary);
if (idx >= RARRAY(ary)->aux.capa) {
@@ -370,10 +366,10 @@ rb_ary_store(ary, idx, val)
if (new_capa < ARY_DEFAULT_SIZE) {
new_capa = ARY_DEFAULT_SIZE;
}
- if (new_capa >= ARY_MAX_SIZE - idx) {
- new_capa = (ARY_MAX_SIZE - idx) / 2;
- }
new_capa += idx;
+ if (new_capa * (long)sizeof(VALUE) <= new_capa) {
+ rb_raise(rb_eArgError, "index too big");
+ }
REALLOC_N(RARRAY(ary)->ptr, VALUE, new_capa);
RARRAY(ary)->aux.capa = new_capa;
}
@@ -979,9 +975,6 @@ rb_ary_splice(ary, beg, len, rpl)
rb_ary_modify(ary);
if (beg >= RARRAY(ary)->len) {
- if (beg > ARY_MAX_SIZE - rlen) {
- rb_raise(rb_eIndexError, "index %ld too big", beg);
- }
len = beg + rlen;
if (len >= RARRAY(ary)->aux.capa) {
REALLOC_N(RARRAY(ary)->ptr, VALUE, len);
@@ -2385,7 +2378,7 @@ rb_ary_times(ary, times)
if (len < 0) {
rb_raise(rb_eArgError, "negative argument");
}
- if (ARY_MAX_SIZE/len < RARRAY(ary)->len) {
+ if (LONG_MAX/len < RARRAY(ary)->len) {
rb_raise(rb_eArgError, "argument too big");
}
len *= RARRAY(ary)->len;
@@ -2469,19 +2462,6 @@ rb_ary_rassoc(ary, value)
return Qnil;
}
-static VALUE
-recursive_equal(ary1, ary2)
- VALUE ary1, ary2;
-{
- long i;
-
- for (i=0; i<RARRAY(ary1)->len; i++) {
- if (!rb_equal(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
- return Qfalse;
- }
- return Qtrue;
-}
-
/*
* call-seq:
* array == other_array -> bool
@@ -2500,6 +2480,8 @@ static VALUE
rb_ary_equal(ary1, ary2)
VALUE ary1, ary2;
{
+ long i;
+
if (ary1 == ary2) return Qtrue;
if (TYPE(ary2) != T_ARRAY) {
if (!rb_respond_to(ary2, rb_intern("to_ary"))) {
@@ -2508,18 +2490,8 @@ rb_ary_equal(ary1, ary2)
return rb_equal(ary2, ary1);
}
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
- if (rb_inspecting_p(ary1)) return Qfalse;
- return rb_protect_inspect(recursive_equal, ary1, ary2);
-}
-
-static VALUE
-recursive_eql(ary1, ary2)
- VALUE ary1, ary2;
-{
- long i;
-
for (i=0; i<RARRAY(ary1)->len; i++) {
- if (!rb_eql(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
+ if (!rb_equal(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
return Qfalse;
}
return Qtrue;
@@ -2537,29 +2509,16 @@ static VALUE
rb_ary_eql(ary1, ary2)
VALUE ary1, ary2;
{
+ long i;
+
if (ary1 == ary2) return Qtrue;
if (TYPE(ary2) != T_ARRAY) return Qfalse;
if (RARRAY(ary1)->len != RARRAY(ary2)->len) return Qfalse;
- if (rb_inspecting_p(ary1)) return Qfalse;
- return rb_protect_inspect(recursive_eql, ary1, ary2);
-}
-
-static VALUE recursive_hash _((VALUE ary));
-
-static VALUE
-recursive_hash(ary)
- VALUE ary;
-{
- long i, h;
- VALUE n;
-
- h = RARRAY(ary)->len;
- for (i=0; i<RARRAY(ary)->len; i++) {
- h = (h << 1) | (h<0 ? 1 : 0);
- n = rb_hash(RARRAY(ary)->ptr[i]);
- h ^= NUM2LONG(n);
+ for (i=0; i<RARRAY(ary1)->len; i++) {
+ if (!rb_eql(rb_ary_elt(ary1, i), rb_ary_elt(ary2, i)))
+ return Qfalse;
}
- return LONG2FIX(h);
+ return Qtrue;
}
/*
@@ -2574,10 +2533,16 @@ static VALUE
rb_ary_hash(ary)
VALUE ary;
{
- if (rb_inspecting_p(ary)) {
- return LONG2FIX(0);
+ long i, h;
+ VALUE n;
+
+ h = RARRAY(ary)->len;
+ for (i=0; i<RARRAY(ary)->len; i++) {
+ h = (h << 1) | (h<0 ? 1 : 0);
+ n = rb_hash(RARRAY(ary)->ptr[i]);
+ h ^= NUM2LONG(n);
}
- return rb_protect_inspect(recursive_hash, ary, 0);
+ return LONG2FIX(h);
}
/*
@@ -2608,24 +2573,6 @@ rb_ary_includes(ary, item)
return Qfalse;
}
-VALUE
-recursive_cmp(ary1, ary2)
- VALUE ary1, ary2;
-{
- long i, len;
-
- len = RARRAY(ary1)->len;
- if (len > RARRAY(ary2)->len) {
- len = RARRAY(ary2)->len;
- }
- for (i=0; i<len; i++) {
- VALUE v = rb_funcall(rb_ary_elt(ary1, i), id_cmp, 1, rb_ary_elt(ary2, i));
- if (v != INT2FIX(0)) {
- return v;
- }
- }
- return Qundef;
-}
/*
* call-seq:
@@ -2651,14 +2598,19 @@ VALUE
rb_ary_cmp(ary1, ary2)
VALUE ary1, ary2;
{
- long len;
- VALUE v;
+ long i, len;
ary2 = to_ary(ary2);
- if (ary1 == ary2) return INT2FIX(0);
- if (rb_inspecting_p(ary1)) return INT2FIX(0);
- v = rb_protect_inspect(recursive_cmp, ary1, ary2);
- if (v != Qundef) return v;
+ len = RARRAY(ary1)->len;
+ if (len > RARRAY(ary2)->len) {
+ len = RARRAY(ary2)->len;
+ }
+ for (i=0; i<len; i++) {
+ VALUE v = rb_funcall(rb_ary_elt(ary1, i), id_cmp, 1, rb_ary_elt(ary2, i));
+ if (v != INT2FIX(0)) {
+ return v;
+ }
+ }
len = RARRAY(ary1)->len - RARRAY(ary2)->len;
if (len == 0) return INT2FIX(0);
if (len > 0) return INT2FIX(1);
diff --git a/bignum.c b/bignum.c
index e3d531ceaf..25ca9be87e 100644
--- a/bignum.c
+++ b/bignum.c
@@ -36,21 +36,7 @@ VALUE rb_cBignum;
#define BIGLO(x) ((BDIGIT)((x) & (BIGRAD-1)))
#define BDIGMAX ((BDIGIT)-1)
-#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || \
- (BDIGITS(x)[0] == 0 && \
- (RBIGNUM(x)->len == 1 || bigzero_p(x))))
-
-static int bigzero_p(VALUE);
-static int
-bigzero_p(x)
- VALUE x;
-{
- long i;
- for (i = 0; i < RBIGNUM(x)->len; ++i) {
- if (BDIGITS(x)[i]) return 0;
- }
- return 1;
-}
+#define BIGZEROP(x) (RBIGNUM(x)->len == 0 || (RBIGNUM(x)->len == 1 && BDIGITS(x)[0] == 0))
static VALUE
bignew_1(klass, len, sign)
@@ -460,7 +446,7 @@ rb_cstr_to_inum(str, base, badcheck)
}
if (*str == '0') { /* squeeze preceeding 0s */
while (*++str == '0');
- if (!(c = *str) || ISSPACE(c)) --str;
+ if (!*str) --str;
}
c = *str;
c = conv_digit(c);
@@ -666,9 +652,6 @@ rb_big2str0(x, base, trim)
if (BIGZEROP(x)) {
return rb_str_new2("0");
}
- if (i >= LONG_MAX/SIZEOF_BDIGITS/CHAR_BIT) {
- rb_raise(rb_eRangeError, "bignum too big to convert into `string'");
- }
j = SIZEOF_BDIGITS*CHAR_BIT*i;
switch (base) {
case 2: break;
diff --git a/class.c b/class.c
index 106f796140..80dc9e4b2d 100644
--- a/class.c
+++ b/class.c
@@ -48,26 +48,13 @@ rb_class_new(super)
return rb_class_boot(super);
}
-struct clone_method_data {
- st_table *tbl;
- VALUE klass;
-};
-
static int
-clone_method(mid, body, data)
+clone_method(mid, body, tbl)
ID mid;
NODE *body;
- struct clone_method_data *data;
+ st_table *tbl;
{
- NODE *fbody = body->nd_body;
-
- if (fbody && nd_type(fbody) == NODE_SCOPE) {
- VALUE cref = data->klass ?
- (VALUE)NEW_NODE(NODE_CREF,data->klass,0,fbody->nd_rval) :
- fbody->nd_rval;
- fbody = NEW_NODE(NODE_SCOPE, fbody->nd_tbl, cref, fbody->nd_next);
- }
- st_insert(data->tbl, mid, (st_data_t)NEW_METHOD(fbody, body->nd_noex));
+ st_insert(tbl, mid, (st_data_t)NEW_METHOD(body->nd_body, body->nd_noex));
return ST_CONTINUE;
}
@@ -78,8 +65,7 @@ rb_mod_init_copy(clone, orig)
{
rb_obj_init_copy(clone, orig);
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
- RBASIC(clone)->klass = RBASIC(orig)->klass;
- RBASIC(clone)->klass = rb_singleton_class_clone(clone);
+ RBASIC(clone)->klass = rb_singleton_class_clone(orig);
}
RCLASS(clone)->super = RCLASS(orig)->super;
if (RCLASS(orig)->iv_tbl) {
@@ -92,12 +78,9 @@ rb_mod_init_copy(clone, orig)
st_delete(RCLASS(clone)->iv_tbl, (st_data_t*)&id, 0);
}
if (RCLASS(orig)->m_tbl) {
- struct clone_method_data data;
-
- data.tbl = RCLASS(clone)->m_tbl = st_init_numtable();
- data.klass = (VALUE)clone;
-
- st_foreach(RCLASS(orig)->m_tbl, clone_method, (st_data_t)&data);
+ RCLASS(clone)->m_tbl = st_init_numtable();
+ st_foreach(RCLASS(orig)->m_tbl, clone_method,
+ (st_data_t)RCLASS(clone)->m_tbl);
}
return clone;
@@ -143,22 +126,9 @@ rb_singleton_class_clone(obj)
if (RCLASS(klass)->iv_tbl) {
clone->iv_tbl = st_copy(RCLASS(klass)->iv_tbl);
}
- {
- struct clone_method_data data;
-
- data.tbl = clone->m_tbl = st_init_numtable();
- switch (TYPE(obj)) {
- case T_CLASS:
- case T_MODULE:
- data.klass = obj;
- break;
- default:
- data.klass = 0;
- break;
- }
-
- st_foreach(RCLASS(klass)->m_tbl, clone_method, (st_data_t)&data);
- }
+ clone->m_tbl = st_init_numtable();
+ st_foreach(RCLASS(klass)->m_tbl, clone_method,
+ (st_data_t)clone->m_tbl);
rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone);
FL_SET(clone, FL_SINGLETON);
return (VALUE)clone;
diff --git a/configure.in b/configure.in
index ee0e81c257..fafd398eb7 100644
--- a/configure.in
+++ b/configure.in
@@ -377,7 +377,11 @@ human*) ac_cv_func_getpgrp_void=yes
ac_cv_func_setitimer=no
;;
beos*) ac_cv_func_link=no;;
-cygwin*) ;;
+cygwin*) rb_cv_have_daylight=no
+ ac_cv_var_tzname=no
+ ac_cv_func__setjmp=no
+ ac_cv_func_setitimer=no
+ ;;
mingw*) if test "$with_winsock2" = yes; then
LIBS="-lws2_32 $LIBS"
else
@@ -534,14 +538,13 @@ AC_REPLACE_FUNCS(dup2 memmove strcasecmp strncasecmp strerror strftime\
strchr strstr strtoul crypt flock vsnprintf\
isnan finite isinf hypot acosh erf)
AC_CHECK_FUNCS(fmod killpg wait4 waitpid syscall chroot fsync getcwd eaccess\
- truncate ftruncate chsize times utimes fcntl lockf lstat symlink link\
+ truncate chsize times utimes fcntl lockf lstat symlink link\
readlink setitimer setruid seteuid setreuid setresuid\
setproctitle setrgid setegid setregid setresgid issetugid pause\
lchown lchmod getpgrp setpgrp getpgid setpgid initgroups\
getgroups setgroups getpriority getrlimit setrlimit sysconf\
group_member dlopen sigprocmask\
- sigaction _setjmp setsid telldir seekdir fchmod\
- mktime timegm gettimeofday\
+ sigaction _setjmp setsid telldir seekdir fchmod mktime timegm\
cosh sinh tanh round setuid setgid setenv unsetenv)
AC_ARG_ENABLE(setreuid,
[ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
@@ -568,42 +571,6 @@ AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight,
if test "$rb_cv_have_daylight" = yes; then
AC_DEFINE(HAVE_DAYLIGHT)
fi
-AC_DEFUN([RUBY_CHECK_VARTYPE], [dnl
-AC_CACHE_CHECK([for external $1], rb_cv_var_$1,
- [rb_cv_var_$1=no
- AC_TRY_COMPILE([#define _XOPEN_SOURCE 1
- $2
- const volatile void *volatile t;],
- [t = &(&$1)[0];],
- [for t in $3; do
- AC_TRY_COMPILE([#define _XOPEN_SOURCE 1
- $2
- extern $t $1;
- const volatile void *volatile t;],
- [t = &(&$1)[0];],
- [rb_cv_var_$1=$t; break])
- done])])
-if test "[$rb_cv_var_]$1" != no; then
- AC_DEFINE([HAVE_VAR_]m4_toupper($1))
- AC_DEFINE_UNQUOTED([TYPEOF_VAR_]m4_toupper($1), $rb_cv_var_$1)
-fi])
-RUBY_CHECK_VARTYPE(timezone, [#include <time.h>], [long int])
-RUBY_CHECK_VARTYPE(altzone, [#include <time.h>], [long int])
-if test "$rb_cv_var_timezone" = no; then
- AC_CHECK_FUNCS(timezone)
- if test "$ ac_cv_func_timezone" = yes; then
- AC_CACHE_CHECK([whether timezone requires zero arguments], rb_cv_func_timezone_void,
- [AC_TRY_COMPILE([#include <time.h>],
- [(void)timezone(0, 0);],
- [rb_cv_func_timezone_void=no],
- [rb_cv_func_timezone_void=yes])]
- )
- if test $rb_cv_func_timezone_void = yes; then
- AC_DEFINE(TIMEZONE_VOID)
- fi
- fi
-fi
-
AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t,
[AC_TRY_RUN([
#include <time.h>
@@ -645,7 +612,6 @@ fi
if test "$ac_cv_func_sigprocmask" = yes && test "$ac_cv_func_sigaction" = yes; then
AC_DEFINE(POSIX_SIGNAL)
else
- AC_CHECK_FUNCS(sigsetmask)
AC_CACHE_CHECK(for BSD signal semantics, rb_cv_bsd_signal,
[AC_TRY_RUN([
#include <stdio.h>
@@ -668,7 +634,7 @@ main()
],
rb_cv_bsd_signal=yes,
rb_cv_bsd_signal=no,
- rb_cv_bsd_signal=$ac_cv_func_sigsetmask)])
+ rb_cv_bsd_signal=no)])
if test "$rb_cv_bsd_signal" = yes; then
AC_DEFINE(BSD_SIGNAL)
fi
@@ -1004,7 +970,7 @@ AC_SUBST(DLEXT2)dnl
AC_SUBST(LIBEXT)dnl
STATIC=
-: ${LIBPATHFLAG=' -L%s'}
+: ${LIBPATHFLAG=' -L"%s"'}
: ${PATHFLAG=''}
if test "$with_dln_a_out" != yes; then
@@ -1068,7 +1034,7 @@ if test "$with_dln_a_out" != yes; then
rb_cv_dlopen=yes ;;
interix*) : ${LDSHARED="$CC -shared"}
XLDFLAGS="$XLDFLAGS -Wl,-E"
- LIBPATHFLAG=" -L%1\$-s"
+ LIBPATHFLAG=" -L'%1\$-s'"
rb_cv_dlopen=yes ;;
freebsd*|dragonfly*) : ${LDSHARED="$CC -shared"}
if test "$rb_cv_binary_elf" = yes; then
@@ -1148,8 +1114,8 @@ if test "$with_dln_a_out" != yes; then
[ --disable-rpath embed run path into extension libraries.],
[enable_rpath=$enableval], [enable_rpath="$rb_cv_binary_elf"])
if test "$enable_rpath" = yes; then
- LIBPATHFLAG=" -L%1\$-s"
- RPATHFLAG=" ${linker_flag}-R%1\$-s"
+ LIBPATHFLAG=" -L'%1\$-s'"
+ RPATHFLAG=" ${linker_flag}-R'%1\$-s'"
fi
fi
AC_SUBST(LINK_SO)
@@ -1237,7 +1203,7 @@ case "$target_os" in
human*)
AC_CHECK_LIB(signal, _harderr)
AC_CHECK_LIB(hmem, hmemset)
- AC_CHECK_FUNCS(select)
+ AC_CHECK_FUNCS(select gettimeofday)
AC_CACHE_CHECK(whether PD libc _dtos18 fail to convert big number,
rb_cv_missing__dtos18,
[AC_TRY_RUN(
@@ -1501,6 +1467,7 @@ case "$target_os" in
LIBRUBY_SO='cyg$(RUBY_SO_NAME)'${MAJOR}${MINOR}.dll
LIBRUBY='lib$(RUBY_SO_NAME).dll.a'
fi
+ AC_LIBOBJ([strftime])
;;
mingw*)
RUBY_SO_NAME=${rb_cv_msvcrt}-'$(RUBY_INSTALL_NAME)'${MAJOR}${MINOR}
diff --git a/defines.h b/defines.h
index 7b62c5cd02..6b1fd68740 100644
--- a/defines.h
+++ b/defines.h
@@ -251,14 +251,6 @@ void rb_ia64_flushrs(void);
#define ENV_IGNORECASE
#endif
-#ifndef CASEFOLD_FILESYSTEM
-# if defined DOSISH || defined __VMS
-# define CASEFOLD_FILESYSTEM 1
-# else
-# define CASEFOLD_FILESYSTEM 0
-# endif
-#endif
-
#ifndef DLEXT_MAXLEN
#define DLEXT_MAXLEN 4
#endif
diff --git a/dln.c b/dln.c
index ae12758d19..9fd605e32e 100644
--- a/dln.c
+++ b/dln.c
@@ -1772,9 +1772,26 @@ dln_find_1(fname, path, exe_flag)
}
memcpy(bp, fname, i + 1);
+#ifndef __MACOS__
+ if (stat(fbuf, &st) == 0) {
+ if (exe_flag == 0) return fbuf;
+ /* looking for executable */
+ if (!S_ISDIR(st.st_mode) && eaccess(fbuf, X_OK) == 0)
+ return fbuf;
+ }
+#else
+ if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name(fbuf)) {
+ if (exe_flag == 0) return mac_fullpath;
+ /* looking for executable */
+ if (stat(mac_fullpath, &st) == 0) {
+ if (!S_ISDIR(st.st_mode) && eaccess(mac_fullpath, X_OK) == 0)
+ return mac_fullpath;
+ }
+ }
+#endif
#if defined(DOSISH)
if (exe_flag) {
- static const char extension[][5] = {
+ static const char *extension[] = {
#if defined(MSDOS)
".com", ".exe", ".bat",
#if defined(DJGPP)
@@ -1787,10 +1804,11 @@ dln_find_1(fname, path, exe_flag)
".r", ".R", ".x", ".X", ".bat", ".BAT",
/* __human68k__ */
#endif
+ (char *) NULL
};
int j;
- for (j = 0; j < sizeof(extension) / sizeof(extension[0]); j++) {
+ for (j = 0; extension[j]; j++) {
if (fspace < strlen(extension[j])) {
fprintf(stderr, "openpath: pathname too long (ignored)\n");
fprintf(stderr, "\tDirectory \"%.*s\"\n", (int) (bp - fbuf), fbuf);
@@ -1807,28 +1825,9 @@ dln_find_1(fname, path, exe_flag)
#endif
}
- goto next;
}
#endif /* MSDOS or _WIN32 or __human68k__ or __EMX__ */
-#ifndef __MACOS__
- if (stat(fbuf, &st) == 0) {
- if (exe_flag == 0) return fbuf;
- /* looking for executable */
- if (!S_ISDIR(st.st_mode) && eaccess(fbuf, X_OK) == 0)
- return fbuf;
- }
-#else
- if (mac_fullpath = _macruby_exist_file_in_libdir_as_posix_name(fbuf)) {
- if (exe_flag == 0) return mac_fullpath;
- /* looking for executable */
- if (stat(mac_fullpath, &st) == 0) {
- if (!S_ISDIR(st.st_mode) && eaccess(mac_fullpath, X_OK) == 0)
- return mac_fullpath;
- }
- }
-#endif
-
next:
/* if not, and no other alternatives, life is bleak */
if (*ep == '\0') {
diff --git a/eval.c b/eval.c
index 951676c875..505665d513 100644
--- a/eval.c
+++ b/eval.c
@@ -453,8 +453,7 @@ rb_define_alloc_func(klass, func)
VALUE (*func) _((VALUE));
{
Check_Type(klass, T_CLASS);
- rb_add_method(rb_singleton_class(klass), ID_ALLOCATOR, NEW_CFUNC(func, 0),
- NOEX_PRIVATE);
+ rb_add_method(CLASS_OF(klass), ID_ALLOCATOR, NEW_CFUNC(func, 0), NOEX_PRIVATE);
}
void
@@ -462,7 +461,7 @@ rb_undef_alloc_func(klass)
VALUE klass;
{
Check_Type(klass, T_CLASS);
- rb_add_method(rb_singleton_class(klass), ID_ALLOCATOR, 0, NOEX_UNDEF);
+ rb_add_method(CLASS_OF(klass), ID_ALLOCATOR, 0, NOEX_UNDEF);
}
static NODE*
@@ -1299,9 +1298,8 @@ error_print()
warn_print2(RSTRING(epath)->ptr, RSTRING(epath)->len);
warn_print(")\n");
}
- if (tail && elen>len+1) {
+ if (tail) {
warn_print2(tail, elen-len-1);
- if (einfo[elen-1] != '\n') warn_print2("\n", 1);
}
}
}
@@ -2441,8 +2439,6 @@ is_defined(self, node, buf)
case NODE_ATTRSET:
case NODE_OP_ASGN1:
case NODE_OP_ASGN2:
- case NODE_OP_ASGN_OR:
- case NODE_OP_ASGN_AND:
case NODE_MASGN:
case NODE_LASGN:
case NODE_DASGN:
@@ -5502,7 +5498,7 @@ rb_ensure(b_proc, data1, e_proc, data2)
POP_TAG();
retval = prot_tag ? prot_tag->retval : Qnil; /* save retval */
if (!thread_no_ensure()) {
- (*e_proc)(data2);
+ (*e_proc)(data2);
}
if (prot_tag) return_value(retval);
if (state) JUMP_TAG(state);
@@ -6536,17 +6532,16 @@ eval(self, src, scope, file, line)
if (state) {
if (state == TAG_RAISE) {
if (strcmp(file, "(eval)") == 0) {
- VALUE mesg, errat, bt2;
+ VALUE mesg, errat;
errat = get_backtrace(ruby_errinfo);
- mesg = rb_attr_get(ruby_errinfo, rb_intern("mesg"));
- if (!NIL_P(errat) && TYPE(errat) == T_ARRAY &&
- (bt2 = backtrace(-2), RARRAY(bt2)->len > 0)) {
+ mesg = rb_attr_get(ruby_errinfo, rb_intern("mesg"));
+ if (!NIL_P(errat) && TYPE(errat) == T_ARRAY) {
if (!NIL_P(mesg) && TYPE(mesg) == T_STRING) {
rb_str_update(mesg, 0, 0, rb_str_new2(": "));
rb_str_update(mesg, 0, 0, RARRAY(errat)->ptr[0]);
}
- RARRAY(errat)->ptr[0] = RARRAY(bt2)->ptr[0];
+ RARRAY(errat)->ptr[0] = RARRAY(backtrace(-2))->ptr[0];
}
}
rb_exc_raise(ruby_errinfo);
@@ -8345,25 +8340,16 @@ proc_clone(self)
* MISSING: documentation
*/
-#define PROC_TSHIFT (FL_USHIFT+1)
-#define PROC_TMASK (FL_USER1|FL_USER2|FL_USER3)
-#define PROC_TMAX (PROC_TMASK >> PROC_TSHIFT)
-
-static int proc_get_safe_level(VALUE);
-
static VALUE
proc_dup(self)
VALUE self;
{
struct BLOCK *orig, *data;
VALUE bind;
- int safe = proc_get_safe_level(self);
Data_Get_Struct(self, struct BLOCK, orig);
bind = Data_Make_Struct(rb_obj_class(self),struct BLOCK,blk_mark,blk_free,data);
blk_dup(data, orig);
- if (safe > PROC_TMAX) safe = PROC_TMAX;
- FL_SET(bind, (safe << PROC_TSHIFT) & PROC_TMASK);
return bind;
}
@@ -8425,6 +8411,10 @@ rb_f_binding(self)
return bind;
}
+#define PROC_TSHIFT (FL_USHIFT+1)
+#define PROC_TMASK (FL_USER1|FL_USER2|FL_USER3)
+#define PROC_TMAX (PROC_TMASK >> PROC_TSHIFT)
+
#define SAFE_LEVEL_MAX PROC_TMASK
static void
diff --git a/ext/Win32API/lib/win32/registry.rb b/ext/Win32API/lib/win32/registry.rb
index 9a2f3827b7..2671551a33 100644
--- a/ext/Win32API/lib/win32/registry.rb
+++ b/ext/Win32API/lib/win32/registry.rb
@@ -493,7 +493,7 @@ module Win32
# utility functions
#
def self.expand_environ(str)
- str.gsub(/%([^%]+)%/) { ENV[$1] || ENV[$1.upcase] || $& }
+ str.gsub(/%([^%]+)%/) { ENV[$1] || $& }
end
@@type2name = { }
diff --git a/ext/Win32API/lib/win32/resolv.rb b/ext/Win32API/lib/win32/resolv.rb
index 92336fac28..6534d20760 100644
--- a/ext/Win32API/lib/win32/resolv.rb
+++ b/ext/Win32API/lib/win32/resolv.rb
@@ -11,7 +11,7 @@ module Win32
def self.get_hosts_path
path = get_hosts_dir
- path = File.expand_path('hosts', path)
+ path = File.join(path.gsub(/\\/, File::SEPARATOR), 'hosts')
File.exist?(path) ? path : nil
end
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 636c0907d6..a4b769e8cf 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -586,22 +586,19 @@ BigDecimal_to_f(VALUE self)
{
ENTER(1);
Real *p;
- double d;
+ double d, d2;
S_LONG e;
- char *buf;
GUARD_OBJ(p,GetVpValue(self,1));
if(VpVtoD(&d, &e, p)!=1) return rb_float_new(d);
- buf = ALLOCA_N(char,(unsigned int)VpNumOfChars(p,"E"));
- VpToString(p, buf, 0, 0);
errno = 0;
- d = strtod(buf, 0);
- if(errno == ERANGE) {
+ d2 = pow(10.0,(double)e);
+ if((errno == ERANGE && e>0) || (d2>1.0 && (fabs(d) > (DBL_MAX / d2)))) {
VpException(VP_EXCEPTION_OVERFLOW,"BigDecimal to Float conversion",0);
if(d>0.0) return rb_float_new(DBL_MAX);
else return rb_float_new(-DBL_MAX);
}
- return rb_float_new(d);
+ return rb_float_new(d*d2);
}
/* The coerce method provides support for Ruby type coercion. It is not
@@ -1054,7 +1051,7 @@ static VALUE
BigDecimal_remainder(VALUE self, VALUE r) /* remainder */
{
VALUE f;
- Real *d,*rv=0;
+ Real *d,*rv;
f = BigDecimal_divremain(self,r,&d,&rv);
if(f!=(VALUE)0) return f;
return ToValue(rv);
@@ -1508,7 +1505,7 @@ BigDecimal_to_s(int argc, VALUE *argv, VALUE self)
} else if(*psz=='+') {
fPlus = 2; psz++;
}
- while((ch=*psz++)!=0) {
+ while(ch=*psz++) {
if(ISSPACE(ch)) continue;
if(!ISDIGIT(ch)) {
if(ch=='F' || ch=='f') fmt = 1; /* F format */
@@ -1965,27 +1962,17 @@ static int gfCheckVal = 1; /* Value checking flag in VpNmlz() */
static U_LONG gnPrecLimit = 0; /* Global upper limit of the precision newly allocated */
static U_LONG gfRoundMode = VP_ROUND_HALF_UP; /* Mode for general rounding operation */
-#ifndef BASE_FIG
static U_LONG BASE_FIG = 4; /* =log10(BASE) */
static U_LONG BASE = 10000L; /* Base value(value must be 10**BASE_FIG) */
/* The value of BASE**2 + BASE must be represented */
/* within one U_LONG. */
static U_LONG HALF_BASE = 5000L;/* =BASE/2 */
+static S_LONG DBLE_FIG = 8; /* figure of double */
static U_LONG BASE1 = 1000L; /* =BASE/10 */
-#else
-#ifndef BASE
-#error BASE_FIG is defined but BASE is not
-#endif
-#define HALF_BASE (BASE/2)
-#define BASE1 (BASE/10)
-#endif
-#ifndef DBLE_FIG
-#define DBLE_FIG (DBL_DIG+1) /* figure of double */
-#endif
static Real *VpConstOne; /* constant 1.0 */
static Real *VpPt5; /* constant 0.5 */
-#define maxnr 100UL /* Maximum iterations for calcurating sqrt. */
+static U_LONG maxnr = 100; /* Maximum iterations for calcurating sqrt. */
/* used in VpSqrt() */
/* ETC */
@@ -2102,8 +2089,8 @@ VpSetRoundMode(unsigned long n)
* (to let the compiler know they may be changed in outside
* (... but not actually..)).
*/
-volatile const double gZero_ABCED9B1_CE73__00400511F31D = 0.0;
-volatile const double gOne_ABCED9B4_CE73__00400511F31D = 1.0;
+volatile double gZero_ABCED9B1_CE73__00400511F31D = 0.0;
+volatile double gOne_ABCED9B4_CE73__00400511F31D = 1.0;
static double
Zero(void)
{
@@ -2375,15 +2362,16 @@ VpNumOfChars(Real *vp,const char *pszFmt)
VP_EXPORT U_LONG
VpInit(U_LONG BaseVal)
{
+ U_LONG w;
+ double v;
+
/* Setup +/- Inf NaN -0 */
VpGetDoubleNaN();
VpGetDoublePosInf();
VpGetDoubleNegInf();
VpGetDoubleNegZero();
-#ifndef BASE_FIG
if(BaseVal <= 0) {
- U_LONG w;
/* Base <= 0, then determine Base by calcuration. */
BASE = 1;
while(
@@ -2400,8 +2388,6 @@ VpInit(U_LONG BaseVal)
BASE1 = BASE / 10;
BASE_FIG = 0;
while(BaseVal /= 10) ++BASE_FIG;
-#endif
-
/* Allocates Vp constants. */
VpConstOne = VpAlloc((U_LONG)1, "1");
VpPt5 = VpAlloc((U_LONG)1, ".5");
@@ -2410,6 +2396,15 @@ VpInit(U_LONG BaseVal)
gnAlloc = 0;
#endif /* _DEBUG */
+ /* Determine # of digits available in one 'double'. */
+
+ v = 1.0;
+ DBLE_FIG = 0;
+ while(v + 1.0 > 1.0) {
+ ++DBLE_FIG;
+ v /= 10;
+ }
+
#ifdef _DEBUG
if(gfDebug) {
printf("VpInit: BaseVal = %lu\n", BaseVal);
@@ -2512,7 +2507,7 @@ VpAlloc(U_LONG mx, const char *szVal)
psz = ALLOCA_N(char,strlen(szVal)+1);
i = 0;
ipn = 0;
- while((psz[i]=szVal[ipn])!=0) {
+ while(psz[i]=szVal[ipn]) {
if(ISDIGIT(psz[i])) ++ni;
if(psz[i]=='_') {
if(ni>0) {ipn++;continue;}
@@ -2555,7 +2550,7 @@ VpAlloc(U_LONG mx, const char *szVal)
else if(szVal[i] == '+') ++i;
/* Skip digits */
ni = 0; /* digits in mantissa */
- while((v = szVal[i]) != 0) {
+ while(v = szVal[i]) {
if(!ISDIGIT(v)) break;
++i;
++ni;
@@ -2569,7 +2564,7 @@ VpAlloc(U_LONG mx, const char *szVal)
if(szVal[i] == '.') { /* xxx. */
++i;
ipf = i;
- while((v = szVal[i]) != 0) { /* get fraction part. */
+ while(v = szVal[i]) { /* get fraction part. */
if(!ISDIGIT(v)) break;
++i;
++nf;
@@ -2587,7 +2582,7 @@ VpAlloc(U_LONG mx, const char *szVal)
ipe = i;
v = szVal[i];
if((v == '-') ||(v == '+')) ++i;
- while((v=szVal[i])!=0) {
+ while(v=szVal[i]) {
if(!ISDIGIT(v)) break;
++i;
++ne;
@@ -4439,7 +4434,7 @@ VpLeftRound(Real *y, int f, int nf)
if(!VpHasVal(y)) return 0; /* Unable to round */
v = y->frac[0];
nf -= VpExponent(y)*BASE_FIG;
- while((v /= 10) != 0) nf--;
+ while(v=v/10) nf--;
nf += (BASE_FIG-1);
return VpMidRound(y,f,nf);
}
diff --git a/ext/bigdecimal/extconf.rb b/ext/bigdecimal/extconf.rb
index 864aaad862..a68a656044 100644
--- a/ext/bigdecimal/extconf.rb
+++ b/ext/bigdecimal/extconf.rb
@@ -1,12 +1,2 @@
require 'mkmf'
-
-base_fig = 0
-src = ("(BASE > 0) && "
- "(BASE * (BASE+1)) > BASE && "
- "(BASE * (BASE+1)) / BASE == (BASE+1)")
-while try_static_assert(src, nil, "-DBASE=10#{'0'*base_fig}UL")
- base_fig += 1
-end
-$defs << "-DBASE=1#{'0'*base_fig}UL" << "-DBASE_FIG=#{base_fig}"
-
create_makefile('bigdecimal')
diff --git a/ext/dl/ptr.c b/ext/dl/ptr.c
index 7e3d3549d3..5112151733 100644
--- a/ext/dl/ptr.c
+++ b/ext/dl/ptr.c
@@ -4,22 +4,30 @@
#include <ruby.h>
#include <ctype.h>
-#include "st.h"
+#include <version.h> /* for ruby version code */
#include "dl.h"
VALUE rb_cDLPtrData;
VALUE rb_mDLMemorySpace;
-static st_table* st_memory_table;
+static VALUE DLMemoryTable;
#ifndef T_SYMBOL
# define T_SYMBOL T_FIXNUM
#endif
+#if RUBY_VERSION_CODE < 171
+static VALUE
+rb_hash_delete(VALUE hash, VALUE key)
+{
+ return rb_funcall(hash, rb_intern("delete"), 1, key);
+}
+#endif
+
static void
rb_dlmem_delete(void *ptr)
{
rb_secure(4);
- st_delete(st_memory_table, (st_data_t*)&ptr, NULL);
+ rb_hash_delete(DLMemoryTable, DLLONG2NUM(ptr));
}
static void
@@ -29,7 +37,7 @@ rb_dlmem_aset(void *ptr, VALUE obj)
rb_dlmem_delete(ptr);
}
else{
- st_insert(st_memory_table, (st_data_t)ptr, (st_data_t)obj);
+ rb_hash_aset(DLMemoryTable, DLLONG2NUM(ptr), DLLONG2NUM(obj));
}
}
@@ -38,8 +46,8 @@ rb_dlmem_aref(void *ptr)
{
VALUE val;
- if(!st_lookup(st_memory_table, (st_data_t)ptr, &val)) return Qnil;
- return val == Qundef ? Qnil : val;
+ val = rb_hash_aref(DLMemoryTable, DLLONG2NUM(ptr));
+ return val == Qnil ? Qnil : (VALUE)DLNUM2LONG(val);
}
void
@@ -1002,18 +1010,20 @@ rb_dlptr_size(int argc, VALUE argv[], VALUE self)
}
}
-static int
-dlmem_each_i(void* key, VALUE value, void* arg)
+static VALUE
+dlmem_each_i(VALUE assoc, void *data)
{
- VALUE vkey = DLLONG2NUM(key);
- rb_yield(rb_assoc_new(vkey, value));
+ VALUE key, val;
+ key = rb_ary_entry(assoc, 0);
+ val = rb_ary_entry(assoc, 1);
+ rb_yield(rb_assoc_new(key,(VALUE)DLNUM2LONG(val)));
return Qnil;
}
VALUE
rb_dlmem_each(VALUE self)
{
- st_foreach(st_memory_table, dlmem_each_i, 0);
+ rb_iterate(rb_each, DLMemoryTable, dlmem_each_i, 0);
return Qnil;
}
@@ -1052,7 +1062,7 @@ Init_dlptr()
rb_define_method(rb_cDLPtrData, "size=", rb_dlptr_size, -1);
rb_mDLMemorySpace = rb_define_module_under(rb_mDL, "MemorySpace");
- st_memory_table = st_init_numtable();
- rb_define_const(rb_mDLMemorySpace, "MemoryTable", Qnil); /* historical */
+ DLMemoryTable = rb_hash_new();
+ rb_define_const(rb_mDLMemorySpace, "MemoryTable", DLMemoryTable);
rb_define_module_function(rb_mDLMemorySpace, "each", rb_dlmem_each, 0);
}
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 4736cb1008..65fed33bd2 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -101,7 +101,7 @@ static void iconv_dfree _((void *cd));
static VALUE iconv_free _((VALUE cd));
static VALUE iconv_try _((iconv_t cd, const char **inptr, size_t *inlen, char **outptr, size_t *outlen));
static VALUE rb_str_derive _((VALUE str, const char* ptr, int len));
-static VALUE iconv_convert _((iconv_t cd, VALUE str, long start, long length, struct iconv_env_t* env));
+static VALUE iconv_convert _((iconv_t cd, VALUE str, int start, int length, struct iconv_env_t* env));
static VALUE iconv_s_allocate _((VALUE klass));
static VALUE iconv_initialize _((VALUE self, VALUE to, VALUE from));
static VALUE iconv_s_open _((VALUE self, VALUE to, VALUE from));
@@ -170,7 +170,7 @@ iconv_create
}
if (cd == (iconv_t)-1) {
int inval = errno == EINVAL;
- const char *s = inval ? "invalid encoding " : "iconv";
+ char *s = inval ? "invalid encoding " : "iconv";
volatile VALUE msg = rb_str_new(0, strlen(s) + RSTRING(to)->len +
RSTRING(from)->len + 8);
@@ -362,13 +362,13 @@ rb_str_derive
static VALUE
iconv_convert
#ifdef HAVE_PROTOTYPES
- (iconv_t cd, VALUE str, long start, long length, struct iconv_env_t* env)
+ (iconv_t cd, VALUE str, int start, int length, struct iconv_env_t* env)
#else /* HAVE_PROTOTYPES */
(cd, str, start, length, env)
iconv_t cd;
VALUE str;
- long start;
- long length;
+ int start;
+ int length;
struct iconv_env_t *env;
#endif /* HAVE_PROTOTYPES */
{
@@ -417,9 +417,14 @@ iconv_convert
slen = RSTRING(str)->len;
inptr = RSTRING(str)->ptr;
- inptr += start;
- if (length < 0 || length > start + slen)
- length = slen - start;
+ if (start < 0 ? (start += slen) < 0 : start >= slen)
+ length = 0;
+ else if (length < 0 && (length += slen + 1) < 0)
+ length = 0;
+ else if ((length -= start) < 0)
+ length = 0;
+ else
+ inptr += start;
}
instart = inptr;
inlen = length;
@@ -749,17 +754,14 @@ iconv_iconv
{
VALUE str, n1, n2;
VALUE cd = check_iconv(self);
- long start = 0, length = 0, slen = 0;
+ n1 = n2 = Qnil;
rb_scan_args(argc, argv, "12", &str, &n1, &n2);
- if (!NIL_P(str)) slen = RSTRING_LEN(StringValue(str));
- if (argc != 2 || !RTEST(rb_range_beg_len(n1, &start, &length, slen, 0))) {
- if (NIL_P(n1) || ((start = NUM2LONG(n1)) < 0 ? (start += slen) >= 0 : start < slen)) {
- if (!NIL_P(n2)) length = NUM2LONG(n2);
- }
- }
- return iconv_convert(VALUE2ICONV(cd), str, start, length, NULL);
+ return iconv_convert(VALUE2ICONV(cd), str,
+ NIL_P(n1) ? 0 : NUM2INT(n1),
+ NIL_P(n2) ? -1 : NUM2INT(n2),
+ NULL);
}
/*
@@ -823,7 +825,7 @@ iconv_failure_inspect
VALUE self;
#endif /* HAVE_PROTOTYPES */
{
- const char *cname = rb_class2name(CLASS_OF(self));
+ char *cname = rb_class2name(CLASS_OF(self));
VALUE success = rb_attr_get(self, rb_success);
VALUE failed = rb_attr_get(self, rb_failed);
VALUE str = rb_str_buf_cat2(rb_str_new2("#<"), cname);
diff --git a/ext/pty/lib/expect.rb b/ext/pty/lib/expect.rb
index 08191b05b9..aa9ab895d3 100644
--- a/ext/pty/lib/expect.rb
+++ b/ext/pty/lib/expect.rb
@@ -10,7 +10,7 @@ class IO
e_pat = pat
end
while true
- if !IO.select([self],nil,nil,timeout) or eof? then
+ if IO.select([self],nil,nil,timeout).nil? then
result = nil
break
end
diff --git a/ext/readline/extconf.rb b/ext/readline/extconf.rb
index b820c0b32f..b57a36f3a5 100644
--- a/ext/readline/extconf.rb
+++ b/ext/readline/extconf.rb
@@ -42,9 +42,9 @@ else
end
end
-have_func("rl_filename_completion_function")
-have_func("rl_username_completion_function")
-have_func("rl_completion_matches")
+have_readline_var("rl_filename_completion_function")
+have_readline_var("rl_username_completion_function")
+have_readline_var("rl_completion_matches")
have_readline_var("rl_deprep_term_function")
have_readline_var("rl_completion_append_character")
have_readline_var("rl_basic_word_break_characters")
@@ -59,6 +59,7 @@ have_func("rl_cleanup_after_signal")
have_func("rl_clear_signals")
have_func("rl_vi_editing_mode")
have_func("rl_emacs_editing_mode")
+have_func("rl_clear_signals")
have_func("replace_history_entry")
have_func("remove_history")
create_makefile("readline")
diff --git a/ext/readline/readline.c b/ext/readline/readline.c
index 82ddc8a3cb..559e1c677b 100644
--- a/ext/readline/readline.c
+++ b/ext/readline/readline.c
@@ -42,32 +42,17 @@ static ID completion_proc, completion_case_fold;
# define rl_completion_matches completion_matches
#endif
+static int readline_event(void);
static char **readline_attempted_completion_function(const char *text,
int start, int end);
-#ifdef HAVE_RL_EVENT_HOOK
-#ifdef DOSISH
-#define BUSY_WAIT 1
-#else
-#define BUSY_WAIT 0
-#endif
-
-static int readline_event(void);
static int
readline_event()
{
-#if BUSY_WAIT
+ CHECK_INTS;
rb_thread_schedule();
-#else
- fd_set rset;
-
- FD_ZERO(&rset);
- FD_SET(fileno(rl_instream), &rset);
- rb_thread_select(fileno(rl_instream) + 1, &rset, NULL, NULL, NULL);
return 0;
-#endif
}
-#endif
static VALUE
readline_readline(argc, argv, self)
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c
index 6de3546308..078de4f78d 100644
--- a/ext/syck/rubyext.c
+++ b/ext/syck/rubyext.c
@@ -2280,6 +2280,7 @@ Init_syck()
*/
cScalar = rb_define_class_under( rb_syck, "Scalar", cNode );
rb_define_alloc_func( cScalar, syck_scalar_alloc );
+ rb_define_attr( cNode, "value", 1, 0 );
rb_define_method( cScalar, "initialize", syck_scalar_initialize, 3 );
rb_define_method( cScalar, "value=", syck_scalar_value_set, 1 );
rb_define_method( cScalar, "style=", syck_scalar_style_set, 1 );
diff --git a/ext/zlib/extconf.rb b/ext/zlib/extconf.rb
index 53b971b189..b4e76af3c6 100644
--- a/ext/zlib/extconf.rb
+++ b/ext/zlib/extconf.rb
@@ -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 zlib zdll'.find {|z| have_library(z, 'deflateReset')} and
have_header('zlib.h') then
defines = []
@@ -22,7 +22,7 @@ if %w'z libz zlib1 zlib zdll'.find {|z| have_library(z, 'deflateReset')} and
os_code = 'AMIGA'
when /\Aos2[\-_]emx\z/ then
os_code = 'OS2'
- when /mswin|mingw|bccwin/ then
+ when 'mswin32', 'mingw32', 'bccwin32' then
# NOTE: cygwin should be regarded as Unix.
os_code = 'WIN32'
else
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index d4c5028920..8caadaeddc 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -1182,19 +1182,14 @@ static VALUE
rb_deflate_init_copy(self, orig)
VALUE self, orig;
{
- struct zstream *z1, *z2;
+ struct zstream *z1 = get_zstream(self);
+ struct zstream *z2 = get_zstream(orig);
int err;
- Data_Get_Struct(self, struct zstream, z1);
- z2 = get_zstream(orig);
-
err = deflateCopy(&z1->stream, &z2->stream);
if (err != Z_OK) {
raise_zlib_error(err, 0);
}
- z1->input = NIL_P(z2->input) ? Qnil : rb_str_dup(z2->input);
- z1->buf = NIL_P(z2->buf) ? Qnil : rb_str_dup(z2->buf);
- z1->buf_filled = z2->buf_filled;
z1->flags = z2->flags;
return self;
@@ -3116,8 +3111,6 @@ gzreader_gets(argc, argv, obj)
if (NIL_P(rs)) {
dst = gzfile_read_all(gz);
if (RSTRING(dst)->len != 0) gz->lineno++;
- else
- return Qnil;
return dst;
}
@@ -3376,7 +3369,7 @@ void Init_zlib()
rb_define_singleton_method(cDeflate, "deflate", rb_deflate_s_deflate, -1);
rb_define_alloc_func(cDeflate, rb_deflate_s_allocate);
rb_define_method(cDeflate, "initialize", rb_deflate_initialize, -1);
- rb_define_method(cDeflate, "initialize_copy", rb_deflate_init_copy, 1);
+ rb_define_method(cDeflate, "initialize_copy", rb_deflate_init_copy, 0);
rb_define_method(cDeflate, "deflate", rb_deflate_deflate, -1);
rb_define_method(cDeflate, "<<", rb_deflate_addstr, 1);
rb_define_method(cDeflate, "flush", rb_deflate_flush, -1);
diff --git a/file.c b/file.c
index 4279ed6040..cd87d8de7a 100644
--- a/file.c
+++ b/file.c
@@ -16,12 +16,11 @@
#include "missing/file.h"
#endif
#ifdef __CYGWIN__
-#define OpenFile WINAPI_OpenFile
#include <windows.h>
#include <sys/cygwin.h>
-#undef OpenFile
#endif
+#define OpenFile rb_io_t
#include "ruby.h"
#include "rubyio.h"
#include "rubysig.h"
@@ -2316,6 +2315,14 @@ rb_file_s_umask(argc, argv)
#define isdirsep(x) ((x) == '/')
#endif
+#ifndef CharNext /* defined as CharNext[AW] on Windows. */
+# if defined(DJGPP)
+# define CharNext(p) ((p) + mblen(p, MB_CUR_MAX))
+# else
+# define CharNext(p) ((p) + 1)
+# endif
+#endif
+
#if defined _WIN32 || defined __CYGWIN__
#define USE_NTFS 1
#else
@@ -2328,14 +2335,6 @@ rb_file_s_umask(argc, argv)
#define istrailinggabage(x) 0
#endif
-#ifndef CharNext /* defined as CharNext[AW] on Windows. */
-# if defined(DJGPP)
-# define CharNext(p) ((p) + mblen(p, MB_CUR_MAX))
-# else
-# define CharNext(p) ((p) + 1)
-# endif
-#endif
-
#ifdef DOSISH_DRIVE_LETTER
static inline int
has_drive_letter(buf)
@@ -2476,7 +2475,6 @@ rb_path_end(path)
static char *
ntfs_tail(const char *path)
{
- while (*path == '.') path++;
while (*path && *path != ':') {
if (istrailinggabage(*path)) {
const char *last = path++;
@@ -2499,13 +2497,13 @@ ntfs_tail(const char *path)
#define BUFCHECK(cond) do {\
long bdiff = p - buf;\
- if (cond) {\
- do {buflen *= 2;} while (cond);\
- rb_str_resize(result, buflen);\
- buf = RSTRING(result)->ptr;\
- p = buf + bdiff;\
- pend = buf + buflen;\
+ while (cond) {\
+ buflen *= 2;\
}\
+ rb_str_resize(result, buflen);\
+ buf = RSTRING(result)->ptr;\
+ p = buf + bdiff;\
+ pend = buf + buflen;\
} while (0)
#define BUFINIT() (\
@@ -2741,63 +2739,65 @@ file_expand_path(fname, dname, result)
p += s-b;
}
if (p == skiproot(buf) - 1) p++;
+ buflen = p - buf;
-#if USE_NTFS
+ RSTRING(result)->len = buflen;
*p = '\0';
- if ((s = strrdirsep(b = buf)) != 0 && !strpbrk(s, "*?")) {
+#if USE_NTFS
+ if (1 &&
+#ifdef __CYGWIN__
+ !(buf[0] == '/' && !buf[1]) &&
+#endif
+ !strpbrk(b = buf, "*?")) {
size_t len;
WIN32_FIND_DATA wfd;
#ifdef __CYGWIN__
int lnk_added = 0, is_symlink = 0;
struct stat st;
- char w32buf[MAXPATHLEN];
- p = (char *)s;
+ char w32buf[MAXPATHLEN], sep = 0;
+ p = 0;
if (lstat(buf, &st) == 0 && S_ISLNK(st.st_mode)) {
is_symlink = 1;
- *p = '\0';
+ p = strrdirsep(buf);
+ if (!p) p = skipprefix(buf);
+ if (p) {
+ sep = *p;
+ *p = '\0';
+ }
}
- if (cygwin_conv_to_win32_path((*buf ? buf : "/"), w32buf) == 0) {
+ if (cygwin_conv_to_win32_path(buf, w32buf) == 0) {
b = w32buf;
}
+ if (p) *p = sep;
+ else p = buf;
if (is_symlink && b == w32buf) {
- *p = '\\';
- strlcat(w32buf, p, sizeof(w32buf));
len = strlen(p);
if (len > 4 && strcasecmp(p + len - 4, ".lnk") != 0) {
lnk_added = 1;
strlcat(w32buf, ".lnk", sizeof(w32buf));
}
}
- *p = '/';
#endif
HANDLE h = FindFirstFile(b, &wfd);
if (h != INVALID_HANDLE_VALUE) {
FindClose(h);
+ p = strrdirsep(buf);
len = strlen(wfd.cFileName);
#ifdef __CYGWIN__
if (lnk_added && len > 4 &&
strcasecmp(wfd.cFileName + len - 4, ".lnk") == 0) {
- wfd.cFileName[len -= 4] = '\0';
+ len -= 4;
}
-#else
- p = (char *)s;
#endif
- ++p;
- BUFCHECK(bdiff + len >= buflen);
+ if (!p) p = buf;
+ buflen = ++p - buf + len;
+ rb_str_resize(result, buflen);
memcpy(p, wfd.cFileName, len + 1);
- p += len;
}
-#ifdef __CYGWIN__
- else {
- p += strlen(p);
- }
-#endif
}
#endif
if (tainted) OBJ_TAINT(result);
- RSTRING(result)->len = p - buf;
- RSTRING(result)->ptr[p - buf] = '\0';
return result;
}
@@ -2860,12 +2860,7 @@ rmext(p, l1, e)
}
if (l1 < l2) return l1;
-#if CASEFOLD_FILESYSTEM
-#define fncomp strncasecmp
-#else
-#define fncomp strncmp
-#endif
- if (fncomp(p+l1-l2, e, l2) == 0) {
+ if (strncmp(p+l1-l2, e, l2) == 0) {
return l1-l2;
}
return 0;
@@ -3264,7 +3259,7 @@ rb_file_truncate(obj, len)
f = GetWriteFile(fptr);
fflush(f);
fseeko(f, (off_t)0, SEEK_CUR);
-#ifdef HAVE_FTRUNCATE
+#ifdef HAVE_TRUNCATE
if (ftruncate(fileno(f), pos) < 0)
rb_sys_fail(fptr->path);
#else
diff --git a/gc.c b/gc.c
index f1f065bfcb..4298a8acf1 100644
--- a/gc.c
+++ b/gc.c
@@ -378,9 +378,6 @@ rb_newobj()
{
VALUE obj;
- if (during_gc)
- rb_bug("object allocation during garbage collection phase");
-
if (!freelist) garbage_collect();
obj = (VALUE)freelist;
@@ -441,19 +438,20 @@ static unsigned int STACK_LEVEL_MAX = 655300;
# if ( __GNUC__ == 3 && __GNUC_MINOR__ > 0 ) || __GNUC__ > 3
__attribute__ ((noinline))
# endif
-static void
-stack_end_address(VALUE **stack_end_p)
+static VALUE *
+stack_end_address(void)
{
- VALUE stack_end;
- *stack_end_p = &stack_end;
+ return (VALUE *)__builtin_frame_address(0);
}
-# define SET_STACK_END VALUE *stack_end; stack_end_address(&stack_end)
+# define SET_STACK_END VALUE *stack_end = stack_end_address()
# else
# define SET_STACK_END VALUE *stack_end = alloca(1)
# endif
# define STACK_END (stack_end)
#endif
-#if STACK_GROW_DIRECTION < 0
+#if defined(sparc) || defined(__sparc__)
+# define STACK_LENGTH (rb_gc_stack_start - STACK_END + 0x80)
+#elif STACK_GROW_DIRECTION < 0
# define STACK_LENGTH (rb_gc_stack_start - STACK_END)
#elif STACK_GROW_DIRECTION > 0
# define STACK_LENGTH (STACK_END - rb_gc_stack_start + 1)
diff --git a/intern.h b/intern.h
index b8af605292..47da14bb7a 100644
--- a/intern.h
+++ b/intern.h
@@ -400,7 +400,6 @@ const char *ruby_signal_name _((int));
void ruby_default_signal _((int));
/* sprintf.c */
VALUE rb_f_sprintf _((int, VALUE*));
-VALUE rb_str_format _((int, VALUE*, VALUE));
/* string.c */
VALUE rb_str_new _((const char*, long));
VALUE rb_str_new2 _((const char*));
diff --git a/io.c b/io.c
index a65a304384..088b678c51 100644
--- a/io.c
+++ b/io.c
@@ -2169,7 +2169,6 @@ fptr_finalize(fptr, noraise)
{
int n1 = 0, n2 = 0, f1, f2 = -1;
- errno = 0;
if (fptr->f2) {
f2 = fileno(fptr->f2);
while (n2 = 0, fflush(fptr->f2) < 0) {
@@ -3256,7 +3255,7 @@ rb_io_s_popen(argc, argv, klass)
mode = rb_io_modenum_mode(FIX2INT(pmode));
}
else {
- mode = rb_io_flags_mode(rb_io_mode_flags(StringValueCStr(pmode)));
+ mode = rb_io_flags_mode(rb_io_mode_flags(StringValuePtr(pmode)));
}
SafeStringValue(pname);
port = pipe_open(pname, 0, mode);
@@ -3284,14 +3283,12 @@ rb_open_file(argc, argv, io)
VALUE io;
{
VALUE fname, vmode, perm;
- char *path, *mode;
- int flags;
- unsigned int fmode;
+ char *mode;
+ int flags, fmode;
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
SafeStringValue(fname);
- path = StringValueCStr(fname);
if (FIXNUM_P(vmode) || !NIL_P(perm)) {
if (FIXNUM_P(vmode)) {
flags = FIX2INT(vmode);
@@ -3300,13 +3297,13 @@ rb_open_file(argc, argv, io)
SafeStringValue(vmode);
flags = rb_io_mode_modenum(RSTRING(vmode)->ptr);
}
- fmode = NIL_P(perm) ? 0666 : NUM2UINT(perm);
+ fmode = NIL_P(perm) ? 0666 : NUM2INT(perm);
- rb_file_sysopen_internal(io, path, flags, fmode);
+ rb_file_sysopen_internal(io, RSTRING(fname)->ptr, flags, fmode);
}
else {
- mode = NIL_P(vmode) ? "r" : StringValueCStr(vmode);
- rb_file_open_internal(io, path, mode);
+ mode = NIL_P(vmode) ? "r" : StringValuePtr(vmode);
+ rb_file_open_internal(io, RSTRING(fname)->ptr, mode);
}
return io;
}
@@ -3356,8 +3353,7 @@ rb_io_s_sysopen(argc, argv)
VALUE *argv;
{
VALUE fname, vmode, perm;
- int flags, fd;
- unsigned int fmode;
+ int flags, fmode, fd;
char *path;
rb_scan_args(argc, argv, "12", &fname, &vmode, &perm);
@@ -3370,7 +3366,7 @@ rb_io_s_sysopen(argc, argv)
flags = rb_io_mode_modenum(RSTRING(vmode)->ptr);
}
if (NIL_P(perm)) fmode = 0666;
- else fmode = NUM2UINT(perm);
+ else fmode = NUM2INT(perm);
path = ALLOCA_N(char, strlen(RSTRING(fname)->ptr)+1);
strcpy(path, RSTRING(fname)->ptr);
@@ -3660,7 +3656,7 @@ rb_io_reopen(argc, argv, file)
}
if (!NIL_P(nmode)) {
- fptr->mode = rb_io_mode_flags(StringValueCStr(nmode));
+ fptr->mode = rb_io_mode_flags(StringValuePtr(nmode));
}
if (fptr->path) {
@@ -3668,7 +3664,7 @@ rb_io_reopen(argc, argv, file)
fptr->path = 0;
}
- fptr->path = strdup(StringValueCStr(fname));
+ fptr->path = strdup(RSTRING(fname)->ptr);
mode = rb_io_flags_mode(fptr->mode);
if (!fptr->f) {
fptr->f = rb_fopen(fptr->path, mode);
@@ -3679,16 +3675,16 @@ rb_io_reopen(argc, argv, file)
return file;
}
- if (freopen(fptr->path, mode, fptr->f) == 0) {
+ if (freopen(RSTRING(fname)->ptr, mode, fptr->f) == 0) {
rb_sys_fail(fptr->path);
}
#ifdef USE_SETVBUF
if (setvbuf(fptr->f, NULL, _IOFBF, 0) != 0)
- rb_warn("setvbuf() can't be honoured for %s", fptr->path);
+ rb_warn("setvbuf() can't be honoured for %s", RSTRING(fname)->ptr);
#endif
if (fptr->f2) {
- if (freopen(fptr->path, "w", fptr->f2) == 0) {
+ if (freopen(RSTRING(fname)->ptr, "w", fptr->f2) == 0) {
rb_sys_fail(fptr->path);
}
}
@@ -4237,7 +4233,7 @@ rb_io_initialize(argc, argv, io)
}
else {
SafeStringValue(mode);
- flags = rb_io_mode_modenum(StringValueCStr(mode));
+ flags = rb_io_mode_modenum(RSTRING(mode)->ptr);
}
}
else {
@@ -4407,7 +4403,7 @@ next_argv()
retry:
if (RARRAY(rb_argv)->len > 0) {
filename = rb_ary_shift(rb_argv);
- fn = StringValueCStr(filename);
+ fn = StringValuePtr(filename);
if (strlen(fn) == 1 && fn[0] == '-') {
current_file = rb_stdin;
if (ruby_inplace_mode) {
@@ -5068,7 +5064,7 @@ rb_f_syscall(argc, argv)
if (!NIL_P(v)) {
StringValue(v);
rb_str_modify(v);
- arg[i] = (unsigned long)StringValueCStr(v);
+ arg[i] = (unsigned long)RSTRING(v)->ptr;
}
else {
arg[i] = (unsigned long)NUM2LONG(*argv);
@@ -5276,7 +5272,7 @@ rb_io_s_foreach(argc, argv)
else if (!NIL_P(arg.sep)) {
StringValue(arg.sep);
}
- arg.io = rb_io_open(StringValueCStr(fname), "r");
+ arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
if (NIL_P(arg.io)) return Qnil;
return rb_ensure(io_s_foreach, (VALUE)&arg, rb_io_close, arg.io);
@@ -5315,7 +5311,7 @@ rb_io_s_readlines(argc, argv, io)
SafeStringValue(fname);
arg.argc = argc - 1;
- arg.io = rb_io_open(StringValueCStr(fname), "r");
+ arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
if (NIL_P(arg.io)) return Qnil;
return rb_ensure(io_s_readlines, (VALUE)&arg, rb_io_close, arg.io);
}
@@ -5353,7 +5349,7 @@ rb_io_s_read(argc, argv, io)
SafeStringValue(fname);
arg.argc = argc ? 1 : 0;
- arg.io = rb_io_open(StringValueCStr(fname), "r");
+ arg.io = rb_io_open(RSTRING(fname)->ptr, "r");
if (NIL_P(arg.io)) return Qnil;
if (!NIL_P(offset)) {
rb_io_seek(arg.io, offset, SEEK_SET);
@@ -5629,7 +5625,7 @@ opt_i_set(val)
StringValue(val);
if (ruby_inplace_mode) free(ruby_inplace_mode);
ruby_inplace_mode = 0;
- ruby_inplace_mode = strdup(StringValueCStr(val));
+ ruby_inplace_mode = strdup(RSTRING(val)->ptr);
}
/*
diff --git a/lib/benchmark.rb b/lib/benchmark.rb
index 6ab0755613..36e593518f 100644
--- a/lib/benchmark.rb
+++ b/lib/benchmark.rb
@@ -304,10 +304,7 @@ module Benchmark
# Returns the elapsed real time used to execute the given block.
#
def realtime(&blk) # :yield:
- r0 = Time.now
- yield
- r1 = Time.now
- r1.to_f - r0.to_f
+ Benchmark::measure(&blk).real
end
@@ -333,7 +330,7 @@ module Benchmark
# Registers the given label and block pair in the job list.
#
def item(label = "", &blk) # :yield:
- raise ArgumentError, "no block" unless block_given?
+ raise ArgmentError, "no block" unless block_given?
label.concat ' '
w = label.length
@width = w if @width < w
diff --git a/lib/cgi.rb b/lib/cgi.rb
index ccc48d8836..a442d44930 100644
--- a/lib/cgi.rb
+++ b/lib/cgi.rb
@@ -1032,13 +1032,13 @@ class CGI
if "--" == $2
content_length = -1
end
- boundary_end = $2.dup
+ boundary_end = $2.dup
""
end
body.rewind
- /Content-Disposition:.* filename=(?:"((?:\\.|[^\"\s])*)"|([^;\s]*))/ni.match(head)
+ /Content-Disposition:.* filename=(?:"((?:\\.|[^\"])*)"|([^;]*))/ni.match(head)
filename = ($1 or $2 or "")
if /Mac/ni.match(env_table['HTTP_USER_AGENT']) and
/Mozilla/ni.match(env_table['HTTP_USER_AGENT']) and
@@ -1046,7 +1046,7 @@ class CGI
filename = CGI::unescape(filename)
end
- /Content-Type: ([^\s]*)/ni.match(head)
+ /Content-Type: (.*)/ni.match(head)
content_type = ($1 or "")
(class << body; self; end).class_eval do
@@ -1055,7 +1055,7 @@ class CGI
define_method(:content_type) {content_type.dup.taint}
end
- /Content-Disposition:.* name="?([^\";\s]*)"?/ni.match(head)
+ /Content-Disposition:.* name="?([^\";]*)"?/ni.match(head)
name = $1.dup
if params.has_key?(name)
diff --git a/lib/date.rb b/lib/date.rb
index 10d8c94ae3..6da4d6aa8e 100644
--- a/lib/date.rb
+++ b/lib/date.rb
@@ -6,7 +6,7 @@
# Documentation: William Webber <william@williamwebber.com>
#
#--
-# $Id: date.rb,v 2.33 2007-12-22 14:41:34+09 tadf Exp $
+# $Id: date.rb,v 2.30 2006-12-30 21:43:41+09 tadf Exp $
#++
#
# == Overview
@@ -250,7 +250,7 @@ class Date
ABBR_DAYNAMES = %w(Sun Mon Tue Wed Thu Fri Sat)
[MONTHNAMES, DAYNAMES, ABBR_MONTHNAMES, ABBR_DAYNAMES].each do |xs|
- xs.each{|x| x.freeze unless x.nil?}.freeze
+ xs.each{|x| x.freeze}.freeze
end
class Infinity < Numeric # :nodoc:
diff --git a/lib/delegate.rb b/lib/delegate.rb
index ee5fe8d7fe..d810ccad42 100644
--- a/lib/delegate.rb
+++ b/lib/delegate.rb
@@ -164,9 +164,9 @@ class Delegator
# Checks for a method provided by this the delegate object by fowarding the
# call through \_\_getobj\_\_.
#
- def respond_to?(m, include_private = false)
+ def respond_to?(m)
return true if super
- return self.__getobj__.respond_to?(m, include_private)
+ return self.__getobj__.respond_to?(m)
end
#
@@ -228,15 +228,13 @@ class SimpleDelegator<Delegator
# Clone support for the object returned by \_\_getobj\_\_.
def clone
- new = super
- new.__setobj__(__getobj__.clone)
- new
+ super
+ __setobj__(__getobj__.clone)
end
# Duplication support for the object returned by \_\_getobj\_\_.
- def dup
- new = super
- new.__setobj__(__getobj__.clone)
- new
+ def dup(obj)
+ super
+ __setobj__(__getobj__.dup)
end
end
@@ -271,9 +269,9 @@ def DelegateClass(superclass)
end
@_dc_obj.__send__(m, *args)
end
- def respond_to?(m, include_private = false) # :nodoc:
+ def respond_to?(m) # :nodoc:
return true if super
- return @_dc_obj.respond_to?(m, include_private)
+ return @_dc_obj.respond_to?(m)
end
def __getobj__ # :nodoc:
@_dc_obj
@@ -283,14 +281,12 @@ def DelegateClass(superclass)
@_dc_obj = obj
end
def clone # :nodoc:
- new = super
- new.__setobj__(__getobj__.clone)
- new
+ super
+ __setobj__(__getobj__.clone)
end
def dup # :nodoc:
- new = super
- new.__setobj__(__getobj__.clone)
- new
+ super
+ __setobj__(__getobj__.dup)
end
}
for method in methods
diff --git a/lib/erb.rb b/lib/erb.rb
index d7c72b4988..b714aa1ea6 100644
--- a/lib/erb.rb
+++ b/lib/erb.rb
@@ -365,22 +365,21 @@ class ERB
end
end
+ ExplicitTrimRegexp = /(^[ \t]*<%-)|(-%>\n?\z)|(<%-)|(-%>)|(<%%)|(%%>)|(<%=)|(<%#)|(<%)|(%>)|(\n)/
def explicit_trim_line(line)
- line.scan(/(.*?)(^[ \t]*<%\-|<%\-|<%%|%%>|<%=|<%#|<%|-%>\n|-%>|%>|\z)/m) do |tokens|
- tokens.each do |token|
- next if token.empty?
- if @stag.nil? && /[ \t]*<%-/ =~ token
- yield('<%')
- elsif @stag && token == "-%>\n"
- yield('%>')
- yield(:cr)
- elsif @stag && token == '-%>'
- yield('%>')
- else
- yield(token)
- end
- end
- end
+ line.split(ExplicitTrimRegexp).each do |token|
+ next if token.empty?
+ if @stag.nil? && /[ \t]*<%-/ =~ token
+ yield('<%')
+ elsif @stag && /-%>\n/ =~ token
+ yield('%>')
+ yield(:cr)
+ elsif @stag && token == '-%>'
+ yield('%>')
+ else
+ yield(token)
+ end
+ end
end
ERB_STAG = %w(<%= <%# <%)
diff --git a/lib/irb.rb b/lib/irb.rb
index 7580e39d43..1fb4397e68 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -149,15 +149,10 @@ module IRB
line.untaint
@context.evaluate(line, line_no)
output_value if @context.echo?
- exc = nil
- rescue Interrupt => exc
- rescue SystemExit, SignalException
- raise
- rescue Exception => exc
- end
- if exc
- print exc.class, ": ", exc, "\n"
- if exc.backtrace[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/
+ rescue StandardError, ScriptError, Abort
+ $! = RuntimeError.new("unknown exception raised") unless $!
+ print $!.class, ": ", $!, "\n"
+ if $@[0] =~ /irb(2)?(\/.*|-.*|\.rb)?:/ && $!.class.to_s !~ /^IRB/
irb_bug = true
else
irb_bug = false
@@ -166,7 +161,7 @@ module IRB
messages = []
lasts = []
levels = 0
- for m in exc.backtrace
+ for m in $@
m = @context.workspace.filter_backtrace(m) unless irb_bug
if m
if messages.size < @context.back_trace_limit
@@ -188,7 +183,8 @@ module IRB
print "Maybe IRB bug!!\n" if irb_bug
end
if $SAFE > 2
- abort "Error: irb does not work for $SAFE level higher than 2"
+ warn "Error: irb does not work for $SAFE level higher than 2"
+ exit 1
end
end
end
diff --git a/lib/mkmf.rb b/lib/mkmf.rb
index 31f4878b8b..3e80cb0240 100644
--- a/lib/mkmf.rb
+++ b/lib/mkmf.rb
@@ -438,7 +438,7 @@ def try_var(var, headers = nil, &b)
#{headers}
/*top*/
int main() { return 0; }
-int t() { const volatile void *volatile p; p = &(&#{var})[0]; return 0; }
+int t() { const volatile void *volatile p; p = (void *)&#{var}; return 0; }
SRC
end
diff --git a/lib/net/pop.rb b/lib/net/pop.rb
index 6d1343eded..2ecbcbdf28 100644
--- a/lib/net/pop.rb
+++ b/lib/net/pop.rb
@@ -462,8 +462,6 @@ module Net
def do_finish
@mails = nil
- @n_mails = nil
- @n_bytes = nil
@command.quit if @command
ensure
@started = false
diff --git a/lib/net/telnet.rb b/lib/net/telnet.rb
index a55527f15e..80b95a5149 100644
--- a/lib/net/telnet.rb
+++ b/lib/net/telnet.rb
@@ -559,8 +559,7 @@ module Net
Integer(c.rindex(/#{IAC}#{SB}/no))
buf = preprocess(c[0 ... c.rindex(/#{IAC}#{SB}/no)])
rest = c[c.rindex(/#{IAC}#{SB}/no) .. -1]
- elsif pt = c.rindex(/#{IAC}[^#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]?\z/no) ||
- c.rindex(/\r\z/no)
+ elsif pt = c.rindex(/#{IAC}[^#{IAC}#{AO}#{AYT}#{DM}#{IP}#{NOP}]?\z/no)
buf = preprocess(c[0 ... pt])
rest = c[pt .. -1]
else
@@ -572,15 +571,9 @@ module Net
#
# We cannot use preprocess() on this data, because that
# method makes some Telnetmode-specific assumptions.
- buf = rest + c
+ buf = c
+ buf.gsub!(/#{EOL}/no, "\n") unless @options["Binmode"]
rest = ''
- unless @options["Binmode"]
- if pt = buf.rindex(/\r\z/no)
- buf = buf[0 ... pt]
- rest = buf[pt .. -1]
- end
- buf.gsub!(/#{EOL}/no, "\n")
- end
end
@log.print(buf) if @options.has_key?("Output_log")
line += buf
diff --git a/lib/resolv.rb b/lib/resolv.rb
index 1792fd8178..49e40bdf07 100644
--- a/lib/resolv.rb
+++ b/lib/resolv.rb
@@ -278,7 +278,7 @@ class Resolv
end
class Hosts
- if /mswin32|mingw|bccwin/ =~ RUBY_PLATFORM
+ if /mswin32|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
require 'win32/resolv'
DefaultFileName = Win32::Resolv.get_hosts_path
else
@@ -759,7 +759,6 @@ class Resolv
config_hash = Config.parse_resolv_conf(filename)
else
if /mswin32|cygwin|mingw|bccwin/ =~ RUBY_PLATFORM
- require 'win32/resolv'
search, nameserver = Win32::Resolv.get_resolv_info
config_hash = {}
config_hash[:nameserver] = nameserver if nameserver
diff --git a/lib/singleton.rb b/lib/singleton.rb
index 31fb950378..0ab8517275 100644
--- a/lib/singleton.rb
+++ b/lib/singleton.rb
@@ -70,7 +70,8 @@ module Singleton
def dup
raise TypeError, "can't dup instance of singleton #{self.class}"
end
-
+
+ private
# default marshalling strategy
def _dump(depth=-1)
''
diff --git a/lib/timeout.rb b/lib/timeout.rb
index 5a99c28092..dc92964c0b 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -32,13 +32,8 @@ module Timeout
##
# Raised by Timeout#timeout when the block times out.
- class Error < Interrupt
+ class Error<Interrupt
end
- class ExitException < ::Exception # :nodoc:
- end
-
- THIS_FILE = /\A#{Regexp.quote(__FILE__)}:/o
- CALLER_OFFSET = ((c = caller[0]) && THIS_FILE =~ c) ? 1 : 0
##
# Executes the method's block. If the block execution terminates before +sec+
@@ -49,10 +44,9 @@ module Timeout
# Timeout' into your classes so they have a #timeout method, as well as a
# module method, so you can call it directly as Timeout.timeout().
- def timeout(sec, klass = nil)
+ def timeout(sec, exception=Error)
return yield if sec == nil or sec.zero?
raise ThreadError, "timeout within critical session" if Thread.critical
- exception = klass || Class.new(ExitException)
begin
x = Thread.current
y = Thread.start {
@@ -61,17 +55,6 @@ module Timeout
}
yield sec
# return true
- rescue exception => e
- rej = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-4}\z/o
- (bt = e.backtrace).reject! {|m| rej =~ m}
- level = -caller(CALLER_OFFSET).size
- while THIS_FILE =~ bt[level]
- bt.delete_at(level)
- level += 1
- end
- raise if klass # if exception class is specified, it
- # would be expected outside.
- raise Error, e.message, e.backtrace
ensure
y.kill if y and y.alive?
end
@@ -89,7 +72,7 @@ end
# Defined for backwards compatibility with earlier versions of timeout.rb, see
# Timeout#timeout.
-def timeout(n, e = nil, &block) # :nodoc:
+def timeout(n, e=Timeout::Error, &block) # :nodoc:
Timeout::timeout(n, e, &block)
end
diff --git a/lib/uri/common.rb b/lib/uri/common.rb
index af6aaf26fb..f74f0eb2e1 100644
--- a/lib/uri/common.rb
+++ b/lib/uri/common.rb
@@ -110,7 +110,7 @@ module URI
SERVER = "(?:#{USERINFO}@)?#{HOSTPORT}"
# reg_name = 1*( unreserved | escaped | "$" | "," |
# ";" | ":" | "@" | "&" | "=" | "+" )
- REG_NAME = "(?:[#{UNRESERVED}$,;:@&=+]|#{ESCAPED})+"
+ REG_NAME = "(?:[#{UNRESERVED}$,;+@&=+]|#{ESCAPED})+"
# authority = server | reg_name
AUTHORITY = "(?:#{SERVER}|#{REG_NAME})"
diff --git a/lib/uri/generic.rb b/lib/uri/generic.rb
index 88b5078466..2b66adeb93 100644
--- a/lib/uri/generic.rb
+++ b/lib/uri/generic.rb
@@ -1103,9 +1103,8 @@ module URI
end
end
- @@to_s = Kernel.instance_method(:to_s)
def inspect
- @@to_s.bind(self).call.sub!(/>\z/) {" URL:#{self}>"}
+ sprintf("#<%s:%#0x URL:%s>", self.class.to_s, self.object_id, self.to_s)
end
def coerce(oth)
diff --git a/lib/xmlrpc/server.rb b/lib/xmlrpc/server.rb
index ca8d3b0a5b..59a5869408 100644
--- a/lib/xmlrpc/server.rb
+++ b/lib/xmlrpc/server.rb
@@ -639,11 +639,11 @@ class Server < WEBrickServlet
def serve
if RUBY_PLATFORM =~ /mingw|mswin32/
- signals = [1]
+ signal = 1
else
- signals = %w[INT TERM HUP]
+ signal = "HUP"
end
- signals.each { |signal| trap(signal) { @server.shutdown } }
+ trap(signal) { @server.shutdown }
@server.start
end
diff --git a/lib/yaml.rb b/lib/yaml.rb
index a8da42a321..fe8335c8f0 100644
--- a/lib/yaml.rb
+++ b/lib/yaml.rb
@@ -384,10 +384,6 @@ module YAML
else
emitter.reset( opts )
end
- oid =
- case oid when Fixnum, NilClass; oid
- else oid = "#{oid.object_id}-#{oid.hash}"
- end
out.emit( oid, &e )
end
diff --git a/lib/yaml/basenode.rb b/lib/yaml/basenode.rb
index 5439903f42..d24f6172e9 100644
--- a/lib/yaml/basenode.rb
+++ b/lib/yaml/basenode.rb
@@ -184,7 +184,7 @@ module YAML
#
def []( *key )
if Hash === @value
- v = @value.detect { |k,| k.transform == key.first }
+ v = @value.detect { |k,v| k.transform == key.first }
v[1] if v
elsif Array === @value
@value.[]( *key )
diff --git a/lib/yaml/rubytypes.rb b/lib/yaml/rubytypes.rb
index dc6bb3359f..eebf027135 100644
--- a/lib/yaml/rubytypes.rb
+++ b/lib/yaml/rubytypes.rb
@@ -12,7 +12,7 @@ class Object
def to_yaml_style; end
def to_yaml_properties; instance_variables.sort; end
def to_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
+ YAML::quick_emit( object_id, opts ) do |out|
out.map( taguri, to_yaml_style ) do |map|
to_yaml_properties.each do |m|
map.add( m[1..-1], instance_variable_get( m ) )
@@ -35,7 +35,7 @@ class Hash
end
end
def to_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
+ YAML::quick_emit( object_id, opts ) do |out|
out.map( taguri, to_yaml_style ) do |map|
each do |k, v|
map.add( k, v )
@@ -83,7 +83,7 @@ class Struct
end
end
def to_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
+ YAML::quick_emit( object_id, opts ) do |out|
#
# Basic struct is passed as a YAML map
#
@@ -104,7 +104,7 @@ class Array
yaml_as "tag:yaml.org,2002:seq"
def yaml_initialize( tag, val ); concat( val.to_a ); end
def to_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
+ YAML::quick_emit( object_id, opts ) do |out|
out.seq( taguri, to_yaml_style ) do |seq|
each do |x|
seq.add( x )
@@ -124,7 +124,7 @@ class Exception
o
end
def to_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
+ YAML::quick_emit( object_id, opts ) do |out|
out.map( taguri, to_yaml_style ) do |map|
map.add( 'message', message )
to_yaml_properties.each do |m|
@@ -161,7 +161,7 @@ class String
end
end
def to_yaml( opts = {} )
- YAML::quick_emit( is_complex_yaml? ? self : nil, opts ) do |out|
+ YAML::quick_emit( is_complex_yaml? ? object_id : nil, opts ) do |out|
if is_binary_data?
out.scalar( "tag:yaml.org,2002:binary", [self].pack("m"), :literal )
elsif to_yaml_properties.empty?
@@ -227,7 +227,7 @@ class Range
end
end
def to_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
+ YAML::quick_emit( object_id, opts ) do |out|
# if self.begin.is_complex_yaml? or self.begin.respond_to? :to_str or
# self.end.is_complex_yaml? or self.end.respond_to? :to_str or
# not to_yaml_properties.empty?
@@ -310,7 +310,7 @@ class Time
end
end
def to_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
+ YAML::quick_emit( object_id, opts ) do |out|
tz = "Z"
# from the tidy Tobias Peters <t-peters@gmx.de> Thanks!
unless self.utc?
@@ -347,7 +347,7 @@ end
class Date
yaml_as "tag:yaml.org,2002:timestamp#ymd"
def to_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
+ YAML::quick_emit( object_id, opts ) do |out|
out.scalar( "tag:yaml.org,2002:timestamp", self.to_s, :plain )
end
end
diff --git a/lib/yaml/types.rb b/lib/yaml/types.rb
index 3871c628fe..05113f216d 100644
--- a/lib/yaml/types.rb
+++ b/lib/yaml/types.rb
@@ -10,6 +10,7 @@ module YAML
#
class PrivateType
def self.tag_subclasses?; false; end
+ attr_accessor :type_id, :value
verbose, $VERBOSE = $VERBOSE, nil
def initialize( type, val )
@type_id = type; @value = val
@@ -27,6 +28,7 @@ module YAML
#
class DomainType
def self.tag_subclasses?; false; end
+ attr_accessor :domain, :type_id, :value
verbose, $VERBOSE = $VERBOSE, nil
def initialize( domain, type, val )
@domain = domain; @type_id = type; @value = val
@@ -45,7 +47,7 @@ module YAML
class Object
def self.tag_subclasses?; false; end
def to_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
+ YAML::quick_emit( object_id, opts ) do |out|
out.map( "tag:ruby.yaml.org,2002:object:#{ @class }", to_yaml_style ) do |map|
@ivars.each do |k,v|
map.add( k, v )
@@ -123,7 +125,7 @@ module YAML
true
end
def to_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
+ YAML::quick_emit( self.object_id, opts ) do |out|
out.seq( taguri, to_yaml_style ) do |seq|
self.each do |v|
seq.add( Hash[ *v ] )
@@ -173,7 +175,7 @@ module YAML
true
end
def to_yaml( opts = {} )
- YAML::quick_emit( self, opts ) do |out|
+ YAML::quick_emit( self.object_id, opts ) do |out|
out.seq( taguri, to_yaml_style ) do |seq|
self.each do |v|
seq.add( Hash[ *v ] )
diff --git a/marshal.c b/marshal.c
index be5326e0a2..f97b3b8f21 100644
--- a/marshal.c
+++ b/marshal.c
@@ -81,19 +81,9 @@ shortlen(len, ds)
#define TYPE_LINK '@'
static ID s_dump, s_load, s_mdump, s_mload;
-static ID s_dump_data, s_load_data, s_alloc, s_call;
+static ID s_dump_data, s_load_data, s_alloc;
static ID s_getc, s_read, s_write, s_binmode;
-static void
-reentrant_check(obj, sym)
- VALUE obj;
- ID sym;
-{
- if (obj && RBASIC(obj)->klass) {
- rb_raise(rb_eRuntimeError, "%s reentered", rb_id2name(sym));
- }
-}
-
struct dump_arg {
VALUE obj;
VALUE str, dest;
@@ -512,10 +502,9 @@ w_object(obj, arg, limit)
st_add_direct(arg->data, obj, arg->data->num_entries);
if (rb_respond_to(obj, s_mdump)) {
- volatile VALUE v;
+ VALUE v;
v = rb_funcall(obj, s_mdump, 0, 0);
- reentrant_check(arg->str, s_mdump);
w_class(TYPE_USRMARSHAL, obj, arg, Qfalse);
w_object(v, arg, limit);
if (ivtbl) w_ivar(0, &c_arg);
@@ -525,7 +514,6 @@ w_object(obj, arg, limit)
VALUE v;
v = rb_funcall(obj, s_dump, 1, INT2NUM(limit));
- reentrant_check(arg->str, s_dump);
if (TYPE(v) != T_STRING) {
rb_raise(rb_eTypeError, "_dump() must return string");
}
@@ -670,7 +658,6 @@ w_object(obj, arg, limit)
rb_obj_classname(obj));
}
v = rb_funcall(obj, s_dump_data, 0);
- reentrant_check(arg->str, s_dump_data);
w_class(TYPE_DATA, obj, arg, Qtrue);
w_object(v, arg, limit);
}
@@ -703,13 +690,11 @@ static VALUE
dump_ensure(arg)
struct dump_arg *arg;
{
- if (RBASIC(arg->str)->klass) return; /* ignore reentrant */
st_free_table(arg->symbols);
st_free_table(arg->data);
if (arg->taint) {
OBJ_TAINT(arg->str);
}
-
return 0;
}
@@ -762,21 +747,20 @@ marshal_dump(argc, argv)
else port = a1;
}
arg.dest = 0;
- arg.str = rb_str_buf_new(0);
- RBASIC(arg.str)->klass = 0;
if (!NIL_P(port)) {
if (!rb_respond_to(port, s_write)) {
type_error:
rb_raise(rb_eTypeError, "instance of IO needed");
}
+ arg.str = rb_str_buf_new(0);
arg.dest = port;
if (rb_respond_to(port, s_binmode)) {
rb_funcall2(port, s_binmode, 0, 0);
- reentrant_check(arg.str, s_dump_data);
}
}
else {
- port = arg.str;
+ port = rb_str_buf_new(0);
+ arg.str = port;
}
arg.symbols = st_init_numtable();
@@ -790,7 +774,6 @@ marshal_dump(argc, argv)
w_byte(MARSHAL_MINOR, &arg);
rb_ensure(dump, (VALUE)&c_arg, dump_ensure, (VALUE)&arg);
- RBASIC(arg.str)->klass = rb_cString;
return port;
}
@@ -823,7 +806,6 @@ r_byte(arg)
else {
VALUE src = arg->src;
VALUE v = rb_funcall2(src, s_getc, 0, 0);
- reentrant_check(arg->data, s_getc);
if (NIL_P(v)) rb_eof_error();
c = (unsigned char)FIX2INT(v);
}
@@ -904,7 +886,6 @@ r_bytes0(len, arg)
VALUE src = arg->src;
VALUE n = LONG2NUM(len);
str = rb_funcall2(src, s_read, 1, &n);
- reentrant_check(arg->data, s_read);
if (NIL_P(str)) goto too_short;
StringValue(str);
if (RSTRING(str)->len != len) goto too_short;
@@ -1258,7 +1239,6 @@ r_object0(arg, proc, ivp, extmod)
*ivp = Qfalse;
}
v = rb_funcall(klass, s_load, 1, data);
- reentrant_check(arg->data, s_load);
r_entry(v, arg);
}
break;
@@ -1282,7 +1262,6 @@ r_object0(arg, proc, ivp, extmod)
r_entry(v, arg);
data = r_object(arg);
rb_funcall(v, s_mload, 1, data);
- reentrant_check(arg->data, s_mload);
}
break;
@@ -1309,7 +1288,6 @@ r_object0(arg, proc, ivp, extmod)
warn = Qfalse;
}
v = rb_funcall(klass, s_alloc, 0);
- reentrant_check(arg->data, s_alloc);
}
else {
v = rb_obj_alloc(klass);
@@ -1324,7 +1302,6 @@ r_object0(arg, proc, ivp, extmod)
rb_class2name(klass));
}
rb_funcall(v, s_load_data, 1, r_object0(arg, 0, 0, extmod));
- reentrant_check(arg->data, s_load_data);
}
break;
@@ -1367,8 +1344,7 @@ r_object0(arg, proc, ivp, extmod)
break;
}
if (proc) {
- rb_funcall(proc, s_call, 1, v);
- reentrant_check(arg->data, s_call);
+ rb_funcall(proc, rb_intern("call"), 1, v);
}
return v;
}
@@ -1391,7 +1367,6 @@ static VALUE
load_ensure(arg)
struct load_arg *arg;
{
- if (RBASIC(arg->data)->klass) return; /* ignore reentrant */
st_free_table(arg->symbols);
return 0;
}
@@ -1418,10 +1393,9 @@ marshal_load(argc, argv)
struct load_arg arg;
rb_scan_args(argc, argv, "11", &port, &proc);
- v = rb_check_string_type(port);
- if (!NIL_P(v)) {
+ if (rb_respond_to(port, rb_intern("to_str"))) {
arg.taint = OBJ_TAINTED(port); /* original taintedness */
- port = v;
+ StringValue(port); /* possible conversion */
}
else if (rb_respond_to(port, s_getc) && rb_respond_to(port, s_read)) {
if (rb_respond_to(port, s_binmode)) {
@@ -1434,7 +1408,6 @@ marshal_load(argc, argv)
}
arg.src = port;
arg.offset = 0;
- arg.data = 0;
major = r_byte(&arg);
minor = r_byte(&arg);
@@ -1451,11 +1424,9 @@ marshal_load(argc, argv)
arg.symbols = st_init_numtable();
arg.data = rb_hash_new();
- RBASIC(arg.data)->klass = 0;
if (NIL_P(proc)) arg.proc = 0;
else arg.proc = proc;
v = rb_ensure(load, (VALUE)&arg, load_ensure, (VALUE)&arg);
- RBASIC(arg.data)->klass = rb_cHash;
return v;
}
@@ -1505,7 +1476,6 @@ Init_marshal()
s_dump_data = rb_intern("_dump_data");
s_load_data = rb_intern("_load_data");
s_alloc = rb_intern("_alloc");
- s_call = rb_intern("call");
s_getc = rb_intern("getc");
s_read = rb_intern("read");
s_write = rb_intern("write");
diff --git a/misc/ruby-mode.el b/misc/ruby-mode.el
index 779a52def4..25c6b3008d 100644
--- a/misc/ruby-mode.el
+++ b/misc/ruby-mode.el