Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Second merge from trunk.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/rexml_adds_tests@19455 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
commit 8b53e39a2e6110cf13827c88673a3ef2667991cf 1 parent f36a3f0
ser authored
Showing with 5,045 additions and 2,283 deletions.
  1. +786 −1 ChangeLog
  2. +5 −5 bignum.c
  3. +1 −3 common.mk
  4. +207 −167 complex.c
  5. +7 −4 configure.in
  6. +2 −1  dln.c
  7. +2 −2 enc/big5.c
  8. +2 −2 enc/cp949.c
  9. +2 −2 enc/euc_jp.c
  10. +2 −2 enc/euc_kr.c
  11. +2 −2 enc/euc_tw.c
  12. +1 −1  enc/gb18030.c
  13. +2 −2 enc/gbk.c
  14. +2 −2 enc/shift_jis.c
  15. +1 −1  enc/utf_16be.c
  16. +1 −1  enc/utf_16le.c
  17. +1 −1  enc/utf_32be.c
  18. +1 −1  enc/utf_32le.c
  19. +1 −1  enc/utf_8.c
  20. +37 −32 encoding.c
  21. +2 −2 error.c
  22. +0 −3  eval.c
  23. +20 −11 ext/bigdecimal/bigdecimal.c
  24. +2 −3 ext/json/ext/generator/extconf.rb
  25. +3 −10 ext/json/ext/generator/generator.c
  26. +0 −2  ext/json/ext/generator/unicode.c
  27. +2 −3 ext/json/ext/parser/extconf.rb
  28. +317 −314 ext/json/ext/parser/parser.c
  29. +29 −33 ext/json/ext/parser/parser.rl
  30. +1 −3 ext/json/ext/parser/unicode.c
  31. +28 −13 ext/json/lib/json/add/core.rb
  32. +5 −5 ext/json/lib/json/common.rb
  33. +0 −1  ext/json/lib/json/editor.rb
  34. +2 −3 ext/json/lib/json/pure/parser.rb
  35. +1 −1  ext/json/lib/json/version.rb
  36. +17 −15 ext/nkf/nkf-utf8/nkf.c
  37. +11 −0 ext/openssl/ossl_pkey_ec.c
  38. +1 −1  ext/socket/getaddrinfo.c
  39. +1 −1  ext/socket/getnameinfo.c
  40. +15 −0 ext/socket/mkconstants.rb
  41. +1 −1  ext/socket/socket.c
  42. +2 −2 ext/win32ole/win32ole.c
  43. +2 −2 gc.c
  44. +0 −4 hash.c
  45. +1 −1  include/ruby/defines.h
  46. +5 −5 include/ruby/encoding.h
  47. +10 −10 include/ruby/oniguruma.h
  48. +3 −2 include/ruby/ruby.h
  49. +0 −2  inits.c
  50. +48 −31 io.c
  51. +33 −33 lib/cmath.rb
  52. +16 −2 lib/complex.rb
  53. +554 −152 lib/csv.rb
  54. +9 −5 lib/mathn.rb
  55. +14 −6 lib/matrix.rb
  56. +6 −6 lib/open-uri.rb
  57. +8 −1 lib/optparse.rb
  58. +5 −5 lib/pathname.rb
  59. +27 −27 lib/pp.rb
  60. +7 −7 lib/prettyprint.rb
  61. +445 −197 lib/rake.rb
  62. +9 −14 lib/rake/loaders/makefile.rb
  63. +1 −0  lib/rake/packagetask.rb
  64. +7 −7 lib/rake/rdoctask.rb
  65. +8 −3 lib/rake/tasklib.rb
  66. +6 −1 lib/rake/testtask.rb
  67. +20 −20 lib/resolv.rb
  68. +19 −19 lib/time.rb
  69. +10 −10 lib/tsort.rb
  70. +1 −1  lib/uri/common.rb
  71. +1 −1  load.c
  72. +1 −1  marshal.c
  73. +1 −1  math.c
  74. +9 −73 numeric.c
  75. +9 −0 object.c
  76. +4 −6 parse.y
  77. +0 −138 prec.c
  78. +48 −44 rational.c
  79. +22 −18 re.c
  80. +13 −12 regenc.c
  81. +1 −1  regenc.h
  82. +48 −49 regexec.c
  83. +1 −1  regparse.c
  84. +7 −4 ruby.c
  85. +4 −3 st.c
  86. +408 −165 string.c
  87. +689 −0 test/bigdecimal/test_bigdecimal.rb
  88. +30 −2 test/csv/tc_csv_parsing.rb
  89. +2 −1  test/csv/tc_csv_writing.rb
  90. +2 −1  test/csv/tc_data_converters.rb
  91. +94 −6 test/csv/tc_features.rb
  92. +28 −1 test/csv/tc_headers.rb
  93. +74 −5 test/csv/tc_interface.rb
  94. +22 −1 test/csv/tc_row.rb
  95. +2 −1  test/csv/tc_serialization.rb
  96. +15 −1 test/csv/tc_table.rb
  97. +3 −1 test/csv/ts_all.rb
  98. +1 −1  test/json/fixtures/fail18.json
  99. +0 −1  test/json/runner.rb
  100. +51 −13 test/json/test_json.rb
  101. +26 −12 test/json/test_json_addition.rb
  102. +19 −0 test/json/test_json_generate.rb
  103. +6 −5 test/json/test_json_rails.rb
  104. +1 −4 test/json/test_json_unicode.rb
  105. +49 −0 test/matrix/test_matrix.rb
  106. +49 −0 test/matrix/test_vector.rb
  107. +158 −132 test/ruby/test_complex.rb
  108. +0 −9 test/ruby/test_fixnum.rb
  109. +0 −7 test/ruby/test_float.rb
  110. +0 −6 test/ruby/test_integer.rb
  111. +10 −20 test/ruby/test_io.rb
  112. +20 −20 test/ruby/test_io_m17n.rb
  113. +30 −21 test/ruby/test_m17n.rb
  114. +44 −43 test/ruby/test_m17n_comb.rb
  115. +1 −0  test/ruby/test_math.rb
  116. +3 −3 test/ruby/test_mixed_unicode_escapes.rb
  117. +2 −2 test/ruby/test_numeric.rb
  118. +0 −21 test/ruby/test_prec.rb
  119. +55 −42 test/ruby/test_rational.rb
  120. +92 −86 test/ruby/test_transcode.rb
  121. +75 −54 transcode.c
  122. +8 −6 transcode_data.h
  123. +3 −3 version.h
  124. +5 −2 vm.c
