diff --git a/qse/include/qse/Mmgr.hpp b/qse/include/qse/Mmgr.hpp index 2cd9ef4a..34cebf46 100644 --- a/qse/include/qse/Mmgr.hpp +++ b/qse/include/qse/Mmgr.hpp @@ -42,7 +42,7 @@ public: * The Mmgr() function builds a memory manager composed of bridge * functions connecting itself with it. */ - Mmgr () throw () + Mmgr () { this->alloc = alloc_mem; this->realloc = realloc_mem; @@ -63,7 +63,7 @@ protected: */ virtual void* allocMem ( qse_size_t n /**< the size of allocate in bytes */ - ) throw () = 0; + ) = 0; /** * The reallocMem() function resizes a chunk of memory previously @@ -74,7 +74,7 @@ protected: virtual void* reallocMem ( void* ptr, /**< a pointer to a memory chunk to resize */ qse_size_t n /**< new size in bytes */ - ) throw () = 0; + ) = 0; /** * The freeMem() function frees a chunk of memory allocated with @@ -82,13 +82,13 @@ protected: */ virtual void freeMem ( void* ptr /**< a pointer to a memory chunk to free */ - ) throw () = 0; + ) = 0; protected: /** * 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); } @@ -96,7 +96,7 @@ protected: /** * 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); } @@ -104,7 +104,7 @@ protected: /** * 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); } diff --git a/qse/include/qse/awk/Awk.hpp b/qse/include/qse/awk/Awk.hpp index ae708b90..7e3a1aac 100644 --- a/qse/include/qse/awk/Awk.hpp +++ b/qse/include/qse/awk/Awk.hpp @@ -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. @@ -38,11 +38,12 @@ public: typedef qse_map_t map_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_errnum_t errnum_t; typedef qse_awk_errstr_t errstr_t; + typedef qse_awk_errinf_t errinf_t; /** Represents an internal awk value */ typedef qse_awk_val_t val_t; @@ -58,13 +59,207 @@ public: 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: - 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: /** * 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. */ class Source @@ -265,13 +460,13 @@ public: #if !defined(__BORLANDC__) // deletion when initialization fails - void operator delete (void* p, Run* run) throw (); - void operator delete[] (void* p, Run* run) throw (); + void operator delete (void* p, Run* run); + void operator delete[] (void* p, Run* run); #endif // normal deletion - void operator delete (void* p) throw (); - void operator delete[] (void* p) throw (); + void operator delete (void* p); + void operator delete[] (void* p); class Index { @@ -482,180 +677,9 @@ public: 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. - * Awk::setGlobal and Awk::getGlobal can take one of these enumeration. + * Awk::setGlobal and Awk::getGlobal can take one of these enumerators. */ enum Global { @@ -694,16 +718,17 @@ public: operator rtx_t* () const; void stop () const; - bool isStop () const; + bool shouldStop () const; - ErrorNumber errorNumber () const throw (); - size_t errorLine () const throw (); - const char_t* errorMessage () const throw (); + ErrorNumber getErrorNumber () const; + size_t getErrorLine () const; + const char_t* getErrorMessage () const; - 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 setError ( + ErrorNumber code, + size_t line = 0, + const cstr_t* args = QSE_NULL + ); void setErrorWithMessage ( ErrorNumber code, size_t line, const char_t* msg); @@ -748,105 +773,111 @@ public: rtx_t* rtx; }; - /** Constructor */ - Awk () throw (); - - /** Returns the underlying handle */ + /** Returns the primitive handle */ operator awk_t* () const; /** - * @name Error Handling + * @name Basic Functions */ /*@{*/ -protected: - /** - * 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 (); + /** Constructor */ + Awk (); -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. * You must call this function before doing anything meaningful. * @return 0 on success, -1 on failure */ - virtual int open (); + int open (); /** 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 */ - virtual void setOption (int opt); - - /** Gets the option */ - virtual int getOption () const; + void setOption ( + int opt + ); /** Defines the depth ID */ enum Depth @@ -860,40 +891,9 @@ public: }; /** Sets the maximum depth */ - virtual void setMaxDepth (int ids, size_t depth); + void setMaxDepth (int ids, size_t depth); /** Gets the maximum depth */ - virtual 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 (); + size_t getMaxDepth (int id) const; /** * Adds an ARGV string as long as @a len characters pointed to @@ -901,7 +901,7 @@ public: * to a script through ARGV. * @return 0 on success, -1 on failure */ - virtual int addArgument ( + int addArgument ( const char_t* arg, size_t len ); @@ -911,102 +911,117 @@ public: * make a string added available to a script through ARGV. * @return 0 on success, -1 on failure */ - virtual int addArgument (const char_t* arg); + int addArgument (const char_t* arg); /** * 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. */ - 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. - * 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(). + * 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 */ - virtual int setGlobal (int id, const Value& v); - /** - * 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 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); + int setGlobal ( + int id, ///< numeric identifier + const Value& v ///< value + ); /** - * 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) ( - Run& run, Value& ret, const Value* args, size_t nargs, - const char_t* name, size_t len); + Run& run, + Value& ret, + const Value* args, + size_t nargs, + const cstr_t* name + ); /** * Adds a new user-defined intrinsic function. */ - virtual int addFunction ( + int addFunction ( const char_t* name, size_t minArgs, size_t maxArgs, FunctionHandler handler); /** * Deletes a user-defined intrinsic function */ - virtual int deleteFunction (const char_t* name); + int deleteFunction (const char_t* name); + /*@}*/ /** * Enables the run-time callback */ - virtual void enableRunCallback (); + void enableRunCallback (); /** * Disables the run-time callback */ - virtual void disableRunCallback (); + void disableRunCallback (); /** * @name Word Substitution */ /*@{*/ - virtual int getWord ( + int getWord ( const char_t* ow, qse_size_t owl, const char_t** nw, qse_size_t* nwl - ) throw (); + ); - virtual int setWord ( + int setWord ( 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* nw, qse_size_t nwl - ) throw (); + ); - virtual int unsetWord ( + int unsetWord ( const char_t* ow - ) throw (); + ); - virtual int unsetWord ( + int unsetWord ( const char_t* ow, qse_size_t owl - ) throw (); + ); - virtual int unsetAllWords () throw (); + int unsetAllWords (); /*@}*/ protected: - virtual int dispatchFunction (Run* run, const char_t* name, size_t len); - /** * @name Pipe I/O handlers * Pipe operations are achieved through the following functions. @@ -1069,9 +1084,7 @@ protected: rtx_t* rtx, rio_cmd_t cmd, rio_arg_t* riod, char_t* data, size_t count); - static int functionHandler ( - rtx_t* rtx, const char_t* name, size_t len); - static void freeFunctionMapValue (map_t* map, void* dptr, size_t dlen); + static int functionHandler (rtx_t* rtx, const cstr_t* name); static int onLoopEnter (rtx_t* run, void* data); static void onLoopExit (rtx_t* run, val_t* ret, void* data); @@ -1083,7 +1096,10 @@ protected: protected: awk_t* awk; + errstr_t dflerrstr; + errinf_t errinf; + map_t* functionMap; Source::Data sourceIn; @@ -1092,11 +1108,7 @@ protected: Source* sourceReader; Source* sourceWriter; - ErrorNumber errnum; - size_t errlin; - char_t errmsg[256]; - - bool runCallback; + bool runCallback; struct xstrs_t { @@ -1118,7 +1130,9 @@ private: int init_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: Awk (const Awk&); diff --git a/qse/include/qse/awk/StdAwk.hpp b/qse/include/qse/awk/StdAwk.hpp index b8225b96..3fa921dc 100644 --- a/qse/include/qse/awk/StdAwk.hpp +++ b/qse/include/qse/awk/StdAwk.hpp @@ -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. @@ -74,9 +74,9 @@ public: int open (); void close (); - virtual int addConsoleOutput (const char_t* arg, size_t len); - virtual int addConsoleOutput (const char_t* arg); - virtual void clearConsoleOutputs (); + int addConsoleOutput (const char_t* arg, size_t len); + int addConsoleOutput (const char_t* arg); + void clearConsoleOutputs (); protected: // intrinsic functions @@ -128,9 +128,9 @@ protected: int nextConsole (Console& io); // primitive handlers - void* allocMem (size_t n) throw (); - void* reallocMem (void* ptr, size_t n) throw (); - void freeMem (void* ptr) throw (); + void* allocMem (size_t n); + void* reallocMem (void* ptr, size_t n); + void freeMem (void* ptr); real_t pow (real_t x, real_t y); int vsprintf (char_t* buf, size_t size, diff --git a/qse/include/qse/awk/awk.h b/qse/include/qse/awk/awk.h index dc5c76be..da6b5849 100644 --- a/qse/include/qse/awk/awk.h +++ b/qse/include/qse/awk/awk.h @@ -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. @@ -254,8 +254,7 @@ typedef int (*qse_awk_sprintf_t) ( */ typedef int (*qse_awk_fnc_fun_t) ( qse_awk_rtx_t* rtx, /**< runtime context */ - const qse_char_t* name, /**< function name */ - qse_size_t len /**< name length */ + const qse_cstr_t* name /**< function name */ ); /** @@ -710,8 +709,7 @@ enum qse_awk_errnum_t QSE_AWK_ERNEXTEND, /**< 'next' called from END block */ QSE_AWK_ERNEXTFBEG, /**< 'nextfile' called from BEGIN block */ QSE_AWK_ERNEXTFEND, /**< 'nextfile' called from END block */ - QSE_AWK_EFNCUSER, /**< wrong intrinsic function implementation */ - QSE_AWK_EFNCIMPL, /**< intrinsic function handler failed */ + QSE_AWK_EFNCIMPL, /**< intrinsic function handler for '${0}' failed */ QSE_AWK_EIOUSER, /**< wrong user io handler implementation */ QSE_AWK_EIOIMPL, /**< I/O callback returned an error */ QSE_AWK_EIONMNF, /**< no such I/O name found */ @@ -1036,6 +1034,9 @@ void qse_awk_geterror ( const qse_char_t** errmsg ); +/** + * The qse_awk_seterror() functon sets + */ void qse_awk_seterror ( qse_awk_t* awk, qse_awk_errnum_t errnum, diff --git a/qse/include/qse/sed/Sed.hpp b/qse/include/qse/sed/Sed.hpp index 315c154a..c2f6e281 100644 --- a/qse/include/qse/sed/Sed.hpp +++ b/qse/include/qse/sed/Sed.hpp @@ -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. @@ -54,7 +54,7 @@ public: /** * 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. @@ -70,12 +70,12 @@ public: * ready for subsequent use. * @return 0 on success, -1 on failure. */ - int open () throw (); + int open (); /** * The close() function finalizes a stream editor. */ - void close () throw (); + void close (); /** * The compile() function compiles a null-terminated string pointed @@ -84,7 +84,7 @@ public: */ int compile ( const char_t* sptr ///< a pointer to a null-terminated string - ) throw (); + ); /** * The compile() function compiles a string pointed to by @a sptr @@ -94,20 +94,20 @@ public: int compile ( const char_t* sptr, ///< a pointer to a string size_t slen ///< the number of characters in the string - ) throw (); + ); /** * The execute() function executes compiled commands over the IO * streams defined through IO handlers * @return 0 on success, -1 on failure */ - int execute () throw (); + int execute (); /** * The getOption() function gets the current options. * @return current option code */ - int getOption () const throw (); + int getOption () const; /** * The setOption() function sets options for a stream editor. @@ -115,12 +115,12 @@ public: */ void setOption ( int opt ///< option code - ) throw (); + ); /** * 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. @@ -128,35 +128,28 @@ public: void setMaxDepth ( int ids, ///< 0 or a number OR'ed of depth_t values size_t depth ///< 0 maximum depth - ) throw (); + ); /** * The getErrorMessage() function gets the description of the last * error occurred. It returns an empty string if the stream editor * 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 last error occurred. It returns 0 if the stream editor has * 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 * error occurred. It returns QSE_SED_ENOERR if the stream editor * has not been initialized with the open() function. */ - errnum_t getErrorNumber () const throw (); - - /** - * The getConsoleLine() function returns the current line - * number from an input console. - * @return current line number - */ - size_t getConsoleLine () throw (); + errnum_t getErrorNumber () const; /** * 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 ); + /** + * 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 * number from an input console. */ void setConsoleLine ( size_t num ///< a line number - ) throw (); + ); protected: /** @@ -194,7 +194,7 @@ protected: }; protected: - IOBase (io_arg_t* arg, Mode mode) throw (): + IOBase (io_arg_t* arg, Mode mode): arg(arg), mode (mode) {} public: @@ -204,7 +204,7 @@ protected: * an assoicated IO handler closes it or changes it with * another call to setHandle(). */ - const void* getHandle () const throw () + const void* getHandle () const { return arg->handle; } @@ -215,7 +215,7 @@ protected: * and Sed::openFile(). You can get the handle with the * getHandle() function as needed. */ - void setHandle (void* handle) throw () + void setHandle (void* handle) { arg->handle = handle; } @@ -225,7 +225,7 @@ protected: * A stream opening function can inspect the mode requested and * open a stream properly */ - Mode getMode () throw () + Mode getMode () { return this->mode; } @@ -244,7 +244,7 @@ protected: { protected: friend class Sed; - Console (io_arg_t* arg, Mode mode) throw (): + Console (io_arg_t* arg, Mode mode): IOBase (arg, mode) {} }; @@ -256,7 +256,7 @@ protected: { protected: friend class Sed; - File (io_arg_t* arg, Mode mode) throw (): + File (io_arg_t* arg, Mode mode): IOBase (arg, mode) {} public: @@ -265,7 +265,7 @@ protected: * You can call this function from the openFile() function * to determine a file to open. */ - const char_t* getName () const throw () + const char_t* getName () const { return arg->path; } @@ -395,9 +395,9 @@ protected: errstr_t dflerrstr; private: - static ssize_t xin (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw (); - static ssize_t xout (sed_t* s, io_cmd_t cmd, io_arg_t* arg) throw (); - static const char_t* xerrstr (sed_t* s, errnum_t num) throw (); + 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); + static const char_t* xerrstr (sed_t* s, errnum_t num); private: Sed (const Sed&); diff --git a/qse/include/qse/sed/StdSed.hpp b/qse/include/qse/sed/StdSed.hpp index e0191515..6d70c3d1 100644 --- a/qse/include/qse/sed/StdSed.hpp +++ b/qse/include/qse/sed/StdSed.hpp @@ -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. @@ -33,9 +33,9 @@ QSE_BEGIN_NAMESPACE(QSE) class StdSed: public Sed { protected: - void* allocMem (qse_size_t n) throw (); - void* reallocMem (void* ptr, qse_size_t n) throw (); - void freeMem (void* ptr) throw (); + void* allocMem (qse_size_t n); + void* reallocMem (void* ptr, qse_size_t n); + void freeMem (void* ptr); int openConsole (Console& io); int closeConsole (Console& io); diff --git a/qse/lib/awk/Awk.cpp b/qse/lib/awk/Awk.cpp index fc90662c..e1577668 100644 --- a/qse/lib/awk/Awk.cpp +++ b/qse/lib/awk/Awk.cpp @@ -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. @@ -227,7 +227,7 @@ void* Awk::Value::operator new (size_t n, Run* run) throw () 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); 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__) -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)); } -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)); } #endif -void Awk::Value::operator delete (void* ptr) throw () +void Awk::Value::operator delete (void* ptr) { void* p = (char*)ptr-QSE_SIZEOF(Run*); 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*); 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, map); - r->setError (ERR_NOMEM, 0, QSE_NULL, 0); + r->setError (ERR_NOMEM); r->awk->retrieveError (r); return -1; } @@ -887,61 +887,40 @@ Awk::Run::operator Awk::rtx_t* () const return this->rtx; } -void Awk::Run::stop () const +void Awk::Run::stop () const { QSE_ASSERT (this->rtx != QSE_NULL); qse_awk_rtx_stop (this->rtx); } -bool Awk::Run::isStop () const +bool Awk::Run::shouldStop () const { QSE_ASSERT (this->rtx != QSE_NULL); 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); 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); 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); 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_awk_rtx_seterror (this->rtx, (errnum_t)code, 0, QSE_NULL); -} - -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); + qse_awk_rtx_seterror (this->rtx, (errnum_t)code, line, args); } void Awk::Run::setErrorWithMessage ( @@ -949,7 +928,7 @@ void Awk::Run::setErrorWithMessage ( { QSE_ASSERT (this->rtx != QSE_NULL); - qse_awk_errinf_t errinf; + errinf_t errinf; errinf.num = (errnum_t)code; errinf.lin = line; @@ -1013,77 +992,62 @@ int Awk::Run::getGlobal (int id, Value& g) const // 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), - errnum (ERR_NOERR), errlin (0), runCallback (false), - runctx (this) + runCallback (false), 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; } -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 (dflerrstr != QSE_NULL); 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); - 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) -{ - 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) +void Awk::setError (ErrorNumber code, size_t line, const cstr_t* args) { if (awk != QSE_NULL) { - qse_cstr_t x = { arg, len }; - qse_awk_seterror (awk, (errnum_t)code, line, &x); + qse_awk_seterror (awk, (errnum_t)code, line, args); retrieveError (); } else { - this->errnum = code; - this->errlin = line; - qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg), + errinf.num = (errnum_t)code; + errinf.lin = line; + qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg), 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) { - qse_awk_errinf_t errinf; - errinf.num = (errnum_t)code; errinf.lin = line; qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg), msg); - qse_awk_seterrinf (awk, &errinf); - retrieveError (); } else { - this->errnum = code; - this->errlin = line; - qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg), msg); + errinf.num = (errnum_t)code; + errinf.lin = line; + qse_strxcpy (errinf.msg, QSE_COUNTOF(errinf.msg), msg); } } void Awk::clearError () { - this->errnum = ERR_NOERR; - this->errlin = 0; - this->errmsg[0] = QSE_T('\0'); + errinf.num = (errnum_t)ERR_NOERR; + errinf.lin = 0; + errinf.msg[0] = QSE_T('\0'); } void Awk::retrieveError () @@ -1124,29 +1084,25 @@ void Awk::retrieveError () } else { - errnum_t num; - 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); + qse_awk_geterrinf (this->awk, &errinf); } } void Awk::retrieveError (Run* run) { - errnum_t num; - const char_t* msg; - QSE_ASSERT (run != QSE_NULL); if (run->rtx == QSE_NULL) return; - - qse_awk_rtx_geterror (run->rtx, &num, &this->errlin, &msg); - this->errnum = (ErrorNumber)num; - qse_strxcpy (this->errmsg, QSE_COUNTOF(this->errmsg), msg); + qse_awk_rtx_geterrinf (run->rtx, &errinf); } -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); @@ -1181,14 +1137,14 @@ int Awk::open () *(Awk**)QSE_XTN(functionMap) = this; 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)); runCallback = false; return 0; } -void Awk::close () +void Awk::close () { fini_runctx (); clearArguments (); @@ -1209,31 +1165,7 @@ void Awk::close () runCallback = false; } -void Awk::setOption (int opt) -{ - 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) +Awk::Run* Awk::parse (Source& in, Source& out) { QSE_ASSERT (awk != QSE_NULL); @@ -1263,53 +1195,7 @@ Awk::Run* Awk::parse (Source& in, Source& out) return &runctx; } -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::loop () +int Awk::loop () { QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (runctx.rtx != QSE_NULL); @@ -1319,7 +1205,9 @@ int Awk::loop () 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 (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; } -void Awk::stop () +void Awk::stop () { QSE_ASSERT (awk != QSE_NULL); 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 = qse_map_search (functionMap, name, len); + pair = qse_map_search (functionMap, name->ptr, name->len); if (pair == QSE_NULL) { - run->setError (ERR_FUNNF, 0, name, len); + run->setError (ERR_FUNNF, 0, name); return -1; } @@ -1391,7 +1349,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len) args = new(run) Value[nargs]; if (args == QSE_NULL) { - run->setError (ERR_NOMEM, 0, QSE_NULL, 0); + run->setError (ERR_NOMEM); 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); if (args[i].setVal (run, v) == -1) { - run->setError (ERR_NOMEM, 0, QSE_NULL, 0); + run->setError (ERR_NOMEM); if (args != buf) delete[] args; return -1; } @@ -1409,7 +1367,10 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len) 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; @@ -1424,7 +1385,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len) 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) { @@ -1451,7 +1412,7 @@ int Awk::xstrs_t::add (awk_t* awk, const char_t* arg, size_t len) return 0; } -void Awk::xstrs_t::clear (awk_t* awk) +void Awk::xstrs_t::clear (awk_t* awk) { 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); int n = runarg.add (awk, arg, len); @@ -1472,17 +1433,17 @@ int Awk::addArgument (const char_t* arg, size_t len) return n; } -int Awk::addArgument (const char_t* arg) +int Awk::addArgument (const char_t* arg) { return addArgument (arg, qse_strlen(arg)); } -void Awk::clearArguments () +void Awk::clearArguments () { runarg.clear (awk); } -int Awk::addGlobal (const char_t* name) +int Awk::addGlobal (const char_t* name) { QSE_ASSERT (awk != QSE_NULL); @@ -1491,7 +1452,7 @@ int Awk::addGlobal (const char_t* name) return n; } -int Awk::deleteGlobal (const char_t* name) +int Awk::deleteGlobal (const char_t* name) { QSE_ASSERT (awk != QSE_NULL); int n = qse_awk_delgbl (awk, name, qse_strlen(name)); @@ -1499,7 +1460,7 @@ int Awk::deleteGlobal (const char_t* name) 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 (runctx.rtx != QSE_NULL); @@ -1515,7 +1476,7 @@ int Awk::setGlobal (int id, const Value& v) return n; } -int Awk::getGlobal (int id, Value& v) +int Awk::getGlobal (int id, Value& v) { QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (runctx.rtx != QSE_NULL); @@ -1527,7 +1488,7 @@ int Awk::getGlobal (int id, Value& v) int Awk::addFunction ( const char_t* name, size_t minArgs, size_t maxArgs, - FunctionHandler handler) + FunctionHandler handler) { QSE_ASSERT (awk != QSE_NULL); @@ -1568,7 +1529,7 @@ int Awk::addFunction ( return 0; } -int Awk::deleteFunction (const char_t* name) +int Awk::deleteFunction (const char_t* name) { QSE_ASSERT (awk != QSE_NULL); @@ -1581,49 +1542,49 @@ int Awk::deleteFunction (const char_t* name) return n; } -void Awk::enableRunCallback () +void Awk::enableRunCallback () { runCallback = true; } -void Awk::disableRunCallback () +void Awk::disableRunCallback () { runCallback = false; } int Awk::getWord ( 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); 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)); } int Awk::setWord ( 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); 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)); } -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); return qse_awk_setword (awk, ow, owl, QSE_NULL, 0); } -int Awk::unsetAllWords () throw () +int Awk::unsetAllWords () { QSE_ASSERT (awk != QSE_NULL); 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); - switch (cmd) - { - case QSE_AWK_RIO_OPEN: - return awk->openPipe (pipe); - case QSE_AWK_RIO_CLOSE: - return awk->closePipe (pipe); + try + { + switch (cmd) + { + case QSE_AWK_RIO_OPEN: + return awk->openPipe (pipe); + case QSE_AWK_RIO_CLOSE: + return awk->closePipe (pipe); - case QSE_AWK_RIO_READ: - return awk->readPipe (pipe, data, count); - case QSE_AWK_RIO_WRITE: - return awk->writePipe (pipe, data, count); + case QSE_AWK_RIO_READ: + return awk->readPipe (pipe, data, count); + case QSE_AWK_RIO_WRITE: + return awk->writePipe (pipe, data, count); - case QSE_AWK_RIO_FLUSH: - return awk->flushPipe (pipe); + case QSE_AWK_RIO_FLUSH: + return awk->flushPipe (pipe); - case QSE_AWK_RIO_NEXT: - return -1; + default: + return -1; + } + } + catch (...) + { + return -1; } - - return -1; } Awk::ssize_t Awk::fileHandler ( @@ -1723,26 +1689,31 @@ Awk::ssize_t Awk::fileHandler ( File file (rxtn->run, riod); - switch (cmd) + try { - case QSE_AWK_RIO_OPEN: - return awk->openFile (file); - case QSE_AWK_RIO_CLOSE: - return awk->closeFile (file); + switch (cmd) + { + case QSE_AWK_RIO_OPEN: + return awk->openFile (file); + case QSE_AWK_RIO_CLOSE: + return awk->closeFile (file); - case QSE_AWK_RIO_READ: - return awk->readFile (file, data, count); - case QSE_AWK_RIO_WRITE: - return awk->writeFile (file, data, count); + case QSE_AWK_RIO_READ: + return awk->readFile (file, data, count); + case QSE_AWK_RIO_WRITE: + return awk->writeFile (file, data, count); - case QSE_AWK_RIO_FLUSH: - return awk->flushFile (file); + case QSE_AWK_RIO_FLUSH: + return awk->flushFile (file); - case QSE_AWK_RIO_NEXT: - return -1; + default: + return -1; + } + } + catch (...) + { + return -1; } - - return -1; } Awk::ssize_t Awk::consoleHandler ( @@ -1756,39 +1727,41 @@ Awk::ssize_t Awk::consoleHandler ( Console console (rxtn->run, riod); - switch (cmd) + try { - case QSE_AWK_RIO_OPEN: - return awk->openConsole (console); - case QSE_AWK_RIO_CLOSE: - return awk->closeConsole (console); + switch (cmd) + { + case QSE_AWK_RIO_OPEN: + return awk->openConsole (console); + case QSE_AWK_RIO_CLOSE: + return awk->closeConsole (console); - case QSE_AWK_RIO_READ: - return awk->readConsole (console, data, count); - case QSE_AWK_RIO_WRITE: - return awk->writeConsole (console, data, count); + case QSE_AWK_RIO_READ: + return awk->readConsole (console, data, count); + case QSE_AWK_RIO_WRITE: + return awk->writeConsole (console, data, count); - case QSE_AWK_RIO_FLUSH: - return awk->flushConsole (console); - case QSE_AWK_RIO_NEXT: - return awk->nextConsole (console); + case QSE_AWK_RIO_FLUSH: + return awk->flushConsole (console); + case QSE_AWK_RIO_NEXT: + 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); - 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) { Run* run = (Run*)data; diff --git a/qse/lib/awk/StdAwk.cpp b/qse/lib/awk/StdAwk.cpp index 5554cf98..dac99967 100644 --- a/qse/lib/awk/StdAwk.cpp +++ b/qse/lib/awk/StdAwk.cpp @@ -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. @@ -48,7 +48,7 @@ QSE_BEGIN_NAMESPACE(QSE) } \ } while (0) -int StdAwk::open () +int StdAwk::open () { int n = Awk::open (); if (n == -1) return n; @@ -75,7 +75,7 @@ int StdAwk::open () return 0; } -void StdAwk::close () +void StdAwk::close () { clearConsoleOutputs (); Awk::close (); @@ -391,7 +391,7 @@ int StdAwk::flushFile (File& io) 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); int n = ofile.add (awk, arg, len); @@ -399,12 +399,12 @@ int StdAwk::addConsoleOutput (const char_t* arg, size_t len) return n; } -int StdAwk::addConsoleOutput (const char_t* arg) +int StdAwk::addConsoleOutput (const char_t* arg) { return addConsoleOutput (arg, qse_strlen(arg)); } -void StdAwk::clearConsoleOutputs () +void StdAwk::clearConsoleOutputs () { ofile.clear (awk); } @@ -462,7 +462,14 @@ int StdAwk::open_console_in (Console& io) 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. * 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) { /* 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); return -1; } @@ -524,7 +534,10 @@ int StdAwk::open_console_in (Console& io) rtx->awk->mmgr, 0, file, QSE_SIO_READ); 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); return -1; } @@ -581,7 +594,14 @@ int StdAwk::open_console_out (Console& io) 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')) { @@ -594,7 +614,10 @@ int StdAwk::open_console_out (Console& io) rtx->awk->mmgr, 0, file, QSE_SIO_READ); 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; } } @@ -725,17 +748,17 @@ int StdAwk::nextConsole (Console& io) } // memory allocation primitives -void* StdAwk::allocMem (size_t n) throw () +void* StdAwk::allocMem (size_t 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); } -void StdAwk::freeMem (void* ptr) throw () +void StdAwk::freeMem (void* ptr) { ::free (ptr); } diff --git a/qse/lib/awk/err.c b/qse/lib/awk/err.c index d9dd9f58..76018634 100644 --- a/qse/lib/awk/err.c +++ b/qse/lib/awk/err.c @@ -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. @@ -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("'nextfile' called from BEGIN block"), QSE_T("'nextfile' called from END block"), - QSE_T("wrong implementation of intrinsic function handler"), - QSE_T("intrinsic function handler returned an error"), + QSE_T("intrinsic function handler for '${0}' failed"), QSE_T("wrong implementation of user-defined io handler"), QSE_T("I/O handler returned an error"), QSE_T("no such I/O name found"), diff --git a/qse/lib/awk/fnc.c b/qse/lib/awk/fnc.c index 2f1317f3..5c0438b7 100644 --- a/qse/lib/awk/fnc.c +++ b/qse/lib/awk/fnc.c @@ -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. @@ -18,18 +18,18 @@ #include "awk.h" -static int fnc_close (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); -static int fnc_fflush (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); -static int fnc_index (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); -static int fnc_length (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); -static int fnc_substr (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); -static int fnc_split (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); -static int fnc_tolower (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); -static int fnc_toupper (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); -static int fnc_gsub (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); -static int fnc_sub (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); -static int fnc_match (qse_awk_rtx_t*, const qse_char_t*, qse_size_t); -static int fnc_sprintf (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_cstr_t*); +static int fnc_index (qse_awk_rtx_t*, const qse_cstr_t*); +static int fnc_length (qse_awk_rtx_t*, const qse_cstr_t*); +static int fnc_substr (qse_awk_rtx_t*, const qse_cstr_t*); +static int fnc_split (qse_awk_rtx_t*, const qse_cstr_t*); +static int fnc_tolower (qse_awk_rtx_t*, const qse_cstr_t*); +static int fnc_toupper (qse_awk_rtx_t*, const qse_cstr_t*); +static int fnc_gsub (qse_awk_rtx_t*, const qse_cstr_t*); +static int fnc_sub (qse_awk_rtx_t*, const qse_cstr_t*); +static int fnc_match (qse_awk_rtx_t*, const qse_cstr_t*); +static int fnc_sprintf (qse_awk_rtx_t*, const qse_cstr_t*); #undef MAX #define MAX QSE_TYPE_UNSIGNED_MAX(qse_size_t) @@ -227,8 +227,7 @@ qse_awk_fnc_t* qse_awk_getfnc ( return fnc; } -static int fnc_close ( - qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_close (qse_awk_rtx_t* run, const qse_cstr_t* fnm) { qse_size_t nargs; qse_awk_val_t* v, * a0; @@ -334,8 +333,7 @@ static int flush_io ( return n; } -static int fnc_fflush ( - qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_fflush (qse_awk_rtx_t* run, const qse_cstr_t* fnm) { qse_size_t nargs; qse_awk_val_t* a0; @@ -413,8 +411,7 @@ static int fnc_fflush ( return 0; } -static int fnc_index ( - qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_index (qse_awk_rtx_t* run, const qse_cstr_t* fnm) { qse_size_t nargs; qse_awk_val_t* a0, * a1; @@ -472,8 +469,7 @@ static int fnc_index ( return 0; } -static int fnc_length ( - qse_awk_rtx_t* rtx, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_length (qse_awk_rtx_t* rtx, const qse_cstr_t* fnm) { qse_size_t nargs; qse_awk_val_t* v; @@ -514,8 +510,7 @@ static int fnc_length ( return 0; } -static int fnc_substr ( - qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_substr (qse_awk_rtx_t* run, const qse_cstr_t* fnm) { qse_size_t nargs; qse_awk_val_t* a0, * a1, * a2, * r; @@ -587,8 +582,7 @@ static int fnc_substr ( return 0; } -static int fnc_split ( - qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_split (qse_awk_rtx_t* run, const qse_cstr_t* fnm) { qse_size_t nargs; qse_awk_val_t* a0, * a1, * a2, * t1, * t2, ** a1_ref; @@ -839,8 +833,7 @@ static int fnc_split ( return 0; } -static int fnc_tolower ( - qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_tolower (qse_awk_rtx_t* run, const qse_cstr_t* fnm) { qse_size_t nargs; qse_char_t* str; @@ -878,8 +871,7 @@ static int fnc_tolower ( return 0; } -static int fnc_toupper ( - qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_toupper (qse_awk_rtx_t* run, const qse_cstr_t* fnm) { qse_size_t nargs; qse_char_t* str; @@ -1243,20 +1235,17 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count) return 0; } -static int fnc_gsub ( - qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_gsub (qse_awk_rtx_t* run, const qse_cstr_t* fnm) { return __substitute (run, 0); } -static int fnc_sub ( - qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_sub (qse_awk_rtx_t* run, const qse_cstr_t* fnm) { return __substitute (run, 1); } -static int fnc_match ( - qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_match (qse_awk_rtx_t* run, const qse_cstr_t* fnm) { qse_size_t nargs; qse_awk_val_t* a0, * a1; @@ -1372,8 +1361,7 @@ static int fnc_match ( return 0; } -static int fnc_sprintf ( - qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) +static int fnc_sprintf (qse_awk_rtx_t* run, const qse_cstr_t* fnm) { qse_size_t nargs; qse_awk_val_t* a0; diff --git a/qse/lib/awk/run.c b/qse/lib/awk/run.c index 40ef61f9..c4929608 100644 --- a/qse/lib/awk/run.c +++ b/qse/lib/awk/run.c @@ -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. @@ -5701,8 +5701,8 @@ static qse_awk_val_t* __eval_call ( * qse_awk_setword has been used */ n = call->what.fnc.handler ( run, - call->what.fnc.oname.ptr, - call->what.fnc.oname.len); + xstr_to_cstr(&call->what.fnc.oname) + ); if (n <= -1) { @@ -5712,7 +5712,9 @@ static qse_awk_val_t* __eval_call ( * fix it */ qse_awk_rtx_seterror ( run, QSE_AWK_EFNCIMPL, - nde->line, QSE_NULL); + nde->line, + xstr_to_cstr(&call->what.fnc.oname) + ); } else { diff --git a/qse/lib/awk/std.c b/qse/lib/awk/std.c index 0de4539e..b9e35b5e 100644 --- a/qse/lib/awk/std.c +++ b/qse/lib/awk/std.c @@ -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. @@ -1014,7 +1014,7 @@ enum }; 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) { qse_size_t nargs; @@ -1063,7 +1063,7 @@ static int fnc_math_1 ( } 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_awk_val_t* a0, * a1; @@ -1115,10 +1115,10 @@ static int fnc_math_2 ( 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 ( - run, fnm, fnl, + run, fnm, #if defined(HAVE_SINL) FNC_MATH_LD, (void*)sinl #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 ( - run, fnm, fnl, + run, fnm, #if defined(HAVE_COSL) FNC_MATH_LD, (void*)cosl #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 ( - run, fnm, fnl, + run, fnm, #if defined(HAVE_TANL) FNC_MATH_LD, (void*)tanl #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 ( - run, fnm, fnl, + run, fnm, #if defined(HAVE_ATANL) FNC_MATH_LD, (void*)atanl #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 ( - run, fnm, fnl, + run, fnm, #if defined(HAVE_ATAN2L) FNC_MATH_LD, (void*)atan2l #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 ( - run, fnm, fnl, + run, fnm, #if defined(HAVE_LOGL) FNC_MATH_LD, (void*)logl #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 ( - run, fnm, fnl, + run, fnm, #if defined(HAVE_EXPL) FNC_MATH_LD, (void*)expl #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 ( - run, fnm, fnl, + run, fnm, #if defined(HAVE_SQRTL) FNC_MATH_LD, (void*)sqrtl #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_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; } -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; @@ -1294,7 +1294,7 @@ static int fnc_rand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl) 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_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; } -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_awk_val_t* v; diff --git a/qse/lib/awk/tree.h b/qse/lib/awk/tree.h index 096f7147..0373aec7 100644 --- a/qse/lib/awk/tree.h +++ b/qse/lib/awk/tree.h @@ -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. @@ -286,8 +286,7 @@ struct qse_awk_nde_call_t const qse_char_t* spec; } arg; - int (*handler) ( - qse_awk_rtx_t*, const qse_char_t*, qse_size_t); + qse_awk_fnc_fun_t handler; } fnc; } what; qse_awk_nde_t* args; diff --git a/qse/lib/sed/Sed.cpp b/qse/lib/sed/Sed.cpp index 372df8c3..a84018cd 100644 --- a/qse/lib/sed/Sed.cpp +++ b/qse/lib/sed/Sed.cpp @@ -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. @@ -23,7 +23,7 @@ QSE_BEGIN_NAMESPACE(QSE) ///////////////////////////////// -int Sed::open () throw () +int Sed::open () { sed = qse_sed_open (this, QSE_SIZEOF(Sed*)); if (sed == QSE_NULL) return -1; @@ -35,7 +35,7 @@ int Sed::open () throw () return 0; } -void Sed::close () throw() +void Sed::close () { 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); 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); return qse_sed_comp (sed, sptr, slen); } -int Sed::execute () throw () +int Sed::execute () { QSE_ASSERT (sed != QSE_NULL); return qse_sed_exec (sed, xin, xout); } -int Sed::getOption() const throw () +int Sed::getOption() const { QSE_ASSERT (sed != QSE_NULL); return qse_sed_getoption (sed); } -void Sed::setOption (int opt) throw () +void Sed::setOption (int opt) { QSE_ASSERT (sed != QSE_NULL); 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); 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_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); } -Sed::size_t Sed::getErrorLine () const throw () +Sed::size_t Sed::getErrorLine () const { 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); } @@ -107,19 +107,19 @@ void Sed::setError (errnum_t err, size_t lin, const cstr_t* args) qse_sed_seterror (sed, err, lin, args); } -Sed::size_t Sed::getConsoleLine () throw () +Sed::size_t Sed::getConsoleLine () { QSE_ASSERT (sed != QSE_NULL); return qse_sed_getlinnum (sed); } -void Sed::setConsoleLine (size_t num) throw () +void Sed::setConsoleLine (size_t num) { QSE_ASSERT (sed != QSE_NULL); 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); @@ -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); @@ -233,7 +233,7 @@ const Sed::char_t* Sed::getErrorString (errnum_t num) const 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); try diff --git a/qse/lib/sed/StdSed.cpp b/qse/lib/sed/StdSed.cpp index 9c4c0120..4703a294 100644 --- a/qse/lib/sed/StdSed.cpp +++ b/qse/lib/sed/StdSed.cpp @@ -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. @@ -25,17 +25,17 @@ QSE_BEGIN_NAMESPACE(QSE) ///////////////////////////////// -void* StdSed::allocMem (qse_size_t n) throw () +void* StdSed::allocMem (qse_size_t 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); } -void StdSed::freeMem (void* ptr) throw () +void StdSed::freeMem (void* ptr) { ::free (ptr); } diff --git a/qse/regress/awk/regress.out b/qse/regress/awk/regress.out index e613b78b..c39f92df 100644 --- a/qse/regress/awk/regress.out +++ b/qse/regress/awk/regress.out @@ -1352,7 +1352,7 @@ BEGIN { 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 &1 -------------------------------------------------------------------------------- diff --git a/qse/samples/awk/Makefile.am b/qse/samples/awk/Makefile.am index ab783b70..e664b595 100644 --- a/qse/samples/awk/Makefile.am +++ b/qse/samples/awk/Makefile.am @@ -11,15 +11,15 @@ awk03_SOURCES = awk03.c awk04_SOURCES = awk04.c if ENABLE_CXX -bin_PROGRAMS += awk05 awk06 awk07 awk08 +bin_PROGRAMS += awk05 awk06 awk07 #awk08 awk05_SOURCES = awk05.cpp awk06_SOURCES = awk06.cpp awk07_SOURCES = awk07.cpp -awk08_SOURCES = awk08.cpp +#awk08_SOURCES = awk08.cpp awk05_LDADD = -lqseawk++ $(LDADD) awk06_LDADD = -lqseawk++ $(LDADD) awk07_LDADD = -lqseawk++ $(LDADD) -awk08_LDADD = -lqseawk++ $(LDADD) +#awk08_LDADD = -lqseawk++ $(LDADD) endif diff --git a/qse/samples/awk/Makefile.in b/qse/samples/awk/Makefile.in index a2bf09c7..b0601494 100644 --- a/qse/samples/awk/Makefile.in +++ b/qse/samples/awk/Makefile.in @@ -34,7 +34,7 @@ build_triplet = @build@ host_triplet = @host@ bin_PROGRAMS = awk01$(EXEEXT) awk02$(EXEEXT) awk03$(EXEEXT) \ 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 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 @@ -49,7 +49,7 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/include/qse/config.h CONFIG_CLEAN_FILES = @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)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) @@ -83,10 +83,6 @@ am__awk07_SOURCES_DIST = awk07.cpp @ENABLE_CXX_TRUE@am_awk07_OBJECTS = awk07.$(OBJEXT) awk07_OBJECTS = $(am_awk07_OBJECTS) @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 depcomp = $(SHELL) $(top_srcdir)/ac/au/depcomp am__depfiles_maybe = depfiles @@ -110,11 +106,10 @@ CXXLINK = $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ $(LDFLAGS) -o $@ SOURCES = $(awk01_SOURCES) $(awk02_SOURCES) $(awk03_SOURCES) \ $(awk04_SOURCES) $(awk05_SOURCES) $(awk06_SOURCES) \ - $(awk07_SOURCES) $(awk08_SOURCES) + $(awk07_SOURCES) DIST_SOURCES = $(awk01_SOURCES) $(awk02_SOURCES) $(awk03_SOURCES) \ $(awk04_SOURCES) $(am__awk05_SOURCES_DIST) \ - $(am__awk06_SOURCES_DIST) $(am__awk07_SOURCES_DIST) \ - $(am__awk08_SOURCES_DIST) + $(am__awk06_SOURCES_DIST) $(am__awk07_SOURCES_DIST) ETAGS = etags CTAGS = ctags 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@awk06_SOURCES = awk06.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@awk06_LDADD = -lqseawk++ $(LDADD) @ENABLE_CXX_TRUE@awk07_LDADD = -lqseawk++ $(LDADD) -@ENABLE_CXX_TRUE@awk08_LDADD = -lqseawk++ $(LDADD) all: all-am .SUFFIXES: @@ -350,9 +344,6 @@ awk06$(EXEEXT): $(awk06_OBJECTS) $(awk06_DEPENDENCIES) awk07$(EXEEXT): $(awk07_OBJECTS) $(awk07_DEPENDENCIES) @rm -f awk07$(EXEEXT) $(CXXLINK) $(awk07_OBJECTS) $(awk07_LDADD) $(LIBS) -awk08$(EXEEXT): $(awk08_OBJECTS) $(awk08_DEPENDENCIES) - @rm -f awk08$(EXEEXT) - $(CXXLINK) $(awk08_OBJECTS) $(awk08_LDADD) $(LIBS) mostlyclean-compile: -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)/awk06.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: @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 \ uninstall-binPROGRAMS +#awk08_LDADD = -lqseawk++ $(LDADD) # 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. .NOEXPORT: diff --git a/qse/samples/awk/awk05.cpp b/qse/samples/awk/awk05.cpp index 97093334..39e94ca1 100644 --- a/qse/samples/awk/awk05.cpp +++ b/qse/samples/awk/awk05.cpp @@ -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) { // ARGV[0] @@ -65,7 +60,7 @@ static int awk_main (int argc, qse_char_t* argv[]) int ret = awk.open (); 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 (); return ret; diff --git a/qse/samples/awk/awk06.cpp b/qse/samples/awk/awk06.cpp index 11d0f536..e165d693 100644 --- a/qse/samples/awk/awk06.cpp +++ b/qse/samples/awk/awk06.cpp @@ -78,7 +78,7 @@ static int awk_main (int argc, qse_char_t* argv[]) int ret = awk.open(); 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 (); return -1; diff --git a/qse/samples/awk/awk07.cpp b/qse/samples/awk/awk07.cpp index 57bcb4b8..5b3b5128 100644 --- a/qse/samples/awk/awk07.cpp +++ b/qse/samples/awk/awk07.cpp @@ -123,7 +123,7 @@ static int awk_main (int argc, qse_char_t* argv[]) QSE::StdAwk::OPT_RESET); 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 (); return -1; diff --git a/qse/samples/awk/awk08.cpp b/qse/samples/awk/awk08.cpp index 869dcf7a..c6421646 100644 --- a/qse/samples/awk/awk08.cpp +++ b/qse/samples/awk/awk08.cpp @@ -481,14 +481,14 @@ static int awk_main (int argc, qse_char_t* argv[]) if (awk.open() <= -1) { - print_error (awk.errorMessage()); + print_error (awk.getErrorMessage()); return -1; } // ARGV[0] if (awk.addArgument (QSE_T("awk05")) <= -1) { - print_error (awk.errorMessage()); + print_error (awk.getErrorMessage()); awk.close (); return -1; } @@ -629,7 +629,7 @@ static int awk_main (int argc, qse_char_t* argv[]) if (run == QSE_NULL) { qse_fprintf (stderr, QSE_T("cannot parse: LINE[%d] %s\n"), - awk.errorLine(), awk.errorMessage()); + awk.getErrorLine(), awk.getErrorMessage()); awk.close (); return -1; } @@ -640,7 +640,7 @@ static int awk_main (int argc, qse_char_t* argv[]) if (awk.loop () <= -1) { qse_fprintf (stderr, QSE_T("cannot run: LINE[%d] %s\n"), - awk.errorLine(), awk.errorMessage()); + awk.getErrorLine(), awk.getErrorMessage()); awk.close (); 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) { qse_fprintf (stderr, QSE_T("cannot run: LINE[%d] %s\n"), - awk.errorLine(), awk.errorMessage()); + awk.getErrorLine(), awk.getErrorMessage()); awk.close (); } #endif