From 7c886ae2e37e776d457927480245a88a423ff569 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 12 Apr 2018 02:50:37 +0000 Subject: [PATCH] added hcl_setinloc() and called this on each .SCRIPT command received in the server --- lib/hcl-s.c | 8 +++++--- lib/hcl.c | 21 ++++++++------------- lib/hcl.h | 22 ++++++++++++++-------- lib/main.c | 2 +- 4 files changed, 28 insertions(+), 25 deletions(-) diff --git a/lib/hcl-s.c b/lib/hcl-s.c index c09d9a2..e77f8e7 100644 --- a/lib/hcl-s.c +++ b/lib/hcl-s.c @@ -757,7 +757,7 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags) if (!bufptr) return HCL_NULL; } - if (flags & HCL_VMPRIM_OPENDL_PFMOD) + if (flags & HCL_VMPRIM_DLOPEN_PFMOD) { hcl_oow_t len, i, xlen; @@ -1671,11 +1671,11 @@ static void reformat_synerr (hcl_t* hcl) orgmsg = hcl_backuperrmsg(hcl); hcl_seterrbfmt ( hcl, HCL_ESYNERR, - "%js%s%.*js at line %lu", + "%js%s%.*js at line %zu column %zu", orgmsg, (synerr.tgt.len > 0? " near ": ""), synerr.tgt.len, synerr.tgt.ptr, - (unsigned long int)synerr.loc.line + synerr.loc.line, synerr.loc.colm ); } @@ -1765,6 +1765,8 @@ int hcl_server_proto_handle_request (hcl_server_proto_t* proto) hcl_oop_t obj; hcl_ooci_t c; + hcl_setinloc (proto->hcl, 1, 1); + /* do a special check bypassing get_token(). it checks if the script contents * come on the same line as .SCRIPT */ GET_CHAR_TO_WITH_GOTO (proto, c, fail_with_errmsg); diff --git a/lib/hcl.c b/lib/hcl.c index 418c729..2cbc135 100644 --- a/lib/hcl.c +++ b/lib/hcl.c @@ -286,22 +286,11 @@ void hcl_fini (hcl_t* hcl) } } -void hcl_reset (hcl_t* hcl/*, int flags*/) +void hcl_reset (hcl_t* hcl) { hcl_oop_t v; hcl_oow_t i; -#if 0 - if (flags & HCL_RESET_LXC) - { - hcl->c->nungots = 0; - - hcl->c->inarg.line = 1; - hcl->c->inarg.colm = 1; - /* reset on curinp???? hwo to reset the input stream? or crate a separate function? */ - } -#endif - /* delete all literals shown in the literal frame from the system dictionary * excluding special kernel symbols. */ for (i = 0; i < hcl->code.lit.len; i++) @@ -323,6 +312,12 @@ void hcl_reset (hcl_t* hcl/*, int flags*/) hcl_gc (hcl); } +void hcl_setinloc (hcl_t* hcl, hcl_oow_t line, hcl_oow_t colm) +{ + hcl->c->inarg.line = line; + hcl->c->inarg.colm = colm; +} + int hcl_setoption (hcl_t* hcl, hcl_option_t id, const void* value) { switch (id) @@ -618,7 +613,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel hcl_copy_oochars((hcl_ooch_t*)md.mod.name, name, namelen); if (hcl->vmprim.dl_open && hcl->vmprim.dl_getsym && hcl->vmprim.dl_close) { - md.handle = hcl->vmprim.dl_open(hcl, &buf[MOD_PREFIX_LEN], HCL_VMPRIM_OPENDL_PFMOD); + md.handle = hcl->vmprim.dl_open(hcl, &buf[MOD_PREFIX_LEN], HCL_VMPRIM_DLOPEN_PFMOD); } if (md.handle == HCL_NULL) diff --git a/lib/hcl.h b/lib/hcl.h index 81ad916..f965c5f 100644 --- a/lib/hcl.h +++ b/lib/hcl.h @@ -743,11 +743,11 @@ typedef void (*hcl_syserrstru_t) ( hcl_oow_t len ); -enum hcl_vmprim_opendl_flag_t +enum hcl_vmprim_dlopen_flag_t { - HCL_VMPRIM_OPENDL_PFMOD = (1 << 0) + HCL_VMPRIM_DLOPEN_PFMOD = (1 << 0) }; -typedef enum hcl_vmprim_opendl_flag_t hcl_vmprim_opendl_flag_t; +typedef enum hcl_vmprim_dlopen_flag_t hcl_vmprim_dlopen_flag_t; typedef void* (*hcl_vmprim_dlopen_t) ( hcl_t* hcl, @@ -818,8 +818,8 @@ typedef enum hcl_iocmd_t hcl_iocmd_t; struct hcl_ioloc_t { - unsigned long int line; /**< line */ - unsigned long int colm; /**< column */ + hcl_oow_t line; /**< line */ + hcl_oow_t colm; /**< column */ const hcl_ooch_t* file; /**< file specified in #include */ }; typedef struct hcl_ioloc_t hcl_ioloc_t; @@ -874,8 +874,8 @@ struct hcl_ioinarg_t int state; } b; - unsigned long int line; - unsigned long int colm; + hcl_oow_t line; + hcl_oow_t colm; hcl_ooci_t nl; hcl_iolxc_t lxc; @@ -1484,7 +1484,13 @@ HCL_EXPORT void hcl_fini ( * the variable symbol. */ HCL_EXPORT void hcl_reset ( - hcl_t* hcl + hcl_t* hcl +); + +HCL_EXPORT void hcl_setinloc ( + hcl_t* hcl, + hcl_oow_t line, + hcl_oow_t colm ); #if defined(HCL_HAVE_INLINE) diff --git a/lib/main.c b/lib/main.c index 5faec5f..84a6750 100644 --- a/lib/main.c +++ b/lib/main.c @@ -788,7 +788,7 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags) if (!bufptr) return HCL_NULL; } - if (flags & HCL_VMPRIM_OPENDL_PFMOD) + if (flags & HCL_VMPRIM_DLOPEN_PFMOD) { hcl_oow_t len, i, xlen;