mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-01 02:14:20 +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() {
|
while i < cap.len() {
|
||||||
cur = cap[i] as char;
|
cur = cap[i] as char;
|
||||||
debug!("current char: %c", cur);
|
|
||||||
let mut old_state = state;
|
let mut old_state = state;
|
||||||
match state {
|
match state {
|
||||||
Nothing => {
|
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 |")
|
(_, _) => return Err(~"non-numbers on stack with |")
|
||||||
},
|
},
|
||||||
'A' => match (stack.pop(), stack.pop()) {
|
'A' => match (stack.pop(), stack.pop()) {
|
||||||
(Number(x), Number(y)) => {
|
(Number(0), Number(_)) => stack.push(Number(0)),
|
||||||
if x == 1 && y == 1 {
|
(Number(_), Number(0)) => stack.push(Number(0)),
|
||||||
stack.push(Number(1));
|
(Number(_), Number(_)) => stack.push(Number(1)),
|
||||||
} else {
|
_ => return Err(~"non-numbers on stack with logical and")
|
||||||
stack.push(Number(0));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
(_, _) => return Err(~"non-numbers on stack with logical and")
|
|
||||||
},
|
},
|
||||||
'O' => match (stack.pop(), stack.pop()) {
|
'O' => match (stack.pop(), stack.pop()) {
|
||||||
(Number(x), Number(y)) => {
|
(Number(0), Number(0)) => stack.push(Number(0)),
|
||||||
if x == 1 && y == 1 {
|
(Number(_), Number(_)) => stack.push(Number(1)),
|
||||||
stack.push(Number(1));
|
_ => return Err(~"non-numbers on stack with logical or")
|
||||||
} else {
|
|
||||||
stack.push(Number(0));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
(_, _) => return Err(~"non-numbers on stack with logical or")
|
|
||||||
},
|
},
|
||||||
'!' => match stack.pop() {
|
'!' => match stack.pop() {
|
||||||
Number(x) => {
|
Number(0) => stack.push(Number(1)),
|
||||||
if x == 1 {
|
Number(_) => stack.push(Number(0)),
|
||||||
stack.push(Number(0))
|
|
||||||
} else {
|
|
||||||
stack.push(Number(1))
|
|
||||||
}
|
|
||||||
},
|
|
||||||
_ => return Err(~"non-number on stack with logical not")
|
_ => return Err(~"non-number on stack with logical not")
|
||||||
},
|
},
|
||||||
'~' => match stack.pop() {
|
'~' => 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 %~")
|
_ => return Err(~"non-number on stack with %~")
|
||||||
},
|
},
|
||||||
'i' => match (copy params[0], copy params[1]) {
|
'i' => match (copy params[0], copy params[1]) {
|
||||||
(Number(x), Number(y)) => {
|
(Number(ref mut x), Number(ref mut y)) => {
|
||||||
params[0] = Number(x + 1);
|
*x += 1;
|
||||||
params[1] = Number(y + 1);
|
*y += 1;
|
||||||
},
|
},
|
||||||
(_, _) => return Err(~"first two params not numbers with %i")
|
(_, _) => return Err(~"first two params not numbers with %i")
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user