Fixed bug with counting parens
This commit is contained in:
parent
1ed120f569
commit
a111783887
|
@ -212,7 +212,7 @@ main(int argc, char **argv)
|
||||||
return !printf("usage: modal [-vqn] source.modal\n");
|
return !printf("usage: modal [-vqn] source.modal\n");
|
||||||
for(i = 1; i < argc && *argv[i] == '-'; i++) {
|
for(i = 1; i < argc && *argv[i] == '-'; i++) {
|
||||||
switch(argv[i][1]) {
|
switch(argv[i][1]) {
|
||||||
case 'v': /* version */ return !printf("Modal Interpreter, 22 Apr 2024.\n");
|
case 'v': /* version */ return !printf("Modal Interpreter, 23 Apr 2024.\n");
|
||||||
case 'q': /* quiet */ quiet = 1; break;
|
case 'q': /* quiet */ quiet = 1; break;
|
||||||
case 'n': /* infinite */ cycles = 0xffffffff; break;
|
case 'n': /* infinite */ cycles = 0xffffffff; break;
|
||||||
}
|
}
|
||||||
|
@ -225,9 +225,9 @@ main(int argc, char **argv)
|
||||||
if(c == ' ' && *(w - 1) == '(') continue;
|
if(c == ' ' && *(w - 1) == '(') continue;
|
||||||
if(c == ')' && *(w - 1) == ' ') w--;
|
if(c == ')' && *(w - 1) == ' ') w--;
|
||||||
if(c == ' ' && *(w - 1) == ' ') w--;
|
if(c == ' ' && *(w - 1) == ' ') w--;
|
||||||
if(c == '(') pl++;
|
|
||||||
if(c == ')') pr++;
|
|
||||||
}
|
}
|
||||||
|
if(c == '(') pl++;
|
||||||
|
if(c == ')') pr++;
|
||||||
*w++ = c;
|
*w++ = c;
|
||||||
}
|
}
|
||||||
while(*(--w) <= ' ') *w = 0;
|
while(*(--w) <= ' ') *w = 0;
|
||||||
|
|
Loading…
Reference in New Issue