From 1cc957a6d864eadd794c3582feedbde9c82c50b4 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 30 Jun 2015 19:56:52 -0400 Subject: [PATCH] Fixed up command-line-args --- runtime.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/runtime.c b/runtime.c index 40bd3565..48dbca36 100644 --- a/runtime.c +++ b/runtime.c @@ -896,19 +896,16 @@ string_type Cyc_substring(object str, object start, object end) { object Cyc_command_line_arguments(object cont) { int i; object lis = nil; - for (i = argc; i > 0; i--) { + for (i = _cyc_argc; i > 0; i--) { object ps = alloca(sizeof(string_type)); object pl = alloca(sizeof(cons_type)); make_string(s, _cyc_argv[i - 1]); - memcpy(ps, s, sizeof(string_type)); - -TODO: unfortunately this won't work because vars will get clobbered. need to use alloca - to get fresh memory each iteration for s and l. - attempting to above, but code is incomplete -// make_cons(l, &s, lis); -// lis = &l; + memcpy(ps, &s, sizeof(string_type)); + ((list)pl)->tag = cons_tag; + ((list)pl)->cons_car = ps; + ((list)pl)->cons_cdr = lis; + lis = pl; } - return_funcall1(cont, lis); }