summaryrefslogtreecommitdiffstats
path: root/newlib/libc/stdio/open_memstream.c
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2009-02-18 21:28:41 +0000
committerJeff Johnston <jjohnstn@redhat.com>2009-02-18 21:28:41 +0000
commit3f60f7e544656eb9f701ca0cf6c4358fe9ae9400 (patch)
tree99ceaffb49a593c855b7b99ce2ceb39067493680 /newlib/libc/stdio/open_memstream.c
parent15fc34ac5ac00f4efb1ddfc98a623833a1aaddb2 (diff)
downloadcygnal-3f60f7e544656eb9f701ca0cf6c4358fe9ae9400.tar.gz
cygnal-3f60f7e544656eb9f701ca0cf6c4358fe9ae9400.tar.bz2
cygnal-3f60f7e544656eb9f701ca0cf6c4358fe9ae9400.zip
2009-02-18 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/open_memstream.c (internal_open_memstream_r): Fix max buffer size to be in wchar_t units if wide == 1 is passed in. In this case, also initialize the first character of the buffer to be wide char null. (_open_wmemstream_r): Cast buf to be (char **) to avoid warning. * libc/stdlib/mbtowc_r.c (_mbtowc_r): Change all occurences of incrementing the size_t value n to first check that n is not already size_t -1. Fix some compiler warnings. * libc/stdlib/wcstod.c: Add includes for <wctype.h> and <math.h>.
Diffstat (limited to 'newlib/libc/stdio/open_memstream.c')
-rw-r--r--newlib/libc/stdio/open_memstream.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/newlib/libc/stdio/open_memstream.c b/newlib/libc/stdio/open_memstream.c
index 2b94d66d6..e062ec7e9 100644
--- a/newlib/libc/stdio/open_memstream.c
+++ b/newlib/libc/stdio/open_memstream.c
@@ -325,6 +325,8 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide),
mallocs on small strings) and 64k bytes (to avoid overusing the
heap if *size was garbage). */
c->max = *size;
+ if (wide == 1)
+ c->max *= sizeof(wchar_t);
if (c->max < 64)
c->max = 64;
else if (c->max > 64 * 1024)
@@ -342,7 +344,10 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide),
_free_r (ptr, c);
return NULL;
}
- **buf = '\0';
+ if (wide == 1)
+ **((wchar_t **)buf) = L'\0';
+ else
+ **buf = '\0';
c->storage = c;
c->pbuf = buf;
@@ -374,7 +379,7 @@ _DEFUN(_open_memstream_r, (ptr, buf, size),
char **buf _AND
size_t *size)
{
- internal_open_memstream_r (ptr, buf, size, -1);
+ return internal_open_memstream_r (ptr, buf, size, -1);
}
FILE *
@@ -383,7 +388,7 @@ _DEFUN(_open_wmemstream_r, (ptr, buf, size),
wchar_t **buf _AND
size_t *size)
{
- internal_open_memstream_r (ptr, buf, size, 1);
+ return internal_open_memstream_r (ptr, (char **)buf, size, 1);
}
#ifndef _REENT_ONLY