浏览代码

strcoll as strcmp because no locale

jD91mZM2 6 年之前
父节点
当前提交
878208485c
共有 2 个文件被更改,包括 12 次插入6 次删除
  1. 11 5
      src/string/src/lib.rs
  2. 1 1
      src/time/src/strftime.rs

+ 11 - 5
src/string/src/lib.rs

@@ -143,8 +143,9 @@ pub unsafe extern "C" fn strcmp(s1: *const c_char, s2: *const c_char) -> c_int {
 }
 
 // #[no_mangle]
-pub extern "C" fn strcoll(s1: *const c_char, s2: *const c_char) -> c_int {
-    unimplemented!();
+pub unsafe extern "C" fn strcoll(s1: *const c_char, s2: *const c_char) -> c_int {
+    // relibc has no locale stuff (yet)
+    strcmp(s1, s2)
 }
 
 #[no_mangle]
@@ -400,7 +401,12 @@ pub extern "C" fn strtok_r(
     }
 }
 
-// #[no_mangle]
-pub extern "C" fn strxfrm(s1: *mut c_char, s2: *const c_char, n: usize) -> size_t {
-    unimplemented!();
+#[no_mangle]
+pub unsafe extern "C" fn strxfrm(s1: *mut c_char, s2: *const c_char, n: usize) -> size_t {
+    // relibc has no locale stuff (yet)
+    let len = strlen(s2);
+    if len < n {
+        strcpy(s1, s2);
+    }
+    len
 }

+ 1 - 1
src/time/src/strftime.rs

@@ -84,7 +84,7 @@ pub unsafe fn strftime<W: Write>(
 
         format = format.offset(1);
 
-        if *format == b'E' || *format == b'O' {
+        if *format as u8 == b'E' || *format as u8 == b'O' {
             // Ignore because these do nothing without locale
             format = format.offset(1);
         }