From 258fd27a9c981dcf74bae0553a662d98838b9c4f Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Thu, 4 Apr 2024 17:26:16 -0700 Subject: [PATCH] Fixed issue with wrapped cells --- examples/test.modal | 3 +-- src/modal.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/test.modal b/examples/test.modal index ba31c3a..7bf0ba0 100644 --- a/examples/test.modal +++ b/examples/test.modal @@ -1,5 +1,4 @@ <> (dup ?x) (?x ?x) -<> (?x ?y swap) (?y ?x) -((hey) (there) swap) +(dup (123)) diff --git a/src/modal.c b/src/modal.c index 12a5877..0619992 100644 --- a/src/modal.c +++ b/src/modal.c @@ -20,8 +20,11 @@ walk(char *s) char c; while((c = *s++)) { if(c == '(') depth++; - if(c == ')') --depth; - if(spacer(c) && !depth) break; + if(c == ')') { + --depth; + if(!depth) break; + } + if(depth < 0) break; } return s; } @@ -46,10 +49,13 @@ writereg(char r) int depth = 0; char c, *s = regs[(int)r]; while((c = *s++)) { - *outp_++ = c; if(c == '(') depth++; - if(c == ')') --depth; - if(!depth) break; + if(c == ')') { + --depth; + if(!depth) break; + } + if(depth < 0) break; + *outp_++ = c; } return 1; }