static void skip_until_mark(void) { int ch; for (;;) { ch = readch(); switch (ch) { case 'M': return; case EOF: errx(1, "mark not found"); return; case 'l': case 'L': case 's': case 'S': case ':': case ';': case '<': case '>': case '=': (void)readreg(); if (readch() == 'e') (void)readreg(); else unreadch(); break; case '[': free(read_string(&bmachine.readstack[bmachine.readsp])); break; case '!': switch (ch = readch()) { case '<': case '>': case '=': (void)readreg(); if (readch() == 'e') (void)readreg(); else unreadch(); break; default: free(readline()); break; } break; default: break; } } }
static void eval_string(char *p) { int ch; if (bmachine.readsp > 0) { /* Check for tail call. Do not recurse in that case. */ ch = readch(); if (ch == EOF) { src_free(); src_setstring(&bmachine.readstack[bmachine.readsp], p); return; } else unreadch(); } if (bmachine.readsp == bmachine.readstack_sz - 1) { size_t newsz = bmachine.readstack_sz * 2; struct source *stack; stack = reallocarray(bmachine.readstack, newsz, sizeof(struct source)); if (stack == NULL) err(1, "recursion too deep"); bmachine.readstack_sz = newsz; bmachine.readstack = stack; } src_setstring(&bmachine.readstack[++bmachine.readsp], p); }
static void parse_number(void) { unreadch(); push_number(readnumber(&bmachine.readstack[bmachine.readsp], bmachine.ibase)); }
static void compare(enum bcode_compare type) { int index, elseindex; struct number *a, *b; bool ok; struct value *v; elseindex = NO_ELSE; index = readreg(); if (readch() == 'e') elseindex = readreg(); else unreadch(); a = pop_number(); if (a == NULL) return; b = pop_number(); if (b == NULL) { push_number(a); return; } ok = compare_numbers(type, a, b); if (!ok && elseindex != NO_ELSE) index = elseindex; if (index >= 0 && (ok || (!ok && elseindex != NO_ELSE))) { v = stack_tos(&bmachine.reg[index]); if (v == NULL) warnx("register '%c' (0%o) is empty", index, index); else { switch(v->type) { case BCODE_NONE: warnx("register '%c' (0%o) is empty", index, index); break; case BCODE_NUMBER: warn("eval called with non-string argument"); break; case BCODE_STRING: eval_string(bstrdup(v->u.string)); break; } } } }
static void not_compare(void) { switch (readch()) { case '<': not_less(); break; case '>': not_greater(); break; case '=': not_equal(); break; default: unreadch(); (void)fprintf(stderr, "! command is deprecated\n"); break; } }
static void not_compare(void) { switch (readch()) { case '<': not_less(); break; case '>': not_greater(); break; case '=': not_equal(); break; default: unreadch(); bexec(readline()); break; } }