[ALL] Merge master (#447)

This commit is contained in:
Philippe Tillet
2022-01-30 20:21:20 -08:00
committed by GitHub
parent bef76b142a
commit 807d8a1945
14 changed files with 199 additions and 130 deletions

View File

@@ -13,6 +13,14 @@ namespace tools
{
#ifdef _WIN32
#define popen _popen
#define pclose _pclose
#endif
#ifndef WEXITSTATUS
#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) & 255)
#endif
int exec(const std::string& cmd, std::string& result) {
char buffer[128];

View File

@@ -33,19 +33,10 @@ namespace tools
inline std::string getenv(const char * name)
{
#ifdef _MSC_VER
char* cache_path = 0;
std::size_t sz = 0;
_dupenv_s(&cache_path, &sz, name);
#else
const char * cstr = std::getenv(name);
#endif
const char * cstr = std::getenv(name);
if(!cstr)
return "";
std::string result(cstr);
#ifdef _MSC_VER
free(cache_path);
#endif
return result;
}