From 88d2ac66ccfe3f433315ab448802a52da05a3b59 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Tue, 4 Oct 2016 12:44:16 -0400 Subject: Add quoting to rpn --- .bin/rpn.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to '.bin') 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; -- cgit 1.4.1