aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
Commit message (Collapse)AuthorAgeFilesLines
* Split dtoa.cnobu2019-02-071-3416/+7
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* suppress integer overflow warningsshyouhei2018-11-151-0/+2
| | | | | | | | | * util.c: annotate as NO_SANITIZE * bignum.c: avoid (size_t)-- * marshal.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65739 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* suppress integer overflow warningsshyouhei2018-11-131-1/+9
| | | | | | | | | | | | | * random.c: annotate rb_hash_start with NO_SANITIZE (seed.key.hash + h overflows and that seems intentional) * bignum.c: avoid (size_t)-- * cont.c: ditto * util.c: ditto * vm_insnhelper.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: suppress warningsshyouhei2018-11-091-0/+2
| | | | | | | | These functions handle overflows correctly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* avoid (size_t)-- (2nd try)shyouhei2018-11-081-1/+5
| | | | | | | | | | | The decrements overflow and these variables remain ~0 when leaving the while loops. They are not fatal by accident, but better replace with ordinal for loops. See also: https://travis-ci.org/ruby/ruby/jobs/452218871#L3246 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* svn merge -r 65625:65623 .shyouhei2018-11-081-5/+1
| | | | | | | Was breaking make test-all git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* avoid (size_t)--shyouhei2018-11-081-1/+5
| | | | | | | | | | | The decrements overflow and these variables remain ~0 when leaving the while loops. They are not fatal by accident, but better replace with ordinal for loops. See also: https://travis-ci.org/ruby/ruby/jobs/452218871#L3246 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* yet another -Wparentheses tweakshyouhei2018-09-261-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: removed extra #endif [Bug #15091]nobu2018-09-101-1/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: fix ruby_qsort with qsort_snobu2018-09-101-18/+20
| | | | | | | | * util.c (ruby_qsort): __STDC_VERSION__ may not be defined even if it is available. fixed duplicate definitions when qsort_s is available on non-Windows platforms. [ruby-core:88921] [Bug #15091] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* there is no such predefined macro. check build before commit!usa2018-09-101-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: qsort_s in C11nobu2018-09-091-4/+21
| | | | | | | | | | | | | * configure.ac: macro for C11 to use qsort_s. * util.c (ruby_qsort): fix for C11 qsort_s. the comparison function for MSVCRT qsort_s is compatible with BSD qsort_r, but not with C11 qsort_s, in spite of its name. note that mingw defines __STDC_VERSION__ but uses qsort_s in MSVCRT, so the MSVCRT block needs to preced the C11 block. [ruby-core:88899] [Bug #15091] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* define NO_LONG_LONG appropriatelyshyouhei2018-01-041-0/+2
| | | | | | as documented above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Drop to support NaCl platform.hsbt2017-10-231-4/+1
| | | | | | | | | | | Because NaCl and PNaCl are already sunset status. see https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160 configure.ac: Patch for this file was provided by @nobu. [Feature #14041][ruby-core:83497][fix GH-1726] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Merge latest dtoa.c [Bug #13545]naruse2017-05-191-5/+7
| | | | | | Apply some part of http://www.netlib.org/fp/dtoa.c with my eyes... git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* potential memory leaknobu2017-05-181-0/+8
| | | | | | | | * dir.c (rb_dir_getwd): get rid of potential memory leak. * util.c (ruby_getcwd): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* fix for mingw64nobu2017-03-031-0/+4
| | | | | | | * util.c: define MINGW_HAS_SECURE_API for qsort_s on recent mingw64. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: round to evennobu2016-11-041-7/+8
| | | | | | | * util.c (ruby_dtoa): round to even, instead of rounding to nearest. [ruby-core:77864] [Bug #12889] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: do not underflownobu2016-07-151-1/+1
| | | | | | | | * util.c (ruby_strtod): do not underflow only by preceeding zeros, which may be canceled out by the exponent. http://twitter.com/kazuho/status/753829998767714305 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: round nearly middle valuenobu2016-07-101-0/+4
| | | | | | | | * util.c (ruby_dtoa): [EXPERIMENTAL] adjust the case that the Float value is close to the exact but unrepresentable middle value of two values in the given precision, as r55604. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: qsort_snobu2016-05-111-0/+5
| | | | | | | * util.c (ruby_qsort): use qsort_s if available, for Microsoft Visual Studio 2005 (msvcr80.dll) and mingw. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * gc.c (rb_gc_unprotect_logging): throw rb_memerror when it cannotnaruse2016-05-081-2/+2
| | | | | | | | | | | | allocate memory. This is pointed out by Facebook's Infer. * gc.c (gc_prof_setup_new_record): ditto. * regparse.c (parse_regexp): ditto. * util.c (MALLOC): use xmalloc and xfree like above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* prefer rb_syserr_failnobu2015-12-231-3/+5
| | | | | | | | * file.c, io.c, util.c: prefer rb_syserr_fail with saved errno over setting errno then call rb_sys_fail, not to be clobbered potentially and to reduce thread local errno accesses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: BSD qsort_rnobu2015-09-151-1/+23
| | | | | | * util.c (ruby_qsort): use BSD-style qsort_r if available. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: fix off-by-one errornobu2015-06-171-1/+2
| | | | | | | * util.c (ruby_scan_digits): fix the return length off-by-one error when the length is given and the last char is a digit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* parse.y: check NTH_REF rangenobu2015-05-291-9/+13
| | | | | | | | | | * compile.c (iseq_compile_each): out of range NTH_REF is always nil. * parse.y (parse_numvar): check overflow of NTH_REF and range. [ruby-core:69393] [Bug #11192] * util.c (ruby_scan_digits): make public and add length parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: hexdigitnobu2015-02-131-2/+3
| | | | | | * util.c (hexdigit): extract identical constants. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: Include ruby.h and ruby/encoding.h to beakr2014-11-151-1/+0
| | | | | | | | includable without prior inclusion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: let getcwd allocate buffernobu2014-04-161-9/+9
| | | | | | | * util.c (ruby_getcwd): POSIX.1-2001 extends getcwd(3) as it allocates the buffer if the argument is NULL. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * configure.in: check qsort_r(3) and whether it is GNU version.glass2014-02-081-0/+2
| | | | | | | | | | BSD version has different prototype. * util.h: use qsort_r() as ruby_qsort() if it is GNU version. * util.c: define ruby_qsort() if needed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44889 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: bump stack size in ruby_qsort()nobu2013-12-141-1/+3
| | | | | | | | * util.c (ruby_qsort): fix potential stack overflow on a large machine. based on the patch by Conrad Irwin <conrad.irwin AT gmail.com> at [ruby-core:51816]. [Bug #7772] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44195 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: more precisionnobu2013-11-221-1/+1
| | | | | | * util.c (ruby_strtod): BigMath requires more precision. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: ignore too long fraction partnobu2013-11-221-2/+12
| | | | | | | * util.c (ruby_strtod): ignore too long fraction part, which does not affect the result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h (ruby_digit36_to_number_table): Declared.akr2013-07-031-20/+21
| | | | | | | | | | | | * util.c (ruby_digit36_to_number_table): Moved from scan_digits. * bignum.c (conv_digit): Use ruby_digit36_to_number_table. * pack.c (hex2num): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* util.c: constifynobu2013-07-011-1/+1
| | | | | | * util.c (scan_digits): constify readonly table. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * util.c (ruby_hdtoa): revert r29729.naruse2013-04-221-5/+2
| | | | | | | If you want ruby to behave as before on x86, specify to use SSE like -msse2 -mfpmath=sse for gcc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40404 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Imports Ruby's port to NativeClient (a.k.a NaCl).yugui2012-05-171-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Patch by Google Inc. [ruby-core:45073]. * configure.in (RUBY_NACL): New M4 func to configure variables for NaCl. (RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names of Pepper interface types. (BTESTRUBY): New variable to specify which ruby should be run on "make btest". NaCl can run the built binary by sel_ldr, but it need rbconfig.rb. So this variable is distinguished from $MINIRUBY. * thread_pthread.c: Disabled some features on NaCl. * io.c: ditto. * process.c: ditto. * signal.c: ditto. * file.c: ditto. * missing/flock.c: ditto. * nacl/pepper_main.c: An example implementation of Pepper application that embeds Ruby. * nacl/example.html: An example of web page that uses the Pepper application. * nacl/nacl-config.rb: Detects variants of NaCl SDK. * nacl/GNUmakefile.in: Makefile template for NaCl specific build process. * nacl/package.rb: script for packaging a NaCl-Ruby embedding application. * nacl/reate_nmf.rb: Wrapper script of create_nmf.py * dln.c (dln_load): Added a hack to call on NaCl. * util.c (ruby_getcwd): Path to the current directort is not available on NaCl. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * util.c (ruby_strtod): no need to check same digit for hexdigitnobu2012-03-151-2/+5
| | | | | | | twice. [ruby-dev:45363][Bug #6146] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/bigdecimal/bigdecimal.h: add satisfy cc-mode comment.kazu2011-12-221-2/+2
| | | | | | * util.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * util.c (mmprepare): fix for fragmental size.nobu2011-10-201-23/+54
| | | | | | * util.c (mmswap_, mmrot3_): portability improvement. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * util.c, include/ruby/util.h (ruby_add_suffix): remove the function.usa2011-08-031-178/+0
| | | | | | | | | | | | | | | | | | | | | | [Bug #5153] [ruby-core:38736] * io.c (argf_next_argv): remove the call of above function. * ext/-test-/add_suffix, test/-ext-/test_add_suffix.rb: remove the test extension module because this is only for testsing ruby_add_suffix(). * LEGAL: remove the mention about a part of util.c, because now we removed the part. * io.c (argf_next_argv): now the new filename is not guranteed to use, so should check the return value of rename(2). * test/ruby/test_argf.rb (TestArgf#test_inplace_rename_impossible): now we expect same result with other platforms on no_safe_rename platforms (=Windows). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * thread_pthread.c (mutex_debug): use exit(EXIT_FAILURE) instad ofkosaki2011-07-101-1/+1
| | | | | | | | | | | exit(1). * thread_pthread.c (add_signal_thread_list): ditto. * thread.c (rb_thread_call_with_gvl): ditto. * util.c (Bug): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32494 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.h: declare more internal functions.akr2011-06-181-3/+1
| | | | | | | | | | | | | | * iseq.h (rb_method_get_iseq): declared. * compile.c, eval.c, eval_error.c, iseq.c, parse.y, proc.c, range.c, ruby.c, time.c, util.c, vm.c: don't declare internal functions. * eval.c, parse.y, thread_pthread.c: non-existing function declarations removed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * util.c: parenthesize macro arguments.akr2011-01-101-35/+35
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * util.c (ruby_strtod): this code uses FPU's rounding system.naruse2010-11-091-2/+5
| | | | | | | | | | But x86's FPU calculates double precision floating-point numbers in 80bit precision, so it fails to round the value. So ensure the value is assigned a variable. [ruby-dev:42551] see also [ruby-math:00802] http://www.shudo.net/java-grandprix99/strictfp/ git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * util.c (ruby_strtod): suppress a warning.nobu2010-11-081-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * util.c (ruby_hdtoa): fix type cast and bufsize.naruse2010-11-081-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * util.c (ruby_strtod): get rid of overflow/underflow as possible.nobu2010-10-301-13/+29
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * util.c (ruby_strtod): fix indent.nobu2010-10-301-14/+14
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * util.c (ruby_strtod): reject 0x1.p+0. [ruby-dev:42432] #3966naruse2010-10-201-2/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e