Skip to content
Snippets Groups Projects
Commit 230a1504 authored by Nicolás Antinori's avatar Nicolás Antinori
Browse files

cleanup

parent 47ed7a59
No related branches found
No related tags found
1 merge request!613wscanf and vwscanf implementation proposal
...@@ -115,11 +115,9 @@ impl<'a> From<&'a mut FILE> for LookAheadFile<'a> { ...@@ -115,11 +115,9 @@ impl<'a> From<&'a mut FILE> for LookAheadFile<'a> {
enum LookAheadReaderEnum<'a> { enum LookAheadReaderEnum<'a> {
FILE(LookAheadFile<'a>), FILE(LookAheadFile<'a>),
// (buffer, location)
BUFFER(LookAheadBuffer), BUFFER(LookAheadBuffer),
} }
// pub struct LookAheadReader(LookAheadBuffer);
pub struct LookAheadReader<'a>(LookAheadReaderEnum<'a>); pub struct LookAheadReader<'a>(LookAheadReaderEnum<'a>);
impl LookAheadReader<'_> { impl LookAheadReader<'_> {
...@@ -138,7 +136,7 @@ impl LookAheadReader<'_> { ...@@ -138,7 +136,7 @@ impl LookAheadReader<'_> {
} }
impl<'a> From<&'a mut FILE> for LookAheadReader<'a> { impl<'a> From<&'a mut FILE> for LookAheadReader<'a> {
fn from(f: &'a mut FILE) -> LookAheadReader { fn from(f: &'a mut FILE) -> LookAheadReader<'a> {
LookAheadReader(LookAheadReaderEnum::FILE(f.into())) LookAheadReader(LookAheadReaderEnum::FILE(f.into()))
} }
} }
......
...@@ -26,7 +26,7 @@ unsafe fn next_char(string: &mut *const wchar_t) -> Result<wint_t, c_int> { ...@@ -26,7 +26,7 @@ unsafe fn next_char(string: &mut *const wchar_t) -> Result<wint_t, c_int> {
let c = **string as wint_t; let c = **string as wint_t;
*string = string.offset(1); *string = string.offset(1);
if c == 0 { if c == 0 {
Err(-2) Err(-1)
} else { } else {
Ok(c) Ok(c)
} }
...@@ -34,10 +34,7 @@ unsafe fn next_char(string: &mut *const wchar_t) -> Result<wint_t, c_int> { ...@@ -34,10 +34,7 @@ unsafe fn next_char(string: &mut *const wchar_t) -> Result<wint_t, c_int> {
macro_rules! wc_as_char { macro_rules! wc_as_char {
($c:ident) => { ($c:ident) => {
char::try_from($c).map_err(|e| { char::try_from($c).map_err(|_| -1)?
println!("{:?}", e);
-3
})?
}; };
} }
...@@ -75,7 +72,7 @@ unsafe fn inner_scanf( ...@@ -75,7 +72,7 @@ unsafe fn inner_scanf(
(inner $($placeholder:expr)*) => { (inner $($placeholder:expr)*) => {
if !skip_read && !read!() { if !skip_read && !read!() {
match matched { match matched {
0 => return Ok(-4), 0 => return Ok(-1),
a => return Ok(a), a => return Ok(a),
} }
} }
...@@ -124,7 +121,7 @@ unsafe fn inner_scanf( ...@@ -124,7 +121,7 @@ unsafe fn inner_scanf(
} else { } else {
match width.parse::<usize>() { match width.parse::<usize>() {
Ok(n) => Some(n), Ok(n) => Some(n),
Err(_) => return Err(-5), Err(_) => return Err(-1),
} }
}; };
...@@ -496,7 +493,7 @@ unsafe fn inner_scanf( ...@@ -496,7 +493,7 @@ unsafe fn inner_scanf(
*ap.arg::<*mut c_int>() = count as c_int; *ap.arg::<*mut c_int>() = count as c_int;
} }
} }
_ => return Err(-6), _ => return Err(-1),
} }
if eof { if eof {
......
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