mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 08:33:58 +02:00
* parse.y (string_content): turn off NODE_NEWLINE flag to avoid
unnecessary line trace for inlined expression. (ruby-bugs PR#1320) * numeric.c (flo_to_s): tweak output string based to preserve decimal point and to remove trailing zeros. [ruby-talk:97891] * string.c (rb_str_index_m): use unsigned comparison for T_FIXNUM search. [ruby-talk:97342] * hash.c (rb_hash_equal): returns true if two hashes have same set of key-value set. [ruby-talk:97559] * hash.c (rb_hash_eql): returns true if two hashes are equal and have same default values. * string.c (rb_str_equal): always returns true or false, never returns nil. [ruby-dev:23404] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c4216a26e2
commit
1b0f90ca33
22 changed files with 272 additions and 111 deletions
10
string.c
10
string.c
|
@ -888,7 +888,7 @@ rb_str_equal(str1, str2)
|
|||
if (str1 == str2) return Qtrue;
|
||||
if (TYPE(str2) != T_STRING) {
|
||||
if (!rb_respond_to(str2, rb_intern("to_str"))) {
|
||||
return Qnil;
|
||||
return Qfalse;
|
||||
}
|
||||
return rb_equal(str2, str1);
|
||||
}
|
||||
|
@ -1080,7 +1080,7 @@ rb_str_index_m(argc, argv, str)
|
|||
{
|
||||
int c = FIX2INT(sub);
|
||||
long len = RSTRING(str)->len;
|
||||
char *p = RSTRING(str)->ptr;
|
||||
unsigned char *p = RSTRING(str)->ptr;
|
||||
|
||||
for (;pos<len;pos++) {
|
||||
if (p[pos] == c) return LONG2NUM(pos);
|
||||
|
@ -1202,15 +1202,15 @@ rb_str_rindex_m(argc, argv, str)
|
|||
case T_FIXNUM:
|
||||
{
|
||||
int c = FIX2INT(sub);
|
||||
char *p = RSTRING(str)->ptr + pos;
|
||||
char *pbeg = RSTRING(str)->ptr;
|
||||
unsigned char *p = RSTRING(str)->ptr + pos;
|
||||
unsigned char *pbeg = RSTRING(str)->ptr;
|
||||
|
||||
if (pos == RSTRING(str)->len) {
|
||||
if (pos == 0) return Qnil;
|
||||
--p;
|
||||
}
|
||||
while (pbeg <= p) {
|
||||
if (*p == c) return LONG2NUM(p - RSTRING(str)->ptr);
|
||||
if (*p == c) return LONG2NUM((char*)p - RSTRING(str)->ptr);
|
||||
p--;
|
||||
}
|
||||
return Qnil;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue