about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2012-09-07 16:09:38 -0700
committerPatrick Walton <pcwalton@mimiga.net>2012-09-07 16:09:38 -0700
commit3078830934ba5596e7eac86825636b49451e40e3 (patch)
tree9fb865c4018544c30854ed70c5b0bf7f14afecf5 /src
parent1fcfee674a569b296d0da391af113a3776c749a1 (diff)
downloadrust-3078830934ba5596e7eac86825636b49451e40e3.tar.gz
rust-3078830934ba5596e7eac86825636b49451e40e3.zip
libcore: Make str_eq not break with coretest
Diffstat (limited to 'src')
-rw-r--r--src/libcore/str.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libcore/str.rs b/src/libcore/str.rs
index 003f2a888c1..ca96090ebd4 100644
--- a/src/libcore/str.rs
+++ b/src/libcore/str.rs
@@ -713,6 +713,7 @@ Section: Comparing strings
 */
 
 /// Bytewise slice equality
+#[cfg(notest)]
 #[lang="str_eq"]
 pure fn eq_slice(a: &str, b: &str) -> bool {
     do as_buf(a) |ap, alen| {
@@ -729,6 +730,22 @@ pure fn eq_slice(a: &str, b: &str) -> bool {
     }
 }
 
+#[cfg(test)]
+pure fn eq_slice(a: &str, b: &str) -> bool {
+    do as_buf(a) |ap, alen| {
+        do as_buf(b) |bp, blen| {
+            if (alen != blen) { false }
+            else {
+                unsafe {
+                    libc::memcmp(ap as *libc::c_void,
+                                 bp as *libc::c_void,
+                                 (alen - 1) as libc::size_t) == 0
+                }
+            }
+        }
+    }
+}
+
 /// Bytewise string equality
 pure fn eq(a: &~str, b: &~str) -> bool {
     eq_slice(*a, *b)