8
8
mod flags;
9
9
10
10
use clap:: { Arg , ArgAction , ArgMatches , Command } ;
11
- use nix:: libc:: { c_ushort , O_NONBLOCK , TIOCGWINSZ , TIOCSWINSZ } ;
11
+ use nix:: libc:: { O_NONBLOCK , TIOCGWINSZ , TIOCSWINSZ , c_ushort } ;
12
12
use nix:: sys:: termios:: {
13
- cfgetospeed , cfsetospeed , tcgetattr , tcsetattr , ControlFlags , InputFlags , LocalFlags ,
14
- OutputFlags , SpecialCharacterIndices , Termios ,
13
+ ControlFlags , InputFlags , LocalFlags , OutputFlags , SpecialCharacterIndices , Termios ,
14
+ cfgetospeed , cfsetospeed , tcgetattr , tcsetattr ,
15
15
} ;
16
16
use nix:: { ioctl_read_bad, ioctl_write_ptr_bad} ;
17
17
use std:: fs:: File ;
18
- use std:: io:: { self , stdout , Stdout } ;
18
+ use std:: io:: { self , Stdout , stdout } ;
19
19
use std:: ops:: ControlFlow ;
20
20
use std:: os:: fd:: { AsFd , BorrowedFd } ;
21
21
use std:: os:: unix:: fs:: OpenOptionsExt ;
@@ -224,7 +224,9 @@ fn stty(opts: &Options) -> UResult<()> {
224
224
ControlCharMappingError :: IntOutOfRange => {
225
225
return Err ( USimpleError :: new (
226
226
1 ,
227
- format ! ( "invalid integer argument: '{new_cc}': Numerical result out of range" ) ,
227
+ format ! (
228
+ "invalid integer argument: '{new_cc}': Numerical result out of range"
229
+ ) ,
228
230
) ) ;
229
231
}
230
232
ControlCharMappingError :: MultipleChars => {
@@ -530,7 +532,6 @@ fn string_to_control_char(s: &str) -> Result<u8, ControlCharMappingError> {
530
532
return Ok ( 0 ) ;
531
533
}
532
534
533
- // check if the number is greater than 255, return ControlCharMappingError::IntOutOfRange
534
535
// try to parse integer (hex, octal, or decimal)
535
536
let mut ascii_num: Option < u32 > = None ;
536
537
if let Some ( hex) = s. strip_prefix ( "0x" ) {
@@ -556,7 +557,7 @@ fn string_to_control_char(s: &str) -> Result<u8, ControlCharMappingError> {
556
557
if c == '?' {
557
558
return Ok ( ASCII_DEL ) ;
558
559
}
559
- // subract by '@' to turn the char into the ascii value of '^<char>'
560
+ // subtract by '@' to turn the char into the ascii value of '^<char>'
560
561
Ok ( ( c. to_ascii_uppercase ( ) as u8 ) . wrapping_sub ( b'@' ) )
561
562
}
562
563
( Some ( c) , None ) => Ok ( c as u8 ) ,
0 commit comments