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:
authorJeff Johnston <jjohnstn@redhat.com>2009-02-19 00:28:41 +0300
committerJeff Johnston <jjohnstn@redhat.com>2009-02-19 00:28:41 +0300
commit3f60f7e544656eb9f701ca0cf6c4358fe9ae9400 (patch)
tree99ceaffb49a593c855b7b99ce2ceb39067493680 /newlib/libc/stdlib
parent15fc34ac5ac00f4efb1ddfc98a623833a1aaddb2 (diff)
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/stdlib')
-rw-r--r--newlib/libc/stdlib/mbtowc_r.c28
-rw-r--r--newlib/libc/stdlib/wcstod.c2
2 files changed, 16 insertions, 14 deletions
diff --git a/newlib/libc/stdlib/mbtowc_r.c b/newlib/libc/stdlib/mbtowc_r.c
index 7f0dd11aa..71bbf8537 100644
--- a/newlib/libc/stdlib/mbtowc_r.c
+++ b/newlib/libc/stdlib/mbtowc_r.c
@@ -65,8 +65,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
return -2;
#ifdef _MB_CAPABLE
- if (__lc_ctype == NULL ||
- (strlen (__lc_ctype) <= 1))
+ if (strlen (__lc_ctype) <= 1)
{ /* fall-through */ }
else if (!strcmp (__lc_ctype, "C-UTF-8"))
{
@@ -80,7 +79,8 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
ch = t[i++];
else
{
- ++n;
+ if (n < (size_t)-1)
+ ++n;
ch = state->__value.__wchb[0];
}
@@ -123,7 +123,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
state->__value.__wchb[0] = ch;
if (state->__count == 0)
state->__count = 1;
- else
+ else if (n < (size_t)-1)
++n;
if (n < 2)
return -2;
@@ -158,7 +158,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
state->__value.__wchb[0] = ch;
if (state->__count == 0)
state->__count = 1;
- else
+ else if (n < (size_t)-1)
++n;
if (n < 2)
return -2;
@@ -171,7 +171,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
state->__value.__wchb[1] = ch;
if (state->__count == 1)
state->__count = 2;
- else
+ else if (n < (size_t)-1)
++n;
if (n < 3)
return -2;
@@ -201,7 +201,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
state->__value.__wchb[0] = ch;
if (state->__count == 0)
state->__count = 1;
- else
+ else if (n < (size_t)-1)
++n;
if (n < 2)
return -2;
@@ -214,7 +214,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
state->__value.__wchb[1] = ch;
if (state->__count == 1)
state->__count = 2;
- else
+ else if (n < (size_t)-1)
++n;
if (n < 3)
return -2;
@@ -224,7 +224,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
state->__value.__wchb[2] = ch;
if (state->__count == 2)
state->__count = 3;
- else
+ else if (n < (size_t)-1)
++n;
if (n < 4)
return -2;
@@ -254,7 +254,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
state->__value.__wchb[0] = ch;
if (state->__count == 0)
state->__count = 1;
- else
+ else if (n < (size_t)-1)
++n;
if (n < 2)
return -2;
@@ -267,7 +267,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
state->__value.__wchb[1] = ch;
if (state->__count == 1)
state->__count = 2;
- else
+ else if (n < (size_t)-1)
++n;
if (n < 3)
return -2;
@@ -277,7 +277,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
state->__value.__wchb[2] = ch;
if (state->__count == 2)
state->__count = 3;
- else
+ else if (n < (size_t)-1)
++n;
if (n < 4)
return -2;
@@ -287,7 +287,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
state->__value.__wchb[3] = ch;
if (state->__count == 3)
state->__count = 4;
- else
+ else if (n < (size_t)-1)
++n;
if (n < 5)
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]);
return (i + 1);
case MAKE_A:
- ptr = (char *)(t + i + 1);
+ ptr = (unsigned char *)(t + i + 1);
break;
case ERROR:
default:
diff --git a/newlib/libc/stdlib/wcstod.c b/newlib/libc/stdlib/wcstod.c
index 403415705..2d62a86af 100644
--- a/newlib/libc/stdlib/wcstod.c
+++ b/newlib/libc/stdlib/wcstod.c
@@ -117,6 +117,8 @@ Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
#include <errno.h>
#include <stdlib.h>
#include <wchar.h>
+#include <wctype.h>
+#include <math.h>
double
_DEFUN (_wcstod_r, (ptr, nptr, endptr),