Граф коммитов

482 Коммитов

Автор SHA1 Сообщение Дата
ko1 68f55c4b35 * dir.c (glob_helper): use #ifdef instead of #if.
gcc's -Wundef option shows warning for undefined macro.
* numeric.c (flo_is_finite_p): ditto.
* vm_dump.c (rb_vmdebug_thread_dump_state): ditto.
* vm_core.h: define VM_DEBUG_VERIFY_METHOD_CACHE to 0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-09-04 08:50:31 +00:00
nobu 52b59fc9d9 numeric.c: 0 % Float::NAN returns Float::NAN
* numeric.c (flodivmod): all results are NaN if divisor is NaN.
  [fix GH-692]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-01 07:35:48 +00:00
nagachika 71336a03fa * numeric.c (num_step_scan_args): table argument of rb_get_kwargs() is
array of IDs, not Symbols. [ruby-dev:48353] [Bug #9811]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-07-01 14:36:03 +00:00
eregon a21ac07f69 * numeric.c (do_coerce): Add a warning when an exception is raised
or an invalid value is returned in #coerce called by
  numeric comparison operators and the exception
  thrown by the caller has no information on the failure.
  In the next release such exception should not be rescued or
  should be the cause of the caller exception. nil is accepted
  as the "no possible coercion" return value. See #7688.
* test/ruby/test_numeric.rb: Add corresponding test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-07 13:16:01 +00:00
eregon ea7ce3096e * numeric.c (bit_coerce): remove constant parameter `err'
(always TRUE) of bit_coerce().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-07 09:16:21 +00:00
nobu f2980e3e20 encoding.h: constify rb_encoding
* include/ruby/encoding.h: constify `rb_encoding` itself, not only
  arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-02 20:23:47 +00:00
nobu 046831094b constify rb_encoding and OnigEncoding
* include/ruby/encoding.h: constify `rb_encoding` arguments.
* include/ruby/oniguruma.h: constify `OnigEncoding` arguments.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46309 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-06-01 22:06:11 +00:00
nobu c0dba956d1 id.def: predefine to_i
* defs/id.def: predefine `to_i` as well as `to_int`.

* numeric.c (id_to_i): use predefined `idTo_i`.

* object.c (conv_method_names): add `to_i` ID.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46030 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-20 08:28:33 +00:00
akr 63fee73500 * configure.in: Check nextafter() availability.
* include/ruby/missing.h (nextafter): New optional declaration.

* missing/nextafter.c: New file.

* numeric.c: Float#next_float and Float#prev_float implemented.

   [ruby-core:62562] [Feature #9834]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 00:37:10 +00:00
nobu a352b0a207 numeric.c: check keyword arguments
* numeric.c (num_step_scan_args): check keyword arguments and fail
  if they conflict with positional arguments.
  [ruby-dev:48177] [Bug #9811]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 08:24:09 +00:00
nobu f8661f7ffb numeric.c: merge miss
* numeric.c (num_step_scan_args): fix merge miss.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 08:10:00 +00:00
nobu ba90ac2529 numeric.c: num_step_scan_args
* numeric.c (num_step_scan_args): turn a macro into a function.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 08:05:00 +00:00
nobu 5c5180256a numeric.c: indent
* numeric.c (ruby_num_interval_step_size): adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-07 07:34:33 +00:00
akr a6024cdc1b * numeric.c (rb_num2long): Returns a long.
(rb_num2ulong): Returns a unsigned long.

* bignum.c (rb_big2long): Returns a long.
  (rb_big2ulong): Returns a unsigned long.

* include/ruby/intern.h: Follow above changes.

* include/ruby/ruby.h: Follow above changes.
  (rb_num2long_inline): No need to cast.
  (rb_num2ulong_inline): Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-04-18 15:46:32 +00:00
ko1 57e557908a * enumerator.c (enumerator_block_call): use PARRAY_CONST_PTR()
instead of RARRAY_PTR().
* io.c (rb_io_s_popen): ditto.
* numeric.c (num_step_size): ditto.
* vm_eval.c (rb_apply): ditto.
* vm_eval.c (rb_eval_cmd): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-17 04:20:16 +00:00
nobu fc23374f06 [DOC] add links to `Object#hash`
add links to `Object#hash` to each #`hash` methods rdocs.
[Fixes GH-567]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45329 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-14 01:27:43 +00:00
marcandre 9047641ce3 * numeric.c: Mention that Float::DIG is the minimum number
of siginificant digits. See #9191

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02 01:55:02 +00:00
nobu e8b9611b32 numeric.c: predefined constants
* numeric.c (id_eq, id_cmp): use predefined constants in id.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 15:47:52 +00:00
nobu 99431e7355 numeric.c: float overflow
* numeric.c (ruby_num_interval_step_size): get rid of float
  conversion overflow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 05:11:44 +00:00
nobu a4a551f856 numeric.c: integer overflow
* numeric.c (ruby_num_interval_step_size): get rid of integer
  overflow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 04:59:49 +00:00
marcandre d596ba8dc0 * numeric.c: Fix rdoc for step
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 02:19:21 +00:00
marcandre 1636c60fe1 * numeric.c: Fix Numeric#step with 0 unit [#9575]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 02:04:59 +00:00
marcandre 11a57c63f3 * numeric.c: Simplify by getting rid of macro
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 02:04:43 +00:00
marcandre 814fb8e6c7 * numeric.c: Create var for rb_intern("<=>")
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 02:04:28 +00:00
marcandre e184e31c09 * numeric.c: Simplify [ruby-core:61106] [Bug #9570]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-28 02:03:30 +00:00
nobu c1fc20124c numeric.c: check signs before division
* numeric.c (ruby_num_interval_step_size): check signs and get rid
  of implementation dependent behavior of negative division.
  [ruby-core:61106] [Bug #9570]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 03:10:12 +00:00
akr 3c99764bcd * internal.h: Rename macro names: RBIGNUM_FOO to BIGNUM_FOO.
(BIGNUM_EMBED_LEN_NUMBITS): Renamed from RBIGNUM_EMBED_LEN_NUMBITS.
  (BIGNUM_EMBED_LEN_MAX): Renamed from RBIGNUM_EMBED_LEN_MAX.
  (BIGNUM_SIGN_BIT): Renamed from RBIGNUM_SIGN_BIT.
  (BIGNUM_SIGN): Renamed from RBIGNUM_SIGN.
  (BIGNUM_SET_SIGN): Renamed from RBIGNUM_SET_SIGN.
  (BIGNUM_POSITIVE_P): Renamed from RBIGNUM_POSITIVE_P.
  (BIGNUM_NEGATIVE_P): Renamed from RBIGNUM_NEGATIVE_P.
  (BIGNUM_EMBED_FLAG): Renamed from RBIGNUM_EMBED_FLAG.
  (BIGNUM_EMBED_LEN_MASK): Renamed from RBIGNUM_EMBED_LEN_MASK.
  (BIGNUM_EMBED_LEN_SHIFT): Renamed from RBIGNUM_EMBED_LEN_SHIFT.
  (BIGNUM_LEN): Renamed from RBIGNUM_LEN.
  (RBIGNUM_DIGITS): Renamed from RBIGNUM_DIGITS.
  (BIGNUM_LENINT): Renamed from RBIGNUM_LENINT.

* bignum.c: Follow the above change.

* gc.c: Ditto.

* marshal.c: Ditto.

* math.c: Ditto.

* numeric.c: Ditto.

* random.c: Ditto.

* rational.c: Ditto.

* sprintf.c: Ditto.

* ext/-test-/bignum/bigzero.c: Ditto.

* ext/-test-/bignum/intpack.c: Ditto.

* ext/bigdecimal/bigdecimal.c: Ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-15 21:17:34 +00:00
akr 2fee22f30d [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-11 16:40:41 +00:00
zzak 65fd879a0a * numeric.c: [DOC] Fix typo in example for #step [ci skip]
Patch by @ksss [Fixes GH-522] https://github.com/ruby/ruby/pull/522


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-31 21:05:52 +00:00
nobu eb6575e137 numeric.c: preserve encoding
* numeric.c (num_init_copy): preserve encoding of error message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15 08:16:42 +00:00
nobu c1b4b10a12 numeric.c: preserve encoding
* numeric.c (num_sadded): preserve encoding of error message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44612 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15 08:16:40 +00:00
nobu 3ea61a2cf5 numeric.c: FLOAT_OUT_OF_RANGE
* numeric.c (FLOAT_OUT_OF_RANGE): extract a macro and a helper to
  raise RangeError of float.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44611 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15 08:16:38 +00:00
nobu 2c65cdd319 numeric.c: preserve encoding
* numeric.c (coerce_failed): preserve encoding of error message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15 08:16:37 +00:00
a_matsuda 38e89273ed * numeric.c: Fix typo in an error message
s/unsgined/unsigned/

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-07 14:29:41 +00:00
nobu 006e66b668 numeric.c: isfinite
* numeric.c (flo_is_finite_p): prefer C99 standard isfinite() than
  deprecated finite().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-05 12:33:42 +00:00
nobu 09b02349c2 numeric.c: no declaration of finite
* numeric.c (finite): disable declaration on Windows, which can be
  defined in ruby/win32.h.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-10 06:33:34 +00:00
mame 487a25d29b * numeric.c (fix_aref): avoid a possible undefined behavior.
1L << 63 on 64-bit platform is undefined, at least, according to
  ISO/IEC 9899 (C99) 6.5.7.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-09 15:08:41 +00:00
nobu d700d34043 internal.h: move inline functions
* internal.h (rb_float_value, rb_float_new): move inline functions
  from ruby/ruby.h.
* numeric.c (rb_float_value, rb_float_new): define external functions
  for extension libraries.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-25 07:58:49 +00:00
nobu ed6c17f75c numeric.c: use RB_TYPE_P
* numeric.c: use RB_TYPE_P() for special classes instead of switch
  with TYPE().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-11 08:23:06 +00:00
nobu 9b6ee42d86 numeric.c: use positive_int_p
* numeric.c (NUM_STEP_SCAN_ARGS): use positive_int_p() to fix rubyspec
  failures.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42877 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 19:04:33 +00:00
nobu ba6c734847 numeric.c: no extra checks
* numeric.c (NUM_STEP_SCAN_ARGS): remove extra class checks, which
  cause the incompatibilities.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-07 19:04:28 +00:00
nobu 326e38164b numeric.c: split NUM_STEP_GET_INF
* numeric.c (NUM_STEP_GET_INF): split from NUM_STEP_SCAN_ARGS(), since
  inf is not used in num_step_size().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-04 13:57:02 +00:00
knu c68596aef1 Retain behavior of Numeric#step when nil is given as second argument.
* numeric.c (NUM_STEP_SCAN_ARGS): On sencond thought, keep
  Numeral#step backward compatible in that it raises TypeError
  when nil is given as second argument.

* test/ruby/test_float.rb (TestFloat#test_num2dbl): Revert.

* test/ruby/test_numeric.rb (TestNumeric#test_step): Fix test
  cases for the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 22:54:58 +00:00
knu 4993cf9e24 Numeral#step should raise TypeError if a non-numeric parameter is given.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 22:39:22 +00:00
knu fd4b5b8dc8 Enhance Numeric#step.
* numeric.c (num_step): Default the limit argument to infinity and
  allow it to be omitted.  Keyword arguments (by: and to:) are
  introduced for ease of use. [Feature #8838] [ruby-dev:47662]
  [ruby-dev:42194]

* numeric.c (num_step): Optimize for infinite loop.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-02 14:56:06 +00:00
akr 77f245e62e * numeric.c (rb_fix_bit_length): Moved from bignum.c.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42752 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-01 01:31:16 +00:00
ktsj 22bfbc9419 * numeric.c: [DOC] fix typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-10 05:02:56 +00:00
akr ba3ec382c7 [DOC] refine a call seq.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-06 03:33:22 +00:00
nobu 7c9a3d19fc parse.y: calculate powers of ten
* parse.y (parser_yylex): calculate denominator directly as powers of
  ten, not parsing string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42334 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-02 14:48:55 +00:00
zzak 4314d8c2e3 * numeric.c: [DOC] improve rdoc formatting for parameters and links
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41989 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-15 18:27:23 +00:00