From bd8bf36485bda4f03929c2cbd06bae34f0bae601 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 15 Feb 2024 00:27:19 +0900 Subject: [PATCH] touched up some error message --- lib/hcl.h | 7 ++++++- lib/read.c | 14 ++++++++++---- lib/std.c | 14 +++++++------- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lib/hcl.h b/lib/hcl.h index a0b763b..d689401 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -1229,7 +1229,12 @@ struct hcl_io_cciarg_t /** * [OUT] place data here for #HCL_IO_READ */ - hcl_ooch_t buf[2048]; /* TODO: resize this if necessary */ + hcl_ooch_t buf[2047]; /* TODO: resize this if necessary */ + hcl_ooch_t is_bytes; +#if defined(HCL_OOCH_IS_UCH) + hcl_bch_t b_int[10]; + hcl_bch_t bbuf[2037]; +#endif /** * [OUT] place the number of characters read here for #HCL_IO_READ diff --git a/lib/read.c b/lib/read.c index 4dbda45..6cb86da 100644 --- a/lib/read.c +++ b/lib/read.c @@ -2915,23 +2915,29 @@ static void feed_update_lx_loc (hcl_t* hcl, hcl_ooci_t ch) } #if 0 -TODO: support the byte cci stream +/*TODO: support the byte cci stream*/ static int read_cci_stream (hcl_t* hcl) { int x; hcl_io_cciarg_t* arg; + static hcl_io_cmd_t read_cmd[] = + { + HCL_IO_READ, + HCL_IO_READ_BYTES + }; arg = hcl->c->curinp; /*x = hcl->c->cci_rdr(hcl, HCL_IO_READ, hcl->c->curinp);*/ - x = hcl->c->cci_rdr(hcl, arg->read_cmd, hcl->c->curinp); + x = hcl->c->cci_rdr(hcl, read_cmd[!!arg->is_bytes], hcl->c->curinp); if (x <= -1) return -1; #if defined(HCL_OOCH_IS_UCH) - if (arg->read_cmd == HCL_IO_READ_BYTES) + if (arg->is_bytes) { - hcl_oow_t bcslen, ucslen; + hcl_oow_t bcslen, ucslen, remlen; + bcslen = arg->bytes.len; ucslen = HCL_COUNTOF(arg->buf); x = hcl_convbtooochars(hcl, arg->bytes.buf, &bcslen, arg->buf, &ucslen); diff --git a/lib/std.c b/lib/std.c index 70c4a70..89d3b39 100644 --- a/lib/std.c +++ b/lib/std.c @@ -3502,7 +3502,7 @@ static HCL_INLINE int open_udi_stream (hcl_t* hcl, hcl_io_udiarg_t* arg) if (!bb->fp) { - hcl_seterrbfmt (hcl, HCL_EIOERR, "unable to open %hs", bb->fn); + hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to open udi stream '%hs'", xtn->udi_path); goto oops; } @@ -3549,7 +3549,7 @@ static HCL_INLINE int read_udi_stream (hcl_t* hcl, hcl_io_udiarg_t* arg) { if (ferror((FILE*)bb->fp)) { - hcl_seterrnum (hcl, HCL_EIOERR); + hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to read udi stream"); return -1; } break; @@ -3599,7 +3599,7 @@ static HCL_INLINE int read_udi_stream_bytes (hcl_t* hcl, hcl_io_udiarg_t* arg) { if (ferror((FILE*)bb->fp)) { - hcl_seterrnum (hcl, HCL_EIOERR); + hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to read udi stream"); return -1; } break; @@ -3663,9 +3663,9 @@ static HCL_INLINE int open_udo_stream (hcl_t* hcl, hcl_io_udoarg_t* arg) if (!fp) { if (xtn->udo_path) - hcl_seterrbfmt (hcl, HCL_EIOERR, "unable to open %hs", xtn->udo_path); + hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to open udp stream '%hs'", xtn->udo_path); else - hcl_seterrnum (hcl, HCL_EIOERR); + hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to open udo stream", xtn->udo_path); return -1; } @@ -3713,7 +3713,7 @@ static HCL_INLINE int write_udo_stream (hcl_t* hcl, hcl_io_udoarg_t* arg) if (fwrite(bcsbuf, HCL_SIZEOF(bcsbuf[0]), bcslen, (FILE*)arg->handle) < bcslen) { - hcl_seterrnum (hcl, HCL_EIOERR); + hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to write udo stream"); return -1; } @@ -3734,7 +3734,7 @@ static HCL_INLINE int write_udo_stream_bytes (hcl_t* hcl, hcl_io_udoarg_t* arg) if (fwrite(ptr, HCL_SIZEOF(*ptr), arg->len, (FILE*)arg->handle) < arg->len) { - hcl_seterrnum (hcl, HCL_EIOERR); + hcl_seterrbfmtwithsyserr (hcl, 0, errno, "unable to write udo stream"); return -1; }