enhanced win32 utf8 console hack in sio

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

View File

@ -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);

View File

@ -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:

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");
}
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;

View File

@ -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 (

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;
}
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;

View File

@ -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)
{

View File

@ -35,6 +35,9 @@
*/
#include <qse/cmn/ipad.h>
#include <qse/cmn/hton.h>
#include <qse/cmn/str.h>
#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)

View File

@ -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;
}

View File

@ -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)
{

View File

@ -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[] =
{

View File

@ -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

View File

@ -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;
}

View File

@ -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

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");
}
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;

View File

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

View File

@ -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 */
);
/**

View File

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