diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-04-07 10:18:09 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-04-07 10:18:09 +0000 |
commit | 9c855a83f2c34ecf0e2f448d2213a6b091cdce95 (patch) | |
tree | a84a7001c1181e38c72155e5d1fd8e8929e5a6a7 /string.c | |
parent | 63b3f1b482c823bb599eb02f9c6716095a5705ec (diff) |
Array#cmp
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -482,9 +482,11 @@ str_cmp(str1, str2) len = min(RSTRING(str1)->len, RSTRING(str2)->len); retval = memcmp(RSTRING(str1)->ptr, RSTRING(str2)->ptr, len); if (retval == 0) { - return RSTRING(str1)->ptr[len] - RSTRING(str2)->ptr[len]; + retval = RSTRING(str1)->ptr[len] - RSTRING(str2)->ptr[len]; } - return retval; + if (retval == 0) return 0; + if (retval > 0) return 1; + return -1; } static VALUE |