Modified env_get_string() to accept wcstring instead of wchar_t*.

This commit is contained in:
Siteshwar Vashisht 2012-02-24 00:55:46 +05:30
parent 2ae56564ef
commit 8232857d07
9 changed files with 14 additions and 17 deletions

View file

@ -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?

View file

@ -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;

View file

@ -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;

13
env.cpp
View file

@ -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() );
}

2
env.h
View file

@ -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

View file

@ -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 );
}

View file

@ -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

View file

@ -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);

View file

@ -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