This patch solves the "Wide character -65493 has no narrow
representation" problem. For some reason on my system, mbstowcs
returns zero for valid strings. That was a bugger to track down for
sure, as fish just randomly corrupts memory when this happens, and of
course the symptom of this crops up somewhere entirely different ....
--- wutil.c~ 2008-01-13 02:47:44.000000000 +0100
+++ wutil.c 2008-02-28 18:16:53.000000000 +0100
@@ -193,9 +193,10 @@
}
-wchar_t *wgetcwd( wchar_t *buff, size_t sz )
+wchar_t *wgetcwd()
{
- char *buffc = malloc( sz*MAX_UTF8_BYTES);
+ const int bufsize = 4096;
+ char *buffc = malloc( bufsize*MAX_UTF8_BYTES);
char *res;
wchar_t *ret = 0;
@@ -204,14 +205,11 @@
errno = ENOMEM;
return 0;
}
-
- res = getcwd( buffc, sz*MAX_UTF8_BYTES );
+
+ res = getcwd( buffc, bufsize*MAX_UTF8_BYTES );
if( res )
{
- if( (size_t)-1 != mbstowcs( buff, buffc, sizeof( wchar_t ) * sz
) )
- {
- ret = buff;
- }
+ return str2wcs(buffc);
}
free( buffc );
--- wutil.h~ 2008-01-13 02:47:44.000000000 +0100
+++ wutil.h 2008-02-28 18:13:23.000000000 +0100
@@ -88,7 +88,7 @@
/**
Wide character version of getcwd().
*/
-wchar_t *wgetcwd( wchar_t *buff, size_t sz );
+wchar_t *wgetcwd();
/**
Wide character version of chdir()
--- builtin.c~ 2008-01-13 02:47:44.000000000 +0100
+++ builtin.c 2008-02-28 18:13:30.000000000 +0100
@@ -2535,14 +2535,13 @@
*/
static int set_pwd( wchar_t *env)
{
- wchar_t dir_path[4096];
- wchar_t *res = wgetcwd( dir_path, 4096 );
+ wchar_t *res = wgetcwd();
if( !res )
{
builtin_wperror( L"wgetcwd" );
return STATUS_BUILTIN_OK;
}
- env_set( env, dir_path, ENV_EXPORT | ENV_GLOBAL );
+ env_set( env, res, ENV_EXPORT | ENV_GLOBAL );
return 1;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users