aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Siteshwar Vashisht <siteshwar@gmail.com>2012-02-24 00:55:46 +0530
committerGravatar Siteshwar Vashisht <siteshwar@gmail.com>2012-02-24 00:58:01 +0530
commit8232857d0785b5b2db8884d11680de5c2fe9b857 (patch)
tree9acbad3ff194926b80887f66b0c727b50eb4a71a
parent2ae56564ef2f9752bd59616a551f49b1d1db03fb (diff)
Modified env_get_string() to accept wcstring instead of wchar_t*.
-rw-r--r--autoload.cpp2
-rw-r--r--builtin_set.cpp2
-rw-r--r--complete.cpp2
-rw-r--r--env.cpp13
-rw-r--r--env.h2
-rw-r--r--env_universal.cpp4
-rw-r--r--env_universal.h2
-rw-r--r--env_universal_common.cpp2
-rw-r--r--env_universal_common.h2
9 files changed, 14 insertions, 17 deletions
diff --git a/autoload.cpp b/autoload.cpp
index dd3dafbf..e214acb0 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 1f64cb01..c46be8b1 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 ee348d07..78282cc7 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 e2e380a8..82547116 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 a5ac97b4..acef82a6 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 94e592a1..fef32fe7 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 435fc4b7..fc05741d 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 d7dea877..9098121d 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<wcstring, var_uni_entry_t*>::const_iterator result = env_universal_var.find(name);
diff --git a/env_universal_common.h b/env_universal_common.h
index 908c5bae..c6c1d74e 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