From dd957483ac35b6651c00de04d982c85723975eb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emysl=20Janouch?= Date: Fri, 26 May 2017 20:25:02 +0200 Subject: interpreter: forward "argv" --- interpreter.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/interpreter.c b/interpreter.c index 1ca2744..7be4fc7 100644 --- a/interpreter.c +++ b/interpreter.c @@ -50,9 +50,13 @@ main (int argc, char *argv[]) { if (!init_runtime_library (&ctx)) printf ("%s\n", "runtime library initialization failed"); + // In this one place we optimistically expect allocation to succeed + struct item *args = NULL, **tail = &args; + for (int i = 2; i < argc; i++) + tail = &(*tail = new_string (argv[i], strlen (argv[i])))->next; + struct item *result = NULL; - // TODO: pass argv as the list of arguments - (void) execute_block (&ctx, program, NULL, &result); + (void) execute_block (&ctx, program, args, &result); item_free_list (result); item_free_list (program); -- cgit v1.2.3