Adopt wcstring in env_set
This commit is contained in:
parent
294fbc8309
commit
175249b455
10
env.cpp
10
env.cpp
@ -728,7 +728,7 @@ static env_node_t *env_get_node( const wcstring &key )
|
||||
return env;
|
||||
}
|
||||
|
||||
int env_set(const wchar_t *key, const wchar_t *val, int var_mode)
|
||||
int env_set(const wcstring &key, const wchar_t *val, int var_mode)
|
||||
{
|
||||
ASSERT_IS_MAIN_THREAD();
|
||||
env_node_t *node = NULL;
|
||||
@ -738,8 +738,6 @@ int env_set(const wchar_t *key, const wchar_t *val, int var_mode)
|
||||
int done=0;
|
||||
|
||||
int is_universal = 0;
|
||||
|
||||
CHECK( key, ENV_INVALID );
|
||||
|
||||
if( val && contains( key, L"PWD", L"HOME" ) )
|
||||
{
|
||||
@ -756,7 +754,7 @@ int env_set(const wchar_t *key, const wchar_t *val, int var_mode)
|
||||
return ENV_PERM;
|
||||
}
|
||||
|
||||
if( wcscmp( key, L"umask" ) == 0)
|
||||
if (key == L"umask")
|
||||
{
|
||||
wchar_t *end;
|
||||
int mask;
|
||||
@ -804,7 +802,7 @@ int env_set(const wchar_t *key, const wchar_t *val, int var_mode)
|
||||
exportv = (var_mode & ENV_EXPORT );
|
||||
}
|
||||
|
||||
env_universal_set( key, val, exportv );
|
||||
env_universal_set(key, val, exportv);
|
||||
is_universal = 1;
|
||||
|
||||
}
|
||||
@ -861,7 +859,7 @@ int env_set(const wchar_t *key, const wchar_t *val, int var_mode)
|
||||
exportv = (var_mode & ENV_EXPORT );
|
||||
}
|
||||
|
||||
env_universal_set( key, val, exportv );
|
||||
env_universal_set(key, val, exportv);
|
||||
is_universal = 1;
|
||||
|
||||
done = 1;
|
||||
|
2
env.h
2
env.h
@ -81,7 +81,7 @@ void env_destroy();
|
||||
* ENV_INVALID, the variable name or mode was invalid
|
||||
*/
|
||||
|
||||
int env_set(const wchar_t *key, const wchar_t *val, int mode);
|
||||
int env_set(const wcstring &key, const wchar_t *val, int mode);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -326,12 +326,10 @@ wchar_t *env_universal_get( const wcstring &name )
|
||||
return env_universal_common_get( name );
|
||||
}
|
||||
|
||||
int env_universal_get_export( const wchar_t *name )
|
||||
int env_universal_get_export( const wcstring &name )
|
||||
{
|
||||
if( !init)
|
||||
return 0;
|
||||
|
||||
CHECK( name, 0 );
|
||||
|
||||
return env_universal_common_get_export( name );
|
||||
}
|
||||
@ -399,26 +397,24 @@ void env_universal_barrier()
|
||||
}
|
||||
|
||||
|
||||
void env_universal_set( const wchar_t *name, const wchar_t *value, int exportv )
|
||||
void env_universal_set( const wcstring &name, const wcstring &value, int exportv )
|
||||
{
|
||||
message_t *msg;
|
||||
|
||||
if( !init )
|
||||
return;
|
||||
|
||||
CHECK( name, );
|
||||
|
||||
debug( 3, L"env_universal_set( \"%ls\", \"%ls\" )", name, value );
|
||||
debug( 3, L"env_universal_set( \"%ls\", \"%ls\" )", name.c_str(), value.c_str() );
|
||||
|
||||
if( is_dead() )
|
||||
{
|
||||
env_universal_common_set( name, value, exportv );
|
||||
env_universal_common_set( name.c_str(), value.c_str(), exportv );
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = create_message( exportv?SET_EXPORT:SET,
|
||||
name,
|
||||
value);
|
||||
name.c_str(),
|
||||
value.c_str());
|
||||
|
||||
if( !msg )
|
||||
{
|
||||
|
@ -35,12 +35,12 @@ wchar_t *env_universal_get( const wcstring &name );
|
||||
Get the export flag of the variable with the specified
|
||||
name. Returns 0 if the variable doesn't exist.
|
||||
*/
|
||||
int env_universal_get_export( const wchar_t *name );
|
||||
int env_universal_get_export( const wcstring &name );
|
||||
|
||||
/**
|
||||
Set the value of a universal variable
|
||||
*/
|
||||
void env_universal_set( const wchar_t *name, const wchar_t *val, int exportv );
|
||||
void env_universal_set( const wcstring &name, const wcstring &val, int exportv );
|
||||
/**
|
||||
Erase a universal variable
|
||||
|
||||
|
@ -903,18 +903,15 @@ wchar_t *env_universal_common_get( const wcstring &name )
|
||||
return 0;
|
||||
}
|
||||
|
||||
int env_universal_common_get_export( const wchar_t *name )
|
||||
int env_universal_common_get_export( const wcstring &name )
|
||||
{
|
||||
std::map<wcstring, var_uni_entry_t*>::const_iterator result = env_universal_var.find(name);
|
||||
|
||||
if (result != env_universal_var.end() )
|
||||
{
|
||||
const var_uni_entry_t *e = result->second;
|
||||
|
||||
if( e )
|
||||
if (e != NULL)
|
||||
return e->exportv;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -190,7 +190,7 @@ wchar_t *env_universal_common_get( const wcstring &name );
|
||||
This function operate agains the local copy of all universal
|
||||
variables, it does not communicate with any other process.
|
||||
*/
|
||||
int env_universal_common_get_export( const wchar_t *name );
|
||||
int env_universal_common_get_export( const wcstring &name );
|
||||
|
||||
/**
|
||||
Add messages about all existing variables to the specified connection
|
||||
|
Loading…
x
Reference in New Issue
Block a user