View
787 ChangeLog
@@ -1,3 +1,787 @@
+Sun Sep 21 21:52:41 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * math.c (math_log): should check argc.
+
+Sun Sep 21 21:20:24 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c: added two macros.
+
+ * rational.c: ditto.
+
+Sun Sep 21 18:06:38 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c (nucomp_s_convert): checks argc.
+
+ * rational.c (nurat_s_convert): ditto.
+
+Sun Sep 21 10:19:04 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c (nucomp_s_canonicalize_internal): checks exactness of
+ imag only.
+
+ * rational.c (nurat_s_convert): accepts non real value
+ (Rational(a,b) as a/b).
+
+ * complex.c (nucomp_s_convert): refined.
+
+Sun Sep 21 09:37:57 2008 James Edward Gray II <jeg2@ruby-lang.org>
+
+ * lib/csv/csv.rb: Reworked CSV's parser and generator to be m17n. Data
+ is now parsed in the Encoding it is in without need for translation.
+ * lib/csv/csv.rb: Improved inspect() messages for better IRb support.
+ * lib/csv/csv.rb: Fixed header writing bug reported by Dov Murik.
+ * lib/csv/csv.rb: Use custom separators in parsing header Strings as
+ suggested by Shmulik Regev.
+ * lib/csv/csv.rb: Added a :write_headers option for outputting headers.
+ * lib/csv/csv.rb: Handle open() calls in binary mode whenever we can to
+ workaround a Windows issue where line-ending translation can cause an
+ off-by-one error in seeking back to a non-zero starting position after
+ auto-discovery for :row_sep as suggested by Robert Battle.
+ * lib/csv/csv.rb: Improved the parser to fail faster when fed some forms
+ of invalid CSV that can be detected without reading ahead.
+ * lib/csv/csv.rb: Added a :field_size_limit option to control CSV's
+ lookahead and prevent the parser from biting off more data than
+ it can chew.
+ * lib/csv/csv.rb: Added readers for CSV attributes: col_sep(), row_sep(),
+ quote_char(), field_size_limit(), converters(), unconverted_fields?(),
+ headers(), return_headers?(), write_headers?(), header_converters(),
+ skip_blanks?(), and force_quotes?().
+ * lib/csv/csv.rb: Cleaned up code syntax to be more inline with
+ Ruby 1.9 than 1.8.
+
+Sun Sep 21 07:43:16 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c: an instance method image has been removed and
+ uses "imag" instead of "image".
+
+ * complex.c: two instance method re and im are removed.
+
+ * rational.c: follows the above changes.
+
+ * include/ruby/ruby.h: ditto.
+
+ * gc.c: ditto.
+
+ * lib/cmath.rb: ditto.
+
+ * lib/mathn.rb: ditto.
+
+ * lib/complex.rb: ditto. and provides some obsolate methods.
+
+Sun Sep 21 02:48:45 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * ext/json/ext/parser/parse.c: use ruby_xfree().
+
+ * ext/json/ext/parser/parse.rl: ditto.
+
+ * ext/json/ext/parser/unicode.c: ditto.
+
+Sun Sep 21 02:40:20 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * ext/json: import JSON v 1.1.3.
+
+Sat Sep 20 11:43:08 2008 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * lib/optparse.rb (summarize): separator "" should output new line.
+
+Sat Sep 20 08:07:34 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * parse.y: strings which contain only US-ASCII don't force to have
+ US-ASCII encoding. [ruby-dev:36400]
+
+Sat Sep 20 07:59:31 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * re.c (rb_reg_desc): Regexps of ASCII Compatible encoding may
+ contain non-ASCII characters. So in that case its encoding
+ must keep original encoding.
+
+Sat Sep 20 07:44:56 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * common.mk: prec.c is removed.
+
+Fri Sep 19 22:37:25 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c: uses f_(in)?exact_p macro.
+
+ * rational.c: ditto.
+
+ * bignum.c (rb_big_pow): bignum**bignum - should calculate without
+ rational.
+
+ * lib/complex.rb: should override Math module at most once.
+
+ * lib/mathn.rb: requires 'cmath' directly.
+
+Fri Sep 19 20:48:06 2008 Yuki Sonoda <yugui@yugui.jp>
+
+ * prec.c: removed. Precision will be redesigned and be back again.
+ c.f. [ruby-dev:36352].
+
+ * common.mk (COMMON_OBJS): removed prec.o.
+
+ * inits.c (rb_call_inits): removed Init_Precision.
+
+ * numeric.c (Init_Numeric): removed inclusion of Precision.
+ removed #induced_from from each class.
+
+ * rational.c: ditto.
+
+ * ext/bigdecimal/bigdecimal.c: ditto.
+
+ * lib/rdoc/knwon_classes.rb: removed the entry for Precision.
+
+ * test/ruby/test_prec.rb: removed.
+
+ * test/ruby/test_integer.rb: removed tests for Precision.
+
+ * test/ruby/test_fixnum.rb: ditto.
+
+ * test/ruby/test_float.rb: ditto.
+
+ * test/ruby/test_rational.rb: ditto.
+
+ * test/ruby/test_complex.rb: ditto.
+
+ * test/bigdecimal/test_bigdecimal.rb: ditto.
+
+Fri Sep 19 19:43:40 2008 Yuki Sonoda <yugui@yugui.jp>
+
+ * common.mk : Reverts the changeset 18994.
+ Uses the official repository of rubyspec again.
+
+Fri Sep 19 17:41:56 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * configure.in: applied OS/2 support patch from Brendan Oakley
+ <gentux2@gmail.com> in [ruby-core:18707].
+
+Fri Sep 19 09:29:26 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dln.c: newer BeOS support. a patch from Pete Goodeve
+ <pete.goodeve at computer.org> in [ruby-core:18712].
+
+Fri Sep 19 03:41:25 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * ext/nkf/nkf-utf8/nkf.c: fix memory violation. mentioned by mame [ruby-dev:36373]
+
+Fri Sep 19 01:07:36 2008 Tanaka Akira <akr@fsij.org>
+
+ * regexec.c (string_cmp_ic): add text_end argument.
+ (slow_search): call enclen with real string end.
+ (map_search): add text_end argument.
+
+Thu Sep 18 22:54:39 2008 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * ext/openssl/ossl_pkey_ec.c (ossl_ec_key_to_string): comment out
+ fragments of unused code.
+
+Thu Sep 18 22:35:03 2008 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * ext/bigdecimal/bigdecimal.c (VpCtoV): 1E1000...000 is interpreted as
+ Infinity. [ruby-dev:36159]
+
+ * ext/bigdecimal/bigdecimal.c (VpPower): Infinity ** 1 returns
+ Infinity instead of NaN. [ruby-dev:36159]
+
+ * test/bigdecimal/test_bigdecimal.rb: add tests for above.
+
+Thu Sep 18 21:57:32 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_comparable): make ascii8bit string to be
+ compatible with any other encoding.
+
+ * string.c (rb_str_cmp): use rb_str_comparable() instead of
+ rb_enc_compatible() since <=> is a comparison anyway.
+
+Thu Sep 18 21:37:14 2008 Tanaka Akira <akr@fsij.org>
+
+ * grapheme cluster implementation reverted. [ruby-dev:36375]
+
+Thu Sep 18 20:50:36 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/rake.rb (Rake::Application#standard_exception_handling):
+ replaced magic numbers for exit status.
+
+Thu Sep 18 20:37:59 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * lib/optparse.rb (OptionParser::ParseError#set_backtrace): omits
+ OptionParser internal backtraces unless debug flag is set.
+
+Thu Sep 18 20:02:48 2008 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * lib/uri/common.rb (unescape): skip '%' to make String#hex work
+ correctly.
+
+Thu Sep 18 19:51:11 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * bignum.c (big2str_karatsuba): free internal buffer eagerly.
+ a patch from TOYOFUKU Chikanobu <nobu_toyofuku at nifty.com>
+ in [ruby-dev:36217].
+
+ * bignum.c (rb_big2str0): ditto.
+
+Thu Sep 18 19:43:04 2008 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * st.c (new_size): raise RuntimeError when st_table is too big.
+ [ruby-dev:36354]
+
+Thu Sep 18 18:23:23 2008 Tanaka Akira <akr@fsij.org>
+
+ * transcode.c (enc_arg): must take pointer argument to avoid GC
+ problem. StringValueCStr modifies the argument and it should be
+ preserved while the string StringValueCStr returns is used.
+ Since the string is used by caller, the modified argument should be
+ hold by caller. Actually
+ GC.stress = true
+ def (o=Object.new).to_str()
+ "universal"+"_newline"
+ end
+ "\u3042".encode(o, "")
+ causes curious warning:
+ rb_define_const: invalid name `' for constant
+
+Thu Sep 18 17:32:44 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * transcode.c: add "Error" suffix for Encoding exception classes.
+ a patch from Tadashi Saito <shiba at mail2.accsnet.ne.jp> in
+ [ruby-dev:36346].
+
+ * encoding.c (Init_Encoding): rename EncodingCompatibilityError to
+ Encoding::CompatibilityError. [ruby-dev:36366]
+
+Thu Sep 18 17:18:35 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * transcode.c (enc_arg): revert last change. too early exception
+ raising.
+
+ * transcode.c (enc_arg): need not to take pointer argument.
+
+Sun Sep 18 02:22:15 2008 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * test/bigdecimal/test_bigdecimal.rb: add tests to achieve over 90%
+ test coverage of bigdecimal.
+
+Wed Sep 17 21:50:14 2008 Tanaka Akira <akr@fsij.org>
+
+ * string.c (rb_str_casecmp): don't use rb_enc_codepoint.
+
+Wed Sep 17 19:55:33 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c (nucomp_s_convert): accepts complex
+ value (Complex(a,b) as a+bi).
+
+Wed Sep 17 19:16:47 2008 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
+
+ * test/ruby/test_io.rb (TestIO#test_dup): avoid infinite loop.
+ [ruby-dev:36326]
+
+ * test/ruby/test_io.rb (TestIO#test_dup): remove needless open.
+ [ruby-dev:35957]
+
+Wed Sep 17 17:44:59 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_extract_modeenc): process option mode: and perm: as
+ well.
+
+ * io.c (open_key_args): move mode: and perm: related code to
+ rb_io_extract_modeenc().
+
+Wed Sep 17 13:42:59 2008 Takeyuki Fujioka <xibbar@ruby-lang.org>
+
+ * lib/cgi/html.rb (checkbox_group,radio_group): bug fix
+ use size instead of bytesize.
+
+ * test/cgi/test_cgi_tag_helper.rb: test for checkbox_group,radio_group.
+
+Wed Sep 17 06:58:31 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * numeric.c: provides predicate real? instead of scalar?.
+
+ * complex.c: follows the above change.
+
+ * lib/cmath.rb: ditto.
+
+Wed Sep 17 01:56:27 2008 Tanaka Akira <akr@fsij.org>
+
+ * test/ruby/test_io_m17n.rb: use __FILE__ instead of /dev/null.
+ [ruby-dev:36327]
+
+Wed Sep 17 01:33:11 2008 Tanaka Akira <akr@fsij.org>
+
+ * include/ruby/oniguruma.h (OnigEncodingTypeST): add precise_ret
+ argument for mbc_to_code.
+ (ONIGENC_MBC_TO_CODE): provide NULL for precise_ret.
+ (ONIGENC_MBC_PRECISE_CODEPOINT): defined.
+
+ * include/ruby/encoding.h (rb_enc_mbc_precise_codepoint): defined.
+
+ * regenc.h (onigenc_single_byte_mbc_to_code): precise_ret argument
+ added.
+ (onigenc_mbn_mbc_to_code): ditto.
+
+ * regenc.c (onigenc_single_byte_mbc_to_code): precise_ret argument
+ added.
+ (onigenc_mbn_mbc_to_code): ditto.
+
+ * string.c (count_utf8_lead_bytes_with_word): removed.
+ (str_utf8_nth): removed.
+ (str_utf8_offset): removed.
+ (str_strlen): UTF-8 codepoint oriented optimization removed.
+ (rb_str_substr): ditto.
+ (enc_succ_char): use rb_enc_mbc_precise_codepoint.
+ (enc_pred_char): ditto.
+ (rb_str_succ): ditto.
+
+ * encoding.c (rb_enc_ascget): check length with
+ rb_enc_mbc_precise_codepoint.
+ (rb_enc_codepoint): use rb_enc_mbc_precise_codepoint.
+
+ * regexec.c (string_cmp_ic): add text_end argument.
+ (match_at): check end of character after exact string matches.
+
+ * enc/utf_8.c (grapheme_table): defined for extended grapheme cluster
+ boundary.
+ (grapheme_cmp): defined.
+ (get_grapheme_properties): defined.
+ (grapheme_boundary_p): defined.
+ (MAX_BYTES_LENGTH): defined.
+ (comb_char_enc_len): defined.
+ (mbc_to_code0): extracted from mbc_to_code.
+ (mbc_to_code): use mbc_to_code0.
+ (left_adjust_combchar_head): defined.
+ (utf_8): use a extended grapheme cluster as a unit.
+
+ * enc/unicode.c (onigenc_unicode_mbc_case_fold): use
+ ONIGENC_MBC_PRECISE_CODEPOINT to extract codepoints.
+ (onigenc_unicode_get_case_fold_codes_by_str): ditto.
+
+ * enc/euc_jp.c (mbc_to_code): follow mbc_to_code field change.
+ use onigenc_mbn_mbc_to_code.
+
+ * enc/shift_jis.c (mbc_to_code): ditto.
+
+ * enc/emacs_mule.c (mbc_to_code): ditto.
+
+ * enc/gbk.c (gbk_mbc_to_code): follow mbc_to_code field and
+ onigenc_mbn_mbc_to_code change.
+
+ * enc/cp949.c (cp949_mbc_to_code): ditto.
+
+ * enc/big5.c (big5_mbc_to_code): ditto.
+
+ * enc/euc_tw.c (euctw_mbc_to_code): ditto.
+
+ * enc/euc_kr.c (euckr_mbc_to_code): ditto.
+
+ * enc/gb18030.c (gb18030_mbc_to_code): ditto.
+
+ * enc/utf_32be.c (utf32be_mbc_to_code): follow mbc_to_code field
+ change.
+
+ * enc/utf_16be.c (utf16be_mbc_to_code): ditto.
+
+ * enc/utf_32le.c (utf32le_mbc_to_code): ditto.
+
+ * enc/utf_16le.c (utf16le_mbc_to_code): ditto.
+
+Wed Sep 17 01:17:12 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * transcode.c (enc_arg): raise exception when unknown encoding is
+ given.
+
+Tue Sep 16 22:23:24 2008 Takeyuki Fujioka <xibbar@ruby-lang.org>
+
+ * lib/cgi/core.rb (CGI#header): performance improvement.
+ From CGIAlt http://cgialt.rubyforge.org/
+
+ * test/cgi/test_cgi_header.rb: exception class fixed.
+
+Tue Sep 16 22:21:33 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * string.c (rb_str_concat): fix rdoc. (codepoint is integer)
+
+ * string.c (rb_str_each_codepoint): use UINT2NUM.
+
+Tue Sep 16 21:48:55 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * re.c (rb_reg_desc): Regexp#inspect should be US-ASCII.
+
+Tue Sep 16 21:33:22 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * string.c (rb_str_crypt): orthodox crypt() sees only first two bytes
+ of salt.
+
+Tue Sep 16 19:18:40 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c (nucomp_marshal_{dump,load}): preserve instance
+ variables.
+
+ * rational.c (nurat_marshal_{dump,load}): ditto.
+
+Tue Sep 16 18:28:52 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * io.c (rb_io_gets_m): rdoc updated. limit counts in bytes.
+ [ruby-core:18617]
+
+ * io.c (rb_io_readlines, rb_f_gets): ditto.
+
+ * io.c (rb_io_readbyte): rdoc updated. [ruby-core:18617]
+
+Tue Sep 16 11:55:16 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_each_codepoint): add new methods, #codepoints
+ and #each_codepoint. a patch from Michael Selig
+ <michael.selig at fs.com.au> in [ruby-core:18532].
+
+Tue Sep 16 11:24:44 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * ext/socket/mkconstants.rb: add new constants. a patch from
+ IWAMURO Motonori <deenheart+ruby at gmail.com> in [ruby-dev:36309].
+
+Tue Sep 16 09:20:42 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * test/ruby/test_io.rb (TestIO#test_dup): exception should be
+ raised from IO#dup.
+
+Tue Sep 16 08:35:29 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * test/ruby/test_io.rb (TestIO#test_dup): this test might fail if
+ there are any garbage IO objects.
+
+Tue Sep 16 02:02:56 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * string.c (rb_str_buf_cat_ascii): codepoint is unsigned int.
+
+ * string.c (rb_str_concat): ditto.
+
+ * string.c (str_cat_char): ditto.
+
+ * string.c (prefix_escape): ditto.
+
+Tue Sep 16 01:47:07 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (single_byte_optimizable): make function inline. based
+ on a patch from Michael Selig <michael.selig at fs.com.au> in
+ [ruby-core:18532].
+
+ * string.c (str_modify_keep_cr): new function act as
+ rb_str_modify(), but don't clear coderange
+
+ * string.c (rb_str_casecmp): specialized for single byte strings.
+
+ * string.c (rb_str_splice): preserve coderange.
+
+ * string.c (rb_str_slice_bang, rb_str_reverse_bang,
+ rb_str_upcase_bang, rb_str_downcase_bang, tr_trans,
+ rb_str_capitalize_bang, rb_str_swapcase_bang,
+ rb_str_delete_bang, rb_str_chop_bang, rb_str_chomp_bang,
+ rb_str_lstrip_bang, rb_str_rstrip_bang): ditto.
+
+ * string.c (rb_str_clear): preset coderange.
+
+ * string.c (rb_str_split_m): specialized for splitting with a
+ string.
+
+Tue Sep 16 00:57:56 2008 Tanaka Akira <akr@fsij.org>
+
+ * re.c (rb_reg_quote): use rb_enc_mbcput to generate ASCII
+ incompatible characters properly.
+
+Tue Sep 16 00:51:59 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * encoding.c (Encoding#base_encoding): removed. [ruby-dev:36270]
+
+Tue Sep 16 00:40:56 2008 Tanaka Akira <akr@fsij.org>
+
+ * transcode_data.h (STR1_LENGTH): defined.
+ (makeSTR1LEN): defined.
+
+ * tool/transcode-tblgen.rb: use makeSTR1LEN. generate STR1 for 4 to
+ 259 bytes.
+
+ * transcode.c (rb_transcoding): new field: output_index.
+ (transcode_restartable0): use STR1_LENGTH.
+
+Mon Sep 15 23:52:45 2008 Koichi Sasada <ko1@atdot.net>
+
+ * gc.c, include/ruby/ruby.h: rename rb_register_mark_object()
+ to rb_gc_register_mark_object().
+
+ * eval.c, vm.c: initialize vm->mark_object_ary at
+ Init_top_self().
+
+ * bignum.c, complex.c, encoding.c, ext/win32ole/win32ole.c,
+ io.c, load.c, marshal.c, rational.c, ruby.c, vm.c:
+ use rb_gc_register_mark_object() instead of
+ rb_global_variable() or rb_gc_register_address().
+
+Mon Sep 15 23:37:15 2008 Tanaka Akira <akr@fsij.org>
+
+ * transcode.c (econv_opts): don't use to_sym.
+
+Mon Sep 15 23:28:28 2008 Tanaka Akira <akr@fsij.org>
+
+ * encoding.c (rb_enc_get_index): don't return -1.
+
+ * io.c (rb_scan_open_args): call FilePathValue before encoding
+ conversion.
+
+Mon Sep 15 22:11:07 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * string.c (rb_str_squeeze_bang): specialized for 7bit characters in
+ ASCII compatible strings.
+
+ * string.c (rb_str_count): ditto.
+
+ * string.c (tr_trans): preserve 7bit/valid coderange flag.
+
+ * string.c (rb_str_squeeze_bang): preserve previous coderange value.
+
+ * string.c (rb_str_lstrip_bang): ditto.
+
+ * string.c (rb_str_rstrip_bang): ditto.
+
+ * encoding.c (rb_default_external_encoding): preserve
+ default_external_encoding in a static variable.
+
+ * string.c (single_byte_optimizable): check coderange first, to
+ reduce number of calling rb_enc_from_index().
+
+Mon Sep 15 20:57:00 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
+
+ * lib/matrix.rb (Matrix#eql?): fixed [ruby-dev:36298].
+ Reported by an anonymous user.
+
+ * lib/matrix.rb (Vector#eql?): ditto.
+
+ * (Matrix#compare_by_row_vectors): takes comparison
+ strategy as an optional parameter.
+
+ * (Vector#compare_by): ditto.
+
+Mon Sep 15 14:34:32 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * encoding.c (RUBY_MAX_CHAR_LEN): defined.
+
+ * encoding.c (str_cat_char): use RUBY_MAX_CHAR_LEN.
+
+Mon Sep 15 13:53:33 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * encoding.c (rb_enc_compatible): accept other than strings and
+ regexps. [ruby-core:18595]
+
+ * encoding.c (rb_enc_get_index): works files and encodings.
+
+Mon Sep 15 13:17:21 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c (nucomp_eql_p): new.
+
+ * complex.c (nucomp_hash): should use hash values of the elements.
+
+ * rational.c (nurat_hash): ditto.
+
+ * hash.c (rb_any_cmp): removed an unused variable.
+
+Mon Sep 15 11:11:04 2008 Tanaka Akira <akr@fsij.org>
+
+ * transcode_data.h (rb_transcoder): resetsize_func and resetstate_func
+ also returns ssize_t.
+
+ * enc/trans/iso2022.trans: follow the type change.
+
+Mon Sep 15 10:28:10 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
+
+ * test/matrix/test_matrix.rb (setup): typo.
+ (test_equality): misdefinition of the expected working.
+ Reported by an anonymous user.
+ (test_hash): added.
+
+ * test/matrix/test_vector.rb: ditto.
+
+Mon Sep 15 03:33:10 2008 Tanaka Akira <akr@fsij.org>
+
+ * transcode_data.h: return output functions ssize_t.
+
+ * transcode.c (transcode_restartable0): don't need to cast the result
+ of output functions.
+
+ * enc/trans/newline.trans: follow the type change.
+
+ * enc/trans/escape.trans: ditto.
+
+ * enc/trans/utf_16_32.trans: ditto.
+
+ * enc/trans/iso2022.trans: ditto.
+
+ * enc/trans/japanese.trans: ditto.
+
+Mon Sep 15 03:04:29 2008 Tanaka Akira <akr@fsij.org>
+
+ * transcode_data.h: output function takes output buffer size.
+
+ * transcode.c: give output buffer size for output functions.
+
+ * enc/trans/newline.trans: follow the type change.
+
+ * enc/trans/escape.trans: ditto.
+
+ * enc/trans/utf_16_32.trans: ditto.
+
+ * enc/trans/iso2022.trans: ditto.
+
+ * enc/trans/japanese.trans: ditto.
+
+Mon Sep 15 02:37:19 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * transcode.c (str_encode): returns duplicated string if nothing
+ changed. [ruby-core:18578]
+
+Sun Sep 14 22:09:01 2008 Takeyuki Fujioka <xibbar@ruby-lang.org>
+
+ * lib/cgi/core.rb (CGI::parse): performance improvement
+
+Sun Sep 14 18:33:32 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c: trivial changes.
+
+Sun Sep 14 16:15:22 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
+
+ * lib/matrix.rb (Vector#eql?): typo of the method name as "eqn?".
+ (Vector#eqn?): removed. Defined by mistake.
+ Fixes [ruby-dev:36294]. Reported by weda <weda AT
+ issp.u-tokyo.ac.jp> and an anonymous user.
+
+ * test/matrix/test_matrix.rb: added.
+
+ * test/matrix/test_vector.rb: added.
+
+Sun Sep 14 16:07:04 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ruby.c (process_options): associates the locale encoding with $0 as
+ well as ARGV.
+
+Sun Sep 14 13:48:03 2008 Yuki Sonoda (Yugui) <yugui@yugui.jp>
+
+ * object.c (Init_Object): added metameta-class initialization for
+ BasicObject, Object, and Module.
+ The metameta-classes of them are now the metaclass of Class, as the
+ metameta-class of Class is.
+
+ * object.c (boot_defmetametaclass): added.
+
+Sun Sep 14 10:10:43 2008 Tadayoshi Funaba <tadf@dotrb.org>
+
+ * complex.c (f_{add,mul,sub}): omitted some shortcuts for preserving
+ signed zero anyway.
+
+ * complex.c (nucomp_negate): new.
+
+Sun Sep 14 04:15:16 2008 Tanaka Akira <akr@fsij.org>
+
+ * include/ruby/oniguruma.h (OnigEncodingTypeST): add end argument for
+ left_adjust_char_head.
+ (ONIGENC_LEFT_ADJUST_CHAR_HEAD): add end argument.
+ (onigenc_get_left_adjust_char_head): ditto.
+
+ * include/ruby/encoding.h (rb_enc_left_char_head): add end argument.
+
+ * regenc.h (onigenc_single_byte_left_adjust_char_head): ditto.
+
+ * regenc.c (onigenc_get_right_adjust_char_head): follow the interface
+ change.
+ (onigenc_get_right_adjust_char_head_with_prev): ditto.
+ (onigenc_get_prev_char_head): ditto.
+ (onigenc_step_back): ditto.
+ (onigenc_get_left_adjust_char_head): ditto.
+ (onigenc_single_byte_code_to_mbc): ditto.
+
+ * re.c: ditto.
+
+ * string.c: ditto.
+
+ * io.c: ditto.
+
+ * regexec.c: ditto.
+
+ * enc/euc_jp.c: ditto.
+
+ * enc/cp949.c: ditto.
+
+ * enc/shift_jis.c: ditto.
+
+ * enc/gbk.c: ditto.
+
+ * enc/big5.c: ditto.
+
+ * enc/euc_tw.c: ditto.
+
+ * enc/euc_kr.c: ditto.
+
+ * enc/emacs_mule.c: ditto.
+
+ * enc/gb18030.c: ditto.
+
+ * enc/utf_8.c: ditto.
+
+ * enc/utf_16le.c: ditto.
+
+ * enc/utf_16be.c: ditto.
+
+ * enc/utf_32le.c: ditto.
+
+ * enc/utf_32be.c: ditto.
+
+Sun Sep 14 03:43:27 2008 Tanaka Akira <akr@fsij.org>
+
+ * include/ruby/oniguruma.h (ONIGENC_STEP_BACK): add end argument.
+ (onigenc_step_back): ditto.
+
+ * regenc.c (onigenc_step_back): add end argument.
+
+ * regexec.c: follow the interface change.
+
+Sun Sep 14 03:20:03 2008 Tanaka Akira <akr@fsij.org>
+
+ * include/ruby/oniguruma.h (onigenc_get_prev_char_head): add end
+ argument.
+
+ * include/ruby/encoding.h (rb_enc_prev_char): ditto.
+
+ * regenc.c (onigenc_get_prev_char_head): add end argument.
+
+ * regparse.c: follow the interface change.
+
+ * regexec.c: ditto.
+
+ * string.c: ditto.
+
+ * parse.y: ditto.
+
+Sun Sep 14 02:04:28 2008 Tanaka Akira <akr@fsij.org>
+
+ * include/ruby/oniguruma.h
+ (onigenc_get_right_adjust_char_head_with_prev): add end argument.
+
+ * regenc.c (onigenc_get_right_adjust_char_head_with_prev): use end
+ argument.
+
+ * regexec.c (forward_search_range): follow the interface change.
+
+Sun Sep 14 01:38:26 2008 Tanaka Akira <akr@fsij.org>
+
+ * include/ruby/oniguruma.h (onigenc_get_right_adjust_char_head): add
+ end argument.
+
+ * include/ruby/encoding.h (rb_enc_right_char_head): add end argument.
+
+ * regenc.c (onigenc_get_right_adjust_char_head): use end argument.
+
+ * re.c (rb_reg_adjust_startpos): follow the interface change.
+
+ * string.c (rb_str_index): ditto.
+
+ * regexec.c (backward_search_range): ditto.
+ (onig_search): ditto.
+
Sun Sep 14 00:43:28 2008 Tanaka Akira <akr@fsij.org>
* ext/ripper/depend (ripper.o): it depends on ruby headers.
@@ -962,7 +1746,8 @@ Thu Sep 4 19:10:27 2008 Tanaka Akira <akr@fsij.org>
* include/ruby/encoding.h (ECONV_INVALID_IGNORE): removed because
it tend to cause security problem. If the behaviour is really
required, ECONV_INVALID_REPLACE with empty string can be used.
- For example, CVE-2006-2313, CVE-2008-1036, [ruby-core:15645]
+ For example, CVE-2006-2313, CVE-2008-1036, [ruby-core:15645],
+ http://unicode.org/reports/tr36/
(ECONV_UNDEF_IGNORE): ditto.
* transcode.c (rb_econv_convert): follow the above change.
View
10 bignum.c
@@ -774,7 +774,7 @@ power_cache_get_power0(int base, int i)
big2str_power_cache[base - 2][i] =
i == 0 ? rb_big_pow(rb_int2big(base), INT2FIX(KARATSUBA_DIGITS))
: bigsqr(power_cache_get_power0(base, i - 1));
- rb_global_variable(&big2str_power_cache[base - 2][i]);
+ rb_gc_register_mark_object(big2str_power_cache[base - 2][i]);
}
return big2str_power_cache[base - 2][i];
}
@@ -909,8 +909,10 @@ big2str_karatsuba(VALUE x, int base, char* ptr,
bigdivmod(x, b, &q, &r);
lh = big2str_karatsuba(q, base, ptr, (len - m1)/2,
len - m1, hbase, trim);
+ rb_big_resize(q, 0);
ll = big2str_karatsuba(r, base, ptr + lh, m1/2,
m1, hbase, !lh && trim);
+ rb_big_resize(r, 0);
return lh + ll;
}
@@ -953,6 +955,7 @@ rb_big2str0(VALUE x, int base, int trim)
len = off + big2str_karatsuba(xx, base, ptr + off, n1,
n2, hbase, trim);
}
+ rb_big_resize(xx, 0);
ptr[len] = '\0';
rb_str_resize(ss, len);
@@ -2099,9 +2102,6 @@ rb_big_pow(VALUE x, VALUE y)
break;
case T_BIGNUM:
- if (rb_funcall(y, '<', 1, INT2FIX(0)))
- return rb_funcall(rb_rational_raw1(x), rb_intern("**"), 1, y);
-
rb_warn("in a**b, b may be too big");
d = rb_big2dbl(y);
break;
@@ -2110,7 +2110,7 @@ rb_big_pow(VALUE x, VALUE y)
yy = FIX2LONG(y);
if (yy < 0)
- return rb_funcall(rb_rational_raw1(x), rb_intern("**"), 1, y);
+ return rb_funcall(rb_rational_raw1(x), rb_intern("**"), 1, y);
else {
VALUE z = 0;
SIGNED_VALUE mask;
View
4 common.mk
@@ -9,7 +9,7 @@ RUBYOPT = -
SPEC_GIT_BASE = git://github.com/rubyspec
MSPEC_GIT_URL = $(SPEC_GIT_BASE)/mspec.git
-RUBYSPEC_GIT_URL = git://github.com/yugui/rubyspec.git
+RUBYSPEC_GIT_URL = $(SPEC_GIT_BASE)/rubyspec.git
STATIC_RUBY = static-ruby
@@ -49,7 +49,6 @@ COMMONOBJS = array.$(OBJEXT) \
pack.$(OBJEXT) \
parse.$(OBJEXT) \
process.$(OBJEXT) \
- prec.$(OBJEXT) \
random.$(OBJEXT) \
range.$(OBJEXT) \
rational.$(OBJEXT) \
@@ -520,7 +519,6 @@ parse.$(OBJEXT): {$(VPATH)}parse.c {$(VPATH)}parse.y $(RUBY_H_INCLUDES) \
{$(VPATH)}oniguruma.h $(ID_H_INCLUDES) {$(VPATH)}regenc.h \
{$(VPATH)}regex.h {$(VPATH)}util.h {$(VPATH)}lex.c {$(VPATH)}keywords \
{$(VPATH)}debug.h {$(VPATH)}id.c
-prec.$(OBJEXT): {$(VPATH)}prec.c $(RUBY_H_INCLUDES) {$(VPATH)}st.h
proc.$(OBJEXT): {$(VPATH)}proc.c {$(VPATH)}eval_intern.h \
$(RUBY_H_INCLUDES) {$(VPATH)}st.h {$(VPATH)}node.h {$(VPATH)}util.h \
{$(VPATH)}vm_core.h {$(VPATH)}debug.h \
View
374 complex.c
@@ -21,11 +21,10 @@
VALUE rb_cComplex;
-static ID id_Unify, id_abs, id_abs2, id_arg, id_cmp, id_conjugate,
- id_convert, id_denominator, id_divmod, id_equal_p, id_exact_p, id_expt,
- id_floor, id_format, id_idiv, id_inspect, id_negate, id_new, id_new_bang,
- id_numerator, id_polar, id_quo, id_scalar_p, id_to_f, id_to_i, id_to_r,
- id_to_s, id_truncate;
+static ID id_Unify, id_abs, id_abs2, id_arg, id_cmp, id_conj, id_convert,
+ id_denominator, id_divmod, id_equal_p, id_expt, id_floor, id_hash,
+ id_idiv, id_inspect, id_negate, id_numerator, id_polar, id_quo,
+ id_real_p, id_to_f, id_to_i, id_to_r, id_to_s;
#define f_boolcast(x) ((x) ? Qtrue : Qfalse)
@@ -64,13 +63,17 @@ m_##n(VALUE x, VALUE y)\
return rb_funcall(rb_mMath, id_##n, 2, x, y);\
}
+#define PRESERVE_SIGNEDZERO
+
inline static VALUE
f_add(VALUE x, VALUE y)
{
+#ifndef PRESERVE_SIGNEDZERO
if (FIXNUM_P(y) && FIX2LONG(y) == 0)
return x;
else if (FIXNUM_P(x) && FIX2LONG(x) == 0)
return y;
+#endif
return rb_funcall(x, '+', 1, y);
}
@@ -117,6 +120,7 @@ binop(mod, '%')
inline static VALUE
f_mul(VALUE x, VALUE y)
{
+#ifndef PRESERVE_SIGNEDZERO
if (FIXNUM_P(y)) {
long iy = FIX2LONG(y);
if (iy == 0) {
@@ -135,14 +139,17 @@ f_mul(VALUE x, VALUE y)
else if (ix == 1)
return y;
}
+#endif
return rb_funcall(x, '*', 1, y);
}
inline static VALUE
f_sub(VALUE x, VALUE y)
{
+#ifndef PRESERVE_SIGNEDZERO
if (FIXNUM_P(y) && FIX2LONG(y) == 0)
return x;
+#endif
return rb_funcall(x, '-', 1, y);
}
@@ -151,23 +158,20 @@ binop(xor, '^')
fun1(abs)
fun1(abs2)
fun1(arg)
-fun1(conjugate)
+fun1(conj)
fun1(denominator)
-fun1(exact_p)
fun1(floor)
+fun1(hash)
fun1(inspect)
fun1(negate)
fun1(numerator)
fun1(polar)
-fun1(scalar_p)
-
-#define f_real_p f_scalar_p
+fun1(real_p)
fun1(to_f)
fun1(to_i)
fun1(to_r)
fun1(to_s)
-fun1(truncate)
fun2(divmod)
@@ -191,6 +195,8 @@ f_negative_p(VALUE x)
return rb_funcall(x, '<', 1, ZERO);
}
+#define f_positive_p(x) (!f_negative_p(x))
+
inline static VALUE
f_zero_p(VALUE x)
{
@@ -199,6 +205,8 @@ f_zero_p(VALUE x)
return rb_funcall(x, id_equal_p, 1, ZERO);
}
+#define f_nonzero_p(x) (!f_zero_p(x))
+
inline static VALUE
f_one_p(VALUE x)
{
@@ -243,6 +251,9 @@ k_complex_p(VALUE x)
return f_kind_of_p(x, rb_cComplex);
}
+#define k_exact_p(x) (!k_float_p(x))
+#define k_inexact_p(x) k_float_p(x)
+
#define get_dat1(x) \
struct RComplex *dat;\
dat = ((struct RComplex *)(x))
@@ -253,13 +264,13 @@ k_complex_p(VALUE x)
bdat = ((struct RComplex *)(y))
inline static VALUE
-nucomp_s_new_internal(VALUE klass, VALUE real, VALUE image)
+nucomp_s_new_internal(VALUE klass, VALUE real, VALUE imag)
{
NEWOBJ(obj, struct RComplex);
OBJSETUP(obj, klass, T_COMPLEX);
obj->real = real;
- obj->image = image;
+ obj->imag = imag;
return (VALUE)obj;
}
@@ -273,23 +284,23 @@ nucomp_s_alloc(VALUE klass)
static VALUE
nucomp_s_new_bang(int argc, VALUE *argv, VALUE klass)
{
- VALUE real, image;
+ VALUE real, imag;
- switch (rb_scan_args(argc, argv, "11", &real, &image)) {
+ switch (rb_scan_args(argc, argv, "11", &real, &imag)) {
case 1:
if (!k_numeric_p(real))
real = f_to_i(real);
- image = ZERO;
+ imag = ZERO;
break;
default:
if (!k_numeric_p(real))
real = f_to_i(real);
- if (!k_numeric_p(image))
- image = f_to_i(image);
+ if (!k_numeric_p(imag))
+ imag = f_to_i(imag);
break;
}
- return nucomp_s_new_internal(klass, real, image);
+ return nucomp_s_new_internal(klass, real, imag);
}
inline static VALUE
@@ -325,39 +336,38 @@ nucomp_real_check(VALUE num)
}
inline static VALUE
-nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE image)
+nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE imag)
{
#define CL_CANON
#ifdef CL_CANON
- if (f_zero_p(image) && f_unify_p(klass) &&
- !k_float_p(real) && !k_float_p(image))
+ if (f_zero_p(imag) && k_exact_p(imag) && f_unify_p(klass))
return real;
#else
- if (f_zero_p(image) && f_unify_p(klass))
+ if (f_zero_p(imag) && f_unify_p(klass))
return real;
#endif
- else if (f_real_p(real) && f_real_p(image))
- return nucomp_s_new_internal(klass, real, image);
+ else if (f_real_p(real) && f_real_p(imag))
+ return nucomp_s_new_internal(klass, real, imag);
else if (f_real_p(real)) {
- get_dat1(image);
+ get_dat1(imag);
return nucomp_s_new_internal(klass,
- f_sub(real, dat->image),
+ f_sub(real, dat->imag),
f_add(ZERO, dat->real));
}
- else if (f_real_p(image)) {
+ else if (f_real_p(imag)) {
get_dat1(real);
return nucomp_s_new_internal(klass,
dat->real,
- f_add(dat->image, image));
+ f_add(dat->imag, imag));
}
else {
- get_dat2(real, image);
+ get_dat2(real, imag);
return nucomp_s_new_internal(klass,
- f_sub(adat->real, bdat->image),
- f_add(adat->image, bdat->real));
+ f_sub(adat->real, bdat->imag),
+ f_add(adat->imag, bdat->real));
}
}
@@ -365,36 +375,40 @@ nucomp_s_canonicalize_internal(VALUE klass, VALUE real, VALUE image)
static VALUE
nucomp_s_canonicalize(int argc, VALUE *argv, VALUE klass)
{
- VALUE real, image;
+ VALUE real, imag;
- switch (rb_scan_args(argc, argv, "11", &real, &image)) {
+ switch (rb_scan_args(argc, argv, "11", &real, &imag)) {
case 1:
- image = ZERO;
+ nucomp_real_check(real);
+ imag = ZERO;
+ break;
+ default:
+ nucomp_real_check(real);
+ nucomp_real_check(imag);
break;
}
- nucomp_real_check(real);
- nucomp_real_check(image);
-
- return nucomp_s_canonicalize_internal(klass, real, image);
+ return nucomp_s_canonicalize_internal(klass, real, imag);
}
#endif
static VALUE
nucomp_s_new(int argc, VALUE *argv, VALUE klass)
{
- VALUE real, image;
+ VALUE real, imag;
- switch (rb_scan_args(argc, argv, "11", &real, &image)) {
+ switch (rb_scan_args(argc, argv, "11", &real, &imag)) {
case 1:
- image = ZERO;
+ nucomp_real_check(real);
+ imag = ZERO;
+ break;
+ default:
+ nucomp_real_check(real);
+ nucomp_real_check(imag);
break;
}
- nucomp_real_check(real);
- nucomp_real_check(image);
-
- return nucomp_s_canonicalize_internal(klass, real, image);
+ return nucomp_s_canonicalize_internal(klass, real, imag);
}
inline static VALUE
@@ -446,44 +460,46 @@ m_log_bang(VALUE x)
static VALUE
m_cos(VALUE x)
{
- get_dat1(x);
-
if (f_real_p(x))
return m_cos_bang(x);
- return f_complex_new2(rb_cComplex,
- f_mul(m_cos_bang(dat->real),
- m_cosh_bang(dat->image)),
- f_mul(f_negate(m_sin_bang(dat->real)),
- m_sinh_bang(dat->image)));
+ {
+ get_dat1(x);
+ return f_complex_new2(rb_cComplex,
+ f_mul(m_cos_bang(dat->real),
+ m_cosh_bang(dat->imag)),
+ f_mul(f_negate(m_sin_bang(dat->real)),
+ m_sinh_bang(dat->imag)));
+ }
}
static VALUE
m_sin(VALUE x)
{
- get_dat1(x);
-
if (f_real_p(x))
return m_sin_bang(x);
- return f_complex_new2(rb_cComplex,
- f_mul(m_sin_bang(dat->real),
- m_cosh_bang(dat->image)),
- f_mul(m_cos_bang(dat->real),
- m_sinh_bang(dat->image)));
+ {
+ get_dat1(x);
+ return f_complex_new2(rb_cComplex,
+ f_mul(m_sin_bang(dat->real),
+ m_cosh_bang(dat->imag)),
+ f_mul(m_cos_bang(dat->real),
+ m_sinh_bang(dat->imag)));
+ }
}
static VALUE
m_sqrt(VALUE x)
{
if (f_real_p(x)) {
- if (!f_negative_p(x))
+ if (f_positive_p(x))
return m_sqrt_bang(x);
return f_complex_new2(rb_cComplex, ZERO, m_sqrt_bang(f_negate(x)));
}
else {
get_dat1(x);
- if (f_negative_p(dat->image))
- return f_conjugate(m_sqrt(f_conjugate(x)));
+ if (f_negative_p(dat->imag))
+ return f_conj(m_sqrt(f_conj(x)));
else {
VALUE a = f_abs(x);
return f_complex_new2(rb_cComplex,
@@ -517,30 +533,38 @@ nucomp_real(VALUE self)
}
static VALUE
-nucomp_image(VALUE self)
+nucomp_imag(VALUE self)
{
get_dat1(self);
- return dat->image;
+ return dat->imag;
+}
+
+static VALUE
+nucomp_negate(VALUE self)
+{
+ get_dat1(self);
+ return f_complex_new2(CLASS_OF(self),
+ f_negate(dat->real), f_negate(dat->imag));
}
static VALUE
nucomp_add(VALUE self, VALUE other)
{
if (k_complex_p(other)) {
- VALUE real, image;
+ VALUE real, imag;
get_dat2(self, other);
real = f_add(adat->real, bdat->real);
- image = f_add(adat->image, bdat->image);
+ imag = f_add(adat->imag, bdat->imag);
- return f_complex_new2(CLASS_OF(self), real, image);
+ return f_complex_new2(CLASS_OF(self), real, imag);
}
if (k_numeric_p(other) && f_real_p(other)) {
get_dat1(self);
return f_complex_new2(CLASS_OF(self),
- f_add(dat->real, other), dat->image);
+ f_add(dat->real, other), dat->imag);
}
return rb_num_coerce_bin(self, other, '+');
}
@@ -549,20 +573,20 @@ static VALUE
nucomp_sub(VALUE self, VALUE other)
{
if (k_complex_p(other)) {
- VALUE real, image;
+ VALUE real, imag;
get_dat2(self, other);
real = f_sub(adat->real, bdat->real);
- image = f_sub(adat->image, bdat->image);
+ imag = f_sub(adat->imag, bdat->imag);
- return f_complex_new2(CLASS_OF(self), real, image);
+ return f_complex_new2(CLASS_OF(self), real, imag);
}
if (k_numeric_p(other) && f_real_p(other)) {
get_dat1(self);
return f_complex_new2(CLASS_OF(self),
- f_sub(dat->real, other), dat->image);
+ f_sub(dat->real, other), dat->imag);
}
return rb_num_coerce_bin(self, other, '-');
}
@@ -571,23 +595,23 @@ static VALUE
nucomp_mul(VALUE self, VALUE other)
{
if (k_complex_p(other)) {
- VALUE real, image;
+ VALUE real, imag;
get_dat2(self, other);
real = f_sub(f_mul(adat->real, bdat->real),
- f_mul(adat->image, bdat->image));
- image = f_add(f_mul(adat->real, bdat->image),
- f_mul(adat->image, bdat->real));
+ f_mul(adat->imag, bdat->imag));
+ imag = f_add(f_mul(adat->real, bdat->imag),
+ f_mul(adat->imag, bdat->real));
- return f_complex_new2(CLASS_OF(self), real, image);
+ return f_complex_new2(CLASS_OF(self), real, imag);
}
if (k_numeric_p(other) && f_real_p(other)) {
get_dat1(self);
return f_complex_new2(CLASS_OF(self),
f_mul(dat->real, other),
- f_mul(dat->image, other));
+ f_mul(dat->imag, other));
}
return rb_num_coerce_bin(self, other, '*');
}
@@ -601,23 +625,23 @@ nucomp_div(VALUE self, VALUE other)
get_dat2(self, other);
if (TYPE(adat->real) == T_FLOAT ||
- TYPE(adat->image) == T_FLOAT ||
+ TYPE(adat->imag) == T_FLOAT ||
TYPE(bdat->real) == T_FLOAT ||
- TYPE(bdat->image) == T_FLOAT) {
- VALUE magn = m_hypot(bdat->real, bdat->image);
+ TYPE(bdat->imag) == T_FLOAT) {
+ VALUE magn = m_hypot(bdat->real, bdat->imag);
VALUE tmp = f_complex_new_bang2(CLASS_OF(self),
f_div(bdat->real, magn),
- f_div(bdat->image, magn));
- return f_div(f_mul(self, f_conjugate(tmp)), magn);
+ f_div(bdat->imag, magn));
+ return f_div(f_mul(self, f_conj(tmp)), magn);
}
- return f_div(f_mul(self, f_conjugate(other)), f_abs2(other));
+ return f_div(f_mul(self, f_conj(other)), f_abs2(other));
}
if (k_numeric_p(other) && f_real_p(other)) {
get_dat1(self);
return f_complex_new2(CLASS_OF(self),
f_div(dat->real, other),
- f_div(dat->image, other));
+ f_div(dat->imag, other));
}
return rb_num_coerce_bin(self, other, '/');
}
@@ -632,13 +656,13 @@ nucomp_fdiv(VALUE self, VALUE other)
return f_div(f_complex_new2(CLASS_OF(self),
f_to_f(dat->real),
- f_to_f(dat->image)), other);
+ f_to_f(dat->imag)), other);
}
static VALUE
nucomp_expt(VALUE self, VALUE other)
{
- if (f_zero_p(other))
+ if (k_exact_p(other) && f_zero_p(other))
return f_complex_new_bang1(CLASS_OF(self), ONE);
if (k_rational_p(other) && f_one_p(f_denominator(other)))
@@ -654,7 +678,7 @@ nucomp_expt(VALUE self, VALUE other)
theta = RARRAY_PTR(a)[1];
ore = dat->real;
- oim = dat->image;
+ oim = dat->imag;
nr = m_exp_bang(f_sub(f_mul(ore, m_log_bang(r)),
f_mul(oim, theta)));
ntheta = f_add(f_mul(theta, ore), f_mul(oim, m_log_bang(r)));
@@ -668,7 +692,7 @@ nucomp_expt(VALUE self, VALUE other)
z = x;
n = f_sub(other, ONE);
- while (!f_zero_p(n)) {
+ while (f_nonzero_p(n)) {
VALUE a;
while (a = f_divmod(n, TWO),
@@ -677,8 +701,8 @@ nucomp_expt(VALUE self, VALUE other)
x = f_complex_new2(CLASS_OF(self),
f_sub(f_mul(dat->real, dat->real),
- f_mul(dat->image, dat->image)),
- f_mul(f_mul(TWO, dat->real), dat->image));
+ f_mul(dat->imag, dat->imag)),
+ f_mul(f_mul(TWO, dat->real), dat->imag));
n = RARRAY_PTR(a)[0];
}
z = f_mul(z, x);
@@ -707,12 +731,12 @@ nucomp_equal_p(VALUE self, VALUE other)
get_dat2(self, other);
return f_boolcast(f_equal_p(adat->real, bdat->real) &&
- f_equal_p(adat->image, bdat->image));
+ f_equal_p(adat->imag, bdat->imag));
}
if (k_numeric_p(other) && f_real_p(other)) {
get_dat1(self);
- return f_boolcast(f_equal_p(dat->real, other) && f_zero_p(dat->image));
+ return f_boolcast(f_equal_p(dat->real, other) && f_zero_p(dat->imag));
}
return f_equal_p(other, self);
}
@@ -732,7 +756,7 @@ static VALUE
nucomp_abs(VALUE self)
{
get_dat1(self);
- return m_hypot(dat->real, dat->image);
+ return m_hypot(dat->real, dat->imag);
}
static VALUE
@@ -740,21 +764,21 @@ nucomp_abs2(VALUE self)
{
get_dat1(self);
return f_add(f_mul(dat->real, dat->real),
- f_mul(dat->image, dat->image));
+ f_mul(dat->imag, dat->imag));
}
static VALUE
nucomp_arg(VALUE self)
{
get_dat1(self);
- return m_atan2_bang(dat->image, dat->real);
+ return m_atan2_bang(dat->imag, dat->real);
}
static VALUE
nucomp_rect(VALUE self)
{
get_dat1(self);
- return rb_assoc_new(dat->real, dat->image);
+ return rb_assoc_new(dat->real, dat->imag);
}
static VALUE
@@ -764,10 +788,10 @@ nucomp_polar(VALUE self)
}
static VALUE
-nucomp_conjugate(VALUE self)
+nucomp_conj(VALUE self)
{
get_dat1(self);
- return f_complex_new2(CLASS_OF(self), dat->real, f_negate(dat->image));
+ return f_complex_new2(CLASS_OF(self), dat->real, f_negate(dat->imag));
}
#if 0
@@ -789,7 +813,7 @@ static VALUE
nucomp_exact_p(VALUE self)
{
get_dat1(self);
- return f_boolcast(f_exact_p(dat->real) && f_exact_p(dat->image));
+ return f_boolcast(f_exact_p(dat->real) && f_exact_p(dat->imag));
}
static VALUE
@@ -805,7 +829,7 @@ static VALUE
nucomp_denominator(VALUE self)
{
get_dat1(self);
- return rb_lcm(f_denominator(dat->real), f_denominator(dat->image));
+ return rb_lcm(f_denominator(dat->real), f_denominator(dat->imag));
}
static VALUE
@@ -819,15 +843,29 @@ nucomp_numerator(VALUE self)
return f_complex_new2(CLASS_OF(self),
f_mul(f_numerator(dat->real),
f_div(cd, f_denominator(dat->real))),
- f_mul(f_numerator(dat->image),
- f_div(cd, f_denominator(dat->image))));
+ f_mul(f_numerator(dat->imag),
+ f_div(cd, f_denominator(dat->imag))));
}
static VALUE
nucomp_hash(VALUE self)
{
get_dat1(self);
- return f_xor(dat->real, dat->image);
+ return f_xor(f_hash(dat->real), f_hash(dat->imag));
+}
+
+static VALUE
+nucomp_eql_p(VALUE self, VALUE other)
+{
+ if (k_complex_p(other)) {
+ get_dat2(self, other);
+
+ return f_boolcast((CLASS_OF(adat->real) == CLASS_OF(bdat->real)) &&
+ (CLASS_OF(adat->imag) == CLASS_OF(bdat->imag)) &&
+ f_equal_p(self, other));
+
+ }
+ return Qfalse;
}
#ifndef HAVE_SIGNBIT
@@ -869,12 +907,12 @@ nucomp_to_s(VALUE self)
get_dat1(self);
- impos = f_tpositive_p(dat->image);
+ impos = f_tpositive_p(dat->imag);
s = f_to_s(dat->real);
rb_str_cat2(s, !impos ? "-" : "+");
- rb_str_concat(s, f_to_s(f_abs(dat->image)));
+ rb_str_concat(s, f_to_s(f_abs(dat->imag)));
rb_str_cat2(s, "i");
return s;
@@ -887,13 +925,13 @@ nucomp_inspect(VALUE self)
get_dat1(self);
- impos = f_tpositive_p(dat->image);
+ impos = f_tpositive_p(dat->imag);
s = rb_str_new2("(");
rb_str_concat(s, f_inspect(dat->real));
rb_str_cat2(s, !impos ? "-" : "+");
- rb_str_concat(s, f_inspect(f_abs(dat->image)));
+ rb_str_concat(s, f_inspect(f_abs(dat->imag)));
rb_str_cat2(s, "i)");
return s;
@@ -902,8 +940,12 @@ nucomp_inspect(VALUE self)
static VALUE
nucomp_marshal_dump(VALUE self)
{
+ VALUE a;
get_dat1(self);
- return rb_assoc_new(dat->real, dat->image);
+
+ a = rb_assoc_new(dat->real, dat->imag);
+ rb_copy_generic_ivar(a, self);
+ return a;
}
static VALUE
@@ -911,7 +953,8 @@ nucomp_marshal_load(VALUE self, VALUE a)
{
get_dat1(self);
dat->real = RARRAY_PTR(a)[0];
- dat->image = RARRAY_PTR(a)[1];
+ dat->imag = RARRAY_PTR(a)[1];
+ rb_copy_generic_ivar(self, a);
return self;
}
@@ -951,7 +994,7 @@ nucomp_to_i(VALUE self)
{
get_dat1(self);
- if (k_float_p(dat->image) || !f_zero_p(dat->image)) {
+ if (k_inexact_p(dat->imag) || f_nonzero_p(dat->imag)) {
VALUE s = f_to_s(self);
rb_raise(rb_eRangeError, "can't convert %s into Integer",
StringValuePtr(s));
@@ -964,7 +1007,7 @@ nucomp_to_f(VALUE self)
{
get_dat1(self);
- if (k_float_p(dat->image) || !f_zero_p(dat->image)) {
+ if (k_inexact_p(dat->imag) || f_nonzero_p(dat->imag)) {
VALUE s = f_to_s(self);
rb_raise(rb_eRangeError, "can't convert %s into Float",
StringValuePtr(s));
@@ -977,7 +1020,7 @@ nucomp_to_r(VALUE self)
{
get_dat1(self);
- if (k_float_p(dat->image) || !f_zero_p(dat->image)) {
+ if (k_inexact_p(dat->imag) || f_nonzero_p(dat->imag)) {
VALUE s = f_to_s(self);
rb_raise(rb_eRangeError, "can't convert %s into Rational",
StringValuePtr(s));
@@ -1021,29 +1064,29 @@ make_patterns(void)
if (comp_pat0) return;
comp_pat0 = rb_reg_new(comp_pat0_source, sizeof comp_pat0_source - 1, 0);
- rb_global_variable(&comp_pat0);
+ rb_gc_register_mark_object(comp_pat0);
comp_pat1 = rb_reg_new(comp_pat1_source, sizeof comp_pat1_source - 1, 0);
- rb_global_variable(&comp_pat1);
+ rb_gc_register_mark_object(comp_pat1);
comp_pat2 = rb_reg_new(comp_pat2_source, sizeof comp_pat2_source - 1, 0);
- rb_global_variable(&comp_pat2);
+ rb_gc_register_mark_object(comp_pat2);
a_slash = rb_str_new2("/");
- rb_global_variable(&a_slash);
+ rb_gc_register_mark_object(a_slash);
a_dot_and_an_e = rb_str_new2(".eE");
- rb_global_variable(&a_dot_and_an_e);
+ rb_gc_register_mark_object(a_dot_and_an_e);
null_string = rb_str_new2("");
- rb_global_variable(&null_string);
+ rb_gc_register_mark_object(null_string);
underscores_pat = rb_reg_new(underscores_pat_source,
sizeof underscores_pat_source - 1, 0);
- rb_global_variable(&underscores_pat);
+ rb_gc_register_mark_object(underscores_pat);
an_underscore = rb_str_new2("_");
- rb_global_variable(&an_underscore);
+ rb_gc_register_mark_object(an_underscore);
}
#define id_match rb_intern("match")
@@ -1109,9 +1152,8 @@ string_to_c_internal(VALUE self)
}
if (NIL_P(m)) {
m = f_match(comp_pat2, s);
- if (NIL_P(m)) {
+ if (NIL_P(m))
return rb_assoc_new(Qnil, self);
- }
sr = f_aref(m, INT2FIX(1));
if (NIL_P(f_aref(m, INT2FIX(2))))
si = Qnil;
@@ -1149,7 +1191,6 @@ string_to_c_internal(VALUE self)
return rb_assoc_new(rb_complex_polar(r, i), re);
else
return rb_assoc_new(rb_complex_new2(r, i), re);
-
}
}
@@ -1191,7 +1232,7 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
{
VALUE a1, a2, backref;
- rb_scan_args(argc, argv, "02", &a1, &a2);
+ rb_scan_args(argc, argv, "11", &a1, &a2);
backref = rb_backref_get();
rb_match_busy(backref);
@@ -1223,7 +1264,7 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
{
get_dat1(a1);
- if (!k_float_p(dat->image) && f_zero_p(dat->image))
+ if (k_exact_p(dat->imag) && f_zero_p(dat->imag))
a1 = dat->real;
}
}
@@ -1233,17 +1274,29 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
{
get_dat1(a2);
- if (!k_float_p(dat->image) && f_zero_p(dat->image))
+ if (k_exact_p(dat->imag) && f_zero_p(dat->imag))
a2 = dat->real;
}
}
switch (TYPE(a1)) {
case T_COMPLEX:
- if (NIL_P(a2) || f_zero_p(a2))
+ if (argc == 1 || (k_exact_p(a2) && f_zero_p(a2)))
return a1;
}
+ if (argc == 1) {
+ if (k_numeric_p(a1) && !f_real_p(a1))
+ return a1;
+ }
+ else {
+ if ((k_numeric_p(a1) && k_numeric_p(a2)) &&
+ (!f_real_p(a1) || !f_real_p(a2)))
+ return f_add(a1,
+ f_mul(a2,
+ f_complex_new_bang2(rb_cComplex, ZERO, ONE)));
+ }
+
{
VALUE argv2[2];
argv2[0] = a1;
@@ -1254,20 +1307,6 @@ nucomp_s_convert(int argc, VALUE *argv, VALUE klass)
/* --- */
-#define id_Complex rb_intern("Complex")
-
-static VALUE
-numeric_re(VALUE self)
-{
- return rb_Complex1(self);
-}
-
-static VALUE
-numeric_im(VALUE self)
-{
- return rb_Complex2(ZERO, self);
-}
-
static VALUE
numeric_real(VALUE self)
{
@@ -1275,7 +1314,7 @@ numeric_real(VALUE self)
}
static VALUE
-numeric_image(VALUE self)
+numeric_imag(VALUE self)
{
return INT2FIX(0);
}
@@ -1291,7 +1330,7 @@ numeric_abs2(VALUE self)
static VALUE
numeric_arg(VALUE self)
{
- if (!f_negative_p(self))
+ if (f_positive_p(self))
return INT2FIX(0);
return rb_const_get(rb_mMath, id_PI);
}
@@ -1299,7 +1338,7 @@ numeric_arg(VALUE self)
static VALUE
numeric_rect(VALUE self)
{
- return rb_assoc_new(self, ZERO);
+ return rb_assoc_new(self, INT2FIX(0));
}
static VALUE
@@ -1309,7 +1348,7 @@ numeric_polar(VALUE self)
}
static VALUE
-numeric_conjugate(VALUE self)
+numeric_conj(VALUE self)
{
return self;
}
@@ -1327,29 +1366,25 @@ Init_Complex(void)
id_abs2 = rb_intern("abs2");
id_arg = rb_intern("arg");
id_cmp = rb_intern("<=>");
- id_conjugate = rb_intern("conjugate");
+ id_conj = rb_intern("conj");
id_convert = rb_intern("convert");
id_denominator = rb_intern("denominator");
id_divmod = rb_intern("divmod");
id_equal_p = rb_intern("==");
- id_exact_p = rb_intern("exact?");
id_expt = rb_intern("**");
id_floor = rb_intern("floor");
- id_format = rb_intern("format");
+ id_hash = rb_intern("hash");
id_idiv = rb_intern("div");
id_inspect = rb_intern("inspect");
id_negate = rb_intern("-@");
- id_new = rb_intern("new");
- id_new_bang = rb_intern("new!");
id_numerator = rb_intern("numerator");
id_polar = rb_intern("polar");
id_quo = rb_intern("quo");
- id_scalar_p = rb_intern("scalar?");
+ id_real_p = rb_intern("real?");
id_to_f = rb_intern("to_f");
id_to_i = rb_intern("to_i");
id_to_r = rb_intern("to_r");
id_to_s = rb_intern("to_s");
- id_truncate = rb_intern("truncate");
rb_cComplex = rb_define_class(COMPLEX_NAME, rb_cNumeric);
@@ -1390,9 +1425,10 @@ Init_Complex(void)
#endif
rb_define_method(rb_cComplex, "real", nucomp_real, 0);
- rb_define_method(rb_cComplex, "image", nucomp_image, 0);
- rb_define_method(rb_cComplex, "imag", nucomp_image, 0);
+ rb_define_method(rb_cComplex, "imaginary", nucomp_imag, 0);
+ rb_define_method(rb_cComplex, "imag", nucomp_imag, 0);
+ rb_define_method(rb_cComplex, "-@", nucomp_negate, 0);
rb_define_method(rb_cComplex, "+", nucomp_add, 1);
rb_define_method(rb_cComplex, "-", nucomp_sub, 1);
rb_define_method(rb_cComplex, "*", nucomp_mul, 1);
@@ -1413,24 +1449,24 @@ Init_Complex(void)
rb_define_method(rb_cComplex, "rectangular", nucomp_rect, 0);
rb_define_method(rb_cComplex, "rect", nucomp_rect, 0);
rb_define_method(rb_cComplex, "polar", nucomp_polar, 0);
- rb_define_method(rb_cComplex, "conjugate", nucomp_conjugate, 0);
- rb_define_method(rb_cComplex, "conj", nucomp_conjugate, 0);
+ rb_define_method(rb_cComplex, "conjugate", nucomp_conj, 0);
+ rb_define_method(rb_cComplex, "conj", nucomp_conj, 0);
#if 0
- rb_define_method(rb_cComplex, "~", nucomp_conjugate, 0); /* gcc */
+ rb_define_method(rb_cComplex, "~", nucomp_conj, 0); /* gcc */
#endif
-#if 0
rb_define_method(rb_cComplex, "real?", nucomp_false, 0);
+#if 0
rb_define_method(rb_cComplex, "complex?", nucomp_true, 0);
rb_define_method(rb_cComplex, "exact?", nucomp_exact_p, 0);
rb_define_method(rb_cComplex, "inexact?", nucomp_inexact_p, 0);
#endif
- rb_define_method(rb_cComplex, "scalar?", nucomp_false, 0);
rb_define_method(rb_cComplex, "numerator", nucomp_numerator, 0);
rb_define_method(rb_cComplex, "denominator", nucomp_denominator, 0);
rb_define_method(rb_cComplex, "hash", nucomp_hash, 0);
+ rb_define_method(rb_cComplex, "eql?", nucomp_eql_p, 1);
rb_define_method(rb_cComplex, "to_s", nucomp_to_s, 0);
rb_define_method(rb_cComplex, "inspect", nucomp_inspect, 0);
@@ -1456,11 +1492,9 @@ Init_Complex(void)
/* --- */
- rb_define_method(rb_cNumeric, "re", numeric_re, 0);
- rb_define_method(rb_cNumeric, "im", numeric_im, 0);
rb_define_method(rb_cNumeric, "real", numeric_real, 0);
- rb_define_method(rb_cNumeric, "image", numeric_image, 0);
- rb_define_method(rb_cNumeric, "imag", numeric_image, 0);
+ rb_define_method(rb_cNumeric, "imaginary", numeric_imag, 0);
+ rb_define_method(rb_cNumeric, "imag", numeric_imag, 0);
rb_define_method(rb_cNumeric, "abs2", numeric_abs2, 0);
rb_define_method(rb_cNumeric, "arg", numeric_arg, 0);
rb_define_method(rb_cNumeric, "angle", numeric_arg, 0);
@@ -1468,9 +1502,15 @@ Init_Complex(void)
rb_define_method(rb_cNumeric, "rectangular", numeric_rect, 0);
rb_define_method(rb_cNumeric, "rect", numeric_rect, 0);
rb_define_method(rb_cNumeric, "polar", numeric_polar, 0);
- rb_define_method(rb_cNumeric, "conjugate", numeric_conjugate, 0);
- rb_define_method(rb_cNumeric, "conj", numeric_conjugate, 0);
+ rb_define_method(rb_cNumeric, "conjugate", numeric_conj, 0);
+ rb_define_method(rb_cNumeric, "conj", numeric_conj, 0);
rb_define_const(rb_cComplex, "I",
f_complex_new_bang2(rb_cComplex, ZERO, ONE));
}
+
+/*
+Local variables:
+c-file-style: "ruby"
+End:
+*/
View
11 configure.in
@@ -1423,10 +1423,12 @@ if test "$with_dln_a_out" != yes; then
powerpc*)
: ${LDSHARED="ld -xms"}
DLDFLAGS="$DLDFLAGS "'-export Init_$(TARGET) -lbe -lroot glue-noinit.a init_term_dyn.o start_dyn.o'
- ;;
+ LDFLAGS="$LDFLAGS -L/boot/home/config/lib -lbe -lroot"
+ ;;
i586*)
: ${LDSHARED="ld -shared"}
- DLDFLAGS="$DLDFLAGS -L/boot/develop/lib/x86 -lbe -lroot"
+ DLDFLAGS="$DLDFLAGS -L/boot/develop/lib/x86 -L/boot/home/config/lib \$(topdir)/_APP_ -lbe -lroot"
+ LDFLAGS="$LDFLAGS -L/boot/develop/lib/x86 -L/boot/home/config/lib -lbe -lroot"
;;
esac
: ${LIBPATHENV=LIBRARY_PATH}
@@ -1455,7 +1457,7 @@ if test "$with_dln_a_out" != yes; then
hiuxmpp) : ${LDSHARED='ld -r'} ;;
atheos*) : ${LDSHARED="$CC -shared"}
rb_cv_dlopen=yes ;;
- os2-emx*) LDFLAGS="$LDFLAGS -Zbsd-signals"
+ os2-emx*) LDFLAGS="$LDFLAGS -Zomf"
;;
*) : ${LDSHARED='ld'} ;;
esac
@@ -1799,7 +1801,7 @@ case "$target_os" in
MINIDLNOBJ=dmydln.o
;;
os2-emx)
- CFLAGS="$CFLAGS -DOS2 -Zmts"
+ CFLAGS="$CFLAGS -DOS2"
LIBRUBY_A=`echo $LIBRUBY_A | sed 's/^lib//'`
LIBRUBY_SO=`echo $LIBRUBY_SO | sed 's/^lib//'`
LIBRUBY_ALIASES=`for i in $LIBRUBY_ALIASES; do echo "$i"; done | sed 's/^lib//'`
@@ -1826,6 +1828,7 @@ case "$target_os" in
CFLAGS="$CFLAGS -relax_pointers"
;;
esac
+ CPPFLAGS="$CPPFLAGS -I/boot/home/config/include"
;;
cygwin*|mingw*)
LIBRUBY_DLDFLAGS="${DLDFLAGS}"' -Wl,--out-implib=$(LIBRUBY)'
View
3  dln.c
@@ -1442,7 +1442,8 @@ dln_load(const char *file)
/* load extention module */
img_id = load_add_on(file);
if (img_id <= 0) {
- rb_loaderror("Failed to load %.200s", file);
+ rb_loaderror("Failed to load add_on %.200s error_code=%x",
+ file, img_id);
}
/* find symbol for module initialize function. */
View
4 enc/big5.c
@@ -165,7 +165,7 @@ static const char BIG5_CAN_BE_TRAIL_TABLE[256] = {
#define BIG5_ISMB_TRAIL(byte) BIG5_CAN_BE_TRAIL_TABLE[(byte)]
static UChar*
-big5_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
+big5_left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc)
{
const UChar *p;
int len;
@@ -181,7 +181,7 @@ big5_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
}
}
}
- len = enclen(enc, p, s);
+ len = enclen(enc, p, end);
if (p + len > s) return (UChar* )p;
p += len;
return (UChar* )(p + ((s - p) & ~1));
View
4 enc/cp949.c
@@ -165,7 +165,7 @@ cp949_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
}
static UChar*
-cp949_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
+cp949_left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc)
{
const UChar *p;
int len;
@@ -181,7 +181,7 @@ cp949_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc
}
}
}
- len = enclen(enc, p, s);
+ len = enclen(enc, p, end);
if (p + len > s) return (UChar* )p;
p += len;
return (UChar* )(p + ((s - p) & ~1));
View
4 enc/euc_jp.c
@@ -222,7 +222,7 @@ mbc_case_fold(OnigCaseFoldType flag,
}
static UChar*
-left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
+left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc)
{
/* In this encoding
mb-trail bytes doesn't mix with single bytes.
@@ -234,7 +234,7 @@ left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
p = s;
while (!eucjp_islead(*p) && p > start) p--;
- len = enclen(enc, p, s);
+ len = enclen(enc, p, end);
if (p + len > s) return (UChar* )p;
p += len;
return (UChar* )(p + ((s - p) & ~1));
View
4 enc/euc_kr.c
@@ -145,7 +145,7 @@ euckr_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
#define euckr_islead(c) ((c) < 0xa1 || (c) == 0xff)
static UChar*
-euckr_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
+euckr_left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc)
{
/* Assumed in this encoding,
mb-trail bytes don't mix with single bytes.
@@ -157,7 +157,7 @@ euckr_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc
p = s;
while (!euckr_islead(*p) && p > start) p--;
- len = enclen(enc, p, s);
+ len = enclen(enc, p, end);
if (p + len > s) return (UChar* )p;
p += len;
return (UChar* )(p + ((s - p) & ~1));
View
4 enc/euc_tw.c
@@ -187,7 +187,7 @@ euctw_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
#define euctw_islead(c) ((UChar )((c) - 0xa1) > 0xfe - 0xa1)
static UChar*
-euctw_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
+euctw_left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc)
{
/* Assumed in this encoding,
mb-trail bytes don't mix with single bytes.
@@ -199,7 +199,7 @@ euctw_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc
p = s;
while (!euctw_islead(*p) && p > start) p--;
- len = enclen(enc, p, s);
+ len = enclen(enc, p, end);
if (p + len > s) return (UChar* )p;
p += len;
return (UChar* )(p + ((s - p) & ~1));
View
2  enc/gb18030.c
@@ -245,7 +245,7 @@ enum state {
};
static UChar*
-gb18030_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
+gb18030_left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc)
{
const UChar *p;
enum state state = S_START;
View
4 enc/gbk.c
@@ -165,7 +165,7 @@ gbk_is_code_ctype(OnigCodePoint code, unsigned int ctype, OnigEncoding enc)
}
static UChar*
-gbk_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
+gbk_left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc)
{
const UChar *p;
int len;
@@ -181,7 +181,7 @@ gbk_left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
}
}
}
- len = enclen(enc, p, s);
+ len = enclen(enc, p, end);
if (p + len > s) return (UChar* )p;
p += len;
return (UChar* )(p + ((s - p) & ~1));
View
4 enc/shift_jis.c
@@ -229,7 +229,7 @@ is_code_ctype(OnigCodePoint code, unsigned int ctype)
#endif
static UChar*
-left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
+left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end, OnigEncoding enc)
{
const UChar *p;
int len;
@@ -245,7 +245,7 @@ left_adjust_char_head(const UChar* start, const UChar* s, OnigEncoding enc)
}
}
}
- len = enclen(enc, p, s);
+ len = enclen(enc, p, end);
if (p + len > s) return (UChar* )p;
p += len;
return (UChar* )(p + ((s - p) & ~1));
View
2  enc/utf_16be.c
@@ -212,7 +212,7 @@ utf16be_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* e
#endif
static UChar*
-utf16be_left_adjust_char_head(const UChar* start, const UChar* s,
+utf16be_left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end,
OnigEncoding enc ARG_UNUSED)
{
if (s <= start) return (UChar* )s;
View
2  enc/utf_16le.c
@@ -204,7 +204,7 @@ utf16le_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp,
#endif
static UChar*
-utf16le_left_adjust_char_head(const UChar* start, const UChar* s,
+utf16le_left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end,
OnigEncoding enc ARG_UNUSED)
{
if (s <= start) return (UChar* )s;
View
2  enc/utf_32be.c
@@ -152,7 +152,7 @@ utf32be_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* e
#endif
static UChar*
-utf32be_left_adjust_char_head(const UChar* start, const UChar* s,
+utf32be_left_adjust_char_head(const UChar* start, const UChar* s, const UChar* end,
OnigEncoding enc ARG_UNUSED)
{
int rem;
View
2  enc/utf_32le.c
@@ -152,7 +152,7 @@ utf32le_is_mbc_ambiguous(OnigCaseFoldType flag, const UChar** pp, const UChar* e
#endif