diff --git a/src/uxnasm.c b/src/uxnasm.c index 7c0f6c5..d7b2229 100644 --- a/src/uxnasm.c +++ b/src/uxnasm.c @@ -243,8 +243,13 @@ parse(char *w, FILE *f) return error("Invalid token", w); switch(w[0]) { case '(': /* comment */ - while(fscanf(f, "%63s", word) == 1) - if(word[0] == ')') break; + if(slen(w) != 1) fprintf(stderr, "-- Malformed comment: %s\n", w); + i = 1; /* track nested comment depth */ + while(fscanf(f, "%63s", word) == 1) { + if(slen(word) != 1) continue; + else if(word[0] == '(') i++; + else if(word[0] == ')' && --i < 1) break; + } break; case '~': /* include */ if(!doinclude(w + 1))