diff --git a/tools/qwaq/main.c b/tools/qwaq/main.c index 3a84f1893..f45cf93fd 100644 --- a/tools/qwaq/main.c +++ b/tools/qwaq/main.c @@ -152,6 +152,8 @@ main (int argc, char **argv) { func_t main_func; const char *name = "qwaq.dat"; + string_t *pr_argv; + int pr_argc = 1, i; init_qf (); @@ -161,7 +163,17 @@ main (int argc, char **argv) if (!load_progs (name)) Sys_Error ("couldn't load %s", "qwaq.dat"); + if (argc > 2) + pr_argc = argc - 1; + pr_argv = PR_Zone_Malloc (&pr, (pr_argc + 1) * 4); + pr_argv[0] = PR_SetString (&pr, name); + for (i = 1; i < pr_argc; i++) + pr_argv[i] = PR_SetString (&pr, argv[1 + i]); + pr_argv[i] = 0; + main_func = PR_GetFunctionIndex (&pr, "main"); + P_INT (&pr, 0) = pr_argc; + P_INT (&pr, 1) = POINTER_TO_PROG (&pr, pr_argv); PR_ExecuteProgram (&pr, main_func); return G_INT (&pr, OFS_RETURN); } diff --git a/tools/qwaq/main.qc b/tools/qwaq/main.qc index b172c77e0..8b36b256b 100644 --- a/tools/qwaq/main.qc +++ b/tools/qwaq/main.qc @@ -1,5 +1,10 @@ -integer () main = +integer (integer argc, string []argv) main = { + local integer i; + for (i = 0; i < argc; i++) { + print (argv[i]); + print ("\n"); + } local id foo = [[Foo alloc] init]; [foo run]; return 0;