@@ -33,18 +33,17 @@ impl io::Read for Stdin {
33
33
}
34
34
35
35
// Try reading any pending data
36
- let inp = read ( stdin) ?;
36
+ let inp = simple_text_input_read ( stdin) ?;
37
37
38
38
// Check if the key is printiable character
39
39
if inp == 0x00 {
40
40
return Err ( io:: const_io_error!( io:: ErrorKind :: Interrupted , "Special Key Press" ) ) ;
41
41
}
42
42
43
- // The option unwrap is safe since iterator will have 1 element.
44
- let ch: char = char:: decode_utf16 ( [ inp] )
45
- . next ( )
46
- . unwrap ( )
47
- . map_err ( |_| io:: const_io_error!( io:: ErrorKind :: InvalidInput , "Invalid Input" ) ) ?;
43
+ let Some ( Ok ( ch) ) = char:: decode_utf16 ( [ inp] ) . next ( ) else {
44
+ return Err ( io:: const_io_error!( io:: ErrorKind :: InvalidInput , "Invalid Input" ) ) ;
45
+ } ;
46
+
48
47
if ch. len_utf8 ( ) > buf. len ( ) {
49
48
self . pending = Some ( ch) ;
50
49
return Ok ( 0 ) ;
@@ -97,8 +96,8 @@ impl io::Write for Stderr {
97
96
// UCS-2 character should occupy 3 bytes at most in UTF-8
98
97
pub const STDIN_BUF_SIZE : usize = 3 ;
99
98
100
- pub fn is_ebadf ( err : & io:: Error ) -> bool {
101
- err . raw_os_error ( ) == Some ( r_efi :: efi :: Status :: UNSUPPORTED . as_usize ( ) )
99
+ pub fn is_ebadf ( _err : & io:: Error ) -> bool {
100
+ false
102
101
}
103
102
104
103
pub fn panic_output ( ) -> Option < impl io:: Write > {
@@ -116,6 +115,7 @@ fn write(
116
115
} ;
117
116
118
117
let mut utf16: Vec < u16 > = utf8. encode_utf16 ( ) . collect ( ) ;
118
+ // NULL terminate the string
119
119
utf16. push ( 0 ) ;
120
120
121
121
unsafe { simple_text_output ( protocol, & mut utf16) } ?;
@@ -131,7 +131,9 @@ unsafe fn simple_text_output(
131
131
if res. is_error ( ) { Err ( io:: Error :: from_raw_os_error ( res. as_usize ( ) ) ) } else { Ok ( ( ) ) }
132
132
}
133
133
134
- fn read ( stdin : * mut r_efi:: protocols:: simple_text_input:: Protocol ) -> io:: Result < u16 > {
134
+ fn simple_text_input_read (
135
+ stdin : * mut r_efi:: protocols:: simple_text_input:: Protocol ,
136
+ ) -> io:: Result < u16 > {
135
137
loop {
136
138
match read_key_stroke ( stdin) {
137
139
Ok ( x) => return Ok ( x. unicode_char ) ,
0 commit comments