auto merge of #7160 : kballard/rust/terminfo-parm-i-fix, r=thestinger

My latest terminfo work introduced a bug in the handling of %i, which was noticed by @huonw after the PR was already merged in.

r? @thestinger
This commit is contained in:
bors 2013-06-16 05:33:59 -07:00
commit c1548991cf

View File

@ -224,9 +224,9 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
}
} else { return Err(~"stack is empty") },
'i' => match (copy mparams[0], copy mparams[1]) {
(Number(ref mut x), Number(ref mut y)) => {
*x += 1;
*y += 1;
(Number(x), Number(y)) => {
mparams[0] = Number(x+1);
mparams[1] = Number(y+1);
},
(_, _) => return Err(~"first two params not numbers with %i")
},
@ -352,6 +352,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
#[cfg(test)]
mod test {
use super::*;
use core::result::Ok;
#[test]
fn test_basic_setabf() {
@ -366,6 +367,16 @@ mod test {
bytes!("21").to_owned());
}
#[test]
fn test_op_i() {
let mut vars = Variables::new();
assert_eq!(expand(bytes!("%p1%d%p2%d%p3%d%i%p1%d%p2%d%p3%d"),
[Number(1),Number(2),Number(3)], &mut vars),
Ok(bytes!("123233").to_owned()));
assert_eq!(expand(bytes!("%p1%d%p2%d%i%p1%d%p2%d"), [], &mut vars),
Ok(bytes!("0011").to_owned()));
}
#[test]
fn test_param_stack_failure_conditions() {
let mut varstruct = Variables::new();