pike.git/
src/
builtin.cmod
Branch:
Tag:
Non-build tags
All tags
No tags
2013-05-06
2013-05-06 15:46:34 by Martin Nilsson <nilsson@opera.com>
1e7c748fd29b3219e426fb9d6120fc6e120ddac2 (
17
lines) (+
17
/-
0
)
[
Show
|
Annotate
]
Branch:
7.9
Added sprintf to String.Buffer.
2355:
void f_Buffer_get( INT32 args ); void f_Buffer_add( INT32 args );
+
typedef void (_low_f_sprintf)(INT32, int, struct string_builder *);
+
static _low_f_sprintf *low_f_sprintf;
/*! @decl void create(int initial_size) *!
2624:
string_builder_putchar(&str->str, c); }
+
/*! @decl int sprintf(mixed ... arguments)
+
*! Appends the output from @[sprintf] at the end of the string.
+
*/
+
PIKEFUN int sprintf(mixed ... arguments)
+
{
+
// FIXME: Reset length on exception?
+
struct Buffer_struct *str = THIS;
+
if(!str->str.s)
+
init_string_builder_alloc(&str->str, str->initial, 0);
+
low_f_sprintf(args, 0, &str->str);
+
RETURN str->str.s->len;
+
}
+
/*! @decl string get_copy() *! *! Get the data from the buffer. Significantly slower than @[get],
2692:
{ struct Buffer_struct *str = THIS; MEMSET( str, 0, sizeof( *str ) );
+
low_f_sprintf = PIKE_MODULE_IMPORT(sprintf, low_f_sprintf);
} EXIT