survivor

graphical action game for the linux terminal
git clone https://git.ce9e.org/survivor.git

commit
65ff1510e436d94fc304d5054ce62c0e9e350888
parent
c896a144668c4e27a4ab8074179f911c9565656f
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-02-21 21:37
portable: do not assume struct fields on initialization

Diffstat

M src/input.rs 12 ++----------
M src/term.rs 8 ++------

2 files changed, 4 insertions, 16 deletions


diff --git a/src/input.rs b/src/input.rs

@@ -8,17 +8,9 @@ pub struct Input {
    8     8 
    9     9 impl Input {
   10    10     pub fn new() -> Self {
   11    -1         let mut t = libc::termios {
   12    -1             c_iflag: 0,
   13    -1             c_oflag: 0,
   14    -1             c_cflag: 0,
   15    -1             c_lflag: 0,
   16    -1             c_line: 0,
   17    -1             c_cc: [0; 32],
   18    -1             c_ispeed: 0,
   19    -1             c_ospeed: 0,
   20    -1         };
   -1    11         let mut t: libc::termios;
   21    12         unsafe {
   -1    13             t = std::mem::zeroed();
   22    14             libc::tcgetattr(0, &mut t);
   23    15         }
   24    16 

diff --git a/src/term.rs b/src/term.rs

@@ -1,13 +1,9 @@
    1     1 extern crate libc;
    2     2 
    3     3 fn get_terminal_size() -> (usize, usize) {
    4    -1     let w: libc::winsize = libc::winsize {
    5    -1         ws_col: 0,
    6    -1         ws_row: 0,
    7    -1         ws_ypixel: 0,
    8    -1         ws_xpixel: 0,
    9    -1     };
   -1     4     let w: libc::winsize;
   10     5     unsafe {
   -1     6         w = std::mem::zeroed();
   11     7         libc::ioctl(1, libc::TIOCGWINSZ, &w);
   12     8     }
   13     9     return (w.ws_col as usize, w.ws_row as usize);