Remove c_str functions, replace with CStr

This commit is contained in:
Jeremy Soller
2018-09-24 21:08:29 -06:00
parent ef9fee5a2b
commit 7f14fcdee0
8 changed files with 29 additions and 62 deletions
+3 -2
View File
@@ -15,7 +15,7 @@ use header::stdlib::mkstemp;
use header::string::strlen;
use platform;
use platform::types::*;
use platform::{c_str, errno, ReadByte, WriteByte};
use platform::{errno, ReadByte, WriteByte};
use platform::{Pal, Sys};
mod printf;
@@ -739,7 +739,8 @@ pub extern "C" fn pclose(_stream: &mut FILE) -> c_int {
#[no_mangle]
pub unsafe extern "C" fn perror(s: *const c_char) {
let s_str = str::from_utf8_unchecked(c_str(s));
let s_cstr = CStr::from_ptr(s);
let s_str = str::from_utf8_unchecked(s_cstr.to_bytes());
let mut w = platform::FileWriter(2);
if errno >= 0 && errno < STR_ERROR.len() as c_int {
+3 -1
View File
@@ -1,6 +1,7 @@
use core::fmt::Write as CoreWrite;
use core::{ptr, slice, str};
use c_str::CStr;
use platform::types::*;
use platform::{self, WriteByte};
use va_list::VaList;
@@ -62,7 +63,8 @@ pub unsafe fn printf<W: WriteByte>(w: W, format: *const c_char, mut ap: VaList)
found_percent = false;
if a != ptr::null() {
w.write_str(str::from_utf8_unchecked(platform::c_str(a)))
let a_cstr = CStr::from_ptr(a);
w.write_str(str::from_utf8_unchecked(a_cstr.to_bytes()))
} else {
w.write_str("NULL")
}