diff --git a/qse/cmd/sed/sed.c b/qse/cmd/sed/sed.c index 504330e2..b50d48a2 100644 --- a/qse/cmd/sed/sed.c +++ b/qse/cmd/sed/sed.c @@ -558,14 +558,13 @@ static void trace_exec (qse_sed_t* sed, qse_sed_exec_op_t op, const qse_sed_cmd_ { switch (op) { -#if 0 case QSE_SED_EXEC_READ: - qse_fprintf (QSE_STDERR, QSE_T("reading...\n")); + /*qse_fprintf (QSE_STDERR, QSE_T("reading...\n"));*/ break; case QSE_SED_EXEC_WRITE: - qse_fprintf (QSE_STDERR, QSE_T("wrting...\n")); + /*qse_fprintf (QSE_STDERR, QSE_T("wrting...\n"));*/ break; -#endif + /* TODO: use function to get hold space and pattern space and print them */ case QSE_SED_EXEC_MATCH: diff --git a/qse/include/qse/awk/Awk.hpp b/qse/include/qse/awk/Awk.hpp index 76b3941e..a8633ebf 100644 --- a/qse/include/qse/awk/Awk.hpp +++ b/qse/include/qse/awk/Awk.hpp @@ -1171,7 +1171,7 @@ private: int dispatch_function (Run* run, const cstr_t* name); - static const char_t* xerrstr (awk_t* a, errnum_t num); + static const char_t* xerrstr (const awk_t* a, errnum_t num); private: Awk (const Awk&); diff --git a/qse/include/qse/awk/awk.h b/qse/include/qse/awk/awk.h index 0c9e9a0c..9a9fc6e8 100644 --- a/qse/include/qse/awk/awk.h +++ b/qse/include/qse/awk/awk.h @@ -999,7 +999,7 @@ typedef struct qse_awk_errinf_t qse_awk_errinf_t; * object with the qse_awk_seterrstr() function to customize an error string. */ typedef const qse_char_t* (*qse_awk_errstr_t) ( - qse_awk_t* awk, /**< awk */ + const qse_awk_t* awk, /**< awk */ qse_awk_errnum_t num /**< error number */ ); @@ -1205,7 +1205,7 @@ int qse_awk_clear ( * The qse_awk_geterrstr() gets an error string getter. */ qse_awk_errstr_t qse_awk_geterrstr ( - qse_awk_t* awk /**< awk */ + const qse_awk_t* awk /**< awk */ ); /** @@ -1243,7 +1243,7 @@ void qse_awk_seterrstr ( * @return error number */ qse_awk_errnum_t qse_awk_geterrnum ( - qse_awk_t* awk /**< awk */ + const qse_awk_t* awk /**< awk */ ); /** @@ -1251,7 +1251,7 @@ qse_awk_errnum_t qse_awk_geterrnum ( * last error has occurred. */ const qse_awk_loc_t* qse_awk_geterrloc ( - qse_awk_t* awk /**< awk */ + const qse_awk_t* awk /**< awk */ ); /** @@ -1261,7 +1261,7 @@ const qse_awk_loc_t* qse_awk_geterrloc ( * @return error message */ const qse_char_t* qse_awk_geterrmsg ( - qse_awk_t* awk /**< awk */ + const qse_awk_t* awk /**< awk */ ); /** @@ -1269,7 +1269,7 @@ const qse_char_t* qse_awk_geterrmsg ( * pointed to by @a errinf from @a awk. */ void qse_awk_geterrinf ( - qse_awk_t* awk, /**< awk */ + const qse_awk_t* awk, /**< awk */ qse_awk_errinf_t* errinf /**< error information buffer */ ); @@ -1300,7 +1300,7 @@ void qse_awk_seterrinf ( * The qse_awk_geterror() function gets error information via parameters. */ void qse_awk_geterror ( - qse_awk_t* awk, /**< awk */ + const qse_awk_t* awk, /**< awk */ qse_awk_errnum_t* errnum, /**< error number */ const qse_char_t** errmsg, /**< error message */ qse_awk_loc_t* errloc /**< error location */ @@ -1322,7 +1322,7 @@ void qse_awk_seterror ( * @return 0 or a number ORed of #qse_awk_option_t enumerators. */ int qse_awk_getoption ( - qse_awk_t* awk /**< awk */ + const qse_awk_t* awk /**< awk */ ); /** @@ -1340,8 +1340,8 @@ void qse_awk_setoption ( * @return maximum depth */ qse_size_t qse_awk_getmaxdepth ( - qse_awk_t* awk, /**< awk */ - qse_awk_depth_t type /**< operation type */ + const qse_awk_t* awk, /**< awk */ + qse_awk_depth_t type /**< operation type */ ); /** @@ -1797,7 +1797,7 @@ qse_htb_t* qse_awk_rtx_getnvmap ( * @return error number */ qse_awk_errnum_t qse_awk_rtx_geterrnum ( - qse_awk_rtx_t* rtx /**< runtime context */ + const qse_awk_rtx_t* rtx /**< runtime context */ ); /** @@ -1806,7 +1806,7 @@ qse_awk_errnum_t qse_awk_rtx_geterrnum ( * @return error location */ const qse_awk_loc_t* qse_awk_rtx_geterrloc ( - qse_awk_rtx_t* rtx /**< runtime context */ + const qse_awk_rtx_t* rtx /**< runtime context */ ); /** @@ -1815,7 +1815,7 @@ const qse_awk_loc_t* qse_awk_rtx_geterrloc ( * @return error message */ const qse_char_t* qse_awk_rtx_geterrmsg ( - qse_awk_rtx_t* rtx /**< runtime context */ + const qse_awk_rtx_t* rtx /**< runtime context */ ); /** @@ -1823,8 +1823,8 @@ const qse_char_t* qse_awk_rtx_geterrmsg ( * pointed to by @a errinf from a runtime context @a rtx. */ void qse_awk_rtx_geterrinf ( - qse_awk_rtx_t* rtx, /**< runtime context */ - qse_awk_errinf_t* errinf /**< error information */ + const qse_awk_rtx_t* rtx, /**< runtime context */ + qse_awk_errinf_t* errinf /**< error information */ ); /** @@ -1834,10 +1834,10 @@ void qse_awk_rtx_geterrinf ( * @a errmsg; the error line into memory pointed to by @a errlin. */ void qse_awk_rtx_geterror ( - qse_awk_rtx_t* rtx, /**< runtime context */ - qse_awk_errnum_t* errnum, /**< error number */ - const qse_char_t** errmsg, /**< error message */ - qse_awk_loc_t* errloc /**< error location */ + const qse_awk_rtx_t* rtx, /**< runtime context */ + qse_awk_errnum_t* errnum, /**< error number */ + const qse_char_t** errmsg, /**< error message */ + qse_awk_loc_t* errloc /**< error location */ ); /** diff --git a/qse/include/qse/cmn/fio.h b/qse/include/qse/cmn/fio.h index 29d4223b..b54e75cd 100644 --- a/qse/include/qse/cmn/fio.h +++ b/qse/include/qse/cmn/fio.h @@ -210,15 +210,19 @@ void qse_fio_fini ( qse_fio_t* fio ); +qse_fio_errnum_t qse_fio_geterrnum ( + const qse_fio_t* fio +); + /** * The qse_fio_gethandle() function returns the native file handle. */ qse_fio_hnd_t qse_fio_gethandle ( - qse_fio_t* fio + const qse_fio_t* fio ); qse_ubi_t qse_fio_gethandleasubi ( - qse_fio_t* fio + const qse_fio_t* fio ); /** diff --git a/qse/include/qse/cmn/htb.h b/qse/include/qse/cmn/htb.h index cdbf10b8..3047b02d 100644 --- a/qse/include/qse/cmn/htb.h +++ b/qse/include/qse/cmn/htb.h @@ -121,11 +121,11 @@ typedef void (*qse_htb_freeer_t) ( * integer otherwise. */ typedef int (*qse_htb_comper_t) ( - qse_htb_t* htb, /**< hash table */ - const void* kptr1, /**< key pointer */ - qse_size_t klen1, /**< key length */ - const void* kptr2, /**< key pointer */ - qse_size_t klen2 /**< key length */ + const qse_htb_t* htb, /**< hash table */ + const void* kptr1, /**< key pointer */ + qse_size_t klen1, /**< key length */ + const void* kptr2, /**< key pointer */ + qse_size_t klen2 /**< key length */ ); /** @@ -154,9 +154,9 @@ typedef qse_size_t (*qse_htb_sizer_t) ( * The qse_htb_hasher_t type defines a key hash function */ typedef qse_size_t (*qse_htb_hasher_t) ( - qse_htb_t* htb, /**< hash table */ - const void* kptr, /**< key pointer */ - qse_size_t klen /**< key length in bytes */ + const qse_htb_t* htb, /**< hash table */ + const void* kptr, /**< key pointer */ + qse_size_t klen /**< key length in bytes */ ); /** @@ -361,7 +361,7 @@ void qse_htb_fini ( * The qse_htb_getmancbs() function gets manipulation callback function set. */ const qse_htb_mancbs_t* qse_htb_getmancbs ( - qse_htb_t* htb /**< hash table */ + const qse_htb_t* htb /**< hash table */ ); /** @@ -377,7 +377,7 @@ void qse_htb_setmancbs ( * The qse_htb_getsize() function gets the number of pairs in hash table. */ qse_size_t qse_htb_getsize ( - qse_htb_t* htb + const qse_htb_t* htb ); /** @@ -385,7 +385,7 @@ qse_size_t qse_htb_getsize ( * in a hash bucket. */ qse_size_t qse_htb_getcapa ( - qse_htb_t* htb /**< hash table */ + const qse_htb_t* htb /**< hash table */ ); /** @@ -396,9 +396,9 @@ qse_size_t qse_htb_getcapa ( * or #QSE_NULL if no match is found. */ qse_htb_pair_t* qse_htb_search ( - qse_htb_t* htb, /**< hash table */ - const void* kptr, /**< key pointer */ - qse_size_t klen /**< key length */ + const qse_htb_t* htb, /**< hash table */ + const void* kptr, /**< key pointer */ + qse_size_t klen /**< key length */ ); /** @@ -632,20 +632,20 @@ void qse_htb_freepair ( * The qse_htb_dflhash() function is a default hash function. */ qse_size_t qse_htb_dflhash ( - qse_htb_t* htb, - const void* kptr, - qse_size_t klen + const qse_htb_t* htb, + const void* kptr, + qse_size_t klen ); /** * The qse_htb_dflcomp() function is default comparator. */ int qse_htb_dflcomp ( - qse_htb_t* htb, - const void* kptr1, - qse_size_t klen1, - const void* kptr2, - qse_size_t klen2 + const qse_htb_t* htb, + const void* kptr1, + qse_size_t klen1, + const void* kptr2, + qse_size_t klen2 ); #ifdef __cplusplus diff --git a/qse/include/qse/cmn/ipad.h b/qse/include/qse/cmn/ipad.h index 6246c4ef..92060a20 100644 --- a/qse/include/qse/cmn/ipad.h +++ b/qse/include/qse/cmn/ipad.h @@ -1,4 +1,3 @@ - /* * $Id$ * @@ -25,7 +24,7 @@ #include #include -typedef struct qse_ipad_t qse_ipad_t; +typedef struct qse_ipad_t qse_ipad_t; typedef struct qse_ipad4_t qse_ipad4_t; typedef struct qse_ipad6_t qse_ipad6_t; @@ -44,14 +43,14 @@ struct qse_ipad_t { enum { - QSE_IPAD_IP4, - QSE_IPAD_IP6 + QSE_IPAD_V4, + QSE_IPAD_V6 } type; union { - qse_ipad4_t ip4; - qse_ipad4_t ip6; + qse_ipad4_t v4; + qse_ipad6_t v6; } u; }; @@ -59,6 +58,38 @@ struct qse_ipad_t extern "C" { #endif +int qse_mbstoipad4 ( + const qse_mchar_t* mbs, + qse_ipad4_t* ipad +); + +int qse_mbsntoipad4 ( + const qse_mchar_t* mbs, + qse_size_t len +); + +int qse_ipad4tombs ( + const qse_ipad4_t* ipad, + qse_mchar_t* mbs, + qse_size_t len +); + +int qse_wcstoipad4 ( + const qse_wchar_t* wcs, + qse_ipad4_t* ipad +); + +int qse_wcstoipad4 ( + const qse_wchar_t* wcs, + qse_ipad4_t* ipad +); + +int qse_ipad4towcs ( + const qse_ipad4_t* ipad, + qse_wchar_t* wcs, + qse_size_t len +); + #ifdef __cplusplus } #endif diff --git a/qse/include/qse/cmn/pio.h b/qse/include/qse/cmn/pio.h index 7b53f20b..3155f2f9 100644 --- a/qse/include/qse/cmn/pio.h +++ b/qse/include/qse/cmn/pio.h @@ -263,12 +263,21 @@ void qse_pio_fini ( qse_pio_t* pio /**< pio object */ ); +/** + * The qse_pio_geterrnum() function returns the number of the last error + * occurred. + * @return error number + */ +qse_pio_errnum_t qse_pio_geterrnum ( + const qse_pio_t* pio /**< pio object */ +); + /** * The qse_pio_getoption() function gets the current option. * @return option number OR'ed of #qse_pio_option_t enumerators */ int qse_pio_getoption ( - qse_pio_t* pio /**< pio object */ + const qse_pio_t* pio /**< pio object */ ); /** @@ -280,15 +289,6 @@ void qse_pio_setoption ( enumerators */ ); -/** - * The qse_pio_geterrnum() function returns the number of the last error - * occurred. - * @return error number - */ -qse_pio_errnum_t qse_pio_geterrnum ( - qse_pio_t* pio /**< pio object */ -); - /** * The qse_pio_getcmgr() function returns the current character manager. * It returns #QSE_NULL is @a pio is not opened with #QSE_PIO_TEXT. @@ -313,8 +313,8 @@ void qse_pio_setcmgr ( * @return pipe handle */ qse_pio_hnd_t qse_pio_gethandle ( - qse_pio_t* pio, /**< pio object */ - qse_pio_hid_t hid /**< handle ID */ + const qse_pio_t* pio, /**< pio object */ + qse_pio_hid_t hid /**< handle ID */ ); /** @@ -323,8 +323,8 @@ qse_pio_hnd_t qse_pio_gethandle ( * @return pipe handle */ qse_ubi_t qse_pio_gethandleasubi ( - qse_pio_t* pio, /**< pio object */ - qse_pio_hid_t hid /**< handle ID */ + const qse_pio_t* pio, /**< pio object */ + qse_pio_hid_t hid /**< handle ID */ ); /** @@ -332,7 +332,7 @@ qse_ubi_t qse_pio_gethandleasubi ( * @return process handle */ qse_pio_pid_t qse_pio_getchild ( - qse_pio_t* pio /**< pio object */ + const qse_pio_t* pio /**< pio object */ ); /** diff --git a/qse/include/qse/cmn/rbt.h b/qse/include/qse/cmn/rbt.h index 8be88ac1..e7aebe58 100644 --- a/qse/include/qse/cmn/rbt.h +++ b/qse/include/qse/cmn/rbt.h @@ -116,11 +116,11 @@ typedef void (*qse_rbt_freeer_t) ( * key is greater than the second key, -1 otherwise. */ typedef int (*qse_rbt_comper_t) ( - qse_rbt_t* rbt, /**< red-black tree */ - const void* kptr1, /**< key pointer */ - qse_size_t klen1, /**< key length */ - const void* kptr2, /**< key pointer */ - qse_size_t klen2 /**< key length */ + const qse_rbt_t* rbt, /**< red-black tree */ + const void* kptr1, /**< key pointer */ + qse_size_t klen1, /**< key length */ + const void* kptr2, /**< key pointer */ + qse_size_t klen2 /**< key length */ ); /** @@ -319,7 +319,7 @@ void qse_rbt_fini ( * The qse_rbt_getmancbs() function gets manipulation callback function set. */ const qse_rbt_mancbs_t* qse_rbt_getmancbs ( - qse_rbt_t* rbt /**< red-black tree */ + const qse_rbt_t* rbt /**< red-black tree */ ); /** @@ -335,7 +335,7 @@ void qse_rbt_setmancbs ( * The qse_rbt_getsize() function gets the number of pairs in red-black tree. */ qse_size_t qse_rbt_getsize ( - qse_rbt_t* rbt /**< red-black tree */ + const qse_rbt_t* rbt /**< red-black tree */ ); /** @@ -346,9 +346,9 @@ qse_size_t qse_rbt_getsize ( * or QSE_NULL if no match is found. */ qse_rbt_pair_t* qse_rbt_search ( - qse_rbt_t* rbt, /**< red-black tree */ - const void* kptr, /**< key pointer */ - qse_size_t klen /**< the size of the key */ + const qse_rbt_t* rbt, /**< red-black tree */ + const void* kptr, /**< key pointer */ + qse_size_t klen /**< the size of the key */ ); /** @@ -574,11 +574,11 @@ void qse_rbt_freepair ( * The qse_rbt_dflcomp() function defines the default key comparator. */ int qse_rbt_dflcomp ( - qse_rbt_t* rbt, - const void* kptr1, - qse_size_t klen1, - const void* kptr2, - qse_size_t klen2 + const qse_rbt_t* rbt, + const void* kptr1, + qse_size_t klen1, + const void* kptr2, + qse_size_t klen2 ); #ifdef __cplusplus diff --git a/qse/include/qse/cmn/rex.h b/qse/include/qse/cmn/rex.h index e0fa5c42..ef400d52 100644 --- a/qse/include/qse/cmn/rex.h +++ b/qse/include/qse/cmn/rex.h @@ -238,7 +238,7 @@ qse_rex_node_t* qse_rex_yield ( * The qse_rex_getoption() function returns the current options. */ int qse_rex_getoption ( - qse_rex_t* rex /**< regular expression processor */ + const qse_rex_t* rex /**< regular expression processor */ ); /** @@ -250,11 +250,11 @@ void qse_rex_setoption ( ); qse_rex_errnum_t qse_rex_geterrnum ( - qse_rex_t* rex + const qse_rex_t* rex ); const qse_char_t* qse_rex_geterrmsg ( - qse_rex_t* rex + const qse_rex_t* rex ); qse_rex_node_t* qse_rex_comp ( diff --git a/qse/include/qse/cmn/sio.h b/qse/include/qse/cmn/sio.h index 95b40d49..1593cb69 100644 --- a/qse/include/qse/cmn/sio.h +++ b/qse/include/qse/cmn/sio.h @@ -197,7 +197,7 @@ void qse_sio_fini ( ); qse_sio_errnum_t qse_sio_geterrnum ( - qse_sio_t* sio + const qse_sio_t* sio ); qse_cmgr_t* qse_sio_getcmgr ( @@ -210,11 +210,11 @@ void qse_sio_setcmgr ( ); qse_sio_hnd_t qse_sio_gethandle ( - qse_sio_t* sio + const qse_sio_t* sio ); qse_ubi_t qse_sio_gethandleasubi ( - qse_sio_t* sio + const qse_sio_t* sio ); qse_ssize_t qse_sio_flush ( diff --git a/qse/include/qse/cmn/tio.h b/qse/include/qse/cmn/tio.h index 290691ca..d24efef3 100644 --- a/qse/include/qse/cmn/tio.h +++ b/qse/include/qse/cmn/tio.h @@ -169,7 +169,7 @@ int qse_tio_fini ( * The qse_tio_geterrnum() function returns the current error code. */ qse_tio_errnum_t qse_tio_geterrnum ( - qse_tio_t* tio + const qse_tio_t* tio ); /** diff --git a/qse/include/qse/sed/Sed.hpp b/qse/include/qse/sed/Sed.hpp index d6d49f07..f1f48d25 100644 --- a/qse/include/qse/sed/Sed.hpp +++ b/qse/include/qse/sed/Sed.hpp @@ -316,7 +316,7 @@ private: sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* buf, size_t len); static ssize_t xout ( sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* dat, size_t len); - static const char_t* xerrstr (sed_t* s, errnum_t num); + static const char_t* xerrstr (const sed_t* s, errnum_t num); private: Sed (const Sed&); diff --git a/qse/include/qse/sed/sed.h b/qse/include/qse/sed/sed.h index 86a81d18..3f468eb9 100644 --- a/qse/include/qse/sed/sed.h +++ b/qse/include/qse/sed/sed.h @@ -234,7 +234,7 @@ typedef enum qse_sed_errnum_t qse_sed_errnum_t; * editor with the qse_sed_seterrstr() function to customize an error string. */ typedef const qse_char_t* (*qse_sed_errstr_t) ( - qse_sed_t* sed, /**< stream editor */ + const qse_sed_t* sed, /**< stream editor */ qse_sed_errnum_t num /**< an error number */ ); @@ -355,7 +355,7 @@ void qse_sed_close ( * @return 0 or a number OR'ed of #qse_sed_option_t values */ int qse_sed_getoption ( - qse_sed_t* sed /**< stream editor */ + const qse_sed_t* sed /**< stream editor */ ); /** @@ -370,7 +370,7 @@ void qse_sed_setoption ( * The qse_sed_geterrstr() gets an error string getter. */ qse_sed_errstr_t qse_sed_geterrstr ( - qse_sed_t* sed /**< stream editor */ + const qse_sed_t* sed /**< stream editor */ ); /** @@ -407,7 +407,7 @@ void qse_sed_seterrstr ( * @return the number of the last error */ qse_sed_errnum_t qse_sed_geterrnum ( - qse_sed_t* sed /**< stream editor */ + const qse_sed_t* sed /**< stream editor */ ); /** @@ -416,7 +416,7 @@ qse_sed_errnum_t qse_sed_geterrnum ( * @return error location */ const qse_sed_loc_t* qse_sed_geterrloc ( - qse_sed_t* sed /**< stream editor */ + const qse_sed_t* sed /**< stream editor */ ); /** @@ -424,7 +424,7 @@ const qse_sed_loc_t* qse_sed_geterrloc ( * @return a pointer to an error message */ const qse_char_t* qse_sed_geterrmsg ( - qse_sed_t* sed /**< stream editor */ + const qse_sed_t* sed /**< stream editor */ ); /** @@ -433,7 +433,7 @@ const qse_char_t* qse_sed_geterrmsg ( * to by each parameter. */ void qse_sed_geterror ( - qse_sed_t* sed, /**< stream editor */ + const qse_sed_t* sed, /**< stream editor */ qse_sed_errnum_t* errnum, /**< error number */ const qse_char_t** errmsg, /**< error message */ qse_sed_loc_t* errloc /**< error location */ diff --git a/qse/lib/awk/Awk.cpp b/qse/lib/awk/Awk.cpp index 5ea96875..a5f122cf 100644 --- a/qse/lib/awk/Awk.cpp +++ b/qse/lib/awk/Awk.cpp @@ -979,7 +979,7 @@ const Awk::char_t* Awk::getErrorString (errnum_t num) const return dflerrstr (awk, num); } -const Awk::char_t* Awk::xerrstr (awk_t* a, errnum_t num) +const Awk::char_t* Awk::xerrstr (const awk_t* a, errnum_t num) { Awk* awk = *(Awk**)QSE_XTN(a); return awk->getErrorString (num); diff --git a/qse/lib/awk/awk.c b/qse/lib/awk/awk.c index 584a559c..bba5e005 100644 --- a/qse/lib/awk/awk.c +++ b/qse/lib/awk/awk.c @@ -376,7 +376,7 @@ qse_awk_prm_t* qse_awk_getprm (qse_awk_t* awk) return &awk->prm; } -int qse_awk_getoption (qse_awk_t* awk) +int qse_awk_getoption (const qse_awk_t* awk) { return awk->option; } @@ -391,7 +391,7 @@ void qse_awk_stopall (qse_awk_t* awk) awk->stopall = QSE_TRUE; } -qse_size_t qse_awk_getmaxdepth (qse_awk_t* awk, qse_awk_depth_t type) +qse_size_t qse_awk_getmaxdepth (const qse_awk_t* awk, qse_awk_depth_t type) { return (type == QSE_AWK_DEPTH_BLOCK_PARSE)? awk->parse.depth.max.block: (type == QSE_AWK_DEPTH_BLOCK_RUN)? awk->run.depth.max.block: diff --git a/qse/lib/awk/err.c b/qse/lib/awk/err.c index 389084e8..773e367b 100644 --- a/qse/lib/awk/err.c +++ b/qse/lib/awk/err.c @@ -154,7 +154,7 @@ const qse_char_t* qse_awk_dflerrstr (qse_awk_t* awk, qse_awk_errnum_t errnum) errstr[errnum]: QSE_T("unknown error"); } -qse_awk_errstr_t qse_awk_geterrstr (qse_awk_t* awk) +qse_awk_errstr_t qse_awk_geterrstr (const qse_awk_t* awk) { return awk->errstr; } @@ -164,23 +164,23 @@ void qse_awk_seterrstr (qse_awk_t* awk, qse_awk_errstr_t errstr) awk->errstr = errstr; } -qse_awk_errnum_t qse_awk_geterrnum (qse_awk_t* awk) +qse_awk_errnum_t qse_awk_geterrnum (const qse_awk_t* awk) { return awk->errinf.num; } -const qse_awk_loc_t* qse_awk_geterrloc (qse_awk_t* awk) +const qse_awk_loc_t* qse_awk_geterrloc (const qse_awk_t* awk) { return &awk->errinf.loc; } -const qse_char_t* qse_awk_geterrmsg (qse_awk_t* awk) +const qse_char_t* qse_awk_geterrmsg (const qse_awk_t* awk) { return (awk->errinf.msg[0] == QSE_T('\0'))? qse_awk_geterrstr(awk)(awk,awk->errinf.num): awk->errinf.msg; } -void qse_awk_geterrinf (qse_awk_t* awk, qse_awk_errinf_t* errinf) +void qse_awk_geterrinf (const qse_awk_t* awk, qse_awk_errinf_t* errinf) { QSE_MEMCPY (errinf, &awk->errinf, QSE_SIZEOF(*errinf)); if (errinf->msg[0] == QSE_T('\0')) @@ -191,7 +191,7 @@ void qse_awk_geterrinf (qse_awk_t* awk, qse_awk_errinf_t* errinf) } void qse_awk_geterror ( - qse_awk_t* awk, qse_awk_errnum_t* errnum, + const qse_awk_t* awk, qse_awk_errnum_t* errnum, const qse_char_t** errmsg, qse_awk_loc_t* errloc) { if (errnum != QSE_NULL) *errnum = awk->errinf.num; @@ -234,23 +234,23 @@ void qse_awk_seterror ( if (errloc != QSE_NULL) awk->errinf.loc = *errloc; } -qse_awk_errnum_t qse_awk_rtx_geterrnum (qse_awk_rtx_t* rtx) +qse_awk_errnum_t qse_awk_rtx_geterrnum (const qse_awk_rtx_t* rtx) { return rtx->errinf.num; } -const qse_awk_loc_t* qse_awk_rtx_geterrloc (qse_awk_rtx_t* rtx) +const qse_awk_loc_t* qse_awk_rtx_geterrloc (const qse_awk_rtx_t* rtx) { return &rtx->errinf.loc; } -const qse_char_t* qse_awk_rtx_geterrmsg (qse_awk_rtx_t* rtx) +const qse_char_t* qse_awk_rtx_geterrmsg (const qse_awk_rtx_t* rtx) { return (rtx->errinf.msg[0] == QSE_T('\0')) ? qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errinf.num): rtx->errinf.msg; } -void qse_awk_rtx_geterrinf (qse_awk_rtx_t* rtx, qse_awk_errinf_t* errinf) +void qse_awk_rtx_geterrinf (const qse_awk_rtx_t* rtx, qse_awk_errinf_t* errinf) { QSE_MEMCPY (errinf, &rtx->errinf, QSE_SIZEOF(*errinf)); if (errinf->msg[0] == QSE_T('\0')) @@ -261,7 +261,7 @@ void qse_awk_rtx_geterrinf (qse_awk_rtx_t* rtx, qse_awk_errinf_t* errinf) } void qse_awk_rtx_geterror ( - qse_awk_rtx_t* rtx, qse_awk_errnum_t* errnum, + const qse_awk_rtx_t* rtx, qse_awk_errnum_t* errnum, const qse_char_t** errmsg, qse_awk_loc_t* errloc) { if (errnum != QSE_NULL) *errnum = rtx->errinf.num; diff --git a/qse/lib/awk/std.c b/qse/lib/awk/std.c index 6cf21634..5f158bf4 100644 --- a/qse/lib/awk/std.c +++ b/qse/lib/awk/std.c @@ -449,11 +449,13 @@ static qse_ssize_t sf_in_open ( xtn->s.in.u.str.ptr = xtn->s.in.x->u.str.ptr; xtn->s.in.u.str.end = xtn->s.in.x->u.str.ptr + xtn->s.in.x->u.str.len; return 1; + + default: + /* this should never happen */ + qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL); + return -1; } - /* this should never happen */ - qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL); - return -1; } else { @@ -522,6 +524,10 @@ static qse_ssize_t sf_in_close ( case QSE_AWK_PARSESTD_STR: /* nothing to close */ break; + + default: + /* nothing to close */ + break; } } else @@ -574,10 +580,13 @@ static qse_ssize_t sf_in_read ( } return n; } + + default: + /* this should never happen */ + qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL); + return -1; } - qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL); - return -1; } else { @@ -613,10 +622,10 @@ static qse_ssize_t sf_in ( case QSE_AWK_SIO_READ: return sf_in_read (awk, arg, data, size, xtn); + default: + qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL); + return -1; } - - qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL); - return -1; } static qse_ssize_t sf_out ( diff --git a/qse/lib/cmn/fio.c b/qse/lib/cmn/fio.c index c44bb1f1..3cdcd505 100644 --- a/qse/lib/cmn/fio.c +++ b/qse/lib/cmn/fio.c @@ -737,12 +737,17 @@ void qse_fio_fini (qse_fio_t* fio) } } -qse_fio_hnd_t qse_fio_gethandle (qse_fio_t* fio) +qse_fio_errnum_t qse_fio_geterrnum (const qse_fio_t* fio) +{ + return fio->errnum; +} + +qse_fio_hnd_t qse_fio_gethandle (const qse_fio_t* fio) { return fio->handle; } -qse_ubi_t qse_fio_gethandleasubi (qse_fio_t* fio) +qse_ubi_t qse_fio_gethandleasubi (const qse_fio_t* fio) { qse_ubi_t handle; diff --git a/qse/lib/cmn/htb.c b/qse/lib/cmn/htb.c index 12a95981..d26c974b 100644 --- a/qse/lib/cmn/htb.c +++ b/qse/lib/cmn/htb.c @@ -322,7 +322,7 @@ void qse_htb_fini (htb_t* htb) QSE_MMGR_FREE (htb->mmgr, htb->bucket); } -const mancbs_t* qse_htb_getmancbs (htb_t* htb) +const mancbs_t* qse_htb_getmancbs (const htb_t* htb) { return htb->mancbs; } @@ -333,17 +333,17 @@ void qse_htb_setmancbs (htb_t* htb, const mancbs_t* mancbs) htb->mancbs = mancbs; } -size_t qse_htb_getsize (htb_t* htb) +size_t qse_htb_getsize (const htb_t* htb) { return htb->size; } -size_t qse_htb_getcapa (htb_t* htb) +size_t qse_htb_getcapa (const htb_t* htb) { return htb->capa; } -pair_t* qse_htb_search (htb_t* htb, const void* kptr, size_t klen) +pair_t* qse_htb_search (const htb_t* htb, const void* kptr, size_t klen) { pair_t* pair; size_t hc; @@ -709,7 +709,8 @@ pair_t* qse_htb_getnextpair (htb_t* htb, pair_t* pair, size_t* buckno) return QSE_NULL; } -size_t qse_htb_dflhash (htb_t* htb, const void* kptr, size_t klen) +size_t qse_htb_dflhash ( + const htb_t* htb, const void* kptr, size_t klen) { /*size_t h = 2166136261;*/ /*size_t h = 0;*/ @@ -727,7 +728,8 @@ size_t qse_htb_dflhash (htb_t* htb, const void* kptr, size_t klen) return h ; } -int qse_htb_dflcomp (htb_t* htb, +int qse_htb_dflcomp ( + const htb_t* htb, const void* kptr1, size_t klen1, const void* kptr2, size_t klen2) { diff --git a/qse/lib/cmn/ipad.c b/qse/lib/cmn/ipad.c index abd7c464..cf2304ca 100644 --- a/qse/lib/cmn/ipad.c +++ b/qse/lib/cmn/ipad.c @@ -35,6 +35,9 @@ */ #include +#include +#include +#include "mem.h" #if 0 const qse_ipad4_t qse_ipad4_any = @@ -64,7 +67,6 @@ const qse_ipad6_t qse_ipad6_loopback = }; #endif -#if 0 int qse_strtoipad4 (const qse_char_t* str, qse_ipad4_t* ipad) { qse_char_t c; @@ -218,7 +220,7 @@ int qse_strtoipad6 (const qse_char_t* src, qse_ipad6_t* ipad) int saw_xdigit; unsigned int val; - qse_memset (&tmp, 0, QSE_SIZEOF(tmp)); + QSE_MEMSET (&tmp, 0, QSE_SIZEOF(tmp)); tp = &tmp.value[0]; endp = &tmp.value[QSE_COUNTOF(tmp.value)]; colonp = QSE_NULL; @@ -347,7 +349,7 @@ int qse_strxtoipad6 (const qse_char_t* src, qse_size_t len, qse_ipad6_t* ipad) src_end = src + len; - qse_memset (&tmp, 0, QSE_SIZEOF(tmp)); + QSE_MEMSET (&tmp, 0, QSE_SIZEOF(tmp)); tp = &tmp.value[0]; endp = &tmp.value[QSE_COUNTOF(tmp.value)]; colonp = QSE_NULL; @@ -472,7 +474,7 @@ qse_size_t qse_ipad6tostrx ( * Copy the input (bytewise) array into a wordwise array. * Find the longest run of 0x00's in src[] for :: shorthanding. */ - qse_memset (words, 0, QSE_SIZEOF(words)); + QSE_MEMSET (words, 0, QSE_SIZEOF(words)); for (i = 0; i < QSE_SIZEOF(ipad->value); i++) words[i / 2] |= (ipad->value[i] << ((1 - (i % 2)) << 3)); best.base = -1; @@ -529,7 +531,7 @@ qse_size_t qse_ipad6tostrx ( (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) { qse_ipad4_t ipad4; - qse_memcpy (&ipad4.value, ipad->value+12, QSE_SIZEOF(ipad4.value)); + QSE_MEMCPY (&ipad4.value, ipad->value+12, QSE_SIZEOF(ipad4.value)); tp += qse_ipad4tostrx (&ipad4, tp, QSE_SIZEOF(tmp) - (tp - tmp)); break; } @@ -547,6 +549,7 @@ qse_size_t qse_ipad6tostrx ( #undef IP6ADDR_NWORDS } +#if 0 int qse_strtoipad (const qse_char_t* str, qse_ipad_t* ipad) { if (qse_strtoipad4 (str, &ipad->u.ip4) <= -1) diff --git a/qse/lib/cmn/pio.c b/qse/lib/cmn/pio.c index d27eadf0..ffd7e2b6 100644 --- a/qse/lib/cmn/pio.c +++ b/qse/lib/cmn/pio.c @@ -1734,7 +1734,12 @@ void qse_pio_fini (qse_pio_t* pio) qse_pio_wait (pio); } -int qse_pio_getoption (qse_pio_t* pio) +qse_pio_errnum_t qse_pio_geterrnum (const qse_pio_t* pio) +{ + return pio->errnum; +} + +int qse_pio_getoption (const qse_pio_t* pio) { return pio->option; } @@ -1744,11 +1749,6 @@ void qse_pio_setoption (qse_pio_t* pio, int opt) pio->option = opt; } -qse_pio_errnum_t qse_pio_geterrnum (qse_pio_t* pio) -{ - return pio->errnum; -} - qse_cmgr_t* qse_pio_getcmgr (qse_pio_t* pio, qse_pio_hid_t hid) { return pio->pin[hid].tio? @@ -1760,12 +1760,12 @@ void qse_pio_setcmgr (qse_pio_t* pio, qse_pio_hid_t hid, qse_cmgr_t* cmgr) if (pio->pin[hid].tio) qse_tio_setcmgr (pio->pin[hid].tio, cmgr); } -qse_pio_hnd_t qse_pio_gethandle (qse_pio_t* pio, qse_pio_hid_t hid) +qse_pio_hnd_t qse_pio_gethandle (const qse_pio_t* pio, qse_pio_hid_t hid) { return pio->pin[hid].handle; } -qse_ubi_t qse_pio_gethandleasubi (qse_pio_t* pio, qse_pio_hid_t hid) +qse_ubi_t qse_pio_gethandleasubi (const qse_pio_t* pio, qse_pio_hid_t hid) { qse_ubi_t handle; @@ -1782,7 +1782,7 @@ qse_ubi_t qse_pio_gethandleasubi (qse_pio_t* pio, qse_pio_hid_t hid) return handle; } -qse_pio_pid_t qse_pio_getchild (qse_pio_t* pio) +qse_pio_pid_t qse_pio_getchild (const qse_pio_t* pio) { return pio->child; } diff --git a/qse/lib/cmn/rbt.c b/qse/lib/cmn/rbt.c index 41db7de8..d2ba599a 100644 --- a/qse/lib/cmn/rbt.c +++ b/qse/lib/cmn/rbt.c @@ -248,7 +248,7 @@ void qse_rbt_fini (rbt_t* rbt) qse_rbt_clear (rbt); } -const mancbs_t* qse_rbt_getmancbs (rbt_t* rbt) +const mancbs_t* qse_rbt_getmancbs (const rbt_t* rbt) { return rbt->mancbs; } @@ -259,12 +259,12 @@ void qse_rbt_setmancbs (rbt_t* rbt, const mancbs_t* mancbs) rbt->mancbs = mancbs; } -size_t qse_rbt_getsize (rbt_t* rbt) +size_t qse_rbt_getsize (const rbt_t* rbt) { return rbt->size; } -pair_t* qse_rbt_search (rbt_t* rbt, const void* kptr, size_t klen) +pair_t* qse_rbt_search (const rbt_t* rbt, const void* kptr, size_t klen) { pair_t* pair = rbt->root; @@ -972,7 +972,7 @@ void qse_rbt_rwalk (rbt_t* rbt, walker_t walker, void* ctx) } int qse_rbt_dflcomp ( - qse_rbt_t* rbt, + const qse_rbt_t* rbt, const void* kptr1, size_t klen1, const void* kptr2, size_t klen2) { diff --git a/qse/lib/cmn/rex.c b/qse/lib/cmn/rex.c index d577c740..328e3f63 100644 --- a/qse/lib/cmn/rex.c +++ b/qse/lib/cmn/rex.c @@ -200,7 +200,7 @@ qse_rex_node_t* qse_rex_yield (qse_rex_t* rex) return code; } -int qse_rex_getoption (qse_rex_t* rex) +int qse_rex_getoption (const qse_rex_t* rex) { return rex->option; } @@ -210,12 +210,12 @@ void qse_rex_setoption (qse_rex_t* rex, int opts) rex->option = opts; } -qse_rex_errnum_t qse_rex_geterrnum (qse_rex_t* rex) +qse_rex_errnum_t qse_rex_geterrnum (const qse_rex_t* rex) { return rex->errnum; } -const qse_char_t* qse_rex_geterrmsg (qse_rex_t* rex) +const qse_char_t* qse_rex_geterrmsg (const qse_rex_t* rex) { static const qse_char_t* errstr[] = { diff --git a/qse/lib/cmn/sio.c b/qse/lib/cmn/sio.c index e0061807..cbd250fc 100644 --- a/qse/lib/cmn/sio.c +++ b/qse/lib/cmn/sio.c @@ -31,6 +31,14 @@ # include "syscall.h" #endif + +/* internal status codes */ +enum +{ + STATUS_UTF8_CONSOLE = (1 << 0) +}; + + static qse_ssize_t file_input ( qse_tio_t* tio, qse_tio_cmd_t cmd, void* buf, qse_size_t size); static qse_ssize_t file_output ( @@ -113,14 +121,19 @@ qse_sio_t* qse_sio_openstd ( qse_fio_hnd_t hnd; if (qse_getstdfiohandle (std, &hnd) <= -1) return QSE_NULL; + sio = qse_sio_open (mmgr, xtnsize, (const qse_char_t*)&hnd, flags | QSE_SIO_HANDLE | QSE_SIO_NOCLOSE); #if defined(_WIN32) if (sio) { - QSE_ASSERT (std >= 0 && std < QSE_TYPE_MAX(int)); - sio->status = std + 1; + DWORD mode; + if (GetConsoleMode (sio->u.file.handle, &mode) == TRUE && + GetConsoleOutputCP() == CP_UTF8) + { + sio->status |= STATUS_UTF8_CONSOLE; + } } #endif @@ -190,14 +203,19 @@ int qse_sio_initstd ( qse_fio_hnd_t hnd; if (qse_getstdfiohandle (std, &hnd) <= -1) return -1; + n = qse_sio_init (sio, mmgr, (const qse_char_t*)&hnd, flags | QSE_SIO_HANDLE | QSE_SIO_NOCLOSE); #if defined(_WIN32) if (n >= 0) { - QSE_ASSERT (std >= 0 && std < QSE_TYPE_MAX(int)); - sio->status = std + 1; + DWORD mode; + if (GetConsoleMode (sio->u.file.handle, &mode) == TRUE && + GetConsoleOutputCP() == CP_UTF8) + { + sio->status |= STATUS_UTF8_CONSOLE; + } } #endif @@ -212,6 +230,11 @@ void qse_sio_fini (qse_sio_t* sio) qse_fio_fini (&sio->u.file); } +qse_sio_errnum_t qse_sio_geterrnum (const qse_sio_t* sio) +{ + return sio->errnum; +} + qse_cmgr_t* qse_sio_getcmgr (qse_sio_t* sio) { return qse_tio_getcmgr (&sio->tio.io); @@ -222,18 +245,13 @@ void qse_sio_setcmgr (qse_sio_t* sio, qse_cmgr_t* cmgr) qse_tio_setcmgr (&sio->tio.io, cmgr); } -qse_sio_errnum_t qse_sio_geterrnum (qse_sio_t* sio) -{ - return sio->errnum; -} - -qse_sio_hnd_t qse_sio_gethandle (qse_sio_t* sio) +qse_sio_hnd_t qse_sio_gethandle (const qse_sio_t* sio) { /*return qse_fio_gethandle (&sio->u.file);*/ return QSE_FIO_HANDLE(&sio->u.file); } -qse_ubi_t qse_sio_gethandleasubi (qse_sio_t* sio) +qse_ubi_t qse_sio_gethandleasubi (const qse_sio_t* sio) { return qse_fio_gethandleasubi (&sio->u.file); } @@ -390,7 +408,7 @@ qse_ssize_t qse_sio_putmbs (qse_sio_t* sio, const qse_mchar_t* str) #if defined(_WIN32) /* Using WriteConsoleA() didn't help at all. - * so I don't implement any hack here */ + * so I don't implement any hacks here */ #endif sio->errnum = QSE_SIO_ENOERR; @@ -408,7 +426,7 @@ qse_ssize_t qse_sio_putmbsn ( #if defined(_WIN32) /* Using WriteConsoleA() didn't help at all. - * so I don't implement any hack here */ + * so I don't implement any hacks here */ #endif sio->errnum = QSE_SIO_ENOERR; @@ -425,37 +443,31 @@ qse_ssize_t qse_sio_putwcs (qse_sio_t* sio, const qse_wchar_t* str) #if defined(_WIN32) /* DAMN UGLY: See comment in qse_sio_putwcsn() */ - if (sio->status) + if (sio->status & STATUS_UTF8_CONSOLE) { - DWORD mode; + DWORD count, left; + const qse_wchar_t* cur; - if (GetConsoleMode (sio->u.file.handle, &mode) == TRUE && - GetConsoleOutputCP() == CP_UTF8) + if (qse_sio_flush (sio) <= -1) return -1; /* can't do buffering */ + + for (cur = str, left = qse_wcslen(str); left > 0; cur += count, left -= count) { - DWORD count, left; - const qse_wchar_t* cur; - - if (qse_sio_flush (sio) <= -1) return -1; /* can't do buffering */ - - for (cur = str, left = qse_wcslen(str); left > 0; cur += count, left -= count) + if (WriteConsoleW ( + sio->u.file.handle, cur, left, + &count, QSE_NULL) == FALSE) { - if (WriteConsoleW ( - sio->u.file.handle, cur, left, - &count, QSE_NULL) == FALSE) - { - sio->errnum = QSE_SIO_ESYSERR; - return -1; - } - if (count == 0) break; - - if (count > left) - { - sio->errnum = QSE_SIO_ESYSERR; - return -1; - } + sio->errnum = QSE_SIO_ESYSERR; + return -1; + } + if (count == 0) break; + + if (count > left) + { + sio->errnum = QSE_SIO_ESYSERR; + return -1; } - return cur - str; } + return cur - str; } #endif @@ -484,45 +496,39 @@ qse_ssize_t qse_sio_putwcsn ( * Note that the multibyte functions qse_sio_putmbs() and * qse_sio_putmbsn() doesn't handle this. So you may still suffer. */ - if (sio->status) + if (sio->status & STATUS_UTF8_CONSOLE) { - DWORD mode; + DWORD count, left; + const qse_wchar_t* cur; - if (GetConsoleMode (sio->u.file.handle, &mode) == TRUE && - GetConsoleOutputCP() == CP_UTF8) + if (qse_sio_flush (sio) <= -1) return -1; /* can't do buffering */ + + for (cur = str, left = size; left > 0; cur += count, left -= count) { - DWORD count, left; - const qse_wchar_t* cur; - - if (qse_sio_flush (sio) <= -1) return -1; /* can't do buffering */ - - for (cur = str, left = size; left > 0; cur += count, left -= count) + if (WriteConsoleW ( + sio->u.file.handle, cur, left, + &count, QSE_NULL) == FALSE) { - if (WriteConsoleW ( - sio->u.file.handle, cur, left, - &count, QSE_NULL) == FALSE) - { - sio->errnum = QSE_SIO_ESYSERR; - return -1; - } - if (count == 0) break; - - /* Note: - * WriteConsoleW() in unicosw.dll on win 9x/me returns - * the number of bytes via 'count'. If a double byte - * string is given, 'count' can be greater than 'left'. - * this case is a miserable failure. however, i don't - * think there is CP_UTF8 codepage for console on win9x/me. - * so let me make this function fail if that ever happens. - */ - if (count > left) - { - sio->errnum = QSE_SIO_ESYSERR; - return -1; - } + sio->errnum = QSE_SIO_ESYSERR; + return -1; + } + if (count == 0) break; + + /* Note: + * WriteConsoleW() in unicosw.dll on win 9x/me returns + * the number of bytes via 'count'. If a double byte + * string is given, 'count' can be greater than 'left'. + * this case is a miserable failure. however, i don't + * think there is CP_UTF8 codepage for console on win9x/me. + * so let me make this function fail if that ever happens. + */ + if (count > left) + { + sio->errnum = QSE_SIO_ESYSERR; + return -1; } - return cur - str; } + return cur - str; } #endif diff --git a/qse/lib/cmn/tio.c b/qse/lib/cmn/tio.c index 416eacad..65ffde4a 100644 --- a/qse/lib/cmn/tio.c +++ b/qse/lib/cmn/tio.c @@ -87,7 +87,7 @@ int qse_tio_fini (qse_tio_t* tio) return ret; } -qse_tio_errnum_t qse_tio_geterrnum (qse_tio_t* tio) +qse_tio_errnum_t qse_tio_geterrnum (const qse_tio_t* tio) { return tio->errnum; } diff --git a/qse/lib/sed/Sed.cpp b/qse/lib/sed/Sed.cpp index 0535787f..42ca2ce5 100644 --- a/qse/lib/sed/Sed.cpp +++ b/qse/lib/sed/Sed.cpp @@ -239,7 +239,7 @@ const Sed::char_t* Sed::getErrorString (errnum_t num) const return dflerrstr (sed, num); } -const Sed::char_t* Sed::xerrstr (sed_t* s, errnum_t num) +const Sed::char_t* Sed::xerrstr (const sed_t* s, errnum_t num) { Sed* sed = *(Sed**)QSE_XTN(s); try diff --git a/qse/lib/sed/err.c b/qse/lib/sed/err.c index cbcb1587..a2278263 100644 --- a/qse/lib/sed/err.c +++ b/qse/lib/sed/err.c @@ -65,7 +65,7 @@ const qse_char_t* qse_sed_dflerrstr (qse_sed_t* sed, qse_sed_errnum_t errnum) errstr[errnum]: QSE_T("unknown error"); } -qse_sed_errstr_t qse_sed_geterrstr (qse_sed_t* sed) +qse_sed_errstr_t qse_sed_geterrstr (const qse_sed_t* sed) { return sed->errstr; } @@ -75,24 +75,24 @@ void qse_sed_seterrstr (qse_sed_t* sed, qse_sed_errstr_t errstr) sed->errstr = errstr; } -qse_sed_errnum_t qse_sed_geterrnum (qse_sed_t* sed) +qse_sed_errnum_t qse_sed_geterrnum (const qse_sed_t* sed) { return sed->errnum; } -const qse_sed_loc_t* qse_sed_geterrloc (qse_sed_t* sed) +const qse_sed_loc_t* qse_sed_geterrloc (const qse_sed_t* sed) { return &sed->errloc; } -const qse_char_t* qse_sed_geterrmsg (qse_sed_t* sed) +const qse_char_t* qse_sed_geterrmsg (const qse_sed_t* sed) { return (sed->errmsg[0] == QSE_T('\0'))? qse_sed_geterrstr(sed)(sed,sed->errnum): sed->errmsg; } void qse_sed_geterror ( - qse_sed_t* sed, qse_sed_errnum_t* errnum, + const qse_sed_t* sed, qse_sed_errnum_t* errnum, const qse_char_t** errmsg, qse_sed_loc_t* errloc) { if (errnum != QSE_NULL) *errnum = sed->errnum; diff --git a/qse/lib/sed/sed.c b/qse/lib/sed/sed.c index ddcec936..b18d1324 100644 --- a/qse/lib/sed/sed.c +++ b/qse/lib/sed/sed.c @@ -137,13 +137,13 @@ void qse_sed_setoption (qse_sed_t* sed, int option) sed->option = option; } -int qse_sed_getoption (qse_sed_t* sed) +int qse_sed_getoption (const qse_sed_t* sed) { return sed->option; } #if defined(USE_REX) -qse_size_t qse_sed_getmaxdepth (qse_sed_t* sed, qse_sed_depth_t id) +qse_size_t qse_sed_getmaxdepth (const qse_sed_t* sed, qse_sed_depth_t id) { return (id & QSE_SED_DEPTH_REX_BUILD)? sed->depth.rex.build: (id & QSE_SED_DEPTH_REX_MATCH)? sed->depth.rex.match: 0; diff --git a/qse/lib/sed/sed.h b/qse/lib/sed/sed.h index 80a57155..0e74d5f5 100644 --- a/qse/lib/sed/sed.h +++ b/qse/lib/sed/sed.h @@ -243,8 +243,8 @@ const qse_char_t* qse_sed_dflerrstr ( * The qse_sed_getmaxdepth() gets the maximum processing depth. */ qse_size_t qse_sed_getmaxdepth ( - qse_sed_t* sed, /**< stream editor */ - qse_sed_depth_t id /**< one of qse_sed_depth_t values */ + const qse_sed_t* sed, /**< stream editor */ + qse_sed_depth_t id /**< one of qse_sed_depth_t values */ ); /** diff --git a/qse/lib/sed/std.c b/qse/lib/sed/std.c index a9ff58ee..55384c09 100644 --- a/qse/lib/sed/std.c +++ b/qse/lib/sed/std.c @@ -208,6 +208,10 @@ static void close_main_stream ( * i close this in qse_awk_execstd() */ break; + + default: + /* do nothing */ + break; } } @@ -827,7 +831,7 @@ int qse_sed_compstdstr (qse_sed_t* sed, const qse_char_t* script) qse_sed_iostd_t in[2]; in[0].type = QSE_SED_IOSTD_STR; - in[0].u.str.ptr = script; + in[0].u.str.ptr = (qse_char_t*)script; in[0].u.str.len = qse_strlen(script); in[1].type = QSE_SED_IOSTD_NULL;