2007-05-02 01:07:00 +00:00
|
|
|
/*
|
2012-08-16 03:47:55 +00:00
|
|
|
* $Id$
|
2007-05-02 01:07:00 +00:00
|
|
|
*
|
2019-06-06 05:28:23 +00:00
|
|
|
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
2008-12-27 04:35:14 +00:00
|
|
|
|
2014-11-19 14:42:24 +00:00
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
2008-12-27 04:35:14 +00:00
|
|
|
|
2014-11-19 14:42:24 +00:00
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2007-05-02 01:07:00 +00:00
|
|
|
*/
|
|
|
|
|
2016-04-29 03:55:42 +00:00
|
|
|
#include "awk-prv.h"
|
2019-08-28 14:01:28 +00:00
|
|
|
#include <qse/cmn/mbwc.h>
|
2007-05-02 01:07:00 +00:00
|
|
|
|
2019-06-24 14:24:14 +00:00
|
|
|
const qse_char_t* qse_awk_dflerrstr (qse_awk_t* awk, qse_awk_errnum_t errnum)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2008-12-21 21:35:07 +00:00
|
|
|
static const qse_char_t* errstr[] =
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2008-12-21 21:35:07 +00:00
|
|
|
QSE_T("no error"),
|
2012-09-05 10:40:58 +00:00
|
|
|
QSE_T("other error"),
|
2012-06-06 14:41:21 +00:00
|
|
|
QSE_T("not implemented"),
|
2012-09-05 10:40:58 +00:00
|
|
|
QSE_T("subsystem error"),
|
|
|
|
QSE_T("internal error that should never have happened"),
|
2008-12-21 21:35:07 +00:00
|
|
|
|
2009-06-02 03:34:34 +00:00
|
|
|
QSE_T("insufficient memory"),
|
2011-09-18 09:41:26 +00:00
|
|
|
QSE_T("invalid parameter or data"),
|
2012-12-25 14:10:02 +00:00
|
|
|
QSE_T("access denied"),
|
2008-12-21 21:35:07 +00:00
|
|
|
QSE_T("operation not allowed"),
|
2016-12-17 17:38:03 +00:00
|
|
|
QSE_T("not supported"),
|
2009-07-02 07:14:39 +00:00
|
|
|
QSE_T("'${0}' not found"),
|
2009-02-15 03:14:49 +00:00
|
|
|
QSE_T("'${0}' already exists"),
|
2009-07-02 07:14:39 +00:00
|
|
|
QSE_T("I/O error"),
|
2008-12-21 21:35:07 +00:00
|
|
|
|
2009-02-15 03:14:49 +00:00
|
|
|
QSE_T("cannot open '${0}'"),
|
|
|
|
QSE_T("cannot read '${0}'"),
|
|
|
|
QSE_T("cannot write '${0}'"),
|
|
|
|
QSE_T("cannot close '${0}'"),
|
2007-05-02 01:07:00 +00:00
|
|
|
|
2008-12-21 21:35:07 +00:00
|
|
|
QSE_T("block nested too deeply"),
|
2009-07-02 07:14:39 +00:00
|
|
|
QSE_T("expression nested too deeply"),
|
2008-12-21 21:35:07 +00:00
|
|
|
|
2009-02-15 03:14:49 +00:00
|
|
|
QSE_T("invalid character '${0}'"),
|
|
|
|
QSE_T("invalid digit '${0}'"),
|
2008-12-21 21:35:07 +00:00
|
|
|
|
2009-08-20 08:04:15 +00:00
|
|
|
QSE_T("unexpected end of input"),
|
2009-07-02 07:14:39 +00:00
|
|
|
QSE_T("comment not closed properly"),
|
|
|
|
QSE_T("string or regular expression not closed"),
|
2019-04-18 08:42:54 +00:00
|
|
|
QSE_T("invalid mbs character '${0}'"),
|
2009-07-02 07:14:39 +00:00
|
|
|
QSE_T("left brace expected in place of '${0}'"),
|
|
|
|
QSE_T("left parenthesis expected in place of '${0}'"),
|
|
|
|
QSE_T("right parenthesis expected in place of '${0}'"),
|
|
|
|
QSE_T("right bracket expected in place of '${0}'"),
|
|
|
|
QSE_T("comma expected in place of '${0}'"),
|
|
|
|
QSE_T("semicolon expected in place of '${0}'"),
|
|
|
|
QSE_T("colon expected in place of '${0}'"),
|
2019-06-09 05:55:36 +00:00
|
|
|
QSE_T("integer literal expected in place of '${0}'"),
|
2008-12-21 21:35:07 +00:00
|
|
|
QSE_T("statement not ending with a semicolon"),
|
2009-08-01 07:01:04 +00:00
|
|
|
QSE_T("keyword 'in' expected in place of '${0}'"),
|
2009-07-02 07:14:39 +00:00
|
|
|
QSE_T("right-hand side of 'in' not a variable"),
|
2009-08-01 07:01:04 +00:00
|
|
|
QSE_T("expression not recognized around '${0}'"),
|
2008-12-21 21:35:07 +00:00
|
|
|
|
2009-08-01 07:01:04 +00:00
|
|
|
QSE_T("keyword 'function' expected in place of '${0}'"),
|
|
|
|
QSE_T("keyword 'while' expected in place of '${0}'"),
|
2008-12-21 21:35:07 +00:00
|
|
|
QSE_T("invalid assignment statement"),
|
2009-07-02 07:14:39 +00:00
|
|
|
QSE_T("identifier expected in place of '${0}'"),
|
2009-02-15 03:14:49 +00:00
|
|
|
QSE_T("'${0}' not a valid function name"),
|
2009-07-02 07:14:39 +00:00
|
|
|
QSE_T("BEGIN not followed by left bracket on the same line"),
|
|
|
|
QSE_T("END not followed by left bracket on the same line"),
|
2009-06-21 06:47:34 +00:00
|
|
|
QSE_T("keyword '${0}' redefined"),
|
2009-02-15 03:14:49 +00:00
|
|
|
QSE_T("intrinsic function '${0}' redefined"),
|
|
|
|
QSE_T("function '${0}' redefined"),
|
|
|
|
QSE_T("global variable '${0}' redefined"),
|
|
|
|
QSE_T("parameter '${0}' redefined"),
|
|
|
|
QSE_T("variable '${0}' redefined"),
|
|
|
|
QSE_T("duplicate parameter name '${0}'"),
|
|
|
|
QSE_T("duplicate global variable '${0}'"),
|
|
|
|
QSE_T("duplicate local variable '${0}'"),
|
|
|
|
QSE_T("'${0}' not a valid parameter name"),
|
|
|
|
QSE_T("'${0}' not a valid variable name"),
|
2009-06-27 20:50:54 +00:00
|
|
|
QSE_T("variable name missing"),
|
2009-02-15 03:14:49 +00:00
|
|
|
QSE_T("undefined identifier '${0}'"),
|
2008-12-21 21:35:07 +00:00
|
|
|
QSE_T("l-value required"),
|
|
|
|
QSE_T("too many global variables"),
|
|
|
|
QSE_T("too many local variables"),
|
|
|
|
QSE_T("too many parameters"),
|
2013-02-01 14:30:25 +00:00
|
|
|
QSE_T("too many segments"),
|
|
|
|
QSE_T("segment '${0}' too long"),
|
2012-10-20 15:58:20 +00:00
|
|
|
QSE_T("bad argument"),
|
|
|
|
QSE_T("no argument provided"),
|
2009-07-02 07:14:39 +00:00
|
|
|
QSE_T("'break' outside a loop"),
|
|
|
|
QSE_T("'continue' outside a loop"),
|
|
|
|
QSE_T("'next' illegal in the BEGIN block"),
|
|
|
|
QSE_T("'next' illegal in the END block"),
|
|
|
|
QSE_T("'nextfile' illegal in the BEGIN block"),
|
|
|
|
QSE_T("'nextfile' illegal in the END block"),
|
2008-12-21 21:35:07 +00:00
|
|
|
QSE_T("both prefix and postfix increment/decrement operator present"),
|
2009-07-15 02:06:14 +00:00
|
|
|
QSE_T("illegal operand for increment/decrement operator"),
|
2013-02-06 14:31:32 +00:00
|
|
|
QSE_T("'@include' not followed by a string"),
|
2009-07-27 20:31:58 +00:00
|
|
|
QSE_T("include level too deep"),
|
2013-02-18 13:45:50 +00:00
|
|
|
QSE_T("'${0}' not recognized"),
|
2012-11-20 14:44:43 +00:00
|
|
|
QSE_T("@ not followed by a valid word"),
|
2008-12-21 21:35:07 +00:00
|
|
|
|
2019-06-09 05:55:36 +00:00
|
|
|
QSE_T("stack error"),
|
2008-12-21 21:35:07 +00:00
|
|
|
QSE_T("divide by zero"),
|
|
|
|
QSE_T("invalid operand"),
|
|
|
|
QSE_T("wrong position index"),
|
|
|
|
QSE_T("too few arguments"),
|
|
|
|
QSE_T("too many arguments"),
|
2009-02-15 03:14:49 +00:00
|
|
|
QSE_T("function '${0}' not found"),
|
2019-04-29 09:40:13 +00:00
|
|
|
QSE_T("non-function value in '${0}'"),
|
2012-10-25 14:38:27 +00:00
|
|
|
QSE_T("'${0}' not deletable"),
|
2008-12-21 21:35:07 +00:00
|
|
|
QSE_T("value not a map"),
|
|
|
|
QSE_T("right-hand side of the 'in' operator not a map"),
|
|
|
|
QSE_T("right-hand side of the 'in' operator not a map nor nil"),
|
|
|
|
QSE_T("value not referenceable"),
|
2013-04-19 15:06:52 +00:00
|
|
|
QSE_T("cannot return a map"), /* EMAPRET */
|
|
|
|
QSE_T("cannot assign a map to a positional"), /* EMAPTOPOS */
|
|
|
|
QSE_T("cannot assign a map to an indexed variable"),/* EMAPTOIDX */
|
|
|
|
QSE_T("cannot assign a map to a variable '${0}'"), /* EMAPTONVAR */
|
|
|
|
QSE_T("cannot change a map to a scalar"), /* EMAPTOSCALAR */
|
|
|
|
QSE_T("cannot change a scalar to a map"), /* ESCALARTOMAP */
|
|
|
|
QSE_T("cannot change a map '${0}' to another map"),/* ENMAPTOMAP */
|
|
|
|
QSE_T("cannot change a map '${0}' to a scalar"), /* ENMAPTOSCALAR */
|
|
|
|
QSE_T("cannot change a scalar '${0}' to a map"), /* ENSCALARTOMAP */
|
2013-04-16 10:09:24 +00:00
|
|
|
QSE_T("invalid value to convert to a string"),
|
|
|
|
QSE_T("invalid value to convert to a number"),
|
|
|
|
QSE_T("invalid value to a character"),
|
|
|
|
QSE_T("invalid value for hashing"),
|
2009-07-02 07:14:39 +00:00
|
|
|
QSE_T("'next' called from BEGIN block"),
|
|
|
|
QSE_T("'next' called from END block"),
|
|
|
|
QSE_T("'nextfile' called from BEGIN block"),
|
|
|
|
QSE_T("'nextfile' called from END block"),
|
2009-07-16 04:43:31 +00:00
|
|
|
QSE_T("intrinsic function handler for '${0}' failed"),
|
2012-10-20 15:58:20 +00:00
|
|
|
QSE_T("wrong implementation of user-defined I/O handler"),
|
2009-07-02 07:14:39 +00:00
|
|
|
QSE_T("I/O handler returned an error"),
|
|
|
|
QSE_T("no such I/O name found"),
|
|
|
|
QSE_T("I/O name empty"),
|
|
|
|
QSE_T("I/O name '${0}' containing '\\0'"),
|
2008-12-21 21:35:07 +00:00
|
|
|
QSE_T("not sufficient arguments to formatting sequence"),
|
|
|
|
QSE_T("recursion detected in format conversion"),
|
|
|
|
QSE_T("invalid character in CONVFMT"),
|
|
|
|
QSE_T("invalid character in OFMT"),
|
|
|
|
|
2013-04-06 13:39:56 +00:00
|
|
|
QSE_T("failed to build regular expression"),
|
|
|
|
QSE_T("failed to match regular expression"),
|
2009-11-26 07:32:20 +00:00
|
|
|
QSE_T("recursion too deep in regular expression"),
|
|
|
|
QSE_T("right parenthesis expected in regular expression"),
|
|
|
|
QSE_T("right bracket expected in regular expression"),
|
|
|
|
QSE_T("right brace expected in regular expression"),
|
|
|
|
QSE_T("colon expected in regular expression"),
|
|
|
|
QSE_T("invalid character range in regular expression"),
|
|
|
|
QSE_T("invalid character class in regular expression"),
|
|
|
|
QSE_T("invalid occurrence bound in regular expression"),
|
2009-12-10 05:35:54 +00:00
|
|
|
QSE_T("special character at wrong position"),
|
|
|
|
QSE_T("premature end of regular expression")
|
2007-05-02 01:07:00 +00:00
|
|
|
};
|
|
|
|
|
2009-06-02 03:34:34 +00:00
|
|
|
return (errnum >= 0 && errnum < QSE_COUNTOF(errstr))?
|
|
|
|
errstr[errnum]: QSE_T("unknown error");
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-25 01:21:00 +00:00
|
|
|
qse_awk_errstr_t qse_awk_geterrstr (qse_awk_t* awk)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2009-06-02 03:34:34 +00:00
|
|
|
return awk->errstr;
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2009-06-02 03:34:34 +00:00
|
|
|
void qse_awk_seterrstr (qse_awk_t* awk, qse_awk_errstr_t errstr)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2009-06-02 03:34:34 +00:00
|
|
|
awk->errstr = errstr;
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-25 01:21:00 +00:00
|
|
|
qse_awk_errnum_t qse_awk_geterrnum (qse_awk_t* awk)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2009-06-15 02:40:52 +00:00
|
|
|
return awk->errinf.num;
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-25 01:21:00 +00:00
|
|
|
const qse_awk_loc_t* qse_awk_geterrloc (qse_awk_t* awk)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2009-08-26 03:50:07 +00:00
|
|
|
return &awk->errinf.loc;
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2019-08-28 15:14:22 +00:00
|
|
|
const qse_mchar_t* qse_awk_geterrmsgasmbs (qse_awk_t* awk)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2019-08-28 14:01:28 +00:00
|
|
|
#if defined(QSE_CHAR_IS_MCHAR)
|
2009-06-15 02:40:52 +00:00
|
|
|
return (awk->errinf.msg[0] == QSE_T('\0'))?
|
|
|
|
qse_awk_geterrstr(awk)(awk,awk->errinf.num): awk->errinf.msg;
|
2019-08-28 14:01:28 +00:00
|
|
|
#else
|
|
|
|
const qse_char_t* msg;
|
|
|
|
qse_size_t wcslen, mbslen;
|
|
|
|
|
|
|
|
msg = (awk->errinf.msg[0] == QSE_T('\0'))?
|
|
|
|
qse_awk_geterrstr(awk)(awk,awk->errinf.num): awk->errinf.msg;
|
|
|
|
|
|
|
|
mbslen = QSE_COUNTOF(awk->merrmsg);
|
|
|
|
qse_wcstombswithcmgr(msg, &wcslen, awk->merrmsg, &mbslen, qse_awk_getcmgr(awk));
|
|
|
|
|
|
|
|
return awk->merrmsg;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-08-28 15:14:22 +00:00
|
|
|
const qse_wchar_t* qse_awk_geterrmsgaswcs (qse_awk_t* awk)
|
2019-08-28 14:01:28 +00:00
|
|
|
{
|
|
|
|
#if defined(QSE_CHAR_IS_MCHAR)
|
|
|
|
const qse_char_t* msg;
|
|
|
|
qse_size_t wcslen, mbslen;
|
|
|
|
|
|
|
|
msg = (awk->errinf.msg[0] == QSE_T('\0'))?
|
|
|
|
qse_awk_geterrstr(awk)(awk,awk->errinf.num): awk->errinf.msg;
|
|
|
|
|
|
|
|
wcslen = QSE_COUNTOF(awk->werrmsg);
|
|
|
|
qse_mbstowcsallwithcmgr (msg, &mbslen, awk->werrmsg, &wcslen, qse_awk_getcmgr(awk));
|
|
|
|
|
|
|
|
return awk->werrmsg;
|
|
|
|
#else
|
|
|
|
return (awk->errinf.msg[0] == QSE_T('\0'))?
|
|
|
|
qse_awk_geterrstr(awk)(awk,awk->errinf.num): awk->errinf.msg;
|
|
|
|
#endif
|
|
|
|
|
2009-06-15 02:40:52 +00:00
|
|
|
}
|
|
|
|
|
2019-06-25 01:21:00 +00:00
|
|
|
void qse_awk_geterrinf (qse_awk_t* awk, qse_awk_errinf_t* errinf)
|
2009-06-15 02:40:52 +00:00
|
|
|
{
|
|
|
|
QSE_MEMCPY (errinf, &awk->errinf, QSE_SIZEOF(*errinf));
|
|
|
|
if (errinf->msg[0] == QSE_T('\0'))
|
|
|
|
{
|
|
|
|
qse_strxcpy (errinf->msg, QSE_COUNTOF(errinf->msg),
|
|
|
|
qse_awk_geterrstr(awk)(awk,awk->errinf.num));
|
|
|
|
}
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-25 01:21:00 +00:00
|
|
|
void qse_awk_geterror (qse_awk_t* awk, qse_awk_errnum_t* errnum, const qse_char_t** errmsg, qse_awk_loc_t* errloc)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2019-05-08 07:15:17 +00:00
|
|
|
if (errnum) *errnum = awk->errinf.num;
|
|
|
|
if (errmsg)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2009-06-15 02:40:52 +00:00
|
|
|
*errmsg = (awk->errinf.msg[0] == QSE_T('\0'))?
|
|
|
|
qse_awk_geterrstr(awk)(awk,awk->errinf.num):
|
|
|
|
awk->errinf.msg;
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
2019-05-08 07:15:17 +00:00
|
|
|
if (errloc) *errloc = awk->errinf.loc;
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-06 12:11:40 +00:00
|
|
|
const qse_char_t* qse_awk_backuperrmsg (qse_awk_t* awk)
|
|
|
|
{
|
|
|
|
qse_strxcpy (awk->errmsg_backup, QSE_COUNTOF(awk->errmsg_backup), qse_awk_geterrmsg(awk));
|
|
|
|
return awk->errmsg_backup;
|
|
|
|
}
|
2019-05-08 07:15:17 +00:00
|
|
|
|
|
|
|
void qse_awk_seterrnum (qse_awk_t* awk, qse_awk_errnum_t errnum, const qse_cstr_t* errarg)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2009-08-26 03:50:07 +00:00
|
|
|
qse_awk_seterror (awk, errnum, errarg, QSE_NULL);
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2009-06-15 02:40:52 +00:00
|
|
|
void qse_awk_seterrinf (qse_awk_t* awk, const qse_awk_errinf_t* errinf)
|
2007-08-26 23:33:00 +00:00
|
|
|
{
|
2009-06-15 02:40:52 +00:00
|
|
|
QSE_MEMCPY (&awk->errinf, errinf, QSE_SIZEOF(*errinf));
|
2007-08-26 23:33:00 +00:00
|
|
|
}
|
|
|
|
|
2019-05-08 07:15:17 +00:00
|
|
|
void qse_awk_seterrfmt (qse_awk_t* awk, qse_awk_errnum_t errnum, qse_awk_loc_t* errloc, const qse_char_t* errfmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
QSE_MEMSET (&awk->errinf, 0, QSE_SIZEOF(awk->errinf));
|
|
|
|
awk->errinf.num = errnum;
|
|
|
|
|
|
|
|
va_start (ap, errfmt);
|
|
|
|
qse_strxvfmt (awk->errinf.msg, QSE_COUNTOF(awk->errinf.msg), errfmt, ap);
|
|
|
|
va_end (ap);
|
|
|
|
|
|
|
|
if (errloc) awk->errinf.loc = *errloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void qse_awk_seterror (qse_awk_t* awk, qse_awk_errnum_t errnum, const qse_cstr_t* errarg, const qse_awk_loc_t* errloc)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2008-12-21 21:35:07 +00:00
|
|
|
const qse_char_t* errfmt;
|
2007-05-02 01:07:00 +00:00
|
|
|
|
2009-08-26 03:50:07 +00:00
|
|
|
QSE_MEMSET (&awk->errinf, 0, QSE_SIZEOF(awk->errinf));
|
2009-06-15 02:40:52 +00:00
|
|
|
awk->errinf.num = errnum;
|
2007-05-02 01:07:00 +00:00
|
|
|
|
2009-06-02 03:34:34 +00:00
|
|
|
errfmt = qse_awk_geterrstr(awk)(awk,errnum);
|
2009-02-15 03:14:49 +00:00
|
|
|
QSE_ASSERT (errfmt != QSE_NULL);
|
2019-05-08 07:15:17 +00:00
|
|
|
qse_strxfncpy (awk->errinf.msg, QSE_COUNTOF(awk->errinf.msg), errfmt, errarg);
|
2009-08-17 02:08:58 +00:00
|
|
|
|
2009-08-26 03:50:07 +00:00
|
|
|
if (errloc != QSE_NULL) awk->errinf.loc = *errloc;
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2019-05-08 07:15:17 +00:00
|
|
|
|
2019-06-25 01:21:00 +00:00
|
|
|
qse_awk_errnum_t qse_awk_rtx_geterrnum (qse_awk_rtx_t* rtx)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2009-06-15 02:40:52 +00:00
|
|
|
return rtx->errinf.num;
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-25 01:21:00 +00:00
|
|
|
const qse_awk_loc_t* qse_awk_rtx_geterrloc (qse_awk_rtx_t* rtx)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2009-08-26 03:50:07 +00:00
|
|
|
return &rtx->errinf.loc;
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2019-08-28 15:14:22 +00:00
|
|
|
const qse_mchar_t* qse_awk_rtx_geterrmsgasmbs (qse_awk_rtx_t* rtx)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2019-08-28 14:01:28 +00:00
|
|
|
#if defined(QSE_CHAR_IS_MCHAR)
|
|
|
|
return (rtx->errinf.msg[0] == QSE_T('\0')) ?
|
|
|
|
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errinf.num): rtx->errinf.msg;
|
|
|
|
#else
|
|
|
|
const qse_char_t* msg;
|
|
|
|
qse_size_t wcslen, mbslen;
|
|
|
|
|
|
|
|
msg = (rtx->errinf.msg[0] == QSE_T('\0')) ?
|
2019-08-29 09:09:37 +00:00
|
|
|
qse_awk_geterrstr(rtx->awk)(rtx->awk, rtx->errinf.num): rtx->errinf.msg;
|
2019-08-28 14:01:28 +00:00
|
|
|
|
|
|
|
mbslen = QSE_COUNTOF(rtx->merrmsg);
|
|
|
|
qse_wcstombswithcmgr(msg, &wcslen, rtx->merrmsg, &mbslen, qse_awk_rtx_getcmgr(rtx));
|
|
|
|
|
|
|
|
return rtx->merrmsg;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-08-28 15:14:22 +00:00
|
|
|
const qse_wchar_t* qse_awk_rtx_geterrmsgaswcs (qse_awk_rtx_t* rtx)
|
2019-08-28 14:01:28 +00:00
|
|
|
{
|
|
|
|
#if defined(QSE_CHAR_IS_MCHAR)
|
|
|
|
const qse_char_t* msg;
|
|
|
|
qse_size_t wcslen, mbslen;
|
|
|
|
|
|
|
|
msg = (rtx->errinf.msg[0] == QSE_T('\0')) ?
|
|
|
|
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errinf.num): rtx->errinf.msg;
|
|
|
|
|
|
|
|
wcslen = QSE_COUNTOF(rtx->werrmsg);
|
|
|
|
qse_mbstowcsallwithcmgr (msg, &mbslen, rtx->werrmsg, &wcslen, qse_awk_rtx_getcmgr(rtx));
|
|
|
|
|
|
|
|
return rtx->werrmsg;
|
|
|
|
#else
|
2009-06-15 02:40:52 +00:00
|
|
|
return (rtx->errinf.msg[0] == QSE_T('\0')) ?
|
|
|
|
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errinf.num): rtx->errinf.msg;
|
2019-08-28 14:01:28 +00:00
|
|
|
#endif
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
|
2019-06-25 01:21:00 +00:00
|
|
|
void qse_awk_rtx_geterrinf (qse_awk_rtx_t* rtx, qse_awk_errinf_t* errinf)
|
2007-08-26 23:33:00 +00:00
|
|
|
{
|
2009-06-15 02:40:52 +00:00
|
|
|
QSE_MEMCPY (errinf, &rtx->errinf, QSE_SIZEOF(*errinf));
|
|
|
|
if (errinf->msg[0] == QSE_T('\0'))
|
|
|
|
{
|
|
|
|
qse_strxcpy (errinf->msg, QSE_COUNTOF(errinf->msg),
|
|
|
|
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errinf.num));
|
|
|
|
}
|
2007-08-26 23:33:00 +00:00
|
|
|
}
|
|
|
|
|
2009-02-01 03:59:46 +00:00
|
|
|
void qse_awk_rtx_geterror (
|
2019-06-25 01:21:00 +00:00
|
|
|
qse_awk_rtx_t* rtx, qse_awk_errnum_t* errnum,
|
2009-08-26 03:50:07 +00:00
|
|
|
const qse_char_t** errmsg, qse_awk_loc_t* errloc)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2009-06-15 02:40:52 +00:00
|
|
|
if (errnum != QSE_NULL) *errnum = rtx->errinf.num;
|
2009-08-26 03:50:07 +00:00
|
|
|
if (errloc != QSE_NULL) *errloc = rtx->errinf.loc;
|
2008-12-21 21:35:07 +00:00
|
|
|
if (errmsg != QSE_NULL)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2009-06-15 02:40:52 +00:00
|
|
|
*errmsg = (rtx->errinf.msg[0] == QSE_T('\0'))?
|
|
|
|
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errinf.num): rtx->errinf.msg;
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 12:11:40 +00:00
|
|
|
const qse_char_t* qse_awk_rtx_backuperrmsg (qse_awk_rtx_t* rtx)
|
|
|
|
{
|
|
|
|
qse_strxcpy (rtx->errmsg_backup, QSE_COUNTOF(rtx->errmsg_backup), qse_awk_rtx_geterrmsg(rtx));
|
|
|
|
return rtx->errmsg_backup;
|
|
|
|
}
|
|
|
|
|
2009-08-17 02:08:58 +00:00
|
|
|
void qse_awk_rtx_seterrnum (
|
2014-07-08 14:30:42 +00:00
|
|
|
qse_awk_rtx_t* rtx, qse_awk_errnum_t errnum, const qse_cstr_t* errarg)
|
2009-06-15 02:40:52 +00:00
|
|
|
{
|
2009-08-18 06:10:30 +00:00
|
|
|
qse_awk_rtx_seterror (rtx, errnum, errarg, 0);
|
2009-06-15 02:40:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void qse_awk_rtx_seterrinf (qse_awk_rtx_t* rtx, const qse_awk_errinf_t* errinf)
|
|
|
|
{
|
|
|
|
QSE_MEMCPY (&rtx->errinf, errinf, QSE_SIZEOF(*errinf));
|
|
|
|
}
|
|
|
|
|
2019-05-08 07:15:17 +00:00
|
|
|
void qse_awk_rtx_seterrfmt (qse_awk_rtx_t* rtx, qse_awk_errnum_t errnum, const qse_awk_loc_t* errloc, const qse_char_t* errfmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
QSE_MEMSET (&rtx->errinf, 0, QSE_SIZEOF(rtx->errinf));
|
|
|
|
rtx->errinf.num = errnum;
|
|
|
|
|
|
|
|
va_start (ap, errfmt);
|
|
|
|
qse_strxvfmt (rtx->errinf.msg, QSE_COUNTOF(rtx->errinf.msg), errfmt, ap);
|
|
|
|
va_end (ap);
|
|
|
|
|
|
|
|
if (errloc) rtx->errinf.loc = *errloc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void qse_awk_rtx_seterror (qse_awk_rtx_t* rtx, qse_awk_errnum_t errnum, const qse_cstr_t* errarg, const qse_awk_loc_t* errloc)
|
2007-05-02 01:07:00 +00:00
|
|
|
{
|
2008-12-21 21:35:07 +00:00
|
|
|
const qse_char_t* errfmt;
|
2007-05-02 01:07:00 +00:00
|
|
|
|
2009-08-26 03:50:07 +00:00
|
|
|
QSE_MEMSET (&rtx->errinf, 0, QSE_SIZEOF(rtx->errinf));
|
2009-06-15 02:40:52 +00:00
|
|
|
rtx->errinf.num = errnum;
|
2007-05-02 01:07:00 +00:00
|
|
|
|
2009-06-02 03:34:34 +00:00
|
|
|
errfmt = qse_awk_geterrstr(rtx->awk)(rtx->awk,errnum);
|
2009-02-15 03:14:49 +00:00
|
|
|
QSE_ASSERT (errfmt != QSE_NULL);
|
2009-06-15 02:40:52 +00:00
|
|
|
qse_strxfncpy (
|
|
|
|
rtx->errinf.msg, QSE_COUNTOF(rtx->errinf.msg),
|
|
|
|
errfmt, errarg
|
|
|
|
);
|
2009-08-26 03:50:07 +00:00
|
|
|
|
|
|
|
if (errloc != QSE_NULL) rtx->errinf.loc = *errloc;
|
2007-05-02 01:07:00 +00:00
|
|
|
}
|
2011-04-18 09:28:22 +00:00
|
|
|
|