diff --git a/hawk/lib/hawk-prv.h b/hawk/lib/hawk-prv.h index 5cc202a9..b1b9dd76 100644 --- a/hawk/lib/hawk-prv.h +++ b/hawk/lib/hawk-prv.h @@ -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_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) extern "C" { #endif diff --git a/hawk/lib/mod-hawk.c b/hawk/lib/mod-hawk.c index 9b8370d2..b2ad7e12 100644 --- a/hawk/lib/mod-hawk.c +++ b/hawk/lib/mod-hawk.c @@ -303,7 +303,7 @@ static int fnc_isnil (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) a0 = hawk_rtx_getarg(rtx, 0); 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); return 0; @@ -337,6 +337,18 @@ static int fnc_isarr (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) 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) { 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); r = hawk_rtx_makestrvalwithoocstr(rtx, name); - if (r == HAWK_NULL) return -1; + if (HAWK_UNLIKELY(!r)) return -1; hawk_rtx_setretval (rtx, r); return 0; @@ -385,6 +397,7 @@ static fnctab_t fnctab[] = { HAWK_T("ismap"), { { 1, 1, HAWK_NULL }, fnc_ismap, 0 } }, { HAWK_T("isnil"), { { 1, 1, HAWK_NULL }, fnc_isnil, 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 } } }; diff --git a/hawk/lib/parse.c b/hawk/lib/parse.c index a0473864..be861ac8 100644 --- a/hawk/lib/parse.c +++ b/hawk/lib/parse.c @@ -26,27 +26,6 @@ #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_ECOMMA HAWK_T("comma expected in place of '%.*js'") #define FMT_ECOLON HAWK_T("colon expected in place of '%.*js'") diff --git a/hawk/t/Makefile.in b/hawk/t/Makefile.in index 256a9651..67aec334 100644 --- a/hawk/t/Makefile.in +++ b/hawk/t/Makefile.in @@ -558,6 +558,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ diff --git a/hawk/t/bibtex-to-html.hawk b/hawk/t/bibtex-to-html.hawk index 267f9f63..5401fab6 100644 --- a/hawk/t/bibtex-to-html.hawk +++ b/hawk/t/bibtex-to-html.hawk @@ -334,7 +334,7 @@ function begin_file( f) ## print " BibTeX bibliography " FILENAME > f print " BibTeX bibliography " BASE_FILENAME > f print " " > f - print " " > f +## print " " > f print " " > f print " " > f print "" > f diff --git a/hawk/t/bibtex-to-html.out b/hawk/t/bibtex-to-html.out index fcbbb30f..ca49334a 100644 --- a/hawk/t/bibtex-to-html.out +++ b/hawk/t/bibtex-to-html.out @@ -13,7 +13,6 @@