diff --git a/autoload.cpp b/autoload.cpp index dd3dafbf3..e214acb0e 100644 --- a/autoload.cpp +++ b/autoload.cpp @@ -75,7 +75,7 @@ int autoload_t::load( const wcstring &cmd, bool reload ) /* Do some work while locked, including determing the path variable */ { scoped_lock locker(lock); - path_var = env_get_string( env_var_name.c_str() ); + path_var = env_get_string( env_var_name ); /* Do we know where to look? diff --git a/builtin_set.cpp b/builtin_set.cpp index 1f64cb01e..c46be8b1a 100644 --- a/builtin_set.cpp +++ b/builtin_set.cpp @@ -316,7 +316,7 @@ static void print_variables(int include_values, int esc, int scope) if( include_values ) { - env_var_t value = env_get_string(key.c_str()); + env_var_t value = env_get_string(key); if( !value.missing() ) { int shorten = 0; diff --git a/complete.cpp b/complete.cpp index ee348d07d..78282cc7a 100644 --- a/complete.cpp +++ b/complete.cpp @@ -1422,7 +1422,7 @@ static int complete_variable( const wchar_t *whole_var, if( match || match_no_case ) { - const env_var_t value_unescaped = env_get_string( env_name.c_str() ); + const env_var_t value_unescaped = env_get_string( env_name ); if( !value_unescaped.missing() ) { wcstring comp; diff --git a/env.cpp b/env.cpp index e2e380a88..82547116d 100644 --- a/env.cpp +++ b/env.cpp @@ -1076,12 +1076,11 @@ const wchar_t *env_var_t::c_str(void) const { return wcstring::c_str(); } -env_var_t env_get_string( const wchar_t *key ) +env_var_t env_get_string( const wcstring &key ) { scoped_lock lock(env_lock); - CHECK( key, 0 ); - if( wcscmp( key, L"history" ) == 0 ) + if( key == L"history" ) { wcstring result; const wchar_t *current; @@ -1113,19 +1112,19 @@ env_var_t env_get_string( const wchar_t *key ) return result; } - else if( wcscmp( key, L"COLUMNS" )==0 ) + else if( key == L"COLUMNS" ) { return format_val((long)common_get_width()); } - else if( wcscmp( key, L"LINES" )==0 ) + else if( key == L"LINES" ) { return format_val((long)common_get_width()); } - else if( wcscmp( key, L"status" )==0 ) + else if( key == L"status" ) { return format_val((long)proc_get_last_status()); } - else if( wcscmp( key, L"umask" )==0 ) + else if( key == L"umask" ) { return format_string(L"0%0.3o", get_umask() ); } diff --git a/env.h b/env.h index a5ac97b48..acef82a6d 100644 --- a/env.h +++ b/env.h @@ -116,7 +116,7 @@ public: /** Gets the variable with the specified name, or an empty string if it does not exist. */ -env_var_t env_get_string( const wchar_t *key ); +env_var_t env_get_string( const wcstring &key ); /** Returns 1 if the specified key exists. This can't be reliably done diff --git a/env_universal.cpp b/env_universal.cpp index 94e592a19..fef32fe7d 100644 --- a/env_universal.cpp +++ b/env_universal.cpp @@ -318,13 +318,11 @@ int env_universal_read_all() } } -wchar_t *env_universal_get( const wchar_t *name ) +wchar_t *env_universal_get( const wcstring &name ) { if( !init) return 0; - CHECK( name, 0 ); - return env_universal_common_get( name ); } diff --git a/env_universal.h b/env_universal.h index 435fc4b72..fc05741dd 100644 --- a/env_universal.h +++ b/env_universal.h @@ -29,7 +29,7 @@ void env_universal_destroy(); /** Get the value of a universal variable */ -wchar_t *env_universal_get( const wchar_t *name ); +wchar_t *env_universal_get( const wcstring &name ); /** Get the export flag of the variable with the specified diff --git a/env_universal_common.cpp b/env_universal_common.cpp index d7dea877b..9098121dd 100644 --- a/env_universal_common.cpp +++ b/env_universal_common.cpp @@ -896,7 +896,7 @@ void env_universal_common_get_names( wcstring_list_t &lst, } -wchar_t *env_universal_common_get( const wchar_t *name ) +wchar_t *env_universal_common_get( const wcstring &name ) { std::map::const_iterator result = env_universal_var.find(name); diff --git a/env_universal_common.h b/env_universal_common.h index 908c5bae1..c6c1d74ee 100644 --- a/env_universal_common.h +++ b/env_universal_common.h @@ -181,7 +181,7 @@ void env_universal_common_remove( const wcstring &key ); This function operate agains the local copy of all universal variables, it does not communicate with any other process. */ -wchar_t *env_universal_common_get( const wchar_t *name ); +wchar_t *env_universal_common_get( const wcstring &name ); /** Get the export flag of the variable with the specified