~karolbelina


#1 Braces get skipped in pass2, but don't get skipped in pass1 7 months ago

Ticket created by ~karolbelina on ~rabbits/uxn

Hey, I noticed an uxnasm "bug", it's very obscure but I thought I'd share.

Long story short: braces get skipped in pass2, but don't get skipped in pass1.

For example, if you do

|0100 @a 01 { @b 02 } @c 03 04
|0110 :a :b :c

the b gets correctly defined (in pass1) at 0101, but the 02 never gets pushed (in pass2), so c points incorrectly at 04 instead of 03.

If we do this change in uxnasm

...
 static int
 pass1(FILE *f)
 {
-    int ccmnt = 0;
+    int ccmnt = 0, cmacr = 0;
     char w[64], scope[64], subw[64];
     while(fscanf(f, "%63s", w) == 1) {
         if(skipblock(w, &ccmnt, '(', ')')) continue;
+        if(skipblock(w, &cmacr, '{', '}')) continue;
         if(slen(w) >= 63)
 ...

and try to assemble the previous code once again, the b never gets defined in pass1, so uxnasm prints "Unknown label: :b", which is correct IMO.

If we remove the :b

|0100 @a 01 { @b 02 } @c 03 04
|0110 :a :c

the c now points at the correct position.