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

181 Коммитов

Автор SHA1 Сообщение Дата
Xin Li 7400628cb0
[Bug #18997] Don't define ruby_qsort when POSIX qsort_r is available
The current code would define ruby_qsort as a wrapper of qsort_s
when it is available. When both qsort_s and POSIX (GNU) qsort_r
are available, we should call qsort_r directly instead, and
the qsort_s wrapper is redundant.
2022-09-08 17:37:37 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
卜部昌平 538a3919d9 include/ruby/internal/ctype.h: add doxygen
Must not be a bad idea to improve documents.
2021-09-10 20:00:06 +09:00
Nobuyoshi Nakada a4e39112a8
Cast to size_t instead of int
len and *retlen are size_t since r22957
(commit:4de12b6ae9a7fc1e28ada4b62291a78f28ae7528).
2021-07-22 09:52:29 +09:00
Nobuyoshi Nakada 04b5e85bfd
Look up ruby_digit36_to_number_table
Instead of scanning ruby_hexdigits.
2021-07-21 19:32:18 +09:00
xtkoba 511b2f300f Get rid of misleading indentation 2021-05-03 11:17:14 +12:00
Nobuyoshi Nakada 2adbf01ae1
dtoa.c: make thread-safe by using atomic CAS 2021-01-10 18:19:53 +09:00
卜部昌平 9e41a75255 sed -i 's|ruby/impl|ruby/internal|'
To fix build failures.
2020-05-11 09:24:08 +09:00
卜部昌平 d7f4d732c1 sed -i s|ruby/3|ruby/impl|g
This shall fix compile errors.
2020-05-11 09:24:08 +09:00
卜部昌平 9e6e39c351
Merge pull request #2991 from shyouhei/ruby.h
Split ruby.h
2020-04-08 13:28:13 +09:00
卜部昌平 5e22f873ed decouple internal.h headers
Saves comitters' daily life by avoid #include-ing everything from
internal.h to make each file do so instead.  This would significantly
speed up incremental builds.

We take the following inclusion order in this changeset:

1.  "ruby/config.h", where _GNU_SOURCE is defined (must be the very
    first thing among everything).
2.  RUBY_EXTCONF_H if any.
3.  Standard C headers, sorted alphabetically.
4.  Other system headers, maybe guarded by #ifdef
5.  Everything else, sorted alphabetically.

Exceptions are those win32-related headers, which tend not be self-
containing (headers have inclusion order dependencies).
2019-12-26 20:45:12 +09:00
nobu 867338c36e Split dtoa.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-02-07 08:53:11 +00:00
shyouhei 86d1fc8863 suppress integer overflow warnings
* 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
2018-11-15 07:34:01 +00:00
shyouhei 7f6691ae77 suppress integer overflow warnings
* 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
2018-11-13 00:40:52 +00:00
shyouhei 1922253e2e util.c: suppress warnings
These functions handle overflows correctly.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-09 09:44:49 +00:00
shyouhei 7cc97cfe09 avoid (size_t)-- (2nd try)
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
2018-11-08 06:22:57 +00:00
shyouhei a74d08b957 svn merge -r 65625:65623 .
Was breaking make test-all


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-08 05:34:58 +00:00
shyouhei 24fff75045 avoid (size_t)--
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
2018-11-08 05:06:52 +00:00
shyouhei 226b91598a yet another -Wparentheses tweak
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-26 02:02:09 +00:00
nobu 991e95bb36 util.c: removed extra #endif [Bug #15091]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-10 04:23:24 +00:00
nobu ef92aa9a45 util.c: fix ruby_qsort with qsort_s
* 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
2018-09-10 04:21:39 +00:00
usa 5679d0c5c2 there is no such predefined macro. check build before commit!
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-10 01:43:10 +00:00
nobu 8e9a8c043e util.c: qsort_s in C11
* 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
2018-09-09 07:49:04 +00:00
shyouhei f8de9b045a define NO_LONG_LONG appropriately
as documented above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-04 07:51:18 +00:00
hsbt 0e2d2e6a79 Drop to support NaCl platform.
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
2017-10-23 05:56:25 +00:00
naruse 7be47caa88 Merge latest dtoa.c [Bug #13545]
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
2017-05-19 14:14:52 +00:00
nobu 92690b6235 potential memory leak
* 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
2017-05-18 11:29:42 +00:00
nobu 83f76f46c7 fix for mingw64
* 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
2017-03-03 06:18:36 +00:00
nobu 6ed8c79ddb util.c: round to even
* 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
2016-11-04 07:31:47 +00:00
nobu 5292b2727a util.c: do not underflow
* 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
2016-07-15 08:08:59 +00:00
nobu 295f60b94d util.c: round nearly middle value
* 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
2016-07-10 05:27:27 +00:00
nobu be4b1c1e2c util.c: qsort_s
* 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
2016-05-11 08:18:56 +00:00
naruse b3935f179b * gc.c (rb_gc_unprotect_logging): throw rb_memerror when it cannot
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
2016-05-08 17:52:38 +00:00
nobu f4166e2dd7 prefer rb_syserr_fail
* 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
2015-12-23 08:57:48 +00:00
nobu a8994b167e util.c: BSD qsort_r
* 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
2015-09-15 03:44:34 +00:00
nobu e521b916ec util.c: fix off-by-one error
* 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
2015-06-17 07:21:41 +00:00
nobu 238394e738 parse.y: check NTH_REF range
* 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
2015-05-29 05:39:03 +00:00
nobu b4974e71dc util.c: hexdigit
* util.c (hexdigit): extract identical constants.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-13 07:07:39 +00:00
akr 7cd76ab0c5 * internal.h: Include ruby.h and ruby/encoding.h to be
includable without prior inclusion.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48447 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-11-15 11:49:06 +00:00
nobu 17eb86eb12 util.c: let getcwd allocate buffer
* 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
2014-04-16 08:46:29 +00:00
glass cd476cd86b * configure.in: check qsort_r(3) and whether it is GNU version.
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
2014-02-08 12:50:28 +00:00
nobu fcd7887407 util.c: bump stack size in ruby_qsort()
* 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
2013-12-14 02:45:07 +00:00
nobu cf0efb8327 util.c: more precision
* 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
2013-11-22 04:10:46 +00:00
nobu 5cb83d9dab util.c: ignore too long fraction part
* 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
2013-11-22 03:43:56 +00:00
akr b2be623240 * internal.h (ruby_digit36_to_number_table): Declared.
* 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
2013-07-03 13:32:14 +00:00
nobu 2fef15145c util.c: constify
* util.c (scan_digits): constify readonly table.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-01 14:44:31 +00:00
naruse f544ca4e4e * util.c (ruby_hdtoa): revert r29729.
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
2013-04-22 02:59:09 +00:00
yugui 76bc2d1ed7 Imports Ruby's port to NativeClient (a.k.a NaCl).
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
2012-05-17 02:48:59 +00:00
nobu a258d6f415 * util.c (ruby_strtod): no need to check same digit for hexdigit
twice.  [ruby-dev:45363][Bug #6146]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-15 06:04:56 +00:00
kazu 0212af1733 * ext/bigdecimal/bigdecimal.h: add satisfy cc-mode comment.
* util.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-22 21:06:19 +00:00