Skip to content
Snippets Groups Projects
Verified Commit 53a03cb0 authored by Tom Almeida's avatar Tom Almeida
Browse files

Made sure errors were properly handled by printf

parent 8bc07abd
No related branches found
No related tags found
No related merge requests found
...@@ -15,7 +15,7 @@ pub unsafe fn printf<W: Write>(mut w: W, format: *const c_char, mut ap: VaList) ...@@ -15,7 +15,7 @@ pub unsafe fn printf<W: Write>(mut w: W, format: *const c_char, mut ap: VaList)
} }
if found_percent { if found_percent {
match b as char { if match b as char {
'%' => { '%' => {
found_percent = false; found_percent = false;
w.write_char('%') w.write_char('%')
...@@ -97,11 +97,15 @@ pub unsafe fn printf<W: Write>(mut w: W, format: *const c_char, mut ap: VaList) ...@@ -97,11 +97,15 @@ pub unsafe fn printf<W: Write>(mut w: W, format: *const c_char, mut ap: VaList)
'#' => Ok(()), '#' => Ok(()),
'0'...'9' => Ok(()), '0'...'9' => Ok(()),
_ => Ok(()), _ => Ok(()),
}.map_err(|_| return -1).unwrap() }.is_err() {
return -1;
}
} else if b == b'%' { } else if b == b'%' {
found_percent = true; found_percent = true;
} else { } else {
w.write_u8(b).map_err(|_| return -1).unwrap() if w.write_u8(b).is_err() {
return -1;
}
} }
} }
......
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