0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

Remove unnecessary macro from cli/ops/tty.rs (#4254)

It contains a clippy issue, and there's no need for this macro anyway.
This commit is contained in:
Bert Belder 2020-03-04 15:52:08 -08:00
parent a1b98e9e6a
commit 5d3dfa4cf6
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461

View file

@ -39,17 +39,6 @@ pub fn init(i: &mut Isolate, s: &State) {
i.register_op("op_isatty", s.core_op(json_op(s.stateful_op(op_isatty))));
}
#[cfg(windows)]
macro_rules! wincheck {
($funcall:expr) => {{
let rc = unsafe { $funcall };
if rc == 0 {
Err(OpError::from(std::io::Error::last_os_error()))?;
}
rc
}};
}
#[derive(Deserialize)]
struct SetRawArgs {
rid: u32,
@ -73,6 +62,7 @@ pub fn op_set_raw(
#[cfg(windows)]
{
use std::os::windows::io::AsRawHandle;
use winapi::shared::minwindef::FALSE;
use winapi::um::{consoleapi, handleapi};
let state = state_.borrow_mut();
@ -100,13 +90,19 @@ pub fn op_set_raw(
return Err(OpError::other("null handle".to_owned()));
}
let mut original_mode: DWORD = 0;
wincheck!(consoleapi::GetConsoleMode(handle, &mut original_mode));
if unsafe { consoleapi::GetConsoleMode(handle, &mut original_mode) }
== FALSE
{
return Err(OpError::from(std::io::Error::last_os_error()));
}
let new_mode = if is_raw {
original_mode & !RAW_MODE_MASK
} else {
original_mode | RAW_MODE_MASK
};
wincheck!(consoleapi::SetConsoleMode(handle, new_mode));
if unsafe { consoleapi::SetConsoleMode(handle, new_mode) } == FALSE {
return Err(OpError::from(std::io::Error::last_os_error()));
}
Ok(JsonOp::Sync(json!({})))
}