improved the interactive input handling if isocline is available
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-10-27 19:17:07 +09:00
parent a60bcfef80
commit 431840f77b
16 changed files with 311 additions and 68 deletions

View File

@ -312,6 +312,7 @@ INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
ISOCLINE_LIBS = @ISOCLINE_LIBS@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBM = @LIBM@

View File

@ -90,6 +90,12 @@
/* Define to 1 if you have the `isatty' function. */
#undef HAVE_ISATTY
/* Define to 1 if you have the <isocline.h> header file. */
#undef HAVE_ISOCLINE_H
/* libisocline is available */
#undef HAVE_ISOCLINE_LIB
/* Define to 1 if you have the `kqueue' function. */
#undef HAVE_KQUEUE

View File

@ -370,7 +370,7 @@ void hcl_fini (hcl_t* hcl)
if (hcl->vmprim.dl_cleanup) hcl->vmprim.dl_cleanup (hcl);
}
void hcl_reset (hcl_t* hcl)
void hcl_resetcode (hcl_t* hcl)
{
hcl_oop_t v;
hcl_oow_t i;

View File

@ -324,8 +324,8 @@ typedef enum hcl_obj_type_t hcl_obj_type_t;
* terminating null in a variable-char object. internel
* use only.
* kernel: 0 - ordinary object.
* 1 - kernel object. can survive hcl_reset().
* 2 - kernel object. can survive hcl_reset().
* 1 - kernel object. can survive hcl_resetcode().
* 2 - kernel object. can survive hcl_resetcode().
* a symbol object with 2 in the kernel bits cannot be assigned a
* value with the 'set' special form.
* moved: 0 or 1. used by GC. internal use only.
@ -2127,27 +2127,6 @@ HCL_EXPORT void hcl_fini (
hcl_t* hcl
);
/**
* The hcl_reset() function some internal states back to the initial state.
* The affected internal states include byte code buffer, literal frame,
* ordinary global variables. You should take extra precaution as it is
* a risky function. For instance, a global variable inserted manually
* with hcl_putatsysdic() gets deleted if the kernel bit is not set on
* the variable symbol.
*/
HCL_EXPORT void hcl_reset (
hcl_t* hcl
);
#define HCL_XTN(hcl) ((void*)((hcl_uint8_t*)hcl + ((hcl_t*)hcl)->_instsize))
#define HCL_MMGR(hcl) (((hcl_t*)(hcl))->_mmgr)
#define HCL_CMGR(hcl) (((hcl_t*)(hcl))->_cmgr)
#define HCL_ERRNUM(hcl) (((hcl_t*)(hcl))->errnum)
void* hcl_getxtn (
hcl_t* hcl
);
HCL_EXPORT hcl_cmgr_t* hcl_getcmgr (
hcl_t* hcl
);
@ -2513,11 +2492,19 @@ HCL_EXPORT int hcl_feedpending (
hcl_t* hcl
);
HCL_EXPORT void hcl_resetfeed (
hcl_t* hcl
);
HCL_EXPORT void hcl_resetfeedloc (
hcl_t* hcl
);
HCL_EXPORT void hcl_getfeedloc (
hcl_t* hcl,
hcl_loc_t* loc
);
HCL_EXPORT int hcl_endfeed (
hcl_t* hcl
);
@ -2567,10 +2554,32 @@ HCL_EXPORT int hcl_decode (
hcl_oow_t end
);
/**
* The hcl_resetcode() function some internal states back to the initial state.
* The affected internal states include byte code buffer, literal frame,
* ordinary global variables. You should take extra precaution as it is
* a risky function. For instance, a global variable inserted manually
* with hcl_putatsysdic() gets deleted if the kernel bit is not set on
* the variable symbol.
*/
HCL_EXPORT void hcl_resetcode (
hcl_t* hcl
);
HCL_EXPORT void hcl_clearcode (
hcl_t* hcl
);
#define HCL_XTN(hcl) ((void*)((hcl_uint8_t*)hcl + ((hcl_t*)hcl)->_instsize))
#define HCL_MMGR(hcl) (((hcl_t*)(hcl))->_mmgr)
#define HCL_CMGR(hcl) (((hcl_t*)(hcl))->_cmgr)
#define HCL_ERRNUM(hcl) (((hcl_t*)(hcl))->errnum)
void* hcl_getxtn (
hcl_t* hcl
);
#if defined(HCL_HAVE_INLINE)
static HCL_INLINE hcl_code_t* hcl_getcode (hcl_t* hcl) { return &hcl->code; }
static HCL_INLINE hcl_oob_t* hcl_getbcptr (hcl_t* hcl) { return hcl->code.bc.ptr; }

View File

@ -3645,6 +3645,11 @@ int hcl_feedpending (hcl_t* hcl)
return !(hcl->c->r.st == HCL_NULL && FLX_STATE(hcl) == HCL_FLX_START);
}
void hcl_getfeedloc (hcl_t* hcl, hcl_loc_t* loc)
{
*loc = hcl->c->feed.lx.loc;
}
void hcl_resetfeedloc (hcl_t* hcl)
{
hcl->c->feed.lx.loc.line = 1;
@ -3652,6 +3657,14 @@ void hcl_resetfeedloc (hcl_t* hcl)
hcl->c->feed.lx.loc.file = HCL_NULL;
}
void hcl_resetfeed (hcl_t* hcl)
{
feed_reset_reader_state (hcl);
feed_clean_up_reader_stack (hcl);
feed_continue (hcl, HCL_FLX_START);
hcl_resetfeedloc (hcl);
}
int hcl_feed (hcl_t* hcl, const hcl_ooch_t* data, hcl_oow_t len)
{
/* TODO: need to return the number of processed characters?