mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-29 08:54:50 +00:00
Tweak new terminfo logical operator support
This commit is contained in:
parent
821a962feb
commit
9f9e505405
@ -68,7 +68,6 @@ pub fn expand(cap: &[u8], params: &mut [Param], sta: &mut [Param], dyn: &mut [Pa
|
||||
|
||||
while i < cap.len() {
|
||||
cur = cap[i] as char;
|
||||
debug!("current char: %c", cur);
|
||||
let mut old_state = state;
|
||||
match state {
|
||||
Nothing => {
|
||||
@ -134,33 +133,19 @@ pub fn expand(cap: &[u8], params: &mut [Param], sta: &mut [Param], dyn: &mut [Pa
|
||||
(_, _) => return Err(~"non-numbers on stack with |")
|
||||
},
|
||||
'A' => match (stack.pop(), stack.pop()) {
|
||||
(Number(x), Number(y)) => {
|
||||
if x == 1 && y == 1 {
|
||||
stack.push(Number(1));
|
||||
} else {
|
||||
stack.push(Number(0));
|
||||
}
|
||||
},
|
||||
(_, _) => return Err(~"non-numbers on stack with logical and")
|
||||
(Number(0), Number(_)) => stack.push(Number(0)),
|
||||
(Number(_), Number(0)) => stack.push(Number(0)),
|
||||
(Number(_), Number(_)) => stack.push(Number(1)),
|
||||
_ => return Err(~"non-numbers on stack with logical and")
|
||||
},
|
||||
'O' => match (stack.pop(), stack.pop()) {
|
||||
(Number(x), Number(y)) => {
|
||||
if x == 1 && y == 1 {
|
||||
stack.push(Number(1));
|
||||
} else {
|
||||
stack.push(Number(0));
|
||||
}
|
||||
},
|
||||
(_, _) => return Err(~"non-numbers on stack with logical or")
|
||||
(Number(0), Number(0)) => stack.push(Number(0)),
|
||||
(Number(_), Number(_)) => stack.push(Number(1)),
|
||||
_ => return Err(~"non-numbers on stack with logical or")
|
||||
},
|
||||
'!' => match stack.pop() {
|
||||
Number(x) => {
|
||||
if x == 1 {
|
||||
stack.push(Number(0))
|
||||
} else {
|
||||
stack.push(Number(1))
|
||||
}
|
||||
},
|
||||
Number(0) => stack.push(Number(1)),
|
||||
Number(_) => stack.push(Number(0)),
|
||||
_ => return Err(~"non-number on stack with logical not")
|
||||
},
|
||||
'~' => match stack.pop() {
|
||||
@ -168,9 +153,9 @@ pub fn expand(cap: &[u8], params: &mut [Param], sta: &mut [Param], dyn: &mut [Pa
|
||||
_ => return Err(~"non-number on stack with %~")
|
||||
},
|
||||
'i' => match (copy params[0], copy params[1]) {
|
||||
(Number(x), Number(y)) => {
|
||||
params[0] = Number(x + 1);
|
||||
params[1] = Number(y + 1);
|
||||
(Number(ref mut x), Number(ref mut y)) => {
|
||||
*x += 1;
|
||||
*y += 1;
|
||||
},
|
||||
(_, _) => return Err(~"first two params not numbers with %i")
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user