Skip to content

Commit

Permalink
Fix line lengths in terminfo
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyball committed Jun 14, 2013
1 parent f31767d commit da4e614
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/libextra/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ impl Terminal {
}
pub fn reset(&self) {
if self.color_supported {
let s = expand(*self.ti.strings.find_equiv(&("op")).unwrap(), [], &mut Variables::new());
let mut vars = Variables::new();
let s = expand(*self.ti.strings.find_equiv(&("op")).unwrap(), [], &mut vars);
if s.is_ok() {
self.out.write(s.get());
} else {
Expand Down
15 changes: 10 additions & 5 deletions src/libextra/terminfo/parm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,19 +176,22 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
} else { return Err(~"stack is empty") },
'=' => if stack.len() > 1 {
match (stack.pop(), stack.pop()) {
(Number(y), Number(x)) => stack.push(Number(if x == y { 1 } else { 0 })),
(Number(y), Number(x)) => stack.push(Number(if x == y { 1 }
else { 0 })),
_ => return Err(~"non-numbers on stack with =")
}
} else { return Err(~"stack is empty") },
'>' => if stack.len() > 1 {
match (stack.pop(), stack.pop()) {
(Number(y), Number(x)) => stack.push(Number(if x > y { 1 } else { 0 })),
(Number(y), Number(x)) => stack.push(Number(if x > y { 1 }
else { 0 })),
_ => return Err(~"non-numbers on stack with >")
}
} else { return Err(~"stack is empty") },
'<' => if stack.len() > 1 {
match (stack.pop(), stack.pop()) {
(Number(y), Number(x)) => stack.push(Number(if x < y { 1 } else { 0 })),
(Number(y), Number(x)) => stack.push(Number(if x < y { 1 }
else { 0 })),
_ => return Err(~"non-numbers on stack with <")
}
} else { return Err(~"stack is empty") },
Expand Down Expand Up @@ -353,12 +356,14 @@ mod test {
#[test]
fn test_basic_setabf() {
let s = bytes!("\\E[48;5;%p1%dm");
assert_eq!(expand(s, [Number(1)], &mut Variables::new()).unwrap(), bytes!("\\E[48;5;1m").to_owned());
assert_eq!(expand(s, [Number(1)], &mut Variables::new()).unwrap(),
bytes!("\\E[48;5;1m").to_owned());
}

#[test]
fn test_multiple_int_constants() {
assert_eq!(expand(bytes!("%{1}%{2}%d%d"), [], &mut Variables::new()).unwrap(), bytes!("21").to_owned());
assert_eq!(expand(bytes!("%{1}%{2}%d%d"), [], &mut Variables::new()).unwrap(),
bytes!("21").to_owned());
}

#[test]
Expand Down

5 comments on commit da4e614

@bors
Copy link
Contributor

@bors bors commented on da4e614 Jun 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from thestinger
at lilyball@da4e614

@bors
Copy link
Contributor

@bors bors commented on da4e614 Jun 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging kballard/rust/terminfo-parm = da4e614 into auto

@bors
Copy link
Contributor

@bors bors commented on da4e614 Jun 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kballard/rust/terminfo-parm = da4e614 merged ok, testing candidate = da42e6b

@bors
Copy link
Contributor

@bors bors commented on da4e614 Jun 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on da4e614 Jun 15, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = da42e6b

Please sign in to comment.