瀏覽代碼

* fix test case a bit
* remove unnecessary cast

Timothy Bess 7 年之前
父節點
當前提交
898cf98ccc
共有 3 個文件被更改,包括 6 次插入4 次删除
  1. 1 1
      src/string/src/lib.rs
  2. 1 1
      tests/expected/string/strtok.stdout
  3. 4 2
      tests/string/strtok.c

+ 1 - 1
src/string/src/lib.rs

@@ -344,7 +344,7 @@ pub extern "C" fn strtok(s1: *mut c_char, delimiter: *const c_char) -> *mut c_ch
         let token = HAYSTACK;
         HAYSTACK = strpbrk(token, delimiter);
         if !HAYSTACK.is_null() {
-            HAYSTACK.write(0 as c_char);
+            HAYSTACK.write(0);
             HAYSTACK = HAYSTACK.add(1);
         } else {
             HAYSTACK = ptr::null_mut();

+ 1 - 1
tests/expected/string/strtok.stdout

@@ -1,2 +1,2 @@
 I'd_just_like_to_interject_for_a_moment.__What_you're_referring_to_as_Linux,
-is_in_fact,_GNU/Linux,_or_as_I've_recently_taken_to_calling_it,_GNU_plus_Linux.
+is_in_fact,_GNU/Linux,_or_as_I've_recently_taken_to_calling_it,_GNU_plus_Linux.

+ 4 - 2
tests/string/strtok.c

@@ -7,8 +7,10 @@ int main(int argc, char* argv[]) {
 
     char* token = strtok(source, " ");
     while (token) {
-        printf("%s_", token);
-        token = strtok(NULL, " ");
+        printf("%s", token);
+        if (token = strtok(NULL, " ")) {
+            printf("_");
+        }
     }
 
     return 0;