summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-06 05:32:37 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-06 05:32:37 +0000
commit6845578c926de256ee158652a4563f185fa6fec9 (patch)
tree2974c65502810a03e0e6a6e0486031358d49a85e
parentbd00bb3ef75b469a83a8eac6995bb6800a22c15a (diff)
* insns.def (opt_eq): get rid of gcc bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--include/ruby/intern.h2
-rw-r--r--insns.def22
-rw-r--r--re.c2
-rw-r--r--string.c14
5 files changed, 25 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index ff24493262..4f554f4691 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Oct 6 14:32:30 2007 U-nobu-PC\nobu <nobu@ruby-lang.org>
+
+ * insns.def (opt_eq): get rid of gcc bug.
+
Sat Oct 6 02:34:18 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* include/ruby/defines.h: no longer provide DEFAULT_KCODE.
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 500ec6a358..8c39e2a6bd 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -442,7 +442,7 @@ VALUE rb_range_beg_len(VALUE, long*, long*, long, int);
unsigned long genrand_int32(void);
double genrand_real(void);
/* re.c */
-int rb_memcmp(const void*,const void*,long);
+#define rb_memcmp memcmp
int rb_memcicmp(const void*,const void*,long);
long rb_memsearch(const void*,long,const void*,long);
VALUE rb_reg_nth_defined(int, VALUE);
diff --git a/insns.def b/insns.def
index 3cf8e4d67f..d5a6fe7b63 100644
--- a/insns.def
+++ b/insns.def
@@ -1697,18 +1697,18 @@ opt_eq
VALUE str1 = recv;
VALUE str2 = obj;
- if (str1 == str2) {
- val = Qtrue;
- }
- else if (!ENCODING_GET(str1) && !ENCODING_GET(str2) &&
- RSTRING_LEN(str1) == RSTRING_LEN(str2) &&
- rb_memcmp(RSTRING_PTR(str1), RSTRING_PTR(str2),
- RSTRING_LEN(str1)) == 0) {
- val = Qtrue;
- }
- else {
+ val = Qtrue;
+ do {
+ if (str1 == str2) break;
+ if (!ENCODING_GET(str1) && !ENCODING_GET(str2)) {
+ if (RSTRING_LEN(str1) == RSTRING_LEN(str2)) {
+ int cmp = memcmp(RSTRING_PTR(str1), RSTRING_PTR(str2),
+ RSTRING_LEN(str1));
+ if (!cmp) break;
+ }
+ }
val = rb_str_equal(str1, str2);
- }
+ } while (0);
}
else {
goto INSN_LABEL(normal_dispatch);
diff --git a/re.c b/re.c
index 93ab6b869e..12dad39109 100644
--- a/re.c
+++ b/re.c
@@ -91,6 +91,8 @@ rb_memcicmp(const void *x, const void *y, long len)
return 0;
}
+#undef rb_memcmp
+
int
rb_memcmp(const void *p1, const void *p2, long len)
{
diff --git a/string.c b/string.c
index 67ea574015..985c427786 100644
--- a/string.c
+++ b/string.c
@@ -1226,7 +1226,7 @@ rb_str_cmp(VALUE str1, VALUE str2)
rb_enc_check(str1, str2); /* xxxx error-less encoding check? */
len = lesser(RSTRING_LEN(str1), RSTRING_LEN(str2));
- retval = rb_memcmp(RSTRING_PTR(str1), RSTRING_PTR(str2), len);
+ retval = memcmp(RSTRING_PTR(str1), RSTRING_PTR(str2), len);
if (retval == 0) {
if (RSTRING_LEN(str1) == RSTRING_LEN(str2)) return 0;
if (RSTRING_LEN(str1) > RSTRING_LEN(str2)) return 1;
@@ -1485,7 +1485,7 @@ rb_str_rindex(VALUE str, VALUE sub, long pos)
t = RSTRING_PTR(sub);
for (;;) {
s = str_nth(sbeg, e, pos, enc);
- if (rb_memcmp(s, t, slen) == 0) {
+ if (memcmp(s, t, slen) == 0) {
return pos;
}
if (pos == 0) break;
@@ -4090,7 +4090,7 @@ rb_str_each_line(int argc, VALUE *argv, VALUE str)
p -= n;
}
if (c == newline &&
- (rslen <= 1 || rb_memcmp(RSTRING_PTR(rs), p, rslen) == 0)) {
+ (rslen <= 1 || memcmp(RSTRING_PTR(rs), p, rslen) == 0)) {
line = rb_str_new5(str, s, p - s + (rslen ? rslen : n));
OBJ_INFECT(line, str);
rb_yield(line);
@@ -4325,7 +4325,7 @@ rb_str_chomp_bang(int argc, VALUE *argv, VALUE str)
if (p[len-1] == newline &&
(rslen <= 1 ||
- rb_memcmp(RSTRING_PTR(rs), p+len-rslen, rslen) == 0)) {
+ memcmp(RSTRING_PTR(rs), p+len-rslen, rslen) == 0)) {
rb_str_modify(str);
STR_SET_LEN(str, RSTRING_LEN(str) - rslen);
RSTRING_PTR(str)[RSTRING_LEN(str)] = '\0';
@@ -5064,7 +5064,7 @@ rb_str_start_with(int argc, VALUE *argv, VALUE str)
if (NIL_P(tmp)) continue;
rb_enc_check(str, tmp);
if (RSTRING_LEN(str) < RSTRING_LEN(tmp)) continue;
- if (rb_memcmp(RSTRING_PTR(str), RSTRING_PTR(tmp), RSTRING_LEN(tmp)) == 0)
+ if (memcmp(RSTRING_PTR(str), RSTRING_PTR(tmp), RSTRING_LEN(tmp)) == 0)
return Qtrue;
}
return Qfalse;
@@ -5087,8 +5087,8 @@ rb_str_end_with(int argc, VALUE *argv, VALUE str)
if (NIL_P(tmp)) continue;
rb_enc_check(str, tmp);
if (RSTRING_LEN(str) < RSTRING_LEN(tmp)) continue;
- if (rb_memcmp(RSTRING_PTR(str) + RSTRING_LEN(str) - RSTRING_LEN(tmp),
- RSTRING_PTR(tmp), RSTRING_LEN(tmp)) == 0)
+ if (memcmp(RSTRING_PTR(str) + RSTRING_LEN(str) - RSTRING_LEN(tmp),
+ RSTRING_PTR(tmp), RSTRING_LEN(tmp)) == 0)
return Qtrue;
}
return Qfalse;