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

375 Коммитов

Автор SHA1 Сообщение Дата
nobu 57fb219905 * reduce UNREACHABLE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-15 00:06:13 +00:00
drbrain e95f7ea80d * variable.c (trace_ev): Removed "not reached" comment as this line is
reached.
* variable.c (rb_obj_remove_instance_variable):  Replaced "not reached"
  comment with the UNREACHABLE macro.
* variable.c (rb_mod_const_missing):  ditto.
* variable.c (rb_mod_remove_cvar):  ditto.
* enum.c (first_i):  ditto.
* string.c (rb_str_aref):  ditto.
* string.c (str_byte_aref):  ditto.
* string.c (rb_to_id):  ditto.
* io.c (rb_io_fmode_modestr):  ditto.
* io.c (rb_io_oflags_modestr):  ditto.
* pack.c (num2i32):  ditto.
* vm_eval.c (rb_method_missing):  ditto.
* vm_eval.c (rb_f_throw):  ditto.
* dir.c (dir_read):  ditto.
* win32/win32.c (child_result):  ditto.
* struct.c (rb_struct_getmember):  ditto.
* struct.c (rb_struct_set):  ditto.
* struct.c (rb_struct_aref_id):  ditto.
* eval.c (rb_f_raise):  ditto.
* process.c (rb_f_exit_bang):  ditto.
* process.c (rb_f_exit):  ditto.
* process.c (rb_f_abort):  ditto.
* ext/-test-/iter/break.c (iter_break_value):  ditto.
* ext/pty/pty.c (pty_check):  ditto.
* ext/openssl/ossl_pkey.c (ossl_pkey_new):  ditto.
* ext/readline/readline.c (rb_remove_history):  ditto.
* ext/stringio/stringio.c (strio_unimpl):  ditto.
* numeric.c (num_sadded):  ditto.
* numeric.c (num_init_copy):  ditto.
* numeric.c (rb_num2ll):  ditto.
* numeric.c (rb_num2ull):  ditto.
* vm_insnhelper.c (call_cfunc):  ditto.
* ruby.c (opt_W_getter):  ditto.
* bignum.c (rb_big_coerce):  ditto.
* file.c (rb_f_test):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-14 00:36:26 +00:00
nobu c037f1f616 * adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 01:39:00 +00:00
marcandre 7316302483 * include/ruby/intern.h: Add rb_check_arity, rb_error_arity [#6085]
* array.c: Use rb_check_arity / rb_error_arity

* class.c: ditto

* enumerator.c: ditto

* eval.c: ditto

* file.c: ditto

* hash.c: ditto

* numeric.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* re.c: ditto

* signal.c: ditto

* string.c: ditto

* struct.c: ditto

* transcode.c: ditto

* vm_eval.c: ditto

* vm_insnhelper.c: ditto & implementation of rb_error_arity

* test/ruby/test_arity.rb: tests for above

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35024 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 21:10:34 +00:00
usa cc3d03b196 * numeric.c (flodivmod): must through the same pass if HAVE_FMOD or not.
this is a bugfix of r35013.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35015 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 08:56:42 +00:00
marcandre 4c2e2d8bde * numeric.c: fix flodivmod for cornercases [Bug #6044]
add ruby_float_mod

* insns.def (opt_mod): use ruby_float_mod

* internal.h: declare ruby_float_mod

* test/ruby/test_float.rb: tests for above

* test/ruby/envutil.rb: create helper assert_is_minus_zero

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-14 06:10:01 +00:00
naruse 800f04c6a5 * numeric.c (rb_enc_uint_char): raise RangeError when added codepoint
is invalid. [Feature #5855] [Bug #5863] [Bug #5864]

* string.c (rb_str_concat): ditto.

* string.c (rb_str_concat): set encoding as ASCII-8BIT when the string
  is US-ASCII and the argument is an integer greater than 127.

* regenc.c (onigenc_mb2_code_to_mbclen): rearrange error code.

* enc/euc_jp.c (code_to_mbclen): ditto.

* enc/shift_jis.c (code_to_mbclen): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34236 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-08 20:42:45 +00:00
naruse cc56bdee40 Fix for r33811.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-22 04:54:42 +00:00
naruse 033244c1b2 * numeric.c (ruby_float_step): improve floating point calculations.
[ruby-core:35753] [Bug #4576]

* numeric.c (ruby_float_step): correct the error of floating point
  numbers on the excluding case.
  patched by Masahiro Tanaka [ruby-core:39608]

* numeric.c (ruby_float_step): use the end value when the current
  value is greater than or equal to the end value.
  patched by Akira Tanaka [ruby-core:39612]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-22 01:47:35 +00:00
kosaki 302220a8a5 * numeric.c (rb_fix2ushort): fix typo. use num rb_num2ushort()
instead of num2uint().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33745 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-14 05:53:59 +00:00
kosaki b2a2ba1191 * include/ruby/ruby.h: add NUM2SHORT(), NUM2USHORT() macros.
* numeric.c: ditto.

* test/-ext-/num2int/test_num2int.rb: add testcases for NUM2SHORT().
* ext/-test-/num2int/num2int.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-14 03:54:34 +00:00
kosaki 74a13c7634 * numeric.c (check_uint): fix off-by-one bug of NUM2UINT.
* bignum.c (rb_big2ulong): fix off-by-one bug of NUM2ULONG.

* test/-ext-/num2int/test_num2int.rb: add a testcase for NUM2INT()
  NUM2UINT(), NUM2LONG(), NUM2ULONG(), NUM2LL and NUM2ULL().
* ext/-test-/num2int/depend: ditto.
* ext/-test-/num2int/extconf.rb: ditto.
* ext/-test-/num2int/num2int.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-14 03:45:47 +00:00
nobu bb98e0ecec * numeric.c (rb_infinity, rb_nan): aggregated member initializers
need braces.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33513 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-23 09:03:33 +00:00
ngoto 971769cd76 * numeric.c (rb_infinity, rb_nan): use union to prevent bus error
caused by misalignment.  [Bug #5469] [ruby-dev:44657]
* include/ruby/missing.h (INFINITY, NAN): ditto


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-21 17:34:58 +00:00
naruse 0a5ac6a448 Revert r33407; half-baked patch.
"* numeric.c (ruby_float_step): improve floating point calculations."

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-05 07:36:28 +00:00
naruse a635de7dcb * numeric.c (ruby_float_step): improve floating point calculations.
[ruby-core:35753] [Bug #4576]

* numeric.c (ruby_float_step): correct the error of floating point
  numbers on the excluding case.
  patched by Masahiro Tanaka [ruby-core:39608]

* numeric.c (ruby_float_step): use the end value when the current
  value is greater than or equal to the end value.
  patched by Akira Tanaka [ruby-core:39612]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33407 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-05 07:35:27 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
naruse 8ccd05c958 Revert "* numeric.c (ruby_float_step): Avoid error on i386 and amd64."
This reverts commit r33285 because of the message of r33284.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-16 07:09:24 +00:00
marcandre fd47fed269 * numeric.c (ruby_float_step): Avoid error on i386 and amd64.
Patch by Vit Ondruch. Issue #4576 [rubyspec:a9525edcd]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-16 06:44:59 +00:00
naruse 23d472165f Revert "* numeric.c (ruby_float_step): Avoid error on i386 and amd64."
r33282 challenged the precision of floating point but:
* Ruby keeps it as platform dependent
* amd64 won't get this issue because compilers for amd64 uses SSE2 to
  calculate floating point numbers instead of x87 FPU.
* this change won't fix the issue under -O
* this commit has no test for the changed behavior

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-16 01:12:46 +00:00
marcandre 22420b1453 * numeric.c (ruby_float_step): Avoid error on i386 and amd64.
Patch by Vit Ondruch. Issue #4576.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-15 17:13:51 +00:00
marcandre 80f54e6810 * numeric.c (dbl2ival): Fix Float#divmod and #round for 32 bit platform
part 1 of [bug #5276]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-05 21:45:25 +00:00
marcandre 3dc28710c9 * numeric.c (flo_round): Fix criteria for 32 bits platform
part 2 of [bug #5276]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33198 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-05 21:44:42 +00:00
marcandre 75c42535c9 * numeric.c (flo_round): Make Float#round round big values [bug #5272]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-04 20:14:29 +00:00
marcandre 269de36cd0 * numeric.c: Extract integer rounding into int_round_0
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33185 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-04 20:14:00 +00:00
marcandre 9d2f5dff62 * numeric.c (int_round): Integer#round always returns an Integer [Bug #5271]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-04 19:28:54 +00:00
nobu c4eb2983ba * numeric.c (flo_round): substitute machine dependent magic number.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-01 16:07:16 +00:00
marcandre 64e0cae274 * numeric.c (flo_round): Avoid overflow by optimizing for trivial cases
[Bug #5227]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-31 04:13:00 +00:00
mrkn 640420f704 * numeric.c (bit_coerce): A Fixnum and a Bignum are only permitted for
bitwise arithmetic with a Fixnum.  #1792
* test/ruby/test_fixnum.rb: add tests for the above change.
* bignum.c (bit_coerce): A Fixnum and a Bignum are only permitted for
 bitwise arithmetic with a Bignum.  #1792
* test/ruby/test_bignum.rb: add tests for the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-29 01:07:15 +00:00
marcandre 85e24491a6 * numeric.c (int_round): Fix Integer#round [ruby-core:39096]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-24 22:57:55 +00:00
marcandre ee0d942ed9 * numeric.c: Rdoc fix
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33060 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-24 22:57:42 +00:00
ngoto 9fb5dca9c9 * numeric.c (rb_infinity, rb_nan): use WORDS_BIGENDIAN to get endian.
fix [Bug #5160] [ruby-dev:44356]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-05 13:28:50 +00:00
usa 12adf25a80 * numeric.c (rb_num2ull): use FIX2LONG instead of FIX2ULONG. see
rb_num2ulong().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-11 06:03:41 +00:00
nobu 03c618daf0 * numeric.c (ULLONG_MAX): fallback definition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-09 07:54:38 +00:00
naruse 136c117fc1 * numeric.c (rb_num2ull): use own switch sentense.
Current implementation can't convert 18446744073709551615.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-07 06:23:40 +00:00
akr e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
nobu 6f58118e4c * numeric.c (rb_enc_uint_chr): fix message format. Bug#4869
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-11 07:52:34 +00:00
usa 799fafc03b * include/ruby/missing.h, numeric.c (round): moved prototype of round()
from numeric.c to missing.h.  (note: round() is C99 feature, so ruby
  provides it if not exists in C runtime.)


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-03 11:58:11 +00:00
naruse 1d5431374d * insns.def (opt_mult): as r31805, volatile it.
Without this, clang -O fails calculation.

* numeric.c (fix_mul): ditto.

* rational.c (f_imul): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-30 06:53:21 +00:00
naruse 4e4649e13c * numeric.c (int_pow): make sure to assign the result of x * z.
If xz is optimized out, the value won't overflow.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-30 01:28:37 +00:00
nobu 3b58e17d7b revert r31783.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-29 22:06:54 +00:00
nobu 7c99a7df85 * numeric.c (flo_round): use absolute value as divisor.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-29 14:22:49 +00:00
nagachika 4173fb0cb5 * numeric.c: add #include "interna.h" for rb_big_uminus() prototype.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31779 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-29 08:55:54 +00:00
nobu a3ffe9698b * numeric.c (flo_round): fix for negative value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31778 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-29 06:09:08 +00:00
nobu 3a47cf3395 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-15 11:55:52 +00:00
nagachika a55d803ed3 * numeric.c (flo_coerce): fix a typo in documentation.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-13 12:38:49 +00:00
shyouhei eb5de217f1 Add #flo_coerce documentation.
Signed-off-by: URABE, Shyouhei <shyouhei@ruby-lang.org>



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-13 10:27:10 +00:00
naruse 074818f3b0 * numeric.c (int_ord): remove K&R style.
patched by Daehyub Kim. https://github.com/ruby/ruby/pull/17

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-09 02:53:55 +00:00
usa 9d5f651a98 * numeric.c (ruby_float_step): wrong loop condition.
fixes [ruby-core:35753], reported by Joey Zhou.

* test/ruby/test_range.rb (TestRange#test_step_ruby_core_35753):
  test above change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-14 14:50:46 +00:00
nobu 9b66922d7f * numeric.c (flo_round): fix inaccurate results.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-22 23:07:36 +00:00