mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 12:53:13 +00:00
Remove old env_get_names implementation
This commit is contained in:
parent
063fc0c48b
commit
029c8c06c2
2 changed files with 0 additions and 107 deletions
106
env.cpp
106
env.cpp
|
@ -1477,112 +1477,6 @@ void env_pop()
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
Function used with hash_foreach to insert keys of one table into
|
||||
another
|
||||
*/
|
||||
static void add_key_to_hash( void *key,
|
||||
void *data,
|
||||
void *aux )
|
||||
{
|
||||
var_entry_t *e = (var_entry_t *)data;
|
||||
if( ( e->exportv && get_names_show_exported) ||
|
||||
( !e->exportv && get_names_show_unexported) )
|
||||
{
|
||||
hash_put( (hash_table_t *)aux, key, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Add key to hashtable
|
||||
*/
|
||||
static void add_to_hash( void *k, void *aux )
|
||||
{
|
||||
hash_put( (hash_table_t *)aux,
|
||||
k,
|
||||
0 );
|
||||
}
|
||||
|
||||
void env_get_names( array_list_t *l, int flags )
|
||||
{
|
||||
int show_local = flags & ENV_LOCAL;
|
||||
int show_global = flags & ENV_GLOBAL;
|
||||
int show_universal = flags & ENV_UNIVERSAL;
|
||||
|
||||
hash_table_t names;
|
||||
env_node_t *n=top;
|
||||
|
||||
CHECK( l, );
|
||||
|
||||
get_names_show_exported =
|
||||
flags & ENV_EXPORT|| (!(flags & ENV_UNEXPORT));
|
||||
get_names_show_unexported =
|
||||
flags & ENV_UNEXPORT|| (!(flags & ENV_EXPORT));
|
||||
|
||||
if( !show_local && !show_global && !show_universal )
|
||||
{
|
||||
show_local =show_universal = show_global=1;
|
||||
}
|
||||
|
||||
hash_init( &names, &hash_wcs_func, &hash_wcs_cmp );
|
||||
|
||||
if( show_local )
|
||||
{
|
||||
while( n )
|
||||
{
|
||||
if( n == global_env )
|
||||
break;
|
||||
|
||||
hash_foreach2( &n->env,
|
||||
add_key_to_hash,
|
||||
&names );
|
||||
|
||||
if( n->new_scope )
|
||||
break;
|
||||
else
|
||||
n = n->next;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if( show_global )
|
||||
{
|
||||
hash_foreach2( &global_env->env,
|
||||
add_key_to_hash,
|
||||
&names );
|
||||
|
||||
if( get_names_show_unexported ) {
|
||||
for (std::set<wcstring>::iterator iter = env_electric.begin(); iter != env_electric.end(); iter++) {
|
||||
al_push( l, iter->c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
if( get_names_show_exported )
|
||||
{
|
||||
al_push( l, L"COLUMNS" );
|
||||
al_push( l, L"LINES" );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if( show_universal )
|
||||
{
|
||||
array_list_t uni_list;
|
||||
al_init( &uni_list );
|
||||
|
||||
env_universal_get_names( &uni_list,
|
||||
get_names_show_exported,
|
||||
get_names_show_unexported );
|
||||
|
||||
al_foreach2( &uni_list, &add_to_hash, &names );
|
||||
al_destroy( &uni_list );
|
||||
}
|
||||
|
||||
hash_get_keys( &names, l );
|
||||
hash_destroy( &names );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Function used with hash_foreach to insert keys of one table into
|
||||
a set::set<wcstring>
|
||||
|
|
1
env.h
1
env.h
|
@ -155,7 +155,6 @@ char **env_export_arr( int recalc );
|
|||
/**
|
||||
Insert all variable names into l. These are not copies of the strings and should not be freed after use.
|
||||
*/
|
||||
void env_get_names( array_list_t *l, int flags );
|
||||
wcstring_list_t env_get_names( int flags );
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue