[PATCH] swprintf corrections, wcsftime() corrections

Howland Craig D (Craig) howland@LGSInnovations.com
Thu Mar 12 06:18:00 GMT 2009


     Attached is a patch that fixes the following problems with the
string
forms of the new wide printfs (i.e. swprintf and variants):
 
1)  The addition of the terminating wide null did not work when
    sizeof(wchar_t) > 1.
2)  The return values were incorrectly the same as snprintf when the
    output does not fit into the buffer.  While snprintf returns how
    many characters it would take without indicating an error, swprintf
    (and friends) are supposed to indicate an error with a negative
    return.

     In addition to those repairs, the documentation was adjusted to
match.  Additionally, some extra comments were added to identifty
POSIX extensions.  Since swprintf.c started from sprintf.c, sprintf.c
has
been modified with the same basic enhancements.  Since I was editing the
file, I also changed the code to be more clear (no effective change)
where the terminating nulls are added (which was the likely cause of the
#1 swprintf error, due to the port not being obvious).
     Additionally, fixes to strftime.c are included to make wcsftime()
work correctly given the modified return values from swprintf().  Also,
some changes to the (optional) test vectors were made so that they
work properly on targets with sizeof(wchar_t) > 1.
     ChangeLog entries are in the patch file.
     Corinna:  I know we have the question about "if (ret < EOF)
ptr->_errno = EOVERFLOW;" waiting for Jeff, but since that case seems
impossible to both of us and there is a way for EOVERFLOW to be
signalled there, I went ahead and changed it.  I'll restore it as needed
if Jeff points out something that we missed.
				Craig
-------------- next part --------------
A non-text attachment was scrubbed...
Name: misc2.patch
Type: application/octet-stream
Size: 34877 bytes
Desc: misc2.patch
URL: <http://sourceware.org/pipermail/newlib/attachments/20090312/53970cfe/attachment.obj>


More information about the Newlib mailing list