enhanced win32 utf8 console hack in sio

This commit is contained in:
hyung-hwan 2012-02-25 14:52:26 +00:00
parent b0bcf53b6f
commit ada60acf67
30 changed files with 296 additions and 233 deletions

View File

@ -558,14 +558,13 @@ static void trace_exec (qse_sed_t* sed, qse_sed_exec_op_t op, const qse_sed_cmd_
{ {
switch (op) switch (op)
{ {
#if 0
case QSE_SED_EXEC_READ: case QSE_SED_EXEC_READ:
qse_fprintf (QSE_STDERR, QSE_T("reading...\n")); /*qse_fprintf (QSE_STDERR, QSE_T("reading...\n"));*/
break; break;
case QSE_SED_EXEC_WRITE: case QSE_SED_EXEC_WRITE:
qse_fprintf (QSE_STDERR, QSE_T("wrting...\n")); /*qse_fprintf (QSE_STDERR, QSE_T("wrting...\n"));*/
break; break;
#endif
/* TODO: use function to get hold space and pattern space and print them */ /* TODO: use function to get hold space and pattern space and print them */
case QSE_SED_EXEC_MATCH: case QSE_SED_EXEC_MATCH:

View File

@ -1171,7 +1171,7 @@ private:
int dispatch_function (Run* run, const cstr_t* name); 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: private:
Awk (const Awk&); Awk (const Awk&);

View File

@ -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. * object with the qse_awk_seterrstr() function to customize an error string.
*/ */
typedef const qse_char_t* (*qse_awk_errstr_t) ( 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 */ qse_awk_errnum_t num /**< error number */
); );
@ -1205,7 +1205,7 @@ int qse_awk_clear (
* The qse_awk_geterrstr() gets an error string getter. * The qse_awk_geterrstr() gets an error string getter.
*/ */
qse_awk_errstr_t qse_awk_geterrstr ( 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 * @return error number
*/ */
qse_awk_errnum_t qse_awk_geterrnum ( 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. * last error has occurred.
*/ */
const qse_awk_loc_t* qse_awk_geterrloc ( 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 * @return error message
*/ */
const qse_char_t* qse_awk_geterrmsg ( 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. * pointed to by @a errinf from @a awk.
*/ */
void qse_awk_geterrinf ( void qse_awk_geterrinf (
qse_awk_t* awk, /**< awk */ const qse_awk_t* awk, /**< awk */
qse_awk_errinf_t* errinf /**< error information buffer */ 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. * The qse_awk_geterror() function gets error information via parameters.
*/ */
void qse_awk_geterror ( void qse_awk_geterror (
qse_awk_t* awk, /**< awk */ const qse_awk_t* awk, /**< awk */
qse_awk_errnum_t* errnum, /**< error number */ qse_awk_errnum_t* errnum, /**< error number */
const qse_char_t** errmsg, /**< error message */ const qse_char_t** errmsg, /**< error message */
qse_awk_loc_t* errloc /**< error location */ 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. * @return 0 or a number ORed of #qse_awk_option_t enumerators.
*/ */
int qse_awk_getoption ( int qse_awk_getoption (
qse_awk_t* awk /**< awk */ const qse_awk_t* awk /**< awk */
); );
/** /**
@ -1340,7 +1340,7 @@ void qse_awk_setoption (
* @return maximum depth * @return maximum depth
*/ */
qse_size_t qse_awk_getmaxdepth ( qse_size_t qse_awk_getmaxdepth (
qse_awk_t* awk, /**< awk */ const qse_awk_t* awk, /**< awk */
qse_awk_depth_t type /**< operation type */ qse_awk_depth_t type /**< operation type */
); );
@ -1797,7 +1797,7 @@ qse_htb_t* qse_awk_rtx_getnvmap (
* @return error number * @return error number
*/ */
qse_awk_errnum_t qse_awk_rtx_geterrnum ( 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 * @return error location
*/ */
const qse_awk_loc_t* qse_awk_rtx_geterrloc ( 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 * @return error message
*/ */
const qse_char_t* qse_awk_rtx_geterrmsg ( const qse_char_t* qse_awk_rtx_geterrmsg (
qse_awk_rtx_t* rtx /**< runtime context */ const qse_awk_rtx_t* rtx /**< runtime context */
); );
/** /**
@ -1823,7 +1823,7 @@ const qse_char_t* qse_awk_rtx_geterrmsg (
* pointed to by @a errinf from a runtime context @a rtx. * pointed to by @a errinf from a runtime context @a rtx.
*/ */
void qse_awk_rtx_geterrinf ( void qse_awk_rtx_geterrinf (
qse_awk_rtx_t* rtx, /**< runtime context */ const qse_awk_rtx_t* rtx, /**< runtime context */
qse_awk_errinf_t* errinf /**< error information */ qse_awk_errinf_t* errinf /**< error information */
); );
@ -1834,7 +1834,7 @@ void qse_awk_rtx_geterrinf (
* @a errmsg; the error line into memory pointed to by @a errlin. * @a errmsg; the error line into memory pointed to by @a errlin.
*/ */
void qse_awk_rtx_geterror ( void qse_awk_rtx_geterror (
qse_awk_rtx_t* rtx, /**< runtime context */ const qse_awk_rtx_t* rtx, /**< runtime context */
qse_awk_errnum_t* errnum, /**< error number */ qse_awk_errnum_t* errnum, /**< error number */
const qse_char_t** errmsg, /**< error message */ const qse_char_t** errmsg, /**< error message */
qse_awk_loc_t* errloc /**< error location */ qse_awk_loc_t* errloc /**< error location */

View File

@ -210,15 +210,19 @@ void qse_fio_fini (
qse_fio_t* fio 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. * The qse_fio_gethandle() function returns the native file handle.
*/ */
qse_fio_hnd_t qse_fio_gethandle ( qse_fio_hnd_t qse_fio_gethandle (
qse_fio_t* fio const qse_fio_t* fio
); );
qse_ubi_t qse_fio_gethandleasubi ( qse_ubi_t qse_fio_gethandleasubi (
qse_fio_t* fio const qse_fio_t* fio
); );
/** /**

View File

@ -121,7 +121,7 @@ typedef void (*qse_htb_freeer_t) (
* integer otherwise. * integer otherwise.
*/ */
typedef int (*qse_htb_comper_t) ( typedef int (*qse_htb_comper_t) (
qse_htb_t* htb, /**< hash table */ const qse_htb_t* htb, /**< hash table */
const void* kptr1, /**< key pointer */ const void* kptr1, /**< key pointer */
qse_size_t klen1, /**< key length */ qse_size_t klen1, /**< key length */
const void* kptr2, /**< key pointer */ const void* kptr2, /**< key pointer */
@ -154,7 +154,7 @@ typedef qse_size_t (*qse_htb_sizer_t) (
* The qse_htb_hasher_t type defines a key hash function * The qse_htb_hasher_t type defines a key hash function
*/ */
typedef qse_size_t (*qse_htb_hasher_t) ( typedef qse_size_t (*qse_htb_hasher_t) (
qse_htb_t* htb, /**< hash table */ const qse_htb_t* htb, /**< hash table */
const void* kptr, /**< key pointer */ const void* kptr, /**< key pointer */
qse_size_t klen /**< key length in bytes */ 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. * The qse_htb_getmancbs() function gets manipulation callback function set.
*/ */
const qse_htb_mancbs_t* qse_htb_getmancbs ( 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. * The qse_htb_getsize() function gets the number of pairs in hash table.
*/ */
qse_size_t qse_htb_getsize ( 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. * in a hash bucket.
*/ */
qse_size_t qse_htb_getcapa ( qse_size_t qse_htb_getcapa (
qse_htb_t* htb /**< hash table */ const qse_htb_t* htb /**< hash table */
); );
/** /**
@ -396,7 +396,7 @@ qse_size_t qse_htb_getcapa (
* or #QSE_NULL if no match is found. * or #QSE_NULL if no match is found.
*/ */
qse_htb_pair_t* qse_htb_search ( qse_htb_pair_t* qse_htb_search (
qse_htb_t* htb, /**< hash table */ const qse_htb_t* htb, /**< hash table */
const void* kptr, /**< key pointer */ const void* kptr, /**< key pointer */
qse_size_t klen /**< key length */ qse_size_t klen /**< key length */
); );
@ -632,7 +632,7 @@ void qse_htb_freepair (
* The qse_htb_dflhash() function is a default hash function. * The qse_htb_dflhash() function is a default hash function.
*/ */
qse_size_t qse_htb_dflhash ( qse_size_t qse_htb_dflhash (
qse_htb_t* htb, const qse_htb_t* htb,
const void* kptr, const void* kptr,
qse_size_t klen qse_size_t klen
); );
@ -641,7 +641,7 @@ qse_size_t qse_htb_dflhash (
* The qse_htb_dflcomp() function is default comparator. * The qse_htb_dflcomp() function is default comparator.
*/ */
int qse_htb_dflcomp ( int qse_htb_dflcomp (
qse_htb_t* htb, const qse_htb_t* htb,
const void* kptr1, const void* kptr1,
qse_size_t klen1, qse_size_t klen1,
const void* kptr2, const void* kptr2,

View File

@ -1,4 +1,3 @@
/* /*
* $Id$ * $Id$
* *
@ -44,14 +43,14 @@ struct qse_ipad_t
{ {
enum enum
{ {
QSE_IPAD_IP4, QSE_IPAD_V4,
QSE_IPAD_IP6 QSE_IPAD_V6
} type; } type;
union union
{ {
qse_ipad4_t ip4; qse_ipad4_t v4;
qse_ipad4_t ip6; qse_ipad6_t v6;
} u; } u;
}; };
@ -59,6 +58,38 @@ struct qse_ipad_t
extern "C" { extern "C" {
#endif #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 #ifdef __cplusplus
} }
#endif #endif

View File

@ -263,12 +263,21 @@ void qse_pio_fini (
qse_pio_t* pio /**< pio object */ 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. * The qse_pio_getoption() function gets the current option.
* @return option number OR'ed of #qse_pio_option_t enumerators * @return option number OR'ed of #qse_pio_option_t enumerators
*/ */
int qse_pio_getoption ( 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 */ 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. * The qse_pio_getcmgr() function returns the current character manager.
* It returns #QSE_NULL is @a pio is not opened with #QSE_PIO_TEXT. * It returns #QSE_NULL is @a pio is not opened with #QSE_PIO_TEXT.
@ -313,7 +313,7 @@ void qse_pio_setcmgr (
* @return pipe handle * @return pipe handle
*/ */
qse_pio_hnd_t qse_pio_gethandle ( qse_pio_hnd_t qse_pio_gethandle (
qse_pio_t* pio, /**< pio object */ const qse_pio_t* pio, /**< pio object */
qse_pio_hid_t hid /**< handle ID */ qse_pio_hid_t hid /**< handle ID */
); );
@ -323,7 +323,7 @@ qse_pio_hnd_t qse_pio_gethandle (
* @return pipe handle * @return pipe handle
*/ */
qse_ubi_t qse_pio_gethandleasubi ( qse_ubi_t qse_pio_gethandleasubi (
qse_pio_t* pio, /**< pio object */ const qse_pio_t* pio, /**< pio object */
qse_pio_hid_t hid /**< handle ID */ qse_pio_hid_t hid /**< handle ID */
); );
@ -332,7 +332,7 @@ qse_ubi_t qse_pio_gethandleasubi (
* @return process handle * @return process handle
*/ */
qse_pio_pid_t qse_pio_getchild ( qse_pio_pid_t qse_pio_getchild (
qse_pio_t* pio /**< pio object */ const qse_pio_t* pio /**< pio object */
); );
/** /**

View File

@ -116,7 +116,7 @@ typedef void (*qse_rbt_freeer_t) (
* key is greater than the second key, -1 otherwise. * key is greater than the second key, -1 otherwise.
*/ */
typedef int (*qse_rbt_comper_t) ( typedef int (*qse_rbt_comper_t) (
qse_rbt_t* rbt, /**< red-black tree */ const qse_rbt_t* rbt, /**< red-black tree */
const void* kptr1, /**< key pointer */ const void* kptr1, /**< key pointer */
qse_size_t klen1, /**< key length */ qse_size_t klen1, /**< key length */
const void* kptr2, /**< key pointer */ const void* kptr2, /**< key pointer */
@ -319,7 +319,7 @@ void qse_rbt_fini (
* The qse_rbt_getmancbs() function gets manipulation callback function set. * The qse_rbt_getmancbs() function gets manipulation callback function set.
*/ */
const qse_rbt_mancbs_t* qse_rbt_getmancbs ( 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. * The qse_rbt_getsize() function gets the number of pairs in red-black tree.
*/ */
qse_size_t qse_rbt_getsize ( qse_size_t qse_rbt_getsize (
qse_rbt_t* rbt /**< red-black tree */ const qse_rbt_t* rbt /**< red-black tree */
); );
/** /**
@ -346,7 +346,7 @@ qse_size_t qse_rbt_getsize (
* or QSE_NULL if no match is found. * or QSE_NULL if no match is found.
*/ */
qse_rbt_pair_t* qse_rbt_search ( qse_rbt_pair_t* qse_rbt_search (
qse_rbt_t* rbt, /**< red-black tree */ const qse_rbt_t* rbt, /**< red-black tree */
const void* kptr, /**< key pointer */ const void* kptr, /**< key pointer */
qse_size_t klen /**< the size of the key */ qse_size_t klen /**< the size of the key */
); );
@ -574,7 +574,7 @@ void qse_rbt_freepair (
* The qse_rbt_dflcomp() function defines the default key comparator. * The qse_rbt_dflcomp() function defines the default key comparator.
*/ */
int qse_rbt_dflcomp ( int qse_rbt_dflcomp (
qse_rbt_t* rbt, const qse_rbt_t* rbt,
const void* kptr1, const void* kptr1,
qse_size_t klen1, qse_size_t klen1,
const void* kptr2, const void* kptr2,

View File

@ -238,7 +238,7 @@ qse_rex_node_t* qse_rex_yield (
* The qse_rex_getoption() function returns the current options. * The qse_rex_getoption() function returns the current options.
*/ */
int qse_rex_getoption ( 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_errnum_t qse_rex_geterrnum (
qse_rex_t* rex const qse_rex_t* rex
); );
const qse_char_t* qse_rex_geterrmsg ( const qse_char_t* qse_rex_geterrmsg (
qse_rex_t* rex const qse_rex_t* rex
); );
qse_rex_node_t* qse_rex_comp ( qse_rex_node_t* qse_rex_comp (

View File

@ -197,7 +197,7 @@ void qse_sio_fini (
); );
qse_sio_errnum_t qse_sio_geterrnum ( qse_sio_errnum_t qse_sio_geterrnum (
qse_sio_t* sio const qse_sio_t* sio
); );
qse_cmgr_t* qse_sio_getcmgr ( qse_cmgr_t* qse_sio_getcmgr (
@ -210,11 +210,11 @@ void qse_sio_setcmgr (
); );
qse_sio_hnd_t qse_sio_gethandle ( qse_sio_hnd_t qse_sio_gethandle (
qse_sio_t* sio const qse_sio_t* sio
); );
qse_ubi_t qse_sio_gethandleasubi ( qse_ubi_t qse_sio_gethandleasubi (
qse_sio_t* sio const qse_sio_t* sio
); );
qse_ssize_t qse_sio_flush ( qse_ssize_t qse_sio_flush (

View File

@ -169,7 +169,7 @@ int qse_tio_fini (
* The qse_tio_geterrnum() function returns the current error code. * The qse_tio_geterrnum() function returns the current error code.
*/ */
qse_tio_errnum_t qse_tio_geterrnum ( qse_tio_errnum_t qse_tio_geterrnum (
qse_tio_t* tio const qse_tio_t* tio
); );
/** /**

View File

@ -316,7 +316,7 @@ private:
sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* buf, size_t len); sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* buf, size_t len);
static ssize_t xout ( static ssize_t xout (
sed_t* s, io_cmd_t cmd, io_arg_t* arg, char_t* dat, size_t len); 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: private:
Sed (const Sed&); Sed (const Sed&);

View File

@ -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. * editor with the qse_sed_seterrstr() function to customize an error string.
*/ */
typedef const qse_char_t* (*qse_sed_errstr_t) ( 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 */ 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 * @return 0 or a number OR'ed of #qse_sed_option_t values
*/ */
int qse_sed_getoption ( 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. * The qse_sed_geterrstr() gets an error string getter.
*/ */
qse_sed_errstr_t qse_sed_geterrstr ( 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 * @return the number of the last error
*/ */
qse_sed_errnum_t qse_sed_geterrnum ( 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 * @return error location
*/ */
const qse_sed_loc_t* qse_sed_geterrloc ( 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 * @return a pointer to an error message
*/ */
const qse_char_t* qse_sed_geterrmsg ( 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. * to by each parameter.
*/ */
void qse_sed_geterror ( void qse_sed_geterror (
qse_sed_t* sed, /**< stream editor */ const qse_sed_t* sed, /**< stream editor */
qse_sed_errnum_t* errnum, /**< error number */ qse_sed_errnum_t* errnum, /**< error number */
const qse_char_t** errmsg, /**< error message */ const qse_char_t** errmsg, /**< error message */
qse_sed_loc_t* errloc /**< error location */ qse_sed_loc_t* errloc /**< error location */

View File

@ -979,7 +979,7 @@ const Awk::char_t* Awk::getErrorString (errnum_t num) const
return dflerrstr (awk, num); 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); Awk* awk = *(Awk**)QSE_XTN(a);
return awk->getErrorString (num); return awk->getErrorString (num);

View File

@ -376,7 +376,7 @@ qse_awk_prm_t* qse_awk_getprm (qse_awk_t* awk)
return &awk->prm; return &awk->prm;
} }
int qse_awk_getoption (qse_awk_t* awk) int qse_awk_getoption (const qse_awk_t* awk)
{ {
return awk->option; return awk->option;
} }
@ -391,7 +391,7 @@ void qse_awk_stopall (qse_awk_t* awk)
awk->stopall = QSE_TRUE; 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: return (type == QSE_AWK_DEPTH_BLOCK_PARSE)? awk->parse.depth.max.block:
(type == QSE_AWK_DEPTH_BLOCK_RUN)? awk->run.depth.max.block: (type == QSE_AWK_DEPTH_BLOCK_RUN)? awk->run.depth.max.block:

View File

@ -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"); 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; return awk->errstr;
} }
@ -164,23 +164,23 @@ void qse_awk_seterrstr (qse_awk_t* awk, qse_awk_errstr_t errstr)
awk->errstr = 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; 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; 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'))? return (awk->errinf.msg[0] == QSE_T('\0'))?
qse_awk_geterrstr(awk)(awk,awk->errinf.num): awk->errinf.msg; 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)); QSE_MEMCPY (errinf, &awk->errinf, QSE_SIZEOF(*errinf));
if (errinf->msg[0] == QSE_T('\0')) 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 ( 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) const qse_char_t** errmsg, qse_awk_loc_t* errloc)
{ {
if (errnum != QSE_NULL) *errnum = awk->errinf.num; if (errnum != QSE_NULL) *errnum = awk->errinf.num;
@ -234,23 +234,23 @@ void qse_awk_seterror (
if (errloc != QSE_NULL) awk->errinf.loc = *errloc; 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; 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; 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')) ? return (rtx->errinf.msg[0] == QSE_T('\0')) ?
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errinf.num): rtx->errinf.msg; 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)); QSE_MEMCPY (errinf, &rtx->errinf, QSE_SIZEOF(*errinf));
if (errinf->msg[0] == QSE_T('\0')) 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 ( 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) const qse_char_t** errmsg, qse_awk_loc_t* errloc)
{ {
if (errnum != QSE_NULL) *errnum = rtx->errinf.num; if (errnum != QSE_NULL) *errnum = rtx->errinf.num;

View File

@ -449,12 +449,14 @@ 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.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; xtn->s.in.u.str.end = xtn->s.in.x->u.str.ptr + xtn->s.in.x->u.str.len;
return 1; return 1;
}
default:
/* this should never happen */ /* this should never happen */
qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL); qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL);
return -1; return -1;
} }
}
else else
{ {
const qse_char_t* file = arg->name; const qse_char_t* file = arg->name;
@ -522,6 +524,10 @@ static qse_ssize_t sf_in_close (
case QSE_AWK_PARSESTD_STR: case QSE_AWK_PARSESTD_STR:
/* nothing to close */ /* nothing to close */
break; break;
default:
/* nothing to close */
break;
} }
} }
else else
@ -574,11 +580,14 @@ static qse_ssize_t sf_in_read (
} }
return n; return n;
} }
}
default:
/* this should never happen */
qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL); qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL);
return -1; return -1;
} }
}
else else
{ {
qse_ssize_t n; qse_ssize_t n;
@ -613,11 +622,11 @@ static qse_ssize_t sf_in (
case QSE_AWK_SIO_READ: case QSE_AWK_SIO_READ:
return sf_in_read (awk, arg, data, size, xtn); return sf_in_read (awk, arg, data, size, xtn);
} default:
qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL); qse_awk_seterrnum (awk, QSE_AWK_EINTERN, QSE_NULL);
return -1; return -1;
} }
}
static qse_ssize_t sf_out ( static qse_ssize_t sf_out (
qse_awk_t* awk, qse_awk_sio_cmd_t cmd, qse_awk_t* awk, qse_awk_sio_cmd_t cmd,

View File

@ -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; 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; qse_ubi_t handle;

View File

@ -322,7 +322,7 @@ void qse_htb_fini (htb_t* htb)
QSE_MMGR_FREE (htb->mmgr, htb->bucket); 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; return htb->mancbs;
} }
@ -333,17 +333,17 @@ void qse_htb_setmancbs (htb_t* htb, const mancbs_t* mancbs)
htb->mancbs = mancbs; htb->mancbs = mancbs;
} }
size_t qse_htb_getsize (htb_t* htb) size_t qse_htb_getsize (const htb_t* htb)
{ {
return htb->size; return htb->size;
} }
size_t qse_htb_getcapa (htb_t* htb) size_t qse_htb_getcapa (const htb_t* htb)
{ {
return htb->capa; 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; pair_t* pair;
size_t hc; size_t hc;
@ -709,7 +709,8 @@ pair_t* qse_htb_getnextpair (htb_t* htb, pair_t* pair, size_t* buckno)
return QSE_NULL; 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 = 2166136261;*/
/*size_t h = 0;*/ /*size_t h = 0;*/
@ -727,7 +728,8 @@ size_t qse_htb_dflhash (htb_t* htb, const void* kptr, size_t klen)
return h ; 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* kptr1, size_t klen1,
const void* kptr2, size_t klen2) const void* kptr2, size_t klen2)
{ {

View File

@ -35,6 +35,9 @@
*/ */
#include <qse/cmn/ipad.h> #include <qse/cmn/ipad.h>
#include <qse/cmn/hton.h>
#include <qse/cmn/str.h>
#include "mem.h"
#if 0 #if 0
const qse_ipad4_t qse_ipad4_any = const qse_ipad4_t qse_ipad4_any =
@ -64,7 +67,6 @@ const qse_ipad6_t qse_ipad6_loopback =
}; };
#endif #endif
#if 0
int qse_strtoipad4 (const qse_char_t* str, qse_ipad4_t* ipad) int qse_strtoipad4 (const qse_char_t* str, qse_ipad4_t* ipad)
{ {
qse_char_t c; qse_char_t c;
@ -218,7 +220,7 @@ int qse_strtoipad6 (const qse_char_t* src, qse_ipad6_t* ipad)
int saw_xdigit; int saw_xdigit;
unsigned int val; unsigned int val;
qse_memset (&tmp, 0, QSE_SIZEOF(tmp)); QSE_MEMSET (&tmp, 0, QSE_SIZEOF(tmp));
tp = &tmp.value[0]; tp = &tmp.value[0];
endp = &tmp.value[QSE_COUNTOF(tmp.value)]; endp = &tmp.value[QSE_COUNTOF(tmp.value)];
colonp = QSE_NULL; 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; src_end = src + len;
qse_memset (&tmp, 0, QSE_SIZEOF(tmp)); QSE_MEMSET (&tmp, 0, QSE_SIZEOF(tmp));
tp = &tmp.value[0]; tp = &tmp.value[0];
endp = &tmp.value[QSE_COUNTOF(tmp.value)]; endp = &tmp.value[QSE_COUNTOF(tmp.value)];
colonp = QSE_NULL; colonp = QSE_NULL;
@ -472,7 +474,7 @@ qse_size_t qse_ipad6tostrx (
* Copy the input (bytewise) array into a wordwise array. * Copy the input (bytewise) array into a wordwise array.
* Find the longest run of 0x00's in src[] for :: shorthanding. * 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++) for (i = 0; i < QSE_SIZEOF(ipad->value); i++)
words[i / 2] |= (ipad->value[i] << ((1 - (i % 2)) << 3)); words[i / 2] |= (ipad->value[i] << ((1 - (i % 2)) << 3));
best.base = -1; best.base = -1;
@ -529,7 +531,7 @@ qse_size_t qse_ipad6tostrx (
(best.len == 6 || (best.len == 5 && words[5] == 0xffff))) (best.len == 6 || (best.len == 5 && words[5] == 0xffff)))
{ {
qse_ipad4_t ipad4; 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)); tp += qse_ipad4tostrx (&ipad4, tp, QSE_SIZEOF(tmp) - (tp - tmp));
break; break;
} }
@ -547,6 +549,7 @@ qse_size_t qse_ipad6tostrx (
#undef IP6ADDR_NWORDS #undef IP6ADDR_NWORDS
} }
#if 0
int qse_strtoipad (const qse_char_t* str, qse_ipad_t* ipad) int qse_strtoipad (const qse_char_t* str, qse_ipad_t* ipad)
{ {
if (qse_strtoipad4 (str, &ipad->u.ip4) <= -1) if (qse_strtoipad4 (str, &ipad->u.ip4) <= -1)

View File

@ -1734,7 +1734,12 @@ void qse_pio_fini (qse_pio_t* pio)
qse_pio_wait (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; return pio->option;
} }
@ -1744,11 +1749,6 @@ void qse_pio_setoption (qse_pio_t* pio, int opt)
pio->option = 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) qse_cmgr_t* qse_pio_getcmgr (qse_pio_t* pio, qse_pio_hid_t hid)
{ {
return pio->pin[hid].tio? 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); 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; 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; 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; 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; return pio->child;
} }

View File

@ -248,7 +248,7 @@ void qse_rbt_fini (rbt_t* rbt)
qse_rbt_clear (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; return rbt->mancbs;
} }
@ -259,12 +259,12 @@ void qse_rbt_setmancbs (rbt_t* rbt, const mancbs_t* mancbs)
rbt->mancbs = mancbs; rbt->mancbs = mancbs;
} }
size_t qse_rbt_getsize (rbt_t* rbt) size_t qse_rbt_getsize (const rbt_t* rbt)
{ {
return rbt->size; 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; 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 ( int qse_rbt_dflcomp (
qse_rbt_t* rbt, const qse_rbt_t* rbt,
const void* kptr1, size_t klen1, const void* kptr1, size_t klen1,
const void* kptr2, size_t klen2) const void* kptr2, size_t klen2)
{ {

View File

@ -200,7 +200,7 @@ qse_rex_node_t* qse_rex_yield (qse_rex_t* rex)
return code; return code;
} }
int qse_rex_getoption (qse_rex_t* rex) int qse_rex_getoption (const qse_rex_t* rex)
{ {
return rex->option; return rex->option;
} }
@ -210,12 +210,12 @@ void qse_rex_setoption (qse_rex_t* rex, int opts)
rex->option = 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; 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[] = static const qse_char_t* errstr[] =
{ {

View File

@ -31,6 +31,14 @@
# include "syscall.h" # include "syscall.h"
#endif #endif
/* internal status codes */
enum
{
STATUS_UTF8_CONSOLE = (1 << 0)
};
static qse_ssize_t file_input ( static qse_ssize_t file_input (
qse_tio_t* tio, qse_tio_cmd_t cmd, void* buf, qse_size_t size); qse_tio_t* tio, qse_tio_cmd_t cmd, void* buf, qse_size_t size);
static qse_ssize_t file_output ( static qse_ssize_t file_output (
@ -113,14 +121,19 @@ qse_sio_t* qse_sio_openstd (
qse_fio_hnd_t hnd; qse_fio_hnd_t hnd;
if (qse_getstdfiohandle (std, &hnd) <= -1) return QSE_NULL; if (qse_getstdfiohandle (std, &hnd) <= -1) return QSE_NULL;
sio = qse_sio_open (mmgr, xtnsize, sio = qse_sio_open (mmgr, xtnsize,
(const qse_char_t*)&hnd, flags | QSE_SIO_HANDLE | QSE_SIO_NOCLOSE); (const qse_char_t*)&hnd, flags | QSE_SIO_HANDLE | QSE_SIO_NOCLOSE);
#if defined(_WIN32) #if defined(_WIN32)
if (sio) if (sio)
{ {
QSE_ASSERT (std >= 0 && std < QSE_TYPE_MAX(int)); DWORD mode;
sio->status = std + 1; if (GetConsoleMode (sio->u.file.handle, &mode) == TRUE &&
GetConsoleOutputCP() == CP_UTF8)
{
sio->status |= STATUS_UTF8_CONSOLE;
}
} }
#endif #endif
@ -190,14 +203,19 @@ int qse_sio_initstd (
qse_fio_hnd_t hnd; qse_fio_hnd_t hnd;
if (qse_getstdfiohandle (std, &hnd) <= -1) return -1; if (qse_getstdfiohandle (std, &hnd) <= -1) return -1;
n = qse_sio_init (sio, mmgr, n = qse_sio_init (sio, mmgr,
(const qse_char_t*)&hnd, flags | QSE_SIO_HANDLE | QSE_SIO_NOCLOSE); (const qse_char_t*)&hnd, flags | QSE_SIO_HANDLE | QSE_SIO_NOCLOSE);
#if defined(_WIN32) #if defined(_WIN32)
if (n >= 0) if (n >= 0)
{ {
QSE_ASSERT (std >= 0 && std < QSE_TYPE_MAX(int)); DWORD mode;
sio->status = std + 1; if (GetConsoleMode (sio->u.file.handle, &mode) == TRUE &&
GetConsoleOutputCP() == CP_UTF8)
{
sio->status |= STATUS_UTF8_CONSOLE;
}
} }
#endif #endif
@ -212,6 +230,11 @@ void qse_sio_fini (qse_sio_t* sio)
qse_fio_fini (&sio->u.file); 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) qse_cmgr_t* qse_sio_getcmgr (qse_sio_t* sio)
{ {
return qse_tio_getcmgr (&sio->tio.io); 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_tio_setcmgr (&sio->tio.io, cmgr);
} }
qse_sio_errnum_t qse_sio_geterrnum (qse_sio_t* sio) qse_sio_hnd_t qse_sio_gethandle (const qse_sio_t* sio)
{
return sio->errnum;
}
qse_sio_hnd_t qse_sio_gethandle (qse_sio_t* sio)
{ {
/*return qse_fio_gethandle (&sio->u.file);*/ /*return qse_fio_gethandle (&sio->u.file);*/
return QSE_FIO_HANDLE(&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); 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) #if defined(_WIN32)
/* Using WriteConsoleA() didn't help at all. /* Using WriteConsoleA() didn't help at all.
* so I don't implement any hack here */ * so I don't implement any hacks here */
#endif #endif
sio->errnum = QSE_SIO_ENOERR; sio->errnum = QSE_SIO_ENOERR;
@ -408,7 +426,7 @@ qse_ssize_t qse_sio_putmbsn (
#if defined(_WIN32) #if defined(_WIN32)
/* Using WriteConsoleA() didn't help at all. /* Using WriteConsoleA() didn't help at all.
* so I don't implement any hack here */ * so I don't implement any hacks here */
#endif #endif
sio->errnum = QSE_SIO_ENOERR; sio->errnum = QSE_SIO_ENOERR;
@ -425,12 +443,7 @@ qse_ssize_t qse_sio_putwcs (qse_sio_t* sio, const qse_wchar_t* str)
#if defined(_WIN32) #if defined(_WIN32)
/* DAMN UGLY: See comment in qse_sio_putwcsn() */ /* DAMN UGLY: See comment in qse_sio_putwcsn() */
if (sio->status) if (sio->status & STATUS_UTF8_CONSOLE)
{
DWORD mode;
if (GetConsoleMode (sio->u.file.handle, &mode) == TRUE &&
GetConsoleOutputCP() == CP_UTF8)
{ {
DWORD count, left; DWORD count, left;
const qse_wchar_t* cur; const qse_wchar_t* cur;
@ -456,7 +469,6 @@ qse_ssize_t qse_sio_putwcs (qse_sio_t* sio, const qse_wchar_t* str)
} }
return cur - str; return cur - str;
} }
}
#endif #endif
sio->errnum = QSE_SIO_ENOERR; sio->errnum = QSE_SIO_ENOERR;
@ -484,12 +496,7 @@ qse_ssize_t qse_sio_putwcsn (
* Note that the multibyte functions qse_sio_putmbs() and * Note that the multibyte functions qse_sio_putmbs() and
* qse_sio_putmbsn() doesn't handle this. So you may still suffer. * qse_sio_putmbsn() doesn't handle this. So you may still suffer.
*/ */
if (sio->status) if (sio->status & STATUS_UTF8_CONSOLE)
{
DWORD mode;
if (GetConsoleMode (sio->u.file.handle, &mode) == TRUE &&
GetConsoleOutputCP() == CP_UTF8)
{ {
DWORD count, left; DWORD count, left;
const qse_wchar_t* cur; const qse_wchar_t* cur;
@ -523,7 +530,6 @@ qse_ssize_t qse_sio_putwcsn (
} }
return cur - str; return cur - str;
} }
}
#endif #endif

View File

@ -87,7 +87,7 @@ int qse_tio_fini (qse_tio_t* tio)
return ret; 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; return tio->errnum;
} }

View File

@ -239,7 +239,7 @@ const Sed::char_t* Sed::getErrorString (errnum_t num) const
return dflerrstr (sed, num); 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); Sed* sed = *(Sed**)QSE_XTN(s);
try try

View File

@ -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"); 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; return sed->errstr;
} }
@ -75,24 +75,24 @@ void qse_sed_seterrstr (qse_sed_t* sed, qse_sed_errstr_t errstr)
sed->errstr = 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; 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; 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'))? return (sed->errmsg[0] == QSE_T('\0'))?
qse_sed_geterrstr(sed)(sed,sed->errnum): sed->errmsg; qse_sed_geterrstr(sed)(sed,sed->errnum): sed->errmsg;
} }
void qse_sed_geterror ( 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) const qse_char_t** errmsg, qse_sed_loc_t* errloc)
{ {
if (errnum != QSE_NULL) *errnum = sed->errnum; if (errnum != QSE_NULL) *errnum = sed->errnum;

View File

@ -137,13 +137,13 @@ void qse_sed_setoption (qse_sed_t* sed, int option)
sed->option = option; sed->option = option;
} }
int qse_sed_getoption (qse_sed_t* sed) int qse_sed_getoption (const qse_sed_t* sed)
{ {
return sed->option; return sed->option;
} }
#if defined(USE_REX) #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: return (id & QSE_SED_DEPTH_REX_BUILD)? sed->depth.rex.build:
(id & QSE_SED_DEPTH_REX_MATCH)? sed->depth.rex.match: 0; (id & QSE_SED_DEPTH_REX_MATCH)? sed->depth.rex.match: 0;

View File

@ -243,7 +243,7 @@ const qse_char_t* qse_sed_dflerrstr (
* The qse_sed_getmaxdepth() gets the maximum processing depth. * The qse_sed_getmaxdepth() gets the maximum processing depth.
*/ */
qse_size_t qse_sed_getmaxdepth ( qse_size_t qse_sed_getmaxdepth (
qse_sed_t* sed, /**< stream editor */ const qse_sed_t* sed, /**< stream editor */
qse_sed_depth_t id /**< one of qse_sed_depth_t values */ qse_sed_depth_t id /**< one of qse_sed_depth_t values */
); );

View File

@ -208,6 +208,10 @@ static void close_main_stream (
* i close this in qse_awk_execstd() * i close this in qse_awk_execstd()
*/ */
break; 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]; qse_sed_iostd_t in[2];
in[0].type = QSE_SED_IOSTD_STR; 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[0].u.str.len = qse_strlen(script);
in[1].type = QSE_SED_IOSTD_NULL; in[1].type = QSE_SED_IOSTD_NULL;