summaryrefslogtreecommitdiff
path: root/compar.c
AgeCommit message (Collapse)Author
2019-12-26decouple 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). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-23[DOC] Improve readability of requirements for <=>Marcus Stollsteimer
2019-10-26Raise on end-exclusive ranges [Feature #14784]Nobuyoshi Nakada
Raises an error on end-exclusive ranges unless endless, regardless the receiver. Notes: Merged: https://github.com/ruby/ruby/pull/2613
2019-10-25Fixed range argument condition [Feature #14784]Nobuyoshi Nakada
Allows a beginless/endless range, and an end-exclusive range unless the receiver is smaller than its end. Notes: Merged: https://github.com/ruby/ruby/pull/2611
2019-10-16Comparable#clamp with a range [Feature #14784]Nobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/2556
2019-10-15[DOC] fixed a variable name [ci skip]Nobuyoshi Nakada
replaced "anObject" with "obj". also marked up with simple `_`s instead of `<i>`.
2019-04-22Clarify requirements of <=>Shugo Maeda
A return value of <=> is automatically converted to -1, 0, or 1, so other values can be returned. [Misc #15630]
2019-03-22[DOC] fix markups [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-08-11Comparable#clampnobu
* 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-11compar.c: utility functionsnobu
* 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
2015-12-15* compar.c: Update doc for == [#7688] [ci-skip]marcandre
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-21compar.c: variable name [ci skip]nobu
* 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-11* compar.c (cmp_equal): no more error hiding for Comparable#==.eregon
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-01-13compar.c: fix messagenobu
* 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
2014-08-21compar.c: use Module#to_snobu
* 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-19compar.c: preserve encodingsnobu
* 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-01-18* compar.c (cmp_equal): warn for this release and still rescueeregon
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-05* compar.c (cmp_equal): remove error hiding in Comparable#==.eregon
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
2013-12-28* compar.c (cmp_eq_recursive): Fix the return value, the value foreregon
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-10-09compar.c: fail if recursionnobu
* 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-05-06* compar.c (Comparable#==): fix typo.eregon
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-02-17compar.c: inversed comarison without infinite recursionnobu
* 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-07* compar.c (cmp_equal): Document ignored exception and return falsezzak
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
2010-05-17* array.c: Documentation: change => in call-seq to ->.marcandre
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
2009-10-28* string.c: rdoc for <=>, casecmpmarcandre
* 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-02-22stripped trailing spaces.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16* include/ruby/ruby.h (rb_intern_const): tiny optimization.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09* include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.nobu
* *.c: no cache in init functions. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-06* bignum.c (rb_cmpint): moved from compar.c, to check bignummatz
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-01-06* $Date$ keyword removed to avoid inclusion of locale dependentakr
string. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-01* include/ruby/ruby.h (struct RBignum): embed digits in RBignum forakr
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-08-25* encoding.c: provide basic features for M17N.matz
* 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-06-10* include/ruby: moved public headers.nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-12-12* ext/digest/digest.c (rb_digest_base_s_digest): add volatile tomatz
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-09-12* test/dbm/test_dbm.rb: remove locking test, which may not bematz
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* array.c: moved to ANSI function style from K&R function style.ocean
(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
2004-06-22Remove explicit NIL_P() checks since rb_cmpint() does it again in the ↵michal
exactly same manner. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-12-19Fix dependency issuedave
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-10-30031031matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-19* ext/pty/pty.c (pty_finalize_syswait): join (using Thread#value)matz
before detach pid. [ruby-talk:71519] * eval.c (PUSH_FRAME): save outer ruby_block. [ruby-list:37677], [ruby-dev:20202] * eval.c (BEGIN_CALLARGS): restore outer block by using ruby_block->outer. * eval.c (block_pass): do not alter block->prev, but block->outer. * array.c (get_inspect_tbl): warning on wrong condition. * eval.c (localjump_xvalue): renamed exitstatus to exit_value since it's not exit "status" after all. * eval.c (localjump_error): add reason to LocalJumpError. * compar.c (rb_cmpint): raise error via rb_cmperr(), if cmp value is nil. now take new 2 arguments. * time.c (time_cmp): 2003-05-16 fix was incomplete. (ruby-bugs-ja:PR#458) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-08* compar.c (rb_cmperr): raise comparison failure.nobu
* intern.h: prototype; rb_cmperr * numeric.c (flo_gt, flo_ge, flo_lt, flo_le, fix_gt, fix_ge, fix_lt, fix_le): should fail unless the argument is comparable. (ruby-bugs-ja:PR#456) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3768 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-05-02* compar.c (cmp_gt): raises ArgumentError when "<=>" give nil.matz
inspired by discussion on comp.lang.python. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-20* string.c (rb_str_cmp_m): return nil if str2 does not respond tomatz
both "to_str" and "<=>". * compar.c (cmp_gt): return nil if "<=>" returns nil (means incomparable). * compar.c (cmp_ge): ditto. * compar.c (cmp_lt): ditto. * compar.c (cmp_between): use RTEST(), since cmp_lt and cmp_gt may return nil. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3517 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-02-13* range.c (range_step): step might be float 0 < x < 1.matz
* eval.c (rb_thread_schedule): pause if no runnable thread when there's only one thread. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3492 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-01-16Updated Copyrights of Matz to 2003.michal
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-11-22* file.c (rb_find_file_ext): should not terminate searching withmatz
empty path, just ignore. * dir.c: remove <sys/parm.h> inclusion. * compar.c (cmp_eq,cmp_gt,cmp_ge,cmp_lt,cmp_le): check using rb_cmpint(). * error.c (init_syserr): remove sys_nerr dependency. * numeric.c (num_cmp): added to satisfy Comparable assumption. * eval.c (rb_add_method): "initialize" should be public if it is a singleton method. * regex.c (re_match): avoid dereferencing if size == 0. (ruby-bugs-ja:PR#360) * time.c (time_cmp): should return nil if an operand is not a number nor time. (ruby-bugs-ja:PR#359) * file.c (rb_stat_cmp): should return nil if an operand is not File::Stat. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-09-03 * variable.c (rb_copy_generic_ivar): remove old generic instancematz
variable table if it existes. * class.c (rb_make_metaclass): metaclass of a metaclass is a metaclass itself. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-05-22minor bug fixes.matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-05-21* object.c (Init_Object): should do exact match for Module#==.matz
* compar.c (cmp_eq): returns 'false' if <=> returns 'nil'. * compar.c (cmp_gt,cmp_ge,cmp_lt,cmp_le,cmp_between): ditto. * pack.c (pack_pack): should propagate taintedness. * pack.c (pack_unpack): ditto. * eval.c (rb_thread_schedule): need to preserve errno before calling rb_trap_exec(). * regex.c (calculate_must_string): a bug in charset/charset_not parsing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2002-04-18* re.c (rb_reg_expr_str): should treat backslash specially inmatz
escaping. * io.c: complete off_t handling; missing argument for fptr_finalize(); polished rb_scan_args call. * dir.c: wrap multi-statment macro by do { } while (0) * eval.c, numeric,c, sprintf.c, util.c: ditto. * bignum.c (rb_big_eq): check `y == x' if y is neither Fixnum, Bignum, nor Float. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2382 b2dd03c8-39d4-4d8f-98ff-823fe69b080e