about summary refs log tree commit diff
diff options
context:
space:
mode:
authorCorey Richardson <corey@octayn.net>2013-06-13 21:42:49 -0400
committerKevin Ballard <kevin@sb.org>2013-06-14 12:37:53 -0700
commit821a962febc3261e97e31174dcb8cf142678bb4b (patch)
tree9395416240ec0666077e1712c92cefd2ed3d60ec
parenteadd83da8b9abc821b141195503836b2094a9ea3 (diff)
Various terminfo parameterization changes
-rw-r--r--src/libextra/terminfo/parm.rs38
1 files changed, 34 insertions, 4 deletions
diff --git a/src/libextra/terminfo/parm.rs b/src/libextra/terminfo/parm.rs
index 40191c89925..a92ab5ef508 100644
--- a/src/libextra/terminfo/parm.rs
+++ b/src/libextra/terminfo/parm.rs
@@ -68,6 +68,7 @@ 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 => {
@@ -132,9 +133,36 @@ pub fn expand(cap: &[u8], params: &mut [Param], sta: &mut [Param], dyn: &mut [Pa
                         (Number(x), Number(y)) => stack.push(Number(x | y)),
                         (_, _) => return Err(~"non-numbers on stack with |")
                     },
-                    'A' => return Err(~"logical operations unimplemented"),
-                    'O' => return Err(~"logical operations unimplemented"),
-                    '!' => return Err(~"logical operations unimplemented"),
+                    '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")
+                    },
+                    '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")
+                    },
+                    '!' => match stack.pop() {
+                        Number(x) => {
+                            if x == 1 {
+                                stack.push(Number(0))
+                            } else {
+                                stack.push(Number(1))
+                            }
+                        },
+                        _ => return Err(~"non-number on stack with logical not")
+                    },
                     '~' => match stack.pop() {
                         Number(x) => stack.push(Number(!x)),
                         _         => return Err(~"non-number on stack with %~")
@@ -181,7 +209,9 @@ pub fn expand(cap: &[u8], params: &mut [Param], sta: &mut [Param], dyn: &mut [Pa
                 state = CharClose;
             },
             CharClose => {
-                assert!(cur == '\'', "malformed character constant");
+                if cur != '\'' {
+                    return Err(~"malformed character constant");
+                }
             },
             IntConstant => {
                 if cur == '}' {