mirror of
https://github.com/Z3Prover/z3
synced 2026-07-15 11:35:42 +00:00
Refine env var helper in tptp frontend
This commit is contained in:
parent
3f61be81f8
commit
7627f77bb9
1 changed files with 8 additions and 3 deletions
|
|
@ -1780,12 +1780,17 @@ class tptp_parser {
|
|||
return path;
|
||||
}
|
||||
|
||||
static bool try_getenv(char const* name, std::string& value) {
|
||||
static bool get_env_var(char const* name, std::string& value) {
|
||||
#ifdef _WIN32
|
||||
char* buffer = nullptr;
|
||||
size_t len = 0;
|
||||
errno_t err = ::_dupenv_s(&buffer, &len, name);
|
||||
if (err != 0 || !buffer)
|
||||
if (err != 0) {
|
||||
if (buffer)
|
||||
std::free(buffer);
|
||||
return false;
|
||||
}
|
||||
if (!buffer)
|
||||
return false;
|
||||
value.assign(buffer);
|
||||
std::free(buffer);
|
||||
|
|
@ -1807,7 +1812,7 @@ class tptp_parser {
|
|||
if (file_exists(local)) return local;
|
||||
// Try TPTP environment variable (standard TPTP convention)
|
||||
std::string root;
|
||||
if (try_getenv("TPTP", root)) {
|
||||
if (get_env_var("TPTP", root)) {
|
||||
std::string env = normalize_path(root + "/" + name);
|
||||
if (file_exists(env)) return env;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue