name: duk_push_sprintf proto: | const char *duk_push_sprintf(duk_context *ctx, const char *fmt, ...); stack: | [ ... ] -> [ ... str! ] summary: |
Format a string like sprintf()
(but safely) and push the result
to the value stack. Returns a non-NULL
pointer to the resulting
string.
If fmt
is NULL
, an empty string is pushed to the stack
and a non-NULL
pointer to an empty string is returned (this
behavior mimics what sprintf()
does for a NULL
format
string, at least on Linux). The returned pointer can be dereferenced and a
NUL terminator character is guaranteed.
Unlike sprintf()
the string formatting is safe. Concretely,
the implementation will try increasing temporary buffer sizes until a
large enough buffer is found for the temporary formatted value.