fixed the strerror_r issue arising for implementation difference
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
15
lib/std.c
15
lib/std.c
@ -906,7 +906,18 @@ static hcl_errnum_t _syserrstrb (hcl_t* hcl, int syserr_type, int syserr_code, h
|
||||
#if defined(_WIN32) && defined(__STDC_WANT_SECURE_LIB__)
|
||||
if (buf) strerror_s (buf, len, syserr_code);
|
||||
#elif defined(HAVE_STRERROR_R)
|
||||
if (buf) strerror_r (syserr_code, buf, len);
|
||||
if (buf)
|
||||
{
|
||||
/* to work around mess between XSI and GNU strerror_r */
|
||||
hcl_oow_t x;
|
||||
if (len > 0) buf[0] = '\0';
|
||||
/* cast to hcl_oow_t to cater for prototype difference.
|
||||
* one returning int, the other returning a pointer.
|
||||
* x > 1024 in case the XSI version before glibc 2.13 returns
|
||||
* a positive error code upon failure */
|
||||
x = (hcl_oow_t)strerror_r(syserr_code, buf, len);
|
||||
if (len > 0 && buf[0] == '\0' && x != 0 && x > 1024 && x != (hcl_oow_t)-1) hcl_copy_bcstr (buf, len, x);
|
||||
}
|
||||
#else
|
||||
/* this may be thread unsafe */
|
||||
if (buf) hcl_copy_bcstr (buf, len, strerror(syserr_code));
|
||||
@ -3663,7 +3674,7 @@ static HCL_INLINE int open_udo_stream (hcl_t* hcl, hcl_io_udoarg_t* arg)
|
||||
if (!fp)
|
||||
{
|
||||
if (xtn->udo_path)
|
||||
hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to open udp stream '%hs'", xtn->udo_path);
|
||||
hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to open udo stream '%hs'", xtn->udo_path);
|
||||
else
|
||||
hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to open udo stream", xtn->udo_path);
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user