summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x.bin/rpn.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/.bin/rpn.c b/.bin/rpn.c
index 0fcf7933..d3fe0667 100755
--- a/.bin/rpn.c
+++ b/.bin/rpn.c
@@ -35,6 +35,7 @@ static struct {
     int64_t data[1024];
     size_t len;
     int radix;
+    char op;
 } stack = { .radix = 10 };
 
 static void push(int64_t val) {
@@ -48,6 +49,19 @@ static int64_t pop(void) {
 }
 
 static bool stack_op(char op) {
+    if (stack.op == '\'') {
+        push(op);
+        stack.op = 0;
+        return true;
+    }
+    if (stack.op == '"') {
+        if (op == '"')
+            stack.op = 0;
+        else
+            push(op);
+        return true;
+    }
+
     int64_t a, b;
     switch (op) {
         case '$': pop();
@@ -71,6 +85,7 @@ static bool stack_op(char op) {
         break; case 'o': stack.radix = 8;
         break; case 'd': stack.radix = 10;
         break; case 'x': stack.radix = 16;
+        break; case '\'': case '"': stack.op = op;
         break; default: return false;
     }
     return true;