added hawk::modlibdirs()

This commit is contained in:
hyung-hwan 2020-12-01 14:44:53 +00:00
parent 2dd6029064
commit 72557c239b
9 changed files with 44 additions and 28 deletions

View File

@ -588,6 +588,31 @@ static HAWK_INLINE void HAWK_RTX_STACK_POP (hawk_rtx_t* rtx)
#define HAWK_RTX_IS_STRIPRECSPC_ON(rtx) ((rtx)->gbl.striprecspc > 0 || ((rtx)->gbl.striprecspc < 0 && ((rtx)->hawk->parse.pragma.trait & HAWK_STRIPRECSPC))) #define HAWK_RTX_IS_STRIPRECSPC_ON(rtx) ((rtx)->gbl.striprecspc > 0 || ((rtx)->gbl.striprecspc < 0 && ((rtx)->hawk->parse.pragma.trait & HAWK_STRIPRECSPC)))
#define HAWK_RTX_IS_STRIPSTRSPC_ON(rtx) ((rtx)->gbl.stripstrspc > 0 || ((rtx)->gbl.stripstrspc < 0 && ((rtx)->hawk->parse.pragma.trait & HAWK_STRIPSTRSPC))) #define HAWK_RTX_IS_STRIPSTRSPC_ON(rtx) ((rtx)->gbl.stripstrspc > 0 || ((rtx)->gbl.stripstrspc < 0 && ((rtx)->hawk->parse.pragma.trait & HAWK_STRIPSTRSPC)))
#if !defined(HAWK_DEFAULT_MODLIBDIRS)
# define HAWK_DEFAULT_MODLIBDIRS ""
#endif
#if !defined(HAWK_DEFAULT_MODPREFIX)
# if defined(_WIN32)
# define HAWK_DEFAULT_MODPREFIX "hawk-"
# elif defined(__OS2__)
# define HAWK_DEFAULT_MODPREFIX "hawk"
# elif defined(__DOS__)
# define HAWK_DEFAULT_MODPREFIX "hawk"
# else
# define HAWK_DEFAULT_MODPREFIX "libhawk-"
# endif
#endif
#if !defined(HAWK_DEFAULT_MODPOSTFIX)
# define HAWK_DEFAULT_MODPOSTFIX ""
#endif
#if defined(__cplusplus) #if defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif

View File

@ -303,7 +303,7 @@ static int fnc_isnil (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
a0 = hawk_rtx_getarg(rtx, 0); a0 = hawk_rtx_getarg(rtx, 0);
r = hawk_rtx_makeintval(rtx, HAWK_RTX_GETVALTYPE(rtx, a0) == HAWK_VAL_NIL); r = hawk_rtx_makeintval(rtx, HAWK_RTX_GETVALTYPE(rtx, a0) == HAWK_VAL_NIL);
if (r == HAWK_NULL) return -1; if (HAWK_UNLIKELY(!r)) return -1;
hawk_rtx_setretval (rtx, r); hawk_rtx_setretval (rtx, r);
return 0; return 0;
@ -337,6 +337,18 @@ static int fnc_isarr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
return 0; return 0;
} }
static int fnc_modlibdirs (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{
hawk_t* hawk = hawk_rtx_gethawk(rtx);
hawk_val_t* r;
r = hawk_rtx_makestrvalwithoocstr(rtx, (hawk->opt.mod[0].len > 0)? hawk->opt.mod[0].ptr: HAWK_T(HAWK_DEFAULT_MODLIBDIRS));
if (HAWK_UNLIKELY(!r)) return -1;
hawk_rtx_setretval (rtx, r);
return 0;
}
static int fnc_typename (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) static int fnc_typename (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
{ {
hawk_val_t* a0; hawk_val_t* a0;
@ -347,7 +359,7 @@ static int fnc_typename (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
name = hawk_rtx_getvaltypename(rtx, a0); name = hawk_rtx_getvaltypename(rtx, a0);
r = hawk_rtx_makestrvalwithoocstr(rtx, name); r = hawk_rtx_makestrvalwithoocstr(rtx, name);
if (r == HAWK_NULL) return -1; if (HAWK_UNLIKELY(!r)) return -1;
hawk_rtx_setretval (rtx, r); hawk_rtx_setretval (rtx, r);
return 0; return 0;
@ -385,6 +397,7 @@ static fnctab_t fnctab[] =
{ HAWK_T("ismap"), { { 1, 1, HAWK_NULL }, fnc_ismap, 0 } }, { HAWK_T("ismap"), { { 1, 1, HAWK_NULL }, fnc_ismap, 0 } },
{ HAWK_T("isnil"), { { 1, 1, HAWK_NULL }, fnc_isnil, 0 } }, { HAWK_T("isnil"), { { 1, 1, HAWK_NULL }, fnc_isnil, 0 } },
{ HAWK_T("map"), { { 0, A_MAX, HAWK_NULL }, fnc_map, 0 } }, { HAWK_T("map"), { { 0, A_MAX, HAWK_NULL }, fnc_map, 0 } },
{ HAWK_T("modlibdirs"), { { 0, 0, HAWK_NULL }, fnc_modlibdirs, 0 } },
{ HAWK_T("typename"), { { 1, 1, HAWK_NULL }, fnc_typename, 0 } } { HAWK_T("typename"), { { 1, 1, HAWK_NULL }, fnc_typename, 0 } }
}; };

View File

@ -26,27 +26,6 @@
#include "hawk-prv.h" #include "hawk-prv.h"
#if !defined(HAWK_DEFAULT_MODLIBDIRS)
# define HAWK_DEFAULT_MODLIBDIRS ""
#endif
#if !defined(HAWK_DEFAULT_MODPREFIX)
# if defined(_WIN32)
# define HAWK_DEFAULT_MODPREFIX "hawk-"
# elif defined(__OS2__)
# define HAWK_DEFAULT_MODPREFIX "hawk"
# elif defined(__DOS__)
# define HAWK_DEFAULT_MODPREFIX "hawk"
# else
# define HAWK_DEFAULT_MODPREFIX "libhawk-"
# endif
#endif
#if !defined(HAWK_DEFAULT_MODPOSTFIX)
# define HAWK_DEFAULT_MODPOSTFIX ""
#endif
#define FMT_EBADVAR HAWK_T("'%.*js' not a valid variable name") #define FMT_EBADVAR HAWK_T("'%.*js' not a valid variable name")
#define FMT_ECOMMA HAWK_T("comma expected in place of '%.*js'") #define FMT_ECOMMA HAWK_T("comma expected in place of '%.*js'")
#define FMT_ECOLON HAWK_T("colon expected in place of '%.*js'") #define FMT_ECOLON HAWK_T("colon expected in place of '%.*js'")

View File

@ -558,6 +558,7 @@ pdfdir = @pdfdir@
prefix = @prefix@ prefix = @prefix@
program_transform_name = @program_transform_name@ program_transform_name = @program_transform_name@
psdir = @psdir@ psdir = @psdir@
runstatedir = @runstatedir@
sbindir = @sbindir@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@ sharedstatedir = @sharedstatedir@
srcdir = @srcdir@ srcdir = @srcdir@

View File

@ -334,7 +334,7 @@ function begin_file( f)
## print " BibTeX bibliography " FILENAME > f ## print " BibTeX bibliography " FILENAME > f
print " BibTeX bibliography " BASE_FILENAME > f print " BibTeX bibliography " BASE_FILENAME > f
print " </TITLE>" > f print " </TITLE>" > f
print " <LINK REV=\"made\" HREF=\"mailto:" USER "@" HOSTNAME "\">" > f ## print " <LINK REV=\"made\" HREF=\"mailto:" USER "@" HOSTNAME "\">" > f
print " <LINK HREF=\"http://www.math.utah.edu/pub/tex/bib/tugbib.css\" TYPE=\"text/css\" REL=\"stylesheet\">" > f print " <LINK HREF=\"http://www.math.utah.edu/pub/tex/bib/tugbib.css\" TYPE=\"text/css\" REL=\"stylesheet\">" > f
print " </HEAD>" > f print " </HEAD>" > f
print "" > f print "" > f

View File

@ -13,7 +13,6 @@
<TITLE> <TITLE>
BibTeX bibliography journal-toc.in BibTeX bibliography journal-toc.in
</TITLE> </TITLE>
<LINK REV="made" HREF="mailto:hyung-hwan@hyunghwan-elite-desk">
<LINK HREF="http://www.math.utah.edu/pub/tex/bib/tugbib.css" TYPE="text/css" REL="stylesheet"> <LINK HREF="http://www.math.utah.edu/pub/tex/bib/tugbib.css" TYPE="text/css" REL="stylesheet">
</HEAD> </HEAD>

View File

@ -51,7 +51,7 @@ function run_test (x, more_opts, in_name, out_name)
outf = sprintf("/tmp/%s.%d.out", out_name, sys::getpid()); outf = sprintf("/tmp/%s.%d.out", out_name, sys::getpid());
##print TDIR, inf, expf, outf; ##print TDIR, inf, expf, outf;
cmd=sprintf("%s %s -f %s/%s.hawk %s > %s", ARGV[0], more_opts, TDIR, x, inf, outf); cmd=sprintf("%s %s -f %s/%s.hawk --modlibdirs=%s %s > %s", ARGV[0], more_opts, TDIR, x, hawk::modlibdirs(), inf, outf);
##print cmd; ##print cmd;
system (cmd); system (cmd);

View File

@ -9,7 +9,6 @@
<TITLE> <TITLE>
ACM Transactions on Mathematical Software ACM Transactions on Mathematical Software
</TITLE> </TITLE>
<LINK REV="made" HREF="mailto:hyung-hwan@hyunghwan-elite-desk">
</HEAD> </HEAD>
<BODY> <BODY>

View File

@ -663,7 +663,7 @@ function html_header()
print prefix(2) "<TITLE>" print prefix(2) "<TITLE>"
print prefix(3) Journal print prefix(3) Journal
print prefix(2) "</TITLE>" print prefix(2) "</TITLE>"
print prefix(2) "<LINK REV=\"made\" HREF=\"mailto:" USER "@" HOSTNAME "\">" ##print prefix(2) "<LINK REV=\"made\" HREF=\"mailto:" USER "@" HOSTNAME "\">"
print prefix(1) "</HEAD>" print prefix(1) "</HEAD>"
print "" print ""
print prefix(1) "<BODY>" print prefix(1) "<BODY>"