2011-07-15 Yufeng Zhang <yufeng.zhang@arm.com>
* libc/stdio/vfwprintf.c (wcvt): Add a new parameter len of type int. *length is set to the value of (rev - digits) regardless of whether _MB_CAPABLE is defined or not. Replace BUF with len in calling _mbsnrtowcs_r and also in the loop where _MB_CAPABLE is not defined. (_VFWPRINTF_R): Call wcvt with an extra argument. Call wcvt again with allocated new buffer if buf is not large enough for the conversion. * testsuite/newlib.stdio/stdio.exp: New. * testsuite/newlib.stdio/swprintf.c: Likewise.
This commit is contained in:
12
newlib/testsuite/newlib.stdio/stdio.exp
Normal file
12
newlib/testsuite/newlib.stdio/stdio.exp
Normal file
@ -0,0 +1,12 @@
|
||||
# Copyright (C) 2011 by ARM Ltd. All rights reserved.
|
||||
#
|
||||
# Permission to use, copy, modify, and distribute this software
|
||||
# is freely granted, provided that this notice is preserved.
|
||||
#
|
||||
|
||||
load_lib passfail.exp
|
||||
|
||||
set exclude_list {
|
||||
}
|
||||
|
||||
newlib_pass_fail_all -x $exclude_list
|
30
newlib/testsuite/newlib.stdio/swprintf.c
Normal file
30
newlib/testsuite/newlib.stdio/swprintf.c
Normal file
@ -0,0 +1,30 @@
|
||||
/*
|
||||
* Copyright (C) 2011 by ARM Ltd. All rights reserved.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software
|
||||
* is freely granted, provided that this notice is preserved.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <newlib.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include "check.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
#if defined(INTEGER_ONLY) || defined(NO_FLOATING_POINT)
|
||||
|
||||
#else
|
||||
char cbuf[512];
|
||||
wchar_t wcbuf[512], wcbuf2[512];
|
||||
double val = 1E+308;
|
||||
snprintf(cbuf, 512, "%.*f", 3, val);
|
||||
swprintf(wcbuf, 512, L"%.*f", 3, val);
|
||||
mbstowcs(wcbuf2, cbuf, 512);
|
||||
|
||||
CHECK (wcscmp(wcbuf, wcbuf2) == 0);
|
||||
#endif
|
||||
|
||||
exit (0);
|
||||
}
|
Reference in New Issue
Block a user