summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'string.c')
-rw-r--r--string.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/string.c b/string.c
index 17f31b085d..1d3cdadc7c 100644
--- a/string.c
+++ b/string.c
@@ -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