From 175cc408d8ae28e4865bd6805dbc60fbb9b43bb3 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Mon, 31 Jan 2022 23:44:09 +0900 Subject: [PATCH] [qwaq] Update bi_printf to work with Ruamoko's va_list Same deal as for test_bi in qfcc's test harness. I really need to consolidate all these little functions. --- ruamoko/qwaq/builtins/main.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ruamoko/qwaq/builtins/main.c b/ruamoko/qwaq/builtins/main.c index 7d34e1785..670515fc0 100644 --- a/ruamoko/qwaq/builtins/main.c +++ b/ruamoko/qwaq/builtins/main.c @@ -152,6 +152,19 @@ bi_printf (progs_t *pr) pr_type_t **args = pr->pr_params + 1; dstring_t *dstr = dstring_new (); + if (pr->progs->version == PROG_VERSION) { + __auto_type va_list = &P_PACKED (pr, pr_va_list_t, 1); + count = va_list->count; + if (count) { + args = alloca (count * sizeof (pr_type_t *)); + for (int i = 0; i < count; i++) { + args[i] = &pr->pr_globals[va_list->list + i * 4]; + } + } else { + args = 0; + } + } + PR_Sprintf (pr, dstr, "bi_printf", fmt, count, args); if (dstr->str) { Sys_Printf ("%s", dstr->str);