diff options
| author | Nakidai <nakidai@disroot.org> | 2025-03-31 17:02:52 +0300 |
|---|---|---|
| committer | Nakidai <nakidai@disroot.org> | 2025-03-31 17:02:52 +0300 |
| commit | 9bf6d941428e9fd2ba84dd1ebf1a4f7abd7f5642 (patch) | |
| tree | 86847b1e26e15f6113c69abb9f9db3622566cc3f | |
| parent | a8b921e3773d6559bb3374b24ec246a290ca6643 (diff) | |
| download | 3cl-9bf6d941428e9fd2ba84dd1ebf1a4f7abd7f5642.tar.gz 3cl-9bf6d941428e9fd2ba84dd1ebf1a4f7abd7f5642.zip | |
Move line outside
| -rw-r--r-- | executor.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/executor.c b/executor.c index 5806981..144ad2c 100644 --- a/executor.c +++ b/executor.c @@ -13,6 +13,12 @@ static struct cccl_Variables globals = {0}; static struct cccl_Function functions[52] = {0}; static struct cccl_Stack stack = {0}; +static struct +{ + char *buf; + size_t length; +} line = {0}; + static void expand_stack(void) { if (!stack.buffer) @@ -71,12 +77,10 @@ enum cccl_ExecutorStatus cccl_execute(struct cccl_Node *code, struct cccl_Variab fprintf(stderr, "Executing %s, %lu nodes, depth %lu\n", strnode(code->type), code->in_length, depth); if (interactive) { - char *line = NULL; - size_t lsize = 0; - ssize_t length = getline(&line, &lsize, stdin); + ssize_t length = getline(&line.buf, &line.length, stdin); if (length == -1 && ferror(stdin)) err(1, "getline()"); - if (!strcmp(line, "d\n")) + if (!strcmp(line.buf, "d\n")) { fputs("Locals:\n", stderr); for (size_t i = 0; i < 52; ++i) |