Changed object type of function pointers from Option<*const (Fn(...))> to Option<fn(...)> for readability
This commit is contained in:
@@ -20,7 +20,7 @@ static mut default_stdin: FILE = FILE {
|
||||
unget: UNGET,
|
||||
lock: AtomicBool::new(false),
|
||||
write: None,
|
||||
read: Some(&internal::stdio_read),
|
||||
read: Some(internal::stdio_read),
|
||||
seek: None,
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ static mut default_stdout: FILE = FILE {
|
||||
buf_char: b'\n' as i8,
|
||||
unget: 0,
|
||||
lock: AtomicBool::new(false),
|
||||
write: Some(&internal::stdio_write),
|
||||
write: Some(internal::stdio_write),
|
||||
read: None,
|
||||
seek: None,
|
||||
};
|
||||
@@ -63,7 +63,7 @@ static mut default_stderr: FILE = FILE {
|
||||
buf_char: -1,
|
||||
unget: 0,
|
||||
lock: AtomicBool::new(false),
|
||||
write: Some(&internal::stdio_write),
|
||||
write: Some(internal::stdio_write),
|
||||
read: None,
|
||||
seek: None,
|
||||
};
|
||||
|
||||
@@ -78,9 +78,9 @@ pub unsafe fn _fdopen(fd: c_int, mode: *const c_char) -> *mut FILE {
|
||||
buf_char: -1,
|
||||
unget: UNGET,
|
||||
lock: AtomicBool::new(false),
|
||||
write: Some(&internal::stdio_write),
|
||||
read: Some(&internal::stdio_read),
|
||||
seek: Some(&internal::stdio_seek),
|
||||
write: Some(internal::stdio_write),
|
||||
read: Some(internal::stdio_read),
|
||||
seek: Some(internal::stdio_seek),
|
||||
};
|
||||
file
|
||||
}
|
||||
@@ -97,7 +97,7 @@ pub unsafe fn fwritex(buf: *const u8, l: size_t, stream: *mut FILE) -> size_t {
|
||||
}
|
||||
if l > (*stream).wend as usize - (*stream).wpos as usize {
|
||||
// We can't fit all of buf in the buffer
|
||||
return (*stream_write)(stream, buf, l);
|
||||
return stream_write(stream, buf, l);
|
||||
}
|
||||
|
||||
let i = if (*stream).buf_char >= 0 {
|
||||
@@ -106,7 +106,7 @@ pub unsafe fn fwritex(buf: *const u8, l: size_t, stream: *mut FILE) -> size_t {
|
||||
i -= 1;
|
||||
}
|
||||
if i > 0 {
|
||||
let n = (*stream_write)(stream, buf, i);
|
||||
let n = stream_write(stream, buf, i);
|
||||
if n < i {
|
||||
return n;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ pub unsafe fn fwritex(buf: *const u8, l: size_t, stream: *mut FILE) -> size_t {
|
||||
pub unsafe fn fflush_unlocked(stream: *mut FILE) -> c_int {
|
||||
if (*stream).wpos > (*stream).wbase {
|
||||
if let Some(f) = (*stream).write {
|
||||
(*f)(stream, ptr::null(), 0);
|
||||
f(stream, ptr::null(), 0);
|
||||
if (*stream).wpos.is_null() {
|
||||
return -1;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ pub unsafe fn fflush_unlocked(stream: *mut FILE) -> c_int {
|
||||
|
||||
if (*stream).rpos < (*stream).rend {
|
||||
if let Some(s) = (*stream).seek {
|
||||
(*s)(
|
||||
s(
|
||||
stream,
|
||||
(*stream).rpos as i64 - (*stream).rend as i64,
|
||||
SEEK_CUR,
|
||||
|
||||
@@ -83,7 +83,7 @@ pub unsafe fn to_read(stream: *mut FILE) -> bool {
|
||||
|
||||
if (*stream).wpos > (*stream).wbase {
|
||||
if let Some(f) = (*stream).write {
|
||||
(*f)(stream, ptr::null(), 0);
|
||||
f(stream, ptr::null(), 0);
|
||||
}
|
||||
}
|
||||
(*stream).wpos = ptr::null_mut();
|
||||
@@ -123,7 +123,7 @@ pub unsafe fn to_write(stream: *mut FILE) -> bool {
|
||||
|
||||
pub unsafe fn ftello(stream: *mut FILE) -> off_t {
|
||||
if let Some(s) = (*stream).seek {
|
||||
let pos = (*s)(
|
||||
let pos = s(
|
||||
stream,
|
||||
0,
|
||||
if ((*stream).flags & constants::F_APP > 0) && (*stream).wpos > (*stream).wbase {
|
||||
|
||||
@@ -50,9 +50,9 @@ pub struct FILE {
|
||||
buf_char: i8,
|
||||
lock: AtomicBool,
|
||||
unget: size_t,
|
||||
write: Option<*const (Fn(*mut FILE, *const u8, usize) -> size_t)>,
|
||||
read: Option<*const (Fn(*mut FILE, *mut u8, usize) -> size_t)>,
|
||||
seek: Option<*const (Fn(*mut FILE, off_t, c_int) -> off_t)>,
|
||||
write: Option<(fn(*mut FILE, *const u8, usize) -> size_t)>,
|
||||
read: Option<(fn(*mut FILE, *mut u8, usize) -> size_t)>,
|
||||
seek: Option<(fn(*mut FILE, off_t, c_int) -> off_t)>,
|
||||
}
|
||||
|
||||
/// Clears EOF and ERR indicators on a stream
|
||||
@@ -291,7 +291,7 @@ pub unsafe extern "C" fn fread(
|
||||
0
|
||||
} else {
|
||||
if let Some(f) = (*stream).read {
|
||||
(*f)(stream, dest, l as usize)
|
||||
f(stream, dest, l as usize)
|
||||
} else {
|
||||
0
|
||||
}
|
||||
@@ -378,7 +378,7 @@ pub unsafe extern "C" fn fseeko(stream: *mut FILE, offset: off_t, whence: c_int)
|
||||
}
|
||||
if (*stream).wpos > (*stream).wbase {
|
||||
if let Some(f) = (*stream).write {
|
||||
(*f)(stream, ptr::null(), 0);
|
||||
f(stream, ptr::null(), 0);
|
||||
if (*stream).wpos.is_null() {
|
||||
return -1;
|
||||
}
|
||||
@@ -388,7 +388,7 @@ pub unsafe extern "C" fn fseeko(stream: *mut FILE, offset: off_t, whence: c_int)
|
||||
(*stream).wend = ptr::null_mut();
|
||||
(*stream).wbase = ptr::null_mut();
|
||||
if let Some(s) = (*stream).seek {
|
||||
if (*s)(stream, off, whence) < 0 {
|
||||
if s(stream, off, whence) < 0 {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
@@ -481,7 +481,7 @@ pub unsafe extern "C" fn getc_unlocked(stream: *mut FILE) -> c_int {
|
||||
} else {
|
||||
if let Some(read) = (*stream).read {
|
||||
let mut c = 0u8;
|
||||
if !internal::to_read(stream) && (*read)(stream, &mut c, 1) == 1 {
|
||||
if !internal::to_read(stream) && read(stream, &mut c, 1) == 1 {
|
||||
c as c_int
|
||||
} else {
|
||||
-1
|
||||
@@ -575,7 +575,7 @@ pub unsafe extern "C" fn putc_unlocked(c: c_int, stream: *mut FILE) -> c_int {
|
||||
*(*stream).wpos = c as u8;
|
||||
(*stream).wpos = (*stream).wpos.add(1);
|
||||
c
|
||||
} else if (*write)(stream, &c as *const i32 as *const _, 1) != 1 {
|
||||
} else if write(stream, &c as *const i32 as *const _, 1) != 1 {
|
||||
-1
|
||||
} else {
|
||||
c
|
||||
|
||||
Reference in New Issue
Block a user