NAME ^

src/misc.c - Miscellaneous functions

DESCRIPTION ^

Miscellaneous functions, mainly the Parrot_sprintf family.

Uses a generalized formatting algorithm (src/spf_render.c) with a specialized vtable (src/spf_vtable.c) to handle argument extraction.

Functions ^

The naming convention used is:

Parrot_v?n?sprintf

A (nearly) drop-in replacement for v?n?sprintf.

Parrot_v?sprintf_c

Takes a C-string format, returns a Parrot string.

Parrot_v?sprintf_s

Takes a Parrot string format, returns a Parrot string.

So the _ means "returns Parrot string" and the other letter indicates the type for the format.

STRING *Parrot_vsprintf_s

Almost all the other sprintf variants in this file are implemented in terms of this function (see Parrot_psprintf() for the exception). It in turn calls Parrot_sprintf_format() (see src/spf_render.c).

STRING *Parrot_vsprintf_c

C string version of Parrot_vsprintf_s().

void Parrot_vsnprintf

Similar to Parrot_vsprintf() but with an option to specify the length (len) of the returned C string.

STRING *Parrot_sprintf_s

Calls Parrot_vsprintf_s() with the va_list obtained from ....

STRING *Parrot_sprintf_c

C string version of Parrot_sprintf_s().

void Parrot_snprintf

Similar to Parrot_sprintf() but with an option to specify the length (len) of the returned C string.

STRING *Parrot_psprintf

Calls Parrot_sprintf_format() with the insertion arguments in an Array PMC.

int Parrot_secret_snprintf

A simulation of snprintf for systems that do not support it.

SEE ALSO ^

src/misc.h, src/spf_vtable.c, src/spf_render.c.

HISTORY ^

This was once a simple, vararg-based implementation that existed completely within this file. When the file grew to be nearly 1000 lines long, I split it into three. --BD


parrot