Do not injest register on empty put_reg
This commit is contained in:
parent
6a61088a70
commit
f139f3218e
11
src/modal.c
11
src/modal.c
|
@ -48,12 +48,7 @@ set_reg(int r, char *b)
|
||||||
static void
|
static void
|
||||||
put_reg(char r)
|
put_reg(char r)
|
||||||
{
|
{
|
||||||
char c, *s = regs[(int)r], *ss;
|
char c, *s = regs[(int)r], *ss = walk(s);
|
||||||
if(!s) {
|
|
||||||
*dst_++ = '?', *dst_++ = r;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ss = walk(s);
|
|
||||||
if(r == '*') {
|
if(r == '*') {
|
||||||
int i, depth = 0;
|
int i, depth = 0;
|
||||||
if(*s == '(') { /* special explode tuple */
|
if(*s == '(') { /* special explode tuple */
|
||||||
|
@ -142,7 +137,7 @@ write_rule(Rule *r, char last, char *res)
|
||||||
{
|
{
|
||||||
char c, *b = r->b, *origin = dst_;
|
char c, *b = r->b, *origin = dst_;
|
||||||
while((c = *b++))
|
while((c = *b++))
|
||||||
if(spacer(last) && c == '?')
|
if(spacer(last) && c == '?' && regs[(int)*b])
|
||||||
put_reg(*b++);
|
put_reg(*b++);
|
||||||
else
|
else
|
||||||
*dst_++ = c, last = c;
|
*dst_++ = c, last = c;
|
||||||
|
@ -222,7 +217,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, 19 Apr 2024.\n");
|
case 'v': /* version */ return !printf("Modal Interpreter, 20 Apr 2024.\n");
|
||||||
case 'q': /* quiet */ fclose(stderr); break;
|
case 'q': /* quiet */ fclose(stderr); break;
|
||||||
case 'n': /* infinite */ cycles = 0xffffffff; break;
|
case 'n': /* infinite */ cycles = 0xffffffff; break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue