diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2002-07-04 18:56:17 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2002-07-04 18:56:17 +0000 |
commit | 7501704dc9dc7337e621db87ada8901a496766d9 (patch) | |
tree | 8b0549b249b4f5fd48d0ee389d5db48beea55491 /newlib/libc/stdio/sprintf.c | |
parent | 5cff62d6561dc63ef30b57d7ee415e6e1acdfb70 (diff) | |
download | newlib-7501704dc9dc7337e621db87ada8901a496766d9.zip newlib-7501704dc9dc7337e621db87ada8901a496766d9.tar.gz newlib-7501704dc9dc7337e621db87ada8901a496766d9.tar.bz2 |
2002-07-04 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/Makefile.am: Add asprintf.c and vasprintf.c.
* libc/stdio/Makefile.in: Regenerated.
* libc/stdio/asprintf.c: New file.
* libc/stdio/vasprintf.c: Ditto.
* libc/stdio/fvwrite.c: Add code to dynamically reallocate
the buffer for asprintf support.
* libc/stdio/sprintf.c: Add asprintf documentation.
* libc/stdio/vfprintf.c: Add vasprintf documentation.
* libc/include/stdio.h: Add new prototypes.
Diffstat (limited to 'newlib/libc/stdio/sprintf.c')
-rw-r--r-- | newlib/libc/stdio/sprintf.c | 44 |
1 files changed, 27 insertions, 17 deletions
diff --git a/newlib/libc/stdio/sprintf.c b/newlib/libc/stdio/sprintf.c index b537632..6e67501 100644 --- a/newlib/libc/stdio/sprintf.c +++ b/newlib/libc/stdio/sprintf.c @@ -18,12 +18,14 @@ /* FUNCTION - <<printf>>, <<fprintf>>, <<sprintf>>, <<snprintf>>---format output + <<printf>>, <<fprintf>>, <<saprintf>>, <<sprintf>>, <<snprintf>>---format output INDEX fprintf INDEX printf INDEX + saprintf +INDEX sprintf INDEX snprintf @@ -34,6 +36,7 @@ ANSI_SYNOPSIS int printf(const char *<[format]> [, <[arg]>, ...]); int fprintf(FILE *<[fd]>, const char *<[format]> [, <[arg]>, ...]); int sprintf(char *<[str]>, const char *<[format]> [, <[arg]>, ...]); + int saprintf(char **<[strp]>, const char *<[format]> [, <[arg]>, ...]); int snprintf(char *<[str]>, size_t <[size]>, const char *<[format]> [, <[arg]>, ...]); TRAD_SYNOPSIS @@ -46,6 +49,10 @@ TRAD_SYNOPSIS FILE *<[fd]>; char *<[format]>; + int saprintf(<[strp]>, <[format]> [, <[arg]>, ...]); + char **<[strp]>; + char *<[format]>; + int sprintf(<[str]>, <[format]> [, <[arg]>, ...]); char *<[str]>; char *<[format]>; @@ -65,19 +72,22 @@ DESCRIPTION If there are more arguments than the format requires, excess arguments are ignored. - <<fprintf>>, <<sprintf>> and <<snprintf>> are identical to <<printf>>, - other than the destination of the formatted output: <<fprintf>> sends - the output to a specified file <[fd]>, while <<sprintf>> stores the - output in the specified char array <[str]> and <<snprintf>> limits - number of characters written to <[str]> to at most <[size]> (including - terminating <<0>>). For <<sprintf>> and <<snprintf>>, the behavior is - also undefined if the output <<*<[str]>>> overlaps with one of the - arguments. <[format]> is a pointer to a charater string containing - two types of objects: ordinary characters (other than <<%>>), which - are copied unchanged to the output, and conversion - specifications, each of which is introduced by <<%>>. - (To include <<%>> in the output, use <<%%>> in the format string.) - A conversion specification has the following form: + <<fprintf>>, <<saprintf>>, <<sprintf>> and <<snprintf>> are identical + to <<printf>>, other than the destination of the formatted output: + <<fprintf>> sends the output to a specified file <[fd]>, while + <<saprintf>> stores the output in a dynamically allocated buffer, + while <<sprintf>> stores the output in the specified char array + <[str]> and <<snprintf>> limits number of characters written to + <[str]> to at most <[size]> (including terminating <<0>>). For + <<sprintf>> and <<snprintf>>, the behavior is undefined if the + output <<*<[str]>>> overlaps with one of the arguments. For + <<saprintf>>, <[strp]> points to a pointer to char which is filled + in with the dynamically allocated buffer. <[format]> is a pointer + to a charater string containing two types of objects: ordinary + characters (other than <<%>>), which are copied unchanged to the + output, and conversion specifications, each of which is introduced + by <<%>>. (To include <<%>> in the output, use <<%%>> in the format + string.) A conversion specification has the following form: . %[<[flags]>][<[width]>][.<[prec]>][<[size]>][<[type]>] @@ -272,11 +282,11 @@ O- RETURNS -<<sprintf>> returns the number of bytes in the output string, +<<sprintf>> and <<saprintf>> return the number of bytes in the output string, save that the concluding <<NULL>> is not counted. <<printf>> and <<fprintf>> return the number of characters transmitted. -If an error occurs, <<printf>> and <<fprintf>> return <<EOF>>. No -error returns occur for <<sprintf>>. +If an error occurs, <<printf>> and <<fprintf>> return <<EOF>> and +<<saprintf>> returns -1. No error returns occur for <<sprintf>>. PORTABILITY The ANSI C standard specifies that implementations must |