mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-31 03:20:28 +08:00
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>.
This commit is contained in:
parent
15fc34ac5a
commit
3f60f7e544
@ -1,3 +1,15 @@
|
|||||||
|
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>.
|
||||||
|
|
||||||
2009-02-18 Corinna Vinschen <corinna@vinschen.de>
|
2009-02-18 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* libc/stdio/open_memstream.c: Add open_wmemstream to doumentation.
|
* libc/stdio/open_memstream.c: Add open_wmemstream to doumentation.
|
||||||
|
@ -325,6 +325,8 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide),
|
|||||||
mallocs on small strings) and 64k bytes (to avoid overusing the
|
mallocs on small strings) and 64k bytes (to avoid overusing the
|
||||||
heap if *size was garbage). */
|
heap if *size was garbage). */
|
||||||
c->max = *size;
|
c->max = *size;
|
||||||
|
if (wide == 1)
|
||||||
|
c->max *= sizeof(wchar_t);
|
||||||
if (c->max < 64)
|
if (c->max < 64)
|
||||||
c->max = 64;
|
c->max = 64;
|
||||||
else if (c->max > 64 * 1024)
|
else if (c->max > 64 * 1024)
|
||||||
@ -342,7 +344,10 @@ _DEFUN(internal_open_memstream_r, (ptr, buf, size, wide),
|
|||||||
_free_r (ptr, c);
|
_free_r (ptr, c);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
**buf = '\0';
|
if (wide == 1)
|
||||||
|
**((wchar_t **)buf) = L'\0';
|
||||||
|
else
|
||||||
|
**buf = '\0';
|
||||||
|
|
||||||
c->storage = c;
|
c->storage = c;
|
||||||
c->pbuf = buf;
|
c->pbuf = buf;
|
||||||
@ -374,7 +379,7 @@ _DEFUN(_open_memstream_r, (ptr, buf, size),
|
|||||||
char **buf _AND
|
char **buf _AND
|
||||||
size_t *size)
|
size_t *size)
|
||||||
{
|
{
|
||||||
internal_open_memstream_r (ptr, buf, size, -1);
|
return internal_open_memstream_r (ptr, buf, size, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE *
|
FILE *
|
||||||
@ -383,7 +388,7 @@ _DEFUN(_open_wmemstream_r, (ptr, buf, size),
|
|||||||
wchar_t **buf _AND
|
wchar_t **buf _AND
|
||||||
size_t *size)
|
size_t *size)
|
||||||
{
|
{
|
||||||
internal_open_memstream_r (ptr, buf, size, 1);
|
return internal_open_memstream_r (ptr, (char **)buf, size, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _REENT_ONLY
|
#ifndef _REENT_ONLY
|
||||||
|
@ -65,8 +65,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
#ifdef _MB_CAPABLE
|
#ifdef _MB_CAPABLE
|
||||||
if (__lc_ctype == NULL ||
|
if (strlen (__lc_ctype) <= 1)
|
||||||
(strlen (__lc_ctype) <= 1))
|
|
||||||
{ /* fall-through */ }
|
{ /* fall-through */ }
|
||||||
else if (!strcmp (__lc_ctype, "C-UTF-8"))
|
else if (!strcmp (__lc_ctype, "C-UTF-8"))
|
||||||
{
|
{
|
||||||
@ -80,7 +79,8 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
ch = t[i++];
|
ch = t[i++];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++n;
|
if (n < (size_t)-1)
|
||||||
|
++n;
|
||||||
ch = state->__value.__wchb[0];
|
ch = state->__value.__wchb[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
state->__value.__wchb[0] = ch;
|
state->__value.__wchb[0] = ch;
|
||||||
if (state->__count == 0)
|
if (state->__count == 0)
|
||||||
state->__count = 1;
|
state->__count = 1;
|
||||||
else
|
else if (n < (size_t)-1)
|
||||||
++n;
|
++n;
|
||||||
if (n < 2)
|
if (n < 2)
|
||||||
return -2;
|
return -2;
|
||||||
@ -158,7 +158,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
state->__value.__wchb[0] = ch;
|
state->__value.__wchb[0] = ch;
|
||||||
if (state->__count == 0)
|
if (state->__count == 0)
|
||||||
state->__count = 1;
|
state->__count = 1;
|
||||||
else
|
else if (n < (size_t)-1)
|
||||||
++n;
|
++n;
|
||||||
if (n < 2)
|
if (n < 2)
|
||||||
return -2;
|
return -2;
|
||||||
@ -171,7 +171,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
state->__value.__wchb[1] = ch;
|
state->__value.__wchb[1] = ch;
|
||||||
if (state->__count == 1)
|
if (state->__count == 1)
|
||||||
state->__count = 2;
|
state->__count = 2;
|
||||||
else
|
else if (n < (size_t)-1)
|
||||||
++n;
|
++n;
|
||||||
if (n < 3)
|
if (n < 3)
|
||||||
return -2;
|
return -2;
|
||||||
@ -201,7 +201,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
state->__value.__wchb[0] = ch;
|
state->__value.__wchb[0] = ch;
|
||||||
if (state->__count == 0)
|
if (state->__count == 0)
|
||||||
state->__count = 1;
|
state->__count = 1;
|
||||||
else
|
else if (n < (size_t)-1)
|
||||||
++n;
|
++n;
|
||||||
if (n < 2)
|
if (n < 2)
|
||||||
return -2;
|
return -2;
|
||||||
@ -214,7 +214,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
state->__value.__wchb[1] = ch;
|
state->__value.__wchb[1] = ch;
|
||||||
if (state->__count == 1)
|
if (state->__count == 1)
|
||||||
state->__count = 2;
|
state->__count = 2;
|
||||||
else
|
else if (n < (size_t)-1)
|
||||||
++n;
|
++n;
|
||||||
if (n < 3)
|
if (n < 3)
|
||||||
return -2;
|
return -2;
|
||||||
@ -224,7 +224,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
state->__value.__wchb[2] = ch;
|
state->__value.__wchb[2] = ch;
|
||||||
if (state->__count == 2)
|
if (state->__count == 2)
|
||||||
state->__count = 3;
|
state->__count = 3;
|
||||||
else
|
else if (n < (size_t)-1)
|
||||||
++n;
|
++n;
|
||||||
if (n < 4)
|
if (n < 4)
|
||||||
return -2;
|
return -2;
|
||||||
@ -254,7 +254,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
state->__value.__wchb[0] = ch;
|
state->__value.__wchb[0] = ch;
|
||||||
if (state->__count == 0)
|
if (state->__count == 0)
|
||||||
state->__count = 1;
|
state->__count = 1;
|
||||||
else
|
else if (n < (size_t)-1)
|
||||||
++n;
|
++n;
|
||||||
if (n < 2)
|
if (n < 2)
|
||||||
return -2;
|
return -2;
|
||||||
@ -267,7 +267,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
state->__value.__wchb[1] = ch;
|
state->__value.__wchb[1] = ch;
|
||||||
if (state->__count == 1)
|
if (state->__count == 1)
|
||||||
state->__count = 2;
|
state->__count = 2;
|
||||||
else
|
else if (n < (size_t)-1)
|
||||||
++n;
|
++n;
|
||||||
if (n < 3)
|
if (n < 3)
|
||||||
return -2;
|
return -2;
|
||||||
@ -277,7 +277,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
state->__value.__wchb[2] = ch;
|
state->__value.__wchb[2] = ch;
|
||||||
if (state->__count == 2)
|
if (state->__count == 2)
|
||||||
state->__count = 3;
|
state->__count = 3;
|
||||||
else
|
else if (n < (size_t)-1)
|
||||||
++n;
|
++n;
|
||||||
if (n < 4)
|
if (n < 4)
|
||||||
return -2;
|
return -2;
|
||||||
@ -287,7 +287,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
state->__value.__wchb[3] = ch;
|
state->__value.__wchb[3] = ch;
|
||||||
if (state->__count == 3)
|
if (state->__count == 3)
|
||||||
state->__count = 4;
|
state->__count = 4;
|
||||||
else
|
else if (n < (size_t)-1)
|
||||||
++n;
|
++n;
|
||||||
if (n < 5)
|
if (n < 5)
|
||||||
return -2;
|
return -2;
|
||||||
@ -444,7 +444,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
|
|||||||
*pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)(t[i]);
|
*pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)(t[i]);
|
||||||
return (i + 1);
|
return (i + 1);
|
||||||
case MAKE_A:
|
case MAKE_A:
|
||||||
ptr = (char *)(t + i + 1);
|
ptr = (unsigned char *)(t + i + 1);
|
||||||
break;
|
break;
|
||||||
case ERROR:
|
case ERROR:
|
||||||
default:
|
default:
|
||||||
|
@ -117,6 +117,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#include <wctype.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
double
|
double
|
||||||
_DEFUN (_wcstod_r, (ptr, nptr, endptr),
|
_DEFUN (_wcstod_r, (ptr, nptr, endptr),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user