2006-03-04 10:08:13 +00:00
|
|
|
/*
|
2007-01-10 14:33:51 +00:00
|
|
|
* $Id: err.c,v 1.70 2007-01-10 14:33:36 bacon Exp $
|
2006-03-04 10:08:13 +00:00
|
|
|
*/
|
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
#include <ase/awk/awk_i.h>
|
2006-03-04 10:08:13 +00:00
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
int ase_awk_geterrnum (ase_awk_t* awk)
|
2006-03-04 10:08:13 +00:00
|
|
|
{
|
|
|
|
return awk->errnum;
|
|
|
|
}
|
|
|
|
|
2006-12-19 14:20:30 +00:00
|
|
|
ase_size_t ase_awk_geterrlin (ase_awk_t* awk)
|
|
|
|
{
|
|
|
|
return awk->errlin;
|
|
|
|
}
|
|
|
|
|
|
|
|
const ase_char_t* ase_awk_geterrmsg (ase_awk_t* awk)
|
|
|
|
{
|
|
|
|
if (awk->errmsg[0] == ASE_T('\0'))
|
|
|
|
return ase_awk_geterrstr (awk->errnum);
|
|
|
|
return awk->errmsg;
|
|
|
|
}
|
|
|
|
|
2006-12-23 05:44:17 +00:00
|
|
|
|
|
|
|
void ase_awk_geterror (
|
|
|
|
ase_awk_t* awk, int* errnum,
|
|
|
|
ase_size_t* errlin, const ase_char_t** errmsg)
|
|
|
|
{
|
|
|
|
if (errnum != ASE_NULL) *errnum = awk->errnum;
|
|
|
|
if (errlin != ASE_NULL) *errlin = awk->errlin;
|
2007-01-03 09:51:53 +00:00
|
|
|
if (errmsg != ASE_NULL)
|
|
|
|
{
|
|
|
|
if (awk->errmsg[0] == ASE_T('\0'))
|
|
|
|
*errmsg = ase_awk_geterrstr (awk->errnum);
|
|
|
|
else
|
|
|
|
*errmsg = awk->errmsg;
|
|
|
|
}
|
2006-12-23 05:44:17 +00:00
|
|
|
}
|
|
|
|
|
2006-12-19 14:20:30 +00:00
|
|
|
void ase_awk_seterror (
|
|
|
|
ase_awk_t* awk, int errnum,
|
2006-12-23 05:44:17 +00:00
|
|
|
ase_size_t errlin, const ase_char_t* errmsg)
|
2006-12-19 14:20:30 +00:00
|
|
|
{
|
|
|
|
awk->errnum = errnum;
|
|
|
|
awk->errlin = errlin;
|
2006-12-23 05:44:17 +00:00
|
|
|
if (errmsg == ASE_NULL) awk->errmsg[0] = ASE_T('\0');
|
2006-12-24 17:21:24 +00:00
|
|
|
else if (awk->errmsg != errmsg)
|
|
|
|
{
|
|
|
|
ase_awk_strxcpy (
|
|
|
|
awk->errmsg, ASE_COUNTOF(awk->errmsg), errmsg);
|
|
|
|
}
|
2006-12-19 14:20:30 +00:00
|
|
|
}
|
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
const ase_char_t* ase_awk_geterrstr (int errnum)
|
2006-03-04 10:08:13 +00:00
|
|
|
{
|
2006-10-24 04:10:12 +00:00
|
|
|
static const ase_char_t* __errstr[] =
|
2006-03-04 10:08:13 +00:00
|
|
|
{
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("no error"),
|
2006-12-16 16:14:40 +00:00
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("invalid parameter"),
|
2006-12-16 16:14:40 +00:00
|
|
|
ASE_T("out of memory"),
|
|
|
|
ASE_T("not supported"),
|
|
|
|
ASE_T("operation not allowed"),
|
|
|
|
ASE_T("no such device"),
|
|
|
|
ASE_T("no space left on device"),
|
|
|
|
ASE_T("no such file, directory, or data"),
|
|
|
|
ASE_T("too many open files"),
|
|
|
|
ASE_T("too many links"),
|
|
|
|
ASE_T("resource temporarily unavailable"),
|
|
|
|
ASE_T("file or data exists"),
|
|
|
|
ASE_T("file or data too big"),
|
|
|
|
ASE_T("system too busy"),
|
|
|
|
ASE_T("is a directory"),
|
|
|
|
ASE_T("i/o error"),
|
|
|
|
|
2007-01-10 14:33:51 +00:00
|
|
|
ASE_T("internal error that should never have happened"),
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("general run-time error"),
|
|
|
|
ASE_T("one or more running instances"),
|
|
|
|
ASE_T("recursion too deep"),
|
2006-12-15 14:58:37 +00:00
|
|
|
ASE_T("system functions not provided or not proper"),
|
2006-04-22 13:54:53 +00:00
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("cannot open source input"),
|
|
|
|
ASE_T("cannot close source input"),
|
|
|
|
ASE_T("cannot read source input"),
|
2006-04-22 13:54:53 +00:00
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("cannot open source output"),
|
|
|
|
ASE_T("cannot close source output"),
|
|
|
|
ASE_T("cannot write source output"),
|
2006-08-06 12:35:06 +00:00
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("cannot open console for read"),
|
|
|
|
ASE_T("cannot close console for read"),
|
|
|
|
ASE_T("cannot switch to next console for read"),
|
|
|
|
ASE_T("cannot read from console"),
|
2006-08-03 09:54:16 +00:00
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("cannot open console for write"),
|
|
|
|
ASE_T("cannot close console for write"),
|
|
|
|
ASE_T("cannot switch to next console for write"),
|
|
|
|
ASE_T("cannot write to console"),
|
2006-04-22 13:54:53 +00:00
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("invalid character"),
|
|
|
|
ASE_T("cannot unget character"),
|
2006-04-07 04:23:11 +00:00
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("unexpected end of source"),
|
|
|
|
ASE_T("unexpected end of a comment"),
|
|
|
|
ASE_T("unexpected end of a string"),
|
|
|
|
ASE_T("unexpected end of a regular expression"),
|
|
|
|
ASE_T("left brace expected"),
|
|
|
|
ASE_T("left parenthesis expected"),
|
|
|
|
ASE_T("right parenthesis expected"),
|
|
|
|
ASE_T("right bracket expected"),
|
|
|
|
ASE_T("comma expected"),
|
|
|
|
ASE_T("semicolon expected"),
|
|
|
|
ASE_T("colon expected"),
|
|
|
|
ASE_T("keyword 'in' expected"),
|
|
|
|
ASE_T("not a variable after 'in'"),
|
|
|
|
ASE_T("expression expected"),
|
2006-04-10 15:52:07 +00:00
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("keyword 'while' expected"),
|
|
|
|
ASE_T("assignment statement expected"),
|
|
|
|
ASE_T("identifier expected"),
|
|
|
|
ASE_T("BEGIN requires an action block"),
|
|
|
|
ASE_T("END requires an action block"),
|
|
|
|
ASE_T("duplicate BEGIN"),
|
|
|
|
ASE_T("duplicate END"),
|
2006-12-25 12:01:01 +00:00
|
|
|
ASE_T("built-in function redefined"),
|
|
|
|
ASE_T("function redefined"),
|
|
|
|
ASE_T("global variable redefined"),
|
2006-12-25 13:45:43 +00:00
|
|
|
ASE_T("parameter redefined"),
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("duplicate parameter name"),
|
2006-12-25 13:45:43 +00:00
|
|
|
ASE_T("duplicate global variable name"),
|
|
|
|
ASE_T("duplicate local variable name"),
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("undefined identifier"),
|
|
|
|
ASE_T("l-value required"),
|
|
|
|
ASE_T("too many global variables"),
|
|
|
|
ASE_T("too many local variables"),
|
|
|
|
ASE_T("too many parameters"),
|
|
|
|
ASE_T("break outside a loop"),
|
|
|
|
ASE_T("continue outside a loop"),
|
|
|
|
ASE_T("next illegal in BEGIN or END block"),
|
|
|
|
ASE_T("nextfile illegal in BEGIN or END block"),
|
|
|
|
ASE_T("getline expected"),
|
2006-10-31 10:13:15 +00:00
|
|
|
ASE_T("printf requires one or more arguments"),
|
2006-04-05 15:56:20 +00:00
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("divide by zero"),
|
|
|
|
ASE_T("invalid operand"),
|
|
|
|
ASE_T("wrong position index"),
|
2006-12-25 12:01:01 +00:00
|
|
|
ASE_T("too few arguments"),
|
|
|
|
ASE_T("too many arguments"),
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("no such function"),
|
|
|
|
ASE_T("variable not indexable"),
|
|
|
|
ASE_T("variable not deletable"),
|
2006-12-30 08:54:43 +00:00
|
|
|
ASE_T("value not a map"),
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("value not referenceable"),
|
2006-12-30 08:54:43 +00:00
|
|
|
ASE_T("value not assignable"),
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("an indexed value cannot be assigned a map"),
|
|
|
|
ASE_T("a positional value cannot be assigned a map"),
|
|
|
|
ASE_T("cannot change a map to a scalar value"),
|
|
|
|
ASE_T("cannot change a scalar value to a map"),
|
|
|
|
ASE_T("a map is not allowed"),
|
|
|
|
ASE_T("wrong value type"),
|
|
|
|
ASE_T("next cannot be called from the BEGIN or END block"),
|
|
|
|
ASE_T("nextfile cannot be called from the BEGIN or END block"),
|
2006-11-29 14:52:36 +00:00
|
|
|
ASE_T("wrong implementation of built-in function handler"),
|
2006-12-02 16:26:29 +00:00
|
|
|
ASE_T("built-in function handler returned an error"),
|
2007-01-02 12:25:18 +00:00
|
|
|
ASE_T("wrong implementation of user-defined io handler"),
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("no such io name found"),
|
2006-12-17 14:56:07 +00:00
|
|
|
ASE_T("i/o handler returned an error"),
|
|
|
|
ASE_T("invalid i/o name"),
|
2006-11-16 04:44:16 +00:00
|
|
|
ASE_T("not sufficient arguments to formatting sequence"),
|
|
|
|
ASE_T("recursion detected in format conversion"),
|
2006-11-18 12:15:20 +00:00
|
|
|
ASE_T("invalid character in CONVFMT"),
|
|
|
|
ASE_T("invalid character in OFMT"),
|
2006-08-10 16:02:15 +00:00
|
|
|
|
2006-11-16 04:44:16 +00:00
|
|
|
ASE_T("a right parenthesis expected in the regular expression"),
|
|
|
|
ASE_T("a right bracket expected in the regular expression"),
|
|
|
|
ASE_T("a right brace expected in the regular expression"),
|
|
|
|
ASE_T("a colon expected in the regular expression"),
|
2006-10-24 04:10:12 +00:00
|
|
|
ASE_T("invalid character range in the regular expression"),
|
|
|
|
ASE_T("invalid character class in the regular expression"),
|
|
|
|
ASE_T("invalid boundary range in the regular expression"),
|
|
|
|
ASE_T("unexpected end of the regular expression"),
|
|
|
|
ASE_T("garbage after the regular expression")
|
2006-03-04 10:08:13 +00:00
|
|
|
};
|
|
|
|
|
2006-11-29 02:54:17 +00:00
|
|
|
if (errnum >= 0 && errnum < ASE_COUNTOF(__errstr))
|
2006-07-25 16:41:40 +00:00
|
|
|
{
|
2006-08-10 16:02:15 +00:00
|
|
|
return __errstr[errnum];
|
2006-03-04 10:08:13 +00:00
|
|
|
}
|
|
|
|
|
2006-10-24 04:10:12 +00:00
|
|
|
return ASE_T("unknown error");
|
2006-03-04 10:08:13 +00:00
|
|
|
}
|
2006-07-26 16:43:35 +00:00
|
|
|
|