GCC Middle and Back End API Reference
|
Data Structures | |
struct | kv |
Public Member Functions | |
void | init (bool can_restore, bool debug) |
const char * | get (const char *name) |
void | xput (const char *string) |
void | restore () |
Private Attributes | |
bool | m_can_restore |
bool | m_debug |
vec< kv > | m_keys |
Manage the manipulation of env vars. We poison "getenv" and "putenv", so that all enviroment-handling is done through this class. Note that poisoning happens in the preprocessor at the identifier level, and doesn't distinguish between env.getenv (); and getenv (); Hence we need to use "get" for the accessor method, not "getenv".
const char * env_manager::get | ( | const char * | name | ) |
Get the value of NAME within the environment. Essentially a wrapper for ::getenv, but adding logging, and the possibility of caching results.
References m_debug.
Referenced by getenv_spec_function(), and process_command().
Initializer for class env_manager. We can't do this as a constructor since we have a statically allocated instance ("env" above).
References debug, m_can_restore, and m_debug.
Referenced by driver::driver().
void env_manager::restore | ( | ) |
Undo any xputenv changes made since last restore. Can only be called if the env_manager was initialized with CAN_RESTORE enabled.
References FOR_EACH_VEC_ELT_REVERSE, free(), gcc_assert, i, m_can_restore, m_debug, env_manager::kv::m_key, m_keys, and env_manager::kv::m_value.
Referenced by driver::finalize().
void env_manager::xput | ( | const char * | string | ) |
Put the given KEY=VALUE entry STRING into the environment. If the env_manager was initialized with CAN_RESTORE set, then also record the old value of KEY within the environment, so that it can be later restored.
References CONST_CAST, fnotice(), gcc_assert, m_can_restore, m_debug, env_manager::kv::m_key, m_keys, env_manager::kv::m_value, and NULL.
Referenced by xputenv().