added HAWK_OPT_MODLIBDIRS to specify search path for module files
This commit is contained in:
parent
a36dbd9c2f
commit
5f4635d455
103
hawk/bin/main.c
103
hawk/bin/main.c
@ -107,6 +107,8 @@ struct arg_t
|
||||
hawk_bch_t* call; /* function to call */
|
||||
hawk_cmgr_t* script_cmgr;
|
||||
hawk_cmgr_t* console_cmgr;
|
||||
hawk_bch_t* includedirs;
|
||||
hawk_bch_t* modlibdirs;
|
||||
|
||||
unsigned int modern: 1;
|
||||
unsigned int classic: 1;
|
||||
@ -345,7 +347,7 @@ static hawk_htb_walk_t print_awk_value (hawk_htb_t* map, hawk_htb_pair_t* pair,
|
||||
return HAWK_HTB_WALK_FORWARD;
|
||||
}
|
||||
|
||||
static int add_gvs_to_awk (hawk_t* hawk, arg_t* arg)
|
||||
static int add_gvs_to_hawk (hawk_t* hawk, arg_t* arg)
|
||||
{
|
||||
if (arg->gvm.size > 0)
|
||||
{
|
||||
@ -539,6 +541,9 @@ static void print_usage (FILE* out, const hawk_bch_t* argv0)
|
||||
fprintf (out, " --script-encoding string specify script file encoding name\n");
|
||||
fprintf (out, " --console-encoding string specify console encoding name\n");
|
||||
#endif
|
||||
|
||||
fprintf (out, " --includedirs specify directories to look for module files in\n");
|
||||
fprintf (out, " --modlibdirs specify directories to look for include files in\n");
|
||||
fprintf (out, " --modern run in the modern mode(default)\n");
|
||||
fprintf (out, " --classic run in the classic mode\n");
|
||||
|
||||
@ -659,6 +664,10 @@ static int process_argv (int argc, hawk_bch_t* argv[], struct arg_t* arg)
|
||||
|
||||
{ ":script-encoding", '\0' },
|
||||
{ ":console-encoding", '\0' },
|
||||
#if 0
|
||||
{ ":includedirs", '\0' },
|
||||
#endif
|
||||
{ ":modlibdirs", '\0' },
|
||||
|
||||
{ "modern", '\0' },
|
||||
{ "classic", '\0' },
|
||||
@ -749,8 +758,8 @@ static int process_argv (int argc, hawk_bch_t* argv[], struct arg_t* arg)
|
||||
tmp.len = hawk_count_bcstr(opt.arg);
|
||||
if (collect_into_xarg(&tmp, &arg->ocf) <= -1)
|
||||
{
|
||||
print_error ("out of memory\n");
|
||||
goto oops;
|
||||
print_error ("out of memory\n");
|
||||
goto oops;
|
||||
}
|
||||
arg->ocf.ptr[arg->ocf.size] = HAWK_NULL;
|
||||
break;
|
||||
@ -863,6 +872,16 @@ static int process_argv (int argc, hawk_bch_t* argv[], struct arg_t* arg)
|
||||
{
|
||||
arg->classic = 1;
|
||||
}
|
||||
#if 0
|
||||
else if (hawk_comp_bcstr(opt.lngopt, "includedirs", 0) == 0)
|
||||
{
|
||||
arg->includedirs = opt.arg;
|
||||
}
|
||||
#endif
|
||||
else if (hawk_comp_bcstr(opt.lngopt, "modlibdirs", 0) == 0)
|
||||
{
|
||||
arg->modlibdirs = opt.arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; opttab[i].name; i++)
|
||||
@ -1083,7 +1102,7 @@ static hawk_mmgr_t debug_mmgr =
|
||||
|
||||
static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[])
|
||||
{
|
||||
hawk_t* awk = HAWK_NULL;
|
||||
hawk_t* hawk = HAWK_NULL;
|
||||
hawk_rtx_t* rtx = HAWK_NULL;
|
||||
hawk_val_t* retv;
|
||||
int i;
|
||||
@ -1142,60 +1161,98 @@ static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
awk = hawk_openstd(0, HAWK_NULL);
|
||||
if (awk == HAWK_NULL)
|
||||
hawk = hawk_openstd(0, HAWK_NULL);
|
||||
if (HAWK_UNLIKELY(!hawk))
|
||||
{
|
||||
print_error ("cannot open awk\n");
|
||||
print_error ("cannot open hawk\n");
|
||||
goto oops;
|
||||
}
|
||||
|
||||
if (arg.modern) i = HAWK_MODERN;
|
||||
else if (arg.classic) i = HAWK_CLASSIC;
|
||||
else hawk_getopt (awk, HAWK_OPT_TRAIT, &i);
|
||||
else hawk_getopt (hawk, HAWK_OPT_TRAIT, &i);
|
||||
if (arg.opton) i |= arg.opton;
|
||||
if (arg.optoff) i &= ~arg.optoff;
|
||||
hawk_setopt (awk, HAWK_OPT_TRAIT, &i);
|
||||
hawk_setopt (hawk, HAWK_OPT_TRAIT, &i);
|
||||
|
||||
/* TODO: get depth from command line */
|
||||
{
|
||||
hawk_oow_t tmp;
|
||||
tmp = 50;
|
||||
hawk_setopt (awk, HAWK_OPT_DEPTH_BLOCK_PARSE, &tmp);
|
||||
hawk_setopt (awk, HAWK_OPT_DEPTH_EXPR_PARSE, &tmp);
|
||||
hawk_setopt (hawk, HAWK_OPT_DEPTH_BLOCK_PARSE, &tmp);
|
||||
hawk_setopt (hawk, HAWK_OPT_DEPTH_EXPR_PARSE, &tmp);
|
||||
tmp = 500;
|
||||
hawk_setopt (awk, HAWK_OPT_DEPTH_BLOCK_RUN, &tmp);
|
||||
hawk_setopt (awk, HAWK_OPT_DEPTH_EXPR_RUN, &tmp);
|
||||
hawk_setopt (hawk, HAWK_OPT_DEPTH_BLOCK_RUN, &tmp);
|
||||
hawk_setopt (hawk, HAWK_OPT_DEPTH_EXPR_RUN, &tmp);
|
||||
tmp = 64;
|
||||
hawk_setopt (awk, HAWK_OPT_DEPTH_INCLUDE, &tmp);
|
||||
hawk_setopt (hawk, HAWK_OPT_DEPTH_INCLUDE, &tmp);
|
||||
}
|
||||
|
||||
if (add_gvs_to_awk(awk, &arg) <= -1)
|
||||
#if 0
|
||||
if (arg.includedirs)
|
||||
{
|
||||
print_hawk_error (awk);
|
||||
#if defined(HAWK_OOCH_IS_UCH)
|
||||
hawk_ooch_t* tmp;
|
||||
tmp = hawk_dupbtoucstr(hawk, arg.includedirs, HAWK_NULL, 1);
|
||||
if (HAWK_UNLIKELY(!tmp))
|
||||
{
|
||||
print_hawk_error (hawk);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
hawk_setopt (hawk, HAWK_OPT_INCLUDEDIRS, tmp);
|
||||
hawk_freemem (hawk, tmp);
|
||||
#else
|
||||
hawk_setopt (hawk, HAWK_OPT_INCLUDEDIRS, arg.includedirs);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (arg.modlibdirs)
|
||||
{
|
||||
#if defined(HAWK_OOCH_IS_UCH)
|
||||
hawk_ooch_t* tmp;
|
||||
tmp = hawk_dupbtoucstr(hawk, arg.modlibdirs, HAWK_NULL, 1);
|
||||
if (HAWK_UNLIKELY(!tmp))
|
||||
{
|
||||
print_hawk_error (hawk);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
hawk_setopt (hawk, HAWK_OPT_MODLIBDIRS, tmp);
|
||||
hawk_freemem (hawk, tmp);
|
||||
#else
|
||||
hawk_setopt (hawk, HAWK_OPT_MODLIBDIRS, arg.modlibdirs);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (add_gvs_to_hawk(hawk, &arg) <= -1)
|
||||
{
|
||||
print_hawk_error (hawk);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
if (hawk_parsestd(awk, arg.psin, ((arg.osf == HAWK_NULL)? HAWK_NULL: &psout)) <= -1)
|
||||
if (hawk_parsestd(hawk, arg.psin, ((arg.osf == HAWK_NULL)? HAWK_NULL: &psout)) <= -1)
|
||||
{
|
||||
print_hawk_error (awk);
|
||||
print_hawk_error (hawk);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
rtx = hawk_rtx_openstdwithbcstr(
|
||||
awk, 0, argv[0],
|
||||
hawk, 0, argv[0],
|
||||
(arg.call? HAWK_NULL: arg.icf.ptr), /* console input */
|
||||
arg.ocf.ptr, /* console output */
|
||||
arg.console_cmgr
|
||||
);
|
||||
if (rtx == HAWK_NULL)
|
||||
if (HAWK_UNLIKELY(!rtx))
|
||||
{
|
||||
print_hawk_error (awk);
|
||||
print_hawk_error (hawk);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
if (apply_fs_and_gvs_to_rtx(rtx, &arg) <= -1)
|
||||
{
|
||||
print_hawk_error (awk);
|
||||
print_hawk_error (hawk);
|
||||
goto oops;
|
||||
}
|
||||
|
||||
@ -1241,7 +1298,7 @@ static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[])
|
||||
|
||||
oops:
|
||||
if (rtx) hawk_rtx_close (rtx);
|
||||
if (awk) hawk_close (awk);
|
||||
if (hawk) hawk_close (hawk);
|
||||
|
||||
#if 0
|
||||
if (xma_mmgr.ctx) hawk_xma_close (xma_mmgr.ctx);
|
||||
|
@ -150,9 +150,11 @@ int HawkStd::open ()
|
||||
|
||||
if (!this->stdmod_up)
|
||||
{
|
||||
/*
|
||||
#if defined(USE_DLFCN)
|
||||
if (hawk_setopt(this->hawk, HAWK_OPT_MODPOSTFIX, HAWK_T(".so")) <= -1) goto oops;
|
||||
#endif
|
||||
*/
|
||||
|
||||
if (hawk_stdmodstartup(this->hawk) <= -1) goto oops;
|
||||
this->stdmod_up = true;
|
||||
|
@ -18,9 +18,9 @@ endif
|
||||
if WIN32
|
||||
# you must adjust the value of DEFAULT_MODPOSTFIX according
|
||||
# to the first number in -version-info above
|
||||
CPPFLAGS_PFMOD = -DHAWK_DEFAULT_MODPREFIX=\"libhawk-\" -DHAWK_DEFAULT_MODPOSTFIX=\"-1.dll\"
|
||||
CPPFLAGS_PFMOD = -DHAWK_DEFAULT_MODLIBDIRS=\"\" -DHAWK_DEFAULT_MODPREFIX=\"libhawk-\" -DHAWK_DEFAULT_MODPOSTFIX=\"-1.dll\"
|
||||
else
|
||||
CPPFLAGS_PFMOD = -DHAWK_DEFAULT_MODPREFIX=\"$(libdir)/libhawk-\"
|
||||
CPPFLAGS_PFMOD = -DHAWK_DEFAULT_MODLIBDIRS=\"$(libdir)\" -DHAWK_DEFAULT_MODPREFIX=\"libhawk-\"
|
||||
if MACOSX
|
||||
CPPFLAGS_PFMOD += -DHAWK_DEFAULT_MODPOSTFIX=\".dylib\"
|
||||
else
|
||||
|
@ -571,8 +571,8 @@ CPPFLAGS_ALL_COMMON = \
|
||||
|
||||
@ENABLE_STATIC_MODULE_FALSE@LDFLAGS_ALL_COMMON = -L$(abs_builddir) -L$(libdir)
|
||||
@ENABLE_STATIC_MODULE_TRUE@LDFLAGS_ALL_COMMON = -L$(abs_builddir)/../mod -L$(abs_builddir) -L$(libdir)
|
||||
@WIN32_FALSE@CPPFLAGS_PFMOD = \
|
||||
@WIN32_FALSE@ -DHAWK_DEFAULT_MODPREFIX=\"$(libdir)/libhawk-\" \
|
||||
@WIN32_FALSE@CPPFLAGS_PFMOD = -DHAWK_DEFAULT_MODLIBDIRS=\"$(libdir)\" \
|
||||
@WIN32_FALSE@ -DHAWK_DEFAULT_MODPREFIX=\"libhawk-\" \
|
||||
@WIN32_FALSE@ $(am__append_1) $(am__append_2)
|
||||
|
||||
##################################################
|
||||
@ -581,7 +581,8 @@ CPPFLAGS_ALL_COMMON = \
|
||||
|
||||
# you must adjust the value of DEFAULT_MODPOSTFIX according
|
||||
# to the first number in -version-info above
|
||||
@WIN32_TRUE@CPPFLAGS_PFMOD = -DHAWK_DEFAULT_MODPREFIX=\"libhawk-\" \
|
||||
@WIN32_TRUE@CPPFLAGS_PFMOD = -DHAWK_DEFAULT_MODLIBDIRS=\"\" \
|
||||
@WIN32_TRUE@ -DHAWK_DEFAULT_MODPREFIX=\"libhawk-\" \
|
||||
@WIN32_TRUE@ -DHAWK_DEFAULT_MODPOSTFIX=\"-1.dll\" \
|
||||
@WIN32_TRUE@ $(am__append_1) $(am__append_2)
|
||||
pkginclude_HEADERS = hawk.h hawk-arr.h hawk-chr.h hawk-cmn.h \
|
||||
|
@ -210,7 +210,7 @@ struct hawk_t
|
||||
{
|
||||
int trait;
|
||||
hawk_oocs_t mod[3];
|
||||
hawk_oocs_t incldirs;
|
||||
hawk_oocs_t includedirs;
|
||||
|
||||
union
|
||||
{
|
||||
|
@ -175,7 +175,7 @@ int hawk_init (hawk_t* awk, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr, const hawk_prm
|
||||
init_token(awk, &awk->ntok) <= -1) goto oops;
|
||||
|
||||
awk->opt.trait = HAWK_MODERN;
|
||||
#if defined(__OS2__) || defined(_WIN32) || defined(__DOS__)
|
||||
#if defined(__WIN32__) || defined(_OS2) || defined(__DOS__)
|
||||
awk->opt.trait |= HAWK_CRLF;
|
||||
#endif
|
||||
awk->opt.rtx_stack_limit = HAWK_DFL_RTX_STACK_LIMIT;
|
||||
@ -427,22 +427,22 @@ void hawk_clear (hawk_t* awk)
|
||||
*/
|
||||
}
|
||||
|
||||
void hawk_getprm (hawk_t* awk, hawk_prm_t* prm)
|
||||
void hawk_getprm (hawk_t* hawk, hawk_prm_t* prm)
|
||||
{
|
||||
*prm = awk->prm;
|
||||
*prm = hawk->prm;
|
||||
}
|
||||
|
||||
void hawk_setprm (hawk_t* awk, const hawk_prm_t* prm)
|
||||
void hawk_setprm (hawk_t* hawk, const hawk_prm_t* prm)
|
||||
{
|
||||
awk->prm = *prm;
|
||||
hawk->prm = *prm;
|
||||
}
|
||||
|
||||
static int dup_str_opt (hawk_t* awk, const void* value, hawk_oocs_t* tmp)
|
||||
static int dup_str_opt (hawk_t* hawk, const void* value, hawk_oocs_t* tmp)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
tmp->ptr = hawk_dupoocstr(awk, value, &tmp->len);
|
||||
if (!tmp->ptr) return -1;
|
||||
tmp->ptr = hawk_dupoocstr(hawk, value, &tmp->len);
|
||||
if (HAWK_UNLIKELY(!tmp->ptr)) return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -461,7 +461,7 @@ int hawk_setopt (hawk_t* hawk, hawk_opt_t id, const void* value)
|
||||
hawk->opt.trait = *(const int*)value;
|
||||
return 0;
|
||||
|
||||
case HAWK_OPT_MODLIBDIR:
|
||||
case HAWK_OPT_MODLIBDIRS:
|
||||
case HAWK_OPT_MODPREFIX:
|
||||
case HAWK_OPT_MODPOSTFIX:
|
||||
{
|
||||
@ -470,7 +470,7 @@ int hawk_setopt (hawk_t* hawk, hawk_opt_t id, const void* value)
|
||||
|
||||
if (dup_str_opt(hawk, value, &tmp) <= -1) return -1;
|
||||
|
||||
idx = id - HAWK_OPT_MODLIBDIR;
|
||||
idx = id - HAWK_OPT_MODLIBDIRS;
|
||||
if (hawk->opt.mod[idx].ptr) hawk_freemem (hawk, hawk->opt.mod[idx].ptr);
|
||||
|
||||
hawk->opt.mod[idx] = tmp;
|
||||
@ -481,8 +481,8 @@ int hawk_setopt (hawk_t* hawk, hawk_opt_t id, const void* value)
|
||||
{
|
||||
hawk_oocs_t tmp;
|
||||
if (dup_str_opt(hawk, value, &tmp) <= -1) return -1;
|
||||
if (hawk->opt.incldirs.ptr) hawk_freemem (hawk, hawk->opt.incldirs.ptr);
|
||||
hawk->opt.incldirs = tmp;
|
||||
if (hawk->opt.includedirs.ptr) hawk_freemem (hawk, hawk->opt.includedirs.ptr);
|
||||
hawk->opt.includedirs = tmp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -525,14 +525,14 @@ int hawk_getopt (hawk_t* hawk, hawk_opt_t id, void* value)
|
||||
*(int*)value = hawk->opt.trait;
|
||||
return 0;
|
||||
|
||||
case HAWK_OPT_MODLIBDIR:
|
||||
case HAWK_OPT_MODLIBDIRS:
|
||||
case HAWK_OPT_MODPREFIX:
|
||||
case HAWK_OPT_MODPOSTFIX:
|
||||
*(const hawk_ooch_t**)value = hawk->opt.mod[id - HAWK_OPT_MODLIBDIR].ptr;
|
||||
*(const hawk_ooch_t**)value = hawk->opt.mod[id - HAWK_OPT_MODLIBDIRS].ptr;
|
||||
return 0;
|
||||
|
||||
case HAWK_OPT_INCLUDEDIRS:
|
||||
*(const hawk_ooch_t**)value = hawk->opt.incldirs.ptr;
|
||||
*(const hawk_ooch_t**)value = hawk->opt.includedirs.ptr;
|
||||
return 0;
|
||||
|
||||
case HAWK_OPT_DEPTH_INCLUDE:
|
||||
|
@ -1144,7 +1144,7 @@ enum hawk_opt_t
|
||||
/** trait option. 0 or bitwise-ORed of ::hawk_trait_t values */
|
||||
HAWK_OPT_TRAIT,
|
||||
|
||||
HAWK_OPT_MODLIBDIR,
|
||||
HAWK_OPT_MODLIBDIRS,
|
||||
HAWK_OPT_MODPREFIX,
|
||||
HAWK_OPT_MODPOSTFIX,
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
|
||||
#include "hawk-prv.h"
|
||||
|
||||
#if !defined(HAWK_DEFAULT_MODLIBDIR)
|
||||
# define HAWK_DEFAULT_MODLIBDIR ""
|
||||
#if !defined(HAWK_DEFAULT_MODLIBDIRS)
|
||||
# define HAWK_DEFAULT_MODLIBDIRS ""
|
||||
#endif
|
||||
|
||||
#if !defined(HAWK_DEFAULT_MODPREFIX)
|
||||
@ -836,7 +836,7 @@ static int begin_include (hawk_t* awk, int once)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (awk->opt.incldirs.ptr)
|
||||
if (awk->opt.includedirs.ptr)
|
||||
{
|
||||
/* include directory is set... */
|
||||
/* TODO: search target files in these directories */
|
||||
@ -890,7 +890,6 @@ static int begin_include (hawk_t* awk, int once)
|
||||
if (get_token(awk) <= -1) return -1; /* skip the include file name */
|
||||
if (MATCH(awk, TOK_SEMICOLON) || MATCH(awk, TOK_NEWLINE))
|
||||
{
|
||||
|
||||
if (get_token(awk) <= -1) return -1; /* skip the semicolon */
|
||||
}
|
||||
}
|
||||
@ -3703,8 +3702,7 @@ static int fold_constants_for_binop (
|
||||
/* TODO: can i shorten various comparisons below?
|
||||
* i hate to repeat similar code just for type difference */
|
||||
|
||||
if (left->type == HAWK_NDE_INT &&
|
||||
right->type == HAWK_NDE_INT)
|
||||
if (left->type == HAWK_NDE_INT && right->type == HAWK_NDE_INT)
|
||||
{
|
||||
fold = HAWK_NDE_INT;
|
||||
switch (opcode)
|
||||
@ -3760,8 +3758,7 @@ static int fold_constants_for_binop (
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (left->type == HAWK_NDE_FLT &&
|
||||
right->type == HAWK_NDE_FLT)
|
||||
else if (left->type == HAWK_NDE_FLT && right->type == HAWK_NDE_FLT)
|
||||
{
|
||||
fold = HAWK_NDE_FLT;
|
||||
switch (opcode)
|
||||
@ -3788,7 +3785,7 @@ static int fold_constants_for_binop (
|
||||
break;
|
||||
|
||||
case HAWK_BINOP_MOD:
|
||||
folded->r = awk->prm.math.mod (
|
||||
folded->r = awk->prm.math.mod(
|
||||
awk,
|
||||
((hawk_nde_flt_t*)left)->val,
|
||||
((hawk_nde_flt_t*)right)->val
|
||||
@ -3800,8 +3797,7 @@ static int fold_constants_for_binop (
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (left->type == HAWK_NDE_INT &&
|
||||
right->type == HAWK_NDE_FLT)
|
||||
else if (left->type == HAWK_NDE_INT && right->type == HAWK_NDE_FLT)
|
||||
{
|
||||
fold = HAWK_NDE_FLT;
|
||||
switch (opcode)
|
||||
@ -3830,7 +3826,7 @@ static int fold_constants_for_binop (
|
||||
break;
|
||||
|
||||
case HAWK_BINOP_MOD:
|
||||
folded->r = awk->prm.math.mod (
|
||||
folded->r = awk->prm.math.mod(
|
||||
awk,
|
||||
(hawk_flt_t)((hawk_nde_int_t*)left)->val,
|
||||
((hawk_nde_flt_t*)right)->val
|
||||
@ -3842,8 +3838,7 @@ static int fold_constants_for_binop (
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (left->type == HAWK_NDE_FLT &&
|
||||
right->type == HAWK_NDE_INT)
|
||||
else if (left->type == HAWK_NDE_FLT && right->type == HAWK_NDE_INT)
|
||||
{
|
||||
fold = HAWK_NDE_FLT;
|
||||
switch (opcode)
|
||||
@ -3872,7 +3867,7 @@ static int fold_constants_for_binop (
|
||||
break;
|
||||
|
||||
case HAWK_BINOP_MOD:
|
||||
folded->r = awk->prm.math.mod (
|
||||
folded->r = awk->prm.math.mod(
|
||||
awk,
|
||||
((hawk_nde_flt_t*)left)->val,
|
||||
(hawk_flt_t)((hawk_nde_int_t*)right)->val
|
||||
@ -3908,59 +3903,55 @@ static hawk_nde_t* new_exp_bin_node (
|
||||
return (hawk_nde_t*)tmp;
|
||||
}
|
||||
|
||||
static hawk_nde_t* new_int_node (
|
||||
hawk_t* awk, hawk_int_t lv, const hawk_loc_t* loc)
|
||||
static hawk_nde_t* new_int_node (hawk_t* hawk, hawk_int_t lv, const hawk_loc_t* loc)
|
||||
{
|
||||
hawk_nde_int_t* tmp;
|
||||
|
||||
tmp = (hawk_nde_int_t*) hawk_callocmem (awk, HAWK_SIZEOF(*tmp));
|
||||
if (tmp)
|
||||
tmp = (hawk_nde_int_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*tmp));
|
||||
if (HAWK_LIKELY(tmp))
|
||||
{
|
||||
tmp->type = HAWK_NDE_INT;
|
||||
tmp->loc = *loc;
|
||||
tmp->val = lv;
|
||||
}
|
||||
else ADJERR_LOC (awk, loc);
|
||||
else ADJERR_LOC (hawk, loc);
|
||||
|
||||
return (hawk_nde_t*)tmp;
|
||||
}
|
||||
|
||||
static hawk_nde_t* new_flt_node (
|
||||
hawk_t* awk, hawk_flt_t rv, const hawk_loc_t* loc)
|
||||
static hawk_nde_t* new_flt_node (hawk_t* hawk, hawk_flt_t rv, const hawk_loc_t* loc)
|
||||
{
|
||||
hawk_nde_flt_t* tmp;
|
||||
|
||||
tmp = (hawk_nde_flt_t*) hawk_callocmem (awk, HAWK_SIZEOF(*tmp));
|
||||
if (tmp)
|
||||
tmp = (hawk_nde_flt_t*)hawk_callocmem(hawk, HAWK_SIZEOF(*tmp));
|
||||
if (HAWK_LIKELY(tmp))
|
||||
{
|
||||
tmp->type = HAWK_NDE_FLT;
|
||||
tmp->loc = *loc;
|
||||
tmp->val = rv;
|
||||
}
|
||||
else ADJERR_LOC (awk, loc);
|
||||
else ADJERR_LOC (hawk, loc);
|
||||
|
||||
return (hawk_nde_t*)tmp;
|
||||
}
|
||||
|
||||
static HAWK_INLINE void update_int_node (
|
||||
hawk_t* awk, hawk_nde_int_t* node, hawk_int_t lv)
|
||||
static HAWK_INLINE void update_int_node (hawk_t* hawk, hawk_nde_int_t* node, hawk_int_t lv)
|
||||
{
|
||||
node->val = lv;
|
||||
if (node->str)
|
||||
{
|
||||
hawk_freemem (awk, node->str);
|
||||
hawk_freemem (hawk, node->str);
|
||||
node->str = HAWK_NULL;
|
||||
node->len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static HAWK_INLINE void update_flt_node (
|
||||
hawk_t* awk, hawk_nde_flt_t* node, hawk_flt_t rv)
|
||||
static HAWK_INLINE void update_flt_node (hawk_t* hawk, hawk_nde_flt_t* node, hawk_flt_t rv)
|
||||
{
|
||||
node->val = rv;
|
||||
if (node->str)
|
||||
{
|
||||
hawk_freemem (awk, node->str);
|
||||
hawk_freemem (hawk, node->str);
|
||||
node->str = HAWK_NULL;
|
||||
node->len = 0;
|
||||
}
|
||||
@ -3975,8 +3966,8 @@ static hawk_nde_t* parse_binary (
|
||||
hawk_nde_t* right = HAWK_NULL;
|
||||
hawk_loc_t rloc;
|
||||
|
||||
left = next_level_func (awk, xloc);
|
||||
if (left == HAWK_NULL) goto oops;
|
||||
left = next_level_func(awk, xloc);
|
||||
if (HAWK_UNLIKELY(!left)) goto oops;
|
||||
|
||||
do
|
||||
{
|
||||
@ -7340,43 +7331,36 @@ static hawk_mod_t* query_module (hawk_t* awk, const hawk_oocs_t segs[], int nseg
|
||||
goto done;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* attempt to find an external module */
|
||||
HAWK_MEMSET (&spec, 0, HAWK_SIZEOF(spec));
|
||||
spec.prefix = (awk->opt.mod[1].len > 0)? awk->opt.mod[1].ptr: HAWK_T(HAWK_DEFAULT_MODPREFIX);
|
||||
spec.postfix = (awk->opt.mod[2].len > 0)? awk->opt.mod[2].ptr: HAWK_T(HAWK_DEFAULT_MODPOSTFIX);
|
||||
spec.name = segs[0].ptr;
|
||||
if (!awk->prm.modopen || !awk->prm.modgetsym || !awk->prm.modclose)
|
||||
{
|
||||
hawk_seterrfmt (awk, HAWK_NULL, HAWK_EINVAL, HAWK_T("module callbacks not set properly"));
|
||||
goto open_fail;
|
||||
}
|
||||
|
||||
hawk_seterrnum (awk, HAWK_NULL, HAWK_ENOERR);
|
||||
|
||||
/* attempt to find an external module */
|
||||
HAWK_MEMSET (&spec, 0, HAWK_SIZEOF(spec));
|
||||
if (awk->opt.mod[0].len > 0)
|
||||
spec.libdir = awk->opt.mod[0].ptr;
|
||||
else
|
||||
spec.libdir = HAWK_T(HAWK_DEFAULT_MODLIBDIR);
|
||||
|
||||
if (awk->opt.mod[1].len > 0)
|
||||
spec.prefix = awk->opt.mod[1].ptr;
|
||||
else spec.prefix = HAWK_T(HAWK_DEFAULT_MODPREFIX);
|
||||
|
||||
if (awk->opt.mod[2].len > 0)
|
||||
spec.postfix = awk->opt.mod[2].ptr;
|
||||
else spec.postfix = HAWK_T(HAWK_DEFAULT_MODPOSTFIX);
|
||||
|
||||
HAWK_MEMSET (&md, 0, HAWK_SIZEOF(md));
|
||||
spec.name = segs[0].ptr;
|
||||
spec.libdir = (awk->opt.mod[0].len > 0)? awk->opt.mod[0].ptr: HAWK_T(HAWK_DEFAULT_MODLIBDIRS);
|
||||
do
|
||||
{
|
||||
#if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
|
||||
# define LIBDIR_SEPARATOR ';'
|
||||
#else
|
||||
# define LIBDIR_SEPARATOR ':'
|
||||
#endif
|
||||
hawk_ooch_t* colon;
|
||||
|
||||
colon = hawk_find_oochar_in_oocstr(spec.libdir, ':');
|
||||
colon = hawk_find_oochar_in_oocstr(spec.libdir, LIBDIR_SEPARATOR);
|
||||
if (colon) *colon = '\0';
|
||||
|
||||
HAWK_MEMSET (&md, 0, HAWK_SIZEOF(md));
|
||||
md.handle = awk->prm.modopen(awk, &spec);
|
||||
if (!colon) break;
|
||||
|
||||
*colon = ':';
|
||||
*colon = LIBDIR_SEPARATOR;
|
||||
spec.libdir = colon + 1;
|
||||
#undef LIBDIR_SEPARATOR
|
||||
}
|
||||
while (!md.handle);
|
||||
|
||||
|
@ -914,6 +914,7 @@ hawk_t* hawk_openstdwithmmgr (hawk_mmgr_t* mmgr, hawk_oow_t xtnsize, hawk_cmgr_t
|
||||
/* adjust the object size by the sizeof xtn_t so that hawk_getxtn() returns the right pointer. */
|
||||
awk->_instsize += HAWK_SIZEOF(xtn_t);
|
||||
|
||||
/*
|
||||
#if defined(USE_DLFCN)
|
||||
if (hawk_setopt(awk, HAWK_OPT_MODPOSTFIX, HAWK_T(".so")) <= -1)
|
||||
{
|
||||
@ -921,6 +922,7 @@ hawk_t* hawk_openstdwithmmgr (hawk_mmgr_t* mmgr, hawk_oow_t xtnsize, hawk_cmgr_t
|
||||
goto oops;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
/* initialize extension */
|
||||
xtn = GET_XTN(awk);
|
||||
|
@ -42,4 +42,4 @@ TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
|
||||
|
||||
TEST_EXTENSIONS = .hawk
|
||||
HAWK_LOG_COMPILER = ../bin/hawk
|
||||
AM_HAWK_LOG_FLAGS = -f
|
||||
AM_HAWK_LOG_FLAGS = --modlibdirs=../lib/.libs:../mod/.libs -f
|
||||
|
@ -576,7 +576,7 @@ t_005_DEPENDENCIES = ../lib/libhawk.la
|
||||
TESTS = $(check_PROGRAMS) $(check_SCRIPTS)
|
||||
TEST_EXTENSIONS = .hawk
|
||||
HAWK_LOG_COMPILER = ../bin/hawk
|
||||
AM_HAWK_LOG_FLAGS = -f
|
||||
AM_HAWK_LOG_FLAGS = --modlibdirs=../lib/.libs:../mod/.libs -f
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
|
Loading…
Reference in New Issue
Block a user