Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2013-01-12 00:05:41 +0400
committerCorinna Vinschen <corinna@vinschen.de>2013-01-12 00:05:41 +0400
commit3920a99a229053dc5692099626ada88d29b79b1f (patch)
tree7d22c6e747d406f9fbee2a34cc1704d5c6f71cbd /newlib/libc/stdio/vfwprintf.c
parent2f47bbd55583be9b24bee039e6b7f35e3727b8de (diff)
* libc/stdio/vfwprintf.c (_VFWPRINTF_R): Add code to correctly handle
's' format specifier on not _MB_CAPABLE targets. Fix a formatting glitch in _MB_CAPABLE enabled code. Add a missing 'L' specifier.
Diffstat (limited to 'newlib/libc/stdio/vfwprintf.c')
-rw-r--r--newlib/libc/stdio/vfwprintf.c38
1 files changed, 30 insertions, 8 deletions
diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c
index 968c218b5..dfa8fde2f 100644
--- a/newlib/libc/stdio/vfwprintf.c
+++ b/newlib/libc/stdio/vfwprintf.c
@@ -1171,11 +1171,11 @@ string:
insize = strlen(arg);
if (insize >= BUF) {
if ((malloc_buf = (wchar_t *) _malloc_r (data, (insize + 1) * sizeof (wchar_t)))
- == NULL) {
- fp->_flags |= __SERR;
- goto error;
- }
- cp = malloc_buf;
+ == NULL) {
+ fp->_flags |= __SERR;
+ goto error;
+ }
+ cp = malloc_buf;
} else
cp = buf;
memset ((_PTR)&ps, '\0', sizeof (mbstate_t));
@@ -1195,9 +1195,31 @@ string:
*p = L'\0';
size = p - cp;
}
- else
+#else
+ if (ch != L'S' && !(flags & LONGINT)) {
+ char *arg = (char *) cp;
+ size_t insize = 0;
+
+ if (prec >= 0) {
+ char *p = memchr (arg, '\0', prec);
+ insize = p ? p - arg : prec;
+ } else
+ insize = strlen (arg);
+ if (insize >= BUF) {
+ if ((malloc_buf = (wchar_t *) _malloc_r (data, (insize + 1) * sizeof (wchar_t)))
+ == NULL) {
+ fp->_flags |= __SERR;
+ goto error;
+ }
+ cp = malloc_buf;
+ } else
+ cp = buf;
+ for (size = 0; size < insize; ++size)
+ cp[size] = arg[size];
+ cp[size] = L'\0';
+ }
#endif /* _MB_CAPABLE */
- if (prec >= 0) {
+ else if (prec >= 0) {
/*
* can't use wcslen; can only look for the
* NUL in the first `prec' characters, and
@@ -1222,7 +1244,7 @@ string:
case L'X':
xdigs = L"0123456789ABCDEF";
goto hex;
- case 'x':
+ case L'x':
xdigs = L"0123456789abcdef";
hex: _uquad = UARG ();
base = HEX;