simplified error formatting in qse_awk_t

- added qse_awk_errstr_t and related functions
- changed the Awk class
also fixed a minor bug in qse_awk_rtx_call()
This commit is contained in:
hyung-hwan 2009-06-02 03:34:34 +00:00
parent 3148407114
commit cd52c663cf
15 changed files with 211 additions and 166 deletions

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.hpp 156 2009-05-25 13:39:18Z hyunghwan.chung $
* $Id: Awk.hpp 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -36,15 +36,17 @@ class Awk: public Mmgr
{
public:
typedef qse_map_t map_t;
/** Represents a key/value pair */
typedef qse_map_pair_t pair_t;
/** Represents an internal awk value */
typedef qse_awk_val_t val_t;
/** Represents a underlying interpreter */
typedef qse_awk_t awk_t;
typedef qse_awk_errnum_t errnum_t;
typedef qse_awk_errstr_t errstr_t;
/** Represents an internal awk value */
typedef qse_awk_val_t val_t;
/** Represents a runtime context */
typedef qse_awk_rtx_t rtx_t;
@ -792,8 +794,9 @@ public:
/** Gets the maximum depth */
virtual size_t getMaxDepth (int id) const;
virtual const char_t* getErrorString (ErrorCode num) const;
virtual int setErrorString (ErrorCode num, const char_t* str);
virtual const char_t* getErrorString (
ErrorCode num
) const;
virtual int getWord (
const char_t* ow, qse_size_t owl,
@ -1038,6 +1041,7 @@ protected:
protected:
awk_t* awk;
errstr_t dflerrstr;
map_t* functionMap;
Source sourceIn;
@ -1049,6 +1053,9 @@ protected:
bool runCallback;
private:
static const char_t* xerrstr (awk_t* a, errnum_t num) throw ();
private:
Awk (const Awk&);
Awk& operator= (const Awk&);

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h 168 2009-05-30 01:19:46Z hyunghwan.chung $
* $Id: awk.h 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -27,9 +27,6 @@
/** @file
* An embeddable AWK interpreter is defined in this header files.
*
* @todo
* - change the way to set a custom error string: follow qse_sed_errstr_t
*
* @example awk01.c
* This program demonstrates how to use qse_awk_rtx_loop().
* @example awk02.c
@ -419,10 +416,8 @@ enum qse_awk_option_t
QSE_AWK_NEWLINE | QSE_AWK_PABLOCK
};
/****e* AWK/qse_awk_errnum_t
* NAME
* qse_awk_errnum_t - define an error code
* SYNOPSIS
/**
* The qse_awk_errnum_t type defines error codes.
*/
enum qse_awk_errnum_t
{
@ -575,10 +570,21 @@ enum qse_awk_errnum_t
/* the number of error numbers, internal use only */
QSE_AWK_NUMERRNUM
};
/******/
typedef enum qse_awk_errnum_t qse_awk_errnum_t;
/**
* The qse_awk_errstr_t type defines a error string getter. It should return
* an error formatting string for an error number requested. A new string
* should contain the same number of positional parameters (${X}) as in the
* default error formatting string. You can set a new getter into an awk
* object with the qse_awk_seterrstr() function to customize an error string.
*/
typedef const qse_char_t* (*qse_awk_errstr_t) (
qse_awk_t* awk, /**< an awk object */
qse_awk_errnum_t num /**< an error number */
);
/* depth types */
enum qse_awk_depth_t
{
@ -845,35 +851,41 @@ int qse_awk_clear (
);
/******/
/****f* AWK/qse_awk_geterrstr
* NAME
* qse_awk_geterrstr - get a format string for an error code
* DESCRIPTION
* The qse_awk_geterrstr() function returns a pointer to a format string for
* the error number num.
* SYNOPSIS
/**
* The qse_awk_geterrstr() gets an error string getter.
*/
const qse_char_t* qse_awk_geterrstr (
qse_awk_t* awk,
qse_awk_errnum_t num
qse_awk_errstr_t qse_awk_geterrstr (
qse_awk_t* awk /**< an awk object */
);
/******/
/****f* AWK/qse_awk_seterrstr
* NAME
* qse_awk_geterrstr - set a format string for an error
* DESCRIPTION
* The qse_awk_seterrstr() function sets a format string for an error. The
* format string is used to compose an actual error message to be returned
* by qse_awk_geterrmsg() and qse_awk_geterror().
* SYNOPSIS
/**
* The qse_awk_seterrstr() sets an error string getter that is called to
* compose an error message when its retrieval is requested.
*
* Here is an example of changing the formatting string for the #QSE_SED_ECMDNR
* error.
* @code
* qse_awk_errstr_t orgerrstr;
*
* const qse_char_t* myerrstr (qse_awk_t* awk, qse_awk_errnum_t num)
* {
* if (num == QSE_SED_ECMDNR) return QSE_T("unrecognized command ${0}");
* return orgerrstr (awk, num);
* }
* int main ()
* {
* qse_awk_t* awk;
* ...
* orgerrstr = qse_awk_geterrstr (awk);
* qse_awk_seterrstr (awk, myerrstr);
* ...
* }
* @endcode
*/
int qse_awk_seterrstr (
qse_awk_t* awk,
qse_awk_errnum_t num,
const qse_char_t* str
void qse_awk_seterrstr (
qse_awk_t* awk, /**< an awk object */
qse_awk_errstr_t errstr /**< an error string getter */
);
/******/
int qse_awk_geterrnum (
qse_awk_t* awk
@ -889,26 +901,26 @@ const qse_char_t* qse_awk_geterrmsg (
void qse_awk_seterrnum (
qse_awk_t* awk,
int errnum
qse_awk_errnum_t errnum
);
void qse_awk_seterrmsg (
qse_awk_t* awk,
int errnum,
qse_awk_errnum_t errnum,
qse_size_t errlin,
const qse_char_t* errmsg
);
void qse_awk_geterror (
qse_awk_t* awk,
int* errnum,
qse_awk_errnum_t* errnum,
qse_size_t* errlin,
const qse_char_t** errmsg
);
void qse_awk_seterror (
qse_awk_t* awk,
int errnum,
qse_awk_errnum_t errnum,
qse_size_t errlin,
const qse_cstr_t* errarg
);
@ -1428,26 +1440,26 @@ const qse_char_t* qse_awk_rtx_geterrmsg (
void qse_awk_rtx_seterrnum (
qse_awk_rtx_t* rtx,
int errnum
qse_awk_errnum_t errnum
);
void qse_awk_rtx_seterrmsg (
qse_awk_rtx_t* rtx,
int errnum,
qse_awk_errnum_t errnum,
qse_size_t errlin,
const qse_char_t* errmsg
);
void qse_awk_rtx_geterror (
qse_awk_rtx_t* rtx,
int* errnum,
qse_awk_errnum_t* errnum,
qse_size_t* errlin,
const qse_char_t** errmsg
);
void qse_awk_rtx_seterror (
qse_awk_rtx_t* rtx,
int errnum,
qse_awk_errnum_t errnum,
qse_size_t errlin,
const qse_cstr_t* errarg
);

View File

@ -386,7 +386,7 @@ protected:
*/
virtual const char_t* getErrorString (
errnum_t num ///< an error number
);
) const;
protected:
/// handle to a primitive sed object
@ -398,6 +398,10 @@ private:
static ssize_t xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw ();
static ssize_t xout (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw ();
static const char_t* xerrstr (sed_t* s, errnum_t num) throw ();
private:
Sed (const Sed&);
Sed& operator= (const Sed&);
};
/////////////////////////////////

View File

@ -1,5 +1,5 @@
/*
* $Id: Awk.cpp 148 2009-05-20 10:44:47Z hyunghwan.chung $
* $Id: Awk.cpp 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -966,20 +966,20 @@ const Awk::char_t* Awk::Run::getErrorMessage () const
void Awk::Run::setError (ErrorCode code)
{
QSE_ASSERT (this->run != QSE_NULL);
qse_awk_rtx_seterror (this->run, code, 0, QSE_NULL);
qse_awk_rtx_seterror (this->run, (errnum_t)code, 0, QSE_NULL);
}
void Awk::Run::setError (ErrorCode code, size_t line)
{
QSE_ASSERT (this->run != QSE_NULL);
qse_awk_rtx_seterror (this->run, code, line, QSE_NULL);
qse_awk_rtx_seterror (this->run, (errnum_t)code, line, QSE_NULL);
}
void Awk::Run::setError (ErrorCode code, size_t line, const char_t* arg)
{
QSE_ASSERT (this->run != QSE_NULL);
qse_cstr_t x = { arg, qse_strlen(arg) };
qse_awk_rtx_seterror (this->run, code, line, &x);
qse_awk_rtx_seterror (this->run, (errnum_t)code, line, &x);
}
void Awk::Run::setError (
@ -987,14 +987,14 @@ void Awk::Run::setError (
{
QSE_ASSERT (this->run != QSE_NULL);
qse_cstr_t x = { arg, len };
qse_awk_rtx_seterror (this->run, code, line, &x);
qse_awk_rtx_seterror (this->run, (errnum_t)code, line, &x);
}
void Awk::Run::setErrorWithMessage (
ErrorCode code, size_t line, const char_t* msg)
{
QSE_ASSERT (this->run != QSE_NULL);
qse_awk_rtx_seterrmsg (this->run, code, line, msg);
qse_awk_rtx_seterrmsg (this->run, (errnum_t)code, line, msg);
}
int Awk::Run::setGlobal (int id, long_t v)
@ -1113,17 +1113,15 @@ void Awk::setError (ErrorCode code, size_t line, const char_t* arg, size_t len)
if (awk != QSE_NULL)
{
qse_cstr_t x = { arg, len };
qse_awk_seterror (awk, code, line, &x);
qse_awk_seterror (awk, (errnum_t)code, line, &x);
retrieveError ();
}
else
{
this->errnum = code;
this->errlin = line;
const char_t* es = qse_awk_geterrstr (
QSE_NULL, (qse_awk_errnum_t)code);
qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg), es);
qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg),
QSE_T("not ready to set an error message"));
}
}
@ -1131,7 +1129,7 @@ void Awk::setErrorWithMessage (ErrorCode code, size_t line, const char_t* msg)
{
if (awk != QSE_NULL)
{
qse_awk_seterrmsg (awk, code, line, msg);
qse_awk_seterrmsg (awk, (errnum_t)code, line, msg);
retrieveError ();
}
else
@ -1157,7 +1155,7 @@ void Awk::retrieveError ()
}
else
{
int num;
errnum_t num;
const char_t* msg;
qse_awk_geterror (this->awk, &num, &this->errlin, &msg);
@ -1168,7 +1166,7 @@ void Awk::retrieveError ()
void Awk::retrieveError (rtx_t* rtx)
{
int num;
errnum_t num;
const char_t* msg;
qse_awk_rtx_geterror (rtx, &num, &this->errlin, &msg);
@ -1195,6 +1193,9 @@ int Awk::open ()
xtn_t* xtn = (xtn_t*) QSE_XTN (awk);
xtn->awk = this;
dflerrstr = qse_awk_geterrstr (awk);
qse_awk_seterrstr (awk, xerrstr);
//functionMap = qse_map_open (
// this, 512, 70, freeFunctionMapValue, QSE_NULL,
// qse_awk_getmmgr(awk));
@ -1262,14 +1263,21 @@ Awk::size_t Awk::getMaxDepth (int id) const
const Awk::char_t* Awk::getErrorString (ErrorCode num) const
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_geterrstr (awk, (qse_awk_errnum_t)num);
QSE_ASSERT (dflerrstr != QSE_NULL);
return dflerrstr (awk, (errnum_t)num);
}
int Awk::setErrorString (ErrorCode num, const char_t* str)
const Awk::char_t* Awk::xerrstr (awk_t* a, errnum_t num) throw ()
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_seterrstr (awk, (qse_awk_errnum_t)num, str);
Awk* awk = *(Awk**)QSE_XTN(a);
try
{
return awk->getErrorString ((ErrorCode)num);
}
catch (...)
{
return awk->dflerrstr (a, num);
}
}
int Awk::getWord (
@ -1735,7 +1743,7 @@ void Awk::onRunExit (rtx_t* run, val_t* ret, void* data)
Argument x (r);
if (x.init (ret) == -1)
qse_awk_rtx_seterrnum (r->run, ERR_NOMEM);
qse_awk_rtx_seterrnum (r->run, (errnum_t)ERR_NOMEM);
else r->awk->onRunExit (*r, x);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.c 151 2009-05-21 06:50:02Z hyunghwan.chung $
* $Id: awk.c 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -155,6 +155,7 @@ qse_awk_t* qse_awk_open (qse_mmgr_t* mmgr, qse_size_t xtn, qse_awk_prm_t* prm)
awk->option = QSE_AWK_CLASSIC;
awk->errnum = QSE_AWK_ENOERR;
awk->errlin = 0;
awk->errstr = qse_awk_dflerrstr;
awk->stopall = QSE_FALSE;
awk->parse.nlcls_max = 0;
@ -243,15 +244,6 @@ int qse_awk_close (qse_awk_t* awk)
qse_str_close (awk->token.name);
for (i = 0; i < QSE_COUNTOF(awk->errstr); i++)
{
if (awk->errstr[i] != QSE_NULL)
{
QSE_AWK_FREE (awk, awk->errstr[i]);
awk->errstr[i] = QSE_NULL;
}
}
/* QSE_AWK_ALLOC, QSE_AWK_FREE, etc can not be used
* from the next line onwards */
QSE_AWK_FREE (awk, awk);

View File

@ -1,5 +1,5 @@
/*
* $Id: awk.h 151 2009-05-21 06:50:02Z hyunghwan.chung $
* $Id: awk.h 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -37,6 +37,7 @@ typedef struct qse_awk_tree_t qse_awk_tree_t;
#include "run.h"
#include "rio.h"
#include "val.h"
#include "err.h"
#include "misc.h"
#define QSE_AWK_MAX_GBLS 9999
@ -229,10 +230,11 @@ struct qse_awk_t
} tmp;
/* housekeeping */
int errnum;
qse_awk_errstr_t errstr;
qse_awk_errnum_t errnum;
qse_size_t errlin;
qse_char_t errmsg[256];
qse_char_t* errstr[QSE_AWK_NUMERRNUM];
qse_bool_t stopall;
};
@ -365,7 +367,7 @@ struct qse_awk_rtx_t
} max;
} depth;
int errnum;
qse_awk_errnum_t errnum;
qse_size_t errlin;
qse_char_t errmsg[256];

View File

@ -1,9 +1,9 @@
/*
* $Id: err.c 113 2009-03-25 14:53:10Z hyunghwan.chung $
* $Id: err.c 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
Licenawk under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
@ -18,7 +18,7 @@
#include "awk.h"
static const qse_char_t* __geterrstr (int errnum)
const qse_char_t* qse_awk_dflerrstr (qse_awk_t* awk, qse_awk_errnum_t errnum)
{
static const qse_char_t* errstr[] =
{
@ -26,7 +26,7 @@ static const qse_char_t* __geterrstr (int errnum)
QSE_T("unknown error"),
QSE_T("invalid parameter or data"),
QSE_T("out of memory"),
QSE_T("insufficient memory"),
QSE_T("not supported"),
QSE_T("operation not allowed"),
QSE_T("no such device"),
@ -64,8 +64,8 @@ static const qse_char_t* __geterrstr (int errnum)
QSE_T("cannot unget character"),
QSE_T("unexpected end of source"),
QSE_T("a comment not closed properly"),
QSE_T("a string or a regular expression not closed"),
QSE_T("a comment not cloawk properly"),
QSE_T("a string or a regular expression not cloawk"),
QSE_T("unexpected end of a regular expression"),
QSE_T("a left brace expected in place of '${0}'"),
QSE_T("a left parenthesis expected in place of '${0}'"),
@ -164,37 +164,18 @@ static const qse_char_t* __geterrstr (int errnum)
QSE_T("garbage after the regular expression")
};
if (errnum >= 0 && errnum < QSE_COUNTOF(errstr))
{
return errstr[errnum];
}
return QSE_T("unknown error");
return (errnum >= 0 && errnum < QSE_COUNTOF(errstr))?
errstr[errnum]: QSE_T("unknown error");
}
const qse_char_t* qse_awk_geterrstr (qse_awk_t* awk, qse_awk_errnum_t num)
qse_awk_errstr_t qse_awk_geterrstr (qse_awk_t* awk)
{
if (awk != QSE_NULL &&
awk->errstr[num] != QSE_NULL) return awk->errstr[num];
return __geterrstr (num);
return awk->errstr;
}
int qse_awk_seterrstr (
qse_awk_t* awk, qse_awk_errnum_t num, const qse_char_t* str)
void qse_awk_seterrstr (qse_awk_t* awk, qse_awk_errstr_t errstr)
{
qse_char_t* dup;
if (str == QSE_NULL) dup = QSE_NULL;
else
{
dup = QSE_AWK_STRDUP (awk, str);
if (dup == QSE_NULL) return -1;
}
if (awk->errstr[num] != QSE_NULL)
QSE_AWK_FREE (awk, awk->errstr[num]);
else awk->errstr[num] = dup;
return 0;
awk->errstr = errstr;
}
int qse_awk_geterrnum (qse_awk_t* awk)
@ -209,13 +190,12 @@ qse_size_t qse_awk_geterrlin (qse_awk_t* awk)
const qse_char_t* qse_awk_geterrmsg (qse_awk_t* awk)
{
if (awk->errmsg[0] == QSE_T('\0'))
return qse_awk_geterrstr (awk, awk->errnum);
return awk->errmsg;
return (awk->errmsg[0] == QSE_T('\0'))?
qse_awk_geterrstr(awk)(awk,awk->errnum): awk->errmsg;
}
void qse_awk_geterror (
qse_awk_t* awk, int* errnum,
qse_awk_t* awk, qse_awk_errnum_t* errnum,
qse_size_t* errlin, const qse_char_t** errmsg)
{
if (errnum != QSE_NULL) *errnum = awk->errnum;
@ -223,12 +203,12 @@ void qse_awk_geterror (
if (errmsg != QSE_NULL)
{
*errmsg = (awk->errmsg[0] == QSE_T('\0'))?
qse_awk_geterrstr (awk, awk->errnum):
qse_awk_geterrstr(awk)(awk,awk->errnum):
awk->errmsg;
}
}
void qse_awk_seterrnum (qse_awk_t* awk, int errnum)
void qse_awk_seterrnum (qse_awk_t* awk, qse_awk_errnum_t errnum)
{
awk->errnum = errnum;
awk->errlin = 0;
@ -236,7 +216,7 @@ void qse_awk_seterrnum (qse_awk_t* awk, int errnum)
}
void qse_awk_seterrmsg (qse_awk_t* awk,
int errnum, qse_size_t errlin, const qse_char_t* errmsg)
qse_awk_errnum_t errnum, qse_size_t errlin, const qse_char_t* errmsg)
{
awk->errnum = errnum;
awk->errlin = errlin;
@ -244,7 +224,7 @@ void qse_awk_seterrmsg (qse_awk_t* awk,
}
void qse_awk_seterror (
qse_awk_t* awk, int errnum,
qse_awk_t* awk, qse_awk_errnum_t errnum,
qse_size_t errlin, const qse_cstr_t* errarg)
{
const qse_char_t* errfmt;
@ -252,30 +232,28 @@ void qse_awk_seterror (
awk->errnum = errnum;
awk->errlin = errlin;
errfmt = qse_awk_geterrstr (awk, errnum);
errfmt = qse_awk_geterrstr(awk)(awk,errnum);
QSE_ASSERT (errfmt != QSE_NULL);
qse_strxfncpy (awk->errmsg, QSE_COUNTOF(awk->errmsg), errfmt, errarg);
}
int qse_awk_rtx_geterrnum (qse_awk_rtx_t* run)
int qse_awk_rtx_geterrnum (qse_awk_rtx_t* rtx)
{
return run->errnum;
return rtx->errnum;
}
qse_size_t qse_awk_rtx_geterrlin (qse_awk_rtx_t* run)
qse_size_t qse_awk_rtx_geterrlin (qse_awk_rtx_t* rtx)
{
return run->errlin;
return rtx->errlin;
}
const qse_char_t* qse_awk_rtx_geterrmsg (qse_awk_rtx_t* run)
const qse_char_t* qse_awk_rtx_geterrmsg (qse_awk_rtx_t* rtx)
{
if (run->errmsg[0] == QSE_T('\0'))
return qse_awk_geterrstr (run->awk, run->errnum);
return run->errmsg;
return (rtx->errmsg[0] == QSE_T('\0')) ?
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errnum): rtx->errmsg;
}
void qse_awk_rtx_seterrnum (qse_awk_rtx_t* rtx, int errnum)
void qse_awk_rtx_seterrnum (qse_awk_rtx_t* rtx, qse_awk_errnum_t errnum)
{
rtx->errnum = errnum;
rtx->errlin = 0;
@ -283,7 +261,7 @@ void qse_awk_rtx_seterrnum (qse_awk_rtx_t* rtx, int errnum)
}
void qse_awk_rtx_seterrmsg (qse_awk_rtx_t* rtx,
int errnum, qse_size_t errlin, const qse_char_t* errmsg)
qse_awk_errnum_t errnum, qse_size_t errlin, const qse_char_t* errmsg)
{
rtx->errnum = errnum;
rtx->errlin = errlin;
@ -291,7 +269,7 @@ void qse_awk_rtx_seterrmsg (qse_awk_rtx_t* rtx,
}
void qse_awk_rtx_geterror (
qse_awk_rtx_t* rtx, int* errnum,
qse_awk_rtx_t* rtx, qse_awk_errnum_t* errnum,
qse_size_t* errlin, const qse_char_t** errmsg)
{
if (errnum != QSE_NULL) *errnum = rtx->errnum;
@ -299,12 +277,12 @@ void qse_awk_rtx_geterror (
if (errmsg != QSE_NULL)
{
*errmsg = (rtx->errmsg[0] == QSE_T('\0'))?
qse_awk_geterrstr (rtx->awk, rtx->errnum): rtx->errmsg;
qse_awk_geterrstr(rtx->awk)(rtx->awk,rtx->errnum): rtx->errmsg;
}
}
void qse_awk_rtx_seterror (
qse_awk_rtx_t* rtx, int errnum,
qse_awk_rtx_t* rtx, qse_awk_errnum_t errnum,
qse_size_t errlin, const qse_cstr_t* errarg)
{
const qse_char_t* errfmt;
@ -312,7 +290,7 @@ void qse_awk_rtx_seterror (
rtx->errnum = errnum;
rtx->errlin = errlin;
errfmt = qse_awk_geterrstr (rtx->awk, errnum);
errfmt = qse_awk_geterrstr(rtx->awk)(rtx->awk,errnum);
QSE_ASSERT (errfmt != QSE_NULL);
qse_strxfncpy (rtx->errmsg, QSE_COUNTOF(rtx->errmsg), errfmt, errarg);
}

33
qse/lib/awk/err.h Normal file
View File

@ -0,0 +1,33 @@
/*
* $Id: misc.h 135 2009-05-15 13:31:43Z baconevi $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#ifndef _QSE_LIB_AWK_ERR_H_
#define _QSE_LIB_AWK_ERR_H_
#ifdef __cplusplus
extern "C" {
#endif
const qse_char_t* qse_awk_dflerrstr (qse_awk_t* awk, qse_awk_errnum_t errnum);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: fnc.c 135 2009-05-15 13:31:43Z hyunghwan.chung $
* $Id: fnc.c 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -591,7 +591,7 @@ static int fnc_split (
qse_size_t fs_len;
void* fs_rex = QSE_NULL;
void* fs_rex_free = QSE_NULL;
int errnum;
qse_awk_errnum_t errnum;
nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs >= 2 && nargs <= 3);

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.c 135 2009-05-15 13:31:43Z hyunghwan.chung $
* $Id: misc.c 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -834,7 +834,8 @@ qse_char_t* qse_awk_rtx_strxntokbyrex (
qse_awk_rtx_t* rtx,
const qse_char_t* str, qse_size_t len,
const qse_char_t* substr, qse_size_t sublen,
void* rex, qse_char_t** tok, qse_size_t* tok_len, int* errnum)
void* rex, qse_char_t** tok, qse_size_t* tok_len,
qse_awk_errnum_t* errnum)
{
int n;
qse_size_t i, left = sublen;
@ -942,7 +943,8 @@ exit_loop:
QSE_AWK_EINTERN)
void* qse_awk_buildrex (
qse_awk_t* awk, const qse_char_t* ptn, qse_size_t len, int* errnum)
qse_awk_t* awk, const qse_char_t* ptn,
qse_size_t len, qse_awk_errnum_t* errnum)
{
qse_rex_errnum_t err;
void* p;
@ -957,7 +959,7 @@ int qse_awk_matchrex (
qse_awk_t* awk, void* code, int option,
const qse_char_t* str, qse_size_t len,
const qse_char_t* substr, qse_size_t sublen,
qse_cstr_t* match, int* errnum)
qse_cstr_t* match, qse_awk_errnum_t* errnum)
{
int x;
qse_rex_errnum_t err;

View File

@ -1,5 +1,5 @@
/*
* $Id: misc.h 135 2009-05-15 13:31:43Z hyunghwan.chung $
* $Id: misc.h 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -50,18 +50,22 @@ qse_char_t* qse_awk_rtx_strxntokbyrex (
void* rex,
qse_char_t** tok,
qse_size_t* tok_len,
int* errnum
qse_awk_errnum_t* errnum
);
void* qse_awk_buildrex (
qse_awk_t* awk, const qse_char_t* ptn, qse_size_t len, int* errnum);
qse_awk_t* awk,
const qse_char_t* ptn,
qse_size_t len,
qse_awk_errnum_t* errnum
);
int qse_awk_matchrex (
qse_awk_t* awk, void* code, int option,
const qse_char_t* str, qse_size_t len,
const qse_char_t* substr, qse_size_t sublen,
qse_cstr_t* match, int* errnum);
qse_cstr_t* match, qse_awk_errnum_t* errnum
);
#ifdef __cplusplus
}

View File

@ -1,5 +1,5 @@
/*
* $Id: parse.c 113 2009-03-25 14:53:10Z hyunghwan.chung $
* $Id: parse.c 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -2927,7 +2927,7 @@ static qse_awk_nde_t* parse_primary (qse_awk_t* awk, qse_size_t line)
else if (MATCH(awk,TOKEN_DIV))
{
qse_awk_nde_rex_t* nde;
int errnum;
qse_awk_errnum_t errnum;
/* the regular expression is tokenized here because
* of the context-sensitivity of the slash symbol.

View File

@ -1,5 +1,5 @@
/*
* $Id: rec.c 135 2009-05-15 13:31:43Z hyunghwan.chung $
* $Id: rec.c 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -101,7 +101,7 @@ static int split_record (qse_awk_rtx_t* run)
qse_awk_val_t* v, * fs;
qse_char_t* fs_ptr, * fs_free;
qse_size_t fs_len;
int errnum;
qse_awk_errnum_t errnum;
/* inrec should be cleared before split_record is called */
QSE_ASSERT (run->inrec.nflds == 0);

View File

@ -1,5 +1,5 @@
/*
* $Id: run.c 135 2009-05-15 13:31:43Z hyunghwan.chung $
* $Id: run.c 171 2009-06-01 09:34:34Z hyunghwan.chung $
*
Copyright 2006-2009 Chung, Hyung-Hwan.
@ -1486,6 +1486,7 @@ qse_awk_val_t* qse_awk_rtx_call (
call.type = QSE_AWK_NDE_FUN;
call.what.fun.name.ptr = (qse_char_t*)name;
call.what.fun.name.len = qse_strlen(name);
call.nargs = nargs;
/* find the function */
pair = qse_map_search (
@ -3059,7 +3060,8 @@ static int output_formatted (
static qse_awk_val_t* eval_expression (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
{
qse_awk_val_t* v;
int n, errnum;
int n;
qse_awk_errnum_t errnum;
#if 0
if (run->exit_level >= EXIT_GLOBAL)
@ -3267,7 +3269,7 @@ static qse_awk_val_t* do_assignment (
qse_awk_rtx_t* run, qse_awk_nde_t* var, qse_awk_val_t* val)
{
qse_awk_val_t* ret;
int errnum;
qse_awk_errnum_t errnum;
if (var->type == QSE_AWK_NDE_NAMED ||
var->type == QSE_AWK_NDE_GBL ||
@ -4729,7 +4731,8 @@ static qse_awk_val_t* eval_binop_match0 (
qse_size_t lline, qse_size_t rline, int ret)
{
qse_awk_val_t* res;
int n, errnum;
int n;
qse_awk_errnum_t errnum;
void* rex_code;
if (right->type == QSE_AWK_VAL_REX)

View File

@ -227,7 +227,7 @@ Sed::ssize_t Sed::xout (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw ()
}
}
const Sed::char_t* Sed::getErrorString (errnum_t num)
const Sed::char_t* Sed::getErrorString (errnum_t num) const
{
QSE_ASSERT (dflerrstr != QSE_NULL);
return dflerrstr (sed, num);