Fix to preserve errno across certain calls to stop printing EOVERFLOW messages in weird places

This commit is contained in:
ridiculousfish 2012-03-03 15:28:16 -08:00
parent 3ead99b088
commit 00764406d7
3 changed files with 8 additions and 2 deletions

View file

@ -74,7 +74,7 @@ static int my_env_set( const wchar_t *key, wcstring_list_t &val, int scope )
int show_hint = 0;
struct stat buff;
const wchar_t *dir = val[ i ].c_str();
const wchar_t *dir = val[i].c_str();
if( wstat( dir, &buff ) )
{
@ -91,7 +91,6 @@ static int my_env_set( const wchar_t *key, wcstring_list_t &val, int scope )
if( error )
{
const wchar_t *colon;
append_format(stderr_buffer, _(BUILTIN_SET_PATH_ERROR), L"set", dir, key);
colon = wcschr( dir, L':' );

View file

@ -460,10 +460,13 @@ wcstring vformat_string(const wchar_t *format, va_list va_orig)
void append_format(wcstring &str, const wchar_t *format, ...)
{
/* Preserve errno across this call since it likes to stomp on it */
int err = errno;
va_list va;
va_start( va, format );
str.append(vformat_string(format, va));
va_end( va );
errno = err;
}
wchar_t *wcsvarname( const wchar_t *str )

View file

@ -372,6 +372,9 @@ const wchar_t *wgettext( const wchar_t *in )
{
if( !in )
return in;
// preserve errno across this since this is often used in printing error messages
int err = errno;
wgettext_init_if_necessary();
@ -384,6 +387,7 @@ const wchar_t *wgettext( const wchar_t *in )
char *out = gettext(mbs_in.c_str());
val = new wcstring(format_string(L"%s", out));
}
errno = err;
return val->c_str();
}