diff --git a/qse/include/qse/awk/Awk.hpp b/qse/include/qse/awk/Awk.hpp index 5e55d8f5..d57a3e78 100644 --- a/qse/include/qse/awk/Awk.hpp +++ b/qse/include/qse/awk/Awk.hpp @@ -59,9 +59,9 @@ public: /** Represents an internal awk value */ typedef qse_awk_val_t val_t; /** Represents the external I/O context */ - typedef qse_awk_extio_t extio_t; + typedef qse_awk_eio_t eio_t; /** Represents the run-time context */ - typedef qse_awk_run_t run_t; + typedef qse_awk_rtx_t run_t; /** Represents the underlying interpreter */ typedef qse_awk_t awk_t; @@ -214,12 +214,12 @@ public: }; /** - * Extio class + * EIO class */ - class Extio + class EIO { protected: - Extio (extio_t* extio); + EIO (eio_t* eio); public: const char_t* getName() const; @@ -228,30 +228,30 @@ public: operator Awk* () const; operator awk_t* () const; - operator extio_t* () const; + operator eio_t* () const; operator run_t* () const; protected: - extio_t* extio; + eio_t* eio; }; /** * Pipe */ - class Pipe: public Extio + class Pipe: public EIO { public: friend class Awk; enum Mode { - READ = QSE_AWK_EXTIO_PIPE_READ, - WRITE = QSE_AWK_EXTIO_PIPE_WRITE, - RW = QSE_AWK_EXTIO_PIPE_RW + READ = QSE_AWK_EIO_PIPE_READ, + WRITE = QSE_AWK_EIO_PIPE_WRITE, + RW = QSE_AWK_EIO_PIPE_RW }; protected: - Pipe (extio_t* extio); + Pipe (eio_t* eio); public: Mode getMode () const; @@ -260,20 +260,20 @@ public: /** * File */ - class File: public Extio + class File: public EIO { public: friend class Awk; enum Mode { - READ = QSE_AWK_EXTIO_FILE_READ, - WRITE = QSE_AWK_EXTIO_FILE_WRITE, - APPEND = QSE_AWK_EXTIO_FILE_APPEND + READ = QSE_AWK_EIO_FILE_READ, + WRITE = QSE_AWK_EIO_FILE_WRITE, + APPEND = QSE_AWK_EIO_FILE_APPEND }; protected: - File (extio_t* extio); + File (eio_t* eio); public: Mode getMode () const; @@ -282,19 +282,19 @@ public: /** * Console */ - class Console: public Extio + class Console: public EIO { public: friend class Awk; enum Mode { - READ = QSE_AWK_EXTIO_CONSOLE_READ, - WRITE = QSE_AWK_EXTIO_CONSOLE_WRITE + READ = QSE_AWK_EIO_CONSOLE_READ, + WRITE = QSE_AWK_EIO_CONSOLE_WRITE }; protected: - Console (extio_t* extio); + Console (eio_t* eio); ~Console (); public: @@ -564,7 +564,7 @@ public: OPT_BXOR = QSE_AWK_BXOR, OPT_SHIFT = QSE_AWK_SHIFT, OPT_IDIV = QSE_AWK_IDIV, - OPT_EXTIO = QSE_AWK_EXTIO, + OPT_EIO = QSE_AWK_EIO, OPT_RWPIPE = QSE_AWK_RWPIPE, /** Can terminate a statement with a new line */ diff --git a/qse/include/qse/awk/awk.h b/qse/include/qse/awk/awk.h index 2db3658e..aa13b931 100644 --- a/qse/include/qse/awk/awk.h +++ b/qse/include/qse/awk/awk.h @@ -33,10 +33,10 @@ ****** */ -typedef struct qse_awk_t qse_awk_t; -typedef struct qse_awk_run_t qse_awk_run_t; +typedef struct qse_awk_t qse_awk_t; +typedef struct qse_awk_rtx_t qse_awk_rtx_t; /* (R)untime con(T)e(X)t */ typedef struct qse_awk_val_t qse_awk_val_t; -typedef struct qse_awk_extio_t qse_awk_extio_t; +typedef struct qse_awk_eio_t qse_awk_eio_t; /* External IO */ typedef struct qse_awk_prmfns_t qse_awk_prmfns_t; typedef struct qse_awk_srcios_t qse_awk_srcios_t; @@ -52,9 +52,9 @@ typedef int (*qse_awk_sprintf_t) ( typedef qse_ssize_t (*qse_awk_io_t) ( int cmd, void* arg, qse_char_t* data, qse_size_t count); -struct qse_awk_extio_t +struct qse_awk_eio_t { - qse_awk_run_t* run; /* [IN] */ + qse_awk_rtx_t* run; /* [IN] */ int type; /* [IN] console, file, coproc, pipe */ int mode; /* [IN] read, write, etc */ qse_char_t* name; /* [IN] */ @@ -78,7 +78,7 @@ struct qse_awk_extio_t qse_bool_t eos; } out; - qse_awk_extio_t* next; + qse_awk_eio_t* next; }; struct qse_awk_prmfns_t @@ -109,19 +109,19 @@ struct qse_awk_runios_t struct qse_awk_runcbs_t { int (*on_start) ( - qse_awk_run_t* run, void* data); + qse_awk_rtx_t* run, void* data); int (*on_enter) ( - qse_awk_run_t* run, void* data); + qse_awk_rtx_t* run, void* data); void (*on_statement) ( - qse_awk_run_t* run, qse_size_t line, void* data); + qse_awk_rtx_t* run, qse_size_t line, void* data); void (*on_exit) ( - qse_awk_run_t* run, qse_awk_val_t* ret, void* data); + qse_awk_rtx_t* run, qse_awk_val_t* ret, void* data); void (*on_end) ( - qse_awk_run_t* run, int errnum, void* data); + qse_awk_rtx_t* run, int errnum, void* data); void* data; }; @@ -174,9 +174,9 @@ enum qse_awk_option_t QSE_AWK_IDIV = (1 << 5), /* support getline and print */ - QSE_AWK_EXTIO = (1 << 7), + QSE_AWK_EIO = (1 << 7), - /* support dual direction pipe. QSE_AWK_EXTIO must be on */ + /* support dual direction pipe. QSE_AWK_EIO must be on */ QSE_AWK_RWPIPE = (1 << 8), /* can terminate a statement with a new line */ @@ -381,30 +381,30 @@ enum qse_awk_depth_t QSE_AWK_DEPTH_REX_MATCH = (1 << 5) }; -/* extio types */ -enum qse_awk_extio_type_t +/* eio types */ +enum qse_awk_eio_type_t { - /* extio types available */ - QSE_AWK_EXTIO_PIPE, - QSE_AWK_EXTIO_FILE, - QSE_AWK_EXTIO_CONSOLE, + /* eio types available */ + QSE_AWK_EIO_PIPE, + QSE_AWK_EIO_FILE, + QSE_AWK_EIO_CONSOLE, /* reserved for internal use only */ - QSE_AWK_EXTIO_NUM + QSE_AWK_EIO_NUM }; -enum qse_awk_extio_mode_t +enum qse_awk_eio_mode_t { - QSE_AWK_EXTIO_PIPE_READ = 0, - QSE_AWK_EXTIO_PIPE_WRITE = 1, - QSE_AWK_EXTIO_PIPE_RW = 2, + QSE_AWK_EIO_PIPE_READ = 0, + QSE_AWK_EIO_PIPE_WRITE = 1, + QSE_AWK_EIO_PIPE_RW = 2, - QSE_AWK_EXTIO_FILE_READ = 0, - QSE_AWK_EXTIO_FILE_WRITE = 1, - QSE_AWK_EXTIO_FILE_APPEND = 2, + QSE_AWK_EIO_FILE_READ = 0, + QSE_AWK_EIO_FILE_WRITE = 1, + QSE_AWK_EIO_FILE_APPEND = 2, - QSE_AWK_EXTIO_CONSOLE_READ = 0, - QSE_AWK_EXTIO_CONSOLE_WRITE = 1 + QSE_AWK_EIO_CONSOLE_READ = 0, + QSE_AWK_EIO_CONSOLE_WRITE = 1 }; enum qse_awk_global_id_t @@ -886,21 +886,21 @@ int qse_awk_run ( qse_awk_runios_t* runios, qse_awk_runcbs_t* runcbs, const qse_cstr_t* runarg, void* data); -void qse_awk_stop (qse_awk_run_t* run); +void qse_awk_stop (qse_awk_rtx_t* run); void qse_awk_stopall (qse_awk_t* awk); -qse_bool_t qse_awk_isstop (qse_awk_run_t* run); +qse_bool_t qse_awk_isstop (qse_awk_rtx_t* run); /** * Gets the number of arguments passed to qse_awk_run */ -qse_size_t qse_awk_getnargs (qse_awk_run_t* run); +qse_size_t qse_awk_getnargs (qse_awk_rtx_t* run); /** * Gets an argument passed to qse_awk_run */ -qse_awk_val_t* qse_awk_getarg (qse_awk_run_t* run, qse_size_t idx); +qse_awk_val_t* qse_awk_getarg (qse_awk_rtx_t* run, qse_size_t idx); /****f* qse.awk/qse_awk_getglobal * NAME @@ -917,7 +917,7 @@ qse_awk_val_t* qse_awk_getarg (qse_awk_run_t* run, qse_size_t idx); * SYNOPSIS */ qse_awk_val_t* qse_awk_getglobal ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, int id ); /******/ @@ -929,7 +929,7 @@ qse_awk_val_t* qse_awk_getglobal ( * SYNOPSIS */ int qse_awk_setglobal ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, int id, qse_awk_val_t* val ); @@ -948,14 +948,14 @@ int qse_awk_setglobal ( * once the return value is set. */ void qse_awk_setretval ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, qse_awk_val_t* val ); int qse_awk_setfilename ( - qse_awk_run_t* run, const qse_char_t* name, qse_size_t len); + qse_awk_rtx_t* run, const qse_char_t* name, qse_size_t len); int qse_awk_setofilename ( - qse_awk_run_t* run, const qse_char_t* name, qse_size_t len); + qse_awk_rtx_t* run, const qse_char_t* name, qse_size_t len); /****f* qse.awk/qse_awk_getrunawk @@ -965,7 +965,7 @@ int qse_awk_setofilename ( * SYNOPSIS */ qse_awk_t* qse_awk_getrunawk ( - qse_awk_run_t* run + qse_awk_rtx_t* run ); /******/ @@ -976,7 +976,7 @@ qse_awk_t* qse_awk_getrunawk ( * SYNOPSIS */ qse_mmgr_t* qse_awk_getrunmmgr ( - qse_awk_run_t* run + qse_awk_rtx_t* run ); /******/ @@ -987,7 +987,7 @@ qse_mmgr_t* qse_awk_getrunmmgr ( * SYNOPSIS */ void* qse_awk_getrundata ( - qse_awk_run_t* run + qse_awk_rtx_t* run ); /******/ @@ -998,37 +998,37 @@ void* qse_awk_getrundata ( * SYNOPSIS */ qse_map_t* qse_awk_getrunnvmap ( - qse_awk_run_t* run + qse_awk_rtx_t* run ); /******/ /* functions to manipulate the run-time error */ int qse_awk_getrunerrnum ( - qse_awk_run_t* run + qse_awk_rtx_t* run ); qse_size_t qse_awk_getrunerrlin ( - qse_awk_run_t* run + qse_awk_rtx_t* run ); const qse_char_t* qse_awk_getrunerrmsg ( - qse_awk_run_t* run + qse_awk_rtx_t* run ); void qse_awk_setrunerrnum ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, int errnum ); void qse_awk_setrunerrmsg ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, int errnum, qse_size_t errlin, const qse_char_t* errmsg ); void qse_awk_getrunerror ( - qse_awk_run_t* run, int* errnum, + qse_awk_rtx_t* run, int* errnum, qse_size_t* errlin, const qse_char_t** errmsg); void qse_awk_setrunerror ( - qse_awk_run_t* run, int errnum, qse_size_t errlin, + qse_awk_rtx_t* run, int errnum, qse_size_t errlin, const qse_cstr_t* errarg, qse_size_t argcnt); /* functions to manipulate intrinsic functions */ @@ -1036,7 +1036,7 @@ void* qse_awk_addfunc ( qse_awk_t* awk, const qse_char_t* name, qse_size_t name_len, int when_valid, qse_size_t min_args, qse_size_t max_args, const qse_char_t* arg_spec, - int (*handler)(qse_awk_run_t*,const qse_char_t*,qse_size_t)); + int (*handler)(qse_awk_rtx_t*,const qse_char_t*,qse_size_t)); int qse_awk_delfunc ( qse_awk_t* awk, const qse_char_t* name, qse_size_t name_len); @@ -1044,8 +1044,8 @@ int qse_awk_delfunc ( void qse_awk_clrbfn (qse_awk_t* awk); /* record and field functions */ -int qse_awk_clrrec (qse_awk_run_t* run, qse_bool_t skip_inrec_line); -int qse_awk_setrec (qse_awk_run_t* run, qse_size_t idx, const qse_char_t* str, qse_size_t len); +int qse_awk_clrrec (qse_awk_rtx_t* run, qse_bool_t skip_inrec_line); +int qse_awk_setrec (qse_awk_rtx_t* run, qse_size_t idx, const qse_char_t* str, qse_size_t len); /****f* qse.awk/qse_awk_alloc * NAME @@ -1116,43 +1116,43 @@ qse_size_t qse_awk_longtostr ( qse_char_t* buf, qse_size_t size); /* value manipulation functions */ -qse_awk_val_t* qse_awk_makeintval (qse_awk_run_t* run, qse_long_t v); -qse_awk_val_t* qse_awk_makerealval (qse_awk_run_t* run, qse_real_t v); +qse_awk_val_t* qse_awk_makeintval (qse_awk_rtx_t* run, qse_long_t v); +qse_awk_val_t* qse_awk_makerealval (qse_awk_rtx_t* run, qse_real_t v); qse_awk_val_t* qse_awk_makestrval0 ( - qse_awk_run_t* run, const qse_char_t* str); + qse_awk_rtx_t* run, const qse_char_t* str); qse_awk_val_t* qse_awk_makestrval ( - qse_awk_run_t* run, const qse_char_t* str, qse_size_t len); + qse_awk_rtx_t* run, const qse_char_t* str, qse_size_t len); qse_awk_val_t* qse_awk_makestrval_nodup ( - qse_awk_run_t* run, qse_char_t* str, qse_size_t len); + qse_awk_rtx_t* run, qse_char_t* str, qse_size_t len); qse_awk_val_t* qse_awk_makestrval2 ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, const qse_char_t* str1, qse_size_t len1, const qse_char_t* str2, qse_size_t len2); qse_awk_val_t* qse_awk_makerexval ( - qse_awk_run_t* run, const qse_char_t* buf, qse_size_t len, void* code); -qse_awk_val_t* qse_awk_makemapval (qse_awk_run_t* run); + qse_awk_rtx_t* run, const qse_char_t* buf, qse_size_t len, void* code); +qse_awk_val_t* qse_awk_makemapval (qse_awk_rtx_t* run); qse_awk_val_t* qse_awk_makerefval ( - qse_awk_run_t* run, int id, qse_awk_val_t** adr); + qse_awk_rtx_t* run, int id, qse_awk_val_t** adr); qse_bool_t qse_awk_isstaticval (qse_awk_val_t* val); -void qse_awk_freeval (qse_awk_run_t* run, qse_awk_val_t* val, qse_bool_t cache); +void qse_awk_freeval (qse_awk_rtx_t* run, qse_awk_val_t* val, qse_bool_t cache); -void qse_awk_refupval (qse_awk_run_t* run, qse_awk_val_t* val); -void qse_awk_refdownval (qse_awk_run_t* run, qse_awk_val_t* val); -void qse_awk_refdownval_nofree (qse_awk_run_t* run, qse_awk_val_t* val); +void qse_awk_refupval (qse_awk_rtx_t* run, qse_awk_val_t* val); +void qse_awk_refdownval (qse_awk_rtx_t* run, qse_awk_val_t* val); +void qse_awk_refdownval_nofree (qse_awk_rtx_t* run, qse_awk_val_t* val); -void qse_awk_freevalchunk (qse_awk_run_t* run, qse_awk_val_chunk_t* chunk); +void qse_awk_freevalchunk (qse_awk_rtx_t* run, qse_awk_val_chunk_t* chunk); qse_bool_t qse_awk_valtobool ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, qse_awk_val_t* val ); qse_char_t* qse_awk_valtostr ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, qse_awk_val_t* val, int opt, qse_str_t* buf, @@ -1186,7 +1186,7 @@ qse_char_t* qse_awk_valtostr ( * SYNOPSIS */ int qse_awk_valtonum ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, qse_awk_val_t* v /* the value to convert to a number */, qse_long_t* l /* a pointer to a long number */, qse_real_t* r /* a pointer to a qse_real_t */ @@ -1200,7 +1200,7 @@ int qse_awk_valtonum ( * SYNOPSIS */ int qse_awk_strtonum ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, const qse_char_t* ptr, qse_size_t len, qse_long_t* l, diff --git a/qse/include/qse/cmn/fio.h b/qse/include/qse/cmn/fio.h index a00d65cb..9438b963 100644 --- a/qse/include/qse/cmn/fio.h +++ b/qse/include/qse/cmn/fio.h @@ -88,6 +88,9 @@ typedef struct qse_fio_lck_t qse_fio_lck_t; struct qse_fio_t { + /* note that qse_fio_t is instantiated statically + * in sio.c. make sure that you update the static instantiation + * when you change the structure of qse_fio_t */ QSE_DEFINE_STD_FIELDS (fio) int errnum; qse_fio_hnd_t handle; @@ -204,6 +207,12 @@ qse_ssize_t qse_fio_read ( /****f* qse.cmn.fio/qse_fio_write * NAME * qse_fio_write - write data + * + * DESCRIPTION + * If QSE_FIO_TEXT is used and the size parameter is (qse_size_t)-1, + * the function treats the data parameter as a pointer to a null-terminated + * string. + * * SYNOPSIS */ qse_ssize_t qse_fio_write ( diff --git a/qse/include/qse/cmn/sio.h b/qse/include/qse/cmn/sio.h index 19ab5dc2..dc893a42 100644 --- a/qse/include/qse/cmn/sio.h +++ b/qse/include/qse/cmn/sio.h @@ -95,9 +95,8 @@ void qse_sio_purge ( qse_sio_t* sio ); -#if 0 qse_ssize_t qse_sio_getc ( - qse_sio_t* sio, + qse_sio_t* sio, qse_char_t* c ); @@ -107,10 +106,10 @@ qse_ssize_t qse_sio_gets ( qse_size_t size ); - -qse_ssize_t qse_sio_getstr ( - qse_sio_t* sio, - qse_str_t* buf +qse_ssize_t qse_sio_getsn ( + qse_sio_t* sio, + qse_char_t* buf, + qse_size_t size ); qse_ssize_t qse_sio_putc ( @@ -122,24 +121,28 @@ qse_ssize_t qse_sio_puts ( qse_sio_t* sio, const qse_char_t* str ); -#endif -qse_ssize_t qse_sio_read ( - qse_sio_t* sio, - qse_char_t* buf, - qse_size_t size -); - -qse_ssize_t qse_sio_write ( +qse_ssize_t qse_sio_putsn ( qse_sio_t* sio, const qse_char_t* str, qse_size_t size ); +/****f* qse.cmn.sio/qse_sio_getpos + * NAME + * qse_sio_getpos - get the stream position + * + * WARNING + * The getpos() function may not return the desired postion because of + * buffering. + * + * SYNOPSIS + */ int qse_sio_getpos ( qse_sio_t* sio, qse_sio_pos_t* pos ); +/******/ int qse_sio_setpos ( qse_sio_t* sio, @@ -147,14 +150,6 @@ int qse_sio_setpos ( ); #if 0 -qse_ssize_t qse_sio_putsn (qse_sio_t* sio, ...); -qse_ssize_t qse_sio_putsxn (qse_sio_t* sio, ...); -qse_ssize_t qse_sio_putsv (qse_sio_t* sio, qse_va_list ap); -qse_ssize_t qse_sio_putsxv (qse_sio_t* sio, qse_va_list ap); - -/* WARNING: - * getpos may not return the desired postion because of the buffering - */ int qse_sio_rewind (qse_sio_t* sio); int qse_sio_movetoend (qse_sio_t* sio); #endif diff --git a/qse/include/qse/cmn/tio.h b/qse/include/qse/cmn/tio.h index 05cce7e5..68f94d11 100644 --- a/qse/include/qse/cmn/tio.h +++ b/qse/include/qse/cmn/tio.h @@ -263,6 +263,12 @@ qse_ssize_t qse_tio_read ( /******/ /****f* qse.cmn.tio/qse_tio_write + * NAME + * qse_tio_write - write text + * + * DESCRIPTION + * If the size paramenter is (qse_size_t)-1, the function treats the data + * parameter as a pointer to a null-terminated string. * * SYNOPSIS */ diff --git a/qse/lib/awk/Awk.cpp b/qse/lib/awk/Awk.cpp index d475711b..c1b5ae0d 100644 --- a/qse/lib/awk/Awk.cpp +++ b/qse/lib/awk/Awk.cpp @@ -49,83 +49,83 @@ void Awk::Source::setHandle (void* handle) } ////////////////////////////////////////////////////////////////// -// Awk::Extio +// Awk::EIO ////////////////////////////////////////////////////////////////// -Awk::Extio::Extio (extio_t* extio): extio (extio) +Awk::EIO::EIO (eio_t* eio): eio (eio) { } -const Awk::char_t* Awk::Extio::getName () const +const Awk::char_t* Awk::EIO::getName () const { - return extio->name; + return eio->name; } -const void* Awk::Extio::getHandle () const +const void* Awk::EIO::getHandle () const { - return extio->handle; + return eio->handle; } -void Awk::Extio::setHandle (void* handle) +void Awk::EIO::setHandle (void* handle) { - extio->handle = handle; + eio->handle = handle; } -Awk::Extio::operator Awk::Awk* () const +Awk::EIO::operator Awk::Awk* () const { // it assumes that the Awk object is set to the data field. // make sure that it happens in Awk::run () - runios.data = this; - return (Awk::Awk*)extio->data; + return (Awk::Awk*)eio->data; } -Awk::Extio::operator Awk::awk_t* () const +Awk::EIO::operator Awk::awk_t* () const { // it assumes that the Awk object is set to the data field. // make sure that it happens in Awk::run () - runios.data = this; - return (Awk::awk_t*)(Awk::Awk*)extio->data; + return (Awk::awk_t*)(Awk::Awk*)eio->data; } -Awk::Extio::operator Awk::extio_t* () const +Awk::EIO::operator Awk::eio_t* () const { - return extio; + return eio; } -Awk::Extio::operator Awk::run_t* () const +Awk::EIO::operator Awk::run_t* () const { - return extio->run; + return eio->run; } ////////////////////////////////////////////////////////////////// // Awk::Pipe ////////////////////////////////////////////////////////////////// -Awk::Pipe::Pipe (extio_t* extio): Extio(extio) +Awk::Pipe::Pipe (eio_t* eio): EIO(eio) { } Awk::Pipe::Mode Awk::Pipe::getMode () const { - return (Mode)extio->mode; + return (Mode)eio->mode; } ////////////////////////////////////////////////////////////////// // Awk::File ////////////////////////////////////////////////////////////////// -Awk::File::File (extio_t* extio): Extio(extio) +Awk::File::File (eio_t* eio): EIO(eio) { } Awk::File::Mode Awk::File::getMode () const { - return (Mode)extio->mode; + return (Mode)eio->mode; } ////////////////////////////////////////////////////////////////// // Awk::Console ////////////////////////////////////////////////////////////////// -Awk::Console::Console (extio_t* extio): Extio(extio), filename(QSE_NULL) +Awk::Console::Console (eio_t* eio): EIO(eio), filename(QSE_NULL) { } @@ -139,15 +139,15 @@ Awk::Console::~Console () int Awk::Console::setFileName (const char_t* name) { - if (extio->mode == READ) + if (eio->mode == READ) { return qse_awk_setfilename ( - extio->run, name, qse_strlen(name)); + eio->run, name, qse_strlen(name)); } else { return qse_awk_setofilename ( - extio->run, name, qse_strlen(name)); + eio->run, name, qse_strlen(name)); } } @@ -156,19 +156,19 @@ int Awk::Console::setFNR (long_t fnr) qse_awk_val_t* tmp; int n; - tmp = qse_awk_makeintval (extio->run, fnr); + tmp = qse_awk_makeintval (eio->run, fnr); if (tmp == QSE_NULL) return -1; - qse_awk_refupval (extio->run, tmp); - n = qse_awk_setglobal (extio->run, QSE_AWK_GLOBAL_FNR, tmp); - qse_awk_refdownval (extio->run, tmp); + qse_awk_refupval (eio->run, tmp); + n = qse_awk_setglobal (eio->run, QSE_AWK_GLOBAL_FNR, tmp); + qse_awk_refdownval (eio->run, tmp); return n; } Awk::Console::Mode Awk::Console::getMode () const { - return (Mode)extio->mode; + return (Mode)eio->mode; } ////////////////////////////////////////////////////////////////// @@ -1211,7 +1211,7 @@ int Awk::open () int opt = OPT_IMPLICIT | - OPT_EXTIO | + OPT_EIO | OPT_NEWLINE | OPT_BASEONE | OPT_PABLOCK; @@ -1614,12 +1614,12 @@ Awk::ssize_t Awk::sourceWriter ( Awk::ssize_t Awk::pipeHandler ( int cmd, void* arg, char_t* data, size_t count) { - extio_t* extio = (extio_t*)arg; - Awk* awk = (Awk*)extio->data; + eio_t* eio = (eio_t*)arg; + Awk* awk = (Awk*)eio->data; - QSE_ASSERT ((extio->type & 0xFF) == QSE_AWK_EXTIO_PIPE); + QSE_ASSERT ((eio->type & 0xFF) == QSE_AWK_EIO_PIPE); - Pipe pipe (extio); + Pipe pipe (eio); switch (cmd) { @@ -1646,12 +1646,12 @@ Awk::ssize_t Awk::pipeHandler ( Awk::ssize_t Awk::fileHandler ( int cmd, void* arg, char_t* data, size_t count) { - extio_t* extio = (extio_t*)arg; - Awk* awk = (Awk*)extio->data; + eio_t* eio = (eio_t*)arg; + Awk* awk = (Awk*)eio->data; - QSE_ASSERT ((extio->type & 0xFF) == QSE_AWK_EXTIO_FILE); + QSE_ASSERT ((eio->type & 0xFF) == QSE_AWK_EIO_FILE); - File file (extio); + File file (eio); switch (cmd) { @@ -1678,12 +1678,12 @@ Awk::ssize_t Awk::fileHandler ( Awk::ssize_t Awk::consoleHandler ( int cmd, void* arg, char_t* data, size_t count) { - extio_t* extio = (extio_t*)arg; - Awk* awk = (Awk*)extio->data; + eio_t* eio = (eio_t*)arg; + Awk* awk = (Awk*)eio->data; - QSE_ASSERT ((extio->type & 0xFF) == QSE_AWK_EXTIO_CONSOLE); + QSE_ASSERT ((eio->type & 0xFF) == QSE_AWK_EIO_CONSOLE); - Console console (extio); + Console console (eio); switch (cmd) { diff --git a/qse/lib/awk/Makefile.am b/qse/lib/awk/Makefile.am index b4d341c7..8a8e75c8 100644 --- a/qse/lib/awk/Makefile.am +++ b/qse/lib/awk/Makefile.am @@ -4,7 +4,7 @@ AUTOMAKE_OPTIONS = nostdinc AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libqseawk.la -libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c func.c misc.c extio.c std.c awk.h extio.h func.h misc.h parse.h run.h tree.h +libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c func.c misc.c eio.c std.c awk.h eio.h func.h misc.h parse.h run.h tree.h libqseawk_la_LDFLAGS= -L../cmn -L../utl -version-info 1:0:0 -no-undefined libqseawk_la_LIBADD= -lqsecmn -lqseutl diff --git a/qse/lib/awk/Makefile.in b/qse/lib/awk/Makefile.in index 7747e1cb..a932bd21 100644 --- a/qse/lib/awk/Makefile.in +++ b/qse/lib/awk/Makefile.in @@ -61,7 +61,7 @@ libqseawk___la_LINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) \ @ENABLE_CXX_TRUE@am_libqseawk___la_rpath = -rpath $(libdir) libqseawk_la_DEPENDENCIES = am_libqseawk_la_OBJECTS = awk.lo err.lo tree.lo parse.lo run.lo rec.lo \ - val.lo func.lo misc.lo extio.lo std.lo + val.lo func.lo misc.lo eio.lo std.lo libqseawk_la_OBJECTS = $(am_libqseawk_la_OBJECTS) libqseawk_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -217,7 +217,7 @@ top_srcdir = @top_srcdir@ AUTOMAKE_OPTIONS = nostdinc AM_CPPFLAGS = -I$(top_srcdir)/include lib_LTLIBRARIES = libqseawk.la $(am__append_1) -libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c func.c misc.c extio.c std.c awk.h extio.h func.h misc.h parse.h run.h tree.h +libqseawk_la_SOURCES = awk.c err.c tree.c parse.c run.c rec.c val.c func.c misc.c eio.c std.c awk.h eio.h func.h misc.h parse.h run.h tree.h libqseawk_la_LDFLAGS = -L../cmn -L../utl -version-info 1:0:0 -no-undefined libqseawk_la_LIBADD = -lqsecmn -lqseutl @ENABLE_CXX_TRUE@libqseawk___la_SOURCES = Awk.cpp StdAwk.cpp @@ -297,8 +297,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Awk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StdAwk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/err.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/extio.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/func.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/misc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Plo@am__quote@ diff --git a/qse/lib/awk/StdAwk.cpp b/qse/lib/awk/StdAwk.cpp index 165f6b3b..30f424aa 100644 --- a/qse/lib/awk/StdAwk.cpp +++ b/qse/lib/awk/StdAwk.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -340,7 +341,7 @@ int StdAwk::flushPipe (Pipe& io) int StdAwk::openFile (File& io) { Awk::File::Mode mode = io.getMode(); - qse_sio_t* sio = QSE_NULL; + qse_fio_t* fio = QSE_NULL; int flags; switch (mode) @@ -359,37 +360,39 @@ int StdAwk::openFile (File& io) break; } - sio = qse_sio_open ( + fio = qse_fio_open ( ((Awk*)io)->getMmgr(), 0, io.getName(), - flags + flags, + QSE_FIO_RUSR | QSE_FIO_WUSR | + QSE_FIO_RGRP | QSE_FIO_ROTH ); - if (sio == NULL) return -1; + if (fio == NULL) return -1; - io.setHandle (sio); + io.setHandle (fio); return 1; } int StdAwk::closeFile (File& io) { - qse_sio_close ((qse_sio_t*)io.getHandle()); + qse_fio_close ((qse_fio_t*)io.getHandle()); return 0; } StdAwk::ssize_t StdAwk::readFile (File& io, char_t* buf, size_t len) { - return qse_sio_read ((qse_sio_t*)io.getHandle(), buf, len); + return qse_fio_read ((qse_fio_t*)io.getHandle(), buf, len); } StdAwk::ssize_t StdAwk::writeFile (File& io, const char_t* buf, size_t len) { - return qse_sio_write ((qse_sio_t*)io.getHandle(), buf, len); + return qse_fio_write ((qse_fio_t*)io.getHandle(), buf, len); } int StdAwk::flushFile (File& io) { - return qse_sio_flush ((qse_sio_t*)io.getHandle()); + return qse_fio_flush ((qse_fio_t*)io.getHandle()); } // memory allocation primitives diff --git a/qse/lib/awk/awk.h b/qse/lib/awk/awk.h index 4b580a29..c7aee9c1 100644 --- a/qse/lib/awk/awk.h +++ b/qse/lib/awk/awk.h @@ -34,7 +34,7 @@ typedef struct qse_awk_tree_t qse_awk_tree_t; #include "func.h" #include "parse.h" #include "run.h" -#include "extio.h" +#include "eio.h" #include "misc.h" #define QSE_AWK_MAX_GLOBALS 9999 @@ -246,7 +246,7 @@ struct qse_awk_chain_t qse_awk_chain_t* next; }; -struct qse_awk_run_t +struct qse_awk_rtx_t { int id; qse_map_t* named; @@ -332,13 +332,13 @@ struct qse_awk_run_t } subsep; } global; - /* extio chain */ + /* eio chain */ struct { - qse_awk_io_t handler[QSE_AWK_EXTIO_NUM]; + qse_awk_io_t handler[QSE_AWK_EIO_NUM]; void* data; - qse_awk_extio_t* chain; - } extio; + qse_awk_eio_t* chain; + } eio; struct { diff --git a/qse/lib/awk/extio.c b/qse/lib/awk/eio.c similarity index 75% rename from qse/lib/awk/extio.c rename to qse/lib/awk/eio.c index bcfb4ecc..165b850e 100644 --- a/qse/lib/awk/extio.c +++ b/qse/lib/awk/eio.c @@ -1,5 +1,5 @@ /* - * $Id: extio.c 466 2008-12-09 09:50:40Z baconevi $ + * $Id: eio.c 466 2008-12-09 09:50:40Z baconevi $ * Copyright 2006-2008 Chung, Hyung-Hwan. @@ -31,20 +31,20 @@ static int in_type_map[] = { /* the order should match the order of the * QSE_AWK_IN_XXX values in tree.h */ - QSE_AWK_EXTIO_PIPE, - QSE_AWK_EXTIO_PIPE, - QSE_AWK_EXTIO_FILE, - QSE_AWK_EXTIO_CONSOLE + QSE_AWK_EIO_PIPE, + QSE_AWK_EIO_PIPE, + QSE_AWK_EIO_FILE, + QSE_AWK_EIO_CONSOLE }; static int in_mode_map[] = { /* the order should match the order of the * QSE_AWK_IN_XXX values in tree.h */ - QSE_AWK_EXTIO_PIPE_READ, - QSE_AWK_EXTIO_PIPE_RW, - QSE_AWK_EXTIO_FILE_READ, - QSE_AWK_EXTIO_CONSOLE_READ + QSE_AWK_EIO_PIPE_READ, + QSE_AWK_EIO_PIPE_RW, + QSE_AWK_EIO_FILE_READ, + QSE_AWK_EIO_CONSOLE_READ }; static int in_mask_map[] = @@ -59,22 +59,22 @@ static int out_type_map[] = { /* the order should match the order of the * QSE_AWK_OUT_XXX values in tree.h */ - QSE_AWK_EXTIO_PIPE, - QSE_AWK_EXTIO_PIPE, - QSE_AWK_EXTIO_FILE, - QSE_AWK_EXTIO_FILE, - QSE_AWK_EXTIO_CONSOLE + QSE_AWK_EIO_PIPE, + QSE_AWK_EIO_PIPE, + QSE_AWK_EIO_FILE, + QSE_AWK_EIO_FILE, + QSE_AWK_EIO_CONSOLE }; static int out_mode_map[] = { /* the order should match the order of the * QSE_AWK_OUT_XXX values in tree.h */ - QSE_AWK_EXTIO_PIPE_WRITE, - QSE_AWK_EXTIO_PIPE_RW, - QSE_AWK_EXTIO_FILE_WRITE, - QSE_AWK_EXTIO_FILE_APPEND, - QSE_AWK_EXTIO_CONSOLE_WRITE + QSE_AWK_EIO_PIPE_WRITE, + QSE_AWK_EIO_PIPE_RW, + QSE_AWK_EIO_FILE_WRITE, + QSE_AWK_EIO_FILE_APPEND, + QSE_AWK_EIO_CONSOLE_WRITE }; static int out_mask_map[] = @@ -86,13 +86,13 @@ static int out_mask_map[] = MASK_WRITE }; -int qse_awk_readextio ( - qse_awk_run_t* run, int in_type, +int qse_awk_readeio ( + qse_awk_rtx_t* run, int in_type, const qse_char_t* name, qse_str_t* buf) { - qse_awk_extio_t* p = run->extio.chain; + qse_awk_eio_t* p = run->eio.chain; qse_awk_io_t handler; - int extio_type, extio_mode, extio_mask, ret, n; + int eio_type, eio_mode, eio_mask, ret, n; qse_ssize_t x; qse_awk_val_t* rs; qse_char_t* rs_ptr; @@ -104,13 +104,13 @@ int qse_awk_readextio ( QSE_ASSERT (in_type >= 0 && in_type <= QSE_COUNTOF(in_mode_map)); QSE_ASSERT (in_type >= 0 && in_type <= QSE_COUNTOF(in_mask_map)); - /* translate the in_type into the relevant extio type and mode */ - extio_type = in_type_map[in_type]; - extio_mode = in_mode_map[in_type]; - extio_mask = in_mask_map[in_type]; + /* translate the in_type into the relevant eio type and mode */ + eio_type = in_type_map[in_type]; + eio_mode = in_mode_map[in_type]; + eio_mask = in_mask_map[in_type]; /* get the io handler provided by a user */ - handler = run->extio.handler[extio_type]; + handler = run->eio.handler[eio_type]; if (handler == QSE_NULL) { /* no io handler provided */ @@ -121,7 +121,7 @@ int qse_awk_readextio ( /* search the chain for exiting an existing io name */ while (p != QSE_NULL) { - if (p->type == (extio_type | extio_mask) && + if (p->type == (eio_type | eio_mask) && qse_strcmp (p->name,name) == 0) break; p = p->next; } @@ -130,8 +130,8 @@ int qse_awk_readextio ( { /* if the name doesn't exist in the chain, create an entry * to the chain */ - p = (qse_awk_extio_t*) QSE_AWK_ALLOC ( - run->awk, QSE_SIZEOF(qse_awk_extio_t)); + p = (qse_awk_eio_t*) QSE_AWK_ALLOC ( + run->awk, QSE_SIZEOF(qse_awk_eio_t)); if (p == QSE_NULL) { qse_awk_setrunerrnum (run, QSE_AWK_ENOMEM); @@ -147,11 +147,11 @@ int qse_awk_readextio ( } p->run = run; - p->type = (extio_type | extio_mask); - p->mode = extio_mode; + p->type = (eio_type | eio_mask); + p->mode = eio_mode; p->handle = QSE_NULL; p->next = QSE_NULL; - p->data = run->extio.data; + p->data = run->eio.data; p->in.buf[0] = QSE_T('\0'); p->in.pos = 0; @@ -179,8 +179,8 @@ int qse_awk_readextio ( } /* chain it */ - p->next = run->extio.chain; - run->extio.chain = p; + p->next = run->eio.chain; + run->eio.chain = p; /* usually, x == 0 indicates that it has reached the end * of the input. the user io handler can return 0 for the @@ -411,8 +411,8 @@ int qse_awk_readextio ( return ret; } -int qse_awk_writeextio_val ( - qse_awk_run_t* run, int out_type, +int qse_awk_writeeio_val ( + qse_awk_rtx_t* run, int out_type, const qse_char_t* name, qse_awk_val_t* v) { qse_char_t* str; @@ -433,31 +433,31 @@ int qse_awk_writeextio_val ( if (str == QSE_NULL) return -1; } - n = qse_awk_writeextio_str (run, out_type, name, str, len); + n = qse_awk_writeeio_str (run, out_type, name, str, len); if (v->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str); return n; } -int qse_awk_writeextio_str ( - qse_awk_run_t* run, int out_type, +int qse_awk_writeeio_str ( + qse_awk_rtx_t* run, int out_type, const qse_char_t* name, qse_char_t* str, qse_size_t len) { - qse_awk_extio_t* p = run->extio.chain; + qse_awk_eio_t* p = run->eio.chain; qse_awk_io_t handler; - int extio_type, extio_mode, extio_mask; + int eio_type, eio_mode, eio_mask; qse_ssize_t n; QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_type_map)); QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_mode_map)); QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_mask_map)); - /* translate the out_type into the relevant extio type and mode */ - extio_type = out_type_map[out_type]; - extio_mode = out_mode_map[out_type]; - extio_mask = out_mask_map[out_type]; + /* translate the out_type into the relevant eio type and mode */ + eio_type = out_type_map[out_type]; + eio_mode = out_mode_map[out_type]; + eio_mask = out_mask_map[out_type]; - handler = run->extio.handler[extio_type]; + handler = run->eio.handler[eio_type]; if (handler == QSE_NULL) { /* no io handler provided */ @@ -465,29 +465,29 @@ int qse_awk_writeextio_str ( return -1; } - /* look for the corresponding extio for name */ + /* look for the corresponding eio for name */ while (p != QSE_NULL) { /* the file "1.tmp", in the following code snippets, * would be opened by the first print statement, but not by * the second print statement. this is because * both QSE_AWK_OUT_FILE and QSE_AWK_OUT_APFILE are - * translated to QSE_AWK_EXTIO_FILE and it is used to + * translated to QSE_AWK_EIO_FILE and it is used to * keep track of file handles.. * * print "1111" >> "1.tmp" * print "1111" > "1.tmp" */ - if (p->type == (extio_type | extio_mask) && + if (p->type == (eio_type | eio_mask) && qse_strcmp (p->name, name) == 0) break; p = p->next; } - /* if there is not corresponding extio for name, create one */ + /* if there is not corresponding eio for name, create one */ if (p == QSE_NULL) { - p = (qse_awk_extio_t*) QSE_AWK_ALLOC ( - run->awk, QSE_SIZEOF(qse_awk_extio_t)); + p = (qse_awk_eio_t*) QSE_AWK_ALLOC ( + run->awk, QSE_SIZEOF(qse_awk_eio_t)); if (p == QSE_NULL) { qse_awk_setrunerror ( @@ -505,11 +505,11 @@ int qse_awk_writeextio_str ( } p->run = run; - p->type = (extio_type | extio_mask); - p->mode = extio_mode; + p->type = (eio_type | eio_mask); + p->mode = eio_mode; p->handle = QSE_NULL; p->next = QSE_NULL; - p->data = run->extio.data; + p->data = run->eio.data; p->out.eof = QSE_FALSE; p->out.eos = QSE_FALSE; @@ -528,8 +528,8 @@ int qse_awk_writeextio_str ( } /* chain it */ - p->next = run->extio.chain; - run->extio.chain = p; + p->next = run->eio.chain; + run->eio.chain = p; /* usually, n == 0 indicates that it has reached the end * of the input. the user io handler can return 0 for the @@ -581,12 +581,12 @@ int qse_awk_writeextio_str ( return 1; } -int qse_awk_flushextio ( - qse_awk_run_t* run, int out_type, const qse_char_t* name) +int qse_awk_flusheio ( + qse_awk_rtx_t* run, int out_type, const qse_char_t* name) { - qse_awk_extio_t* p = run->extio.chain; + qse_awk_eio_t* p = run->eio.chain; qse_awk_io_t handler; - int extio_type, /*extio_mode,*/ extio_mask; + int eio_type, /*eio_mode,*/ eio_mask; qse_ssize_t n; qse_bool_t ok = QSE_FALSE; @@ -594,12 +594,12 @@ int qse_awk_flushextio ( QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_mode_map)); QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_mask_map)); - /* translate the out_type into the relevant extio type and mode */ - extio_type = out_type_map[out_type]; - /*extio_mode = out_mode_map[out_type];*/ - extio_mask = out_mask_map[out_type]; + /* translate the out_type into the relevant eio type and mode */ + eio_type = out_type_map[out_type]; + /*eio_mode = out_mode_map[out_type];*/ + eio_mask = out_mask_map[out_type]; - handler = run->extio.handler[extio_type]; + handler = run->eio.handler[eio_type]; if (handler == QSE_NULL) { /* no io handler provided */ @@ -607,10 +607,10 @@ int qse_awk_flushextio ( return -1; } - /* look for the corresponding extio for name */ + /* look for the corresponding eio for name */ while (p != QSE_NULL) { - if (p->type == (extio_type | extio_mask) && + if (p->type == (eio_type | eio_mask) && (name == QSE_NULL || qse_strcmp(p->name,name) == 0)) { qse_awk_setrunerrnum (run, QSE_AWK_ENOERR); @@ -631,29 +631,29 @@ int qse_awk_flushextio ( if (ok) return 0; - /* there is no corresponding extio for name */ + /* there is no corresponding eio for name */ qse_awk_setrunerrnum (run, QSE_AWK_EIONONE); return -1; } -int qse_awk_nextextio_read ( - qse_awk_run_t* run, int in_type, const qse_char_t* name) +int qse_awk_nexteio_read ( + qse_awk_rtx_t* run, int in_type, const qse_char_t* name) { - qse_awk_extio_t* p = run->extio.chain; + qse_awk_eio_t* p = run->eio.chain; qse_awk_io_t handler; - int extio_type, /*extio_mode,*/ extio_mask; + int eio_type, /*eio_mode,*/ eio_mask; qse_ssize_t n; QSE_ASSERT (in_type >= 0 && in_type <= QSE_COUNTOF(in_type_map)); QSE_ASSERT (in_type >= 0 && in_type <= QSE_COUNTOF(in_mode_map)); QSE_ASSERT (in_type >= 0 && in_type <= QSE_COUNTOF(in_mask_map)); - /* translate the in_type into the relevant extio type and mode */ - extio_type = in_type_map[in_type]; - /*extio_mode = in_mode_map[in_type];*/ - extio_mask = in_mask_map[in_type]; + /* translate the in_type into the relevant eio type and mode */ + eio_type = in_type_map[in_type]; + /*eio_mode = in_mode_map[in_type];*/ + eio_mask = in_mask_map[in_type]; - handler = run->extio.handler[extio_type]; + handler = run->eio.handler[eio_type]; if (handler == QSE_NULL) { /* no io handler provided */ @@ -663,7 +663,7 @@ int qse_awk_nextextio_read ( while (p != QSE_NULL) { - if (p->type == (extio_type | extio_mask) && + if (p->type == (eio_type | eio_mask) && qse_strcmp (p->name,name) == 0) break; p = p->next; } @@ -672,7 +672,7 @@ int qse_awk_nextextio_read ( { /* something is totally wrong */ QSE_ASSERT ( - !"should never happen - cannot find the relevant extio entry"); + !"should never happen - cannot find the relevant eio entry"); qse_awk_setrunerror (run, QSE_AWK_EINTERN, 0, QSE_NULL, 0); return -1; } @@ -695,7 +695,7 @@ int qse_awk_nextextio_read ( if (n == 0) { /* the next stream cannot be opened. - * set the eos flags so that the next call to nextextio_read + * set the eos flags so that the next call to nexteio_read * will return 0 without executing the handler */ p->in.eos = QSE_TRUE; return 0; @@ -714,24 +714,24 @@ int qse_awk_nextextio_read ( } } -int qse_awk_nextextio_write ( - qse_awk_run_t* run, int out_type, const qse_char_t* name) +int qse_awk_nexteio_write ( + qse_awk_rtx_t* run, int out_type, const qse_char_t* name) { - qse_awk_extio_t* p = run->extio.chain; + qse_awk_eio_t* p = run->eio.chain; qse_awk_io_t handler; - int extio_type, /*extio_mode,*/ extio_mask; + int eio_type, /*eio_mode,*/ eio_mask; qse_ssize_t n; QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_type_map)); QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_mode_map)); QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_mask_map)); - /* translate the out_type into the relevant extio type and mode */ - extio_type = out_type_map[out_type]; - /*extio_mode = out_mode_map[out_type];*/ - extio_mask = out_mask_map[out_type]; + /* translate the out_type into the relevant eio type and mode */ + eio_type = out_type_map[out_type]; + /*eio_mode = out_mode_map[out_type];*/ + eio_mask = out_mask_map[out_type]; - handler = run->extio.handler[extio_type]; + handler = run->eio.handler[eio_type]; if (handler == QSE_NULL) { /* no io handler provided */ @@ -741,7 +741,7 @@ int qse_awk_nextextio_write ( while (p != QSE_NULL) { - if (p->type == (extio_type | extio_mask) && + if (p->type == (eio_type | eio_mask) && qse_strcmp (p->name,name) == 0) break; p = p->next; } @@ -749,7 +749,7 @@ int qse_awk_nextextio_write ( if (p == QSE_NULL) { /* something is totally wrong */ - QSE_ASSERT (!"should never happen - cannot find the relevant extio entry"); + QSE_ASSERT (!"should never happen - cannot find the relevant eio entry"); qse_awk_setrunerror (run, QSE_AWK_EINTERN, 0, QSE_NULL, 0); return -1; @@ -773,7 +773,7 @@ int qse_awk_nextextio_write ( if (n == 0) { /* the next stream cannot be opened. - * set the eos flags so that the next call to nextextio_write + * set the eos flags so that the next call to nexteio_write * will return 0 without executing the handler */ p->out.eos = QSE_TRUE; return 0; @@ -787,23 +787,23 @@ int qse_awk_nextextio_write ( } } -int qse_awk_closeextio_read ( - qse_awk_run_t* run, int in_type, const qse_char_t* name) +int qse_awk_closeeio_read ( + qse_awk_rtx_t* run, int in_type, const qse_char_t* name) { - qse_awk_extio_t* p = run->extio.chain, * px = QSE_NULL; + qse_awk_eio_t* p = run->eio.chain, * px = QSE_NULL; qse_awk_io_t handler; - int extio_type, /*extio_mode,*/ extio_mask; + int eio_type, /*eio_mode,*/ eio_mask; QSE_ASSERT (in_type >= 0 && in_type <= QSE_COUNTOF(in_type_map)); QSE_ASSERT (in_type >= 0 && in_type <= QSE_COUNTOF(in_mode_map)); QSE_ASSERT (in_type >= 0 && in_type <= QSE_COUNTOF(in_mask_map)); - /* translate the in_type into the relevant extio type and mode */ - extio_type = in_type_map[in_type]; - /*extio_mode = in_mode_map[in_type];*/ - extio_mask = in_mask_map[in_type]; + /* translate the in_type into the relevant eio type and mode */ + eio_type = in_type_map[in_type]; + /*eio_mode = in_mode_map[in_type];*/ + eio_mask = in_mask_map[in_type]; - handler = run->extio.handler[extio_type]; + handler = run->eio.handler[eio_type]; if (handler == QSE_NULL) { /* no io handler provided */ @@ -813,12 +813,12 @@ int qse_awk_closeextio_read ( while (p != QSE_NULL) { - if (p->type == (extio_type | extio_mask) && + if (p->type == (eio_type | eio_mask) && qse_strcmp (p->name, name) == 0) { qse_awk_io_t handler; - handler = run->extio.handler[p->type & MASK_CLEAR]; + handler = run->eio.handler[p->type & MASK_CLEAR]; if (handler != QSE_NULL) { if (handler (QSE_AWK_IO_CLOSE, p, QSE_NULL, 0) <= -1) @@ -830,7 +830,7 @@ int qse_awk_closeextio_read ( } if (px != QSE_NULL) px->next = p->next; - else run->extio.chain = p->next; + else run->eio.chain = p->next; QSE_AWK_FREE (run->awk, p->name); QSE_AWK_FREE (run->awk, p); @@ -846,23 +846,23 @@ int qse_awk_closeextio_read ( return -1; } -int qse_awk_closeextio_write ( - qse_awk_run_t* run, int out_type, const qse_char_t* name) +int qse_awk_closeeio_write ( + qse_awk_rtx_t* run, int out_type, const qse_char_t* name) { - qse_awk_extio_t* p = run->extio.chain, * px = QSE_NULL; + qse_awk_eio_t* p = run->eio.chain, * px = QSE_NULL; qse_awk_io_t handler; - int extio_type, /*extio_mode,*/ extio_mask; + int eio_type, /*eio_mode,*/ eio_mask; QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_type_map)); QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_mode_map)); QSE_ASSERT (out_type >= 0 && out_type <= QSE_COUNTOF(out_mask_map)); - /* translate the out_type into the relevant extio type and mode */ - extio_type = out_type_map[out_type]; - /*extio_mode = out_mode_map[out_type];*/ - extio_mask = out_mask_map[out_type]; + /* translate the out_type into the relevant eio type and mode */ + eio_type = out_type_map[out_type]; + /*eio_mode = out_mode_map[out_type];*/ + eio_mask = out_mask_map[out_type]; - handler = run->extio.handler[extio_type]; + handler = run->eio.handler[eio_type]; if (handler == QSE_NULL) { /* no io handler provided */ @@ -872,12 +872,12 @@ int qse_awk_closeextio_write ( while (p != QSE_NULL) { - if (p->type == (extio_type | extio_mask) && + if (p->type == (eio_type | eio_mask) && qse_strcmp (p->name, name) == 0) { qse_awk_io_t handler; - handler = run->extio.handler[p->type & MASK_CLEAR]; + handler = run->eio.handler[p->type & MASK_CLEAR]; if (handler != QSE_NULL) { qse_awk_setrunerrnum (run, QSE_AWK_ENOERR); @@ -890,7 +890,7 @@ int qse_awk_closeextio_write ( } if (px != QSE_NULL) px->next = p->next; - else run->extio.chain = p->next; + else run->eio.chain = p->next; QSE_AWK_FREE (run->awk, p->name); QSE_AWK_FREE (run->awk, p); @@ -905,19 +905,19 @@ int qse_awk_closeextio_write ( return -1; } -int qse_awk_closeextio (qse_awk_run_t* run, const qse_char_t* name) +int qse_awk_closeeio (qse_awk_rtx_t* run, const qse_char_t* name) { - qse_awk_extio_t* p = run->extio.chain, * px = QSE_NULL; + qse_awk_eio_t* p = run->eio.chain, * px = QSE_NULL; while (p != QSE_NULL) { /* it handles the first that matches the given name - * regardless of the extio type */ + * regardless of the eio type */ if (qse_strcmp (p->name, name) == 0) { qse_awk_io_t handler; - handler = run->extio.handler[p->type & MASK_CLEAR]; + handler = run->eio.handler[p->type & MASK_CLEAR]; if (handler != QSE_NULL) { qse_awk_setrunerrnum (run, QSE_AWK_ENOERR); @@ -931,7 +931,7 @@ int qse_awk_closeextio (qse_awk_run_t* run, const qse_char_t* name) } if (px != QSE_NULL) px->next = p->next; - else run->extio.chain = p->next; + else run->eio.chain = p->next; QSE_AWK_FREE (run->awk, p->name); QSE_AWK_FREE (run->awk, p); @@ -947,22 +947,22 @@ int qse_awk_closeextio (qse_awk_run_t* run, const qse_char_t* name) return -1; } -void qse_awk_clearextio (qse_awk_run_t* run) +void qse_awk_cleareio (qse_awk_rtx_t* run) { - qse_awk_extio_t* next; + qse_awk_eio_t* next; qse_awk_io_t handler; qse_ssize_t n; - while (run->extio.chain != QSE_NULL) + while (run->eio.chain != QSE_NULL) { - handler = run->extio.handler[ - run->extio.chain->type & MASK_CLEAR]; - next = run->extio.chain->next; + handler = run->eio.handler[ + run->eio.chain->type & MASK_CLEAR]; + next = run->eio.chain->next; if (handler != QSE_NULL) { qse_awk_setrunerrnum (run, QSE_AWK_ENOERR); - n = handler (QSE_AWK_IO_CLOSE, run->extio.chain, QSE_NULL, 0); + n = handler (QSE_AWK_IO_CLOSE, run->eio.chain, QSE_NULL, 0); if (n <= -1) { if (run->errnum == QSE_AWK_ENOERR) @@ -971,9 +971,9 @@ void qse_awk_clearextio (qse_awk_run_t* run) } } - QSE_AWK_FREE (run->awk, run->extio.chain->name); - QSE_AWK_FREE (run->awk, run->extio.chain); + QSE_AWK_FREE (run->awk, run->eio.chain->name); + QSE_AWK_FREE (run->awk, run->eio.chain); - run->extio.chain = next; + run->eio.chain = next; } } diff --git a/qse/lib/awk/eio.h b/qse/lib/awk/eio.h new file mode 100644 index 00000000..950a3ff1 --- /dev/null +++ b/qse/lib/awk/eio.h @@ -0,0 +1,59 @@ +/* + * $Id: eio.h 363 2008-09-04 10:58:08Z baconevi $ + * + Copyright 2006-2008 Chung, Hyung-Hwan. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#ifndef _QSE_LIB_AWK_EIO_H_ +#define _QSE_LIB_AWK_EIO_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int qse_awk_readeio ( + qse_awk_rtx_t* run, int in_type, + const qse_char_t* name, qse_str_t* buf); + +int qse_awk_writeeio_val ( + qse_awk_rtx_t* run, int out_type, + const qse_char_t* name, qse_awk_val_t* v); + +int qse_awk_writeeio_str ( + qse_awk_rtx_t* run, int out_type, + const qse_char_t* name, qse_char_t* str, qse_size_t len); + +int qse_awk_flusheio ( + qse_awk_rtx_t* run, int out_type, const qse_char_t* name); + +int qse_awk_nexteio_read ( + qse_awk_rtx_t* run, int in_type, const qse_char_t* name); + +int qse_awk_nexteio_write ( + qse_awk_rtx_t* run, int out_type, const qse_char_t* name); + +int qse_awk_closeeio_read ( + qse_awk_rtx_t* run, int in_type, const qse_char_t* name); +int qse_awk_closeeio_write ( + qse_awk_rtx_t* run, int out_type, const qse_char_t* name); +int qse_awk_closeeio (qse_awk_rtx_t* run, const qse_char_t* name); + +void qse_awk_cleareio (qse_awk_rtx_t* run); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/qse/lib/awk/err.c b/qse/lib/awk/err.c index f54c8d09..1af1109f 100644 --- a/qse/lib/awk/err.c +++ b/qse/lib/awk/err.c @@ -345,17 +345,17 @@ void qse_awk_seterror ( } } -int qse_awk_getrunerrnum (qse_awk_run_t* run) +int qse_awk_getrunerrnum (qse_awk_rtx_t* run) { return run->errnum; } -qse_size_t qse_awk_getrunerrlin (qse_awk_run_t* run) +qse_size_t qse_awk_getrunerrlin (qse_awk_rtx_t* run) { return run->errlin; } -const qse_char_t* qse_awk_getrunerrmsg (qse_awk_run_t* run) +const qse_char_t* qse_awk_getrunerrmsg (qse_awk_rtx_t* run) { if (run->errmsg[0] == QSE_T('\0')) return qse_awk_geterrstr (run->awk, run->errnum); @@ -363,14 +363,14 @@ const qse_char_t* qse_awk_getrunerrmsg (qse_awk_run_t* run) return run->errmsg; } -void qse_awk_setrunerrnum (qse_awk_run_t* run, int errnum) +void qse_awk_setrunerrnum (qse_awk_rtx_t* run, int errnum) { run->errnum = errnum; run->errlin = 0; run->errmsg[0] = QSE_T('\0'); } -void qse_awk_setrunerrmsg (qse_awk_run_t* run, +void qse_awk_setrunerrmsg (qse_awk_rtx_t* run, int errnum, qse_size_t errlin, const qse_char_t* errmsg) { run->errnum = errnum; @@ -379,7 +379,7 @@ void qse_awk_setrunerrmsg (qse_awk_run_t* run, } void qse_awk_getrunerror ( - qse_awk_run_t* run, int* errnum, + qse_awk_rtx_t* run, int* errnum, qse_size_t* errlin, const qse_char_t** errmsg) { if (errnum != QSE_NULL) *errnum = run->errnum; @@ -394,7 +394,7 @@ void qse_awk_getrunerror ( } void qse_awk_setrunerror ( - qse_awk_run_t* run, int errnum, qse_size_t errlin, + qse_awk_rtx_t* run, int errnum, qse_size_t errlin, const qse_cstr_t* errarg, qse_size_t argcnt) { const qse_char_t* errfmt; diff --git a/qse/lib/awk/extio.h b/qse/lib/awk/extio.h deleted file mode 100644 index b37d5dfa..00000000 --- a/qse/lib/awk/extio.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * $Id: extio.h 363 2008-09-04 10:58:08Z baconevi $ - * - Copyright 2006-2008 Chung, Hyung-Hwan. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - */ - -#ifndef _QSE_LIB_AWK_EXTIO_H_ -#define _QSE_LIB_AWK_EXTIO_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -int qse_awk_readextio ( - qse_awk_run_t* run, int in_type, - const qse_char_t* name, qse_str_t* buf); - -int qse_awk_writeextio_val ( - qse_awk_run_t* run, int out_type, - const qse_char_t* name, qse_awk_val_t* v); - -int qse_awk_writeextio_str ( - qse_awk_run_t* run, int out_type, - const qse_char_t* name, qse_char_t* str, qse_size_t len); - -int qse_awk_flushextio ( - qse_awk_run_t* run, int out_type, const qse_char_t* name); - -int qse_awk_nextextio_read ( - qse_awk_run_t* run, int in_type, const qse_char_t* name); - -int qse_awk_nextextio_write ( - qse_awk_run_t* run, int out_type, const qse_char_t* name); - -int qse_awk_closeextio_read ( - qse_awk_run_t* run, int in_type, const qse_char_t* name); -int qse_awk_closeextio_write ( - qse_awk_run_t* run, int out_type, const qse_char_t* name); -int qse_awk_closeextio (qse_awk_run_t* run, const qse_char_t* name); - -void qse_awk_clearextio (qse_awk_run_t* run); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/qse/lib/awk/func.c b/qse/lib/awk/func.c index 9d413aa2..6357c824 100644 --- a/qse/lib/awk/func.c +++ b/qse/lib/awk/func.c @@ -18,18 +18,18 @@ #include "awk.h" -static int bfn_close (qse_awk_run_t*, const qse_char_t*, qse_size_t); -static int bfn_fflush (qse_awk_run_t*, const qse_char_t*, qse_size_t); -static int bfn_index (qse_awk_run_t*, const qse_char_t*, qse_size_t); -static int bfn_length (qse_awk_run_t*, const qse_char_t*, qse_size_t); -static int bfn_substr (qse_awk_run_t*, const qse_char_t*, qse_size_t); -static int bfn_split (qse_awk_run_t*, const qse_char_t*, qse_size_t); -static int bfn_tolower (qse_awk_run_t*, const qse_char_t*, qse_size_t); -static int bfn_toupper (qse_awk_run_t*, const qse_char_t*, qse_size_t); -static int bfn_gsub (qse_awk_run_t*, const qse_char_t*, qse_size_t); -static int bfn_sub (qse_awk_run_t*, const qse_char_t*, qse_size_t); -static int bfn_match (qse_awk_run_t*, const qse_char_t*, qse_size_t); -static int bfn_sprintf (qse_awk_run_t*, const qse_char_t*, qse_size_t); +static int bfn_close (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); +static int bfn_fflush (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); +static int bfn_index (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); +static int bfn_length (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); +static int bfn_substr (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); +static int bfn_split (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); +static int bfn_tolower (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); +static int bfn_toupper (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); +static int bfn_gsub (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); +static int bfn_sub (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); +static int bfn_match (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); +static int bfn_sprintf (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); #undef MAX #define MAX QSE_TYPE_UNSIGNED_MAX(qse_size_t) @@ -37,8 +37,8 @@ static int bfn_sprintf (qse_awk_run_t*, const qse_char_t*, qse_size_t); static qse_awk_bfn_t sys_bfn[] = { /* io functions */ - { {QSE_T("close"), 5}, QSE_AWK_EXTIO, {1, 1, QSE_NULL}, bfn_close}, - { {QSE_T("fflush"), 6}, QSE_AWK_EXTIO, {0, 1, QSE_NULL}, bfn_fflush}, + { {QSE_T("close"), 5}, QSE_AWK_EIO, {1, 1, QSE_NULL}, bfn_close}, + { {QSE_T("fflush"), 6}, QSE_AWK_EIO, {0, 1, QSE_NULL}, bfn_fflush}, /* string functions */ { {QSE_T("index"), 5}, 0, {2, 2, QSE_NULL}, bfn_index}, @@ -59,7 +59,7 @@ void* qse_awk_addfunc ( qse_awk_t* awk, const qse_char_t* name, qse_size_t name_len, int when_valid, qse_size_t min_args, qse_size_t max_args, const qse_char_t* arg_spec, - int (*handler)(qse_awk_run_t*,const qse_char_t*,qse_size_t)) + int (*handler)(qse_awk_rtx_t*,const qse_char_t*,qse_size_t)) { qse_awk_bfn_t* bfn; qse_size_t spec_len; @@ -226,7 +226,7 @@ qse_awk_bfn_t* qse_awk_getbfn ( } static int bfn_close ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_awk_val_t* v, * a0; @@ -261,9 +261,9 @@ static int bfn_close ( * it either. * another reason for this is if close is called explicitly * with an empty string, it may close the console that uses - * an empty string for its identification because closeextio - * closes any extios that match the name given unlike - * closeextio_read or closeextio_write. */ + * an empty string for its identification because closeeio + * closes any eios that match the name given unlike + * closeeio_read or closeeio_write. */ n = -1; goto skip_close; } @@ -279,7 +279,7 @@ static int bfn_close ( } } - n = qse_awk_closeextio (run, name); + n = qse_awk_closeeio (run, name); /* if (n == -1 && run->errnum != QSE_AWK_EIONONE) { @@ -303,14 +303,14 @@ skip_close: return 0; } -static int flush_extio ( - qse_awk_run_t* run, int extio, const qse_char_t* name, int n) +static int flush_eio ( + qse_awk_rtx_t* run, int eio, const qse_char_t* name, int n) { int n2; - if (run->extio.handler[extio] != QSE_NULL) + if (run->eio.handler[eio] != QSE_NULL) { - n2 = qse_awk_flushextio (run, extio, name); + n2 = qse_awk_flusheio (run, eio, name); if (n2 == -1) { /* @@ -334,7 +334,7 @@ static int flush_extio ( } static int bfn_fflush ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_awk_val_t* a0; @@ -349,7 +349,7 @@ static int bfn_fflush ( { /* flush the console output. * fflush() should return -1 on errors */ - n = qse_awk_flushextio (run, QSE_AWK_OUT_CONSOLE, QSE_T("")); + n = qse_awk_flusheio (run, QSE_AWK_OUT_CONSOLE, QSE_T("")); } else { @@ -383,13 +383,13 @@ static int bfn_fflush ( ptr++; } - /* flush the given extio */ - n = flush_extio ( - run, QSE_AWK_EXTIO_FILE, + /* flush the given eio */ + n = flush_eio ( + run, QSE_AWK_EIO_FILE, ((len0 == 0)? QSE_NULL: str0), 1); /*if (n == -99) return -1;*/ - n = flush_extio ( - run, QSE_AWK_EXTIO_PIPE, + n = flush_eio ( + run, QSE_AWK_EIO_PIPE, ((len0 == 0)? QSE_NULL: str0), n); /*if (n == -99) return -1;*/ @@ -415,7 +415,7 @@ static int bfn_fflush ( } static int bfn_index ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_awk_val_t* a0, * a1; @@ -478,7 +478,7 @@ static int bfn_index ( } static int bfn_length ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_awk_val_t* v; @@ -513,7 +513,7 @@ static int bfn_length ( } static int bfn_substr ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_awk_val_t* a0, * a1, * a2, * r; @@ -587,7 +587,7 @@ static int bfn_substr ( } static int bfn_split ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_awk_val_t* a0, * a1, * a2, * t1, * t2, ** a1_ref; @@ -844,7 +844,7 @@ static int bfn_split ( } static int bfn_tolower ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_char_t* str; @@ -884,7 +884,7 @@ static int bfn_tolower ( } static int bfn_toupper ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_char_t* str; @@ -923,7 +923,7 @@ static int bfn_toupper ( return 0; } -static int __substitute (qse_awk_run_t* run, qse_long_t max_count) +static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count) { qse_size_t nargs; qse_awk_val_t* a0, * a1, * a2, ** a2_ref, * v; @@ -1215,19 +1215,19 @@ static int __substitute (qse_awk_run_t* run, qse_long_t max_count) } static int bfn_gsub ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { return __substitute (run, 0); } static int bfn_sub ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { return __substitute (run, 1); } static int bfn_match ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_awk_val_t* a0, * a1; @@ -1346,7 +1346,7 @@ static int bfn_match ( } static int bfn_sprintf ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_awk_val_t* a0; diff --git a/qse/lib/awk/func.h b/qse/lib/awk/func.h index 4c346cb3..607a23fa 100644 --- a/qse/lib/awk/func.h +++ b/qse/lib/awk/func.h @@ -38,7 +38,7 @@ struct qse_awk_bfn_t qse_char_t* spec; } arg; - int (*handler) (qse_awk_run_t*, const qse_char_t*, qse_size_t); + int (*handler) (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); /*qse_awk_bfn_t* next;*/ }; diff --git a/qse/lib/awk/misc.c b/qse/lib/awk/misc.c index ad81e5cd..fbb6ba78 100644 --- a/qse/lib/awk/misc.c +++ b/qse/lib/awk/misc.c @@ -611,7 +611,7 @@ qse_size_t qse_awk_longtostr ( } qse_char_t* qse_awk_strtok ( - qse_awk_run_t* run, const qse_char_t* s, + qse_awk_rtx_t* run, const qse_char_t* s, const qse_char_t* delim, qse_char_t** tok, qse_size_t* tok_len) { return qse_awk_strxntok ( @@ -620,7 +620,7 @@ qse_char_t* qse_awk_strtok ( } qse_char_t* qse_awk_strxtok ( - qse_awk_run_t* run, const qse_char_t* s, qse_size_t len, + qse_awk_rtx_t* run, const qse_char_t* s, qse_size_t len, const qse_char_t* delim, qse_char_t** tok, qse_size_t* tok_len) { return qse_awk_strxntok ( @@ -629,7 +629,7 @@ qse_char_t* qse_awk_strxtok ( } qse_char_t* qse_awk_strntok ( - qse_awk_run_t* run, const qse_char_t* s, + qse_awk_rtx_t* run, const qse_char_t* s, const qse_char_t* delim, qse_size_t delim_len, qse_char_t** tok, qse_size_t* tok_len) { @@ -639,7 +639,7 @@ qse_char_t* qse_awk_strntok ( } qse_char_t* qse_awk_strxntok ( - qse_awk_run_t* run, const qse_char_t* s, qse_size_t len, + qse_awk_rtx_t* run, const qse_char_t* s, qse_size_t len, const qse_char_t* delim, qse_size_t delim_len, qse_char_t** tok, qse_size_t* tok_len) { @@ -831,7 +831,7 @@ exit_loop: } qse_char_t* qse_awk_strxntokbyrex ( - qse_awk_run_t* run, const qse_char_t* s, qse_size_t len, + qse_awk_rtx_t* run, const qse_char_t* s, qse_size_t len, void* rex, qse_char_t** tok, qse_size_t* tok_len, int* errnum) { int n; diff --git a/qse/lib/awk/misc.h b/qse/lib/awk/misc.h index c466e35a..eb02b702 100644 --- a/qse/lib/awk/misc.h +++ b/qse/lib/awk/misc.h @@ -24,25 +24,25 @@ extern "C" { #endif qse_char_t* qse_awk_strtok ( - qse_awk_run_t* run, const qse_char_t* s, + qse_awk_rtx_t* run, const qse_char_t* s, const qse_char_t* delim, qse_char_t** tok, qse_size_t* tok_len); qse_char_t* qse_awk_strxtok ( - qse_awk_run_t* run, const qse_char_t* s, qse_size_t len, + qse_awk_rtx_t* run, const qse_char_t* s, qse_size_t len, const qse_char_t* delim, qse_char_t** tok, qse_size_t* tok_len); qse_char_t* qse_awk_strntok ( - qse_awk_run_t* run, const qse_char_t* s, + qse_awk_rtx_t* run, const qse_char_t* s, const qse_char_t* delim, qse_size_t delim_len, qse_char_t** tok, qse_size_t* tok_len); qse_char_t* qse_awk_strxntok ( - qse_awk_run_t* run, const qse_char_t* s, qse_size_t len, + qse_awk_rtx_t* run, const qse_char_t* s, qse_size_t len, const qse_char_t* delim, qse_size_t delim_len, qse_char_t** tok, qse_size_t* tok_len); qse_char_t* qse_awk_strxntokbyrex ( - qse_awk_run_t* run, const qse_char_t* s, qse_size_t len, + qse_awk_rtx_t* run, const qse_char_t* s, qse_size_t len, void* rex, qse_char_t** tok, qse_size_t* tok_len, int* errnum); diff --git a/qse/lib/awk/parse.c b/qse/lib/awk/parse.c index 55dfee65..bbf7305e 100644 --- a/qse/lib/awk/parse.c +++ b/qse/lib/awk/parse.c @@ -178,12 +178,12 @@ static qse_awk_nde_t* parse_binary_expr ( qse_awk_nde_t*(*next_level_func)(qse_awk_t*,qse_size_t)); static qse_awk_nde_t* parse_logical_or (qse_awk_t* awk, qse_size_t line); -static qse_awk_nde_t* parse_logical_or_with_extio (qse_awk_t* awk, qse_size_t line); +static qse_awk_nde_t* parse_logical_or_with_eio (qse_awk_t* awk, qse_size_t line); static qse_awk_nde_t* parse_logical_and (qse_awk_t* awk, qse_size_t line); static qse_awk_nde_t* parse_in (qse_awk_t* awk, qse_size_t line); static qse_awk_nde_t* parse_regex_match (qse_awk_t* awk, qse_size_t line); static qse_awk_nde_t* parse_bitwise_or (qse_awk_t* awk, qse_size_t line); -static qse_awk_nde_t* parse_bitwise_or_with_extio (qse_awk_t* awk, qse_size_t line); +static qse_awk_nde_t* parse_bitwise_or_with_eio (qse_awk_t* awk, qse_size_t line); static qse_awk_nde_t* parse_bitwise_xor (qse_awk_t* awk, qse_size_t line); static qse_awk_nde_t* parse_bitwise_and (qse_awk_t* awk, qse_size_t line); static qse_awk_nde_t* parse_equality (qse_awk_t* awk, qse_size_t line); @@ -282,11 +282,11 @@ static kwent_t kwtab[] = { QSE_T("nextofile"), 9, TOKEN_NEXTOFILE, QSE_AWK_PABLOCK | QSE_AWK_NEXTOFILE }, { QSE_T("delete"), 6, TOKEN_DELETE, 0 }, { QSE_T("reset"), 5, TOKEN_RESET, QSE_AWK_RESET }, - { QSE_T("print"), 5, TOKEN_PRINT, QSE_AWK_EXTIO }, - { QSE_T("printf"), 6, TOKEN_PRINTF, QSE_AWK_EXTIO }, + { QSE_T("print"), 5, TOKEN_PRINT, QSE_AWK_EIO }, + { QSE_T("printf"), 6, TOKEN_PRINTF, QSE_AWK_EIO }, /* keywords that can start an expression */ - { QSE_T("getline"), 7, TOKEN_GETLINE, QSE_AWK_EXTIO }, + { QSE_T("getline"), 7, TOKEN_GETLINE, QSE_AWK_EIO }, { QSE_NULL, 0, 0, 0 } }; @@ -332,13 +332,13 @@ static global_t gtab[] = { QSE_T("OFILENAME"), 9, QSE_AWK_PABLOCK | QSE_AWK_NEXTOFILE }, /* output real-to-str conversion format for 'print' */ - { QSE_T("OFMT"), 4, QSE_AWK_EXTIO}, + { QSE_T("OFMT"), 4, QSE_AWK_EIO}, /* output field separator for 'print' */ - { QSE_T("OFS"), 3, QSE_AWK_EXTIO }, + { QSE_T("OFS"), 3, QSE_AWK_EIO }, /* output record separator. used for 'print' and blockless output */ - { QSE_T("ORS"), 3, QSE_AWK_EXTIO }, + { QSE_T("ORS"), 3, QSE_AWK_EIO }, { QSE_T("RLENGTH"), 7, 0 }, { QSE_T("RS"), 2, 0 }, @@ -796,9 +796,9 @@ static qse_awk_t* parse_progunit (qse_awk_t* awk) } } - if ((awk->option & QSE_AWK_EXTIO) != QSE_AWK_EXTIO) + if ((awk->option & QSE_AWK_EIO) != QSE_AWK_EIO) { - /* blockless pattern requires QSE_AWK_EXTIO + /* blockless pattern requires QSE_AWK_EIO * to be ON because the implicit block is * "print $0" */ SETERRLIN (awk, QSE_AWK_ENOSUP, tline); @@ -2227,10 +2227,10 @@ static qse_awk_nde_t* parse_binary_expr ( static qse_awk_nde_t* parse_logical_or (qse_awk_t* awk, qse_size_t line) { - if ((awk->option & QSE_AWK_EXTIO) && + if ((awk->option & QSE_AWK_EIO) && (awk->option & QSE_AWK_RWPIPE)) { - return parse_logical_or_with_extio (awk, line); + return parse_logical_or_with_eio (awk, line); } else { @@ -2244,7 +2244,7 @@ static qse_awk_nde_t* parse_logical_or (qse_awk_t* awk, qse_size_t line) } } -static qse_awk_nde_t* parse_logical_or_with_extio (qse_awk_t* awk, qse_size_t line) +static qse_awk_nde_t* parse_logical_or_with_eio (qse_awk_t* awk, qse_size_t line) { qse_awk_nde_t* left, * right; @@ -2434,9 +2434,9 @@ static qse_awk_nde_t* parse_regex_match (qse_awk_t* awk, qse_size_t line) static qse_awk_nde_t* parse_bitwise_or (qse_awk_t* awk, qse_size_t line) { - if (awk->option & QSE_AWK_EXTIO) + if (awk->option & QSE_AWK_EIO) { - return parse_bitwise_or_with_extio (awk, line); + return parse_bitwise_or_with_eio (awk, line); } else { @@ -2451,7 +2451,7 @@ static qse_awk_nde_t* parse_bitwise_or (qse_awk_t* awk, qse_size_t line) } } -static qse_awk_nde_t* parse_bitwise_or_with_extio (qse_awk_t* awk, qse_size_t line) +static qse_awk_nde_t* parse_bitwise_or_with_eio (qse_awk_t* awk, qse_size_t line) { qse_awk_nde_t* left, * right; diff --git a/qse/lib/awk/rec.c b/qse/lib/awk/rec.c index 393b409e..f1b0b3df 100644 --- a/qse/lib/awk/rec.c +++ b/qse/lib/awk/rec.c @@ -18,13 +18,13 @@ #include "awk.h" -static int split_record (qse_awk_run_t* run); +static int split_record (qse_awk_rtx_t* run); static int recomp_record_fields ( - qse_awk_run_t* run, qse_size_t lv, + qse_awk_rtx_t* run, qse_size_t lv, const qse_char_t* str, qse_size_t len); int qse_awk_setrec ( - qse_awk_run_t* run, qse_size_t idx, + qse_awk_rtx_t* run, qse_size_t idx, const qse_char_t* str, qse_size_t len) { qse_awk_val_t* v; @@ -94,7 +94,7 @@ int qse_awk_setrec ( return 0; } -static int split_record (qse_awk_run_t* run) +static int split_record (qse_awk_rtx_t* run) { qse_char_t* p, * tok; qse_size_t len, tok_len, nflds; @@ -248,7 +248,7 @@ static int split_record (qse_awk_run_t* run) return 0; } -int qse_awk_clrrec (qse_awk_run_t* run, qse_bool_t skip_inrec_line) +int qse_awk_clrrec (qse_awk_rtx_t* run, qse_bool_t skip_inrec_line) { qse_size_t i; int n = 0; @@ -287,7 +287,7 @@ int qse_awk_clrrec (qse_awk_run_t* run, qse_bool_t skip_inrec_line) } static int recomp_record_fields ( - qse_awk_run_t* run, qse_size_t lv, + qse_awk_rtx_t* run, qse_size_t lv, const qse_char_t* str, qse_size_t len) { qse_awk_val_t* v; diff --git a/qse/lib/awk/run.c b/qse/lib/awk/run.c index efa49c9e..441d5199 100644 --- a/qse/lib/awk/run.c +++ b/qse/lib/awk/run.c @@ -69,192 +69,192 @@ enum exit_level_t (idx) < QSE_TYPE_MAX(qse_size_t)) static int set_global ( - qse_awk_run_t* run, qse_size_t idx, + qse_awk_rtx_t* run, qse_size_t idx, qse_awk_nde_var_t* var, qse_awk_val_t* val); static int init_run ( - qse_awk_run_t* run, qse_awk_t* awk, + qse_awk_rtx_t* run, qse_awk_t* awk, qse_awk_runios_t* runios, void* data); -static void deinit_run (qse_awk_run_t* run); +static void deinit_run (qse_awk_rtx_t* run); static int run_main ( - qse_awk_run_t* run, const qse_char_t* main, + qse_awk_rtx_t* run, const qse_char_t* main, const qse_cstr_t* runarg); -static int run_pattern_blocks (qse_awk_run_t* run); +static int run_pattern_blocks (qse_awk_rtx_t* run); static int run_pattern_block_chain ( - qse_awk_run_t* run, qse_awk_chain_t* chain); + qse_awk_rtx_t* run, qse_awk_chain_t* chain); static int run_pattern_block ( - qse_awk_run_t* run, qse_awk_chain_t* chain, qse_size_t block_no); -static int run_block (qse_awk_run_t* run, qse_awk_nde_blk_t* nde); -static int run_block0 (qse_awk_run_t* run, qse_awk_nde_blk_t* nde); -static int run_statement (qse_awk_run_t* run, qse_awk_nde_t* nde); -static int run_if (qse_awk_run_t* run, qse_awk_nde_if_t* nde); -static int run_while (qse_awk_run_t* run, qse_awk_nde_while_t* nde); -static int run_for (qse_awk_run_t* run, qse_awk_nde_for_t* nde); -static int run_foreach (qse_awk_run_t* run, qse_awk_nde_foreach_t* nde); -static int run_break (qse_awk_run_t* run, qse_awk_nde_break_t* nde); -static int run_continue (qse_awk_run_t* run, qse_awk_nde_continue_t* nde); -static int run_return (qse_awk_run_t* run, qse_awk_nde_return_t* nde); -static int run_exit (qse_awk_run_t* run, qse_awk_nde_exit_t* nde); -static int run_next (qse_awk_run_t* run, qse_awk_nde_next_t* nde); -static int run_nextfile (qse_awk_run_t* run, qse_awk_nde_nextfile_t* nde); -static int run_delete (qse_awk_run_t* run, qse_awk_nde_delete_t* nde); -static int run_reset (qse_awk_run_t* run, qse_awk_nde_reset_t* nde); -static int run_print (qse_awk_run_t* run, qse_awk_nde_print_t* nde); -static int run_printf (qse_awk_run_t* run, qse_awk_nde_print_t* nde); + qse_awk_rtx_t* run, qse_awk_chain_t* chain, qse_size_t block_no); +static int run_block (qse_awk_rtx_t* run, qse_awk_nde_blk_t* nde); +static int run_block0 (qse_awk_rtx_t* run, qse_awk_nde_blk_t* nde); +static int run_statement (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static int run_if (qse_awk_rtx_t* run, qse_awk_nde_if_t* nde); +static int run_while (qse_awk_rtx_t* run, qse_awk_nde_while_t* nde); +static int run_for (qse_awk_rtx_t* run, qse_awk_nde_for_t* nde); +static int run_foreach (qse_awk_rtx_t* run, qse_awk_nde_foreach_t* nde); +static int run_break (qse_awk_rtx_t* run, qse_awk_nde_break_t* nde); +static int run_continue (qse_awk_rtx_t* run, qse_awk_nde_continue_t* nde); +static int run_return (qse_awk_rtx_t* run, qse_awk_nde_return_t* nde); +static int run_exit (qse_awk_rtx_t* run, qse_awk_nde_exit_t* nde); +static int run_next (qse_awk_rtx_t* run, qse_awk_nde_next_t* nde); +static int run_nextfile (qse_awk_rtx_t* run, qse_awk_nde_nextfile_t* nde); +static int run_delete (qse_awk_rtx_t* run, qse_awk_nde_delete_t* nde); +static int run_reset (qse_awk_rtx_t* run, qse_awk_nde_reset_t* nde); +static int run_print (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde); +static int run_printf (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde); static int output_formatted ( - qse_awk_run_t* run, int out_type, const qse_char_t* dst, + qse_awk_rtx_t* run, int out_type, const qse_char_t* dst, const qse_char_t* fmt, qse_size_t fmt_len, qse_awk_nde_t* args); -static qse_awk_val_t* eval_expression (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_expression0 (qse_awk_run_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_expression (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_expression0 (qse_awk_rtx_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_group (qse_awk_run_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_group (qse_awk_rtx_t* run, qse_awk_nde_t* nde); static qse_awk_val_t* eval_assignment ( - qse_awk_run_t* run, qse_awk_nde_t* nde); + qse_awk_rtx_t* run, qse_awk_nde_t* nde); static qse_awk_val_t* do_assignment ( - qse_awk_run_t* run, qse_awk_nde_t* var, qse_awk_val_t* val); + qse_awk_rtx_t* run, qse_awk_nde_t* var, qse_awk_val_t* val); static qse_awk_val_t* do_assignment_scalar ( - qse_awk_run_t* run, qse_awk_nde_var_t* var, qse_awk_val_t* val); + qse_awk_rtx_t* run, qse_awk_nde_var_t* var, qse_awk_val_t* val); static qse_awk_val_t* do_assignment_map ( - qse_awk_run_t* run, qse_awk_nde_var_t* var, qse_awk_val_t* val); + qse_awk_rtx_t* run, qse_awk_nde_var_t* var, qse_awk_val_t* val); static qse_awk_val_t* do_assignment_pos ( - qse_awk_run_t* run, qse_awk_nde_pos_t* pos, qse_awk_val_t* val); + qse_awk_rtx_t* run, qse_awk_nde_pos_t* pos, qse_awk_val_t* val); static qse_awk_val_t* eval_binary ( - qse_awk_run_t* run, qse_awk_nde_t* nde); + qse_awk_rtx_t* run, qse_awk_nde_t* nde); static qse_awk_val_t* eval_binop_lor ( - qse_awk_run_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right); + qse_awk_rtx_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right); static qse_awk_val_t* eval_binop_land ( - qse_awk_run_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right); + qse_awk_rtx_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right); static qse_awk_val_t* eval_binop_in ( - qse_awk_run_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right); + qse_awk_rtx_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right); static qse_awk_val_t* eval_binop_bor ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_bxor ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_band ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_eq ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_ne ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_gt ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_ge ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_lt ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_le ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_lshift ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_rshift ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_plus ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_minus ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_mul ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_div ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_idiv ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_mod ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_exp ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_concat ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); static qse_awk_val_t* eval_binop_ma ( - qse_awk_run_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right); + qse_awk_rtx_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right); static qse_awk_val_t* eval_binop_nm ( - qse_awk_run_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right); + qse_awk_rtx_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right); static qse_awk_val_t* eval_binop_match0 ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right, + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right, qse_size_t lline, qse_size_t rline, int ret); -static qse_awk_val_t* eval_unary (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_incpre (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_incpst (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_cnd (qse_awk_run_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_unary (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_cnd (qse_awk_rtx_t* run, qse_awk_nde_t* nde); static qse_awk_val_t* eval_afn_intrinsic ( - qse_awk_run_t* run, qse_awk_nde_t* nde, + qse_awk_rtx_t* run, qse_awk_nde_t* nde, void(*errhandler)(void*), void* eharg); -static qse_awk_val_t* eval_bfn (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_afn (qse_awk_run_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_bfn (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_afn (qse_awk_rtx_t* run, qse_awk_nde_t* nde); static qse_awk_val_t* eval_call ( - qse_awk_run_t* run, qse_awk_nde_t* nde, + qse_awk_rtx_t* run, qse_awk_nde_t* nde, const qse_char_t* bfn_arg_spec, qse_awk_afn_t* afn, void(*errhandler)(void*), void* eharg); static int get_reference ( - qse_awk_run_t* run, qse_awk_nde_t* nde, qse_awk_val_t*** ref); + qse_awk_rtx_t* run, qse_awk_nde_t* nde, qse_awk_val_t*** ref); static qse_awk_val_t** get_reference_indexed ( - qse_awk_run_t* run, qse_awk_nde_var_t* nde, qse_awk_val_t** val); + qse_awk_rtx_t* run, qse_awk_nde_var_t* nde, qse_awk_val_t** val); -static qse_awk_val_t* eval_int (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_real (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_str (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_rex (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_named (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_global (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_local (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_arg (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_namedidx (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_globalidx (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_localidx (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_argidx (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_pos (qse_awk_run_t* run, qse_awk_nde_t* nde); -static qse_awk_val_t* eval_getline (qse_awk_run_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_int (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_real (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_str (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_rex (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_named (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_global (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_local (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_arg (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_namedidx (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_globalidx (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_localidx (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_argidx (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_pos (qse_awk_rtx_t* run, qse_awk_nde_t* nde); +static qse_awk_val_t* eval_getline (qse_awk_rtx_t* run, qse_awk_nde_t* nde); -static int __raw_push (qse_awk_run_t* run, void* val); +static int __raw_push (qse_awk_rtx_t* run, void* val); #define __raw_pop(run) \ do { \ QSE_ASSERT ((run)->stack_top > (run)->stack_base); \ (run)->stack_top--; \ } while (0) -static int read_record (qse_awk_run_t* run); -static int shorten_record (qse_awk_run_t* run, qse_size_t nflds); +static int read_record (qse_awk_rtx_t* run); +static int shorten_record (qse_awk_rtx_t* run, qse_size_t nflds); static qse_char_t* idxnde_to_str ( - qse_awk_run_t* run, qse_awk_nde_t* nde, qse_char_t* buf, qse_size_t* len); + qse_awk_rtx_t* run, qse_awk_nde_t* nde, qse_char_t* buf, qse_size_t* len); typedef qse_awk_val_t* (*binop_func_t) ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right); -typedef qse_awk_val_t* (*eval_expr_t) (qse_awk_run_t* run, qse_awk_nde_t* nde); + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); +typedef qse_awk_val_t* (*eval_expr_t) (qse_awk_rtx_t* run, qse_awk_nde_t* nde); -qse_size_t qse_awk_getnargs (qse_awk_run_t* run) +qse_size_t qse_awk_getnargs (qse_awk_rtx_t* run) { return (qse_size_t) STACK_NARGS (run); } -qse_awk_val_t* qse_awk_getarg (qse_awk_run_t* run, qse_size_t idx) +qse_awk_val_t* qse_awk_getarg (qse_awk_rtx_t* run, qse_size_t idx) { return STACK_ARG (run, idx); } -qse_awk_val_t* qse_awk_getglobal (qse_awk_run_t* run, int id) +qse_awk_val_t* qse_awk_getglobal (qse_awk_rtx_t* run, int id) { QSE_ASSERT (id >= 0 && id < (int)QSE_LDA_SIZE(run->awk->parse.globals)); return STACK_GLOBAL (run, id); } -int qse_awk_setglobal (qse_awk_run_t* run, int id, qse_awk_val_t* val) +int qse_awk_setglobal (qse_awk_rtx_t* run, int id, qse_awk_val_t* val) { QSE_ASSERT (id >= 0 && id < (int)QSE_LDA_SIZE(run->awk->parse.globals)); return set_global (run, (qse_size_t)id, QSE_NULL, val); } static int set_global ( - qse_awk_run_t* run, qse_size_t idx, + qse_awk_rtx_t* run, qse_size_t idx, qse_awk_nde_var_t* var, qse_awk_val_t* val) { qse_awk_val_t* old; @@ -547,7 +547,7 @@ static int set_global ( return 0; } -void qse_awk_setretval (qse_awk_run_t* run, qse_awk_val_t* val) +void qse_awk_setretval (qse_awk_rtx_t* run, qse_awk_val_t* val) { qse_awk_refdownval (run, STACK_RETVAL(run)); STACK_RETVAL(run) = val; @@ -556,7 +556,7 @@ void qse_awk_setretval (qse_awk_run_t* run, qse_awk_val_t* val) } int qse_awk_setfilename ( - qse_awk_run_t* run, const qse_char_t* name, qse_size_t len) + qse_awk_rtx_t* run, const qse_char_t* name, qse_size_t len) { qse_awk_val_t* tmp; int n; @@ -576,7 +576,7 @@ int qse_awk_setfilename ( } int qse_awk_setofilename ( - qse_awk_run_t* run, const qse_char_t* name, qse_size_t len) + qse_awk_rtx_t* run, const qse_char_t* name, qse_size_t len) { qse_awk_val_t* tmp; int n; @@ -599,22 +599,22 @@ int qse_awk_setofilename ( return n; } -qse_awk_t* qse_awk_getrunawk (qse_awk_run_t* run) +qse_awk_t* qse_awk_getrunawk (qse_awk_rtx_t* run) { return run->awk; } -qse_mmgr_t* qse_awk_getrunmmgr (qse_awk_run_t* run) +qse_mmgr_t* qse_awk_getrunmmgr (qse_awk_rtx_t* run) { return run->awk->mmgr; } -void* qse_awk_getrundata (qse_awk_run_t* run) +void* qse_awk_getrundata (qse_awk_rtx_t* run) { return run->data; } -qse_map_t* qse_awk_getrunnvmap (qse_awk_run_t* run) +qse_map_t* qse_awk_getrunnvmap (qse_awk_rtx_t* run) { return run->named; } @@ -626,7 +626,7 @@ int qse_awk_run (qse_awk_t* awk, const qse_cstr_t* runarg, void* data) { - qse_awk_run_t* run; + qse_awk_rtx_t* run; int n; QSE_ASSERTX (awk->ccls != QSE_NULL, "Call qse_setccls() first"); @@ -648,7 +648,7 @@ int qse_awk_run (qse_awk_t* awk, } /* allocate the storage for the run object */ - run = (qse_awk_run_t*) QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_run_t)); + run = (qse_awk_rtx_t*) QSE_AWK_ALLOC (awk, QSE_SIZEOF(qse_awk_rtx_t)); if (run == QSE_NULL) { /* if it fails, the failure is reported thru @@ -658,7 +658,7 @@ int qse_awk_run (qse_awk_t* awk, } /* clear the run object space */ - QSE_MEMSET (run, 0, QSE_SIZEOF(qse_awk_run_t)); + QSE_MEMSET (run, 0, QSE_SIZEOF(qse_awk_rtx_t)); /* initialize the run object */ if (init_run (run, awk, runios, data) == -1) @@ -727,12 +727,12 @@ int qse_awk_run (qse_awk_t* awk, return n; } -void qse_awk_stop (qse_awk_run_t* run) +void qse_awk_stop (qse_awk_rtx_t* run) { run->exit_level = EXIT_ABORT; } -qse_bool_t qse_awk_isstop (qse_awk_run_t* run) +qse_bool_t qse_awk_isstop (qse_awk_rtx_t* run) { return (run->exit_level == EXIT_ABORT || run->awk->stopall); } @@ -740,17 +740,17 @@ qse_bool_t qse_awk_isstop (qse_awk_run_t* run) static void free_namedval (qse_map_t* map, void* dptr, qse_size_t dlen) { qse_awk_refdownval ( - *(qse_awk_run_t**)QSE_MAP_XTN(map), dptr); + *(qse_awk_rtx_t**)QSE_MAP_XTN(map), dptr); } static void same_namedval (qse_map_t* map, void* dptr, qse_size_t dlen) { qse_awk_refdownval_nofree ( - *(qse_awk_run_t**)QSE_MAP_XTN(map), dptr); + *(qse_awk_rtx_t**)QSE_MAP_XTN(map), dptr); } static int init_run ( - qse_awk_run_t* run, qse_awk_t* awk, + qse_awk_rtx_t* run, qse_awk_t* awk, qse_awk_runios_t* runios, void* data) { run->awk = awk; @@ -813,7 +813,7 @@ static int init_run ( qse_awk_seterror (awk, QSE_AWK_ENOMEM, 0, QSE_NULL, 0); return -1; } - *(qse_awk_run_t**)QSE_MAP_XTN(run->named) = run; + *(qse_awk_rtx_t**)QSE_MAP_XTN(run->named) = run; qse_map_setcopier (run->named, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE); qse_map_setfreeer (run->named, QSE_MAP_VAL, free_namedval); qse_map_setkeeper (run->named, same_namedval); @@ -856,11 +856,11 @@ static int init_run ( if (runios != QSE_NULL) { - run->extio.handler[QSE_AWK_EXTIO_PIPE] = runios->pipe; - run->extio.handler[QSE_AWK_EXTIO_FILE] = runios->file; - run->extio.handler[QSE_AWK_EXTIO_CONSOLE] = runios->console; - run->extio.data = runios->data; - run->extio.chain = QSE_NULL; + run->eio.handler[QSE_AWK_EIO_PIPE] = runios->pipe; + run->eio.handler[QSE_AWK_EIO_FILE] = runios->file; + run->eio.handler[QSE_AWK_EIO_CONSOLE] = runios->console; + run->eio.data = runios->data; + run->eio.chain = QSE_NULL; } run->global.rs = QSE_NULL; @@ -875,15 +875,15 @@ static int init_run ( return 0; } -static void deinit_run (qse_awk_run_t* run) +static void deinit_run (qse_awk_rtx_t* run) { if (run->pattern_range_state != QSE_NULL) QSE_AWK_FREE (run->awk, run->pattern_range_state); - /* close all pending extio's */ + /* close all pending eio's */ /* TODO: what if this operation fails? */ - qse_awk_clearextio (run); - QSE_ASSERT (run->extio.chain == QSE_NULL); + qse_awk_cleareio (run); + QSE_ASSERT (run->eio.chain == QSE_NULL); if (run->global.rs != QSE_NULL) { @@ -996,7 +996,7 @@ static void deinit_run (qse_awk_run_t* run) } static int build_runarg ( - qse_awk_run_t* run, const qse_cstr_t* runarg, qse_size_t* nargs) + qse_awk_rtx_t* run, const qse_cstr_t* runarg, qse_size_t* nargs) { const qse_cstr_t* p; qse_size_t argc; @@ -1098,7 +1098,7 @@ static int build_runarg ( } -static int update_fnr (qse_awk_run_t* run, qse_long_t fnr, qse_long_t nr) +static int update_fnr (qse_awk_rtx_t* run, qse_long_t fnr, qse_long_t nr) { qse_awk_val_t* tmp1, * tmp2; @@ -1140,7 +1140,7 @@ static int update_fnr (qse_awk_run_t* run, qse_long_t fnr, qse_long_t nr) return 0; } -static int set_globals_to_default (qse_awk_run_t* run) +static int set_globals_to_default (qse_awk_rtx_t* run) { struct gtab_t { @@ -1203,7 +1203,7 @@ static int set_globals_to_default (qse_awk_run_t* run) struct capture_retval_data_t { - qse_awk_run_t* run; + qse_awk_rtx_t* run; qse_awk_val_t* val; }; @@ -1216,7 +1216,7 @@ static void capture_retval_on_exit (void* arg) qse_awk_refupval (data->run, data->val); } -static int prepare_globals (qse_awk_run_t* run, const qse_cstr_t* runarg) +static int prepare_globals (qse_awk_rtx_t* run, const qse_cstr_t* runarg) { qse_size_t saved_stack_top; qse_size_t nglobals; @@ -1255,7 +1255,7 @@ oops: return -1; } -static void refdown_globals (qse_awk_run_t* run, int pop) +static void refdown_globals (qse_awk_rtx_t* run, int pop) { qse_size_t nglobals; @@ -1269,7 +1269,7 @@ static void refdown_globals (qse_awk_run_t* run, int pop) } } -static int enter_stack_frame (qse_awk_run_t* run) +static int enter_stack_frame (qse_awk_rtx_t* run) { qse_size_t saved_stack_top; @@ -1301,7 +1301,7 @@ oops: return -1; } -static void exit_stack_frame (qse_awk_run_t* run) +static void exit_stack_frame (qse_awk_rtx_t* run) { /* At this point, the current stack frame should have * the 4 entries pushed in enter_stack_frame(). */ @@ -1311,7 +1311,7 @@ static void exit_stack_frame (qse_awk_run_t* run) run->stack_base = (qse_size_t)run->stack[run->stack_base+0]; } -static int run_bpae_loop (qse_awk_run_t* run) +static int run_bpae_loop (qse_awk_rtx_t* run) { qse_awk_nde_t* nde; qse_size_t nargs, i; @@ -1430,7 +1430,7 @@ static int run_bpae_loop (qse_awk_run_t* run) return ret; } -static int run_bpae (qse_awk_run_t* run, const qse_cstr_t* runarg) +static int run_bpae (qse_awk_rtx_t* run, const qse_cstr_t* runarg) { int ret; @@ -1469,11 +1469,11 @@ static int run_bpae (qse_awk_run_t* run, const qse_cstr_t* runarg) return ret; } -static int qse_awk_pushfuncarg (qse_awk_run_t* run, qse_awk_val_t* val) +static int qse_awk_pushfuncarg (qse_awk_rtx_t* run, qse_awk_val_t* val) { } -static int qse_awk_runfunc (qse_awk_run_t* run, const qse_char_t* name) +static int qse_awk_runfunc (qse_awk_rtx_t* run, const qse_char_t* name) { int ret = 0; struct capture_retval_data_t crdata; @@ -1593,7 +1593,7 @@ static int qse_awk_runfunc (qse_awk_run_t* run, const qse_char_t* name) } static int run_function ( - qse_awk_run_t* run, const qse_char_t* main, const qse_cstr_t* runarg) + qse_awk_rtx_t* run, const qse_char_t* main, const qse_cstr_t* runarg) { int ret; @@ -1623,7 +1623,7 @@ static int run_function ( } static int run_main ( - qse_awk_run_t* run, const qse_char_t* name, + qse_awk_rtx_t* run, const qse_char_t* name, const qse_cstr_t* runarg) { @@ -1633,7 +1633,7 @@ static int run_main ( } static int ____run_main_to_be_removed____ ( - qse_awk_run_t* run, const qse_char_t* main, + qse_awk_rtx_t* run, const qse_char_t* main, const qse_cstr_t* runarg) { qse_size_t nglobals, nargs, nrunargs, i; @@ -1987,7 +1987,7 @@ static int ____run_main_to_be_removed____ ( return n; } -static int run_pattern_blocks (qse_awk_run_t* run) +static int run_pattern_blocks (qse_awk_rtx_t* run) { int n; @@ -2038,7 +2038,7 @@ static int run_pattern_blocks (qse_awk_run_t* run) return 0; } -static int run_pattern_block_chain (qse_awk_run_t* run, qse_awk_chain_t* chain) +static int run_pattern_block_chain (qse_awk_rtx_t* run, qse_awk_chain_t* chain) { qse_size_t block_no = 0; @@ -2060,7 +2060,7 @@ static int run_pattern_block_chain (qse_awk_run_t* run, qse_awk_chain_t* chain) } static int run_pattern_block ( - qse_awk_run_t* run, qse_awk_chain_t* chain, qse_size_t block_no) + qse_awk_rtx_t* run, qse_awk_chain_t* chain, qse_size_t block_no) { qse_awk_nde_t* ptn; qse_awk_nde_blk_t* blk; @@ -2152,7 +2152,7 @@ static int run_pattern_block ( return 0; } -static int run_block (qse_awk_run_t* run, qse_awk_nde_blk_t* nde) +static int run_block (qse_awk_rtx_t* run, qse_awk_nde_blk_t* nde) { int n; @@ -2171,7 +2171,7 @@ static int run_block (qse_awk_run_t* run, qse_awk_nde_blk_t* nde) return n; } -static int run_block0 (qse_awk_run_t* run, qse_awk_nde_blk_t* nde) +static int run_block0 (qse_awk_rtx_t* run, qse_awk_nde_blk_t* nde) { qse_awk_nde_t* p; qse_size_t nlocals; @@ -2183,7 +2183,7 @@ static int run_block0 (qse_awk_run_t* run, qse_awk_nde_blk_t* nde) /* blockless pattern - execute print $0*/ qse_awk_refupval (run, run->inrec.d0); - n = qse_awk_writeextio_str (run, + n = qse_awk_writeeio_str (run, QSE_AWK_OUT_CONSOLE, QSE_T(""), QSE_STR_PTR(&run->inrec.line), QSE_STR_LEN(&run->inrec.line)); @@ -2196,7 +2196,7 @@ static int run_block0 (qse_awk_run_t* run, qse_awk_nde_blk_t* nde) return -1; } - n = qse_awk_writeextio_str ( + n = qse_awk_writeeio_str ( run, QSE_AWK_OUT_CONSOLE, QSE_T(""), run->global.ors.ptr, run->global.ors.len); if (n == -1) @@ -2277,7 +2277,7 @@ static int run_block0 (qse_awk_run_t* run, qse_awk_nde_blk_t* nde) run, (nde)->line, (run)->cbs->data); \ } -static int run_statement (qse_awk_run_t* run, qse_awk_nde_t* nde) +static int run_statement (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { ON_STATEMENT (run, nde); @@ -2413,7 +2413,7 @@ static int run_statement (qse_awk_run_t* run, qse_awk_nde_t* nde) return 0; } -static int run_if (qse_awk_run_t* run, qse_awk_nde_if_t* nde) +static int run_if (qse_awk_rtx_t* run, qse_awk_nde_if_t* nde) { qse_awk_val_t* test; int n = 0; @@ -2440,7 +2440,7 @@ static int run_if (qse_awk_run_t* run, qse_awk_nde_if_t* nde) return n; } -static int run_while (qse_awk_run_t* run, qse_awk_nde_while_t* nde) +static int run_while (qse_awk_rtx_t* run, qse_awk_nde_while_t* nde) { qse_awk_val_t* test; @@ -2530,7 +2530,7 @@ static int run_while (qse_awk_run_t* run, qse_awk_nde_while_t* nde) return 0; } -static int run_for (qse_awk_run_t* run, qse_awk_nde_for_t* nde) +static int run_for (qse_awk_rtx_t* run, qse_awk_nde_for_t* nde) { qse_awk_val_t* val; @@ -2611,7 +2611,7 @@ static int run_for (qse_awk_run_t* run, qse_awk_nde_for_t* nde) struct foreach_walker_t { - qse_awk_run_t* run; + qse_awk_rtx_t* run; qse_awk_nde_t* var; qse_awk_nde_t* body; int ret; @@ -2652,7 +2652,7 @@ static qse_map_walk_t walk_foreach ( return QSE_MAP_WALK_FORWARD; } -static int run_foreach (qse_awk_run_t* run, qse_awk_nde_foreach_t* nde) +static int run_foreach (qse_awk_rtx_t* run, qse_awk_nde_foreach_t* nde) { qse_awk_nde_exp_t* test; qse_awk_val_t* rv; @@ -2692,19 +2692,19 @@ static int run_foreach (qse_awk_run_t* run, qse_awk_nde_foreach_t* nde) return walker.ret; } -static int run_break (qse_awk_run_t* run, qse_awk_nde_break_t* nde) +static int run_break (qse_awk_rtx_t* run, qse_awk_nde_break_t* nde) { run->exit_level = EXIT_BREAK; return 0; } -static int run_continue (qse_awk_run_t* run, qse_awk_nde_continue_t* nde) +static int run_continue (qse_awk_rtx_t* run, qse_awk_nde_continue_t* nde) { run->exit_level = EXIT_CONTINUE; return 0; } -static int run_return (qse_awk_run_t* run, qse_awk_nde_return_t* nde) +static int run_return (qse_awk_rtx_t* run, qse_awk_nde_return_t* nde) { if (nde->val != QSE_NULL) { @@ -2741,7 +2741,7 @@ static int run_return (qse_awk_run_t* run, qse_awk_nde_return_t* nde) return 0; } -static int run_exit (qse_awk_run_t* run, qse_awk_nde_exit_t* nde) +static int run_exit (qse_awk_rtx_t* run, qse_awk_nde_exit_t* nde) { if (nde->val != QSE_NULL) { @@ -2764,7 +2764,7 @@ static int run_exit (qse_awk_run_t* run, qse_awk_nde_exit_t* nde) return 0; } -static int run_next (qse_awk_run_t* run, qse_awk_nde_next_t* nde) +static int run_next (qse_awk_rtx_t* run, qse_awk_nde_next_t* nde) { /* the parser checks if next has been called in the begin/end * block or whereever inappropriate. so the runtime doesn't @@ -2786,7 +2786,7 @@ static int run_next (qse_awk_run_t* run, qse_awk_nde_next_t* nde) return 0; } -static int run_nextinfile (qse_awk_run_t* run, qse_awk_nde_nextfile_t* nde) +static int run_nextinfile (qse_awk_rtx_t* run, qse_awk_nde_nextfile_t* nde) { int n; @@ -2804,7 +2804,7 @@ static int run_nextinfile (qse_awk_run_t* run, qse_awk_nde_nextfile_t* nde) return -1; } - n = qse_awk_nextextio_read (run, QSE_AWK_IN_CONSOLE, QSE_T("")); + n = qse_awk_nexteio_read (run, QSE_AWK_IN_CONSOLE, QSE_T("")); if (n == -1) { /* adjust the error line */ @@ -2831,13 +2831,13 @@ static int run_nextinfile (qse_awk_run_t* run, qse_awk_nde_nextfile_t* nde) } -static int run_nextoutfile (qse_awk_run_t* run, qse_awk_nde_nextfile_t* nde) +static int run_nextoutfile (qse_awk_rtx_t* run, qse_awk_nde_nextfile_t* nde) { int n; /* nextofile can be called from BEGIN and END block unlike nextfile */ - n = qse_awk_nextextio_write (run, QSE_AWK_OUT_CONSOLE, QSE_T("")); + n = qse_awk_nexteio_write (run, QSE_AWK_OUT_CONSOLE, QSE_T("")); if (n == -1) { /* adjust the error line */ @@ -2857,14 +2857,14 @@ static int run_nextoutfile (qse_awk_run_t* run, qse_awk_nde_nextfile_t* nde) return 0; } -static int run_nextfile (qse_awk_run_t* run, qse_awk_nde_nextfile_t* nde) +static int run_nextfile (qse_awk_rtx_t* run, qse_awk_nde_nextfile_t* nde) { return (nde->out)? run_nextoutfile (run, nde): run_nextinfile (run, nde); } -static int run_delete (qse_awk_run_t* run, qse_awk_nde_delete_t* nde) +static int run_delete (qse_awk_rtx_t* run, qse_awk_nde_delete_t* nde) { qse_awk_nde_var_t* var; @@ -3119,7 +3119,7 @@ static int run_delete (qse_awk_run_t* run, qse_awk_nde_delete_t* nde) return 0; } -static int run_reset (qse_awk_run_t* run, qse_awk_nde_reset_t* nde) +static int run_reset (qse_awk_rtx_t* run, qse_awk_nde_reset_t* nde) { qse_awk_nde_var_t* var; @@ -3174,7 +3174,7 @@ static int run_reset (qse_awk_run_t* run, qse_awk_nde_reset_t* nde) return 0; } -static int run_print (qse_awk_run_t* run, qse_awk_nde_print_t* nde) +static int run_print (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde) { qse_char_t* out = QSE_NULL; const qse_char_t* dst; @@ -3235,7 +3235,7 @@ static int run_print (qse_awk_run_t* run, qse_awk_nde_print_t* nde) } } - /* transforms the destination to suit the usage with extio */ + /* transforms the destination to suit the usage with eio */ dst = (out == QSE_NULL)? QSE_T(""): out; /* check if print is followed by any arguments */ @@ -3243,7 +3243,7 @@ static int run_print (qse_awk_run_t* run, qse_awk_nde_print_t* nde) { /* if it doesn't have any arguments, print the entire * input record */ - n = qse_awk_writeextio_str ( + n = qse_awk_writeeio_str ( run, nde->out_type, dst, QSE_STR_PTR(&run->inrec.line), QSE_STR_LEN(&run->inrec.line)); @@ -3275,7 +3275,7 @@ static int run_print (qse_awk_run_t* run, qse_awk_nde_print_t* nde) { if (np != head) { - n = qse_awk_writeextio_str ( + n = qse_awk_writeeio_str ( run, nde->out_type, dst, run->global.ofs.ptr, run->global.ofs.len); @@ -3299,7 +3299,7 @@ static int run_print (qse_awk_run_t* run, qse_awk_nde_print_t* nde) } qse_awk_refupval (run, v); - n = qse_awk_writeextio_val (run, nde->out_type, dst, v); + n = qse_awk_writeeio_val (run, nde->out_type, dst, v); if (n <= -1 /*&& run->errnum != QSE_AWK_EIOIMPL*/) { if (out != QSE_NULL) @@ -3316,7 +3316,7 @@ static int run_print (qse_awk_run_t* run, qse_awk_nde_print_t* nde) } /* print the value ORS to terminate the operation */ - n = qse_awk_writeextio_str ( + n = qse_awk_writeeio_str ( run, nde->out_type, dst, run->global.ors.ptr, run->global.ors.len); if (n <= -1 /*&& run->errnum != QSE_AWK_EIOIMPL*/) @@ -3334,7 +3334,7 @@ static int run_print (qse_awk_run_t* run, qse_awk_nde_print_t* nde) return 0; } -static int run_printf (qse_awk_run_t* run, qse_awk_nde_print_t* nde) +static int run_printf (qse_awk_rtx_t* run, qse_awk_nde_print_t* nde) { qse_char_t* out = QSE_NULL; const qse_char_t* dst; @@ -3421,7 +3421,7 @@ static int run_printf (qse_awk_run_t* run, qse_awk_nde_print_t* nde) { /* the remaining arguments are ignored as the format cannot * contain any % characters */ - n = qse_awk_writeextio_val (run, nde->out_type, dst, v); + n = qse_awk_writeeio_val (run, nde->out_type, dst, v); if (n <= -1 /*&& run->errnum != QSE_AWK_EIOIMPL*/) { if (out != QSE_NULL) QSE_AWK_FREE (run->awk, out); @@ -3458,7 +3458,7 @@ static int run_printf (qse_awk_run_t* run, qse_awk_nde_print_t* nde) } static int output_formatted ( - qse_awk_run_t* run, int out_type, const qse_char_t* dst, + qse_awk_rtx_t* run, int out_type, const qse_char_t* dst, const qse_char_t* fmt, qse_size_t fmt_len, qse_awk_nde_t* args) { qse_char_t* ptr; @@ -3469,13 +3469,13 @@ static int output_formatted ( QSE_NULL, QSE_NULL, fmt, fmt_len, 0, args, &len); if (ptr == QSE_NULL) return -1; - n = qse_awk_writeextio_str (run, out_type, dst, ptr, len); + n = qse_awk_writeeio_str (run, out_type, dst, ptr, len); if (n <= -1 /*&& run->errnum != QSE_AWK_EIOIMPL*/) return -1; return 0; } -static qse_awk_val_t* eval_expression (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_expression (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_val_t* v; int n, errnum; @@ -3513,9 +3513,9 @@ static qse_awk_val_t* eval_expression (qse_awk_run_t* run, qse_awk_nde_t* nde) "the internal value representing $0 should always be of the string type once it has been set/updated. it is nil initially."); n = QSE_AWK_MATCHREX ( - ((qse_awk_run_t*)run)->awk, + ((qse_awk_rtx_t*)run)->awk, ((qse_awk_val_rex_t*)v)->code, - ((((qse_awk_run_t*)run)->global.ignorecase)? QSE_REX_IGNORECASE: 0), + ((((qse_awk_rtx_t*)run)->global.ignorecase)? QSE_REX_IGNORECASE: 0), ((qse_awk_val_str_t*)run->inrec.d0)->ptr, ((qse_awk_val_str_t*)run->inrec.d0)->len, QSE_NULL, QSE_NULL, &errnum); @@ -3548,7 +3548,7 @@ static qse_awk_val_t* eval_expression (qse_awk_run_t* run, qse_awk_nde_t* nde) return v; } -static qse_awk_val_t* eval_expression0 (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_expression0 (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { static eval_expr_t eval_func[] = { @@ -3603,7 +3603,7 @@ static qse_awk_val_t* eval_expression0 (qse_awk_run_t* run, qse_awk_nde_t* nde) return v; } -static qse_awk_val_t* eval_group (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_group (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { /* eval_binop_in evaluates the QSE_AWK_NDE_GRP specially. * so this function should never be reached. */ @@ -3612,7 +3612,7 @@ static qse_awk_val_t* eval_group (qse_awk_run_t* run, qse_awk_nde_t* nde) return QSE_NULL; } -static qse_awk_val_t* eval_assignment (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_assignment (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_val_t* val, * ret; qse_awk_nde_ass_t* ass = (qse_awk_nde_ass_t*)nde; @@ -3682,7 +3682,7 @@ static qse_awk_val_t* eval_assignment (qse_awk_run_t* run, qse_awk_nde_t* nde) } static qse_awk_val_t* do_assignment ( - qse_awk_run_t* run, qse_awk_nde_t* var, qse_awk_val_t* val) + qse_awk_rtx_t* run, qse_awk_nde_t* var, qse_awk_val_t* val) { qse_awk_val_t* ret; int errnum; @@ -3742,7 +3742,7 @@ exit_on_error: } static qse_awk_val_t* do_assignment_scalar ( - qse_awk_run_t* run, qse_awk_nde_var_t* var, qse_awk_val_t* val) + qse_awk_rtx_t* run, qse_awk_nde_var_t* var, qse_awk_val_t* val) { QSE_ASSERT ( (var->type == QSE_AWK_NDE_NAMED || @@ -3841,7 +3841,7 @@ static qse_awk_val_t* do_assignment_scalar ( } static qse_awk_val_t* do_assignment_map ( - qse_awk_run_t* run, qse_awk_nde_var_t* var, qse_awk_val_t* val) + qse_awk_rtx_t* run, qse_awk_nde_var_t* var, qse_awk_val_t* val) { qse_awk_val_map_t* map; qse_char_t* str; @@ -3970,7 +3970,7 @@ static qse_awk_val_t* do_assignment_map ( } static qse_awk_val_t* do_assignment_pos ( - qse_awk_run_t* run, qse_awk_nde_pos_t* pos, qse_awk_val_t* val) + qse_awk_rtx_t* run, qse_awk_nde_pos_t* pos, qse_awk_val_t* val) { qse_awk_val_t* v; qse_long_t lv; @@ -4025,7 +4025,7 @@ static qse_awk_val_t* do_assignment_pos ( return (lv == 0)? run->inrec.d0: run->inrec.flds[lv-1].val; } -static qse_awk_val_t* eval_binary (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_binary (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { static binop_func_t binop_func[] = { @@ -4126,7 +4126,7 @@ static qse_awk_val_t* eval_binary (qse_awk_run_t* run, qse_awk_nde_t* nde) } static qse_awk_val_t* eval_binop_lor ( - qse_awk_run_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right) + qse_awk_rtx_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right) { /* qse_awk_val_t* res = QSE_NULL; @@ -4175,7 +4175,7 @@ static qse_awk_val_t* eval_binop_lor ( } static qse_awk_val_t* eval_binop_land ( - qse_awk_run_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right) + qse_awk_rtx_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right) { /* qse_awk_val_t* res = QSE_NULL; @@ -4224,7 +4224,7 @@ static qse_awk_val_t* eval_binop_land ( } static qse_awk_val_t* eval_binop_in ( - qse_awk_run_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right) + qse_awk_rtx_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right) { qse_awk_val_t* rv; qse_char_t* str; @@ -4298,7 +4298,7 @@ static qse_awk_val_t* eval_binop_in ( } static qse_awk_val_t* eval_binop_bor ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -4322,7 +4322,7 @@ static qse_awk_val_t* eval_binop_bor ( } static qse_awk_val_t* eval_binop_bxor ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -4346,7 +4346,7 @@ static qse_awk_val_t* eval_binop_bxor ( } static qse_awk_val_t* eval_binop_band ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -4370,13 +4370,13 @@ static qse_awk_val_t* eval_binop_band ( } static int __cmp_nil_nil ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { return 0; } static int __cmp_nil_int ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { if (((qse_awk_val_int_t*)right)->val < 0) return 1; if (((qse_awk_val_int_t*)right)->val > 0) return -1; @@ -4384,7 +4384,7 @@ static int __cmp_nil_int ( } static int __cmp_nil_real ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { if (((qse_awk_val_real_t*)right)->val < 0) return 1; if (((qse_awk_val_real_t*)right)->val > 0) return -1; @@ -4392,13 +4392,13 @@ static int __cmp_nil_real ( } static int __cmp_nil_str ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { return (((qse_awk_val_str_t*)right)->len == 0)? 0: -1; } static int __cmp_int_nil ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { if (((qse_awk_val_int_t*)left)->val > 0) return 1; if (((qse_awk_val_int_t*)left)->val < 0) return -1; @@ -4406,7 +4406,7 @@ static int __cmp_int_nil ( } static int __cmp_int_int ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { if (((qse_awk_val_int_t*)left)->val > ((qse_awk_val_int_t*)right)->val) return 1; @@ -4416,7 +4416,7 @@ static int __cmp_int_int ( } static int __cmp_int_real ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { if (((qse_awk_val_int_t*)left)->val > ((qse_awk_val_real_t*)right)->val) return 1; @@ -4426,7 +4426,7 @@ static int __cmp_int_real ( } static int __cmp_int_str ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { qse_char_t* str; qse_size_t len; @@ -4485,7 +4485,7 @@ static int __cmp_int_str ( } static int __cmp_real_nil ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { if (((qse_awk_val_real_t*)left)->val > 0) return 1; if (((qse_awk_val_real_t*)left)->val < 0) return -1; @@ -4493,7 +4493,7 @@ static int __cmp_real_nil ( } static int __cmp_real_int ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { if (((qse_awk_val_real_t*)left)->val > ((qse_awk_val_int_t*)right)->val) return 1; @@ -4503,7 +4503,7 @@ static int __cmp_real_int ( } static int __cmp_real_real ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { if (((qse_awk_val_real_t*)left)->val > ((qse_awk_val_real_t*)right)->val) return 1; @@ -4513,7 +4513,7 @@ static int __cmp_real_real ( } static int __cmp_real_str ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { qse_char_t* str; qse_size_t len; @@ -4557,25 +4557,25 @@ static int __cmp_real_str ( } static int __cmp_str_nil ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { return (((qse_awk_val_str_t*)left)->len == 0)? 0: 1; } static int __cmp_str_int ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { return -__cmp_int_str (run, right, left); } static int __cmp_str_real ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { return -__cmp_real_str (run, right, left); } static int __cmp_str_str ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n; qse_awk_val_str_t* ls, * rs; @@ -4598,9 +4598,9 @@ static int __cmp_str_str ( } static int __cmp_val ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { - typedef int (*cmp_val_t) (qse_awk_run_t*, qse_awk_val_t*, qse_awk_val_t*); + typedef int (*cmp_val_t) (qse_awk_rtx_t*, qse_awk_val_t*, qse_awk_val_t*); static cmp_val_t func[] = { @@ -4630,7 +4630,7 @@ static int __cmp_val ( } static qse_awk_val_t* eval_binop_eq ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n = __cmp_val (run, left, right); if (n == CMP_ERROR) return QSE_NULL; @@ -4638,7 +4638,7 @@ static qse_awk_val_t* eval_binop_eq ( } static qse_awk_val_t* eval_binop_ne ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n = __cmp_val (run, left, right); if (n == CMP_ERROR) return QSE_NULL; @@ -4646,7 +4646,7 @@ static qse_awk_val_t* eval_binop_ne ( } static qse_awk_val_t* eval_binop_gt ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n = __cmp_val (run, left, right); if (n == CMP_ERROR) return QSE_NULL; @@ -4654,7 +4654,7 @@ static qse_awk_val_t* eval_binop_gt ( } static qse_awk_val_t* eval_binop_ge ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n = __cmp_val (run, left, right); if (n == CMP_ERROR) return QSE_NULL; @@ -4662,7 +4662,7 @@ static qse_awk_val_t* eval_binop_ge ( } static qse_awk_val_t* eval_binop_lt ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n = __cmp_val (run, left, right); if (n == CMP_ERROR) return QSE_NULL; @@ -4670,7 +4670,7 @@ static qse_awk_val_t* eval_binop_lt ( } static qse_awk_val_t* eval_binop_le ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n = __cmp_val (run, left, right); if (n == CMP_ERROR) return QSE_NULL; @@ -4678,7 +4678,7 @@ static qse_awk_val_t* eval_binop_le ( } static qse_awk_val_t* eval_binop_lshift ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -4706,7 +4706,7 @@ static qse_awk_val_t* eval_binop_lshift ( } static qse_awk_val_t* eval_binop_rshift ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -4735,7 +4735,7 @@ static qse_awk_val_t* eval_binop_rshift ( } static qse_awk_val_t* eval_binop_plus ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -4766,7 +4766,7 @@ static qse_awk_val_t* eval_binop_plus ( } static qse_awk_val_t* eval_binop_minus ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -4790,7 +4790,7 @@ static qse_awk_val_t* eval_binop_minus ( } static qse_awk_val_t* eval_binop_mul ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -4814,7 +4814,7 @@ static qse_awk_val_t* eval_binop_mul ( } static qse_awk_val_t* eval_binop_div ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -4871,7 +4871,7 @@ static qse_awk_val_t* eval_binop_div ( } static qse_awk_val_t* eval_binop_idiv ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -4920,7 +4920,7 @@ static qse_awk_val_t* eval_binop_idiv ( } static qse_awk_val_t* eval_binop_mod ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -4957,7 +4957,7 @@ static qse_awk_val_t* eval_binop_mod ( } static qse_awk_val_t* eval_binop_exp ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { int n1, n2, n3; qse_long_t l1, l2; @@ -5043,7 +5043,7 @@ static qse_awk_val_t* eval_binop_exp ( } static qse_awk_val_t* eval_binop_concat ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right) + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right) { qse_char_t* strl, * strr; qse_size_t strl_len, strr_len; @@ -5070,7 +5070,7 @@ static qse_awk_val_t* eval_binop_concat ( } static qse_awk_val_t* eval_binop_ma ( - qse_awk_run_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right) + qse_awk_rtx_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right) { qse_awk_val_t* lv, * rv, * res; @@ -5100,7 +5100,7 @@ static qse_awk_val_t* eval_binop_ma ( } static qse_awk_val_t* eval_binop_nm ( - qse_awk_run_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right) + qse_awk_rtx_t* run, qse_awk_nde_t* left, qse_awk_nde_t* right) { qse_awk_val_t* lv, * rv, * res; @@ -5131,7 +5131,7 @@ static qse_awk_val_t* eval_binop_nm ( } static qse_awk_val_t* eval_binop_match0 ( - qse_awk_run_t* run, qse_awk_val_t* left, qse_awk_val_t* right, + qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right, qse_size_t lline, qse_size_t rline, int ret) { qse_awk_val_t* res; @@ -5246,7 +5246,7 @@ static qse_awk_val_t* eval_binop_match0 ( return res; } -static qse_awk_val_t* eval_unary (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_unary (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_val_t* left, * res = QSE_NULL; qse_awk_nde_exp_t* exp = (qse_awk_nde_exp_t*)nde; @@ -5317,7 +5317,7 @@ exit_func: return res; } -static qse_awk_val_t* eval_incpre (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_val_t* left, * res; qse_awk_nde_exp_t* exp = (qse_awk_nde_exp_t*)nde; @@ -5492,7 +5492,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_run_t* run, qse_awk_nde_t* nde) return res; } -static qse_awk_val_t* eval_incpst (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_val_t* left, * res, * res2; qse_awk_nde_exp_t* exp = (qse_awk_nde_exp_t*)nde; @@ -5759,7 +5759,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_run_t* run, qse_awk_nde_t* nde) return res; } -static qse_awk_val_t* eval_cnd (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_cnd (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_val_t* tv, * v; qse_awk_nde_cnd_t* cnd = (qse_awk_nde_cnd_t*)nde; @@ -5782,7 +5782,7 @@ static qse_awk_val_t* eval_cnd (qse_awk_run_t* run, qse_awk_nde_t* nde) return v; } -static qse_awk_val_t* eval_bfn (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_bfn (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_nde_call_t* call = (qse_awk_nde_call_t*)nde; @@ -5807,7 +5807,7 @@ static qse_awk_val_t* eval_bfn (qse_awk_run_t* run, qse_awk_nde_t* nde) } static qse_awk_val_t* eval_afn_intrinsic ( - qse_awk_run_t* run, qse_awk_nde_t* nde, void(*errhandler)(void*), void* eharg) + qse_awk_rtx_t* run, qse_awk_nde_t* nde, void(*errhandler)(void*), void* eharg) { qse_awk_nde_call_t* call = (qse_awk_nde_call_t*)nde; qse_awk_afn_t* afn; @@ -5842,7 +5842,7 @@ static qse_awk_val_t* eval_afn_intrinsic ( return eval_call (run, nde, QSE_NULL, afn, errhandler, eharg); } -static qse_awk_val_t* eval_afn (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_afn (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { return eval_afn_intrinsic (run, nde, QSE_NULL, QSE_NULL); } @@ -5867,7 +5867,7 @@ static qse_awk_val_t* eval_afn (qse_awk_run_t* run, qse_awk_nde_t* nde) } while (0) static qse_awk_val_t* eval_call ( - qse_awk_run_t* run, qse_awk_nde_t* nde, + qse_awk_rtx_t* run, qse_awk_nde_t* nde, const qse_char_t* bfn_arg_spec, qse_awk_afn_t* afn, void(*errhandler)(void*), void* eharg) { @@ -6158,7 +6158,7 @@ static qse_awk_val_t* eval_call ( } static int get_reference ( - qse_awk_run_t* run, qse_awk_nde_t* nde, qse_awk_val_t*** ref) + qse_awk_rtx_t* run, qse_awk_nde_t* nde, qse_awk_val_t*** ref) { qse_awk_nde_var_t* tgt = (qse_awk_nde_var_t*)nde; qse_awk_val_t** tmp; @@ -6299,7 +6299,7 @@ static int get_reference ( } static qse_awk_val_t** get_reference_indexed ( - qse_awk_run_t* run, qse_awk_nde_var_t* nde, qse_awk_val_t** val) + qse_awk_rtx_t* run, qse_awk_nde_var_t* nde, qse_awk_val_t** val) { qse_map_pair_t* pair; qse_char_t* str; @@ -6361,7 +6361,7 @@ static qse_awk_val_t** get_reference_indexed ( return (qse_awk_val_t**)&QSE_MAP_VPTR(pair); } -static qse_awk_val_t* eval_int (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_int (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_val_t* val; @@ -6376,7 +6376,7 @@ static qse_awk_val_t* eval_int (qse_awk_run_t* run, qse_awk_nde_t* nde) return val; } -static qse_awk_val_t* eval_real (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_real (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_val_t* val; @@ -6391,7 +6391,7 @@ static qse_awk_val_t* eval_real (qse_awk_run_t* run, qse_awk_nde_t* nde) return val; } -static qse_awk_val_t* eval_str (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_str (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_val_t* val; @@ -6407,7 +6407,7 @@ static qse_awk_val_t* eval_str (qse_awk_run_t* run, qse_awk_nde_t* nde) return val; } -static qse_awk_val_t* eval_rex (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_rex (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_val_t* val; @@ -6424,7 +6424,7 @@ static qse_awk_val_t* eval_rex (qse_awk_run_t* run, qse_awk_nde_t* nde) return val; } -static qse_awk_val_t* eval_named (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_named (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_map_pair_t* pair; @@ -6435,23 +6435,23 @@ static qse_awk_val_t* eval_named (qse_awk_run_t* run, qse_awk_nde_t* nde) return (pair == QSE_NULL)? qse_awk_val_nil: QSE_MAP_VPTR(pair); } -static qse_awk_val_t* eval_global (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_global (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { return STACK_GLOBAL(run,((qse_awk_nde_var_t*)nde)->id.idxa); } -static qse_awk_val_t* eval_local (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_local (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { return STACK_LOCAL(run,((qse_awk_nde_var_t*)nde)->id.idxa); } -static qse_awk_val_t* eval_arg (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_arg (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { return STACK_ARG(run,((qse_awk_nde_var_t*)nde)->id.idxa); } static qse_awk_val_t* eval_indexed ( - qse_awk_run_t* run, qse_awk_nde_var_t* nde, qse_awk_val_t** val) + qse_awk_rtx_t* run, qse_awk_nde_var_t* nde, qse_awk_val_t** val) { qse_map_pair_t* pair; qse_char_t* str; @@ -6499,7 +6499,7 @@ static qse_awk_val_t* eval_indexed ( (qse_awk_val_t*)QSE_MAP_VPTR(pair); } -static qse_awk_val_t* eval_namedidx (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_namedidx (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_nde_var_t* tgt = (qse_awk_nde_var_t*)nde; qse_map_pair_t* pair; @@ -6522,25 +6522,25 @@ static qse_awk_val_t* eval_namedidx (qse_awk_run_t* run, qse_awk_nde_t* nde) return eval_indexed (run, tgt, (qse_awk_val_t**)&QSE_MAP_VPTR(pair)); } -static qse_awk_val_t* eval_globalidx (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_globalidx (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { return eval_indexed (run, (qse_awk_nde_var_t*)nde, (qse_awk_val_t**)&STACK_GLOBAL(run,((qse_awk_nde_var_t*)nde)->id.idxa)); } -static qse_awk_val_t* eval_localidx (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_localidx (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { return eval_indexed (run, (qse_awk_nde_var_t*)nde, (qse_awk_val_t**)&STACK_LOCAL(run,((qse_awk_nde_var_t*)nde)->id.idxa)); } -static qse_awk_val_t* eval_argidx (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_argidx (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { return eval_indexed (run, (qse_awk_nde_var_t*)nde, (qse_awk_val_t**)&STACK_ARG(run,((qse_awk_nde_var_t*)nde)->id.idxa)); } -static qse_awk_val_t* eval_pos (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_pos (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_nde_pos_t* pos = (qse_awk_nde_pos_t*)nde; qse_awk_val_t* v; @@ -6576,7 +6576,7 @@ static qse_awk_val_t* eval_pos (qse_awk_run_t* run, qse_awk_nde_t* nde) return v; } -static qse_awk_val_t* eval_getline (qse_awk_run_t* run, qse_awk_nde_t* nde) +static qse_awk_val_t* eval_getline (qse_awk_rtx_t* run, qse_awk_nde_t* nde) { qse_awk_nde_getline_t* p; qse_awk_val_t* v, * res; @@ -6648,7 +6648,7 @@ static qse_awk_val_t* eval_getline (qse_awk_run_t* run, qse_awk_nde_t* nde) return QSE_NULL; } - n = qse_awk_readextio (run, p->in_type, dst, &buf); + n = qse_awk_readeio (run, p->in_type, dst, &buf); if (in != QSE_NULL) QSE_AWK_FREE (run->awk, in); if (n <= -1) @@ -6705,7 +6705,7 @@ skip_read: return res; } -static int __raw_push (qse_awk_run_t* run, void* val) +static int __raw_push (qse_awk_rtx_t* run, void* val) { if (run->stack_top >= run->stack_limit) { @@ -6741,13 +6741,13 @@ static int __raw_push (qse_awk_run_t* run, void* val) return 0; } -static int read_record (qse_awk_run_t* run) +static int read_record (qse_awk_rtx_t* run) { qse_ssize_t n; if (qse_awk_clrrec (run, QSE_FALSE) == -1) return -1; - n = qse_awk_readextio ( + n = qse_awk_readeio ( run, QSE_AWK_IN_CONSOLE, QSE_T(""), &run->inrec.line); if (n <= -1) { @@ -6774,7 +6774,7 @@ static int read_record (qse_awk_run_t* run) return 1; } -static int shorten_record (qse_awk_run_t* run, qse_size_t nflds) +static int shorten_record (qse_awk_rtx_t* run, qse_size_t nflds) { qse_awk_val_t* v; qse_char_t* ofs_free = QSE_NULL, * ofs; @@ -6865,7 +6865,7 @@ static int shorten_record (qse_awk_run_t* run, qse_size_t nflds) } static qse_char_t* idxnde_to_str ( - qse_awk_run_t* run, qse_awk_nde_t* nde, qse_char_t* buf, qse_size_t* len) + qse_awk_rtx_t* run, qse_awk_nde_t* nde, qse_char_t* buf, qse_size_t* len) { qse_char_t* str; qse_awk_val_t* idx; @@ -6968,7 +6968,7 @@ static qse_char_t* idxnde_to_str ( } qse_char_t* qse_awk_format ( - qse_awk_run_t* run, qse_str_t* out, qse_str_t* fbu, + qse_awk_rtx_t* run, qse_str_t* out, qse_str_t* fbu, const qse_char_t* fmt, qse_size_t fmt_len, qse_size_t nargs_on_stack, qse_awk_nde_t* args, qse_size_t* len) { diff --git a/qse/lib/awk/run.h b/qse/lib/awk/run.h index 3cef0d62..d610d5c2 100644 --- a/qse/lib/awk/run.h +++ b/qse/lib/awk/run.h @@ -96,7 +96,7 @@ extern "C" { #endif qse_char_t* qse_awk_format ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, qse_str_t* out, qse_str_t* fbu, const qse_char_t* fmt, diff --git a/qse/lib/awk/std.c b/qse/lib/awk/std.c index b3a40fc1..242728f0 100644 --- a/qse/lib/awk/std.c +++ b/qse/lib/awk/std.c @@ -82,7 +82,7 @@ qse_awk_t* qse_awk_opensimple (qse_size_t xtnsize) qse_awk_setprmfns (awk, &xtn->prmfns); qse_awk_setoption (awk, - QSE_AWK_IMPLICIT | QSE_AWK_EXTIO | QSE_AWK_NEWLINE | + QSE_AWK_IMPLICIT | QSE_AWK_EIO | QSE_AWK_NEWLINE | QSE_AWK_BASEONE | QSE_AWK_PABLOCK); if (add_functions (awk) == -1) @@ -176,7 +176,7 @@ static qse_ssize_t sf_in (int cmd, void* arg, qse_char_t* data, qse_size_t size) retry: sio = sf->in.handle; - n = qse_sio_read (sio, data, size); + n = qse_sio_getsn (sio, data, size); if (n == 0 && sf->in.p.files[++sf->in.index] != QSE_NULL) { if (sio != qse_sio_in) qse_sio_close (sio); @@ -278,7 +278,7 @@ static qse_ssize_t sf_out (int cmd, void* arg, qse_char_t* data, qse_size_t size } */ - return qse_sio_write (sf->out.handle, data, size); + return qse_sio_putsn (sf->out.handle, data, size); } return -1; @@ -336,10 +336,10 @@ typedef struct runio_data_t } ic; /* input console */ } runio_data_t; -static qse_ssize_t awk_extio_pipe ( +static qse_ssize_t awk_eio_pipe ( int cmd, void* arg, qse_char_t* data, qse_size_t size) { - qse_awk_extio_t* epa = (qse_awk_extio_t*)arg; + qse_awk_eio_t* epa = (qse_awk_eio_t*)arg; switch (cmd) { @@ -348,17 +348,17 @@ static qse_ssize_t awk_extio_pipe ( qse_pio_t* handle; int flags; - if (epa->mode == QSE_AWK_EXTIO_PIPE_READ) + if (epa->mode == QSE_AWK_EIO_PIPE_READ) { /* TODO: should we specify ERRTOOUT? */ flags = QSE_PIO_READOUT | QSE_PIO_ERRTOOUT; } - else if (epa->mode == QSE_AWK_EXTIO_PIPE_WRITE) + else if (epa->mode == QSE_AWK_EIO_PIPE_WRITE) { flags = QSE_PIO_WRITEIN; } - else if (epa->mode == QSE_AWK_EXTIO_PIPE_RW) + else if (epa->mode == QSE_AWK_EIO_PIPE_RW) { flags = QSE_PIO_READOUT | QSE_PIO_ERRTOOUT | @@ -410,7 +410,7 @@ static qse_ssize_t awk_extio_pipe ( case QSE_AWK_IO_FLUSH: { - /*if (epa->mode == QSE_AWK_EXTIO_PIPE_READ) return -1;*/ + /*if (epa->mode == QSE_AWK_EIO_PIPE_READ) return -1;*/ return qse_pio_flush ((qse_pio_t*)epa->handle, QSE_PIO_IN); } @@ -423,41 +423,43 @@ static qse_ssize_t awk_extio_pipe ( return -1; } -static qse_ssize_t awk_extio_file ( +static qse_ssize_t awk_eio_file ( int cmd, void* arg, qse_char_t* data, qse_size_t size) { - qse_awk_extio_t* epa = (qse_awk_extio_t*)arg; + qse_awk_eio_t* epa = (qse_awk_eio_t*)arg; switch (cmd) { case QSE_AWK_IO_OPEN: { - qse_sio_t* handle; - int mode; + qse_fio_t* handle; + int flags; - if (epa->mode == QSE_AWK_EXTIO_FILE_READ) + if (epa->mode == QSE_AWK_EIO_FILE_READ) { - mode = QSE_SIO_READ; + flags = QSE_FIO_READ; } - else if (epa->mode == QSE_AWK_EXTIO_FILE_WRITE) + else if (epa->mode == QSE_AWK_EIO_FILE_WRITE) { - mode = QSE_SIO_WRITE | - QSE_SIO_CREATE | - QSE_SIO_TRUNCATE; + flags = QSE_FIO_WRITE | + QSE_FIO_CREATE | + QSE_FIO_TRUNCATE; } - else if (epa->mode == QSE_AWK_EXTIO_FILE_APPEND) + else if (epa->mode == QSE_AWK_EIO_FILE_APPEND) { - mode = QSE_SIO_APPEND | - QSE_SIO_CREATE; + flags = QSE_FIO_APPEND | + QSE_FIO_CREATE; } else return -1; /* TODO: any way to set the error number? */ /*dprint (QSE_T("opening %s of type %d (file)\n"), epa->name, epa->type);*/ - handle = qse_sio_open ( + handle = qse_fio_open ( qse_awk_getrunmmgr(epa->run), 0, epa->name, - mode + flags | QSE_FIO_TEXT, + QSE_FIO_RUSR | QSE_FIO_WUSR | + QSE_FIO_RGRP | QSE_FIO_ROTH ); if (handle == QSE_NULL) { @@ -477,15 +479,15 @@ static qse_ssize_t awk_extio_file ( case QSE_AWK_IO_CLOSE: { /*dprint (QSE_T("closing %s of type %d (file)\n"), epa->name, epa->type);*/ - qse_sio_close ((qse_sio_t*)epa->handle); + qse_fio_close ((qse_fio_t*)epa->handle); epa->handle = QSE_NULL; return 0; } case QSE_AWK_IO_READ: { - return qse_sio_read ( - (qse_sio_t*)epa->handle, + return qse_fio_read ( + (qse_fio_t*)epa->handle, data, size ); @@ -493,8 +495,8 @@ static qse_ssize_t awk_extio_file ( case QSE_AWK_IO_WRITE: { - return qse_sio_write ( - (qse_sio_t*)epa->handle, + return qse_fio_write ( + (qse_fio_t*)epa->handle, data, size ); @@ -502,7 +504,7 @@ static qse_ssize_t awk_extio_file ( case QSE_AWK_IO_FLUSH: { - return qse_sio_flush ((qse_sio_t*)epa->handle); + return qse_fio_flush ((qse_fio_t*)epa->handle); } case QSE_AWK_IO_NEXT: @@ -515,13 +517,13 @@ static qse_ssize_t awk_extio_file ( return -1; } -static int open_extio_console (qse_awk_extio_t* epa) +static int open_eio_console (qse_awk_eio_t* epa) { runio_data_t* rd = (runio_data_t*)epa->data; /*dprint (QSE_T("opening console[%s] of type %x\n"), epa->name, epa->type);*/ - if (epa->mode == QSE_AWK_EXTIO_CONSOLE_READ) + if (epa->mode == QSE_AWK_EIO_CONSOLE_READ) { if (rd->ic.files[rd->ic.index] == QSE_NULL) { @@ -573,7 +575,7 @@ static int open_extio_console (qse_awk_extio_t* epa) rd->ic.index++; return 1; } - else if (epa->mode == QSE_AWK_EXTIO_CONSOLE_WRITE) + else if (epa->mode == QSE_AWK_EIO_CONSOLE_WRITE) { /*dprint (QSE_T(" console(w) - \n"));*/ @@ -589,15 +591,15 @@ static int open_extio_console (qse_awk_extio_t* epa) return -1; } -static qse_ssize_t awk_extio_console ( +static qse_ssize_t awk_eio_console ( int cmd, void* arg, qse_char_t* data, qse_size_t size) { - qse_awk_extio_t* epa = (qse_awk_extio_t*)arg; + qse_awk_eio_t* epa = (qse_awk_eio_t*)arg; runio_data_t* rd = (runio_data_t*)epa->data; if (cmd == QSE_AWK_IO_OPEN) { - return open_extio_console (epa); + return open_eio_console (epa); } else if (cmd == QSE_AWK_IO_CLOSE) { @@ -617,7 +619,7 @@ static qse_ssize_t awk_extio_console ( { qse_ssize_t n; - while ((n = qse_sio_read((qse_sio_t*)epa->handle,data,size)) == 0) + while ((n = qse_sio_getsn((qse_sio_t*)epa->handle,data,size)) == 0) { /* it has reached the end of the current file. * open the next file if available */ @@ -696,7 +698,7 @@ static qse_ssize_t awk_extio_console ( } else if (cmd == QSE_AWK_IO_WRITE) { - return qse_sio_write ( + return qse_sio_putsn ( (qse_sio_t*)epa->handle, data, size @@ -713,7 +715,7 @@ static qse_ssize_t awk_extio_console ( /*dprint (QSE_T("switching console[%s] of type %x\n"), epa->name, epa->type);*/ - n = open_extio_console(epa); + n = open_eio_console(epa); if (n == -1) return -1; if (n == 0) @@ -746,9 +748,9 @@ int qse_awk_runsimple (qse_awk_t* awk, qse_char_t** icf, qse_awk_runcbs_t* cbs) rd.ic.files = icf; rd.ic.index = 0; - ios.pipe = awk_extio_pipe; - ios.file = awk_extio_file; - ios.console = awk_extio_console; + ios.pipe = awk_eio_pipe; + ios.file = awk_eio_file; + ios.console = awk_eio_console; ios.data = &rd; if (qse_gettime (&now) == -1) rxtn.seed = 0; @@ -775,7 +777,7 @@ enum }; static int bfn_math_1 ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl, int type, void* f) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl, int type, void* f) { qse_size_t nargs; qse_awk_val_t* a0; @@ -822,7 +824,7 @@ static int bfn_math_1 ( } static int bfn_math_2 ( - qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl, int type, void* f) + qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl, int type, void* f) { qse_size_t nargs; qse_awk_val_t* a0, * a1; @@ -873,7 +875,7 @@ static int bfn_math_2 ( return 0; } -static int bfn_sin (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_sin (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { return bfn_math_1 ( run, fnm, fnl, @@ -889,7 +891,7 @@ static int bfn_sin (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) ); } -static int bfn_cos (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_cos (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { return bfn_math_1 ( run, fnm, fnl, @@ -905,7 +907,7 @@ static int bfn_cos (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) ); } -static int bfn_tan (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_tan (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { return bfn_math_1 ( run, fnm, fnl, @@ -921,7 +923,7 @@ static int bfn_tan (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) ); } -static int bfn_atan (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_atan (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { return bfn_math_1 ( run, fnm, fnl, @@ -937,7 +939,7 @@ static int bfn_atan (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) ); } -static int bfn_atan2 (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_atan2 (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { return bfn_math_2 ( run, fnm, fnl, @@ -953,7 +955,7 @@ static int bfn_atan2 (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) ); } -static int bfn_log (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_log (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { return bfn_math_1 ( run, fnm, fnl, @@ -969,7 +971,7 @@ static int bfn_log (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) ); } -static int bfn_exp (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_exp (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { return bfn_math_1 ( run, fnm, fnl, @@ -985,7 +987,7 @@ static int bfn_exp (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) ); } -static int bfn_sqrt (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_sqrt (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { return bfn_math_1 ( run, fnm, fnl, @@ -1001,7 +1003,7 @@ static int bfn_sqrt (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) ); } -static int bfn_int (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_int (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_awk_val_t* a0; @@ -1030,7 +1032,7 @@ static int bfn_int (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) return 0; } -static int bfn_rand (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_rand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_awk_val_t* r; @@ -1045,7 +1047,7 @@ static int bfn_rand (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) return 0; } -static int bfn_srand (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_srand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_awk_val_t* a0; @@ -1093,7 +1095,7 @@ static int bfn_srand (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) return 0; } -static int bfn_system (qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int bfn_system (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) { qse_size_t nargs; qse_awk_val_t* v; diff --git a/qse/lib/awk/tree.h b/qse/lib/awk/tree.h index 3b04f7e9..0f3157ca 100644 --- a/qse/lib/awk/tree.h +++ b/qse/lib/awk/tree.h @@ -79,7 +79,7 @@ enum qse_awk_nde_type_t enum qse_awk_in_type_t { /* the order of these values match - * __in_type_map and __in_opt_map in extio.c */ + * __in_type_map and __in_opt_map in eio.c */ QSE_AWK_IN_PIPE, QSE_AWK_IN_RWPIPE, @@ -90,7 +90,7 @@ enum qse_awk_in_type_t enum qse_awk_out_type_t { /* the order of these values match - * __out_type_map and __out_opt_map in extio.c */ + * __out_type_map and __out_opt_map in eio.c */ QSE_AWK_OUT_PIPE, QSE_AWK_OUT_RWPIPE, /* dual direction pipe */ @@ -285,7 +285,7 @@ struct qse_awk_nde_call_t } arg; int (*handler) ( - qse_awk_run_t*, const qse_char_t*, qse_size_t); + qse_awk_rtx_t*, const qse_char_t*, qse_size_t); } bfn; } what; qse_awk_nde_t* args; diff --git a/qse/lib/awk/val.c b/qse/lib/awk/val.c index 755e2d76..db72f4db 100644 --- a/qse/lib/awk/val.c +++ b/qse/lib/awk/val.c @@ -51,15 +51,15 @@ struct qse_awk_val_rchunk_t }; static qse_char_t* str_to_str ( - qse_awk_run_t* run, const qse_char_t* str, qse_size_t str_len, + qse_awk_rtx_t* run, const qse_char_t* str, qse_size_t str_len, int opt, qse_str_t* buf, qse_size_t* len); static qse_char_t* val_int_to_str ( - qse_awk_run_t* run, qse_awk_val_int_t* v, + qse_awk_rtx_t* run, qse_awk_val_int_t* v, int opt, qse_str_t* buf, qse_size_t* len); static qse_char_t* val_real_to_str ( - qse_awk_run_t* run, qse_awk_val_real_t* v, + qse_awk_rtx_t* run, qse_awk_val_real_t* v, int opt, qse_str_t* buf, qse_size_t* len); static qse_awk_val_nil_t awk_nil = { QSE_AWK_VAL_NIL, 0 }; @@ -98,7 +98,7 @@ qse_awk_val_t* qse_awk_val_negone = (qse_awk_val_t*)&awk_int[0]; qse_awk_val_t* qse_awk_val_zero = (qse_awk_val_t*)&awk_int[1]; qse_awk_val_t* qse_awk_val_one = (qse_awk_val_t*)&awk_int[2]; -qse_awk_val_t* qse_awk_makeintval (qse_awk_run_t* run, qse_long_t v) +qse_awk_val_t* qse_awk_makeintval (qse_awk_rtx_t* run, qse_long_t v) { qse_awk_val_int_t* val; @@ -179,7 +179,7 @@ qse_awk_val_t* qse_awk_makeintval (qse_awk_run_t* run, qse_long_t v) return (qse_awk_val_t*)val; } -qse_awk_val_t* qse_awk_makerealval (qse_awk_run_t* run, qse_real_t v) +qse_awk_val_t* qse_awk_makerealval (qse_awk_rtx_t* run, qse_real_t v) { qse_awk_val_real_t* val; @@ -250,13 +250,13 @@ qse_awk_val_t* qse_awk_makerealval (qse_awk_run_t* run, qse_real_t v) return (qse_awk_val_t*)val; } -qse_awk_val_t* qse_awk_makestrval0 (qse_awk_run_t* run, const qse_char_t* str) +qse_awk_val_t* qse_awk_makestrval0 (qse_awk_rtx_t* run, const qse_char_t* str) { return qse_awk_makestrval (run, str, qse_strlen(str)); } qse_awk_val_t* qse_awk_makestrval ( - qse_awk_run_t* run, const qse_char_t* str, qse_size_t len) + qse_awk_rtx_t* run, const qse_char_t* str, qse_size_t len) { qse_awk_val_str_t* val; qse_size_t rlen = len; @@ -306,7 +306,7 @@ init: } qse_awk_val_t* qse_awk_makestrval_nodup ( - qse_awk_run_t* run, qse_char_t* str, qse_size_t len) + qse_awk_rtx_t* run, qse_char_t* str, qse_size_t len) { qse_awk_val_str_t* val; @@ -326,7 +326,7 @@ qse_awk_val_t* qse_awk_makestrval_nodup ( } qse_awk_val_t* qse_awk_makestrval2 ( - qse_awk_run_t* run, + qse_awk_rtx_t* run, const qse_char_t* str1, qse_size_t len1, const qse_char_t* str2, qse_size_t len2) { @@ -381,7 +381,7 @@ init: } qse_awk_val_t* qse_awk_makerexval ( - qse_awk_run_t* run, const qse_char_t* buf, qse_size_t len, void* code) + qse_awk_rtx_t* run, const qse_char_t* buf, qse_size_t len, void* code) { qse_awk_val_rex_t* val; @@ -445,7 +445,7 @@ static void same_mapval (void* run, void* v) */ static void free_mapval (qse_map_t* map, void* dptr, qse_size_t dlen) { - qse_awk_run_t* run = *(qse_awk_run_t**)QSE_MAP_XTN(map); + qse_awk_rtx_t* run = *(qse_awk_rtx_t**)QSE_MAP_XTN(map); #ifdef DEBUG_VAL qse_dprintf (QSE_T("refdown in map free...")); @@ -458,7 +458,7 @@ static void free_mapval (qse_map_t* map, void* dptr, qse_size_t dlen) static void same_mapval (qse_map_t* map, void* dptr, qse_size_t dlen) { - qse_awk_run_t* run = *(qse_awk_run_t**)QSE_MAP_XTN(map); + qse_awk_rtx_t* run = *(qse_awk_rtx_t**)QSE_MAP_XTN(map); #ifdef DEBUG_VAL qse_dprintf (QSE_T("refdown nofree in map free...")); qse_awk_dprintval (run, dptr); @@ -468,7 +468,7 @@ static void same_mapval (qse_map_t* map, void* dptr, qse_size_t dlen) } /* END CHECK */ -qse_awk_val_t* qse_awk_makemapval (qse_awk_run_t* run) +qse_awk_val_t* qse_awk_makemapval (qse_awk_rtx_t* run) { qse_awk_val_map_t* val; @@ -516,7 +516,7 @@ qse_awk_val_t* qse_awk_makemapval (qse_awk_run_t* run) qse_awk_setrunerrnum (run, QSE_AWK_ENOMEM); return QSE_NULL; } - *(qse_awk_run_t**)QSE_MAP_XTN(val->map) = run; + *(qse_awk_rtx_t**)QSE_MAP_XTN(val->map) = run; /* the key is copied inline into a pair and is freed when the pair * is destroyed */ @@ -533,7 +533,7 @@ qse_awk_val_t* qse_awk_makemapval (qse_awk_run_t* run) return (qse_awk_val_t*)val; } -qse_awk_val_t* qse_awk_makerefval (qse_awk_run_t* run, int id, qse_awk_val_t** adr) +qse_awk_val_t* qse_awk_makerefval (qse_awk_rtx_t* run, int id, qse_awk_val_t** adr) { qse_awk_val_ref_t* val; @@ -574,7 +574,7 @@ qse_bool_t qse_awk_isstaticval (qse_awk_val_t* val) return IS_STATICVAL(val); } -void qse_awk_freeval (qse_awk_run_t* run, qse_awk_val_t* val, qse_bool_t cache) +void qse_awk_freeval (qse_awk_rtx_t* run, qse_awk_val_t* val, qse_bool_t cache) { if (IS_STATICVAL(val)) return; @@ -668,7 +668,7 @@ void qse_awk_freeval (qse_awk_run_t* run, qse_awk_val_t* val, qse_bool_t cache) } } -void qse_awk_refupval (qse_awk_run_t* run, qse_awk_val_t* val) +void qse_awk_refupval (qse_awk_rtx_t* run, qse_awk_val_t* val) { if (IS_STATICVAL(val)) return; @@ -681,7 +681,7 @@ void qse_awk_refupval (qse_awk_run_t* run, qse_awk_val_t* val) val->ref++; } -void qse_awk_refdownval (qse_awk_run_t* run, qse_awk_val_t* val) +void qse_awk_refdownval (qse_awk_rtx_t* run, qse_awk_val_t* val) { if (IS_STATICVAL(val)) return; @@ -701,7 +701,7 @@ void qse_awk_refdownval (qse_awk_run_t* run, qse_awk_val_t* val) } } -void qse_awk_refdownval_nofree (qse_awk_run_t* run, qse_awk_val_t* val) +void qse_awk_refdownval_nofree (qse_awk_rtx_t* run, qse_awk_val_t* val) { if (IS_STATICVAL(val)) return; @@ -710,7 +710,7 @@ void qse_awk_refdownval_nofree (qse_awk_run_t* run, qse_awk_val_t* val) val->ref--; } -void qse_awk_freevalchunk (qse_awk_run_t* run, qse_awk_val_chunk_t* chunk) +void qse_awk_freevalchunk (qse_awk_rtx_t* run, qse_awk_val_chunk_t* chunk) { while (chunk != QSE_NULL) { @@ -720,7 +720,7 @@ void qse_awk_freevalchunk (qse_awk_run_t* run, qse_awk_val_chunk_t* chunk) } } -qse_bool_t qse_awk_valtobool (qse_awk_run_t* run, qse_awk_val_t* val) +qse_bool_t qse_awk_valtobool (qse_awk_rtx_t* run, qse_awk_val_t* val) { if (val == QSE_NULL) return QSE_FALSE; @@ -749,7 +749,7 @@ qse_bool_t qse_awk_valtobool (qse_awk_run_t* run, qse_awk_val_t* val) } qse_char_t* qse_awk_valtostr ( - qse_awk_run_t* run, qse_awk_val_t* v, + qse_awk_rtx_t* run, qse_awk_val_t* v, int opt, qse_str_t* buf, qse_size_t* len) { if (v->type == QSE_AWK_VAL_NIL) @@ -810,7 +810,7 @@ qse_char_t* qse_awk_valtostr ( } static qse_char_t* str_to_str ( - qse_awk_run_t* run, const qse_char_t* str, qse_size_t str_len, + qse_awk_rtx_t* run, const qse_char_t* str, qse_size_t str_len, int opt, qse_str_t* buf, qse_size_t* len) { if (buf == QSE_NULL) @@ -861,7 +861,7 @@ static qse_char_t* str_to_str ( } static qse_char_t* val_int_to_str ( - qse_awk_run_t* run, qse_awk_val_int_t* v, + qse_awk_rtx_t* run, qse_awk_val_int_t* v, int opt, qse_str_t* buf, qse_size_t* len) { qse_char_t* tmp; @@ -993,7 +993,7 @@ static qse_char_t* val_int_to_str ( } static qse_char_t* val_real_to_str ( - qse_awk_run_t* run, qse_awk_val_real_t* v, + qse_awk_rtx_t* run, qse_awk_val_real_t* v, int opt, qse_str_t* buf, qse_size_t* len) { qse_char_t* tmp; @@ -1087,7 +1087,7 @@ static qse_char_t* val_real_to_str ( } int qse_awk_valtonum ( - qse_awk_run_t* run, qse_awk_val_t* v, qse_long_t* l, qse_real_t* r) + qse_awk_rtx_t* run, qse_awk_val_t* v, qse_long_t* l, qse_real_t* r) { if (v->type == QSE_AWK_VAL_NIL) { @@ -1125,7 +1125,7 @@ int qse_awk_valtonum ( } int qse_awk_strtonum ( - qse_awk_run_t* run, const qse_char_t* ptr, qse_size_t len, + qse_awk_rtx_t* run, const qse_char_t* ptr, qse_size_t len, qse_long_t* l, qse_real_t* r) { const qse_char_t* endptr; @@ -1154,19 +1154,19 @@ int qse_awk_strtonum ( static qse_map_walk_t print_pair ( qse_map_t* map, qse_map_pair_t* pair, void* arg) { - qse_awk_run_t* run = (qse_awk_run_t*)arg; + qse_awk_rtx_t* run = (qse_awk_rtx_t*)arg; - QSE_ASSERT (run == *(qse_awk_run_t**)QSE_MAP_XTN(map)); + QSE_ASSERT (run == *(qse_awk_rtx_t**)QSE_MAP_XTN(map)); DPRINTF (DCUSTOM, QSE_T(" %.*s=>"), (int)QSE_MAP_KLEN(pair), QSE_MAP_KPTR(pair)); - qse_awk_dprintval ((qse_awk_run_t*)arg, QSE_MAP_VPTR(pair)); + qse_awk_dprintval ((qse_awk_rtx_t*)arg, QSE_MAP_VPTR(pair)); DPRINTF (DCUSTOM, QSE_T(" ")); return QSE_MAP_WALK_FORWARD; } -void qse_awk_dprintval (qse_awk_run_t* run, qse_awk_val_t* val) +void qse_awk_dprintval (qse_awk_rtx_t* run, qse_awk_val_t* val) { /* TODO: better value printing ... */ diff --git a/qse/lib/cmn/sio.c b/qse/lib/cmn/sio.c index 193f0c15..f372d850 100644 --- a/qse/lib/cmn/sio.c +++ b/qse/lib/cmn/sio.c @@ -33,11 +33,13 @@ static qse_sio_t __sio_in = /* fio */ { QSE_NULL, + 0, #ifdef _WIN32 (HANDLE)STD_INPUT_HANDLE, #else 0, #endif + QSE_NULL }, /* tio */ @@ -67,11 +69,13 @@ static qse_sio_t __sio_out = /* fio */ { QSE_NULL, + 0, #ifdef _WIN32 (HANDLE)STD_OUTPUT_HANDLE, #else - 1 + 1, #endif + QSE_NULL }, /* tio */ @@ -101,11 +105,13 @@ static qse_sio_t __sio_err = /* fio */ { QSE_NULL, + 0, #ifdef _WIN32 (HANDLE)STD_ERROR_HANDLE, #else - 2 + 2, #endif + QSE_NULL }, /* tio */ @@ -226,39 +232,41 @@ void qse_sio_purge (qse_sio_t* sio) qse_tio_purge (&sio->tio); } -#if 0 qse_ssize_t qse_sio_getc (qse_sio_t* sio, qse_char_t* c) { - return qse_tio_getc (&sio->tio, c); + return qse_tio_read (&sio->tio, c, 1); } -qse_ssize_t qse_sio_gets (qse_sio_t* sio, qse_char_t* buf, qse_size_t size) +qse_ssize_t qse_sio_gets ( + qse_sio_t* sio, qse_char_t* buf, qse_size_t size) { - return qse_tio_gets (&sio->tio, buf, size); + qse_ssize_t n; + + if (size <= 0) return 0; + n = qse_tio_read (&sio->tio, buf, size -1); + if (n == -1) return -1; + buf[n] = QSE_T('\0'); + return n; } -qse_ssize_t qse_sio_getstr (qse_sio_t* sio, qse_str_t* buf) -{ - return qse_tio_getstr (&sio->tio, buf); -} - -qse_ssize_t qse_sio_putc (qse_sio_t* sio, qse_char_t c) -{ - return qse_tio_putc (&sio->tio, c); -} - -qse_ssize_t qse_sio_puts (qse_sio_t* sio, const qse_char_t* str) -{ - return qse_tio_puts (&sio->tio, str); -} -#endif - -qse_ssize_t qse_sio_read (qse_sio_t* sio, qse_char_t* buf, qse_size_t size) +qse_ssize_t qse_sio_getsn ( + qse_sio_t* sio, qse_char_t* buf, qse_size_t size) { return qse_tio_read (&sio->tio, buf, size); } -qse_ssize_t qse_sio_write (qse_sio_t* sio, const qse_char_t* str, qse_size_t size) +qse_ssize_t qse_sio_putc (qse_sio_t* sio, qse_char_t c) +{ + return qse_tio_write (&sio->tio, &c, 1); +} + +qse_ssize_t qse_sio_puts (qse_sio_t* sio, const qse_char_t* str) +{ + return qse_tio_write (&sio->tio, str, (qse_size_t)-1); +} + +qse_ssize_t qse_sio_putsn ( + qse_sio_t* sio, const qse_char_t* str, qse_size_t size) { return qse_tio_write (&sio->tio, str, size); } diff --git a/qse/lib/cmn/tio_put.c b/qse/lib/cmn/tio_put.c index 6b013039..3ffb58cb 100644 --- a/qse/lib/cmn/tio_put.c +++ b/qse/lib/cmn/tio_put.c @@ -74,19 +74,34 @@ static qse_ssize_t tio_putc (qse_tio_t* tio, qse_char_t c) qse_ssize_t qse_tio_write (qse_tio_t* tio, const qse_char_t* str, qse_size_t size) { qse_ssize_t n; - const qse_char_t* p, * end; + const qse_char_t* p; if (size == 0) return 0; - p = str; end = str + size; - while (p < end) - { - n = tio_putc (tio, *p); - if (n == -1) return -1; - if (n == 0) break; + p = str; - p++; + if (size == (qse_size_t)-1) + { + while (*p != QSE_T('\0')) + { + n = tio_putc (tio, *p); + if (n == -1) return -1; + if (n == 0) break; + p++; + } + } + else + { + const qse_char_t* end = str + size; + while (p < end) + { + n = tio_putc (tio, *p); + if (n == -1) return -1; + if (n == 0) break; + p++; + } } return p - str; } +