Skip to content
Snippets Groups Projects
Commit 49be92f8 authored by Tom Almeida's avatar Tom Almeida
Browse files

ran fmt.sh cause I'm an idiot

parent 8374fcb4
No related branches found
No related tags found
1 merge request!63Implemented fputc, fputs, and puts
...@@ -105,7 +105,9 @@ pub extern "C" fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FI ...@@ -105,7 +105,9 @@ pub extern "C" fn fopen(filename: *const c_char, mode: *const c_char) -> *mut FI
#[no_mangle] #[no_mangle]
pub extern "C" fn fputc(c: c_int, stream: *mut FILE) -> c_int { pub extern "C" fn fputc(c: c_int, stream: *mut FILE) -> c_int {
platform::FileWriter(stream as c_int).write_char(c as u8 as char).map_err(|_| return -1); platform::FileWriter(stream as c_int)
.write_char(c as u8 as char)
.map_err(|_| return -1);
c c
} }
...@@ -114,12 +116,14 @@ pub unsafe extern "C" fn fputs(s: *const c_char, stream: *mut FILE) -> c_int { ...@@ -114,12 +116,14 @@ pub unsafe extern "C" fn fputs(s: *const c_char, stream: *mut FILE) -> c_int {
extern "C" { extern "C" {
fn strlen(s: *const c_char) -> size_t; fn strlen(s: *const c_char) -> size_t;
} }
use core::{ str, slice }; use core::{slice, str};
let len = strlen(s); let len = strlen(s);
platform::FileWriter(stream as c_int).write_str(str::from_utf8_unchecked(slice::from_raw_parts( platform::FileWriter(stream as c_int)
s as *const u8, .write_str(str::from_utf8_unchecked(slice::from_raw_parts(
len, s as *const u8,
))).map_err(|_| return -1); len,
)))
.map_err(|_| return -1);
len as i32 len as i32
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment