From df9106337cd22c91240307c2c2e3b87d1d62024c Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Wed, 6 Apr 2022 15:49:23 +0000 Subject: [PATCH] enhancing hawk::call() to support module functions --- hawk/Makefile.in | 37 ++++++++++++-------- hawk/ac/ar-lib | 17 ++++----- hawk/ac/compile | 6 ++-- hawk/ac/depcomp | 2 +- hawk/ac/install-sh | 13 ++++++- hawk/ac/missing | 2 +- hawk/ac/test-driver | 2 +- hawk/aclocal.m4 | 50 ++++++++++++++------------- hawk/bin/Makefile.in | 5 +-- hawk/configure | 18 ++++++++-- hawk/lib/Makefile.in | 9 ++--- hawk/lib/hawk.h | 6 ++++ hawk/lib/mod-hawk.c | 75 ++++++++++++++++++++++++++++++---------- hawk/lib/parse-prv.h | 2 +- hawk/lib/parse.c | 2 +- hawk/lib/run.c | 20 +++++------ hawk/lib/tree-prv.h | 2 +- hawk/lib/val.c | 47 ++++++++++++++++++++++++- hawk/mod/Makefile.in | 5 +-- hawk/mod/mod-sed.c | 3 +- hawk/samples/Makefile.in | 5 +-- hawk/t/Makefile.in | 5 +-- hawk/t/h-009.hawk | 8 +++-- hawk/tools/Makefile.in | 5 +-- 24 files changed, 240 insertions(+), 106 deletions(-) diff --git a/hawk/Makefile.in b/hawk/Makefile.in index f4259c15..002e65f8 100644 --- a/hawk/Makefile.in +++ b/hawk/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -170,7 +170,7 @@ am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/ar-lib \ $(top_srcdir)/ac/config.sub $(top_srcdir)/ac/install-sh \ $(top_srcdir)/ac/ltmain.sh $(top_srcdir)/ac/missing \ $(top_srcdir)/ac/tap-driver.sh $(top_srcdir)/pkgs/hawk.spec.in \ - ac/ar-lib ac/compile ac/config.guess ac/config.sub ac/depcomp \ + ac/ar-lib ac/compile ac/config.guess ac/config.sub \ ac/install-sh ac/ltmain.sh ac/missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) @@ -353,6 +353,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ @@ -603,6 +604,10 @@ dist-xz: distdir tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz $(am__post_remove_distdir) +dist-zstd: distdir + tardir=$(distdir) && $(am__tar) | zstd -c $${ZSTD_CLEVEL-$${ZSTD_OPT--19}} >$(distdir).tar.zst + $(am__post_remove_distdir) + dist-tarZ: distdir @echo WARNING: "Support for distribution archives compressed with" \ "legacy program 'compress' is deprecated." >&2 @@ -645,6 +650,8 @@ distcheck: dist eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ + *.tar.zst*) \ + zstd -dc $(distdir).tar.zst | $(am__untar) ;;\ esac chmod -R a-w $(distdir) chmod u+w $(distdir) @@ -822,18 +829,18 @@ uninstall-am: am--refresh check check-am clean clean-cscope clean-generic \ clean-libtool cscope cscopelist-am ctags ctags-am dist \ dist-all dist-bzip2 dist-gzip dist-lzip dist-shar dist-tarZ \ - dist-xz dist-zip distcheck distclean distclean-generic \ - distclean-libtool distclean-local distclean-tags \ - distcleancheck distdir distuninstallcheck dvi dvi-am html \ - html-am info info-am install install-am install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-html install-html-am install-info \ - install-info-am install-man install-pdf install-pdf-am \ - install-ps install-ps-am install-strip installcheck \ - installcheck-am installdirs installdirs-am maintainer-clean \ - maintainer-clean-generic mostlyclean mostlyclean-generic \ - mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ - uninstall-am + dist-xz dist-zip dist-zstd distcheck distclean \ + distclean-generic distclean-libtool distclean-local \ + distclean-tags distcleancheck distdir distuninstallcheck dvi \ + dvi-am html html-am info info-am install install-am \ + install-data install-data-am install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am .PRECIOUS: Makefile diff --git a/hawk/ac/ar-lib b/hawk/ac/ar-lib index 0baa4f60..1e9388e2 100755 --- a/hawk/ac/ar-lib +++ b/hawk/ac/ar-lib @@ -2,9 +2,9 @@ # Wrapper for Microsoft lib.exe me=ar-lib -scriptversion=2012-03-01.08; # UTC +scriptversion=2019-07-04.01; # UTC -# Copyright (C) 2010-2018 Free Software Foundation, Inc. +# Copyright (C) 2010-2020 Free Software Foundation, Inc. # Written by Peter Rosin . # # This program is free software; you can redistribute it and/or modify @@ -53,7 +53,7 @@ func_file_conv () MINGW*) file_conv=mingw ;; - CYGWIN*) + CYGWIN* | MSYS*) file_conv=cygwin ;; *) @@ -65,7 +65,7 @@ func_file_conv () mingw) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; - cygwin) + cygwin | msys) file=`cygpath -m "$file" || echo "$file"` ;; wine) @@ -224,10 +224,11 @@ elif test -n "$extract"; then esac done else - $AR -NOLOGO -LIST "$archive" | sed -e 's/\\/\\\\/g' | while read member - do - $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $? - done + $AR -NOLOGO -LIST "$archive" | tr -d '\r' | sed -e 's/\\/\\\\/g' \ + | while read member + do + $AR -NOLOGO -EXTRACT:"$member" "$archive" || exit $? + done fi elif test -n "$quick$replace"; then diff --git a/hawk/ac/compile b/hawk/ac/compile index 99e50524..23fcba01 100755 --- a/hawk/ac/compile +++ b/hawk/ac/compile @@ -3,7 +3,7 @@ scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify @@ -53,7 +53,7 @@ func_file_conv () MINGW*) file_conv=mingw ;; - CYGWIN*) + CYGWIN* | MSYS*) file_conv=cygwin ;; *) @@ -67,7 +67,7 @@ func_file_conv () mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; - cygwin/*) + cygwin/* | msys/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) diff --git a/hawk/ac/depcomp b/hawk/ac/depcomp index 65cbf709..6b391623 100755 --- a/hawk/ac/depcomp +++ b/hawk/ac/depcomp @@ -3,7 +3,7 @@ scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/hawk/ac/install-sh b/hawk/ac/install-sh index 8175c640..20d8b2ea 100755 --- a/hawk/ac/install-sh +++ b/hawk/ac/install-sh @@ -451,7 +451,18 @@ do trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 # Copy the file name to the temp name. - (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + (umask $cp_umask && + { test -z "$stripcmd" || { + # Create $dsttmp read-write so that cp doesn't create it read-only, + # which would cause strip to fail. + if test -z "$doit"; then + : >"$dsttmp" # No need to fork-exec 'touch'. + else + $doit touch "$dsttmp" + fi + } + } && + $doit_exec $cpprog "$src" "$dsttmp") && # and set any options; do chmod last to preserve setuid bits. # diff --git a/hawk/ac/missing b/hawk/ac/missing index 625aeb11..8d0eaad2 100755 --- a/hawk/ac/missing +++ b/hawk/ac/missing @@ -3,7 +3,7 @@ scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify diff --git a/hawk/ac/test-driver b/hawk/ac/test-driver index b8521a48..89dba1e0 100755 --- a/hawk/ac/test-driver +++ b/hawk/ac/test-driver @@ -3,7 +3,7 @@ scriptversion=2018-03-07.03; # UTC -# Copyright (C) 2011-2018 Free Software Foundation, Inc. +# Copyright (C) 2011-2020 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/hawk/aclocal.m4 b/hawk/aclocal.m4 index 31af506d..6cac91f3 100644 --- a/hawk/aclocal.m4 +++ b/hawk/aclocal.m4 @@ -1,6 +1,6 @@ -# generated automatically by aclocal 1.16.1 -*- Autoconf -*- +# generated automatically by aclocal 1.16.2 -*- Autoconf -*- -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) -# Copyright (C) 2002-2018 Free Software Foundation, Inc. +# Copyright (C) 2002-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -35,7 +35,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.16' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. -m4_if([$1], [1.16.1], [], +m4_if([$1], [1.16.2], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) @@ -51,12 +51,12 @@ m4_define([_AM_AUTOCONF_VERSION], []) # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], -[AM_AUTOMAKE_VERSION([1.16.1])dnl +[AM_AUTOMAKE_VERSION([1.16.2])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) -# Copyright (C) 2011-2018 Free Software Foundation, Inc. +# Copyright (C) 2011-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -118,7 +118,7 @@ AC_SUBST([AR])dnl # AM_AUX_DIR_EXPAND -*- Autoconf -*- -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -170,7 +170,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd` # AM_CONDITIONAL -*- Autoconf -*- -# Copyright (C) 1997-2018 Free Software Foundation, Inc. +# Copyright (C) 1997-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -201,7 +201,7 @@ AC_CONFIG_COMMANDS_PRE( Usually this means the macro was only invoked conditionally.]]) fi])]) -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -392,7 +392,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl # Generate code to set up dependency tracking. -*- Autoconf -*- -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -431,7 +431,9 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], done if test $am_rc -ne 0; then AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments - for automatic dependency tracking. Try re-running configure with the + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE="gmake" (or whatever is + necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking).]) fi @@ -458,7 +460,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], # Do all the work for Automake. -*- Autoconf -*- -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -655,7 +657,7 @@ for _am_header in $config_headers :; do done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -676,7 +678,7 @@ if test x"${install_sh+set}" != xset; then fi AC_SUBST([install_sh])]) -# Copyright (C) 2003-2018 Free Software Foundation, Inc. +# Copyright (C) 2003-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -697,7 +699,7 @@ AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -740,7 +742,7 @@ AC_SUBST([am__quote])]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- -# Copyright (C) 1997-2018 Free Software Foundation, Inc. +# Copyright (C) 1997-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -779,7 +781,7 @@ fi # Helper functions for option handling. -*- Autoconf -*- -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -808,7 +810,7 @@ AC_DEFUN([_AM_SET_OPTIONS], AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) -# Copyright (C) 1999-2018 Free Software Foundation, Inc. +# Copyright (C) 1999-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -855,7 +857,7 @@ AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -874,7 +876,7 @@ AC_DEFUN([AM_RUN_LOG], # Check to make sure that the build environment is sane. -*- Autoconf -*- -# Copyright (C) 1996-2018 Free Software Foundation, Inc. +# Copyright (C) 1996-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -955,7 +957,7 @@ AC_CONFIG_COMMANDS_PRE( rm -f conftest.file ]) -# Copyright (C) 2009-2018 Free Software Foundation, Inc. +# Copyright (C) 2009-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1015,7 +1017,7 @@ AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) -# Copyright (C) 2001-2018 Free Software Foundation, Inc. +# Copyright (C) 2001-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1043,7 +1045,7 @@ fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) -# Copyright (C) 2006-2018 Free Software Foundation, Inc. +# Copyright (C) 2006-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -1062,7 +1064,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- -# Copyright (C) 2004-2018 Free Software Foundation, Inc. +# Copyright (C) 2004-2020 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, diff --git a/hawk/bin/Makefile.in b/hawk/bin/Makefile.in index 83bec953..7c30563c 100644 --- a/hawk/bin/Makefile.in +++ b/hawk/bin/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -329,6 +329,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/configure b/hawk/configure index 32674068..80105b1a 100755 --- a/hawk/configure +++ b/hawk/configure @@ -786,6 +786,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -888,6 +889,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1140,6 +1142,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1277,7 +1288,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1430,6 +1441,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] @@ -26106,7 +26118,9 @@ $as_echo X/"$am_mf" | { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} as_fn_error $? "Something went wrong bootstrapping makefile fragments - for automatic dependency tracking. Try re-running configure with the + for automatic dependency tracking. If GNU make was not used, consider + re-running the configure script with MAKE=\"gmake\" (or whatever is + necessary). You can also try re-running configure with the '--disable-dependency-tracking' option to at least be able to build the package (albeit without support for automatic dependency tracking). See \`config.log' for more details" "$LINENO" 5; } diff --git a/hawk/lib/Makefile.in b/hawk/lib/Makefile.in index ce848513..4398049b 100644 --- a/hawk/lib/Makefile.in +++ b/hawk/lib/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -394,8 +394,8 @@ am__pkginclude_HEADERS_DIST = hawk.h hawk-arr.h hawk-chr.h hawk-cmn.h \ hawk-sed.h hawk-std.h hawk-tre.h hawk-unpack.h hawk-xma.h \ Hawk.hpp HawkStd.hpp HEADERS = $(pkginclude_HEADERS) -am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \ - $(LISP)hawk-cfg.h.in +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) \ + hawk-cfg.h.in # Read a list of newline-separated strings from the standard input, # and print each of them once, without duplicates. Input order is # *not* preserved. @@ -566,6 +566,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/lib/hawk.h b/hawk/lib/hawk.h index 0a8d8df4..8518db5b 100644 --- a/hawk/lib/hawk.h +++ b/hawk/lib/hawk.h @@ -3388,6 +3388,12 @@ HAWK_EXPORT hawk_fun_t* hawk_rtx_valtofun ( hawk_val_t* val ); +HAWK_EXPORT hawk_mod_t* hawk_rtx_valtomodfnc ( + hawk_rtx_t* rtx, + hawk_val_t* val, + hawk_fnc_spec_t* spec +); + /** * The hawk_rtx_hashval() function hashes a simple value * to a positive integer. It returns -1 for a inhashable value. diff --git a/hawk/lib/mod-hawk.c b/hawk/lib/mod-hawk.c index 17fa6e94..f3019627 100644 --- a/hawk/lib/mod-hawk.c +++ b/hawk/lib/mod-hawk.c @@ -42,7 +42,11 @@ typedef struct mod_data_t mod_data_t; */ struct pafs_t { - hawk_fun_t* fun; + int is_fun; + + const hawk_ooch_t* argspec_ptr; + hawk_oow_t argspec_len; + hawk_oow_t stack_base; hawk_oow_t start_index; hawk_oow_t end_index; @@ -51,7 +55,7 @@ struct pafs_t static hawk_oow_t push_args_from_stack (hawk_rtx_t* rtx, hawk_nde_fncall_t* call, void* data) { struct pafs_t* pasf = (struct pafs_t*)data; - hawk_oow_t org_stack_base, spec_len, i, j; + hawk_oow_t org_stack_base, i, j; hawk_val_t* v; if (HAWK_RTX_STACK_AVAIL(rtx) < pasf->end_index - pasf->start_index + 1) @@ -60,8 +64,6 @@ static hawk_oow_t push_args_from_stack (hawk_rtx_t* rtx, hawk_nde_fncall_t* call return (hawk_oow_t)-1; } - spec_len = pasf->fun->argspec? hawk_count_oocstr(pasf->fun->argspec): 0; - org_stack_base = rtx->stack_base; for (i = pasf->start_index, j = 0; i <= pasf->end_index; i++, j++) { @@ -72,14 +74,20 @@ static hawk_oow_t push_args_from_stack (hawk_rtx_t* rtx, hawk_nde_fncall_t* call rtx->stack_base = org_stack_base; /* if not sufficient number of spec characters given, take the last value and use it */ - spec = (spec_len <= 0)? '\0': pasf->fun->argspec[((j < spec_len)? j: spec_len - 1)]; + spec = (pasf->argspec_len <= 0)? '\0': pasf->argspec_ptr[((j < pasf->argspec_len)? j: pasf->argspec_len - 1)]; if (HAWK_RTX_GETVALTYPE(rtx, v) == HAWK_VAL_REF) { - v = hawk_rtx_getrefval(rtx, (hawk_val_ref_t*)v); + if (pasf->is_fun) + { + /* take out the actual value and pass it to the callee + * only if the callee is a user-defined function */ + v = hawk_rtx_getrefval(rtx, (hawk_val_ref_t*)v); + } } else { + /* TODO: verify if R must be checked here.. */ if (spec == 'r') { hawk_rtx_seterrnum (rtx, &call->loc, HAWK_ENOTREF); @@ -96,7 +104,6 @@ static hawk_oow_t push_args_from_stack (hawk_rtx_t* rtx, hawk_nde_fncall_t* call static int fnc_call (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) { -/* TODO: support to call a module function such as sys::getpid() */ hawk_fun_t* fun; hawk_oow_t nargs; hawk_nde_fncall_t call; @@ -104,25 +111,57 @@ static int fnc_call (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) hawk_val_t* v; /* this function is similar to hawk_rtx_callfun() but it is more simplified */ + HAWK_MEMSET (&call, 0, HAWK_SIZEOF(call)); + nargs = hawk_rtx_getnargs(rtx); fun = hawk_rtx_valtofun(rtx, hawk_rtx_getarg(rtx, 0)); - if (!fun) return -1; /* hard failure */ - - nargs = hawk_rtx_getnargs(rtx); - if (nargs - 1 > fun->nargs) + if (fun) { - hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_EARGTM); - return -1; /* hard failure */ + if (nargs - 1 > fun->nargs) + { + hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_EARGTM); + return -1; /* hard failure */ + } + + /* user-defined function call */ + call.type = HAWK_NDE_FNCALL_FUN; + call.u.fun.name = fun->name; + + pafs.is_fun = 1; + pafs.argspec_ptr = fun->argspec; + pafs.argspec_len = fun->argspec? hawk_count_oocstr(fun->argspec): 0; + } + else + { + /* find the name in the modules */ + hawk_mod_t* m; + mod_data_t* md; + +// TODO: find normal fnc too. + md = (mod_data_t*)fi->mod->ctx; + /* hawk_querymodulewithname() may update some shared data under + * the hawk object. use a mutex for shared data safety */ + hawk_mtx_lock (&md->mq_mtx, HAWK_NULL); + m = hawk_rtx_valtomodfnc(rtx, hawk_rtx_getarg(rtx, 0), &call.u.fnc.spec); + hawk_mtx_unlock (&md->mq_mtx); + + if (!m) return -1; /* hard failure */ + + call.type = HAWK_NDE_FNCALL_FNC; + // QQQ0 + // call.u.fnc.info.name = name; + call.u.fnc.info.mod = m; + + pafs.is_fun = 0; + pafs.argspec_ptr = call.u.fnc.spec.arg.spec; + pafs.argspec_len = call.u.fnc.spec.arg.spec? hawk_count_oocstr(call.u.fnc.spec.arg.spec): 0; } - HAWK_MEMSET (&call, 0, HAWK_SIZEOF(call)); - call.type = HAWK_NDE_FNCALL_FUN; - call.u.fun.name = fun->name; call.nargs = nargs - 1; /* keep HAWK_NULL in call.args so that hawk_rtx_evalcall() knows it's a fake call structure */ call.arg_base = rtx->stack_base + 5; /* 5 = 4(stack frame prologue) + 1(the first argument to hawk::call()) */ + //pafs.fun = fun; - pafs.fun = fun; pafs.stack_base = rtx->stack_base; pafs.start_index = 1; pafs.end_index = nargs - 1; @@ -163,7 +202,7 @@ static int fnc_function_exists (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) /* hawk_query_module_with_name() may update some shared data under * the hawk object. use a mutex for shared data safety */ hawk_mtx_lock (&md->mq_mtx, HAWK_NULL); - rx = (hawk_query_module_with_name(hawk_rtx_gethawk(rtx), &name, &sym) != HAWK_NULL); + rx = (hawk_querymodulewithname(hawk_rtx_gethawk(rtx), &name, &sym) != HAWK_NULL); hawk_mtx_unlock (&md->mq_mtx); } } diff --git a/hawk/lib/parse-prv.h b/hawk/lib/parse-prv.h index 295251d0..8a69c868 100644 --- a/hawk/lib/parse-prv.h +++ b/hawk/lib/parse-prv.h @@ -117,7 +117,7 @@ void hawk_clearsionames ( ); -hawk_mod_t* hawk_query_module_with_name ( +hawk_mod_t* hawk_querymodulewithname ( hawk_t* hawk, const hawk_oocs_t* name, hawk_mod_sym_t* sym diff --git a/hawk/lib/parse.c b/hawk/lib/parse.c index fedfe98e..0fa21795 100644 --- a/hawk/lib/parse.c +++ b/hawk/lib/parse.c @@ -7553,7 +7553,7 @@ done: } -hawk_mod_t* hawk_query_module_with_name (hawk_t* hawk, const hawk_oocs_t* name, hawk_mod_sym_t* sym) +hawk_mod_t* hawk_querymodulewithname (hawk_t* hawk, const hawk_oocs_t* name, hawk_mod_sym_t* sym) { const hawk_ooch_t* dc; hawk_oocs_t segs[2]; diff --git a/hawk/lib/run.c b/hawk/lib/run.c index 2eed0a08..72bddc7b 100644 --- a/hawk/lib/run.c +++ b/hawk/lib/run.c @@ -2122,7 +2122,7 @@ static HAWK_INLINE int run_block0 (hawk_rtx_t* rtx, hawk_nde_blk_t* nde) /*saved_stack_top = rtx->stack_top;*/ #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("securing space for local variables nlcls = %d\n"), (int)nde->nlcls); + hawk_logbfmt (hawk_rtx_gethawk(rtx), "securing space for local variables nlcls = %d\n", (int)nde->nlcls); #endif if (nde->nlcls > 0) @@ -2168,7 +2168,7 @@ static HAWK_INLINE int run_block0 (hawk_rtx_t* rtx, hawk_nde_blk_t* nde) } #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("executing block statements\n")); + hawk_logbfmt (hawk_rtx_gethawk(rtx), "executing block statements\n"); #endif p = nde->body; @@ -2184,7 +2184,7 @@ static HAWK_INLINE int run_block0 (hawk_rtx_t* rtx, hawk_nde_blk_t* nde) /* pop off local variables */ #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("popping off local variables\n")); + hawk_logbfmt (hawk_rtx_gethawk(rtx), "popping off local variables\n"); #endif if (nde->nlcls > 0) @@ -4146,7 +4146,7 @@ static hawk_val_t* do_assignment_indexed (hawk_rtx_t* rtx, hawk_nde_var_t* var, #endif #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("**** index str=>%s, map->ref=%d, map->type=%d\n"), str, (int)v->ref, (int)v->type); + hawk_logbfmt (hawk_rtx_gethawk(rtx), "**** index str=>%js, map->ref=%d, map->type=%d\n", str, (int)v->ref, (int)v->type); #endif if (vtype == HAWK_VAL_MAP) @@ -6751,7 +6751,7 @@ hawk_val_t* hawk_rtx_evalcall ( saved_stack_top = rtx->stack_top; #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("setting up function stack frame top=%zd base=%zd\n"), (hawk_oow_t)rtx->stack_top, (hawk_oow_t)rtx->stack_base); + hawk_logbfmt (hawk_rtx_gethawk(rtx), "setting up function stack frame top=%zd base=%zd\n", (hawk_oow_t)rtx->stack_top, (hawk_oow_t)rtx->stack_base); #endif /* make a new stack frame */ @@ -6799,7 +6799,7 @@ hawk_val_t* hawk_rtx_evalcall ( HAWK_RTX_STACK_NARGS(rtx) = (void*)nargs; #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("running function body\n")); + hawk_logbfmt (hawk_rtx_gethawk(rtx), "running function body\n"); #endif if (fun) @@ -6825,7 +6825,7 @@ hawk_val_t* hawk_rtx_evalcall ( /* refdown args in the rtx.stack */ nargs = (hawk_oow_t)HAWK_RTX_STACK_NARGS(rtx); #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("block rtx complete nargs = %d\n"), (int)nargs); + hawk_logbfmt (hawk_rtx_gethawk(rtx), "block rtx complete nargs = %d\n", (int)nargs); #endif i = 0; @@ -6949,7 +6949,7 @@ hawk_val_t* hawk_rtx_evalcall ( } #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("got return value\n")); + hawk_logbfmt (hawk_rtx_gethawk(rtx), "got return value\n"); #endif v = HAWK_RTX_STACK_RETVAL(rtx); @@ -7004,7 +7004,7 @@ hawk_val_t* hawk_rtx_evalcall ( if (rtx->exit_level == EXIT_FUNCTION) rtx->exit_level = EXIT_NONE; #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("returning from function top=%zd, base=%zd\n"), (hawk_oow_t)rtx->stack_top, (hawk_oow_t)rtx->stack_base); + hawk_logbfmt (hawk_rtx_gethawk(rtx), "returning from function top=%zd, base=%zd\n", (hawk_oow_t)rtx->stack_top, (hawk_oow_t)rtx->stack_base); #endif return (n <= -1)? HAWK_NULL: v; @@ -7922,7 +7922,7 @@ read_again: } #if defined(DEBUG_RUN) - hawk_logfmt (hawk_rtx_gethawk(rtx), HAWK_T("record len = %d str=[%.*js]\n"), (int)HAWK_OOECS_LEN(buf), HAWK_OOECS_LEN(buf), HAWK_OOECS_PTR(buf)); + hawk_logfbmt (hawk_rtx_gethawk(rtx), "record len = %d str=[%.*js]\n", (int)HAWK_OOECS_LEN(buf), HAWK_OOECS_LEN(buf), HAWK_OOECS_PTR(buf)); #endif if (n == 0) { diff --git a/hawk/lib/tree-prv.h b/hawk/lib/tree-prv.h index 22f27f3d..452b0bf9 100644 --- a/hawk/lib/tree-prv.h +++ b/hawk/lib/tree-prv.h @@ -238,7 +238,7 @@ struct hawk_nde_fncall_t hawk_fun_t* fun; /* cache it */ } fun; - /* minimum information of a intrinsic function + /* minimum information of an intrinsic function * needed during run-time. */ struct { diff --git a/hawk/lib/val.c b/hawk/lib/val.c index 4e48e53f..7ddd2149 100644 --- a/hawk/lib/val.c +++ b/hawk/lib/val.c @@ -2526,7 +2526,7 @@ hawk_bch_t* hawk_rtx_getvalbcstrwithcmgr (hawk_rtx_t* rtx, hawk_val_t* v, hawk_o rtx->bctos.b[fi].c[1] = '\0'; if (len) *len = l; HAWK_ASSERT ((void*)&rtx->bctos.b[fi] == (void*)rtx->bctos.b[fi].c); - return rtx->bctos.b[fi].c; + return (hawk_bch_t*)rtx->bctos.b[fi].c; /* type-cast hawk_bchu_t* to hawk_bch_t* */ } goto duplicate; @@ -2821,6 +2821,51 @@ hawk_fun_t* hawk_rtx_valtofun (hawk_rtx_t* rtx, hawk_val_t* v) return fun; } +hawk_mod_t* hawk_rtx_valtomodfnc (hawk_rtx_t* rtx, hawk_val_t* v, hawk_fnc_spec_t* spec) +{ + hawk_t* hawk = hawk_rtx_gethawk(rtx); + hawk_mod_t* mod; + hawk_mod_sym_t sym; + hawk_val_type_t vtype; + + vtype = HAWK_RTX_GETVALTYPE(rtx, v); + + switch (vtype) + { + case HAWK_VAL_BCHR: + case HAWK_VAL_MBS: + case HAWK_VAL_CHAR: + case HAWK_VAL_STR: + { + hawk_oocs_t x; + x.ptr = hawk_rtx_getvaloocstr(rtx, v, &x.len); + if (HAWK_UNLIKELY(!x.ptr)) return HAWK_NULL; + if (hawk_count_oocstr(x.ptr) != x.len) + { + hawk_rtx_freevaloocstr (rtx, v, x.ptr); + goto error_inval; + } + mod = hawk_querymodulewithname(hawk, &x, &sym); + hawk_rtx_freevaloocstr (rtx, v, x.ptr); + if (!mod) return HAWK_NULL; + break; + } + + default: + error_inval: + hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_EINVAL); + return HAWK_NULL; + } + + if (sym.type != HAWK_MOD_FNC || (hawk->opt.trait & sym.u.fnc_.trait) != sym.u.fnc_.trait) + { + hawk_rtx_seterrnum (rtx, HAWK_NULL, HAWK_ENOENT); + return HAWK_NULL; + } + + *spec = sym.u.fnc_; + return mod; +} /* ========================================================================== */ diff --git a/hawk/mod/Makefile.in b/hawk/mod/Makefile.in index 6b989b06..112da930 100644 --- a/hawk/mod/Makefile.in +++ b/hawk/mod/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -416,6 +416,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/mod/mod-sed.c b/hawk/mod/mod-sed.c index 8da838b6..5bd4aca0 100644 --- a/hawk/mod/mod-sed.c +++ b/hawk/mod/mod-sed.c @@ -157,7 +157,6 @@ static int fnc_str_to_str (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) } /* TODO hawk_set_opt (TRAIT) using the optional parameter */ - for (i = 0; i < 2; i++) { a[i] = hawk_rtx_getarg(rtx, i); @@ -191,7 +190,7 @@ static int fnc_str_to_str (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) } hawk_rtx_refupval (rtx, tmp); - n = hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg (rtx, 2), tmp); + n = hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), tmp); hawk_rtx_refdownval (rtx, tmp); if (n <= -1) { diff --git a/hawk/samples/Makefile.in b/hawk/samples/Makefile.in index e2515d70..0a0e2ebc 100644 --- a/hawk/samples/Makefile.in +++ b/hawk/samples/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -351,6 +351,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/Makefile.in b/hawk/t/Makefile.in index 25f54476..e9fced22 100644 --- a/hawk/t/Makefile.in +++ b/hawk/t/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -556,6 +556,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/h-009.hawk b/hawk/t/h-009.hawk index 0b7daadf..b78cb1c8 100644 --- a/hawk/t/h-009.hawk +++ b/hawk/t/h-009.hawk @@ -7,8 +7,12 @@ function run_test_001 () { @local tmp, out; - tmp = sed::str_to_str("s/a/j/g", "aaabbbaaacccaaaddd", out); - ensure (out === "jjjbbbjjjcccjjjddd", 1, @SCRIPTNAME, @SCRIPTLINE); + if (hawk::function_exists("sed::str_to_str")) + { + ##tmp = sed::str_to_str("s/a/j/g", "aaabbbaaacccaaaddd", out); + tmp = hawk::call("sed::str_to_str", "s/a/j/g", "aaabbbaaacccaaaddd", out); + ensure (out === "jjjbbbjjjcccjjjddd", 1, @SCRIPTNAME, @SCRIPTLINE); + } } function main() diff --git a/hawk/tools/Makefile.in b/hawk/tools/Makefile.in index d6d3f2f4..0dad1bfe 100644 --- a/hawk/tools/Makefile.in +++ b/hawk/tools/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.16.2 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2020 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -328,6 +328,7 @@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ +runstatedir = @runstatedir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@