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:
parent
bd8bf36485
commit
dc8f0102a8
@ -637,7 +637,10 @@ int main (int argc, char* argv[])
|
|||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
print_usage:
|
print_usage:
|
||||||
fprintf (stderr, "Usage: %s filename ...\n", argv[0]);
|
fprintf (stderr, "Usage: %s [options] script-filename [output-filename]\n", argv[0]);
|
||||||
|
fprintf (stderr, "Options are:\n");
|
||||||
|
fprintf (stderr, " -b enable block construct with {}\n");
|
||||||
|
fprintf (stderr, " -n enable line-break as expression terminator\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,7 +703,7 @@ int main (int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((opt.ind + 1) != argc && !show_info) goto print_usage;
|
if ((opt.ind + 1) != argc && (opt.ind + 2) != argc && !show_info) goto print_usage;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
hcl = hcl_openstd(HCL_SIZEOF(xtn_t), HCL_NULL);
|
hcl = hcl_openstd(HCL_SIZEOF(xtn_t), HCL_NULL);
|
||||||
|
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 defined(_WIN32) && defined(__STDC_WANT_SECURE_LIB__)
|
||||||
if (buf) strerror_s (buf, len, syserr_code);
|
if (buf) strerror_s (buf, len, syserr_code);
|
||||||
#elif defined(HAVE_STRERROR_R)
|
#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
|
#else
|
||||||
/* this may be thread unsafe */
|
/* this may be thread unsafe */
|
||||||
if (buf) hcl_copy_bcstr (buf, len, strerror(syserr_code));
|
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 (!fp)
|
||||||
{
|
{
|
||||||
if (xtn->udo_path)
|
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
|
else
|
||||||
hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to open udo stream", xtn->udo_path);
|
hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to open udo stream", xtn->udo_path);
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user