Better walk()

This commit is contained in:
Devine Lu Linvega 2024-04-04 19:37:03 -07:00
parent 689fa77380
commit 070317d22d
2 changed files with 8 additions and 8 deletions

View File

@ -1,4 +1,4 @@
<> (swap ?x ?y) (?y ?x)
(swap 123 456)
(swap (123) (456))

View File

@ -18,15 +18,15 @@ walk(char *s)
{
int depth = 0;
char c;
if(s[0] == '(') {
while((c = *s++)) {
if(c == '(') depth++;
if(c == ')') {
--depth;
if(!depth) break;
if(c == ')') --depth;
if(!depth) return s;
}
if(depth == 0 && c == ' ') return s - 1;
if(depth < 1 && c == ' ') { return s - 1; }
}
while((c = *s++))
if(spacer(c)) return s - 1;
return s;
}