From: Corinna Vinschen Date: Fri, 8 May 2009 20:28:20 +0000 (+0000) Subject: * strfuncs.cc (sys_cp_wcstombs): save and restore previous errno value. X-Git-Tag: sid-snapshot-20090601~48 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=4dff3fed7d1e258f8a16e54c7c3e3410450fc64f;p=newlib-cygwin.git * strfuncs.cc (sys_cp_wcstombs): save and restore previous errno value. (sys_cp_mbstowcs): Ditto. --- diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index b887f4200..f0beeccd6 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2009-05-08 Corinna Vinschen + IWAMURO Motonori + + * strfuncs.cc (sys_cp_wcstombs): save and restore previous errno value. + (sys_cp_mbstowcs): Ditto. + 2009-05-08 IWAMURO Motonori * strfuncs.cc (sys_cp_wcstombs): Set errno to 0 before converting diff --git a/winsup/cygwin/strfuncs.cc b/winsup/cygwin/strfuncs.cc index 75ca3db28..e0395745d 100644 --- a/winsup/cygwin/strfuncs.cc +++ b/winsup/cygwin/strfuncs.cc @@ -416,6 +416,7 @@ sys_cp_wcstombs (wctomb_p f_wctomb, char *charset, char *dst, size_t len, wchar_t *pwcs = (wchar_t *) src; size_t n = 0; mbstate_t ps; + save_errno save; memset (&ps, 0, sizeof ps); if (dst == NULL) @@ -432,7 +433,6 @@ sys_cp_wcstombs (wctomb_p f_wctomb, char *charset, char *dst, size_t len, ASCII SO; UTF-8 representation of invalid char. */ if (bytes == -1 && *charset != 'U'/*TF-8*/) { - _REENT->_errno = 0; buf[0] = 0x0e; /* ASCII SO */ bytes = __utf8_wctomb (_REENT, buf + 1, pw, charset, &ps); if (bytes == -1) @@ -523,6 +523,7 @@ sys_cp_mbstowcs (mbtowc_p f_mbtowc, char *charset, wchar_t *dst, size_t dlen, size_t len = dlen; int bytes; mbstate_t ps; + save_errno save; memset (&ps, 0, sizeof ps); if (dst == NULL)