示例#1
0
static void update_export_array_if_necessary(bool recalc)
{
    ASSERT_IS_MAIN_THREAD();
    if (recalc && ! get_proc_had_barrier())
    {
        set_proc_had_barrier(true);
        env_universal_barrier();
    }

    if (has_changed_exported)
    {
        std::map<wcstring, wcstring> vals;
        size_t i;

        debug(4, L"env_export_arr() recalc");

        get_exported(top, vals);

        wcstring_list_t uni;
        env_universal_get_names2(uni, 1, 0);
        for (i=0; i<uni.size(); i++)
        {
            const wcstring &key = uni.at(i);
            const wchar_t *val = env_universal_get(key.c_str());

            if (wcscmp(val, ENV_NULL))
            {
                // Note that std::map::insert does NOT overwrite a value already in the map,
                // which we depend on here
                vals.insert(std::pair<wcstring, wcstring>(key, val));
            }
        }

        std::vector<std::string> local_export_buffer;
        export_func(vals, local_export_buffer);
        export_array.set(local_export_buffer);
        has_changed_exported=false;
    }

}
示例#2
0
wcstring_list_t env_get_names( int flags )
{
    scoped_lock lock(env_lock);
    
    wcstring_list_t result;
    std::set<wcstring> names;
    int show_local = flags & ENV_LOCAL;
	int show_global = flags & ENV_GLOBAL;
	int show_universal = flags & ENV_UNIVERSAL;

	env_node_t *n=top;

	
	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;
	}
	
	if( show_local )
	{
		while( n )
		{
			if( n == global_env )
				break;
			
			add_key_to_string_set(n->env, names);
			if( n->new_scope )
				break;		
			else
				n = n->next;

		}
	}
	
	if( show_global )
	{
		add_key_to_string_set(global_env->env, names);
		if( get_names_show_unexported ) {
            result.insert(result.end(), env_electric.begin(), env_electric.end());
        }
		
		if( get_names_show_exported )
		{
            result.push_back(L"COLUMNS");
            result.push_back(L"LINES");
		}
		
	}
	
	if( show_universal )
	{
    
        wcstring_list_t uni_list;
        env_universal_get_names2(uni_list,
                                 get_names_show_exported,
                                 get_names_show_unexported);                                 
        names.insert(uni_list.begin(), uni_list.end());
	}
	
    result.insert(result.end(), names.begin(), names.end());
    return result;
}