Update.
* wcsmbs/mbrtowc.c: Create temporary state object if no output is written. * wcsmbs/mbsrtowcs.c: Likewise. * wcsmbs/wcrtomb.c: Likewise. * wcsmbs/wcsrtombs.c: Likewise. * wcsmbs/wcrtomb.c: Compute result correctly for successful call with s == NULL.
This commit is contained in:
parent
a5334a6807
commit
6a07e1f8df
@ -1,5 +1,14 @@
|
|||||||
2000-01-18 Ulrich Drepper <drepper@cygnus.com>
|
2000-01-18 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* wcsmbs/mbrtowc.c: Create temporary state object if no output is
|
||||||
|
written.
|
||||||
|
* wcsmbs/mbsrtowcs.c: Likewise.
|
||||||
|
* wcsmbs/wcrtomb.c: Likewise.
|
||||||
|
* wcsmbs/wcsrtombs.c: Likewise.
|
||||||
|
|
||||||
|
* wcsmbs/wcrtomb.c: Compute result correctly for successful call
|
||||||
|
with s == NULL.
|
||||||
|
|
||||||
* wcsmbs/mbsrtowcs.c: Compute return value correctly after change
|
* wcsmbs/mbsrtowcs.c: Compute return value correctly after change
|
||||||
in gconv function.
|
in gconv function.
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ static mbstate_t state;
|
|||||||
size_t
|
size_t
|
||||||
__mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
__mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
||||||
{
|
{
|
||||||
|
mbstate_t temp_state;
|
||||||
wchar_t buf[1];
|
wchar_t buf[1];
|
||||||
struct __gconv_step_data data;
|
struct __gconv_step_data data;
|
||||||
int status;
|
int status;
|
||||||
@ -57,6 +58,8 @@ __mbrtowc (wchar_t *pwc, const char *s, size_t n, mbstate_t *ps)
|
|||||||
data.__outbuf = (char *) buf;
|
data.__outbuf = (char *) buf;
|
||||||
s = "";
|
s = "";
|
||||||
n = 1;
|
n = 1;
|
||||||
|
temp_state = *data.__statep;
|
||||||
|
data.__statep = &temp_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure we use the correct function. */
|
/* Make sure we use the correct function. */
|
||||||
|
@ -62,10 +62,14 @@ __mbsrtowcs (dst, src, len, ps)
|
|||||||
/* We have to handle DST == NULL special. */
|
/* We have to handle DST == NULL special. */
|
||||||
if (dst == NULL)
|
if (dst == NULL)
|
||||||
{
|
{
|
||||||
|
mbstate_t temp_state;
|
||||||
wchar_t buf[64]; /* Just an arbitrary size. */
|
wchar_t buf[64]; /* Just an arbitrary size. */
|
||||||
const unsigned char *inbuf = (const unsigned char *) *src;
|
const unsigned char *inbuf = (const unsigned char *) *src;
|
||||||
const unsigned char *srcend = inbuf + strlen (inbuf) + 1;
|
const unsigned char *srcend = inbuf + strlen (inbuf) + 1;
|
||||||
|
|
||||||
|
temp_state = *data.__statep;
|
||||||
|
data.__statep = &temp_state;
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
data.__outbufend = (char *) buf + sizeof (buf);
|
data.__outbufend = (char *) buf + sizeof (buf);
|
||||||
do
|
do
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
|
/* Copyright (C) 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
|
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Library General Public License as
|
modify it under the terms of the GNU Library General Public License as
|
||||||
@ -36,6 +36,7 @@ static mbstate_t state;
|
|||||||
size_t
|
size_t
|
||||||
__wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
|
__wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
|
||||||
{
|
{
|
||||||
|
mbstate_t temp_state;
|
||||||
char buf[MB_CUR_MAX];
|
char buf[MB_CUR_MAX];
|
||||||
struct __gconv_step_data data;
|
struct __gconv_step_data data;
|
||||||
int status;
|
int status;
|
||||||
@ -56,6 +57,8 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
|
|||||||
{
|
{
|
||||||
data.__outbuf = buf;
|
data.__outbuf = buf;
|
||||||
wc = L'\0';
|
wc = L'\0';
|
||||||
|
temp_state = *data.__statep;
|
||||||
|
data.__statep = &temp_state;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Make sure we use the correct function. */
|
/* Make sure we use the correct function. */
|
||||||
@ -95,7 +98,7 @@ __wcrtomb (char *s, wchar_t wc, mbstate_t *ps)
|
|||||||
|
|
||||||
if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
|
if (status == __GCONV_OK || status == __GCONV_EMPTY_INPUT
|
||||||
|| status == __GCONV_FULL_OUTPUT)
|
|| status == __GCONV_FULL_OUTPUT)
|
||||||
result = data.__outbuf - (unsigned char *) s;
|
result = data.__outbuf - (unsigned char *) (s ?: buf);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = (size_t) -1;
|
result = (size_t) -1;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
|
/* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
|
Contributed by Ulrich Drepper <drepper@gnu.org>, 1996.
|
||||||
|
|
||||||
@ -60,11 +60,15 @@ __wcsrtombs (dst, src, len, ps)
|
|||||||
/* We have to handle DST == NULL special. */
|
/* We have to handle DST == NULL special. */
|
||||||
if (dst == NULL)
|
if (dst == NULL)
|
||||||
{
|
{
|
||||||
|
mbstate_t temp_state;
|
||||||
unsigned char buf[256]; /* Just an arbitrary value. */
|
unsigned char buf[256]; /* Just an arbitrary value. */
|
||||||
const wchar_t *srcend = *src + __wcslen (*src) + 1;
|
const wchar_t *srcend = *src + __wcslen (*src) + 1;
|
||||||
const wchar_t *inbuf = *src;
|
const wchar_t *inbuf = *src;
|
||||||
size_t dummy;
|
size_t dummy;
|
||||||
|
|
||||||
|
temp_state = *data.__statep;
|
||||||
|
data.__statep = &temp_state;
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
data.__outbufend = buf + sizeof (buf);
|
data.__outbufend = buf + sizeof (buf);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user