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

75 Коммитов

Автор SHA1 Сообщение Дата
Wai-Wai Ng 917e7eb50f
[DOC] Correct docs for Comparable 2023-04-10 01:09:03 +09:00
Kaíque Kandy Koga 46066d0b96
Change ArgumentError message when Comparable#clamp receives min value higher than max value 2023-01-17 21:25:11 -08:00
S-H-GAMELINKS 040e0c8d67 Reuse NIL_OR_UNDEF_P macro 2022-12-02 01:19:55 +09:00
S-H-GAMELINKS 1f4f6c9832 Using UNDEF_P macro 2022-11-16 18:58:33 +09:00
Takashi Kokubun 5b21e94beb Expand tabs [ci skip]
[Misc #18891]
2022-07-21 09:42:04 -07:00
S-H-GAMELINKS 51a3ebf4ec Using RBOOL in cmp_between func 2022-06-17 11:59:49 +09:00
Nobuyoshi Nakada 0bca029d2f
[DOC] Use simple references to operator methods
Method references is not only able to be marked up as code, also
reflects `--show-hash` option.
The bug that prevented the old rdoc from correctly parsing these
methods was fixed last month.
2022-03-30 10:54:52 +09:00
Burdette Lamar f918f6e4e7
[DOC] Repair format and links in What's Here sections (#5711)
* Repair format and links in What's Here for Comparable and Array

* Repair format for What's Here in enum.c
2022-03-25 10:52:06 -05:00
Nobuyoshi Nakada 50c972a1ae
[DOC] Simplify operator method references 2022-02-12 12:38:36 +09:00
S.H b8c3a84bdd
Refactor and Using RBOOL macro 2021-09-15 08:11:05 +09:00
S.H 378e8cdad6
Using RBOOL macro 2021-08-02 12:06:44 +09:00
Burdette Lamar c1741df1a1 What's Here for Numeric and Comparable 2021-06-21 10:38:16 -07:00
Stefan Stüben 8c2e5bbf58 Don't redefine #rb_intern over and over again 2020-10-21 12:45:18 +09:00
卜部昌平 a93da4970b cmp_clamp: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea.  Better refactor.
2020-06-29 11:05:41 +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
Marcus Stollsteimer 16fddfe352 [DOC] Improve readability of requirements for <=> 2019-12-23 15:02:59 +01:00
Nobuyoshi Nakada cf9344131c Raise on end-exclusive ranges [Feature #14784]
Raises an error on end-exclusive ranges unless endless, regardless
the receiver.
2019-10-26 12:52:50 +09:00
Nobuyoshi Nakada 42c652d195 Fixed range argument condition [Feature #14784]
Allows a beginless/endless range, and an end-exclusive range
unless the receiver is smaller than its end.
2019-10-25 23:30:47 +09:00
Nobuyoshi Nakada 929d5fd3b9 Comparable#clamp with a range [Feature #14784] 2019-10-16 01:42:34 +09:00
Nobuyoshi Nakada 81176095f4
[DOC] fixed a variable name [ci skip]
replaced "anObject" with "obj".  also marked up with simple `_`s
instead of `<i>`.
2019-10-15 22:38:39 +09:00
Shugo Maeda f005ccc771
Clarify requirements of <=>
A return value of <=> is automatically converted to -1, 0, or 1, so
other values can be returned.  [Misc #15630]
2019-04-22 17:15:49 +09:00
nobu 56557ec28a [DOC] fix markups [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-22 11:04:59 +00:00
nobu d5a0b8e3cc Comparable#clamp
* compar.c (cmp_clamp): Introduce Comparable#clamp.  [Feature #10594]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-11 07:24:25 +00:00
nobu b8ad953501 compar.c: utility functions
* compar.c (rb_cmp): call comparison method by predefiend ID.

* compar.c (cmpint): returns compared result.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-11 07:20:36 +00:00
marcandre bb9ef64e5b * compar.c: Update doc for == [#7688] [ci-skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-15 20:19:35 +00:00
nobu d429fc6c31 compar.c: variable name [ci skip]
* compar.c (Init_Comparable): [DOC] Replace camelcase variable name.
  [Fix GH-833]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-21 07:18:45 +00:00
eregon a1992e25b9 * compar.c (cmp_equal): no more error hiding for Comparable#==.
It now behaves as other Comparable methods. See #7688.
* test/ruby/test_comparable.rb: update related test.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49570 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-11 19:33:46 +00:00
nobu 748325b80d compar.c: fix message
* compar.c (rb_cmperr): show float values in the error message
  always, not only flonum.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-13 12:07:04 +00:00
nobu 3118c4c46e compar.c: use Module#to_s
* compar.c (rb_cmperr): use Module#to_s so that names in a message
  can be overridden by to_s.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-21 04:39:32 +00:00
nobu 40db3d97ac compar.c: preserve encodings
* compar.c (rb_cmperr): preserve encodings of arguments in the
  message.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-19 04:59:44 +00:00
eregon d1d7f12c89 * compar.c (cmp_equal): warn for this release and still rescue
standard exceptions for a nicer transition. See #7688.
  Partly reverts r44502.
* test/ruby/test_comparable.rb: adapt assertion to match new behavior.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-18 21:40:58 +00:00
eregon d781caaf31 * compar.c (cmp_equal): remove error hiding in Comparable#==.
Comparable#== no longer rescues exceptions silently.
  This was the cause of quite a couple bugs. See #7688. [EXPERIMENTAL]
* test/ruby/test_comparable.rb: adapt assertion to match new behavior.
* lib/rdoc/method_attr.rb: fix bugs discovered by this change.
* test/rdoc/test_rdoc_normal_class.rb: fix bugs in tests.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-05 11:14:59 +00:00
eregon 7e978b1070 * compar.c (cmp_eq_recursive): Fix the return value, the value for
failed #<=> should be nil. It was raising a NoMethodError for
  the test case TestComparable#test_no_cmp (undefined method `>'
  for false:FalseClass). Yet one more reason for #7688.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-28 22:28:39 +00:00
nobu 90c1ebbfd5 compar.c: fail if recursion
* compar.c (cmp_eq): fail if recursion.  [ruby-core:57736] [Bug #9003]
* thread.c (rb_exec_recursive_paired_outer): new function which is
  combinnation of paired and outer variants.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43208 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-09 04:53:18 +00:00
eregon 85bfd7308f * compar.c (Comparable#==): fix typo.
Patch by Andrew Grimm. [Fix GH-297]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-06 06:40:23 +00:00
nobu 44c5c2a312 compar.c: inversed comarison without infinite recursion
* compar.c (rb_invcmp): compare by inversed comarison, with preventing
  from infinite recursion.  [ruby-core:52305] [Bug #7870]
* string.c (rb_str_cmp_m), time.c (time_cmp): get rid of infinite
  recursion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-17 11:55:50 +00:00
zzak e798251a8a * compar.c (cmp_equal): Document ignored exception and return false
By Makoto Kishimoto [Bug #7790] [ruby-dev:46925] [ruby-dev:46910]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-02-07 22:33:32 +00:00
marcandre 7729de4d91 * array.c: Documentation: change => in call-seq to ->.
Harmonize "#=>" in examples. [ruby-core:30206]

* bignum.c: ditto

* class.c: ditto

* compar.c: ditto

* cont.c: ditto

* dir.c: ditto

* encoding.c: ditto

* enum.c: ditto

* enumerator.c: ditto

* error.c: ditto

* eval.c: ditto

* file.c: ditto

* gc.c: ditto

* io.c: ditto

* load.c: ditto

* marshal.c: ditto

* math.c: ditto

* numeric.c: ditto

* object.c: ditto

* pack.c: ditto

* proc.c: ditto

* process.c: ditto

* random.c: ditto

* range.c: ditto

* re.c: ditto

* ruby.c: ditto

* signal.c: ditto

* sprintf.c: ditto

* string.c: ditto

* struct.c: ditto

* thread.c: ditto

* time.c: ditto

* transcode.c: ditto

* variable.c: ditto

* vm_eval.c: ditto

* vm_method.c: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-17 21:07:33 +00:00
marcandre 705c567194 * string.c: rdoc for <=>, casecmp
* bignum.c: rdoc for <=>

* file.c: ditto

* time.c: ditto

* compar.c: rdoc

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25522 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-10-28 04:50:09 +00:00
nobu 12d2c8ba41 stripped trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 14:23:33 +00:00
nobu 5f9c188d97 * include/ruby/ruby.h (rb_intern_const): tiny optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16 00:20:31 +00:00
nobu 5a647a3f5f * include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.
* *.c: no cache in init functions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 09:25:32 +00:00
matz bdc00ba604 * bignum.c (rb_cmpint): moved from compar.c, to check bignum
zero.

* range.c (range_step): add step for each iteration if begin and
  end are numeric.  [ruby-core:15990]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-06 17:11:50 +00:00
akr 6cdef2dc7e * $Date$ keyword removed to avoid inclusion of locale dependent
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 15:49:38 +00:00
akr 2c8e7a50c1 * include/ruby/ruby.h (struct RBignum): embed digits in RBignum for
small bignums.

* bignum.c: RBignum embeded digits implemented.

* include/ruby/intern.h: declare rb_big_resize.

* gc.c: don't free embedded digits.

* numeric.c: replace direct bignum field accessor by abstract field
  accessor such as RBIGNUM(val)->sign to RBIGNUM_SIGN(val).

* sprintf.c: ditto.

* compar.c: ditto.

* marshal.c: ditto.

* random.c: ditto.

* .gdbinit: support embedded small bignums.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-01 12:02:36 +00:00
matz a25fbe3b3e * encoding.c: provide basic features for M17N.
* parse.y: encoding aware parsing.

* parse.y (pragma_encoding): encoding specification pragma.

* parse.y (rb_intern3): encoding specified symbols.

* string.c (rb_str_length): length based on characters.  
  for older behavior, bytesize method added.

* string.c (rb_str_index_m): index based on characters.  rindex as
  well.

* string.c (succ_char): encoding aware succeeding string.

* string.c (rb_str_reverse): reverse based on characters.

* string.c (rb_str_inspect): encoding aware string description.

* string.c (rb_str_upcase_bang): encoding aware case conversion.
  downcase, capitalize, swapcase as well.

* string.c (rb_str_tr_bang): tr based on characters.  delete,
  squeeze, tr_s, count as well.

* string.c (rb_str_split_m): split based on characters.

* string.c (rb_str_each_line): encoding aware each_line.

* string.c (rb_str_each_char): added.  iteration based on
  characters.

* string.c (rb_str_strip_bang): encoding aware whitespace
  stripping.  lstrip, rstrip as well.

* string.c (rb_str_justify): encoding aware justifying (ljust,
  rjust, center).

* string.c (str_encoding): get encoding attribute from a string. 

* re.c (rb_reg_initialize): encoding aware regular expression

* sprintf.c (rb_str_format): formatting (i.e. length count) based
  on characters.

* io.c (rb_io_getc): getc to return one-character string.
  for older behavior, getbyte method added.

* ext/stringio/stringio.c (strio_getc): ditto.

* io.c (rb_io_ungetc): allow pushing arbitrary string at the
  current reading point.

* ext/stringio/stringio.c (strio_ungetc): ditto.

* ext/strscan/strscan.c: encoding support.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 03:29:39 +00:00
nobu 2b592580bf * include/ruby: moved public headers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-10 03:06:15 +00:00
matz 4d467a0865 * ext/digest/digest.c (rb_digest_base_s_digest): add volatile to
protect temporary context object.  [ruby-dev:27979]

* ext/iconv/iconv.c (Init_iconv): rb_gc_register_address() should
  be called before actual variable initialization.
  [ruby-dev:27986]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-12-12 00:36:54 +00:00
matz 35a84adff0 * test/dbm/test_dbm.rb: remove locking test, which may not be
supported on some platforms.  [ruby-dev:27030]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 15:23:54 +00:00
ocean dda5dc00cf * array.c: moved to ANSI function style from K&R function style.
(used protoize on windows, so still K&R remains on #ifdef part of
   other platforms. And  `foo _((boo))' stuff is still there)
   [ruby-dev:26975]

* bignum.c, class.c, compar.c, dir.c, dln.c, dmyext.c, enum.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c,
  io.c, main.c, marshal.c, math.c, numeric.c, object.c, pack.c,
  prec.c, process.c, random.c, range.c, re.c, regcomp.c, regenc.c,
  regerror.c, regexec.c, regparse.c, regparse.h, ruby.c, signal.c,
  sprintf.c, st.c, string.c, struct.c, time.c, util.h, variable.c,
  version.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-09-12 10:44:21 +00:00