cleaned up code

This commit is contained in:
hyung-hwan 2009-07-16 04:43:31 +00:00
parent e149b933f7
commit f0f2db5e8a
22 changed files with 781 additions and 796 deletions

View File

@ -42,7 +42,7 @@ public:
* The Mmgr() function builds a memory manager composed of bridge * The Mmgr() function builds a memory manager composed of bridge
* functions connecting itself with it. * functions connecting itself with it.
*/ */
Mmgr () throw () Mmgr ()
{ {
this->alloc = alloc_mem; this->alloc = alloc_mem;
this->realloc = realloc_mem; this->realloc = realloc_mem;
@ -63,7 +63,7 @@ protected:
*/ */
virtual void* allocMem ( virtual void* allocMem (
qse_size_t n /**< the size of allocate in bytes */ qse_size_t n /**< the size of allocate in bytes */
) throw () = 0; ) = 0;
/** /**
* The reallocMem() function resizes a chunk of memory previously * The reallocMem() function resizes a chunk of memory previously
@ -74,7 +74,7 @@ protected:
virtual void* reallocMem ( virtual void* reallocMem (
void* ptr, /**< a pointer to a memory chunk to resize */ void* ptr, /**< a pointer to a memory chunk to resize */
qse_size_t n /**< new size in bytes */ qse_size_t n /**< new size in bytes */
) throw () = 0; ) = 0;
/** /**
* The freeMem() function frees a chunk of memory allocated with * The freeMem() function frees a chunk of memory allocated with
@ -82,13 +82,13 @@ protected:
*/ */
virtual void freeMem ( virtual void freeMem (
void* ptr /**< a pointer to a memory chunk to free */ void* ptr /**< a pointer to a memory chunk to free */
) throw () = 0; ) = 0;
protected: protected:
/** /**
* a bridge function from the qse_mmgr_t type the allocMem() function. * a bridge function from the qse_mmgr_t type the allocMem() function.
*/ */
static void* alloc_mem (void* udd, qse_size_t n) throw () static void* alloc_mem (void* udd, qse_size_t n)
{ {
return ((Mmgr*)udd)->allocMem (n); return ((Mmgr*)udd)->allocMem (n);
} }
@ -96,7 +96,7 @@ protected:
/** /**
* a bridge function from the qse_mmgr_t type the reallocMem() function. * a bridge function from the qse_mmgr_t type the reallocMem() function.
*/ */
static void* realloc_mem (void* udd, void* ptr, qse_size_t n) throw () static void* realloc_mem (void* udd, void* ptr, qse_size_t n)
{ {
return ((Mmgr*)udd)->reallocMem (ptr, n); return ((Mmgr*)udd)->reallocMem (ptr, n);
} }
@ -104,7 +104,7 @@ protected:
/** /**
* a bridge function from the qse_mmgr_t type the freeMem() function. * a bridge function from the qse_mmgr_t type the freeMem() function.
*/ */
static void free_mem (void* udd, void* ptr) throw () static void free_mem (void* udd, void* ptr)
{ {
return ((Mmgr*)udd)->freeMem (ptr); return ((Mmgr*)udd)->freeMem (ptr);
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.hpp 234 2009-07-14 14:08:48Z hyunghwan.chung $ * $Id: Awk.hpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -38,11 +38,12 @@ public:
typedef qse_map_t map_t; typedef qse_map_t map_t;
typedef qse_map_pair_t pair_t; typedef qse_map_pair_t pair_t;
/** Represents a underlying interpreter */ /** Defines a primitive handle */
typedef qse_awk_t awk_t; typedef qse_awk_t awk_t;
typedef qse_awk_errnum_t errnum_t; typedef qse_awk_errnum_t errnum_t;
typedef qse_awk_errstr_t errstr_t; typedef qse_awk_errstr_t errstr_t;
typedef qse_awk_errinf_t errinf_t;
/** Represents an internal awk value */ /** Represents an internal awk value */
typedef qse_awk_val_t val_t; typedef qse_awk_val_t val_t;
@ -58,13 +59,207 @@ public:
class Run; class Run;
friend class Run; friend class Run;
/**
* @name Error Handling
*/
/*@{*/
/**
* Defines error numbers.
*/
enum ErrorNumber
{
ERR_NOERR = QSE_AWK_ENOERR,
ERR_UNKNOWN = QSE_AWK_EUNKNOWN,
ERR_INVAL = QSE_AWK_EINVAL,
ERR_NOMEM = QSE_AWK_ENOMEM,
ERR_NOSUP = QSE_AWK_ENOSUP,
ERR_NOPER = QSE_AWK_ENOPER,
ERR_NOENT = QSE_AWK_ENOENT,
ERR_EXIST = QSE_AWK_EEXIST,
ERR_IOERR = QSE_AWK_EIOERR,
ERR_OPEN = QSE_AWK_EOPEN,
ERR_READ = QSE_AWK_EREAD,
ERR_WRITE = QSE_AWK_EWRITE,
ERR_CLOSE = QSE_AWK_ECLOSE,
ERR_INTERN = QSE_AWK_EINTERN,
ERR_RUNTIME = QSE_AWK_ERUNTIME,
ERR_BLKNST = QSE_AWK_EBLKNST,
ERR_EXPRNST = QSE_AWK_EEXPRNST,
ERR_SINOP = QSE_AWK_ESINOP,
ERR_SINCL = QSE_AWK_ESINCL,
ERR_SINRD = QSE_AWK_ESINRD,
ERR_SOUTOP = QSE_AWK_ESOUTOP,
ERR_SOUTCL = QSE_AWK_ESOUTCL,
ERR_SOUTWR = QSE_AWK_ESOUTWR,
ERR_LXCHR = QSE_AWK_ELXCHR,
ERR_LXDIG = QSE_AWK_ELXDIG,
ERR_LXUNG = QSE_AWK_ELXUNG,
ERR_ENDSRC = QSE_AWK_EENDSRC,
ERR_ENDCMT = QSE_AWK_EENDCMT,
ERR_ENDSTR = QSE_AWK_EENDSTR,
ERR_ENDREX = QSE_AWK_EENDREX,
ERR_LBRACE = QSE_AWK_ELBRACE,
ERR_LPAREN = QSE_AWK_ELPAREN,
ERR_RPAREN = QSE_AWK_ERPAREN,
ERR_RBRACK = QSE_AWK_ERBRACK,
ERR_COMMA = QSE_AWK_ECOMMA,
ERR_SCOLON = QSE_AWK_ESCOLON,
ERR_COLON = QSE_AWK_ECOLON,
ERR_STMEND = QSE_AWK_ESTMEND,
ERR_IN = QSE_AWK_EIN,
ERR_NOTVAR = QSE_AWK_ENOTVAR,
ERR_EXPRES = QSE_AWK_EEXPRES,
ERR_FUNCTION = QSE_AWK_EFUNCTION,
ERR_WHILE = QSE_AWK_EWHILE,
ERR_ASSIGN = QSE_AWK_EASSIGN,
ERR_IDENT = QSE_AWK_EIDENT,
ERR_FUNNAME = QSE_AWK_EFUNNAME,
ERR_BLKBEG = QSE_AWK_EBLKBEG,
ERR_BLKEND = QSE_AWK_EBLKEND,
ERR_DUPBEG = QSE_AWK_EDUPBEG,
ERR_DUPEND = QSE_AWK_EDUPEND,
ERR_KWRED = QSE_AWK_EKWRED,
ERR_FNCRED = QSE_AWK_EFNCRED,
ERR_FUNRED = QSE_AWK_EFUNRED,
ERR_GBLRED = QSE_AWK_EGBLRED,
ERR_PARRED = QSE_AWK_EPARRED,
ERR_VARRED = QSE_AWK_EVARRED,
ERR_DUPPAR = QSE_AWK_EDUPPAR,
ERR_DUPGBL = QSE_AWK_EDUPGBL,
ERR_DUPLCL = QSE_AWK_EDUPLCL,
ERR_BADPAR = QSE_AWK_EBADPAR,
ERR_BADVAR = QSE_AWK_EBADVAR,
ERR_UNDEF = QSE_AWK_EUNDEF,
ERR_LVALUE = QSE_AWK_ELVALUE,
ERR_GBLTM = QSE_AWK_EGBLTM,
ERR_LCLTM = QSE_AWK_ELCLTM,
ERR_PARTM = QSE_AWK_EPARTM,
ERR_DELETE = QSE_AWK_EDELETE,
ERR_BREAK = QSE_AWK_EBREAK,
ERR_CONTINUE = QSE_AWK_ECONTINUE,
ERR_NEXTBEG = QSE_AWK_ENEXTBEG,
ERR_NEXTEND = QSE_AWK_ENEXTEND,
ERR_NEXTFBEG = QSE_AWK_ENEXTFBEG,
ERR_NEXTFEND = QSE_AWK_ENEXTFEND,
ERR_PRINTFARG = QSE_AWK_EPRINTFARG,
ERR_PREPST = QSE_AWK_EPREPST,
ERR_INCDECOPR = QSE_AWK_EINCDECOPR,
ERR_DIVBY0 = QSE_AWK_EDIVBY0,
ERR_OPERAND = QSE_AWK_EOPERAND,
ERR_POSIDX = QSE_AWK_EPOSIDX,
ERR_ARGTF = QSE_AWK_EARGTF,
ERR_ARGTM = QSE_AWK_EARGTM,
ERR_FUNNF = QSE_AWK_EFUNNF,
ERR_NOTIDX = QSE_AWK_ENOTIDX,
ERR_NOTDEL = QSE_AWK_ENOTDEL,
ERR_NOTMAP = QSE_AWK_ENOTMAP,
ERR_NOTMAPIN = QSE_AWK_ENOTMAPIN,
ERR_NOTMAPNILIN = QSE_AWK_ENOTMAPNILIN,
ERR_NOTREF = QSE_AWK_ENOTREF,
ERR_NOTASS = QSE_AWK_ENOTASS,
ERR_IDXVALASSMAP = QSE_AWK_EIDXVALASSMAP,
ERR_POSVALASSMAP = QSE_AWK_EPOSVALASSMAP,
ERR_MAPTOSCALAR = QSE_AWK_EMAPTOSCALAR,
ERR_SCALARTOMAP = QSE_AWK_ESCALARTOMAP,
ERR_MAPNOTALLOWED = QSE_AWK_EMAPNOTALLOWED,
ERR_VALTYPE = QSE_AWK_EVALTYPE,
ERR_RDELETE = QSE_AWK_ERDELETE,
ERR_RNEXTBEG = QSE_AWK_ERNEXTBEG,
ERR_RNEXTEND = QSE_AWK_ERNEXTEND,
ERR_RNEXTFBEG = QSE_AWK_ERNEXTFBEG,
ERR_RNEXTFEND = QSE_AWK_ERNEXTFEND,
ERR_FNCIMPL = QSE_AWK_EFNCIMPL,
ERR_IOUSER = QSE_AWK_EIOUSER,
ERR_IOIMPL = QSE_AWK_EIOIMPL,
ERR_IONMNF = QSE_AWK_EIONMNF,
ERR_IONMEM = QSE_AWK_EIONMEM,
ERR_IONMNL = QSE_AWK_EIONMNL,
ERR_FMTARG = QSE_AWK_EFMTARG,
ERR_FMTCNV = QSE_AWK_EFMTCNV,
ERR_CONVFMTCHR = QSE_AWK_ECONVFMTCHR,
ERR_OFMTCHR = QSE_AWK_EOFMTCHR,
ERR_REXRECUR = QSE_AWK_EREXRECUR,
ERR_REXRPAREN = QSE_AWK_EREXRPAREN,
ERR_REXRBRACKET = QSE_AWK_EREXRBRACKET,
ERR_REXRBRACE = QSE_AWK_EREXRBRACE,
ERR_REXUNBALPAREN = QSE_AWK_EREXUNBALPAREN,
ERR_REXINVALBRACE = QSE_AWK_EREXINVALBRACE,
ERR_REXCOLON = QSE_AWK_EREXCOLON,
ERR_REXCRANGE = QSE_AWK_EREXCRANGE,
ERR_REXCCLASS = QSE_AWK_EREXCCLASS,
ERR_REXBRANGE = QSE_AWK_EREXBRANGE,
ERR_REXEND = QSE_AWK_EREXEND,
ERR_REXGARBAGE = QSE_AWK_EREXGARBAGE,
};
protected: protected:
class NoSource; /**
* The Awk::getErrorString() function returns a formatting string
* for an error code @a num. You can override this function
* to customize an error message. You must include the same numbers
* of ${X}'s as the orginal formatting string. Their order may be
* different. The example below changes the formatting string for
* ERR_NOENT.
* @code
* const MyAwk::char_t* MyAwk::getErrorString (ErrorNumber num) const
* {
* if (num == ERR_NOENT) return QSE_T("cannot find '${0}'");
* return Awk::getErrorString (num);
* }
* @endcode
*/
virtual const char_t* getErrorString (
ErrorNumber num
) const;
public:
/**
* The Awk::getErrorNumber() function returns the number of the last
* error occurred.
*/
ErrorNumber getErrorNumber () const;
/**
* The Awk::getErrorLine() function returns the line number of the last
* error occurred.
*/
size_t getErrorLine () const;
/**
* The Awk::getErrorMessage() function returns a message describing
* the last error occurred.
*/
const char_t* getErrorMessage () const;
/**
* Set error information.
*/
void setError (
ErrorNumber code,
size_t line = 0,
const cstr_t* args = QSE_NULL
);
void setErrorWithMessage (
ErrorNumber code,
size_t line,
const char_t* msg
);
/** clears error information */
void clearError ();
protected:
void retrieveError ();
void retrieveError (Run* run);
/*@}*/
class NoSource;
public: public:
/** /**
* The Source class is an abstract class to encapsulate * The Source class is an abstract class to encapsulate
* source script I/O. The Awk::parse() function requires a concrete * source script I/O. The Awk::parse function requires a concrete
* object instantiated from its child class. * object instantiated from its child class.
*/ */
class Source class Source
@ -265,13 +460,13 @@ public:
#if !defined(__BORLANDC__) #if !defined(__BORLANDC__)
// deletion when initialization fails // deletion when initialization fails
void operator delete (void* p, Run* run) throw (); void operator delete (void* p, Run* run);
void operator delete[] (void* p, Run* run) throw (); void operator delete[] (void* p, Run* run);
#endif #endif
// normal deletion // normal deletion
void operator delete (void* p) throw (); void operator delete (void* p);
void operator delete[] (void* p) throw (); void operator delete[] (void* p);
class Index class Index
{ {
@ -482,180 +677,9 @@ public:
static const char_t* EMPTY_STRING; static const char_t* EMPTY_STRING;
}; };
// generated by generrcode.awk
/** Defines the error code */
enum ErrorNumber
{
ERR_NOERR = QSE_AWK_ENOERR,
ERR_UNKNOWN = QSE_AWK_EUNKNOWN,
ERR_INVAL = QSE_AWK_EINVAL,
ERR_NOMEM = QSE_AWK_ENOMEM,
ERR_NOSUP = QSE_AWK_ENOSUP,
ERR_NOPER = QSE_AWK_ENOPER,
ERR_NOENT = QSE_AWK_ENOENT,
ERR_EXIST = QSE_AWK_EEXIST,
ERR_IOERR = QSE_AWK_EIOERR,
ERR_OPEN = QSE_AWK_EOPEN,
ERR_READ = QSE_AWK_EREAD,
ERR_WRITE = QSE_AWK_EWRITE,
ERR_CLOSE = QSE_AWK_ECLOSE,
ERR_INTERN = QSE_AWK_EINTERN,
ERR_RUNTIME = QSE_AWK_ERUNTIME,
ERR_BLKNST = QSE_AWK_EBLKNST,
ERR_EXPRNST = QSE_AWK_EEXPRNST,
ERR_SINOP = QSE_AWK_ESINOP,
ERR_SINCL = QSE_AWK_ESINCL,
ERR_SINRD = QSE_AWK_ESINRD,
ERR_SOUTOP = QSE_AWK_ESOUTOP,
ERR_SOUTCL = QSE_AWK_ESOUTCL,
ERR_SOUTWR = QSE_AWK_ESOUTWR,
ERR_LXCHR = QSE_AWK_ELXCHR,
ERR_LXDIG = QSE_AWK_ELXDIG,
ERR_LXUNG = QSE_AWK_ELXUNG,
ERR_ENDSRC = QSE_AWK_EENDSRC,
ERR_ENDCMT = QSE_AWK_EENDCMT,
ERR_ENDSTR = QSE_AWK_EENDSTR,
ERR_ENDREX = QSE_AWK_EENDREX,
ERR_LBRACE = QSE_AWK_ELBRACE,
ERR_LPAREN = QSE_AWK_ELPAREN,
ERR_RPAREN = QSE_AWK_ERPAREN,
ERR_RBRACK = QSE_AWK_ERBRACK,
ERR_COMMA = QSE_AWK_ECOMMA,
ERR_SCOLON = QSE_AWK_ESCOLON,
ERR_COLON = QSE_AWK_ECOLON,
ERR_STMEND = QSE_AWK_ESTMEND,
ERR_IN = QSE_AWK_EIN,
ERR_NOTVAR = QSE_AWK_ENOTVAR,
ERR_EXPRES = QSE_AWK_EEXPRES,
ERR_FUNCTION = QSE_AWK_EFUNCTION,
ERR_WHILE = QSE_AWK_EWHILE,
ERR_ASSIGN = QSE_AWK_EASSIGN,
ERR_IDENT = QSE_AWK_EIDENT,
ERR_FUNNAME = QSE_AWK_EFUNNAME,
ERR_BLKBEG = QSE_AWK_EBLKBEG,
ERR_BLKEND = QSE_AWK_EBLKEND,
ERR_DUPBEG = QSE_AWK_EDUPBEG,
ERR_DUPEND = QSE_AWK_EDUPEND,
ERR_KWRED = QSE_AWK_EKWRED,
ERR_FNCRED = QSE_AWK_EFNCRED,
ERR_FUNRED = QSE_AWK_EFUNRED,
ERR_GBLRED = QSE_AWK_EGBLRED,
ERR_PARRED = QSE_AWK_EPARRED,
ERR_VARRED = QSE_AWK_EVARRED,
ERR_DUPPAR = QSE_AWK_EDUPPAR,
ERR_DUPGBL = QSE_AWK_EDUPGBL,
ERR_DUPLCL = QSE_AWK_EDUPLCL,
ERR_BADPAR = QSE_AWK_EBADPAR,
ERR_BADVAR = QSE_AWK_EBADVAR,
ERR_UNDEF = QSE_AWK_EUNDEF,
ERR_LVALUE = QSE_AWK_ELVALUE,
ERR_GBLTM = QSE_AWK_EGBLTM,
ERR_LCLTM = QSE_AWK_ELCLTM,
ERR_PARTM = QSE_AWK_EPARTM,
ERR_DELETE = QSE_AWK_EDELETE,
ERR_BREAK = QSE_AWK_EBREAK,
ERR_CONTINUE = QSE_AWK_ECONTINUE,
ERR_NEXTBEG = QSE_AWK_ENEXTBEG,
ERR_NEXTEND = QSE_AWK_ENEXTEND,
ERR_NEXTFBEG = QSE_AWK_ENEXTFBEG,
ERR_NEXTFEND = QSE_AWK_ENEXTFEND,
ERR_PRINTFARG = QSE_AWK_EPRINTFARG,
ERR_PREPST = QSE_AWK_EPREPST,
ERR_INCDECOPR = QSE_AWK_EINCDECOPR,
ERR_DIVBY0 = QSE_AWK_EDIVBY0,
ERR_OPERAND = QSE_AWK_EOPERAND,
ERR_POSIDX = QSE_AWK_EPOSIDX,
ERR_ARGTF = QSE_AWK_EARGTF,
ERR_ARGTM = QSE_AWK_EARGTM,
ERR_FUNNF = QSE_AWK_EFUNNF,
ERR_NOTIDX = QSE_AWK_ENOTIDX,
ERR_NOTDEL = QSE_AWK_ENOTDEL,
ERR_NOTMAP = QSE_AWK_ENOTMAP,
ERR_NOTMAPIN = QSE_AWK_ENOTMAPIN,
ERR_NOTMAPNILIN = QSE_AWK_ENOTMAPNILIN,
ERR_NOTREF = QSE_AWK_ENOTREF,
ERR_NOTASS = QSE_AWK_ENOTASS,
ERR_IDXVALASSMAP = QSE_AWK_EIDXVALASSMAP,
ERR_POSVALASSMAP = QSE_AWK_EPOSVALASSMAP,
ERR_MAPTOSCALAR = QSE_AWK_EMAPTOSCALAR,
ERR_SCALARTOMAP = QSE_AWK_ESCALARTOMAP,
ERR_MAPNOTALLOWED = QSE_AWK_EMAPNOTALLOWED,
ERR_VALTYPE = QSE_AWK_EVALTYPE,
ERR_RDELETE = QSE_AWK_ERDELETE,
ERR_RNEXTBEG = QSE_AWK_ERNEXTBEG,
ERR_RNEXTEND = QSE_AWK_ERNEXTEND,
ERR_RNEXTFBEG = QSE_AWK_ERNEXTFBEG,
ERR_RNEXTFEND = QSE_AWK_ERNEXTFEND,
ERR_FNCUSER = QSE_AWK_EFNCUSER,
ERR_FNCIMPL = QSE_AWK_EFNCIMPL,
ERR_IOUSER = QSE_AWK_EIOUSER,
ERR_IOIMPL = QSE_AWK_EIOIMPL,
ERR_IONMNF = QSE_AWK_EIONMNF,
ERR_IONMEM = QSE_AWK_EIONMEM,
ERR_IONMNL = QSE_AWK_EIONMNL,
ERR_FMTARG = QSE_AWK_EFMTARG,
ERR_FMTCNV = QSE_AWK_EFMTCNV,
ERR_CONVFMTCHR = QSE_AWK_ECONVFMTCHR,
ERR_OFMTCHR = QSE_AWK_EOFMTCHR,
ERR_REXRECUR = QSE_AWK_EREXRECUR,
ERR_REXRPAREN = QSE_AWK_EREXRPAREN,
ERR_REXRBRACKET = QSE_AWK_EREXRBRACKET,
ERR_REXRBRACE = QSE_AWK_EREXRBRACE,
ERR_REXUNBALPAREN = QSE_AWK_EREXUNBALPAREN,
ERR_REXINVALBRACE = QSE_AWK_EREXINVALBRACE,
ERR_REXCOLON = QSE_AWK_EREXCOLON,
ERR_REXCRANGE = QSE_AWK_EREXCRANGE,
ERR_REXCCLASS = QSE_AWK_EREXCCLASS,
ERR_REXBRANGE = QSE_AWK_EREXBRANGE,
ERR_REXEND = QSE_AWK_EREXEND,
ERR_REXGARBAGE = QSE_AWK_EREXGARBAGE,
};
// end of enum ErrorNumber
// generated by genoptcode.awk
/** Defines options */
enum Option
{
OPT_IMPLICIT = QSE_AWK_IMPLICIT,
OPT_EXPLICIT = QSE_AWK_EXPLICIT,
OPT_BXOR = QSE_AWK_BXOR,
OPT_SHIFT = QSE_AWK_SHIFT,
OPT_IDIV = QSE_AWK_IDIV,
OPT_RIO = QSE_AWK_RIO,
OPT_RWPIPE = QSE_AWK_RWPIPE,
/** Can terminate a statement with a new line */
OPT_NEWLINE = QSE_AWK_NEWLINE,
OPT_STRIPSPACES = QSE_AWK_STRIPSPACES,
/** Support the nextofile statement */
OPT_NEXTOFILE = QSE_AWK_NEXTOFILE,
/** Enables the keyword 'reset' */
OPT_RESET = QSE_AWK_RESET,
/** Use CR+LF instead of LF for line breaking. */
OPT_CRLF = QSE_AWK_CRLF,
/** Allows the assignment of a map value to a variable */
OPT_MAPTOVAR = QSE_AWK_MAPTOVAR,
/** Allows BEGIN, END, pattern-action blocks */
OPT_PABLOCK = QSE_AWK_PABLOCK,
/** Allows {n,m} in a regular expression */
OPT_REXBOUND = QSE_AWK_REXBOUND,
/**
* Performs numeric comparison when a string convertable
* to a number is compared with a number or vice versa.
*
* For an expression (9 > "10.9"),
* - 9 is greater if #QSE_AWK_NCMPONSTR is off;
* - "10.9" is greater if #QSE_AWK_NCMPONSTR is on
*/
OPT_NCMPONSTR = QSE_AWK_NCMPONSTR
};
// end of enum Option
/** /**
* Defines an identifier of predefined global variables. * Defines an identifier of predefined global variables.
* Awk::setGlobal and Awk::getGlobal can take one of these enumeration. * Awk::setGlobal and Awk::getGlobal can take one of these enumerators.
*/ */
enum Global enum Global
{ {
@ -694,16 +718,17 @@ public:
operator rtx_t* () const; operator rtx_t* () const;
void stop () const; void stop () const;
bool isStop () const; bool shouldStop () const;
ErrorNumber errorNumber () const throw (); ErrorNumber getErrorNumber () const;
size_t errorLine () const throw (); size_t getErrorLine () const;
const char_t* errorMessage () const throw (); const char_t* getErrorMessage () const;
void setError (ErrorNumber code); void setError (
void setError (ErrorNumber code, size_t line); ErrorNumber code,
void setError (ErrorNumber code, size_t line, const char_t* arg); size_t line = 0,
void setError (ErrorNumber code, size_t line, const char_t* arg, size_t len); const cstr_t* args = QSE_NULL
);
void setErrorWithMessage ( void setErrorWithMessage (
ErrorNumber code, size_t line, const char_t* msg); ErrorNumber code, size_t line, const char_t* msg);
@ -748,105 +773,111 @@ public:
rtx_t* rtx; rtx_t* rtx;
}; };
/** Constructor */ /** Returns the primitive handle */
Awk () throw ();
/** Returns the underlying handle */
operator awk_t* () const; operator awk_t* () const;
/** /**
* @name Error Handling * @name Basic Functions
*/ */
/*@{*/ /*@{*/
protected: /** Constructor */
/** Awk ();
* The Awk::errorString() function returns a formatting string
* for an error code @a num. You can override this function
* to customize an error message. You must include the same numbers
* of ${X}'s as the orginal formatting string. Their order may be
* different. The example below changes the formatting string for
* ERR_NOENT.
* @code
* const MyAwk::char_t* MyAwk::errorString (ErrorNumber num) const throw ()
* {
* if (num == ERR_NOENT) return QSE_T("cannot find '${0}'");
* return Awk::errorString (num);
* }
* @endcode
*/
virtual const char_t* errorString (
ErrorNumber num
) const throw ();
public:
/**
* The Awk::errorNumber() function returns the number of the last
* error occurred.
*/
ErrorNumber errorNumber () const throw ();
/**
* The Awk::errorLine() function returns the line number of the last
* error occurred.
*/
size_t errorLine () const throw ();
/**
* The Awk::errorMessage() function returns a message describing
* the last error occurred.
*/
const char_t* errorMessage () const throw ();
void setError (
ErrorNumber code
);
void setError (
ErrorNumber code, size_t line
);
void setError (
ErrorNumber code,
size_t line,
const char_t* arg
);
void setError (
ErrorNumber code,
size_t line,
const char_t* arg,
size_t len
);
void setErrorWithMessage (
ErrorNumber code,
size_t line,
const char_t* msg
);
void clearError ();
protected:
void retrieveError ();
void retrieveError (Run* run);
/*@}*/
public:
/** /**
* The Awk::open() function initializes an interpreter. * The Awk::open() function initializes an interpreter.
* You must call this function before doing anything meaningful. * You must call this function before doing anything meaningful.
* @return 0 on success, -1 on failure * @return 0 on success, -1 on failure
*/ */
virtual int open (); int open ();
/** Closes the interpreter. */ /** Closes the interpreter. */
virtual void close (); void close ();
/**
* The Awk::parse() function parses the source code read from the input
* stream @a in and writes the parse tree to the output stream @out.
* To disable deparsing, you may set @a out to Awk::Source::NONE.
* However, it is not legal to specify Awk::Source::NONE for @a in.
*
* @return a Run object on success, #QSE_NULL on failure
*/
Awk::Run* parse (
Source& in, /**< script to parse */
Source& out /**< deparsing target */
);
/**
* Executes the BEGIN block, pattern-action blocks, and the END block.
* @return 0 on succes, -1 on failure
*/
int loop ();
/**
* Calls a function
*/
int call (
const char_t* name,
Value* ret,
const Value* args,
size_t nargs
);
/**
* Makes request to abort execution
*/
void stop ();
/*@}*/
/**
* @name Configuration
*/
/*@{*/
/** Defines options */
enum Option
{
OPT_IMPLICIT = QSE_AWK_IMPLICIT,
OPT_EXPLICIT = QSE_AWK_EXPLICIT,
OPT_BXOR = QSE_AWK_BXOR,
OPT_SHIFT = QSE_AWK_SHIFT,
OPT_IDIV = QSE_AWK_IDIV,
OPT_RIO = QSE_AWK_RIO,
OPT_RWPIPE = QSE_AWK_RWPIPE,
/** Can terminate a statement with a new line */
OPT_NEWLINE = QSE_AWK_NEWLINE,
OPT_STRIPSPACES = QSE_AWK_STRIPSPACES,
/** Support the nextofile statement */
OPT_NEXTOFILE = QSE_AWK_NEXTOFILE,
/** Enables the keyword 'reset' */
OPT_RESET = QSE_AWK_RESET,
/** Use CR+LF instead of LF for line breaking. */
OPT_CRLF = QSE_AWK_CRLF,
/** Allows the assignment of a map value to a variable */
OPT_MAPTOVAR = QSE_AWK_MAPTOVAR,
/** Allows BEGIN, END, pattern-action blocks */
OPT_PABLOCK = QSE_AWK_PABLOCK,
/** Allows {n,m} in a regular expression */
OPT_REXBOUND = QSE_AWK_REXBOUND,
/**
* Performs numeric comparison when a string convertable
* to a number is compared with a number or vice versa.
*
* For an expression (9 > "10.9"),
* - 9 is greater if #QSE_AWK_NCMPONSTR is off;
* - "10.9" is greater if #QSE_AWK_NCMPONSTR is on
*/
OPT_NCMPONSTR = QSE_AWK_NCMPONSTR
};
/** Gets the option */
int getOption () const;
/** Sets the option */ /** Sets the option */
virtual void setOption (int opt); void setOption (
int opt
/** Gets the option */ );
virtual int getOption () const;
/** Defines the depth ID */ /** Defines the depth ID */
enum Depth enum Depth
@ -860,40 +891,9 @@ public:
}; };
/** Sets the maximum depth */ /** Sets the maximum depth */
virtual void setMaxDepth (int ids, size_t depth); void setMaxDepth (int ids, size_t depth);
/** Gets the maximum depth */ /** Gets the maximum depth */
virtual size_t getMaxDepth (int id) const; size_t getMaxDepth (int id) const;
/**
* The Awk::parse() function parses the source code read from the input
* stream @a in and writes the parse tree to the output stream @out.
* To disable deparsing, you may set @a out to Awk::Source::NONE.
* However, it is not legal to specify Awk::Source::NONE for @a in.
*
* @return a Run object on success, #QSE_NULL on failure
*/
virtual Awk::Run* parse (Source& in, Source& out);
/**
* Executes the BEGIN block, pattern-action blocks, and the END block.
* @return 0 on succes, -1 on failure
*/
virtual int loop ();
/**
* Calls a function
*/
virtual int call (
const char_t* name,
Value* ret,
const Value* args,
size_t nargs
);
/**
* Makes request to abort execution
*/
virtual void stop ();
/** /**
* Adds an ARGV string as long as @a len characters pointed to * Adds an ARGV string as long as @a len characters pointed to
@ -901,7 +901,7 @@ public:
* to a script through ARGV. * to a script through ARGV.
* @return 0 on success, -1 on failure * @return 0 on success, -1 on failure
*/ */
virtual int addArgument ( int addArgument (
const char_t* arg, const char_t* arg,
size_t len size_t len
); );
@ -911,102 +911,117 @@ public:
* make a string added available to a script through ARGV. * make a string added available to a script through ARGV.
* @return 0 on success, -1 on failure * @return 0 on success, -1 on failure
*/ */
virtual int addArgument (const char_t* arg); int addArgument (const char_t* arg);
/** /**
* Deletes all ARGV strings. * Deletes all ARGV strings.
*/ */
virtual void clearArguments (); void clearArguments ();
/** /**
* Adds a intrinsic global variable. * Registers an intrinsic global variable.
* @return integer >= 0 on success, -1 on failure. * @return integer >= 0 on success, -1 on failure.
*/ */
virtual int addGlobal (const char_t* name); int addGlobal (
const char_t* name ///< variable name
);
/** /**
* Deletes a intrinsic global variable. * Unregisters an intrinsic global variable.
* @return 0 on success, -1 on failure.
*/ */
virtual int deleteGlobal (const char_t* name); int deleteGlobal (
const char_t* name ///< variable name
);
/** /**
* Sets the value of a global variable identified by @a id. * Sets the value of a global variable identified by @a id.
* The @a id is either a value returned by Awk::addGlobal() or one of * The @a id is either a value returned by Awk::addGlobal or one of
* Awk::Global enumerations. It is not legal to call this function * Awk::Global enumerators. It is not legal to call this function
* prior to Awk::parse(). * prior to Awk::parse.
* @return 0 on success, -1 on failure * @return 0 on success, -1 on failure
*/ */
virtual int setGlobal (int id, const Value& v); int setGlobal (
/** int id, ///< numeric identifier
* Gets the value of a global riable identified by @a id. const Value& v ///< value
* The @a id is either a value returned by Awk::addGlobal() or one of );
* Awk::Global enumerations. It is not legal to call this function
* prior to Awk::parse().
* @return 0 on success, -1 on failure
*/
virtual int getGlobal (int id, Value& v);
/** /**
* Represents a user-defined intrinsic function. * Gets the value of a global riable identified by @a id.
* The @a id is either a value returned by Awk::addGlobal or one of
* Awk::::Global enumerators. It is not legal to call this function
* prior to Awk::parse.
* @return 0 on success, -1 on failure
*/
int getGlobal (
int id, ///< numeric identifier
Value& v ///< value store
);
/**
* Defines a intrinsic function handler.
*/ */
typedef int (Awk::*FunctionHandler) ( typedef int (Awk::*FunctionHandler) (
Run& run, Value& ret, const Value* args, size_t nargs, Run& run,
const char_t* name, size_t len); Value& ret,
const Value* args,
size_t nargs,
const cstr_t* name
);
/** /**
* Adds a new user-defined intrinsic function. * Adds a new user-defined intrinsic function.
*/ */
virtual int addFunction ( int addFunction (
const char_t* name, size_t minArgs, size_t maxArgs, const char_t* name, size_t minArgs, size_t maxArgs,
FunctionHandler handler); FunctionHandler handler);
/** /**
* Deletes a user-defined intrinsic function * Deletes a user-defined intrinsic function
*/ */
virtual int deleteFunction (const char_t* name); int deleteFunction (const char_t* name);
/*@}*/
/** /**
* Enables the run-time callback * Enables the run-time callback
*/ */
virtual void enableRunCallback (); void enableRunCallback ();
/** /**
* Disables the run-time callback * Disables the run-time callback
*/ */
virtual void disableRunCallback (); void disableRunCallback ();
/** /**
* @name Word Substitution * @name Word Substitution
*/ */
/*@{*/ /*@{*/
virtual int getWord ( int getWord (
const char_t* ow, qse_size_t owl, const char_t* ow, qse_size_t owl,
const char_t** nw, qse_size_t* nwl const char_t** nw, qse_size_t* nwl
) throw (); );
virtual int setWord ( int setWord (
const char_t* ow, const char_t* nw const char_t* ow, const char_t* nw
) throw (); );
virtual int setWord ( int setWord (
const char_t* ow, qse_size_t owl, const char_t* ow, qse_size_t owl,
const char_t* nw, qse_size_t nwl const char_t* nw, qse_size_t nwl
) throw (); );
virtual int unsetWord ( int unsetWord (
const char_t* ow const char_t* ow
) throw (); );
virtual int unsetWord ( int unsetWord (
const char_t* ow, qse_size_t owl const char_t* ow, qse_size_t owl
) throw (); );
virtual int unsetAllWords () throw (); int unsetAllWords ();
/*@}*/ /*@}*/
protected: protected:
virtual int dispatchFunction (Run* run, const char_t* name, size_t len);
/** /**
* @name Pipe I/O handlers * @name Pipe I/O handlers
* Pipe operations are achieved through the following functions. * Pipe operations are achieved through the following functions.
@ -1069,9 +1084,7 @@ protected:
rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod,
char_t* data, size_t count); char_t* data, size_t count);
static int functionHandler ( static int functionHandler (rtx_t* rtx, const cstr_t* name);
rtx_t* rtx, const char_t* name, size_t len);
static void freeFunctionMapValue (map_t* map, void* dptr, size_t dlen);
static int onLoopEnter (rtx_t* run, void* data); static int onLoopEnter (rtx_t* run, void* data);
static void onLoopExit (rtx_t* run, val_t* ret, void* data); static void onLoopExit (rtx_t* run, val_t* ret, void* data);
@ -1083,7 +1096,10 @@ protected:
protected: protected:
awk_t* awk; awk_t* awk;
errstr_t dflerrstr; errstr_t dflerrstr;
errinf_t errinf;
map_t* functionMap; map_t* functionMap;
Source::Data sourceIn; Source::Data sourceIn;
@ -1092,11 +1108,7 @@ protected:
Source* sourceReader; Source* sourceReader;
Source* sourceWriter; Source* sourceWriter;
ErrorNumber errnum; bool runCallback;
size_t errlin;
char_t errmsg[256];
bool runCallback;
struct xstrs_t struct xstrs_t
{ {
@ -1118,7 +1130,9 @@ private:
int init_runctx (); int init_runctx ();
void fini_runctx (); void fini_runctx ();
static const char_t* xerrstr (awk_t* a, errnum_t num) throw (); int dispatch_function (Run* run, const cstr_t* name);
static const char_t* xerrstr (awk_t* a, errnum_t num);
private: private:
Awk (const Awk&); Awk (const Awk&);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: StdAwk.hpp 230 2009-07-13 08:51:23Z hyunghwan.chung $ * $Id: StdAwk.hpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -74,9 +74,9 @@ public:
int open (); int open ();
void close (); void close ();
virtual int addConsoleOutput (const char_t* arg, size_t len); int addConsoleOutput (const char_t* arg, size_t len);
virtual int addConsoleOutput (const char_t* arg); int addConsoleOutput (const char_t* arg);
virtual void clearConsoleOutputs (); void clearConsoleOutputs ();
protected: protected:
// intrinsic functions // intrinsic functions
@ -128,9 +128,9 @@ protected:
int nextConsole (Console& io); int nextConsole (Console& io);
// primitive handlers // primitive handlers
void* allocMem (size_t n) throw (); void* allocMem (size_t n);
void* reallocMem (void* ptr, size_t n) throw (); void* reallocMem (void* ptr, size_t n);
void freeMem (void* ptr) throw (); void freeMem (void* ptr);
real_t pow (real_t x, real_t y); real_t pow (real_t x, real_t y);
int vsprintf (char_t* buf, size_t size, int vsprintf (char_t* buf, size_t size,

View File

@ -1,5 +1,5 @@
/* /*
* $Id: awk.h 232 2009-07-14 08:06:14Z hyunghwan.chung $ * $Id: awk.h 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -254,8 +254,7 @@ typedef int (*qse_awk_sprintf_t) (
*/ */
typedef int (*qse_awk_fnc_fun_t) ( typedef int (*qse_awk_fnc_fun_t) (
qse_awk_rtx_t* rtx, /**< runtime context */ qse_awk_rtx_t* rtx, /**< runtime context */
const qse_char_t* name, /**< function name */ const qse_cstr_t* name /**< function name */
qse_size_t len /**< name length */
); );
/** /**
@ -710,8 +709,7 @@ enum qse_awk_errnum_t
QSE_AWK_ERNEXTEND, /**< 'next' called from END block */ QSE_AWK_ERNEXTEND, /**< 'next' called from END block */
QSE_AWK_ERNEXTFBEG, /**< 'nextfile' called from BEGIN block */ QSE_AWK_ERNEXTFBEG, /**< 'nextfile' called from BEGIN block */
QSE_AWK_ERNEXTFEND, /**< 'nextfile' called from END block */ QSE_AWK_ERNEXTFEND, /**< 'nextfile' called from END block */
QSE_AWK_EFNCUSER, /**< wrong intrinsic function implementation */ QSE_AWK_EFNCIMPL, /**< intrinsic function handler for '${0}' failed */
QSE_AWK_EFNCIMPL, /**< intrinsic function handler failed */
QSE_AWK_EIOUSER, /**< wrong user io handler implementation */ QSE_AWK_EIOUSER, /**< wrong user io handler implementation */
QSE_AWK_EIOIMPL, /**< I/O callback returned an error */ QSE_AWK_EIOIMPL, /**< I/O callback returned an error */
QSE_AWK_EIONMNF, /**< no such I/O name found */ QSE_AWK_EIONMNF, /**< no such I/O name found */
@ -1036,6 +1034,9 @@ void qse_awk_geterror (
const qse_char_t** errmsg const qse_char_t** errmsg
); );
/**
* The qse_awk_seterror() functon sets
*/
void qse_awk_seterror ( void qse_awk_seterror (
qse_awk_t* awk, qse_awk_t* awk,
qse_awk_errnum_t errnum, qse_awk_errnum_t errnum,

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Sed.hpp 191 2009-06-07 13:09:14Z hyunghwan.chung $ * $Id: Sed.hpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -54,7 +54,7 @@ public:
/** /**
* The Sed() function creates an uninitialized stream editor. * The Sed() function creates an uninitialized stream editor.
*/ */
Sed () throw (): sed (QSE_NULL), dflerrstr (QSE_NULL) {} Sed (): sed (QSE_NULL), dflerrstr (QSE_NULL) {}
/** /**
* The ~Sed() function destroys a stream editor. * The ~Sed() function destroys a stream editor.
@ -70,12 +70,12 @@ public:
* ready for subsequent use. * ready for subsequent use.
* @return 0 on success, -1 on failure. * @return 0 on success, -1 on failure.
*/ */
int open () throw (); int open ();
/** /**
* The close() function finalizes a stream editor. * The close() function finalizes a stream editor.
*/ */
void close () throw (); void close ();
/** /**
* The compile() function compiles a null-terminated string pointed * The compile() function compiles a null-terminated string pointed
@ -84,7 +84,7 @@ public:
*/ */
int compile ( int compile (
const char_t* sptr ///< a pointer to a null-terminated string const char_t* sptr ///< a pointer to a null-terminated string
) throw (); );
/** /**
* The compile() function compiles a string pointed to by @a sptr * The compile() function compiles a string pointed to by @a sptr
@ -94,20 +94,20 @@ public:
int compile ( int compile (
const char_t* sptr, ///< a pointer to a string const char_t* sptr, ///< a pointer to a string
size_t slen ///< the number of characters in the string size_t slen ///< the number of characters in the string
) throw (); );
/** /**
* The execute() function executes compiled commands over the IO * The execute() function executes compiled commands over the IO
* streams defined through IO handlers * streams defined through IO handlers
* @return 0 on success, -1 on failure * @return 0 on success, -1 on failure
*/ */
int execute () throw (); int execute ();
/** /**
* The getOption() function gets the current options. * The getOption() function gets the current options.
* @return current option code * @return current option code
*/ */
int getOption () const throw (); int getOption () const;
/** /**
* The setOption() function sets options for a stream editor. * The setOption() function sets options for a stream editor.
@ -115,12 +115,12 @@ public:
*/ */
void setOption ( void setOption (
int opt ///< option code int opt ///< option code
) throw (); );
/** /**
* The getMaxDepth() function gets the maximum processing depth. * The getMaxDepth() function gets the maximum processing depth.
*/ */
size_t getMaxDepth (depth_t id) const throw (); size_t getMaxDepth (depth_t id) const;
/** /**
* The setMaxDepth() function gets the maximum processing depth. * The setMaxDepth() function gets the maximum processing depth.
@ -128,35 +128,28 @@ public:
void setMaxDepth ( void setMaxDepth (
int ids, ///< 0 or a number OR'ed of depth_t values int ids, ///< 0 or a number OR'ed of depth_t values
size_t depth ///< 0 maximum depth size_t depth ///< 0 maximum depth
) throw (); );
/** /**
* The getErrorMessage() function gets the description of the last * The getErrorMessage() function gets the description of the last
* error occurred. It returns an empty string if the stream editor * error occurred. It returns an empty string if the stream editor
* has not been initialized with the open() function. * has not been initialized with the open() function.
*/ */
const char_t* getErrorMessage() const throw (); const char_t* getErrorMessage() const;
/** /**
* The getErrorLine() function gets the number of the line where * The getErrorLine() function gets the number of the line where
* the last error occurred. It returns 0 if the stream editor has * the last error occurred. It returns 0 if the stream editor has
* not been initialized with the open() function. * not been initialized with the open() function.
*/ */
size_t getErrorLine () const throw (); size_t getErrorLine () const;
/** /**
* The getErrorNumber() function gets the number of the last * The getErrorNumber() function gets the number of the last
* error occurred. It returns QSE_SED_ENOERR if the stream editor * error occurred. It returns QSE_SED_ENOERR if the stream editor
* has not been initialized with the open() function. * has not been initialized with the open() function.
*/ */
errnum_t getErrorNumber () const throw (); errnum_t getErrorNumber () const;
/**
* The getConsoleLine() function returns the current line
* number from an input console.
* @return current line number
*/
size_t getConsoleLine () throw ();
/** /**
* The setError() function sets information on an error occurred. * The setError() function sets information on an error occurred.
@ -167,13 +160,20 @@ public:
const cstr_t* args = QSE_NULL ///< strings for formatting an error message const cstr_t* args = QSE_NULL ///< strings for formatting an error message
); );
/**
* The getConsoleLine() function returns the current line
* number from an input console.
* @return current line number
*/
size_t getConsoleLine ();
/** /**
* The setConsoleLine() function changes the current line * The setConsoleLine() function changes the current line
* number from an input console. * number from an input console.
*/ */
void setConsoleLine ( void setConsoleLine (
size_t num ///< a line number size_t num ///< a line number
) throw (); );
protected: protected:
/** /**
@ -194,7 +194,7 @@ protected:
}; };
protected: protected:
IOBase (io_arg_t* arg, Mode mode) throw (): IOBase (io_arg_t* arg, Mode mode):
arg(arg), mode (mode) {} arg(arg), mode (mode) {}
public: public:
@ -204,7 +204,7 @@ protected:
* an assoicated IO handler closes it or changes it with * an assoicated IO handler closes it or changes it with
* another call to setHandle(). * another call to setHandle().
*/ */
const void* getHandle () const throw () const void* getHandle () const
{ {
return arg->handle; return arg->handle;
} }
@ -215,7 +215,7 @@ protected:
* and Sed::openFile(). You can get the handle with the * and Sed::openFile(). You can get the handle with the
* getHandle() function as needed. * getHandle() function as needed.
*/ */
void setHandle (void* handle) throw () void setHandle (void* handle)
{ {
arg->handle = handle; arg->handle = handle;
} }
@ -225,7 +225,7 @@ protected:
* A stream opening function can inspect the mode requested and * A stream opening function can inspect the mode requested and
* open a stream properly * open a stream properly
*/ */
Mode getMode () throw () Mode getMode ()
{ {
return this->mode; return this->mode;
} }
@ -244,7 +244,7 @@ protected:
{ {
protected: protected:
friend class Sed; friend class Sed;
Console (io_arg_t* arg, Mode mode) throw (): Console (io_arg_t* arg, Mode mode):
IOBase (arg, mode) {} IOBase (arg, mode) {}
}; };
@ -256,7 +256,7 @@ protected:
{ {
protected: protected:
friend class Sed; friend class Sed;
File (io_arg_t* arg, Mode mode) throw (): File (io_arg_t* arg, Mode mode):
IOBase (arg, mode) {} IOBase (arg, mode) {}
public: public:
@ -265,7 +265,7 @@ protected:
* You can call this function from the openFile() function * You can call this function from the openFile() function
* to determine a file to open. * to determine a file to open.
*/ */
const char_t* getName () const throw () const char_t* getName () const
{ {
return arg->path; return arg->path;
} }
@ -395,9 +395,9 @@ protected:
errstr_t dflerrstr; errstr_t dflerrstr;
private: private:
static ssize_t xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw (); static ssize_t xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg);
static ssize_t xout (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);
static const char_t* xerrstr (sed_t* s, errnum_t num) throw (); static const char_t* xerrstr (sed_t* s, errnum_t num);
private: private:
Sed (const Sed&); Sed (const Sed&);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: StdSed.hpp 191 2009-06-07 13:09:14Z hyunghwan.chung $ * $Id: StdSed.hpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -33,9 +33,9 @@ QSE_BEGIN_NAMESPACE(QSE)
class StdSed: public Sed class StdSed: public Sed
{ {
protected: protected:
void* allocMem (qse_size_t n) throw (); void* allocMem (qse_size_t n);
void* reallocMem (void* ptr, qse_size_t n) throw (); void* reallocMem (void* ptr, qse_size_t n);
void freeMem (void* ptr) throw (); void freeMem (void* ptr);
int openConsole (Console& io); int openConsole (Console& io);
int closeConsole (Console& io); int closeConsole (Console& io);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Awk.cpp 234 2009-07-14 14:08:48Z hyunghwan.chung $ * $Id: Awk.cpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -227,7 +227,7 @@ void* Awk::Value::operator new (size_t n, Run* run) throw ()
return (char*)ptr+QSE_SIZEOF(run); return (char*)ptr+QSE_SIZEOF(run);
} }
void* Awk::Value::operator new[] (size_t n, Run* run) throw () void* Awk::Value::operator new[] (size_t n, Run* run) throw ()
{ {
void* ptr = qse_awk_rtx_alloc (run->rtx, QSE_SIZEOF(run) + n); void* ptr = qse_awk_rtx_alloc (run->rtx, QSE_SIZEOF(run) + n);
if (ptr == QSE_NULL) return QSE_NULL; if (ptr == QSE_NULL) return QSE_NULL;
@ -237,24 +237,24 @@ void* Awk::Value::operator new[] (size_t n, Run* run) throw ()
} }
#if !defined(__BORLANDC__) #if !defined(__BORLANDC__)
void Awk::Value::operator delete (void* ptr, Run* run) throw () void Awk::Value::operator delete (void* ptr, Run* run)
{ {
qse_awk_rtx_free (run->rtx, (char*)ptr-QSE_SIZEOF(run)); qse_awk_rtx_free (run->rtx, (char*)ptr-QSE_SIZEOF(run));
} }
void Awk::Value::operator delete[] (void* ptr, Run* run) throw () void Awk::Value::operator delete[] (void* ptr, Run* run)
{ {
qse_awk_rtx_free (run->rtx, (char*)ptr-QSE_SIZEOF(run)); qse_awk_rtx_free (run->rtx, (char*)ptr-QSE_SIZEOF(run));
} }
#endif #endif
void Awk::Value::operator delete (void* ptr) throw () void Awk::Value::operator delete (void* ptr)
{ {
void* p = (char*)ptr-QSE_SIZEOF(Run*); void* p = (char*)ptr-QSE_SIZEOF(Run*);
qse_awk_rtx_free ((*(Run**)p)->rtx, p); qse_awk_rtx_free ((*(Run**)p)->rtx, p);
} }
void Awk::Value::operator delete[] (void* ptr) throw () void Awk::Value::operator delete[] (void* ptr)
{ {
void* p = (char*)ptr-QSE_SIZEOF(Run*); void* p = (char*)ptr-QSE_SIZEOF(Run*);
qse_awk_rtx_free ((*(Run**)p)->rtx, p); qse_awk_rtx_free ((*(Run**)p)->rtx, p);
@ -602,7 +602,7 @@ int Awk::Value::setIndexedVal (Run* r, const Index& idx, val_t* v)
{ {
qse_awk_rtx_refdownval (r->rtx, v); qse_awk_rtx_refdownval (r->rtx, v);
qse_awk_rtx_refdownval (r->rtx, map); qse_awk_rtx_refdownval (r->rtx, map);
r->setError (ERR_NOMEM, 0, QSE_NULL, 0); r->setError (ERR_NOMEM);
r->awk->retrieveError (r); r->awk->retrieveError (r);
return -1; return -1;
} }
@ -887,61 +887,40 @@ Awk::Run::operator Awk::rtx_t* () const
return this->rtx; return this->rtx;
} }
void Awk::Run::stop () const void Awk::Run::stop () const
{ {
QSE_ASSERT (this->rtx != QSE_NULL); QSE_ASSERT (this->rtx != QSE_NULL);
qse_awk_rtx_stop (this->rtx); qse_awk_rtx_stop (this->rtx);
} }
bool Awk::Run::isStop () const bool Awk::Run::shouldStop () const
{ {
QSE_ASSERT (this->rtx != QSE_NULL); QSE_ASSERT (this->rtx != QSE_NULL);
return qse_awk_rtx_shouldstop (this->rtx)? true: false; return qse_awk_rtx_shouldstop (this->rtx)? true: false;
} }
Awk::ErrorNumber Awk::Run::errorNumber () const throw () Awk::ErrorNumber Awk::Run::getErrorNumber () const
{ {
QSE_ASSERT (this->rtx != QSE_NULL); QSE_ASSERT (this->rtx != QSE_NULL);
return (ErrorNumber)qse_awk_rtx_geterrnum (this->rtx); return (ErrorNumber)qse_awk_rtx_geterrnum (this->rtx);
} }
Awk::size_t Awk::Run::errorLine () const throw () Awk::size_t Awk::Run::getErrorLine () const
{ {
QSE_ASSERT (this->rtx != QSE_NULL); QSE_ASSERT (this->rtx != QSE_NULL);
return qse_awk_rtx_geterrlin (this->rtx); return qse_awk_rtx_geterrlin (this->rtx);
} }
const Awk::char_t* Awk::Run::errorMessage () const throw () const Awk::char_t* Awk::Run::getErrorMessage () const
{ {
QSE_ASSERT (this->rtx != QSE_NULL); QSE_ASSERT (this->rtx != QSE_NULL);
return qse_awk_rtx_geterrmsg (this->rtx); return qse_awk_rtx_geterrmsg (this->rtx);
} }
void Awk::Run::setError (ErrorNumber code) void Awk::Run::setError (ErrorNumber code, size_t line, const cstr_t* args)
{ {
QSE_ASSERT (this->rtx != QSE_NULL); QSE_ASSERT (this->rtx != QSE_NULL);
qse_awk_rtx_seterror (this->rtx, (errnum_t)code, 0, QSE_NULL); qse_awk_rtx_seterror (this->rtx, (errnum_t)code, line, args);
}
void Awk::Run::setError (ErrorNumber code, size_t line)
{
QSE_ASSERT (this->rtx != QSE_NULL);
qse_awk_rtx_seterror (this->rtx, (errnum_t)code, line, QSE_NULL);
}
void Awk::Run::setError (ErrorNumber code, size_t line, const char_t* arg)
{
QSE_ASSERT (this->rtx != QSE_NULL);
qse_cstr_t x = { arg, qse_strlen(arg) };
qse_awk_rtx_seterror (this->rtx, (errnum_t)code, line, &x);
}
void Awk::Run::setError (
ErrorNumber code, size_t line, const char_t* arg, size_t len)
{
QSE_ASSERT (this->rtx != QSE_NULL);
qse_cstr_t x = { arg, len };
qse_awk_rtx_seterror (this->rtx, (errnum_t)code, line, &x);
} }
void Awk::Run::setErrorWithMessage ( void Awk::Run::setErrorWithMessage (
@ -949,7 +928,7 @@ void Awk::Run::setErrorWithMessage (
{ {
QSE_ASSERT (this->rtx != QSE_NULL); QSE_ASSERT (this->rtx != QSE_NULL);
qse_awk_errinf_t errinf; errinf_t errinf;
errinf.num = (errnum_t)code; errinf.num = (errnum_t)code;
errinf.lin = line; errinf.lin = line;
@ -1013,77 +992,62 @@ int Awk::Run::getGlobal (int id, Value& g) const
// Awk // Awk
////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////
Awk::Awk () throw (): awk (QSE_NULL), functionMap (QSE_NULL), Awk::Awk () : awk (QSE_NULL), functionMap (QSE_NULL),
sourceIn (this, Source::READ), sourceOut (this, Source::WRITE), sourceIn (this, Source::READ), sourceOut (this, Source::WRITE),
errnum (ERR_NOERR), errlin (0), runCallback (false), runCallback (false), runctx (this)
runctx (this)
{ {
this->errmsg[0] = QSE_T('\0'); errinf.num = (errnum_t)ERR_NOERR;
errinf.lin = 0;
errinf.msg[0] = QSE_T('\0');
} }
Awk::operator Awk::awk_t* () const Awk::operator Awk::awk_t* () const
{ {
return this->awk; return this->awk;
} }
const Awk::char_t* Awk::errorString (ErrorNumber num) const throw () const Awk::char_t* Awk::getErrorString (ErrorNumber num) const
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
QSE_ASSERT (dflerrstr != QSE_NULL); QSE_ASSERT (dflerrstr != QSE_NULL);
return dflerrstr (awk, (errnum_t)num); return dflerrstr (awk, (errnum_t)num);
} }
const Awk::char_t* Awk::xerrstr (awk_t* a, errnum_t num) throw () const Awk::char_t* Awk::xerrstr (awk_t* a, errnum_t num)
{ {
Awk* awk = *(Awk**)QSE_XTN(a); Awk* awk = *(Awk**)QSE_XTN(a);
return awk->errorString ((ErrorNumber)num); return awk->getErrorString ((ErrorNumber)num);
} }
Awk::ErrorNumber Awk::errorNumber () const throw () Awk::ErrorNumber Awk::getErrorNumber () const
{ {
return this->errnum; return (ErrorNumber)this->errinf.num;
} }
Awk::size_t Awk::errorLine () const throw () Awk::size_t Awk::getErrorLine () const
{ {
return this->errlin; return this->errinf.lin;
} }
const Awk::char_t* Awk::errorMessage () const throw () const Awk::char_t* Awk::getErrorMessage () const
{ {
return this->errmsg; return this->errinf.msg;
} }
void Awk::setError (ErrorNumber code) void Awk::setError (ErrorNumber code, size_t line, const cstr_t* args)
{
setError (code, 0, QSE_NULL, 0);
}
void Awk::setError (ErrorNumber code, size_t line)
{
setError (code, line, QSE_NULL, 0);
}
void Awk::setError (ErrorNumber code, size_t line, const char_t* arg)
{
setError (code, line, arg, qse_strlen(arg));
}
void Awk::setError (ErrorNumber code, size_t line, const char_t* arg, size_t len)
{ {
if (awk != QSE_NULL) if (awk != QSE_NULL)
{ {
qse_cstr_t x = { arg, len }; qse_awk_seterror (awk, (errnum_t)code, line, args);
qse_awk_seterror (awk, (errnum_t)code, line, &x);
retrieveError (); retrieveError ();
} }
else else
{ {
this->errnum = code; errinf.num = (errnum_t)code;
this->errlin = line; errinf.lin = line;
qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg), qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg),
QSE_T("not ready to set an error message")); QSE_T("not ready to set an error message"));
} }
} }
@ -1092,28 +1056,24 @@ void Awk::setErrorWithMessage (ErrorNumber code, size_t line, const char_t* msg)
{ {
if (awk != QSE_NULL) if (awk != QSE_NULL)
{ {
qse_awk_errinf_t errinf;
errinf.num = (errnum_t)code; errinf.num = (errnum_t)code;
errinf.lin = line; errinf.lin = line;
qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg), msg); qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg), msg);
qse_awk_seterrinf (awk, &errinf); qse_awk_seterrinf (awk, &errinf);
retrieveError ();
} }
else else
{ {
this->errnum = code; errinf.num = (errnum_t)code;
this->errlin = line; errinf.lin = line;
qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg), msg); qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg), msg);
} }
} }
void Awk::clearError () void Awk::clearError ()
{ {
this->errnum = ERR_NOERR; errinf.num = (errnum_t)ERR_NOERR;
this->errlin = 0; errinf.lin = 0;
this->errmsg[0] = QSE_T('\0'); errinf.msg[0] = QSE_T('\0');
} }
void Awk::retrieveError () void Awk::retrieveError ()
@ -1124,29 +1084,25 @@ void Awk::retrieveError ()
} }
else else
{ {
errnum_t num; qse_awk_geterrinf (this->awk, &errinf);
const char_t* msg;
qse_awk_geterror (this->awk, &num, &this->errlin, &msg);
this->errnum = (ErrorNumber)num;
qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg), msg);
} }
} }
void Awk::retrieveError (Run* run) void Awk::retrieveError (Run* run)
{ {
errnum_t num;
const char_t* msg;
QSE_ASSERT (run != QSE_NULL); QSE_ASSERT (run != QSE_NULL);
if (run->rtx == QSE_NULL) return; if (run->rtx == QSE_NULL) return;
qse_awk_rtx_geterrinf (run->rtx, &errinf);
qse_awk_rtx_geterror (run->rtx, &num, &this->errlin, &msg);
this->errnum = (ErrorNumber)num;
qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg), msg);
} }
int Awk::open () static void free_function_map_value (
Awk::map_t* map, void* dptr, Awk::size_t dlen)
{
Awk* awk = *(Awk**) QSE_XTN (map);
qse_awk_free ((Awk::awk_t*)*awk, dptr);
}
int Awk::open ()
{ {
QSE_ASSERT (awk == QSE_NULL && functionMap == QSE_NULL); QSE_ASSERT (awk == QSE_NULL && functionMap == QSE_NULL);
@ -1181,14 +1137,14 @@ int Awk::open ()
*(Awk**)QSE_XTN(functionMap) = this; *(Awk**)QSE_XTN(functionMap) = this;
qse_map_setcopier (functionMap, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE); qse_map_setcopier (functionMap, QSE_MAP_KEY, QSE_MAP_COPIER_INLINE);
qse_map_setfreeer (functionMap, QSE_MAP_VAL, freeFunctionMapValue); qse_map_setfreeer (functionMap, QSE_MAP_VAL, free_function_map_value);
qse_map_setscale (functionMap, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t)); qse_map_setscale (functionMap, QSE_MAP_KEY, QSE_SIZEOF(qse_char_t));
runCallback = false; runCallback = false;
return 0; return 0;
} }
void Awk::close () void Awk::close ()
{ {
fini_runctx (); fini_runctx ();
clearArguments (); clearArguments ();
@ -1209,31 +1165,7 @@ void Awk::close ()
runCallback = false; runCallback = false;
} }
void Awk::setOption (int opt) Awk::Run* Awk::parse (Source& in, Source& out)
{
QSE_ASSERT (awk != QSE_NULL);
qse_awk_setoption (awk, opt);
}
int Awk::getOption () const
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_getoption (awk);
}
void Awk::setMaxDepth (int ids, size_t depth)
{
QSE_ASSERT (awk != QSE_NULL);
qse_awk_setmaxdepth (awk, ids, depth);
}
Awk::size_t Awk::getMaxDepth (int id) const
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_getmaxdepth (awk, id);
}
Awk::Run* Awk::parse (Source& in, Source& out)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
@ -1263,53 +1195,7 @@ Awk::Run* Awk::parse (Source& in, Source& out)
return &runctx; return &runctx;
} }
int Awk::init_runctx () int Awk::loop ()
{
if (runctx.rtx != QSE_NULL) return 0;
qse_awk_rio_t rio;
qse_awk_rcb_t rcb;
rio.pipe = pipeHandler;
rio.file = fileHandler;
rio.console = consoleHandler;
if (runCallback)
{
QSE_MEMSET (&rcb, 0, QSE_SIZEOF(rcb));
rcb.on_loop_enter = onLoopEnter;
rcb.on_loop_exit = onLoopExit;
rcb.on_statement = onStatement;
rcb.udd = &runctx;
}
rtx_t* rtx = qse_awk_rtx_open (
awk, QSE_SIZEOF(rxtn_t), &rio, (qse_cstr_t*)runarg.ptr);
if (rtx == QSE_NULL)
{
retrieveError();
return -1;
}
runctx.rtx = rtx;
rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx);
rxtn->run = &runctx;
if (runCallback) qse_awk_rtx_setrcb (rtx, &rcb);
return 0;
}
void Awk::fini_runctx ()
{
if (runctx.rtx != QSE_NULL)
{
qse_awk_rtx_close (runctx.rtx);
runctx.rtx = QSE_NULL;
}
}
int Awk::loop ()
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
QSE_ASSERT (runctx.rtx != QSE_NULL); QSE_ASSERT (runctx.rtx != QSE_NULL);
@ -1319,7 +1205,9 @@ int Awk::loop ()
return n; return n;
} }
int Awk::call (const char_t* name, Value* ret, const Value* args, size_t nargs) int Awk::call (
const char_t* name, Value* ret,
const Value* args, size_t nargs)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
QSE_ASSERT (runctx.rtx != QSE_NULL); QSE_ASSERT (runctx.rtx != QSE_NULL);
@ -1361,20 +1249,90 @@ int Awk::call (const char_t* name, Value* ret, const Value* args, size_t nargs)
return 0; return 0;
} }
void Awk::stop () void Awk::stop ()
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
qse_awk_stopall (awk); qse_awk_stopall (awk);
} }
int Awk::dispatchFunction (Run* run, const char_t* name, size_t len) int Awk::init_runctx ()
{
if (runctx.rtx != QSE_NULL) return 0;
qse_awk_rio_t rio;
qse_awk_rcb_t rcb;
rio.pipe = pipeHandler;
rio.file = fileHandler;
rio.console = consoleHandler;
if (runCallback)
{
QSE_MEMSET (&rcb, 0, QSE_SIZEOF(rcb));
rcb.on_loop_enter = onLoopEnter;
rcb.on_loop_exit = onLoopExit;
rcb.on_statement = onStatement;
rcb.udd = &runctx;
}
rtx_t* rtx = qse_awk_rtx_open (
awk, QSE_SIZEOF(rxtn_t), &rio, (qse_cstr_t*)runarg.ptr);
if (rtx == QSE_NULL)
{
retrieveError();
return -1;
}
runctx.rtx = rtx;
rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx);
rxtn->run = &runctx;
if (runCallback) qse_awk_rtx_setrcb (rtx, &rcb);
return 0;
}
void Awk::fini_runctx ()
{
if (runctx.rtx != QSE_NULL)
{
qse_awk_rtx_close (runctx.rtx);
runctx.rtx = QSE_NULL;
}
}
int Awk::getOption () const
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_getoption (awk);
}
void Awk::setOption (int opt)
{
QSE_ASSERT (awk != QSE_NULL);
qse_awk_setoption (awk, opt);
}
void Awk::setMaxDepth (int ids, size_t depth)
{
QSE_ASSERT (awk != QSE_NULL);
qse_awk_setmaxdepth (awk, ids, depth);
}
Awk::size_t Awk::getMaxDepth (int id) const
{
QSE_ASSERT (awk != QSE_NULL);
return qse_awk_getmaxdepth (awk, id);
}
int Awk::dispatch_function (Run* run, const cstr_t* name)
{ {
pair_t* pair; pair_t* pair;
pair = qse_map_search (functionMap, name, len); pair = qse_map_search (functionMap, name->ptr, name->len);
if (pair == QSE_NULL) if (pair == QSE_NULL)
{ {
run->setError (ERR_FUNNF, 0, name, len); run->setError (ERR_FUNNF, 0, name);
return -1; return -1;
} }
@ -1391,7 +1349,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
args = new(run) Value[nargs]; args = new(run) Value[nargs];
if (args == QSE_NULL) if (args == QSE_NULL)
{ {
run->setError (ERR_NOMEM, 0, QSE_NULL, 0); run->setError (ERR_NOMEM);
return -1; return -1;
} }
} }
@ -1401,7 +1359,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
val_t* v = qse_awk_rtx_getarg (run->rtx, i); val_t* v = qse_awk_rtx_getarg (run->rtx, i);
if (args[i].setVal (run, v) == -1) if (args[i].setVal (run, v) == -1)
{ {
run->setError (ERR_NOMEM, 0, QSE_NULL, 0); run->setError (ERR_NOMEM);
if (args != buf) delete[] args; if (args != buf) delete[] args;
return -1; return -1;
} }
@ -1409,7 +1367,10 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
Value ret (run); Value ret (run);
int n = (this->*handler) (*run, ret, args, nargs, name, len); int n;
try { n = (this->*handler) (*run, ret, args, nargs, name); }
catch (...) { n = -1; }
if (args != buf) delete[] args; if (args != buf) delete[] args;
@ -1424,7 +1385,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
return 0; return 0;
} }
int Awk::xstrs_t::add (awk_t* awk, const char_t* arg, size_t len) int Awk::xstrs_t::add (awk_t* awk, const char_t* arg, size_t len)
{ {
if (this->len >= this->capa) if (this->len >= this->capa)
{ {
@ -1451,7 +1412,7 @@ int Awk::xstrs_t::add (awk_t* awk, const char_t* arg, size_t len)
return 0; return 0;
} }
void Awk::xstrs_t::clear (awk_t* awk) void Awk::xstrs_t::clear (awk_t* awk)
{ {
if (this->ptr != QSE_NULL) if (this->ptr != QSE_NULL)
{ {
@ -1464,7 +1425,7 @@ void Awk::xstrs_t::clear (awk_t* awk)
} }
} }
int Awk::addArgument (const char_t* arg, size_t len) int Awk::addArgument (const char_t* arg, size_t len)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
int n = runarg.add (awk, arg, len); int n = runarg.add (awk, arg, len);
@ -1472,17 +1433,17 @@ int Awk::addArgument (const char_t* arg, size_t len)
return n; return n;
} }
int Awk::addArgument (const char_t* arg) int Awk::addArgument (const char_t* arg)
{ {
return addArgument (arg, qse_strlen(arg)); return addArgument (arg, qse_strlen(arg));
} }
void Awk::clearArguments () void Awk::clearArguments ()
{ {
runarg.clear (awk); runarg.clear (awk);
} }
int Awk::addGlobal (const char_t* name) int Awk::addGlobal (const char_t* name)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
@ -1491,7 +1452,7 @@ int Awk::addGlobal (const char_t* name)
return n; return n;
} }
int Awk::deleteGlobal (const char_t* name) int Awk::deleteGlobal (const char_t* name)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
int n = qse_awk_delgbl (awk, name, qse_strlen(name)); int n = qse_awk_delgbl (awk, name, qse_strlen(name));
@ -1499,7 +1460,7 @@ int Awk::deleteGlobal (const char_t* name)
return n; return n;
} }
int Awk::setGlobal (int id, const Value& v) int Awk::setGlobal (int id, const Value& v)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
QSE_ASSERT (runctx.rtx != QSE_NULL); QSE_ASSERT (runctx.rtx != QSE_NULL);
@ -1515,7 +1476,7 @@ int Awk::setGlobal (int id, const Value& v)
return n; return n;
} }
int Awk::getGlobal (int id, Value& v) int Awk::getGlobal (int id, Value& v)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
QSE_ASSERT (runctx.rtx != QSE_NULL); QSE_ASSERT (runctx.rtx != QSE_NULL);
@ -1527,7 +1488,7 @@ int Awk::getGlobal (int id, Value& v)
int Awk::addFunction ( int Awk::addFunction (
const char_t* name, size_t minArgs, size_t maxArgs, const char_t* name, size_t minArgs, size_t maxArgs,
FunctionHandler handler) FunctionHandler handler)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
@ -1568,7 +1529,7 @@ int Awk::addFunction (
return 0; return 0;
} }
int Awk::deleteFunction (const char_t* name) int Awk::deleteFunction (const char_t* name)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
@ -1581,49 +1542,49 @@ int Awk::deleteFunction (const char_t* name)
return n; return n;
} }
void Awk::enableRunCallback () void Awk::enableRunCallback ()
{ {
runCallback = true; runCallback = true;
} }
void Awk::disableRunCallback () void Awk::disableRunCallback ()
{ {
runCallback = false; runCallback = false;
} }
int Awk::getWord ( int Awk::getWord (
const char_t* ow, qse_size_t owl, const char_t* ow, qse_size_t owl,
const char_t** nw, qse_size_t* nwl) throw () const char_t** nw, qse_size_t* nwl)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
return qse_awk_getword (awk, ow, owl, nw, nwl); return qse_awk_getword (awk, ow, owl, nw, nwl);
} }
int Awk::setWord (const char_t* ow, const char_t* nw) throw () int Awk::setWord (const char_t* ow, const char_t* nw)
{ {
return setWord (ow, qse_strlen(ow), nw, qse_strlen(nw)); return setWord (ow, qse_strlen(ow), nw, qse_strlen(nw));
} }
int Awk::setWord ( int Awk::setWord (
const char_t* ow, qse_size_t owl, const char_t* ow, qse_size_t owl,
const char_t* nw, qse_size_t nwl) throw () const char_t* nw, qse_size_t nwl)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
return qse_awk_setword (awk, ow, owl, nw, nwl); return qse_awk_setword (awk, ow, owl, nw, nwl);
} }
int Awk::unsetWord (const char_t* ow) throw () int Awk::unsetWord (const char_t* ow)
{ {
return unsetWord (ow, qse_strlen(ow)); return unsetWord (ow, qse_strlen(ow));
} }
int Awk::unsetWord (const char_t* ow, qse_size_t owl) throw () int Awk::unsetWord (const char_t* ow, qse_size_t owl)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
return qse_awk_setword (awk, ow, owl, QSE_NULL, 0); return qse_awk_setword (awk, ow, owl, QSE_NULL, 0);
} }
int Awk::unsetAllWords () throw () int Awk::unsetAllWords ()
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
return qse_awk_setword (awk, QSE_NULL, 0, QSE_NULL, 0); return qse_awk_setword (awk, QSE_NULL, 0, QSE_NULL, 0);
@ -1690,26 +1651,31 @@ Awk::ssize_t Awk::pipeHandler (
Pipe pipe (rxtn->run, riod); Pipe pipe (rxtn->run, riod);
switch (cmd) try
{ {
case QSE_AWK_RIO_OPEN: switch (cmd)
return awk->openPipe (pipe); {
case QSE_AWK_RIO_CLOSE: case QSE_AWK_RIO_OPEN:
return awk->closePipe (pipe); return awk->openPipe (pipe);
case QSE_AWK_RIO_CLOSE:
return awk->closePipe (pipe);
case QSE_AWK_RIO_READ: case QSE_AWK_RIO_READ:
return awk->readPipe (pipe, data, count); return awk->readPipe (pipe, data, count);
case QSE_AWK_RIO_WRITE: case QSE_AWK_RIO_WRITE:
return awk->writePipe (pipe, data, count); return awk->writePipe (pipe, data, count);
case QSE_AWK_RIO_FLUSH: case QSE_AWK_RIO_FLUSH:
return awk->flushPipe (pipe); return awk->flushPipe (pipe);
case QSE_AWK_RIO_NEXT: default:
return -1; return -1;
}
}
catch (...)
{
return -1;
} }
return -1;
} }
Awk::ssize_t Awk::fileHandler ( Awk::ssize_t Awk::fileHandler (
@ -1723,26 +1689,31 @@ Awk::ssize_t Awk::fileHandler (
File file (rxtn->run, riod); File file (rxtn->run, riod);
switch (cmd) try
{ {
case QSE_AWK_RIO_OPEN: switch (cmd)
return awk->openFile (file); {
case QSE_AWK_RIO_CLOSE: case QSE_AWK_RIO_OPEN:
return awk->closeFile (file); return awk->openFile (file);
case QSE_AWK_RIO_CLOSE:
return awk->closeFile (file);
case QSE_AWK_RIO_READ: case QSE_AWK_RIO_READ:
return awk->readFile (file, data, count); return awk->readFile (file, data, count);
case QSE_AWK_RIO_WRITE: case QSE_AWK_RIO_WRITE:
return awk->writeFile (file, data, count); return awk->writeFile (file, data, count);
case QSE_AWK_RIO_FLUSH: case QSE_AWK_RIO_FLUSH:
return awk->flushFile (file); return awk->flushFile (file);
case QSE_AWK_RIO_NEXT: default:
return -1; return -1;
}
}
catch (...)
{
return -1;
} }
return -1;
} }
Awk::ssize_t Awk::consoleHandler ( Awk::ssize_t Awk::consoleHandler (
@ -1756,39 +1727,41 @@ Awk::ssize_t Awk::consoleHandler (
Console console (rxtn->run, riod); Console console (rxtn->run, riod);
switch (cmd) try
{ {
case QSE_AWK_RIO_OPEN: switch (cmd)
return awk->openConsole (console); {
case QSE_AWK_RIO_CLOSE: case QSE_AWK_RIO_OPEN:
return awk->closeConsole (console); return awk->openConsole (console);
case QSE_AWK_RIO_CLOSE:
return awk->closeConsole (console);
case QSE_AWK_RIO_READ: case QSE_AWK_RIO_READ:
return awk->readConsole (console, data, count); return awk->readConsole (console, data, count);
case QSE_AWK_RIO_WRITE: case QSE_AWK_RIO_WRITE:
return awk->writeConsole (console, data, count); return awk->writeConsole (console, data, count);
case QSE_AWK_RIO_FLUSH: case QSE_AWK_RIO_FLUSH:
return awk->flushConsole (console); return awk->flushConsole (console);
case QSE_AWK_RIO_NEXT: case QSE_AWK_RIO_NEXT:
return awk->nextConsole (console); return awk->nextConsole (console);
default:
return -1;
}
}
catch (...)
{
return -1;
} }
return -1;
} }
int Awk::functionHandler (rtx_t* rtx, const char_t* name, size_t len) int Awk::functionHandler (rtx_t* rtx, const cstr_t* name)
{ {
rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx); rxtn_t* rxtn = (rxtn_t*) QSE_XTN (rtx);
return rxtn->run->awk->dispatchFunction (rxtn->run, name, len); return rxtn->run->awk->dispatch_function (rxtn->run, name);
} }
void Awk::freeFunctionMapValue (map_t* map, void* dptr, size_t dlen)
{
Awk* awk = *(Awk**) QSE_XTN (map);
qse_awk_free (awk->awk, dptr);
}
int Awk::onLoopEnter (rtx_t* rtx, void* data) int Awk::onLoopEnter (rtx_t* rtx, void* data)
{ {
Run* run = (Run*)data; Run* run = (Run*)data;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: StdAwk.cpp 234 2009-07-14 14:08:48Z hyunghwan.chung $ * $Id: StdAwk.cpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -48,7 +48,7 @@ QSE_BEGIN_NAMESPACE(QSE)
} \ } \
} while (0) } while (0)
int StdAwk::open () int StdAwk::open ()
{ {
int n = Awk::open (); int n = Awk::open ();
if (n == -1) return n; if (n == -1) return n;
@ -75,7 +75,7 @@ int StdAwk::open ()
return 0; return 0;
} }
void StdAwk::close () void StdAwk::close ()
{ {
clearConsoleOutputs (); clearConsoleOutputs ();
Awk::close (); Awk::close ();
@ -391,7 +391,7 @@ int StdAwk::flushFile (File& io)
return qse_fio_flush ((qse_fio_t*)io.getHandle()); return qse_fio_flush ((qse_fio_t*)io.getHandle());
} }
int StdAwk::addConsoleOutput (const char_t* arg, size_t len) int StdAwk::addConsoleOutput (const char_t* arg, size_t len)
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
int n = ofile.add (awk, arg, len); int n = ofile.add (awk, arg, len);
@ -399,12 +399,12 @@ int StdAwk::addConsoleOutput (const char_t* arg, size_t len)
return n; return n;
} }
int StdAwk::addConsoleOutput (const char_t* arg) int StdAwk::addConsoleOutput (const char_t* arg)
{ {
return addConsoleOutput (arg, qse_strlen(arg)); return addConsoleOutput (arg, qse_strlen(arg));
} }
void StdAwk::clearConsoleOutputs () void StdAwk::clearConsoleOutputs ()
{ {
ofile.clear (awk); ofile.clear (awk);
} }
@ -462,7 +462,14 @@ int StdAwk::open_console_in (Console& io)
return 0; return 0;
} }
// TODO: need to check for '\0' contained??? if (qse_strlen(file) != runarg.ptr[runarg_index].len)
{
cstr_t arg;
arg.ptr = file;
arg.len = qse_strlen (arg.ptr);
((Run*)io)->setError (ERR_IONMNL, 0, &arg);
return -1;
}
/* handle special case when ARGV[x] has been altered. /* handle special case when ARGV[x] has been altered.
* so from here down, the file name gotten from * so from here down, the file name gotten from
@ -506,7 +513,10 @@ int StdAwk::open_console_in (Console& io)
if (qse_strlen(out.u.cpldup.ptr) < out.u.cpldup.len) if (qse_strlen(out.u.cpldup.ptr) < out.u.cpldup.len)
{ {
/* the name contains one or more '\0' */ /* the name contains one or more '\0' */
((Run*)io)->setError (ERR_IONMNL, 0, out.u.cpldup.ptr); cstr_t arg;
arg.ptr = out.u.cpldup.ptr;
arg.len = qse_strlen (arg.ptr);
((Run*)io)->setError (ERR_IONMNL, 0, &arg);
qse_awk_rtx_free (rtx, out.u.cpldup.ptr); qse_awk_rtx_free (rtx, out.u.cpldup.ptr);
return -1; return -1;
} }
@ -524,7 +534,10 @@ int StdAwk::open_console_in (Console& io)
rtx->awk->mmgr, 0, file, QSE_SIO_READ); rtx->awk->mmgr, 0, file, QSE_SIO_READ);
if (sio == QSE_NULL) if (sio == QSE_NULL)
{ {
((Run*)io)->setError (ERR_OPEN, 0, file); cstr_t arg;
arg.ptr = file;
arg.len = qse_strlen (arg.ptr);
((Run*)io)->setError (ERR_OPEN, 0, &arg);
qse_awk_rtx_free (rtx, out.u.cpldup.ptr); qse_awk_rtx_free (rtx, out.u.cpldup.ptr);
return -1; return -1;
} }
@ -581,7 +594,14 @@ int StdAwk::open_console_out (Console& io)
return 0; return 0;
} }
// TODO: need to check for '\0' contained??? if (qse_strlen(file) != ofile.ptr[ofile_index].len)
{
cstr_t arg;
arg.ptr = file;
arg.len = qse_strlen (arg.ptr);
((Run*)io)->setError (ERR_IONMNL, 0, &arg);
return -1;
}
if (file[0] == QSE_T('-') && file[1] == QSE_T('\0')) if (file[0] == QSE_T('-') && file[1] == QSE_T('\0'))
{ {
@ -594,7 +614,10 @@ int StdAwk::open_console_out (Console& io)
rtx->awk->mmgr, 0, file, QSE_SIO_READ); rtx->awk->mmgr, 0, file, QSE_SIO_READ);
if (sio == QSE_NULL) if (sio == QSE_NULL)
{ {
((Run*)io)->setError (ERR_OPEN, 0, file); cstr_t arg;
arg.ptr = file;
arg.len = qse_strlen (arg.ptr);
((Run*)io)->setError (ERR_OPEN, 0, &arg);
return -1; return -1;
} }
} }
@ -725,17 +748,17 @@ int StdAwk::nextConsole (Console& io)
} }
// memory allocation primitives // memory allocation primitives
void* StdAwk::allocMem (size_t n) throw () void* StdAwk::allocMem (size_t n)
{ {
return ::malloc (n); return ::malloc (n);
} }
void* StdAwk::reallocMem (void* ptr, size_t n) throw () void* StdAwk::reallocMem (void* ptr, size_t n)
{ {
return ::realloc (ptr, n); return ::realloc (ptr, n);
} }
void StdAwk::freeMem (void* ptr) throw () void StdAwk::freeMem (void* ptr)
{ {
::free (ptr); ::free (ptr);
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: err.c 232 2009-07-14 08:06:14Z hyunghwan.chung $ * $Id: err.c 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -134,8 +134,7 @@ const qse_char_t* qse_awk_dflerrstr (qse_awk_t* awk, qse_awk_errnum_t errnum)
QSE_T("'next' called from END block"), QSE_T("'next' called from END block"),
QSE_T("'nextfile' called from BEGIN block"), QSE_T("'nextfile' called from BEGIN block"),
QSE_T("'nextfile' called from END block"), QSE_T("'nextfile' called from END block"),
QSE_T("wrong implementation of intrinsic function handler"), QSE_T("intrinsic function handler for '${0}' failed"),
QSE_T("intrinsic function handler returned an error"),
QSE_T("wrong implementation of user-defined io handler"), QSE_T("wrong implementation of user-defined io handler"),
QSE_T("I/O handler returned an error"), QSE_T("I/O handler returned an error"),
QSE_T("no such I/O name found"), QSE_T("no such I/O name found"),

View File

@ -1,5 +1,5 @@
/* /*
* $Id: fnc.c 213 2009-06-26 13:05:19Z hyunghwan.chung $ * $Id: fnc.c 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -18,18 +18,18 @@
#include "awk.h" #include "awk.h"
static int fnc_close (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_close (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_fflush (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_fflush (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_index (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_index (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_length (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_length (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_substr (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_substr (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_split (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_split (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_tolower (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_tolower (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_toupper (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_toupper (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_gsub (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_gsub (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_sub (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_sub (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_match (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_match (qse_awk_rtx_t*, const qse_cstr_t*);
static int fnc_sprintf (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); static int fnc_sprintf (qse_awk_rtx_t*, const qse_cstr_t*);
#undef MAX #undef MAX
#define MAX QSE_TYPE_UNSIGNED_MAX(qse_size_t) #define MAX QSE_TYPE_UNSIGNED_MAX(qse_size_t)
@ -227,8 +227,7 @@ qse_awk_fnc_t* qse_awk_getfnc (
return fnc; return fnc;
} }
static int fnc_close ( static int fnc_close (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* v, * a0; qse_awk_val_t* v, * a0;
@ -334,8 +333,7 @@ static int flush_io (
return n; return n;
} }
static int fnc_fflush ( static int fnc_fflush (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0; qse_awk_val_t* a0;
@ -413,8 +411,7 @@ static int fnc_fflush (
return 0; return 0;
} }
static int fnc_index ( static int fnc_index (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0, * a1; qse_awk_val_t* a0, * a1;
@ -472,8 +469,7 @@ static int fnc_index (
return 0; return 0;
} }
static int fnc_length ( static int fnc_length (qse_awk_rtx_t* rtx, const qse_cstr_t* fnm)
qse_awk_rtx_t* rtx, const qse_char_t* fnm, qse_size_t fnl)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* v; qse_awk_val_t* v;
@ -514,8 +510,7 @@ static int fnc_length (
return 0; return 0;
} }
static int fnc_substr ( static int fnc_substr (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0, * a1, * a2, * r; qse_awk_val_t* a0, * a1, * a2, * r;
@ -587,8 +582,7 @@ static int fnc_substr (
return 0; return 0;
} }
static int fnc_split ( static int fnc_split (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0, * a1, * a2, * t1, * t2, ** a1_ref; qse_awk_val_t* a0, * a1, * a2, * t1, * t2, ** a1_ref;
@ -839,8 +833,7 @@ static int fnc_split (
return 0; return 0;
} }
static int fnc_tolower ( static int fnc_tolower (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_char_t* str; qse_char_t* str;
@ -878,8 +871,7 @@ static int fnc_tolower (
return 0; return 0;
} }
static int fnc_toupper ( static int fnc_toupper (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_char_t* str; qse_char_t* str;
@ -1243,20 +1235,17 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
return 0; return 0;
} }
static int fnc_gsub ( static int fnc_gsub (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
return __substitute (run, 0); return __substitute (run, 0);
} }
static int fnc_sub ( static int fnc_sub (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
return __substitute (run, 1); return __substitute (run, 1);
} }
static int fnc_match ( static int fnc_match (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0, * a1; qse_awk_val_t* a0, * a1;
@ -1372,8 +1361,7 @@ static int fnc_match (
return 0; return 0;
} }
static int fnc_sprintf ( static int fnc_sprintf (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0; qse_awk_val_t* a0;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: run.c 232 2009-07-14 08:06:14Z hyunghwan.chung $ * $Id: run.c 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -5701,8 +5701,8 @@ static qse_awk_val_t* __eval_call (
* qse_awk_setword has been used */ * qse_awk_setword has been used */
n = call->what.fnc.handler ( n = call->what.fnc.handler (
run, run,
call->what.fnc.oname.ptr, xstr_to_cstr(&call->what.fnc.oname)
call->what.fnc.oname.len); );
if (n <= -1) if (n <= -1)
{ {
@ -5712,7 +5712,9 @@ static qse_awk_val_t* __eval_call (
* fix it */ * fix it */
qse_awk_rtx_seterror ( qse_awk_rtx_seterror (
run, QSE_AWK_EFNCIMPL, run, QSE_AWK_EFNCIMPL,
nde->line, QSE_NULL); nde->line,
xstr_to_cstr(&call->what.fnc.oname)
);
} }
else else
{ {

View File

@ -1,5 +1,5 @@
/* /*
* $Id: std.c 224 2009-07-07 13:05:10Z hyunghwan.chung $ * $Id: std.c 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -1014,7 +1014,7 @@ enum
}; };
static int fnc_math_1 ( static int fnc_math_1 (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl, qse_awk_rtx_t* run, const qse_cstr_t* fnm,
int type, void* f) int type, void* f)
{ {
qse_size_t nargs; qse_size_t nargs;
@ -1063,7 +1063,7 @@ static int fnc_math_1 (
} }
static int fnc_math_2 ( static int fnc_math_2 (
qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl, int type, void* f) qse_awk_rtx_t* run, const qse_cstr_t* fnm, int type, void* f)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0, * a1; qse_awk_val_t* a0, * a1;
@ -1115,10 +1115,10 @@ static int fnc_math_2 (
return 0; return 0;
} }
static int fnc_sin (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_sin (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
return fnc_math_1 ( return fnc_math_1 (
run, fnm, fnl, run, fnm,
#if defined(HAVE_SINL) #if defined(HAVE_SINL)
FNC_MATH_LD, (void*)sinl FNC_MATH_LD, (void*)sinl
#elif defined(HAVE_SIN) #elif defined(HAVE_SIN)
@ -1131,10 +1131,10 @@ static int fnc_sin (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
); );
} }
static int fnc_cos (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_cos (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
return fnc_math_1 ( return fnc_math_1 (
run, fnm, fnl, run, fnm,
#if defined(HAVE_COSL) #if defined(HAVE_COSL)
FNC_MATH_LD, (void*)cosl FNC_MATH_LD, (void*)cosl
#elif defined(HAVE_COS) #elif defined(HAVE_COS)
@ -1147,10 +1147,10 @@ static int fnc_cos (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
); );
} }
static int fnc_tan (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_tan (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
return fnc_math_1 ( return fnc_math_1 (
run, fnm, fnl, run, fnm,
#if defined(HAVE_TANL) #if defined(HAVE_TANL)
FNC_MATH_LD, (void*)tanl FNC_MATH_LD, (void*)tanl
#elif defined(HAVE_TAN) #elif defined(HAVE_TAN)
@ -1163,10 +1163,10 @@ static int fnc_tan (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
); );
} }
static int fnc_atan (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_atan (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
return fnc_math_1 ( return fnc_math_1 (
run, fnm, fnl, run, fnm,
#if defined(HAVE_ATANL) #if defined(HAVE_ATANL)
FNC_MATH_LD, (void*)atanl FNC_MATH_LD, (void*)atanl
#elif defined(HAVE_ATAN) #elif defined(HAVE_ATAN)
@ -1179,10 +1179,10 @@ static int fnc_atan (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
); );
} }
static int fnc_atan2 (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_atan2 (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
return fnc_math_2 ( return fnc_math_2 (
run, fnm, fnl, run, fnm,
#if defined(HAVE_ATAN2L) #if defined(HAVE_ATAN2L)
FNC_MATH_LD, (void*)atan2l FNC_MATH_LD, (void*)atan2l
#elif defined(HAVE_ATAN2) #elif defined(HAVE_ATAN2)
@ -1195,10 +1195,10 @@ static int fnc_atan2 (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
); );
} }
static int fnc_log (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_log (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
return fnc_math_1 ( return fnc_math_1 (
run, fnm, fnl, run, fnm,
#if defined(HAVE_LOGL) #if defined(HAVE_LOGL)
FNC_MATH_LD, (void*)logl FNC_MATH_LD, (void*)logl
#elif defined(HAVE_LOG) #elif defined(HAVE_LOG)
@ -1211,10 +1211,10 @@ static int fnc_log (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
); );
} }
static int fnc_exp (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_exp (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
return fnc_math_1 ( return fnc_math_1 (
run, fnm, fnl, run, fnm,
#if defined(HAVE_EXPL) #if defined(HAVE_EXPL)
FNC_MATH_LD, (void*)expl FNC_MATH_LD, (void*)expl
#elif defined(HAVE_EXP) #elif defined(HAVE_EXP)
@ -1227,10 +1227,10 @@ static int fnc_exp (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
); );
} }
static int fnc_sqrt (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_sqrt (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
return fnc_math_1 ( return fnc_math_1 (
run, fnm, fnl, run, fnm,
#if defined(HAVE_SQRTL) #if defined(HAVE_SQRTL)
FNC_MATH_LD, (void*)sqrtl FNC_MATH_LD, (void*)sqrtl
#elif defined(HAVE_SQRT) #elif defined(HAVE_SQRT)
@ -1243,7 +1243,7 @@ static int fnc_sqrt (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
); );
} }
static int fnc_int (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_int (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0; qse_awk_val_t* a0;
@ -1272,7 +1272,7 @@ static int fnc_int (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
return 0; return 0;
} }
static int fnc_rand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_rand (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
qse_awk_val_t* r; qse_awk_val_t* r;
@ -1294,7 +1294,7 @@ static int fnc_rand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
return 0; return 0;
} }
static int fnc_srand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_srand (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0; qse_awk_val_t* a0;
@ -1342,7 +1342,7 @@ static int fnc_srand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
return 0; return 0;
} }
static int fnc_system (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) static int fnc_system (qse_awk_rtx_t* run, const qse_cstr_t* fnm)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* v; qse_awk_val_t* v;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: tree.h 75 2009-02-22 14:10:34Z hyunghwan.chung $ * $Id: tree.h 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -286,8 +286,7 @@ struct qse_awk_nde_call_t
const qse_char_t* spec; const qse_char_t* spec;
} arg; } arg;
int (*handler) ( qse_awk_fnc_fun_t handler;
qse_awk_rtx_t*, const qse_char_t*, qse_size_t);
} fnc; } fnc;
} what; } what;
qse_awk_nde_t* args; qse_awk_nde_t* args;

View File

@ -1,5 +1,5 @@
/* /*
* $Id: Sed.cpp 191 2009-06-07 13:09:14Z hyunghwan.chung $ * $Id: Sed.cpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -23,7 +23,7 @@
QSE_BEGIN_NAMESPACE(QSE) QSE_BEGIN_NAMESPACE(QSE)
///////////////////////////////// /////////////////////////////////
int Sed::open () throw () int Sed::open ()
{ {
sed = qse_sed_open (this, QSE_SIZEOF(Sed*)); sed = qse_sed_open (this, QSE_SIZEOF(Sed*));
if (sed == QSE_NULL) return -1; if (sed == QSE_NULL) return -1;
@ -35,7 +35,7 @@ int Sed::open () throw ()
return 0; return 0;
} }
void Sed::close () throw() void Sed::close ()
{ {
if (sed != QSE_NULL) if (sed != QSE_NULL)
{ {
@ -44,59 +44,59 @@ void Sed::close () throw()
} }
} }
int Sed::compile (const char_t* sptr) throw () int Sed::compile (const char_t* sptr)
{ {
QSE_ASSERT (sed != QSE_NULL); QSE_ASSERT (sed != QSE_NULL);
return qse_sed_comp (sed, sptr, qse_strlen(sptr)); return qse_sed_comp (sed, sptr, qse_strlen(sptr));
} }
int Sed::compile (const char_t* sptr, size_t slen) throw () int Sed::compile (const char_t* sptr, size_t slen)
{ {
QSE_ASSERT (sed != QSE_NULL); QSE_ASSERT (sed != QSE_NULL);
return qse_sed_comp (sed, sptr, slen); return qse_sed_comp (sed, sptr, slen);
} }
int Sed::execute () throw () int Sed::execute ()
{ {
QSE_ASSERT (sed != QSE_NULL); QSE_ASSERT (sed != QSE_NULL);
return qse_sed_exec (sed, xin, xout); return qse_sed_exec (sed, xin, xout);
} }
int Sed::getOption() const throw () int Sed::getOption() const
{ {
QSE_ASSERT (sed != QSE_NULL); QSE_ASSERT (sed != QSE_NULL);
return qse_sed_getoption (sed); return qse_sed_getoption (sed);
} }
void Sed::setOption (int opt) throw () void Sed::setOption (int opt)
{ {
QSE_ASSERT (sed != QSE_NULL); QSE_ASSERT (sed != QSE_NULL);
qse_sed_setoption (sed, opt); qse_sed_setoption (sed, opt);
} }
Sed::size_t Sed::getMaxDepth (depth_t id) const throw () Sed::size_t Sed::getMaxDepth (depth_t id) const
{ {
QSE_ASSERT (sed != QSE_NULL); QSE_ASSERT (sed != QSE_NULL);
return qse_sed_getmaxdepth (sed, id); return qse_sed_getmaxdepth (sed, id);
} }
void Sed::setMaxDepth (int ids, size_t depth) throw () void Sed::setMaxDepth (int ids, size_t depth)
{ {
QSE_ASSERT (sed != QSE_NULL); QSE_ASSERT (sed != QSE_NULL);
qse_sed_setmaxdepth (sed, ids, depth); qse_sed_setmaxdepth (sed, ids, depth);
} }
const Sed::char_t* Sed::getErrorMessage () const throw () const Sed::char_t* Sed::getErrorMessage () const
{ {
return (sed == QSE_NULL)? QSE_T(""): qse_sed_geterrmsg (sed); return (sed == QSE_NULL)? QSE_T(""): qse_sed_geterrmsg (sed);
} }
Sed::size_t Sed::getErrorLine () const throw () Sed::size_t Sed::getErrorLine () const
{ {
return (sed == QSE_NULL)? 0: qse_sed_geterrlin (sed); return (sed == QSE_NULL)? 0: qse_sed_geterrlin (sed);
} }
Sed::errnum_t Sed::getErrorNumber () const throw () Sed::errnum_t Sed::getErrorNumber () const
{ {
return (sed == QSE_NULL)? QSE_SED_ENOERR: qse_sed_geterrnum (sed); return (sed == QSE_NULL)? QSE_SED_ENOERR: qse_sed_geterrnum (sed);
} }
@ -107,19 +107,19 @@ void Sed::setError (errnum_t err, size_t lin, const cstr_t* args)
qse_sed_seterror (sed, err, lin, args); qse_sed_seterror (sed, err, lin, args);
} }
Sed::size_t Sed::getConsoleLine () throw () Sed::size_t Sed::getConsoleLine ()
{ {
QSE_ASSERT (sed != QSE_NULL); QSE_ASSERT (sed != QSE_NULL);
return qse_sed_getlinnum (sed); return qse_sed_getlinnum (sed);
} }
void Sed::setConsoleLine (size_t num) throw () void Sed::setConsoleLine (size_t num)
{ {
QSE_ASSERT (sed != QSE_NULL); QSE_ASSERT (sed != QSE_NULL);
qse_sed_setlinnum (sed, num); qse_sed_setlinnum (sed, num);
} }
Sed::ssize_t Sed::xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw () Sed::ssize_t Sed::xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg)
{ {
Sed* sed = *(Sed**)QSE_XTN(s); Sed* sed = *(Sed**)QSE_XTN(s);
@ -173,7 +173,7 @@ Sed::ssize_t Sed::xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw ()
} }
} }
Sed::ssize_t Sed::xout (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw () Sed::ssize_t Sed::xout (sed_t* s, io_cmd_t cmd, io_arg_t* arg)
{ {
Sed* sed = *(Sed**)QSE_XTN(s); Sed* sed = *(Sed**)QSE_XTN(s);
@ -233,7 +233,7 @@ const Sed::char_t* Sed::getErrorString (errnum_t num) const
return dflerrstr (sed, num); return dflerrstr (sed, num);
} }
const Sed::char_t* Sed::xerrstr (sed_t* s, errnum_t num) throw () const Sed::char_t* Sed::xerrstr (sed_t* s, errnum_t num)
{ {
Sed* sed = *(Sed**)QSE_XTN(s); Sed* sed = *(Sed**)QSE_XTN(s);
try try

View File

@ -1,5 +1,5 @@
/* /*
* $Id: StdSed.cpp 191 2009-06-07 13:09:14Z hyunghwan.chung $ * $Id: StdSed.cpp 235 2009-07-15 10:43:31Z hyunghwan.chung $
* *
Copyright 2006-2009 Chung, Hyung-Hwan. Copyright 2006-2009 Chung, Hyung-Hwan.
@ -25,17 +25,17 @@
QSE_BEGIN_NAMESPACE(QSE) QSE_BEGIN_NAMESPACE(QSE)
///////////////////////////////// /////////////////////////////////
void* StdSed::allocMem (qse_size_t n) throw () void* StdSed::allocMem (qse_size_t n)
{ {
return ::malloc (n); return ::malloc (n);
} }
void* StdSed::reallocMem (void* ptr, qse_size_t n) throw () void* StdSed::reallocMem (void* ptr, qse_size_t n)
{ {
return ::realloc (ptr, n); return ::realloc (ptr, n);
} }
void StdSed::freeMem (void* ptr) throw () void StdSed::freeMem (void* ptr)
{ {
::free (ptr); ::free (ptr);
} }

View File

@ -1352,7 +1352,7 @@ BEGIN {
printf ("%s\n",10.34); printf ("%s\n",10.34);
} }
ERROR: CODE [111] LINE [3] recursion detected in format conversion ERROR: CODE [110] LINE [3] recursion detected in format conversion
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
../../cmd/awk/qseawk --newline=on -o- -f lang-014.awk </dev/stdin 2>&1 ../../cmd/awk/qseawk --newline=on -o- -f lang-014.awk </dev/stdin 2>&1
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------

View File

@ -11,15 +11,15 @@ awk03_SOURCES = awk03.c
awk04_SOURCES = awk04.c awk04_SOURCES = awk04.c
if ENABLE_CXX if ENABLE_CXX
bin_PROGRAMS += awk05 awk06 awk07 awk08 bin_PROGRAMS += awk05 awk06 awk07 #awk08
awk05_SOURCES = awk05.cpp awk05_SOURCES = awk05.cpp
awk06_SOURCES = awk06.cpp awk06_SOURCES = awk06.cpp
awk07_SOURCES = awk07.cpp awk07_SOURCES = awk07.cpp
awk08_SOURCES = awk08.cpp #awk08_SOURCES = awk08.cpp
awk05_LDADD = -lqseawk++ $(LDADD) awk05_LDADD = -lqseawk++ $(LDADD)
awk06_LDADD = -lqseawk++ $(LDADD) awk06_LDADD = -lqseawk++ $(LDADD)
awk07_LDADD = -lqseawk++ $(LDADD) awk07_LDADD = -lqseawk++ $(LDADD)
awk08_LDADD = -lqseawk++ $(LDADD) #awk08_LDADD = -lqseawk++ $(LDADD)
endif endif

View File

@ -34,7 +34,7 @@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
bin_PROGRAMS = awk01$(EXEEXT) awk02$(EXEEXT) awk03$(EXEEXT) \ bin_PROGRAMS = awk01$(EXEEXT) awk02$(EXEEXT) awk03$(EXEEXT) \
awk04$(EXEEXT) $(am__EXEEXT_1) awk04$(EXEEXT) $(am__EXEEXT_1)
@ENABLE_CXX_TRUE@am__append_1 = awk05 awk06 awk07 awk08 @ENABLE_CXX_TRUE@am__append_1 = awk05 awk06 awk07 #awk08
subdir = samples/awk subdir = samples/awk
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@ -49,7 +49,7 @@ mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/include/qse/config.h CONFIG_HEADER = $(top_builddir)/include/qse/config.h
CONFIG_CLEAN_FILES = CONFIG_CLEAN_FILES =
@ENABLE_CXX_TRUE@am__EXEEXT_1 = awk05$(EXEEXT) awk06$(EXEEXT) \ @ENABLE_CXX_TRUE@am__EXEEXT_1 = awk05$(EXEEXT) awk06$(EXEEXT) \
@ENABLE_CXX_TRUE@ awk07$(EXEEXT) awk08$(EXEEXT) @ENABLE_CXX_TRUE@ awk07$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)" am__installdirs = "$(DESTDIR)$(bindir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS) PROGRAMS = $(bin_PROGRAMS)
@ -83,10 +83,6 @@ am__awk07_SOURCES_DIST = awk07.cpp
@ENABLE_CXX_TRUE@am_awk07_OBJECTS = awk07.$(OBJEXT) @ENABLE_CXX_TRUE@am_awk07_OBJECTS = awk07.$(OBJEXT)
awk07_OBJECTS = $(am_awk07_OBJECTS) awk07_OBJECTS = $(am_awk07_OBJECTS)
@ENABLE_CXX_TRUE@awk07_DEPENDENCIES = $(am__DEPENDENCIES_2) @ENABLE_CXX_TRUE@awk07_DEPENDENCIES = $(am__DEPENDENCIES_2)
am__awk08_SOURCES_DIST = awk08.cpp
@ENABLE_CXX_TRUE@am_awk08_OBJECTS = awk08.$(OBJEXT)
awk08_OBJECTS = $(am_awk08_OBJECTS)
@ENABLE_CXX_TRUE@awk08_DEPENDENCIES = $(am__DEPENDENCIES_2)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include/qse DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/include/qse
depcomp = $(SHELL) $(top_srcdir)/ac/au/depcomp depcomp = $(SHELL) $(top_srcdir)/ac/au/depcomp
am__depfiles_maybe = depfiles am__depfiles_maybe = depfiles
@ -110,11 +106,10 @@ CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
$(LDFLAGS) -o $@ $(LDFLAGS) -o $@
SOURCES = $(awk01_SOURCES) $(awk02_SOURCES) $(awk03_SOURCES) \ SOURCES = $(awk01_SOURCES) $(awk02_SOURCES) $(awk03_SOURCES) \
$(awk04_SOURCES) $(awk05_SOURCES) $(awk06_SOURCES) \ $(awk04_SOURCES) $(awk05_SOURCES) $(awk06_SOURCES) \
$(awk07_SOURCES) $(awk08_SOURCES) $(awk07_SOURCES)
DIST_SOURCES = $(awk01_SOURCES) $(awk02_SOURCES) $(awk03_SOURCES) \ DIST_SOURCES = $(awk01_SOURCES) $(awk02_SOURCES) $(awk03_SOURCES) \
$(awk04_SOURCES) $(am__awk05_SOURCES_DIST) \ $(awk04_SOURCES) $(am__awk05_SOURCES_DIST) \
$(am__awk06_SOURCES_DIST) $(am__awk07_SOURCES_DIST) \ $(am__awk06_SOURCES_DIST) $(am__awk07_SOURCES_DIST)
$(am__awk08_SOURCES_DIST)
ETAGS = etags ETAGS = etags
CTAGS = ctags CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
@ -263,11 +258,10 @@ awk04_SOURCES = awk04.c
@ENABLE_CXX_TRUE@awk05_SOURCES = awk05.cpp @ENABLE_CXX_TRUE@awk05_SOURCES = awk05.cpp
@ENABLE_CXX_TRUE@awk06_SOURCES = awk06.cpp @ENABLE_CXX_TRUE@awk06_SOURCES = awk06.cpp
@ENABLE_CXX_TRUE@awk07_SOURCES = awk07.cpp @ENABLE_CXX_TRUE@awk07_SOURCES = awk07.cpp
@ENABLE_CXX_TRUE@awk08_SOURCES = awk08.cpp #awk08_SOURCES = awk08.cpp
@ENABLE_CXX_TRUE@awk05_LDADD = -lqseawk++ $(LDADD) @ENABLE_CXX_TRUE@awk05_LDADD = -lqseawk++ $(LDADD)
@ENABLE_CXX_TRUE@awk06_LDADD = -lqseawk++ $(LDADD) @ENABLE_CXX_TRUE@awk06_LDADD = -lqseawk++ $(LDADD)
@ENABLE_CXX_TRUE@awk07_LDADD = -lqseawk++ $(LDADD) @ENABLE_CXX_TRUE@awk07_LDADD = -lqseawk++ $(LDADD)
@ENABLE_CXX_TRUE@awk08_LDADD = -lqseawk++ $(LDADD)
all: all-am all: all-am
.SUFFIXES: .SUFFIXES:
@ -350,9 +344,6 @@ awk06$(EXEEXT): $(awk06_OBJECTS) $(awk06_DEPENDENCIES)
awk07$(EXEEXT): $(awk07_OBJECTS) $(awk07_DEPENDENCIES) awk07$(EXEEXT): $(awk07_OBJECTS) $(awk07_DEPENDENCIES)
@rm -f awk07$(EXEEXT) @rm -f awk07$(EXEEXT)
$(CXXLINK) $(awk07_OBJECTS) $(awk07_LDADD) $(LIBS) $(CXXLINK) $(awk07_OBJECTS) $(awk07_LDADD) $(LIBS)
awk08$(EXEEXT): $(awk08_OBJECTS) $(awk08_DEPENDENCIES)
@rm -f awk08$(EXEEXT)
$(CXXLINK) $(awk08_OBJECTS) $(awk08_LDADD) $(LIBS)
mostlyclean-compile: mostlyclean-compile:
-rm -f *.$(OBJEXT) -rm -f *.$(OBJEXT)
@ -367,7 +358,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk05.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk05.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk06.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk06.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk07.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk07.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/awk08.Po@am__quote@
.c.o: .c.o:
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@ -595,6 +585,7 @@ uninstall-am: uninstall-binPROGRAMS
pdf pdf-am ps ps-am tags uninstall uninstall-am \ pdf pdf-am ps ps-am tags uninstall uninstall-am \
uninstall-binPROGRAMS uninstall-binPROGRAMS
#awk08_LDADD = -lqseawk++ $(LDADD)
# Tell versions [3.59,3.63) of GNU make to not export all variables. # Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded. # Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT: .NOEXPORT:

View File

@ -29,11 +29,6 @@ static void print_error (unsigned long line, const qse_char_t* msg)
} }
static void print_error (const qse_char_t* msg)
{
print_error (0, msg);
}
static int run_awk (QSE::StdAwk& awk) static int run_awk (QSE::StdAwk& awk)
{ {
// ARGV[0] // ARGV[0]
@ -65,7 +60,7 @@ static int awk_main (int argc, qse_char_t* argv[])
int ret = awk.open (); int ret = awk.open ();
if (ret >= 0) ret = run_awk (awk); if (ret >= 0) ret = run_awk (awk);
if (ret <= -1) print_error (awk.errorLine(), awk.errorMessage()); if (ret <= -1) print_error (awk.getErrorLine(), awk.getErrorMessage());
awk.close (); awk.close ();
return ret; return ret;

View File

@ -78,7 +78,7 @@ static int awk_main (int argc, qse_char_t* argv[])
int ret = awk.open(); int ret = awk.open();
if (ret >= 0) ret = run_awk (awk); if (ret >= 0) ret = run_awk (awk);
if (ret <= -1) print_error (awk.errorLine(), awk.errorMessage()); if (ret <= -1) print_error (awk.getErrorLine(), awk.getErrorMessage());
awk.close (); awk.close ();
return -1; return -1;

View File

@ -123,7 +123,7 @@ static int awk_main (int argc, qse_char_t* argv[])
QSE::StdAwk::OPT_RESET); QSE::StdAwk::OPT_RESET);
if (ret >= 0) ret = run_awk (awk); if (ret >= 0) ret = run_awk (awk);
if (ret <= -1) print_error (awk.errorLine(), awk.errorMessage()); if (ret <= -1) print_error (awk.getErrorLine(), awk.getErrorMessage());
awk.close (); awk.close ();
return -1; return -1;

View File

@ -481,14 +481,14 @@ static int awk_main (int argc, qse_char_t* argv[])
if (awk.open() <= -1) if (awk.open() <= -1)
{ {
print_error (awk.errorMessage()); print_error (awk.getErrorMessage());
return -1; return -1;
} }
// ARGV[0] // ARGV[0]
if (awk.addArgument (QSE_T("awk05")) <= -1) if (awk.addArgument (QSE_T("awk05")) <= -1)
{ {
print_error (awk.errorMessage()); print_error (awk.getErrorMessage());
awk.close (); awk.close ();
return -1; return -1;
} }
@ -629,7 +629,7 @@ static int awk_main (int argc, qse_char_t* argv[])
if (run == QSE_NULL) if (run == QSE_NULL)
{ {
qse_fprintf (stderr, QSE_T("cannot parse: LINE[%d] %s\n"), qse_fprintf (stderr, QSE_T("cannot parse: LINE[%d] %s\n"),
awk.errorLine(), awk.errorMessage()); awk.getErrorLine(), awk.getErrorMessage());
awk.close (); awk.close ();
return -1; return -1;
} }
@ -640,7 +640,7 @@ static int awk_main (int argc, qse_char_t* argv[])
if (awk.loop () <= -1) if (awk.loop () <= -1)
{ {
qse_fprintf (stderr, QSE_T("cannot run: LINE[%d] %s\n"), qse_fprintf (stderr, QSE_T("cannot run: LINE[%d] %s\n"),
awk.errorLine(), awk.errorMessage()); awk.getErrorLine(), awk.getErrorMessage());
awk.close (); awk.close ();
return -1; return -1;
} }
@ -654,7 +654,7 @@ static int awk_main (int argc, qse_char_t* argv[])
if (awk.call (QSE_T("add"), args, 2) <= -1) if (awk.call (QSE_T("add"), args, 2) <= -1)
{ {
qse_fprintf (stderr, QSE_T("cannot run: LINE[%d] %s\n"), qse_fprintf (stderr, QSE_T("cannot run: LINE[%d] %s\n"),
awk.errorLine(), awk.errorMessage()); awk.getErrorLine(), awk.getErrorMessage());
awk.close (); awk.close ();
} }
#endif #endif