mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-03-20 17:31:08 +00:00
[ruamoko] Add vsprintf builtin
This commit is contained in:
parent
b517b95e45
commit
1b1249bdb0
3 changed files with 22 additions and 0 deletions
|
@ -583,6 +583,25 @@ PF_sprintf (progs_t *pr)
|
|||
dstring_delete (dstr);
|
||||
}
|
||||
|
||||
static void
|
||||
PF_vsprintf (progs_t *pr)
|
||||
{
|
||||
const char *fmt = P_GSTRING (pr, 0);
|
||||
__auto_type args = &P_PACKED (pr, pr_va_list_t, 1);
|
||||
pr_type_t *list_start = PR_GetPointer (pr, args->list);
|
||||
pr_type_t **list = alloca (args->count * sizeof (*list));
|
||||
dstring_t *dstr;
|
||||
|
||||
for (int i = 0; i < args->count; i++) {
|
||||
list[i] = list_start + i * pr->pr_param_size;
|
||||
}
|
||||
|
||||
dstr = dstring_newstr ();
|
||||
PR_Sprintf (pr, dstr, "PF_vsprintf", fmt, args->count, list);
|
||||
RETURN_STRING (pr, dstr->str);
|
||||
dstring_delete (dstr);
|
||||
}
|
||||
|
||||
/*
|
||||
string () gametype
|
||||
*/
|
||||
|
@ -643,6 +662,7 @@ static builtin_t builtins[] = {
|
|||
{"strlen", PF_strlen, QF 100},
|
||||
{"charcount", PF_charcount, QF 101},
|
||||
{"sprintf", PF_sprintf, QF 109},
|
||||
{"vsprintf", PF_vsprintf, -1},
|
||||
{"ftoi", PF_ftoi, QF 110},
|
||||
{"itof", PF_itof, QF 111},
|
||||
{"itos", PF_itos, QF 112},
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
@extern float strlen (string s);
|
||||
@extern float charcount (string goal, string s);
|
||||
@extern string sprintf (string fmt, ...);
|
||||
@extern string vsprintf (string fmt, @va_list args);
|
||||
@extern string itos (int i);
|
||||
@extern int stoi (string s);
|
||||
@extern vector stov (string s);
|
||||
|
|
|
@ -6,6 +6,7 @@ float (string s) stof = #81;
|
|||
float (string s) strlen = #0x000f0000 + 100;
|
||||
float (string goal, string s) charcount = #0x000f0000 + 101;
|
||||
string (string fmt, ...) sprintf = #0x000f0000 + 109;
|
||||
string vsprintf (string fmt, @va_list args) = #0;
|
||||
string (int i) itos = #0x000f0000 + 112;
|
||||
int (string s) stoi = #0x000f0000 + 113;
|
||||
vector (string s) stov = #0x000f0000 + 114;
|
||||
|
|
Loading…
Reference in a new issue