From 4a825d4145f7a4d409f355b478781fa6742fabbf Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 12 Mar 2009 10:27:10 +0000 Subject: * libc/stdio/swprintf.c (_swprintf_r, swprintf): correct how terminating L'\0' is added; change return to match standard for when output does not fit; some corrections and enhancements to the docs. * libc/stdio/vswprintf.c (_vswprintf_r): ditto, except for docs. * libc/stdio/vfwprintf.c: some corrections to the docs and some enhancements to comments. (No code changes.) * libc/time/strftime.c: Correct some problems that made wcsftime() not work correctly: work properly with swprintf returns that are different from snprintf returns, correct test vector lengths for when sizeof(wchar_t) > 1. * libc/stdio/sprintf.c: Some documentation and comment corrections and enhancements to match those done to swprintf.c. --- newlib/libc/stdio/sprintf.c | 49 +++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 22 deletions(-) (limited to 'newlib/libc/stdio/sprintf.c') diff --git a/newlib/libc/stdio/sprintf.c b/newlib/libc/stdio/sprintf.c index 1d81ebdf9..072622e75 100644 --- a/newlib/libc/stdio/sprintf.c +++ b/newlib/libc/stdio/sprintf.c @@ -134,6 +134,8 @@ DESCRIPTION arguments must be requested somewhere within <[format]>. If positional parameters are used, then all conversion specifications except for <<%%>> must specify a position. + This positional parameters method is a POSIX extension to the C + standard definition for the functions. o <[flags]> @@ -147,12 +149,13 @@ DESCRIPTION o+ o ' - Since newlib only supports the C locale, this - flag has no effect in this implementation. - But in other locales, when <[type]> is <>, - <>, <>, <>, <>, <>, or <>, - the locale-dependent thousand's separator is - inserted prior to zero padding. + A POSIX extension to the C standard. However, this + implementation presently treats it as a no-op, which + is the default behavior for the C locale, anyway. (If + it did what it is supposed to, when <[type]> were <>, + <>, <>, <>, <>, <>, or <>, the + integer portion of the conversion would be formatted + with thousands' grouping wide characters.) o - The result of the conversion is left @@ -180,7 +183,7 @@ DESCRIPTION o 0 If the <[type]> character is <>, <>, <>, <>, <>, <>, <>, <>, - <>, <>, <>, <>, or <>: leading + <>, <>, <>, <>, <>, or <>: leading zeros are used to pad the field width (following any indication of sign or base); no spaces are used for padding. If the zero @@ -353,11 +356,10 @@ DESCRIPTION o z With <>, <>, <>, <>, <>, or - <>, specifies that the argument is a - <> or <>. + <>, specifies that the argument is a <>. With <>, specifies that the argument is a - pointer to a <>. + pointer to a <>. o t With <>, <>, <>, <>, <>, or @@ -389,7 +391,7 @@ DESCRIPTION character is printed. o C - Short for <<%lc>>. + Short for <<%lc>>. A POSIX extension to the C standard. o s Prints the elements of a pointer to <> @@ -400,13 +402,13 @@ DESCRIPTION multibyte characters before printing. o S - Short for <<%ls>>. + Short for <<%ls>>. A POSIX extension to the C standard. o d or i Prints a signed decimal integer; takes an <>. Leading zeros are inserted as - necessary to reach the precision. A precision - of 0 produces an empty string. + necessary to reach the precision. A value of 0 with + a precision of 0 produces an empty string. o D Newlib extension, short for <<%ld>>. @@ -414,8 +416,8 @@ DESCRIPTION o o Prints an unsigned octal integer; takes an <>. Leading zeros are inserted as - necessary to reach the precision. A precision - of 0 produces an empty string. + necessary to reach the precision. A value of 0 with + a precision of 0 produces an empty string. o O Newlib extension, short for <<%lo>>. @@ -423,8 +425,8 @@ DESCRIPTION o u Prints an unsigned decimal integer; takes an <>. Leading zeros are inserted as - necessary to reach the precision. A precision - of 0 produces an empty string. + necessary to reach the precision. A value of 0 with + a precision of 0 produces an empty string. o U Newlib extension, short for <<%lu>>. @@ -433,8 +435,8 @@ DESCRIPTION Prints an unsigned hexadecimal integer (using <> as digits beyond <<9>>); takes an <>. Leading zeros are inserted as - necessary to reach the precision. A precision - of 0 produces an empty string. + necessary to reach the precision. A value of 0 with + a precision of 0 produces an empty string. o X Like <>, but uses <> as digits @@ -540,6 +542,9 @@ If an error occurs, the result of <>, <>, to ENOMEM if allocation fails, and for <>, <> may be set to EOVERFLOW if <[size]> or the output length exceeds INT_MAX. +BUGS +The ``''' (quote) flag does not work when locale's thousands_sep is not empty. + PORTABILITY ANSI C requires <>, <>, <>, and <>. <> and <> are newlib extensions. @@ -595,7 +600,7 @@ _sprintf_r(ptr, str, fmt, va_alist) #endif ret = _svfprintf_r (ptr, &f, fmt, ap); va_end (ap); - *f._p = 0; + *f._p = '\0'; /* terminate the string */ return (ret); } @@ -628,7 +633,7 @@ sprintf(str, fmt, va_alist) #endif ret = _svfprintf_r (_REENT, &f, fmt, ap); va_end (ap); - *f._p = 0; + *f._p = '\0'; /* terminate the string */ return (ret); } -- cgit v1.2.3