Change the strerror_override handling to check $_JSON_C_STRERROR_OVERRIDE instead of using a variable, so we don't need to export it.

This commit is contained in:
Eric Haszlakiewicz
2020-07-04 18:56:15 +00:00
parent b01d50b8dc
commit 6068d3f6d1
5 changed files with 11 additions and 7 deletions

View File

@@ -59,7 +59,8 @@ static struct
/* clang-format on */
// Enabled during tests
int _json_c_strerror_enable = 0;
static int _json_c_strerror_enable = 0;
extern char *getenv(const char *name); // Avoid including stdlib.h
#define PREFIX "ERRNO="
static char errno_buf[128] = PREFIX;
@@ -70,6 +71,8 @@ char *_json_c_strerror(int errno_in)
int ii, jj;
if (!_json_c_strerror_enable)
_json_c_strerror_enable = (getenv("_JSON_C_STRERROR_ENABLE") == NULL) ? -1 : 1;
if (_json_c_strerror_enable == -1)
return strerror(errno_in);
// Avoid standard functions, so we don't need to include any