Minor code simplification in main.c

darcs-hash:20061111110650-ac50b-0d50d10087ea863ff0c79d05c614fdb06fa3b9bd.gz
This commit is contained in:
axel 2006-11-11 21:06:50 +10:00
parent 8784b78d84
commit d59d3b4463

19
main.c
View File

@ -73,17 +73,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
static int read_init()
{
char cwd[4096];
wchar_t *wcwd;
wchar_t cwd[4096];
wchar_t *config_dir;
wchar_t *config_dir_escaped;
void *context;
string_buffer_t *eval_buff;
if( !getcwd( cwd, 4096 ) )
if( !wgetcwd( cwd, 4096 ) )
{
wperror( L"getcwd" );
wperror( L"wgetcwd" );
return 0;
}
@ -103,20 +101,17 @@ static int read_init()
halloc_free( context );
free( config_dir_escaped );
if( chdir( cwd ) == -1 )
if( wchdir( cwd ) == -1 )
{
/*
If we can't change back to previos directory, we go to
~. Should be a sane default behavior.
*/
eval( L"builtin cd", 0, TOP );
}
wcwd = str2wcs( cwd );
if( wcwd )
}
else
{
env_set( L"PWD", wcwd, ENV_EXPORT );
free( wcwd );
env_set( L"PWD", cwd, ENV_EXPORT );
}
return 1;