fixed to set path on the sio argument in HawkStd

removed some redefinition of primitive types in Hawk
This commit is contained in:
hyung-hwan 2020-01-08 03:14:41 +00:00
parent 4af782af80
commit 19c1a9e831
8 changed files with 111 additions and 122 deletions

View File

@ -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/compile $(top_srcdir)/ac/config.guess \
$(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \ $(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \
$(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \ $(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing ac/ar-lib \
ac/compile ac/config.guess ac/config.sub ac/install-sh \ ac/compile ac/config.guess ac/config.sub ac/depcomp \
ac/ltmain.sh ac/missing ac/install-sh ac/ltmain.sh ac/missing
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION) distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir) top_distdir = $(distdir)

2
hawk/configure vendored
View File

@ -18730,7 +18730,7 @@ fi
done 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 : do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` 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" ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"

View File

@ -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/types.h>
#include <sys/socket.h>]) #include <sys/socket.h>])
AC_CHECK_HEADERS([sys/stropts.h sys/macstat.h linux/ethtool.h linux/sockios.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 check data types
dnl AC_CHECK_TYPE([wchar_t], dnl AC_CHECK_TYPE([wchar_t],

View File

@ -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) int Hawk::Value::setIndexedVal (const Index& idx, hawk_val_t* v)
{ {
if (this->run == HAWK_NULL) return -1; 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) 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.close = fini_xtn;
xtn->ecb.clear = clear_xtn; xtn->ecb.clear = clear_xtn;
/* this->dflerrstr = hawk_geterrstr(this->awk);
// TODO: // TODO: revive this too when hawk_seterrstr is revived()
dflerrstr = hawk_geterrstr(this->awk); // hawk_seterrstr (this->awk, Hawk::xerrstr);
hawk_seterrstr (this->awk, Hawk::xerrstr);
*/
#if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP) #if defined(HAWK_USE_HTB_FOR_FUNCTION_MAP)
this->functionMap = hawk_htb_open( 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); 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; bool has_ref_arg = false;
@ -2193,7 +2191,7 @@ int Hawk::deleteFunction (const hawk_ooch_t* name)
return n; 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); xtn_t* xtn = GET_XTN(hawk);
Source::Data sdat(xtn->hawk, Source::READ, arg); 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); xtn_t* xtn = GET_XTN(hawk);
Source::Data sdat (xtn->hawk, Source::WRITE, arg); 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); rxtn_t* rxtn = GET_RXTN(rtx);
Hawk* awk = rxtn->run->awk; 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); rxtn_t* rxtn = GET_RXTN(rtx);
Hawk* awk = rxtn->run->awk; 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); rxtn_t* rxtn = GET_RXTN(rtx);
Hawk* awk = rxtn->run->awk; Hawk* awk = rxtn->run->awk;
@ -2547,7 +2545,7 @@ int Hawk::nextConsole (Console& io)
return -1; 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); rxtn_t* rxtn = GET_RXTN(rtx);
return rxtn->run->awk->dispatch_function(rxtn->run, fi); 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); 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); xtn_t* xtn = GET_XTN(awk);
return xtn->hawk->modopen(spec); return xtn->hawk->modopen(spec);

View File

@ -396,23 +396,6 @@ public:
DEPTH_REX_MATCH = HAWK_DEPTH_REX_MATCH 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; class Run;
friend class Run; friend class Run;
@ -431,7 +414,7 @@ protected:
/// different. The example below changes the formatting string for /// different. The example below changes the formatting string for
/// #HAWK_ENOENT. /// #HAWK_ENOENT.
/// \code /// \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}'"); /// if (num == HAWK_ENOENT) return HAWK_T("cannot find '${0}'");
/// return Hawk::getErrorString (num); /// return Hawk::getErrorString (num);
@ -521,7 +504,7 @@ public:
friend class Hawk; friend class Hawk;
protected: 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) awk (awk), mode (mode), arg (arg)
{ {
} }
@ -549,6 +532,16 @@ public:
this->arg->name = name; 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 const hawk_ooch_t* getPrevName() const
{ {
return this->arg->prev->name; return this->arg->prev->name;
@ -582,7 +575,7 @@ public:
protected: protected:
Hawk* awk; Hawk* awk;
Mode mode; Mode mode;
sio_arg_t* arg; hawk_sio_arg_t* arg;
}; };
Source () {} Source () {}
@ -1505,7 +1498,7 @@ public:
/// ///
/// The setGlobal() function sets the value of a global variable /// The setGlobal() function sets the value of a global variable
/// identified by \a id. The \a id is either a value returned by /// 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(). /// to call this function prior to parse().
/// \return 0 on success, -1 on failure /// \return 0 on success, -1 on failure
/// ///
@ -1517,7 +1510,7 @@ public:
/// ///
/// The getGlobal() function gets the value of a global variable /// The getGlobal() function gets the value of a global variable
/// identified by \a id. The \a id is either a value returned by /// 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(). /// to call this function before parse().
/// \return 0 on success, -1 on failure /// \return 0 on success, -1 on failure
/// ///
@ -1534,7 +1527,7 @@ public:
Value& ret, Value& ret,
Value* args, Value* args,
hawk_oow_t nargs, 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 pow (flt_t x, flt_t y) = 0;
virtual flt_t mod (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 modclose (void* handle) = 0;
virtual void* modgetsym (void* handle, const hawk_ooch_t* name) = 0; virtual void* modgetsym (void* handle, const hawk_ooch_t* name) = 0;
// static glue members for various handlers // static glue members for various handlers
static hawk_ooi_t readSource ( 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); hawk_ooch_t* data, hawk_oow_t count);
static hawk_ooi_t writeSource ( 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); hawk_ooch_t* data, hawk_oow_t count);
static hawk_ooi_t pipeHandler ( 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); void* data, hawk_oow_t count);
static hawk_ooi_t fileHandler ( 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); void* data, hawk_oow_t count);
static hawk_ooi_t consoleHandler ( 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); 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 pow (hawk_t* awk, flt_t x, flt_t y);
static flt_t mod (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 modclose (hawk_t* awk, void* handle);
static void* modgetsym (hawk_t* awk, void* handle, const hawk_ooch_t* name); static void* modgetsym (hawk_t* awk, void* handle, const hawk_ooch_t* name);
@ -1776,7 +1769,7 @@ private:
int init_runctx (); int init_runctx ();
void fini_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); static const hawk_ooch_t* xerrstr (hawk_t* a, hawk_errnum_t num);
}; };

View File

@ -30,14 +30,7 @@
#include <hawk-std.h> // for hawk_stdmodXXX() functions #include <hawk-std.h> // for hawk_stdmodXXX() functions
#include "hawk-prv.h" #include "hawk-prv.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h>
#if !defined(HAWK_HAVE_CONFIG_H)
# if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
# define HAVE_POW
# define HAVE_FMOD
# endif
#endif
// TODO: remove the following definitions and find a way to share the similar definitions in std.c // TODO: remove the following definitions and find a way to share the similar definitions in std.c
#if defined(HAWK_ENABLE_LIBLTDL) #if defined(HAWK_ENABLE_LIBLTDL)
@ -48,7 +41,12 @@
# error UNSUPPORTED DYNAMIC LINKER # error UNSUPPORTED DYNAMIC LINKER
#endif #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) 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); 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; void* h;
h = hawk_stdmodopen (this->awk, spec); h = hawk_stdmodopen (this->awk, spec);
@ -1185,7 +1183,6 @@ HawkStd::SourceFile::~SourceFile ()
} }
} }
int HawkStd::SourceFile::open (Data& io) int HawkStd::SourceFile::open (Data& io)
{ {
hawk_sio_t* sio; 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); this->name = hawk_dupbcstr(this->_hawk, (hawk_bch_t*)this->_name, HAWK_NULL);
#endif #endif
} }
if (!this->name) if (!this->name) return -1;
{
// TODO: check if retrieveError is needed //((Hawk*)io)->retrieveError();
return -1;
}
} }
if (this->name[0] == HAWK_T('-') && this->name[1] == HAWK_T('\0')) 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); if (this->cmgr) hawk_sio_setcmgr (sio, this->cmgr);
io.setName (this->name); io.setName (this->name);
io.setPath (this->name);
} }
else else
{ {
// open an included file // open an included file
const hawk_ooch_t* ioname, * file; const hawk_ooch_t* ioname;
hawk_ooch_t fbuf[64]; hawk_ooch_t* xpath;
hawk_ooch_t* dbuf = HAWK_NULL;
ioname = io.getName(); ioname = io.getName();
HAWK_ASSERT (ioname != HAWK_NULL); HAWK_ASSERT (ioname != HAWK_NULL);
file = ioname;
if (io.getPrevHandle()) 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()); outer = hawk_sio_getpath((hawk_sio_t*)io.getPrevHandle());
if (outer) if (outer)
{ {
@ -1276,34 +1271,35 @@ int HawkStd::SourceFile::open (Data& io)
totlen = hawk_count_oocstr(ioname) + dirlen; totlen = hawk_count_oocstr(ioname) + dirlen;
if (totlen >= HAWK_COUNTOF(fbuf)) if (totlen >= HAWK_COUNTOF(fbuf))
{ {
dbuf = (hawk_ooch_t*)HAWK_MMGR_ALLOC( dbuf = (hawk_ooch_t*)hawk_allocmem((hawk_t*)io, HAWK_SIZEOF(hawk_ooch_t) * (totlen + 1));
((Hawk*)io)->getMmgr(), if (!dbuf) return -1;
HAWK_SIZEOF(hawk_ooch_t) * (totlen + 1) path = dbuf;
); }
if (dbuf == HAWK_NULL) else path = fbuf;
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
{ {
((Hawk*)io)->setError (HAWK_ENOMEM); xpath = hawk_addsionamewithoochars((hawk_t*)io, ioname, hawk_count_oocstr(ioname));
return -1;
}
file = dbuf;
}
else file = fbuf;
tmplen = hawk_copy_oochars_to_oocstr_unlimited ((hawk_ooch_t*)file, outer, dirlen);
hawk_copy_oocstr_unlimited ((hawk_ooch_t*)file + tmplen, ioname);
}
}
} }
if (!xpath) return -1;
sio = open_sio( sio = open_sio(
io, HAWK_NULL, file, io, HAWK_NULL, xpath,
(io.getMode() == READ? (io.getMode() == READ?
(HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH): (HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH):
(HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR)) (HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR))
); );
if (dbuf) HAWK_MMGR_FREE (((Hawk*)io)->getMmgr(), dbuf); if (!sio) return -1;
if (sio == HAWK_NULL) return -1;
io.setPath (xpath);
io.setHandle (sio);
if (this->cmgr) hawk_sio_setcmgr (sio, this->cmgr); 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); this->str = hawk_dupbcstr(this->_hawk, (hawk_bch_t*)this->_str, HAWK_NULL);
#endif #endif
} }
if (!this->str) if (!this->str) return -1;
{
// TODO: check if retrieveError is needed
return -1;
}
} }
this->ptr = this->str; this->ptr = this->str;
@ -1384,19 +1376,19 @@ int HawkStd::SourceString::open (Data& io)
else else
{ {
// open an included file // open an included file
const hawk_ooch_t* ioname;
const hawk_ooch_t* ioname, * file; hawk_ooch_t* xpath;
hawk_ooch_t fbuf[64];
hawk_ooch_t* dbuf = HAWK_NULL;
ioname = io.getName(); ioname = io.getName();
HAWK_ASSERT (ioname != HAWK_NULL); HAWK_ASSERT (ioname != HAWK_NULL);
file = ioname;
if (io.getPrevHandle()) 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()); outer = hawk_sio_getpath((hawk_sio_t*)io.getPrevHandle());
if (outer) if (outer)
{ {
@ -1412,32 +1404,35 @@ int HawkStd::SourceString::open (Data& io)
if (totlen >= HAWK_COUNTOF(fbuf)) if (totlen >= HAWK_COUNTOF(fbuf))
{ {
dbuf = (hawk_ooch_t*)hawk_allocmem((hawk_t*)io, HAWK_SIZEOF(hawk_ooch_t) * (totlen + 1)); dbuf = (hawk_ooch_t*)hawk_allocmem((hawk_t*)io, HAWK_SIZEOF(hawk_ooch_t) * (totlen + 1));
if (dbuf == HAWK_NULL) if (!dbuf) return -1;
path = dbuf;
}
else path = fbuf;
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
{ {
// TODO: check if retrieveError is needed xpath = hawk_addsionamewithoochars((hawk_t*)io, ioname, hawk_count_oocstr(ioname));
return -1;
}
file = dbuf;
}
else file = fbuf;
tmplen = hawk_copy_oochars_to_oocstr_unlimited((hawk_ooch_t*)file, outer, dirlen);
hawk_copy_oocstr_unlimited ((hawk_ooch_t*)file + tmplen, ioname);
}
}
} }
if (!xpath) return -1;
sio = open_sio( sio = open_sio(
io, HAWK_NULL, file, io, HAWK_NULL, xpath,
(io.getMode() == READ? (io.getMode() == READ?
(HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH): (HAWK_SIO_READ | HAWK_SIO_IGNOREECERR | HAWK_SIO_KEEPPATH):
(HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR)) (HAWK_SIO_WRITE | HAWK_SIO_CREATE | HAWK_SIO_TRUNCATE | HAWK_SIO_IGNOREECERR))
); );
if (dbuf) hawk_freemem ((hawk_t*)io, dbuf); if (!sio) return -1;
if (sio == HAWK_NULL) return -1;
io.setPath (xpath);
io.setHandle (sio); io.setHandle (sio);
//if (this->cmgr) hawk_sio_setcmgr (sio, this->cmgr);
} }
return 1; return 1;

View File

@ -202,7 +202,7 @@ protected:
flt_t pow (flt_t x, flt_t y); flt_t pow (flt_t x, flt_t y);
flt_t mod (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 modclose (void* handle);
void* modgetsym (void* handle, const hawk_ooch_t* name); void* modgetsym (void* handle, const hawk_ooch_t* name);

View File

@ -108,6 +108,9 @@
/* Define to 1 if you have the `cosq' function. */ /* Define to 1 if you have the `cosq' function. */
#undef HAVE_COSQ #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. */ /* Define if c++ supports namespace std. */
#undef HAVE_CXX_NAMESPACE_STD #undef HAVE_CXX_NAMESPACE_STD