Fixed issue with trailing whitespace

This commit is contained in:
Devine Lu Linvega 2024-04-14 16:58:26 -07:00
parent 479cd07383
commit dacb9836a0
1 changed files with 3 additions and 2 deletions

View File

@ -132,7 +132,8 @@ write_rule(Rule *r, char last, char *res)
put_reg(*b++); put_reg(*b++);
else else
*outp_++ = c, last = c; *outp_++ = c, last = c;
if(last == ' ' && outp_ - origin == 0) outp_--; if(outp_ - origin == 0)
while(*res == ' ') res++;
return commit_rule(r, res, 0); return commit_rule(r, res, 0);
} }
@ -200,7 +201,7 @@ main(int argc, char **argv)
if(argc < 2) if(argc < 2)
return !printf("usage: modal [-v] source.modal\n"); return !printf("usage: modal [-v] source.modal\n");
if(argc < 3 && argv[1][0] == '-' && argv[1][1] == 'v') if(argc < 3 && argv[1][0] == '-' && argv[1][1] == 'v')
return !printf("Modal Interpreter, 13 Apr 2024.\n"); return !printf("Modal Interpreter, 14 Apr 2024.\n");
if(!(f = fopen(argv[1], "r"))) if(!(f = fopen(argv[1], "r")))
return !printf("Invalid Modal file: %s.\n", argv[1]); return !printf("Invalid Modal file: %s.\n", argv[1]);
while(fread(&c, 1, 1, f)) { while(fread(&c, 1, 1, f)) {