fixed wrong declarations of qse_awk_rtx_valtowcsdupwithcmgr() and qse_awk_rtx_valtombsdupwithcmgr() which caused segfault when the returned pointer is greater than UINT_MAX

This commit is contained in:
hyung-hwan 2019-06-30 09:26:33 +00:00
parent 88d5820dbb
commit 8d98111202
4 changed files with 224 additions and 283 deletions

View File

@ -287,8 +287,7 @@ struct qse_awk_val_ref_t
QSE_AWK_VAL_REF_GBLIDX, /**< member of global map variable */
QSE_AWK_VAL_REF_LCLIDX, /**< member of local map variable */
QSE_AWK_VAL_REF_ARGIDX, /**< member of map argument */
QSE_AWK_VAL_REF_POS, /**< positional variable */
/*QSE_AWK_VAL_REF_ADDR*/ /**< arbitrary address to a value. the value pointer that resides outside the awk realm. */
QSE_AWK_VAL_REF_POS /**< positional variable */
} id;
/* if id is QSE_AWK_VAL_REF_POS, adr holds the index of a
@ -2833,39 +2832,32 @@ QSE_EXPORT int qse_awk_rtx_valtostr (
);
/**
* The qse_awk_rtx_valtostrdup() function provides a shortcut to the
* qse_awk_rtx_valtostr() function with the #QSE_AWK_RTX_VALTOSTR_CPLDUP type.
* It returns the pointer to a string converted from \a val and stores its
* length to memory pointed to by \a len. You should free the returned
* memory block after use. See the code snippet below for a simple usage.
* The qse_awk_rtx_valtostrdupwithcmgr() function duplicates a string value and returns
* the pointer to it. If the given value is not a string, it converts the non-string
* value to a string and duplicates it. It stores the length of the resulting
* string in memory pointed to by \a len.
* You should free the returned memory block after use. See the code snippet below
* for a simple usage.
*
* \code
* ptr = qse_awk_rtx_valtostrdup (rtx, v, &len);
* if (str == QSE_NULL) handle_error();
* qse_printf (QSE_T("%.*s\n"), (int)len, ptr);
* ptr = qse_awk_rtx_valtowcsdupwithcmgr(rtx, v, &len, qse_awk_rtx_getcmgr(rtx));
* if (!str) handle_error();
* qse_printf (QSE_T("%.*ls\n"), (int)len, ptr);
* qse_awk_rtx_free (rtx, ptr);
* \endcode
*
* \return character pointer to a string converted on success,
* \return character pointer to a duplicated string on success,
* #QSE_NULL on failure
*/
#if 0
QSE_EXPORT qse_char_t* qse_awk_rtx_valtostrdupwithcmgr (
qse_awk_rtx_t* rtx, /**< runtime context */
const qse_awk_val_t* val, /**< value to convert */
qse_size_t* len, /**< result length */
qse_cmgr_t* cmgr
);
#endif
QSE_EXPORT qse_mchar_t* qse_awk_rtx_valtombsdup (
QSE_EXPORT qse_mchar_t* qse_awk_rtx_valtombsdupwithcmgr (
qse_awk_rtx_t* rtx, /**< runtime context */
const qse_awk_val_t* val, /**< value to convert */
qse_size_t* len, /**< result length */
qse_cmgr_t* cmgr
);
QSE_EXPORT qse_wchar_t* qse_awk_rtx_valtowcsdup (
QSE_EXPORT qse_wchar_t* qse_awk_rtx_valtowcsdupwithcmgr (
qse_awk_rtx_t* rtx, /**< runtime context */
const qse_awk_val_t* val, /**< value to convert */
qse_size_t* len, /**< result length */

View File

@ -94,10 +94,10 @@ static int out_mask_map[] =
};
static int find_rio_in (
qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
qse_awk_rtx_t* rtx, int in_type, const qse_char_t* name,
qse_awk_rio_arg_t** rio, qse_awk_rio_impl_t* fun)
{
qse_awk_rio_arg_t* p = run->rio.chain;
qse_awk_rio_arg_t* p = rtx->rio.chain;
qse_awk_rio_impl_t handler;
int io_type, io_mode, io_mask;
@ -111,11 +111,11 @@ static int find_rio_in (
io_mask = in_mask_map[in_type];
/* get the I/O handler provided by a user */
handler = run->rio.handler[io_type];
handler = rtx->rio.handler[io_type];
if (handler == QSE_NULL)
{
/* no I/O handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
@ -133,21 +133,20 @@ static int find_rio_in (
/* if the name doesn't exist in the chain, create an entry
* to the chain */
p = (qse_awk_rio_arg_t*) QSE_AWK_ALLOC (
run->awk, QSE_SIZEOF(qse_awk_rio_arg_t));
p = (qse_awk_rio_arg_t*)qse_awk_rtx_allocmem(rtx, QSE_SIZEOF(qse_awk_rio_arg_t));
if (p == QSE_NULL)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
QSE_MEMSET (p, 0, QSE_SIZEOF(*p));
p->name = QSE_AWK_STRDUP (run->awk, name);
p->name = QSE_AWK_STRDUP (rtx->awk, name);
if (p->name == QSE_NULL)
{
QSE_AWK_FREE (run->awk, p);
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
qse_awk_rtx_freemem (rtx, p);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -166,28 +165,28 @@ static int find_rio_in (
p->in.eos = 0;
*/
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOERR, QSE_NULL);
/* request to open the stream */
x = handler (run, QSE_AWK_RIO_OPEN, p, QSE_NULL, 0);
x = handler (rtx, QSE_AWK_RIO_OPEN, p, QSE_NULL, 0);
if (x <= -1)
{
QSE_AWK_FREE (run->awk, p->name);
QSE_AWK_FREE (run->awk, p);
qse_awk_rtx_freemem (rtx, p->name);
qse_awk_rtx_freemem (rtx, p);
if (run->errinf.num == QSE_AWK_ENOERR)
if (rtx->errinf.num == QSE_AWK_ENOERR)
{
/* if the error number has not been
* set by the user handler */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOIMPL, QSE_NULL);
}
return -1;
}
/* chain it */
p->next = run->rio.chain;
run->rio.chain = p;
p->next = rtx->rio.chain;
rtx->rio.chain = p;
}
*rio = p;
@ -293,7 +292,7 @@ static QSE_INLINE int match_long_rs (qse_awk_rtx_t* run, qse_str_t* buf, qse_awk
return ret;
}
int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name, qse_str_t* buf)
int qse_awk_rtx_readio (qse_awk_rtx_t* rtx, int in_type, const qse_char_t* name, qse_str_t* buf)
{
qse_awk_rio_arg_t* p;
qse_awk_rio_impl_t handler;
@ -305,19 +304,19 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
qse_size_t line_len = 0;
qse_char_t c = QSE_T('\0'), pc;
if (find_rio_in (run, in_type, name, &p, &handler) <= -1) return -1;
if (find_rio_in(rtx, in_type, name, &p, &handler) <= -1) return -1;
if (p->in.eos) return 0; /* no more streams left */
/* ready to read a record(typically a line). clear the buffer. */
qse_str_clear (buf);
/* get the record separator */
rs = qse_awk_rtx_getgbl (run, QSE_AWK_GBL_RS);
qse_awk_rtx_refupval (run, rs);
rs = qse_awk_rtx_getgbl(rtx, QSE_AWK_GBL_RS);
qse_awk_rtx_refupval (rtx, rs);
if (resolve_rs (run, rs, &rrs) <= -1)
if (resolve_rs(rtx, rs, &rrs) <= -1)
{
qse_awk_rtx_refdownval (run, rs);
qse_awk_rtx_refdownval (rtx, rs);
return -1;
}
@ -344,18 +343,16 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
break;
}
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
x = handler (run, QSE_AWK_RIO_READ,
p, p->in.buf, QSE_COUNTOF(p->in.buf));
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOERR, QSE_NULL);
x = handler(rtx, QSE_AWK_RIO_READ, p, p->in.buf, QSE_COUNTOF(p->in.buf));
if (x <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
if (rtx->errinf.num == QSE_AWK_ENOERR)
{
/* if the error number has not been
* set by the user handler, we set
* it here to QSE_AWK_EIOIMPL. */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOIMPL, QSE_NULL);
}
ret = -1;
@ -381,12 +378,10 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
if (QSE_STR_LASTCHAR(buf) == QSE_T('\n'))
{
QSE_STR_LEN(buf) -= 1;
if (run->awk->opt.trait & QSE_AWK_CRLF)
if (rtx->awk->opt.trait & QSE_AWK_CRLF)
{
/* drop preceding CR */
if (QSE_STR_LEN(buf) > 0 &&
QSE_STR_LASTCHAR(buf) == QSE_T('\r'))
QSE_STR_LEN(buf) -= 1;
if (QSE_STR_LEN(buf) > 0 && QSE_STR_LASTCHAR(buf) == QSE_T('\r')) QSE_STR_LEN(buf) -= 1;
}
}
}
@ -400,7 +395,7 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
* At EOF, the match at the end is considered
* the longest as there are no more characters
* left */
int n = match_long_rs (run, buf, p);
int n = match_long_rs(rtx, buf, p);
if (n != 0)
{
if (n <= -1) ret = -1;
@ -456,14 +451,10 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
}
while (p->in.pos < p->in.len);
tmp = qse_str_ncat (
buf,
&p->in.buf[start_pos],
end_pos - start_pos
);
tmp = qse_str_ncat(buf, &p->in.buf[start_pos], end_pos - start_pos);
if (tmp == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
ret = -1;
break;
}
@ -483,8 +474,7 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
/* separate by a blank line */
if (c == QSE_T('\n'))
{
if (pc == QSE_T('\r') &&
QSE_STR_LEN(buf) > 0)
if (pc == QSE_T('\r') && QSE_STR_LEN(buf) > 0)
{
/* shrink the line length and the record
* by dropping of CR before NL */
@ -493,7 +483,7 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
/* we don't drop CR from the record buffer
* if we're in CRLF mode. POINT-X */
if (!(run->awk->opt.trait & QSE_AWK_CRLF))
if (!(rtx->awk->opt.trait & QSE_AWK_CRLF))
QSE_STR_LEN(buf) -= 1;
}
@ -501,10 +491,9 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
{
/* we got a blank line */
if (run->awk->opt.trait & QSE_AWK_CRLF)
if (rtx->awk->opt.trait & QSE_AWK_CRLF)
{
if (QSE_STR_LEN(buf) > 0 &&
QSE_STR_LASTCHAR(buf) == QSE_T('\r'))
if (QSE_STR_LEN(buf) > 0 && QSE_STR_LASTCHAR(buf) == QSE_T('\r'))
{
/* drop CR not dropped in POINT-X above */
QSE_STR_LEN(buf) -= 1;
@ -523,9 +512,7 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
QSE_STR_LEN(buf) -= 1;
/* drop preceding CR */
if (QSE_STR_LEN(buf) > 0 &&
QSE_STR_LASTCHAR(buf) == QSE_T('\r'))
QSE_STR_LEN(buf) -= 1;
if (QSE_STR_LEN(buf) > 0 && QSE_STR_LASTCHAR(buf) == QSE_T('\r')) QSE_STR_LEN(buf) -= 1;
}
else
{
@ -552,7 +539,7 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
if (qse_str_ccat(buf, c) == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
ret = -1;
done = 1;
break;
@ -579,14 +566,10 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
}
while (p->in.pos < p->in.len);
tmp = qse_str_ncat (
buf,
&p->in.buf[start_pos],
end_pos - start_pos
);
tmp = qse_str_ncat(buf, &p->in.buf[start_pos], end_pos - start_pos);
if (tmp == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
ret = -1;
break;
}
@ -606,21 +589,17 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
* to the buffer, it is the longest match.
*/
tmp = qse_str_ncat (
buf,
&p->in.buf[p->in.pos],
p->in.len - p->in.pos
);
tmp = qse_str_ncat(buf, &p->in.buf[p->in.pos], p->in.len - p->in.pos);
if (tmp == (qse_size_t)-1)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOMEM, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
ret = -1;
break;
}
p->in.pos = p->in.len;
n = match_long_rs (run, buf, p);
n = match_long_rs(rtx, buf, p);
if (n != 0)
{
if (n <= -1) ret = -1;
@ -629,25 +608,24 @@ int qse_awk_rtx_readio (qse_awk_rtx_t* run, int in_type, const qse_char_t* name,
}
}
if (rrs.ptr && QSE_AWK_RTX_GETVALTYPE (rtx, rs) != QSE_AWK_VAL_STR)
QSE_AWK_FREE (run->awk, rrs.ptr);
qse_awk_rtx_refdownval (run, rs);
if (rrs.ptr && QSE_AWK_RTX_GETVALTYPE (rtx, rs) != QSE_AWK_VAL_STR) qse_awk_rtx_freemem (rtx, rrs.ptr);
qse_awk_rtx_refdownval (rtx, rs);
return ret;
}
int qse_awk_rtx_writeioval (qse_awk_rtx_t* run, int out_type, const qse_char_t* name, qse_awk_val_t* v)
int qse_awk_rtx_writeioval (qse_awk_rtx_t* rtx, int out_type, const qse_char_t* name, qse_awk_val_t* v)
{
qse_awk_val_type_t vtype;
vtype = QSE_AWK_RTX_GETVALTYPE (run, v);
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, v);
switch (vtype)
{
case QSE_AWK_VAL_STR:
return qse_awk_rtx_writeiostr(run, out_type, name, ((qse_awk_val_str_t*)v)->val.ptr, ((qse_awk_val_str_t*)v)->val.len);
return qse_awk_rtx_writeiostr(rtx, out_type, name, ((qse_awk_val_str_t*)v)->val.ptr, ((qse_awk_val_str_t*)v)->val.len);
case QSE_AWK_VAL_MBS:
return qse_awk_rtx_writeiobytes(run, out_type, name, ((qse_awk_val_mbs_t*)v)->val.ptr, ((qse_awk_val_mbs_t*)v)->val.len);
return qse_awk_rtx_writeiobytes(rtx, out_type, name, ((qse_awk_val_mbs_t*)v)->val.ptr, ((qse_awk_val_mbs_t*)v)->val.len);
default:
{
@ -655,9 +633,9 @@ int qse_awk_rtx_writeioval (qse_awk_rtx_t* run, int out_type, const qse_char_t*
int n;
out.type = QSE_AWK_RTX_VALTOSTR_CPLDUP | QSE_AWK_RTX_VALTOSTR_PRINT;
if (qse_awk_rtx_valtostr(run, v, &out) <= -1) return -1;
n = qse_awk_rtx_writeiostr(run, out_type, name, out.u.cpldup.ptr, out.u.cpldup.len);
QSE_AWK_FREE (run->awk, out.u.cpldup.ptr);
if (qse_awk_rtx_valtostr(rtx, v, &out) <= -1) return -1;
n = qse_awk_rtx_writeiostr(rtx, out_type, name, out.u.cpldup.ptr, out.u.cpldup.len);
qse_awk_rtx_freemem (rtx, out.u.cpldup.ptr);
return n;
}
}
@ -713,7 +691,7 @@ static int prepare_for_write_io_data (qse_awk_rtx_t* rtx, int out_type, const qs
/* if there is not corresponding rio for name, create one */
if (p == QSE_NULL)
{
p = (qse_awk_rio_arg_t*)QSE_AWK_ALLOC(rtx->awk, QSE_SIZEOF(qse_awk_rio_arg_t));
p = (qse_awk_rio_arg_t*)qse_awk_rtx_allocmem(rtx, QSE_SIZEOF(qse_awk_rio_arg_t));
if (p == QSE_NULL)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
@ -725,7 +703,7 @@ static int prepare_for_write_io_data (qse_awk_rtx_t* rtx, int out_type, const qs
p->name = QSE_AWK_STRDUP(rtx->awk, name);
if (p->name == QSE_NULL)
{
QSE_AWK_FREE (rtx->awk, p);
qse_awk_rtx_freemem (rtx, p);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOMEM, QSE_NULL);
return -1;
}
@ -746,8 +724,8 @@ static int prepare_for_write_io_data (qse_awk_rtx_t* rtx, int out_type, const qs
n = handler(rtx, QSE_AWK_RIO_OPEN, p, QSE_NULL, 0);
if (n <= -1)
{
QSE_AWK_FREE (rtx->awk, p->name);
QSE_AWK_FREE (rtx->awk, p);
qse_awk_rtx_freemem (rtx, p->name);
qse_awk_rtx_freemem (rtx, p);
if (rtx->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOIMPL, QSE_NULL);
@ -834,9 +812,9 @@ int qse_awk_rtx_writeiobytes (qse_awk_rtx_t* rtx, int out_type, const qse_char_t
return 1;
}
int qse_awk_rtx_flushio (qse_awk_rtx_t* run, int out_type, const qse_char_t* name)
int qse_awk_rtx_flushio (qse_awk_rtx_t* rtx, int out_type, const qse_char_t* name)
{
qse_awk_rio_arg_t* p = run->rio.chain;
qse_awk_rio_arg_t* p = rtx->rio.chain;
qse_awk_rio_impl_t handler;
int io_type, io_mode, io_mask;
qse_ssize_t n;
@ -851,11 +829,11 @@ int qse_awk_rtx_flushio (qse_awk_rtx_t* run, int out_type, const qse_char_t* nam
io_mode = out_mode_map[out_type];
io_mask = out_mask_map[out_type];
handler = run->rio.handler[io_type];
if (handler == QSE_NULL)
handler = rtx->rio.handler[io_type];
if (!handler)
{
/* no I/O handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
@ -869,13 +847,12 @@ int qse_awk_rtx_flushio (qse_awk_rtx_t* run, int out_type, const qse_char_t* nam
if (p->type == (io_type | io_mask) && p->mode == io_mode &&
(name == QSE_NULL || qse_strcmp(p->name,name) == 0))
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
n = handler(run, QSE_AWK_RIO_FLUSH, p, QSE_NULL, 0);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOERR, QSE_NULL);
n = handler(rtx, QSE_AWK_RIO_FLUSH, p, QSE_NULL, 0);
if (n <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
if (rtx->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
@ -888,14 +865,13 @@ int qse_awk_rtx_flushio (qse_awk_rtx_t* run, int out_type, const qse_char_t* nam
if (ok) return 0;
/* there is no corresponding rio for name */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIONMNF, QSE_NULL);
return -1;
}
int qse_awk_rtx_nextio_read (
qse_awk_rtx_t* run, int in_type, const qse_char_t* name)
int qse_awk_rtx_nextio_read (qse_awk_rtx_t* rtx, int in_type, const qse_char_t* name)
{
qse_awk_rio_arg_t* p = run->rio.chain;
qse_awk_rio_arg_t* p = rtx->rio.chain;
qse_awk_rio_impl_t handler;
int io_type, /*io_mode,*/ io_mask;
qse_ssize_t n;
@ -909,27 +885,25 @@ int qse_awk_rtx_nextio_read (
/*io_mode = in_mode_map[in_type];*/
io_mask = in_mask_map[in_type];
handler = run->rio.handler[io_type];
if (handler == QSE_NULL)
handler = rtx->rio.handler[io_type];
if (!handler)
{
/* no I/O handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
while (p != QSE_NULL)
while (p)
{
if (p->type == (io_type | io_mask) &&
qse_strcmp (p->name,name) == 0) break;
if (p->type == (io_type | io_mask) && qse_strcmp(p->name,name) == 0) break;
p = p->next;
}
if (p == QSE_NULL)
if (!p)
{
/* something is totally wrong */
QSE_ASSERT (
!"should never happen - cannot find the relevant rio entry");
qse_awk_rtx_seterrnum (run, QSE_AWK_EINTERN, QSE_NULL);
QSE_ASSERT (!"should never happen - cannot find the relevant rio entry");
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINTERN, QSE_NULL);
return -1;
}
@ -939,12 +913,12 @@ int qse_awk_rtx_nextio_read (
return 0;
}
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
n = handler (run, QSE_AWK_RIO_NEXT, p, QSE_NULL, 0);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOERR, QSE_NULL);
n = handler(rtx, QSE_AWK_RIO_NEXT, p, QSE_NULL, 0);
if (n <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
if (rtx->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
@ -970,10 +944,9 @@ int qse_awk_rtx_nextio_read (
}
}
int qse_awk_rtx_nextio_write (
qse_awk_rtx_t* run, int out_type, const qse_char_t* name)
int qse_awk_rtx_nextio_write (qse_awk_rtx_t* rtx, int out_type, const qse_char_t* name)
{
qse_awk_rio_arg_t* p = run->rio.chain;
qse_awk_rio_arg_t* p = rtx->rio.chain;
qse_awk_rio_impl_t handler;
int io_type, /*io_mode,*/ io_mask;
qse_ssize_t n;
@ -987,27 +960,26 @@ int qse_awk_rtx_nextio_write (
/*io_mode = out_mode_map[out_type];*/
io_mask = out_mask_map[out_type];
handler = run->rio.handler[io_type];
if (handler == QSE_NULL)
handler = rtx->rio.handler[io_type];
if (!handler)
{
/* no I/O handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
while (p != QSE_NULL)
while (p)
{
if (p->type == (io_type | io_mask) &&
qse_strcmp (p->name,name) == 0) break;
if (p->type == (io_type | io_mask) && qse_strcmp(p->name,name) == 0) break;
p = p->next;
}
if (p == QSE_NULL)
if (!p)
{
/* something is totally wrong */
QSE_ASSERT (!"should never happen - cannot find the relevant rio entry");
qse_awk_rtx_seterrnum (run, QSE_AWK_EINTERN, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EINTERN, QSE_NULL);
return -1;
}
@ -1017,12 +989,12 @@ int qse_awk_rtx_nextio_write (
return 0;
}
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
n = handler (run, QSE_AWK_RIO_NEXT, p, QSE_NULL, 0);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOERR, QSE_NULL);
n = handler(rtx, QSE_AWK_RIO_NEXT, p, QSE_NULL, 0);
if (n <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
if (rtx->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
@ -1043,10 +1015,9 @@ int qse_awk_rtx_nextio_write (
}
}
int qse_awk_rtx_closio_read (
qse_awk_rtx_t* run, int in_type, const qse_char_t* name)
int qse_awk_rtx_closio_read (qse_awk_rtx_t* rtx, int in_type, const qse_char_t* name)
{
qse_awk_rio_arg_t* p = run->rio.chain, * px = QSE_NULL;
qse_awk_rio_arg_t* p = rtx->rio.chain, * px = QSE_NULL;
qse_awk_rio_impl_t handler;
int io_type, /*io_mode,*/ io_mask;
@ -1059,37 +1030,36 @@ int qse_awk_rtx_closio_read (
/*io_mode = in_mode_map[in_type];*/
io_mask = in_mask_map[in_type];
handler = run->rio.handler[io_type];
if (handler == QSE_NULL)
handler = rtx->rio.handler[io_type];
if (!handler)
{
/* no I/O handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
while (p != QSE_NULL)
while (p)
{
if (p->type == (io_type | io_mask) &&
qse_strcmp (p->name, name) == 0)
if (p->type == (io_type | io_mask) && qse_strcmp(p->name, name) == 0)
{
qse_awk_rio_impl_t handler;
handler = run->rio.handler[p->type & IO_MASK_CLEAR];
if (handler != QSE_NULL)
handler = rtx->rio.handler[p->type & IO_MASK_CLEAR];
if (handler)
{
if (handler (run, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
if (handler (rtx, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
{
/* this is not a run-time error.*/
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
/* this is not a rtx-time error.*/
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
}
if (px != QSE_NULL) px->next = p->next;
else run->rio.chain = p->next;
if (px) px->next = p->next;
else rtx->rio.chain = p->next;
QSE_AWK_FREE (run->awk, p->name);
QSE_AWK_FREE (run->awk, p);
qse_awk_rtx_freemem (rtx, p->name);
qse_awk_rtx_freemem (rtx, p);
return 0;
}
@ -1098,14 +1068,13 @@ int qse_awk_rtx_closio_read (
}
/* the name given is not found */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIONMNF, QSE_NULL);
return -1;
}
int qse_awk_rtx_closio_write (
qse_awk_rtx_t* run, int out_type, const qse_char_t* name)
int qse_awk_rtx_closio_write (qse_awk_rtx_t* rtx, int out_type, const qse_char_t* name)
{
qse_awk_rio_arg_t* p = run->rio.chain, * px = QSE_NULL;
qse_awk_rio_arg_t* p = rtx->rio.chain, * px = QSE_NULL;
qse_awk_rio_impl_t handler;
int io_type, /*io_mode,*/ io_mask;
@ -1118,38 +1087,37 @@ int qse_awk_rtx_closio_write (
/*io_mode = out_mode_map[out_type];*/
io_mask = out_mask_map[out_type];
handler = run->rio.handler[io_type];
if (handler == QSE_NULL)
handler = rtx->rio.handler[io_type];
if (!handler)
{
/* no io handler provided */
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOUSER, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOUSER, QSE_NULL);
return -1;
}
while (p != QSE_NULL)
while (p)
{
if (p->type == (io_type | io_mask) &&
qse_strcmp (p->name, name) == 0)
if (p->type == (io_type | io_mask) && qse_strcmp(p->name, name) == 0)
{
qse_awk_rio_impl_t handler;
handler = run->rio.handler[p->type & IO_MASK_CLEAR];
if (handler != QSE_NULL)
handler = rtx->rio.handler[p->type & IO_MASK_CLEAR];
if (handler)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
if (handler (run, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOERR, QSE_NULL);
if (handler (rtx, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
if (rtx->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOIMPL, QSE_NULL);
return -1;
}
}
if (px != QSE_NULL) px->next = p->next;
else run->rio.chain = p->next;
if (px) px->next = p->next;
else rtx->rio.chain = p->next;
QSE_AWK_FREE (run->awk, p->name);
QSE_AWK_FREE (run->awk, p);
qse_awk_rtx_freemem (rtx, p->name);
qse_awk_rtx_freemem (rtx, p);
return 0;
}
@ -1157,12 +1125,11 @@ int qse_awk_rtx_closio_write (
p = p->next;
}
qse_awk_rtx_seterrnum (run, QSE_AWK_EIONMNF, QSE_NULL);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIONMNF, QSE_NULL);
return -1;
}
int qse_awk_rtx_closeio (
qse_awk_rtx_t* rtx, const qse_char_t* name, const qse_char_t* opt)
int qse_awk_rtx_closeio (qse_awk_rtx_t* rtx, const qse_char_t* name, const qse_char_t* opt)
{
qse_awk_rio_arg_t* p = rtx->rio.chain, * px = QSE_NULL;
@ -1209,11 +1176,11 @@ int qse_awk_rtx_closeio (
}
handler = rtx->rio.handler[p->type & IO_MASK_CLEAR];
if (handler != QSE_NULL)
if (handler)
{
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOERR, QSE_NULL);
p->rwcmode = rwcmode;
if (handler (rtx, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
if (handler(rtx, QSE_AWK_RIO_CLOSE, p, QSE_NULL, 0) <= -1)
{
/* this is not a run-time error.*/
if (rtx->errinf.num == QSE_AWK_ENOERR)
@ -1239,8 +1206,8 @@ int qse_awk_rtx_closeio (
if (px != QSE_NULL) px->next = p->next;
else rtx->rio.chain = p->next;
QSE_AWK_FREE (rtx->awk, p->name);
QSE_AWK_FREE (rtx->awk, p);
qse_awk_rtx_freemem (rtx, p->name);
qse_awk_rtx_freemem (rtx, p);
return 0;
}
@ -1254,34 +1221,33 @@ int qse_awk_rtx_closeio (
return -1;
}
void qse_awk_rtx_cleario (qse_awk_rtx_t* run)
void qse_awk_rtx_cleario (qse_awk_rtx_t* rtx)
{
qse_awk_rio_arg_t* next;
qse_awk_rio_impl_t handler;
qse_ssize_t n;
while (run->rio.chain != QSE_NULL)
while (rtx->rio.chain)
{
handler = run->rio.handler[
run->rio.chain->type & IO_MASK_CLEAR];
next = run->rio.chain->next;
handler = rtx->rio.handler[rtx->rio.chain->type & IO_MASK_CLEAR];
next = rtx->rio.chain->next;
if (handler != QSE_NULL)
if (handler)
{
qse_awk_rtx_seterrnum (run, QSE_AWK_ENOERR, QSE_NULL);
run->rio.chain->rwcmode = 0;
n = handler (run, QSE_AWK_RIO_CLOSE, run->rio.chain, QSE_NULL, 0);
qse_awk_rtx_seterrnum (rtx, QSE_AWK_ENOERR, QSE_NULL);
rtx->rio.chain->rwcmode = 0;
n = handler(rtx, QSE_AWK_RIO_CLOSE, rtx->rio.chain, QSE_NULL, 0);
if (n <= -1)
{
if (run->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (run, QSE_AWK_EIOIMPL, QSE_NULL);
if (rtx->errinf.num == QSE_AWK_ENOERR)
qse_awk_rtx_seterrnum (rtx, QSE_AWK_EIOIMPL, QSE_NULL);
/* TODO: some warnings need to be shown??? */
}
}
QSE_AWK_FREE (run->awk, run->rio.chain->name);
QSE_AWK_FREE (run->awk, run->rio.chain);
qse_awk_rtx_freemem (rtx, rtx->rio.chain->name);
qse_awk_rtx_freemem (rtx, rtx->rio.chain);
run->rio.chain = next;
rtx->rio.chain = next;
}
}

View File

@ -1647,44 +1647,43 @@ oops:
return ret;
}
static int run_pblocks (qse_awk_rtx_t* run)
static int run_pblocks (qse_awk_rtx_t* rtx)
{
int n;
#define ADJUST_ERROR(run) \
if (run->awk->tree.chain != QSE_NULL) \
if (rtx->awk->tree.chain != QSE_NULL) \
{ \
if (run->awk->tree.chain->pattern != QSE_NULL) \
ADJERR_LOC (run, &run->awk->tree.chain->pattern->loc); \
else if (run->awk->tree.chain->action != QSE_NULL) \
ADJERR_LOC (run, &run->awk->tree.chain->action->loc); \
if (rtx->awk->tree.chain->pattern != QSE_NULL) \
ADJERR_LOC (rtx, &rtx->awk->tree.chain->pattern->loc); \
else if (rtx->awk->tree.chain->action != QSE_NULL) \
ADJERR_LOC (rtx, &rtx->awk->tree.chain->action->loc); \
} \
else if (run->awk->tree.end != QSE_NULL) \
else if (rtx->awk->tree.end != QSE_NULL) \
{ \
ADJERR_LOC (run, &run->awk->tree.end->loc); \
ADJERR_LOC (run, &rtx->awk->tree.end->loc); \
}
run->inrec.buf_pos = 0;
run->inrec.buf_len = 0;
run->inrec.eof = 0;
rtx->inrec.buf_pos = 0;
rtx->inrec.buf_len = 0;
rtx->inrec.eof = 0;
/* run each pattern block */
while (run->exit_level < EXIT_GLOBAL)
while (rtx->exit_level < EXIT_GLOBAL)
{
run->exit_level = EXIT_NONE;
rtx->exit_level = EXIT_NONE;
n = read_record (run);
n = read_record(rtx);
if (n == -1)
{
ADJUST_ERROR (run);
ADJUST_ERROR (rtx);
return -1; /* error */
}
if (n == 0) break; /* end of input */
if (run->awk->tree.chain != QSE_NULL)
if (rtx->awk->tree.chain)
{
if (run_pblock_chain (
run, run->awk->tree.chain) == -1) return -1;
if (run_pblock_chain(rtx, rtx->awk->tree.chain) == -1) return -1;
}
}
@ -1692,21 +1691,21 @@ static int run_pblocks (qse_awk_rtx_t* run)
return 0;
}
static int run_pblock_chain (qse_awk_rtx_t* run, qse_awk_chain_t* cha)
static int run_pblock_chain (qse_awk_rtx_t* rtx, qse_awk_chain_t* chain)
{
qse_size_t bno = 0;
while (run->exit_level < EXIT_GLOBAL && cha != QSE_NULL)
while (rtx->exit_level < EXIT_GLOBAL && chain)
{
if (run->exit_level == EXIT_NEXT)
if (rtx->exit_level == EXIT_NEXT)
{
run->exit_level = EXIT_NONE;
rtx->exit_level = EXIT_NONE;
break;
}
if (run_pblock (run, cha, bno) == -1) return -1;
if (run_pblock(rtx, chain, bno) <= -1) return -1;
cha = cha->next;
chain = chain->next;
bno++;
}
@ -1721,28 +1720,28 @@ static int run_pblock (qse_awk_rtx_t* rtx, qse_awk_chain_t* cha, qse_size_t bno)
ptn = cha->pattern;
blk = (qse_awk_nde_blk_t*)cha->action;
if (ptn == QSE_NULL)
if (!ptn)
{
/* just execute the block */
rtx->active_block = blk;
if (run_block (rtx, blk) == -1) return -1;
if (run_block(rtx, blk) <= -1) return -1;
}
else
{
if (ptn->next == QSE_NULL)
if (!ptn->next)
{
/* pattern { ... } */
qse_awk_val_t* v1;
v1 = eval_expression (rtx, ptn);
if (v1 == QSE_NULL) return -1;
v1 = eval_expression(rtx, ptn);
if (!v1) return -1;
qse_awk_rtx_refupval (rtx, v1);
if (qse_awk_rtx_valtobool(rtx, v1))
{
rtx->active_block = blk;
if (run_block (rtx, blk) == -1)
if (run_block(rtx, blk) <= -1)
{
qse_awk_rtx_refdownval (rtx, v1);
return -1;
@ -1761,14 +1760,14 @@ static int run_pblock (qse_awk_rtx_t* rtx, qse_awk_chain_t* cha, qse_size_t bno)
{
qse_awk_val_t* v1;
v1 = eval_expression (rtx, ptn);
if (v1 == QSE_NULL) return -1;
v1 = eval_expression(rtx, ptn);
if (!v1) return -1;
qse_awk_rtx_refupval (rtx, v1);
if (qse_awk_rtx_valtobool(rtx, v1))
{
rtx->active_block = blk;
if (run_block (rtx, blk) == -1)
if (run_block(rtx, blk) <= -1)
{
qse_awk_rtx_refdownval (rtx, v1);
return -1;
@ -1783,19 +1782,18 @@ static int run_pblock (qse_awk_rtx_t* rtx, qse_awk_chain_t* cha, qse_size_t bno)
{
qse_awk_val_t* v2;
v2 = eval_expression (rtx, ptn->next);
if (v2 == QSE_NULL) return -1;
v2 = eval_expression(rtx, ptn->next);
if (!v2) return -1;
qse_awk_rtx_refupval (rtx, v2);
rtx->active_block = blk;
if (run_block (rtx, blk) == -1)
if (run_block(rtx, blk) <= -1)
{
qse_awk_rtx_refdownval(rtx, v2);
return -1;
}
if (qse_awk_rtx_valtobool (rtx, v2))
rtx->pattern_range_state[bno] = 0;
if (qse_awk_rtx_valtobool(rtx, v2)) rtx->pattern_range_state[bno] = 0;
qse_awk_rtx_refdownval (rtx, v2);
}
@ -4229,7 +4227,7 @@ static QSE_INLINE int __cmp_int_str (qse_awk_rtx_t* rtx, qse_awk_val_t* left, qs
int n;
/* SCO CC doesn't seem to handle right->nstr > 0 properly */
if (rtx->awk->opt.trait & QSE_AWK_NCMPONSTR || right->nstr /*> 0*/)
if ((rtx->awk->opt.trait & QSE_AWK_NCMPONSTR) || right->nstr /*> 0*/)
{
qse_awk_int_t ll, v1;
qse_awk_flt_t rr;
@ -4277,7 +4275,7 @@ static QSE_INLINE int __cmp_int_mbs (qse_awk_rtx_t* rtx, qse_awk_val_t* left, qs
qse_size_t len0;
int n;
if (rtx->awk->opt.trait & QSE_AWK_NCMPONSTR || right->nstr /*> 0*/)
if ((rtx->awk->opt.trait & QSE_AWK_NCMPONSTR) || right->nstr /*> 0*/)
{
qse_awk_int_t ll, v1;
qse_awk_flt_t rr;
@ -6037,7 +6035,7 @@ static qse_awk_val_t* __eval_call (
qse_errputstrf (QSE_T("block rtx complete nargs = %d\n"), (int)nargs);
#endif
if (fun && fun->argspec && call->nargs > 0)
if (fun && fun->argspec && call->args && call->nargs > 0) /* qse_awk_rtx_callfun() sets up a fake call structure with nargs > 0 but args == QSE_NULL */
{
/* set back the values for pass-by-reference parameters of normal functions.
* the intrinsic functions are not handled here but their implementation would
@ -6052,43 +6050,33 @@ static qse_awk_val_t* __eval_call (
qse_size_t cur_stack_base = rtx->stack_base;
qse_size_t prev_stack_base = (qse_size_t)rtx->stack[rtx->stack_base + 0];
if (call->args) /* qse_awk_rtx_callfun() sets up a fake call structure with nargs > 0 but args == QSE_NULL */
qse_awk_nde_t* p = call->args;
for (i = 0; i < call->nargs; i++)
{
qse_awk_nde_t* p = call->args;
for (i = 0; i < call->nargs; i++)
if (fun->argspec[i] == QSE_T('r'))
{
if (fun->argspec[i] == QSE_T('r'))
{
qse_awk_val_t** ref;
qse_awk_val_ref_t refv;
qse_awk_val_t** ref;
qse_awk_val_ref_t refv;
/* if an argument passed is a local variable or a parameter to the previous caller,
* the argument node information stored is relative to the previous stack frame.
* i revert rtx->stack_base to the previous stack frame base before calling
* get_reference() and restors it back to the current base. this tactic
* is very ugly because the assumptions for this is dependent on get_reference()
* implementation */
rtx->stack_base = prev_stack_base; /* UGLY */
get_reference (rtx, p, &ref); /* no failure check as it must succeed here for the check done above */
rtx->stack_base = cur_stack_base; /* UGLY */
/* if an argument passed is a local variable or a parameter to the previous caller,
* the argument node information stored is relative to the previous stack frame.
* i revert rtx->stack_base to the previous stack frame base before calling
* get_reference() and restors it back to the current base. this tactic
* is very ugly because the assumptions for this is dependent on get_reference()
* implementation */
rtx->stack_base = prev_stack_base; /* UGLY */
get_reference (rtx, p, &ref); /* no failure check as it must succeed here for the check done above */
rtx->stack_base = cur_stack_base; /* UGLY */
QSE_AWK_RTX_INIT_REF_VAL (&refv, p->type - QSE_AWK_NDE_NAMED, ref, 9); /* initialize a fake reference variable. 9 chosen randomly */
qse_awk_rtx_setrefval (rtx, &refv, RTX_STACK_ARG(rtx, i));
}
qse_awk_rtx_refdownval (rtx, RTX_STACK_ARG(rtx,i));
p = p->next;
}
}
else
{
for (i = 0; i < call->nargs; i++)
{
qse_awk_rtx_refdownval (rtx, RTX_STACK_ARG(rtx,i));
QSE_AWK_RTX_INIT_REF_VAL (&refv, p->type - QSE_AWK_NDE_NAMED, ref, 9); /* initialize a fake reference variable. 9 chosen randomly */
qse_awk_rtx_setrefval (rtx, &refv, RTX_STACK_ARG(rtx, i));
}
qse_awk_rtx_refdownval (rtx, RTX_STACK_ARG(rtx,i));
p = p->next;
}
for (i = call->nargs; i < nargs; i++)
for (; i < nargs; i++)
{
qse_awk_rtx_refdownval (rtx, RTX_STACK_ARG(rtx,i));
}
@ -6867,8 +6855,8 @@ read_again:
}
}
if (qse_awk_rtx_setrec (rtx, 0, QSE_STR_XSTR(buf)) <= -1 ||
update_fnr (rtx, rtx->gbl.fnr + 1, rtx->gbl.nr + 1) <= -1) return -1;
if (qse_awk_rtx_setrec(rtx, 0, QSE_STR_XSTR(buf)) <= -1 ||
update_fnr(rtx, rtx->gbl.fnr + 1, rtx->gbl.nr + 1) <= -1) return -1;
return 1;
}
@ -8751,8 +8739,7 @@ wp_mod_main:
}
else
{
if (fmt[i] != QSE_MT('%'))
OUT_MBS (QSE_MBS_PTR(fbu), QSE_MBS_LEN(fbu));
if (fmt[i] != QSE_MT('%')) OUT_MBS (QSE_MBS_PTR(fbu), QSE_MBS_LEN(fbu));
OUT_MCHAR (fmt[i]);
goto skip_taking_arg;
}

View File

@ -180,9 +180,7 @@ int qse_wcsxcmp (const qse_wchar_t* s1, qse_size_t ln, const qse_wchar_t* s2)
return (s1 < end)? 1: ((*s2 == QSE_WT('\0'))? 0: -1);
}
int qse_wcsxncmp (
const qse_wchar_t* s1, qse_size_t ln1,
const qse_wchar_t* s2, qse_size_t ln2)
int qse_wcsxncmp (const qse_wchar_t* s1, qse_size_t ln1, const qse_wchar_t* s2, qse_size_t ln2)
{
qse_wchau_t c1, c2;
const qse_wchar_t* end1 = s1 + ln1;
@ -230,9 +228,7 @@ int qse_wcsxcasecmp (const qse_wchar_t* s1, qse_size_t ln, const qse_wchar_t* s2
return (s1 < end)? 1: ((*s2 == QSE_WT('\0'))? 0: -1);
}
int qse_wcsxncasecmp (
const qse_wchar_t* s1, qse_size_t ln1,
const qse_wchar_t* s2, qse_size_t ln2)
int qse_wcsxncasecmp (const qse_wchar_t* s1, qse_size_t ln1, const qse_wchar_t* s2, qse_size_t ln2)
{
qse_wchau_t c1, c2;
const qse_wchar_t* end1 = s1 + ln1;