Skip to content

Commit

Permalink
The terminfo database uses i16 but ncurses uses c_int for variables.
Browse files Browse the repository at this point in the history
We're just going to use i32 as this doesn't appear to be documented
anywhere and c_int is 32bits on most platforms.
  • Loading branch information
Stebalien committed Nov 24, 2015
1 parent 99696e5 commit 031b0eb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/terminfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,15 @@ impl<T: Write+Send> Terminal for TerminfoTerminal<T> {
fn fg(&mut self, color: color::Color) -> io::Result<bool> {
let color = self.dim_if_necessary(color);
if self.num_colors > color {
return self.apply_cap("setaf", &[Param::Number(color as i16)]);
return self.apply_cap("setaf", &[Param::Number(color as i32)]);
}
Ok(false)
}

fn bg(&mut self, color: color::Color) -> io::Result<bool> {
let color = self.dim_if_necessary(color);
if self.num_colors > color {
return self.apply_cap("setab", &[Param::Number(color as i16)]);
return self.apply_cap("setab", &[Param::Number(color as i32)]);
}
Ok(false)
}
Expand Down
10 changes: 5 additions & 5 deletions src/terminfo/parm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ enum States {
PushParam,
CharConstant,
CharClose,
IntConstant(i16),
IntConstant(i32),
FormatPattern(Flags, FormatState),
SeekIfElse(usize),
SeekIfElsePercent(usize),
Expand All @@ -46,7 +46,7 @@ enum FormatState {
#[derive(Clone)]
pub enum Param {
Words(String),
Number(i16)
Number(i32)
}

/// Container for static and dynamic variable arrays
Expand Down Expand Up @@ -136,7 +136,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
'\'' => state = CharConstant,
'{' => state = IntConstant(0),
'l' => match stack.pop() {
Some(Words(s)) => stack.push(Number(s.len() as i16)),
Some(Words(s)) => stack.push(Number(s.len() as i32)),
Some(_) => return Err("a non-str was used with %l".to_string()),
None => return Err("stack is empty".to_string())
},
Expand Down Expand Up @@ -255,7 +255,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
}
},
CharConstant => {
stack.push(Number(c as i16));
stack.push(Number(c as i32));
state = CharClose;
},
CharClose => if cur != '\'' {
Expand All @@ -266,7 +266,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
stack.push(Number(i));
state = Nothing;
} else if let Some(digit) = cur.to_digit(10) {
match i.checked_mul(10).and_then(|i_ten|i_ten.checked_add(digit as i16)) {
match i.checked_mul(10).and_then(|i_ten|i_ten.checked_add(digit as i32)) {
Some(i) => {
state = IntConstant(i);
old_state = Nothing;
Expand Down

0 comments on commit 031b0eb

Please sign in to comment.