fixed to set path on the sio argument in HawkStd
removed some redefinition of primitive types in Hawk
This commit is contained in:
		| @ -168,8 +168,8 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \ | ||||
| 	$(top_srcdir)/ac/compile $(top_srcdir)/ac/config.guess \ | ||||
| 	$(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \ | ||||
| 	$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \ | ||||
| 	ac/compile ac/config.guess ac/config.sub ac/install-sh \ | ||||
| 	ac/ltmain.sh ac/missing | ||||
| 	ac/compile ac/config.guess ac/config.sub ac/depcomp \ | ||||
| 	ac/install-sh ac/ltmain.sh ac/missing | ||||
| DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) | ||||
| distdir = $(PACKAGE)-$(VERSION) | ||||
| top_distdir = $(distdir) | ||||
|  | ||||
							
								
								
									
										2
									
								
								hawk/configure
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								hawk/configure
									
									
									
									
										vendored
									
									
								
							| @ -18730,7 +18730,7 @@ fi | ||||
|  | ||||
| done | ||||
|  | ||||
| for ac_header in ffi.h dyncall.h libunwind.h quadmath.h | ||||
| for ac_header in ffi.h dyncall.h libunwind.h quadmath.h crt_externs.h | ||||
| do : | ||||
|   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` | ||||
| ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" | ||||
|  | ||||
| @ -189,7 +189,7 @@ AC_CHECK_HEADERS([netinet/in.h sys/un.h netpacket/packet.h net/if.h net/if_dl.h] | ||||
| 	#include <sys/types.h> | ||||
| 	#include <sys/socket.h>]) | ||||
| AC_CHECK_HEADERS([sys/stropts.h sys/macstat.h linux/ethtool.h linux/sockios.h]) | ||||
| AC_CHECK_HEADERS([ffi.h dyncall.h libunwind.h quadmath.h]) | ||||
| AC_CHECK_HEADERS([ffi.h dyncall.h libunwind.h quadmath.h crt_externs.h]) | ||||
|  | ||||
| dnl check data types | ||||
| dnl AC_CHECK_TYPE([wchar_t],  | ||||
|  | ||||
| @ -853,7 +853,7 @@ int Hawk::Value::setMbs (Run* r, const hawk_bch_t* str) | ||||
| int Hawk::Value::setIndexedVal (const Index& idx, hawk_val_t* v) | ||||
| { | ||||
| 	if (this->run == HAWK_NULL) return -1; | ||||
| 	return this->setIndexedVal (this->run, idx, v); | ||||
| 	return this->setIndexedVal(this->run, idx, v); | ||||
| } | ||||
|  | ||||
| int Hawk::Value::setIndexedVal (Run* r, const Index& idx, hawk_val_t* v) | ||||
| @ -1430,11 +1430,9 @@ int Hawk::open () | ||||
| 	xtn->ecb.close = fini_xtn; | ||||
| 	xtn->ecb.clear = clear_xtn; | ||||
|  | ||||
| /* | ||||
| // TODO: | ||||
| 	dflerrstr = hawk_geterrstr(this->awk); | ||||
| 	hawk_seterrstr (this->awk, Hawk::xerrstr); | ||||
| */ | ||||
| 	this->dflerrstr = hawk_geterrstr(this->awk); | ||||
| // TODO: revive this too when hawk_seterrstr is revived() | ||||
| //	hawk_seterrstr (this->awk, Hawk::xerrstr); | ||||
|  | ||||
| #if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP) | ||||
| 	this->functionMap = hawk_htb_open( | ||||
| @ -1727,7 +1725,7 @@ void Hawk::setMaxDepth (depth_t id, hawk_oow_t depth) | ||||
| 	hawk_setopt (awk, (hawk_opt_t)id, &depth); | ||||
| } | ||||
|  | ||||
| int Hawk::dispatch_function (Run* run, const fnc_info_t* fi) | ||||
| int Hawk::dispatch_function (Run* run, const hawk_fnc_info_t* fi) | ||||
| { | ||||
| 	bool has_ref_arg = false; | ||||
|  | ||||
| @ -2193,7 +2191,7 @@ int Hawk::deleteFunction (const hawk_ooch_t* name) | ||||
| 	return n; | ||||
| } | ||||
|  | ||||
| hawk_ooi_t Hawk::readSource (hawk_t* hawk, sio_cmd_t cmd, sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t count) | ||||
| hawk_ooi_t Hawk::readSource (hawk_t* hawk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t count) | ||||
| { | ||||
| 	xtn_t* xtn = GET_XTN(hawk); | ||||
| 	Source::Data sdat(xtn->hawk, Source::READ, arg); | ||||
| @ -2212,7 +2210,7 @@ hawk_ooi_t Hawk::readSource (hawk_t* hawk, sio_cmd_t cmd, sio_arg_t* arg, hawk_o | ||||
| 	} | ||||
| } | ||||
|  | ||||
| hawk_ooi_t Hawk::writeSource (hawk_t* hawk, hawk_sio_cmd_t cmd, sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t count) | ||||
| hawk_ooi_t Hawk::writeSource (hawk_t* hawk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, hawk_ooch_t* data, hawk_oow_t count) | ||||
| { | ||||
| 	xtn_t* xtn = GET_XTN(hawk); | ||||
| 	Source::Data sdat (xtn->hawk, Source::WRITE, arg); | ||||
| @ -2231,7 +2229,7 @@ hawk_ooi_t Hawk::writeSource (hawk_t* hawk, hawk_sio_cmd_t cmd, sio_arg_t* arg, | ||||
| 	} | ||||
| } | ||||
|  | ||||
| hawk_ooi_t Hawk::pipeHandler (hawk_rtx_t* rtx, rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t count) | ||||
| hawk_ooi_t Hawk::pipeHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t count) | ||||
| { | ||||
| 	rxtn_t* rxtn = GET_RXTN(rtx); | ||||
| 	Hawk* awk = rxtn->run->awk; | ||||
| @ -2297,7 +2295,7 @@ hawk_ooi_t Hawk::pipeHandler (hawk_rtx_t* rtx, rio_cmd_t cmd, hawk_rio_arg_t* ri | ||||
| 	} | ||||
| } | ||||
|  | ||||
| hawk_ooi_t Hawk::fileHandler (hawk_rtx_t* rtx, rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t count) | ||||
| hawk_ooi_t Hawk::fileHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t count) | ||||
| { | ||||
| 	rxtn_t* rxtn = GET_RXTN(rtx); | ||||
| 	Hawk* awk = rxtn->run->awk; | ||||
| @ -2363,7 +2361,7 @@ hawk_ooi_t Hawk::fileHandler (hawk_rtx_t* rtx, rio_cmd_t cmd, hawk_rio_arg_t* ri | ||||
| 	} | ||||
| } | ||||
|  | ||||
| hawk_ooi_t Hawk::consoleHandler (hawk_rtx_t* rtx, rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t count) | ||||
| hawk_ooi_t Hawk::consoleHandler (hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, void* data, hawk_oow_t count) | ||||
| { | ||||
| 	rxtn_t* rxtn = GET_RXTN(rtx); | ||||
| 	Hawk* awk = rxtn->run->awk; | ||||
| @ -2547,7 +2545,7 @@ int Hawk::nextConsole (Console& io) | ||||
| 	return -1; | ||||
| } | ||||
|  | ||||
| int Hawk::functionHandler (hawk_rtx_t* rtx, const fnc_info_t* fi) | ||||
| int Hawk::functionHandler (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) | ||||
| { | ||||
| 	rxtn_t* rxtn = GET_RXTN(rtx); | ||||
| 	return rxtn->run->awk->dispatch_function(rxtn->run, fi); | ||||
| @ -2565,7 +2563,7 @@ Hawk::flt_t Hawk::mod (hawk_t* awk, flt_t x, flt_t y) | ||||
| 	return xtn->hawk->mod(x, y); | ||||
| } | ||||
|  | ||||
| void* Hawk::modopen (hawk_t* awk, const mod_spec_t* spec) | ||||
| void* Hawk::modopen (hawk_t* awk, const hawk_mod_spec_t* spec) | ||||
| { | ||||
| 	xtn_t* xtn = GET_XTN(awk); | ||||
| 	return xtn->hawk->modopen(spec); | ||||
|  | ||||
| @ -396,23 +396,6 @@ public: | ||||
| 		DEPTH_REX_MATCH   = HAWK_DEPTH_REX_MATCH | ||||
| 	}; | ||||
|  | ||||
| 	/// The gbl_id_t type redefines #hawk_gbl_id_t. | ||||
| 	typedef hawk_gbl_id_t gbl_id_t; | ||||
|  | ||||
| 	/** Represents an runtime I/O data */ | ||||
|  | ||||
| 	typedef hawk_rio_cmd_t rio_cmd_t; | ||||
|  | ||||
| 	typedef hawk_sio_arg_t sio_arg_t; | ||||
|  | ||||
| 	typedef hawk_sio_cmd_t sio_cmd_t; | ||||
|  | ||||
| 	typedef hawk_fnc_spec_t fnc_spec_t; | ||||
|  | ||||
| 	typedef hawk_fnc_info_t fnc_info_t; | ||||
|  | ||||
| 	typedef hawk_mod_spec_t mod_spec_t; | ||||
|  | ||||
| 	class Run; | ||||
| 	friend class Run; | ||||
|  | ||||
| @ -431,7 +414,7 @@ protected: | ||||
| 	/// different. The example below changes the formatting string for | ||||
| 	/// #HAWK_ENOENT. | ||||
| 	/// \code | ||||
| 	/// const hawk_ooch_t* MyHawk::getErrorString (hawk_hawk_errnum_t num) const  | ||||
| 	/// const hawk_ooch_t* MyHawk::getErrorString (hawk_errnum_t num) const  | ||||
| 	/// { | ||||
| 	///    if (num == HAWK_ENOENT) return HAWK_T("cannot find '${0}'"); | ||||
| 	///    return Hawk::getErrorString (num); | ||||
| @ -506,7 +489,7 @@ public: | ||||
| 		/// The Mode type defines opening mode. | ||||
| 		/// | ||||
| 		enum Mode | ||||
| 		{	 | ||||
| 		{ | ||||
| 			READ,   ///< open for read | ||||
| 			WRITE   ///< open for write | ||||
| 		}; | ||||
| @ -521,7 +504,7 @@ public: | ||||
| 			friend class Hawk; | ||||
|  | ||||
| 		protected: | ||||
| 			Data (Hawk* awk, Mode mode, sio_arg_t* arg):  | ||||
| 			Data (Hawk* awk, Mode mode, hawk_sio_arg_t* arg):  | ||||
| 				awk (awk), mode (mode), arg (arg) | ||||
| 			{ | ||||
| 			} | ||||
| @ -549,6 +532,16 @@ public: | ||||
| 				this->arg->name = name; | ||||
| 			} | ||||
|  | ||||
| 			const hawk_ooch_t* getPath() const | ||||
| 			{ | ||||
| 				return this->arg->path; | ||||
| 			} | ||||
|  | ||||
| 			void setPath (const hawk_ooch_t* path) | ||||
| 			{ | ||||
| 				this->arg->path = (hawk_ooch_t*)path; | ||||
| 			} | ||||
|  | ||||
| 			const hawk_ooch_t* getPrevName() const | ||||
| 			{ | ||||
| 				return this->arg->prev->name; | ||||
| @ -582,7 +575,7 @@ public: | ||||
| 		protected: | ||||
| 			Hawk* awk; | ||||
| 			Mode  mode; | ||||
| 			sio_arg_t* arg; | ||||
| 			hawk_sio_arg_t* arg; | ||||
| 		}; | ||||
|  | ||||
| 		Source () {} | ||||
| @ -1372,20 +1365,20 @@ public: | ||||
| 	/// The call() function invokes a function named \a name. | ||||
| 	/// | ||||
| 	int call ( | ||||
| 		const hawk_bch_t* name,  ///< function name | ||||
| 		const hawk_bch_t*  name,  ///< function name | ||||
| 		Value*             ret,   ///< return value holder | ||||
| 		const Value*       args,  ///< argument array | ||||
| 		hawk_oow_t             nargs  ///< number of arguments | ||||
| 		hawk_oow_t         nargs  ///< number of arguments | ||||
| 	); | ||||
|  | ||||
| 	/// | ||||
| 	/// The call() function invokes a function named \a name. | ||||
| 	/// | ||||
| 	int call ( | ||||
| 		const hawk_uch_t* name,  ///< function name | ||||
| 		const hawk_uch_t*  name,  ///< function name | ||||
| 		Value*             ret,   ///< return value holder | ||||
| 		const Value*       args,  ///< argument array | ||||
| 		hawk_oow_t             nargs  ///< number of arguments | ||||
| 		hawk_oow_t         nargs  ///< number of arguments | ||||
| 	); | ||||
|  | ||||
| 	/// | ||||
| @ -1505,7 +1498,7 @@ public: | ||||
| 	/// | ||||
| 	/// The setGlobal() function sets the value of a global variable  | ||||
| 	/// identified by \a id. The \a id is either a value returned by  | ||||
| 	/// addGlobal() or one of the #gbl_id_t enumerators. It is not allowed | ||||
| 	/// addGlobal() or one of the #hawk_gbl_id_t enumerators. It is not allowed | ||||
| 	/// to call this function prior to parse(). | ||||
| 	/// \return 0 on success, -1 on failure | ||||
| 	/// | ||||
| @ -1517,7 +1510,7 @@ public: | ||||
| 	/// | ||||
| 	/// The getGlobal() function gets the value of a global variable  | ||||
| 	/// identified by \a id. The \a id is either a value returned by  | ||||
| 	/// addGlobal() or one of the #gbl_id_t enumerators. It is not allowed | ||||
| 	/// addGlobal() or one of the #hawk_gbl_id_t enumerators. It is not allowed | ||||
| 	/// to call this function before parse(). | ||||
| 	/// \return 0 on success, -1 on failure | ||||
| 	/// | ||||
| @ -1534,7 +1527,7 @@ public: | ||||
| 		Value&            ret, | ||||
| 		Value*            args, | ||||
| 		hawk_oow_t        nargs,  | ||||
| 		const fnc_info_t* fi | ||||
| 		const hawk_fnc_info_t* fi | ||||
| 	); | ||||
|  | ||||
| 	///  | ||||
| @ -1690,35 +1683,35 @@ protected: | ||||
| 	virtual flt_t pow (flt_t x, flt_t y) = 0; | ||||
| 	virtual flt_t mod (flt_t x, flt_t y) = 0; | ||||
|  | ||||
| 	virtual void* modopen (const mod_spec_t* spec) = 0; | ||||
| 	virtual void* modopen (const hawk_mod_spec_t* spec) = 0; | ||||
| 	virtual void  modclose (void* handle) = 0; | ||||
| 	virtual void* modgetsym (void* handle, const hawk_ooch_t* name) = 0; | ||||
|  | ||||
| 	// static glue members for various handlers | ||||
| 	static hawk_ooi_t readSource ( | ||||
| 		hawk_t* awk, sio_cmd_t cmd, sio_arg_t* arg, | ||||
| 		hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, | ||||
| 		hawk_ooch_t* data, hawk_oow_t count); | ||||
| 	static hawk_ooi_t writeSource ( | ||||
| 		hawk_t* awk, sio_cmd_t cmd, sio_arg_t* arg, | ||||
| 		hawk_t* awk, hawk_sio_cmd_t cmd, hawk_sio_arg_t* arg, | ||||
| 		hawk_ooch_t* data, hawk_oow_t count); | ||||
|  | ||||
| 	static hawk_ooi_t pipeHandler ( | ||||
| 		hawk_rtx_t* rtx, rio_cmd_t cmd, hawk_rio_arg_t* riod, | ||||
| 		hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, | ||||
| 		void* data, hawk_oow_t count); | ||||
| 	static hawk_ooi_t fileHandler ( | ||||
| 		hawk_rtx_t* rtx, rio_cmd_t cmd, hawk_rio_arg_t* riod, | ||||
| 		hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, | ||||
| 		void* data, hawk_oow_t count); | ||||
| 	static hawk_ooi_t consoleHandler ( | ||||
| 		hawk_rtx_t* rtx, rio_cmd_t cmd, hawk_rio_arg_t* riod, | ||||
| 		hawk_rtx_t* rtx, hawk_rio_cmd_t cmd, hawk_rio_arg_t* riod, | ||||
| 		void* data, hawk_oow_t count); | ||||
|  | ||||
| 	static int functionHandler (hawk_rtx_t* rtx, const fnc_info_t* fi); | ||||
| 	static int functionHandler (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi); | ||||
|  | ||||
|  | ||||
| 	static flt_t pow (hawk_t* awk, flt_t x, flt_t y); | ||||
| 	static flt_t mod (hawk_t* awk, flt_t x, flt_t y); | ||||
|  | ||||
| 	static void* modopen (hawk_t* awk, const mod_spec_t* spec); | ||||
| 	static void* modopen (hawk_t* awk, const hawk_mod_spec_t* spec); | ||||
| 	static void  modclose (hawk_t* awk, void* handle); | ||||
| 	static void* modgetsym (hawk_t* awk, void* handle, const hawk_ooch_t* name); | ||||
|  | ||||
| @ -1776,7 +1769,7 @@ private: | ||||
|  | ||||
| 	int init_runctx (); | ||||
| 	void fini_runctx (); | ||||
| 	int dispatch_function (Run* run, const fnc_info_t* fi); | ||||
| 	int dispatch_function (Run* run, const hawk_fnc_info_t* fi); | ||||
|  | ||||
| 	static const hawk_ooch_t* xerrstr (hawk_t* a, hawk_errnum_t num); | ||||
| }; | ||||
|  | ||||
| @ -30,14 +30,7 @@ | ||||
| #include <hawk-std.h> // for hawk_stdmodXXX() functions | ||||
| #include "hawk-prv.h" | ||||
| #include <stdlib.h> | ||||
|  | ||||
| #if !defined(HAWK_HAVE_CONFIG_H) | ||||
| #	if defined(_WIN32) || defined(__OS2__) || defined(__DOS__) | ||||
| #		define HAVE_POW | ||||
| #		define HAVE_FMOD | ||||
| #	endif | ||||
| #endif | ||||
|  | ||||
| #include <stdio.h> | ||||
|  | ||||
| // TODO: remove the following definitions and find a way to share the similar definitions in std.c  | ||||
| #if defined(HAWK_ENABLE_LIBLTDL) | ||||
| @ -48,7 +41,12 @@ | ||||
| #	error UNSUPPORTED DYNAMIC LINKER | ||||
| #endif | ||||
|  | ||||
| extern char **environ; | ||||
| #if defined(HAVE_CRT_EXTERNS_H) | ||||
| #	include <crt_externs.h> /* MacOSX/darwin. _NSGetEnviron() */ | ||||
| #	define environ (*(_NSGetEnviron())) | ||||
| #else | ||||
| 	extern char** environ; | ||||
| #endif | ||||
|  | ||||
| ///////////////////////////////// | ||||
| HAWK_BEGIN_NAMESPACE(HAWK) | ||||
| @ -1155,7 +1153,7 @@ HawkStd::flt_t HawkStd::mod (flt_t x, flt_t y) | ||||
| 	return hawk_stdmathmod (this->awk, x, y); | ||||
| } | ||||
|  | ||||
| void* HawkStd::modopen (const mod_spec_t* spec) | ||||
| void* HawkStd::modopen (const hawk_mod_spec_t* spec) | ||||
| { | ||||
| 	void* h; | ||||
| 	h = hawk_stdmodopen (this->awk, spec); | ||||
| @ -1185,7 +1183,6 @@ HawkStd::SourceFile::~SourceFile () | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| int HawkStd::SourceFile::open (Data& io) | ||||
| { | ||||
| 	hawk_sio_t* sio; | ||||
| @ -1213,11 +1210,7 @@ int HawkStd::SourceFile::open (Data& io) | ||||
| 				this->name = hawk_dupbcstr(this->_hawk, (hawk_bch_t*)this->_name, HAWK_NULL); | ||||
| 			#endif | ||||
| 			} | ||||
| 			if (!this->name)  | ||||
| 			{ | ||||
| 				// TODO: check if retrieveError is needed //((Hawk*)io)->retrieveError(); | ||||
| 				return -1; | ||||
| 			} | ||||
| 			if (!this->name) return -1; | ||||
| 		} | ||||
|  | ||||
| 		if (this->name[0] == HAWK_T('-') && this->name[1] == HAWK_T('\0')) | ||||
| @ -1246,22 +1239,24 @@ int HawkStd::SourceFile::open (Data& io) | ||||
|  | ||||
| 		if (this->cmgr) hawk_sio_setcmgr (sio, this->cmgr); | ||||
| 		io.setName (this->name); | ||||
| 		io.setPath (this->name); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		// open an included file | ||||
| 		const hawk_ooch_t* ioname, * file; | ||||
| 		hawk_ooch_t fbuf[64]; | ||||
| 		hawk_ooch_t* dbuf = HAWK_NULL; | ||||
| 	 | ||||
| 		// open an included file  | ||||
| 		const hawk_ooch_t* ioname; | ||||
| 		hawk_ooch_t* xpath; | ||||
|  | ||||
| 		ioname = io.getName(); | ||||
| 		HAWK_ASSERT (ioname != HAWK_NULL); | ||||
|  | ||||
| 		file = ioname; | ||||
| 		if (io.getPrevHandle()) | ||||
| 		{ | ||||
| 			const hawk_ooch_t* outer; | ||||
| 			const hawk_ooch_t* outer, * path; | ||||
| 			hawk_ooch_t fbuf[64]; | ||||
| 			hawk_ooch_t* dbuf = HAWK_NULL; | ||||
|  | ||||
| 			path = ioname; | ||||
| 			outer = hawk_sio_getpath((hawk_sio_t*)io.getPrevHandle()); | ||||
| 			if (outer) | ||||
| 			{ | ||||
| @ -1271,39 +1266,40 @@ int HawkStd::SourceFile::open (Data& io) | ||||
| 				if (base != outer && ioname[0] != HAWK_T('/')) | ||||
| 				{ | ||||
| 					hawk_oow_t tmplen, totlen, dirlen; | ||||
| 				 | ||||
|  | ||||
| 					dirlen = base - outer; | ||||
| 					totlen = hawk_count_oocstr(ioname) + dirlen; | ||||
| 					if (totlen >= HAWK_COUNTOF(fbuf)) | ||||
| 					{ | ||||
| 						dbuf = (hawk_ooch_t*)HAWK_MMGR_ALLOC( | ||||
| 							((Hawk*)io)->getMmgr(), | ||||
| 							HAWK_SIZEOF(hawk_ooch_t) * (totlen + 1) | ||||
| 						); | ||||
| 						if (dbuf == HAWK_NULL) | ||||
| 						{ | ||||
| 							((Hawk*)io)->setError (HAWK_ENOMEM); | ||||
| 							return -1; | ||||
| 						} | ||||
|  | ||||
| 						file = dbuf; | ||||
| 						dbuf = (hawk_ooch_t*)hawk_allocmem((hawk_t*)io, HAWK_SIZEOF(hawk_ooch_t) * (totlen + 1)); | ||||
| 						if (!dbuf) return -1; | ||||
| 						path = dbuf; | ||||
| 					} | ||||
| 					else file = fbuf; | ||||
| 					else path = fbuf; | ||||
|  | ||||
| 					tmplen = hawk_copy_oochars_to_oocstr_unlimited ((hawk_ooch_t*)file, outer, dirlen); | ||||
| 					hawk_copy_oocstr_unlimited ((hawk_ooch_t*)file + tmplen, ioname); | ||||
| 					tmplen = hawk_copy_oochars_to_oocstr_unlimited((hawk_ooch_t*)path, outer, dirlen); | ||||
| 					hawk_copy_oocstr_unlimited ((hawk_ooch_t*)path + tmplen, ioname); | ||||
| 				} | ||||
| 			} | ||||
| 			xpath = hawk_addsionamewithoochars((hawk_t*)io, path, hawk_count_oocstr(path)); | ||||
| 			if (dbuf) hawk_freemem ((hawk_t*)io, dbuf); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			xpath = hawk_addsionamewithoochars((hawk_t*)io, ioname, hawk_count_oocstr(ioname)); | ||||
| 		} | ||||
| 		if (!xpath) return -1; | ||||
|  | ||||
| 		sio = open_sio( | ||||
| 			io, HAWK_NULL, file, | ||||
| 			io, HAWK_NULL, xpath, | ||||
| 			(io.getMode() == READ?  | ||||
| 				(HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH):  | ||||
| 				(HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR)) | ||||
| 		); | ||||
| 		if (dbuf) HAWK_MMGR_FREE (((Hawk*)io)->getMmgr(), dbuf); | ||||
| 		if (sio == HAWK_NULL) return -1; | ||||
| 		if (!sio) return -1; | ||||
|  | ||||
| 		io.setPath (xpath); | ||||
| 		io.setHandle (sio); | ||||
| 		if (this->cmgr) hawk_sio_setcmgr (sio, this->cmgr); | ||||
| 	} | ||||
|  | ||||
| @ -1372,11 +1368,7 @@ int HawkStd::SourceString::open (Data& io) | ||||
| 				this->str = hawk_dupbcstr(this->_hawk, (hawk_bch_t*)this->_str, HAWK_NULL); | ||||
| 			#endif | ||||
| 			} | ||||
| 			if (!this->str)  | ||||
| 			{ | ||||
| 				// TODO: check if retrieveError is needed  | ||||
| 				return -1; | ||||
| 			} | ||||
| 			if (!this->str) return -1; | ||||
| 		} | ||||
|  | ||||
| 		this->ptr = this->str; | ||||
| @ -1384,19 +1376,19 @@ int HawkStd::SourceString::open (Data& io) | ||||
| 	else | ||||
| 	{ | ||||
| 		// open an included file  | ||||
| 		const hawk_ooch_t* ioname; | ||||
| 		hawk_ooch_t* xpath; | ||||
|  | ||||
| 		const hawk_ooch_t* ioname, * file; | ||||
| 		hawk_ooch_t fbuf[64]; | ||||
| 		hawk_ooch_t* dbuf = HAWK_NULL; | ||||
| 		 | ||||
| 		ioname = io.getName(); | ||||
| 		HAWK_ASSERT (ioname != HAWK_NULL); | ||||
|  | ||||
| 		file = ioname; | ||||
| 		if (io.getPrevHandle()) | ||||
| 		{ | ||||
| 			const hawk_ooch_t* outer; | ||||
| 			const hawk_ooch_t* outer, * path; | ||||
| 			hawk_ooch_t fbuf[64]; | ||||
| 			hawk_ooch_t* dbuf = HAWK_NULL; | ||||
|  | ||||
| 			path = ioname; | ||||
| 			outer = hawk_sio_getpath((hawk_sio_t*)io.getPrevHandle()); | ||||
| 			if (outer) | ||||
| 			{ | ||||
| @ -1406,38 +1398,41 @@ int HawkStd::SourceString::open (Data& io) | ||||
| 				if (base != outer && ioname[0] != HAWK_T('/')) | ||||
| 				{ | ||||
| 					hawk_oow_t tmplen, totlen, dirlen; | ||||
| 				 | ||||
|  | ||||
| 					dirlen = base - outer; | ||||
| 					totlen = hawk_count_oocstr(ioname) + dirlen; | ||||
| 					if (totlen >= HAWK_COUNTOF(fbuf)) | ||||
| 					{ | ||||
| 						dbuf = (hawk_ooch_t*)hawk_allocmem((hawk_t*)io, HAWK_SIZEOF(hawk_ooch_t) * (totlen + 1)); | ||||
| 						if (dbuf == HAWK_NULL) | ||||
| 						{ | ||||
| 							// TODO: check if retrieveError is needed  | ||||
| 							return -1; | ||||
| 						} | ||||
|  | ||||
| 						file = dbuf; | ||||
| 						if (!dbuf) return -1; | ||||
| 						path = dbuf; | ||||
| 					} | ||||
| 					else file = fbuf; | ||||
| 					else path = fbuf; | ||||
|  | ||||
| 					tmplen = hawk_copy_oochars_to_oocstr_unlimited((hawk_ooch_t*)file, outer, dirlen); | ||||
| 					hawk_copy_oocstr_unlimited ((hawk_ooch_t*)file + tmplen, ioname); | ||||
| 					tmplen = hawk_copy_oochars_to_oocstr_unlimited((hawk_ooch_t*)path, outer, dirlen); | ||||
| 					hawk_copy_oocstr_unlimited ((hawk_ooch_t*)path + tmplen, ioname); | ||||
| 				} | ||||
| 			} | ||||
| 			xpath = hawk_addsionamewithoochars((hawk_t*)io, path, hawk_count_oocstr(path)); | ||||
| 			if (dbuf) hawk_freemem ((hawk_t*)io, dbuf); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			xpath = hawk_addsionamewithoochars((hawk_t*)io, ioname, hawk_count_oocstr(ioname)); | ||||
| 		} | ||||
| 		if (!xpath) return -1; | ||||
|  | ||||
| 		sio = open_sio( | ||||
| 			io, HAWK_NULL, file, | ||||
| 			io, HAWK_NULL, xpath, | ||||
| 			(io.getMode() == READ?  | ||||
| 				(HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH):  | ||||
| 				(HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR)) | ||||
| 		); | ||||
| 		if (dbuf) hawk_freemem ((hawk_t*)io, dbuf); | ||||
| 		if (sio == HAWK_NULL) return -1; | ||||
| 		if (!sio) return -1; | ||||
|  | ||||
| 		io.setPath (xpath); | ||||
| 		io.setHandle (sio); | ||||
| 		//if (this->cmgr) hawk_sio_setcmgr (sio, this->cmgr); | ||||
| 	} | ||||
|  | ||||
| 	return 1; | ||||
|  | ||||
| @ -202,7 +202,7 @@ protected: | ||||
| 	flt_t pow (flt_t x, flt_t y); | ||||
| 	flt_t mod (flt_t x, flt_t y); | ||||
|  | ||||
| 	void* modopen (const mod_spec_t* spec); | ||||
| 	void* modopen (const hawk_mod_spec_t* spec); | ||||
| 	void  modclose (void* handle); | ||||
| 	void* modgetsym (void* handle, const hawk_ooch_t* name); | ||||
|  | ||||
|  | ||||
| @ -108,6 +108,9 @@ | ||||
| /* Define to 1 if you have the `cosq' function. */ | ||||
| #undef HAVE_COSQ | ||||
|  | ||||
| /* Define to 1 if you have the <crt_externs.h> header file. */ | ||||
| #undef HAVE_CRT_EXTERNS_H | ||||
|  | ||||
| /* Define if c++ supports namespace std. */ | ||||
| #undef HAVE_CXX_NAMESPACE_STD | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user