mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-27 05:13:10 +00:00
Fix insane bytemark issue on Solaris
darcs-hash:20070908191940-ac50b-f99e05c86f32a5c1c1aff35c1916951269a54d54.gz
This commit is contained in:
parent
3fc1ba0f0e
commit
a900d16540
2 changed files with 22 additions and 4 deletions
|
@ -215,7 +215,7 @@ wchar_t *utf2wcs( const char *in )
|
||||||
char **from_name = iconv_utf8_names;
|
char **from_name = iconv_utf8_names;
|
||||||
|
|
||||||
size_t in_len = strlen( in );
|
size_t in_len = strlen( in );
|
||||||
size_t out_len = sizeof( wchar_t )*(in_len+1);
|
size_t out_len = sizeof( wchar_t )*(in_len+2);
|
||||||
size_t nconv;
|
size_t nconv;
|
||||||
char *nout;
|
char *nout;
|
||||||
|
|
||||||
|
@ -253,8 +253,7 @@ wchar_t *utf2wcs( const char *in )
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nconv = iconv( cd, (const char **)&in, &in_len, &nout, &out_len );
|
||||||
nconv = iconv( cd, (char **)&in, &in_len, &nout, &out_len );
|
|
||||||
|
|
||||||
if (nconv == (size_t) -1)
|
if (nconv == (size_t) -1)
|
||||||
{
|
{
|
||||||
|
@ -264,6 +263,24 @@ wchar_t *utf2wcs( const char *in )
|
||||||
|
|
||||||
*((wchar_t *) nout) = L'\0';
|
*((wchar_t *) nout) = L'\0';
|
||||||
|
|
||||||
|
/*
|
||||||
|
Check for silly iconv behaviour inserting an bytemark in the output
|
||||||
|
string.
|
||||||
|
*/
|
||||||
|
if (*out == L'\xfeff' || *out == L'\xffef' || *out == L'\xefbbbf')
|
||||||
|
{
|
||||||
|
wchar_t *out_old = out;
|
||||||
|
out = wcsdup(out+1);
|
||||||
|
if (! out )
|
||||||
|
{
|
||||||
|
debug(0, L"FNORD!!!!");
|
||||||
|
free( out_old );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
free( out_old );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (iconv_close (cd) != 0)
|
if (iconv_close (cd) != 0)
|
||||||
wperror (L"iconv_close");
|
wperror (L"iconv_close");
|
||||||
|
|
||||||
|
|
|
@ -58,3 +58,4 @@ if test -d include
|
||||||
. $i
|
. $i
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue