From d59d3b4463d3bc3b2369d51730ada4d1f7e734e6 Mon Sep 17 00:00:00 2001 From: axel Date: Sat, 11 Nov 2006 21:06:50 +1000 Subject: [PATCH] Minor code simplification in main.c darcs-hash:20061111110650-ac50b-0d50d10087ea863ff0c79d05c614fdb06fa3b9bd.gz --- main.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/main.c b/main.c index a55f834df..a82b39781 100644 --- a/main.c +++ b/main.c @@ -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;