added a new directory - samples

more code in Hawk and HawkStd
This commit is contained in:
hyung-hwan 2020-01-07 09:02:56 +00:00
parent 053dec0f99
commit 05c58df30f
21 changed files with 3285 additions and 2230 deletions

View File

@ -5,9 +5,9 @@ EXTRA_DIST =
SUBDIRS = SUBDIRS =
if ENABLE_STATIC_MODULE if ENABLE_STATIC_MODULE
SUBDIRS += tools mod lib bin SUBDIRS += tools mod lib bin samples
else else
SUBDIRS += tools lib mod bin SUBDIRS += tools lib mod bin samples
endif endif
DIST_SUBDIRS = $(SUBDIRS) t DIST_SUBDIRS = $(SUBDIRS) t

View File

@ -87,8 +87,8 @@ PRE_UNINSTALL = :
POST_UNINSTALL = : POST_UNINSTALL = :
build_triplet = @build@ build_triplet = @build@
host_triplet = @host@ host_triplet = @host@
@ENABLE_STATIC_MODULE_TRUE@am__append_1 = tools mod lib bin @ENABLE_STATIC_MODULE_TRUE@am__append_1 = tools mod lib bin samples
@ENABLE_STATIC_MODULE_FALSE@am__append_2 = tools lib mod bin @ENABLE_STATIC_MODULE_FALSE@am__append_2 = tools lib mod bin samples
subdir = . subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \ am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
@ -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/depcomp \ ac/compile ac/config.guess ac/config.sub ac/install-sh \
ac/install-sh ac/ltmain.sh ac/missing 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)

View File

@ -4,7 +4,7 @@
me=ar-lib me=ar-lib
scriptversion=2012-03-01.08; # UTC scriptversion=2012-03-01.08; # UTC
# Copyright (C) 2010-2014 Free Software Foundation, Inc. # Copyright (C) 2010-2018 Free Software Foundation, Inc.
# Written by Peter Rosin <peda@lysator.liu.se>. # Written by Peter Rosin <peda@lysator.liu.se>.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@ -18,7 +18,7 @@ scriptversion=2012-03-01.08; # UTC
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a

View File

@ -1,9 +1,9 @@
#! /bin/sh #! /bin/sh
# Wrapper for compilers which do not understand '-c -o'. # Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc. # Copyright (C) 1999-2018 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>. # Written by Tom Tromey <tromey@cygnus.com>.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a
@ -255,7 +255,8 @@ EOF
echo "compile $scriptversion" echo "compile $scriptversion"
exit $? exit $?
;; ;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return... func_cl_wrapper "$@" # Doesn't return...
;; ;;
esac esac
@ -339,9 +340,9 @@ exit $ret
# Local Variables: # Local Variables:
# mode: shell-script # mode: shell-script
# sh-indentation: 2 # sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp) # eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC" # time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC" # time-stamp-end: "; # UTC"
# End: # End:

666
hawk/ac/config.guess vendored

File diff suppressed because it is too large Load Diff

2781
hawk/ac/config.sub vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
#! /bin/sh #! /bin/sh
# depcomp - compile a program generating dependencies as side-effects # depcomp - compile a program generating dependencies as side-effects
scriptversion=2013-05-30.07; # UTC scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc. # Copyright (C) 1999-2018 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -16,7 +16,7 @@ scriptversion=2013-05-30.07; # UTC
# GNU General Public License for more details. # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a
@ -783,9 +783,9 @@ exit 0
# Local Variables: # Local Variables:
# mode: shell-script # mode: shell-script
# sh-indentation: 2 # sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp) # eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC" # time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC" # time-stamp-end: "; # UTC"
# End: # End:

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
# install - install a program, script, or datafile # install - install a program, script, or datafile
scriptversion=2014-09-12.12; # UTC scriptversion=2018-03-11.20; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was # This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the # later released in X11R6 (xc/config/util/install.sh) with the
@ -271,15 +271,18 @@ do
fi fi
dst=$dst_arg dst=$dst_arg
# If destination is a directory, append the input filename; won't work # If destination is a directory, append the input filename.
# if double slashes aren't ignored.
if test -d "$dst"; then if test -d "$dst"; then
if test "$is_target_a_directory" = never; then if test "$is_target_a_directory" = never; then
echo "$0: $dst_arg: Is a directory" >&2 echo "$0: $dst_arg: Is a directory" >&2
exit 1 exit 1
fi fi
dstdir=$dst dstdir=$dst
dst=$dstdir/`basename "$src"` dstbase=`basename "$src"`
case $dst in
*/) dst=$dst$dstbase;;
*) dst=$dst/$dstbase;;
esac
dstdir_status=0 dstdir_status=0
else else
dstdir=`dirname "$dst"` dstdir=`dirname "$dst"`
@ -288,6 +291,11 @@ do
fi fi
fi fi
case $dstdir in
*/) dstdirslash=$dstdir;;
*) dstdirslash=$dstdir/;;
esac
obsolete_mkdir_used=false obsolete_mkdir_used=false
if test $dstdir_status != 0; then if test $dstdir_status != 0; then
@ -324,14 +332,16 @@ do
# is incompatible with FreeBSD 'install' when (umask & 300) != 0. # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;; ;;
*) *)
# $RANDOM is not portable (e.g. dash); use it when possible to # Note that $RANDOM variable is not portable (e.g. dash); Use it
# lower collision chance # here however when possible just to lower collision chance.
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0
# As "mkdir -p" follows symlinks and we work in /tmp possibly; so # Because "mkdir -p" follows existing symlinks and we likely work
# create the $tmpdir first (and fail if unsuccessful) to make sure # directly in world-writeable /tmp, make sure that the '$tmpdir'
# that nobody tries to guess the $tmpdir name. # directory is successfully created first before we actually test
# 'mkdir -p' feature.
if (umask $mkdir_umask && if (umask $mkdir_umask &&
$mkdirprog $mkdir_mode "$tmpdir" && $mkdirprog $mkdir_mode "$tmpdir" &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1
@ -434,8 +444,8 @@ do
else else
# Make a couple of temp file names in the proper directory. # Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_ dsttmp=${dstdirslash}_inst.$$_
rmtmp=$dstdir/_rm.$$_ rmtmp=${dstdirslash}_rm.$$_
# Trap to clean up those temp files at exit. # Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
@ -500,9 +510,9 @@ do
done done
# Local variables: # Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp) # eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC" # time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC" # time-stamp-end: "; # UTC"
# End: # End:

View File

@ -31,7 +31,7 @@
PROGRAM=libtool PROGRAM=libtool
PACKAGE=libtool PACKAGE=libtool
VERSION="2.4.6 Debian-2.4.6-2" VERSION=2.4.6
package_revision=2.4.6 package_revision=2.4.6
@ -2068,12 +2068,12 @@ include the following information:
compiler: $LTCC compiler: $LTCC
compiler flags: $LTCFLAGS compiler flags: $LTCFLAGS
linker: $LD (gnu? $with_gnu_ld) linker: $LD (gnu? $with_gnu_ld)
version: $progname $scriptversion Debian-2.4.6-2 version: $progname (GNU libtool) 2.4.6
automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
Report bugs to <bug-libtool@gnu.org>. Report bugs to <bug-libtool@gnu.org>.
GNU libtool home page: <http://www.gnu.org/s/libtool/>. GNU libtool home page: <http://www.gnu.org/software/libtool/>.
General help using GNU software: <http://www.gnu.org/gethelp/>." General help using GNU software: <http://www.gnu.org/gethelp/>."
exit 0 exit 0
} }
@ -2124,7 +2124,7 @@ fi
# a configuration failure hint, and exit. # a configuration failure hint, and exit.
func_fatal_configuration () func_fatal_configuration ()
{ {
func__fatal_error ${1+"$@"} \ func_fatal_error ${1+"$@"} \
"See the $PACKAGE documentation for more information." \ "See the $PACKAGE documentation for more information." \
"Fatal configuration error." "Fatal configuration error."
} }
@ -7274,11 +7274,10 @@ func_mode_link ()
# -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
# -specs=* GCC specs files # -specs=* GCC specs files
# -stdlib=* select c++ std lib with clang # -stdlib=* select c++ std lib with clang
# -fsanitize=* Clang/GCC memory and address sanitizer
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
-t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
-O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
-specs=*|-fsanitize=*) -specs=*)
func_quote_for_eval "$arg" func_quote_for_eval "$arg"
arg=$func_quote_for_eval_result arg=$func_quote_for_eval_result
func_append compile_command " $arg" func_append compile_command " $arg"
@ -7571,10 +7570,7 @@ func_mode_link ()
case $pass in case $pass in
dlopen) libs=$dlfiles ;; dlopen) libs=$dlfiles ;;
dlpreopen) libs=$dlprefiles ;; dlpreopen) libs=$dlprefiles ;;
link) link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
libs="$deplibs %DEPLIBS%"
test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
;;
esac esac
fi fi
if test lib,dlpreopen = "$linkmode,$pass"; then if test lib,dlpreopen = "$linkmode,$pass"; then
@ -7893,19 +7889,19 @@ func_mode_link ()
# It is a libtool convenience library, so add in its objects. # It is a libtool convenience library, so add in its objects.
func_append convenience " $ladir/$objdir/$old_library" func_append convenience " $ladir/$objdir/$old_library"
func_append old_convenience " $ladir/$objdir/$old_library" func_append old_convenience " $ladir/$objdir/$old_library"
tmp_libs=
for deplib in $dependency_libs; do
deplibs="$deplib $deplibs"
if $opt_preserve_dup_deps; then
case "$tmp_libs " in
*" $deplib "*) func_append specialdeplibs " $deplib" ;;
esac
fi
func_append tmp_libs " $deplib"
done
elif test prog != "$linkmode" && test lib != "$linkmode"; then elif test prog != "$linkmode" && test lib != "$linkmode"; then
func_fatal_error "'$lib' is not a convenience library" func_fatal_error "'$lib' is not a convenience library"
fi fi
tmp_libs=
for deplib in $dependency_libs; do
deplibs="$deplib $deplibs"
if $opt_preserve_dup_deps; then
case "$tmp_libs " in
*" $deplib "*) func_append specialdeplibs " $deplib" ;;
esac
fi
func_append tmp_libs " $deplib"
done
continue continue
fi # $pass = conv fi # $pass = conv
@ -8829,9 +8825,6 @@ func_mode_link ()
revision=$number_minor revision=$number_minor
lt_irix_increment=no lt_irix_increment=no
;; ;;
*)
func_fatal_configuration "$modename: unknown library version type '$version_type'"
;;
esac esac
;; ;;
no) no)

View File

@ -1,9 +1,9 @@
#! /bin/sh #! /bin/sh
# Common wrapper for a few potentially missing GNU programs. # Common wrapper for a few potentially missing GNU programs.
scriptversion=2013-10-28.13; # UTC scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1996-2014 Free Software Foundation, Inc. # Copyright (C) 1996-2018 Free Software Foundation, Inc.
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996. # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
@ -17,7 +17,7 @@ scriptversion=2013-10-28.13; # UTC
# GNU General Public License for more details. # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a
@ -101,9 +101,9 @@ else
exit $st exit $st
fi fi
perl_URL=http://www.perl.org/ perl_URL=https://www.perl.org/
flex_URL=http://flex.sourceforge.net/ flex_URL=https://github.com/westes/flex
gnu_software_URL=http://www.gnu.org/software gnu_software_URL=https://www.gnu.org/software
program_details () program_details ()
{ {
@ -207,9 +207,9 @@ give_advice "$1" | sed -e '1s/^/WARNING: /' \
exit $st exit $st
# Local variables: # Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp) # eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion=" # time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC" # time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC" # time-stamp-end: "; # UTC"
# End: # End:

View File

@ -24,11 +24,7 @@
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#if defined(__cplusplus)
#include <HawkStd.hpp>
#else
#include <hawk-std.h> #include <hawk-std.h>
#endif
#include <hawk-utl.h> #include <hawk-utl.h>
#include <hawk-fmt.h> #include <hawk-fmt.h>
#include <hawk-cli.h> #include <hawk-cli.h>
@ -1083,325 +1079,6 @@ static hawk_mmgr_t debug_mmgr =
#endif #endif
#if defined(__cplusplus)
/* -------------------------------------------------------------------------
* BEGINNING OF execute_hawk() in C++
* ------------------------------------------------------------------------- */
typedef HAWK::HawkStd HawkStd;
typedef HAWK::HawkStd::Run Run;
typedef HAWK::HawkStd::Value Value;
class MyHawk: public HawkStd
{
public:
MyHawk (HAWK::Mmgr* mmgr = HAWK_NULL): HawkStd(mmgr) { }
~MyHawk () { close (); }
int open ()
{
if (HawkStd::open() <= -1) return -1;
idLastSleep = this->addGlobal(HAWK_T("LAST_SLEEP"));
if (idLastSleep <= -1) goto oops;
/* this is for demonstration only.
* you can use sys::sleep() instead */
if (this->addFunction(HAWK_T("sleep"), 1, 1, HAWK_NULL, (FunctionHandler)&MyHawk::sleep) <= -1 ||
this->addFunction(HAWK_T("sumintarray"), 1, 1, HAWK_NULL, (FunctionHandler)&MyHawk::sumintarray) <= -1 ||
this->addFunction(HAWK_T("arrayindices"), 1, 1, HAWK_NULL, (FunctionHandler)&MyHawk::arrayindices) <= -1) goto oops;
return 0;
oops:
HawkStd::close ();
return -1;
}
int sleep (
Run& run, Value& ret, Value* args, hawk_oow_t nargs,
const hawk_ooch_t* name, hawk_oow_t len)
{
if (args[0].isIndexed())
{
run.setError (HAWK_EINVAL);
return -1;
}
Hawk::int_t x = args[0].toInt();
/*Value arg;
if (run.getGlobal(idLastSleep, arg) == 0)
qse_printf (HAWK_T("GOOD: [%d]\n"), (int)arg.toInt());
else { qse_printf (HAWK_T("BAD:\n")); }
*/
if (run.setGlobal(idLastSleep, x) <= -1) return -1;
#if defined(_WIN32)
::Sleep ((DWORD)(x * 1000));
return ret.setInt (0);
#elif defined(__OS2__)
::DosSleep ((ULONG)(x * 1000));
return ret.setInt (0);
#else
return ret.setInt (::sleep (x));
#endif
}
int sumintarray (
Run& run, Value& ret, Value* args, hawk_oow_t nargs,
const hawk_ooch_t* name, hawk_oow_t len)
{
// BEGIN {
// for(i=0;i<=10;i++) x[i]=i;
// print sumintarray(x);
// }
long_t x = 0;
if (args[0].isIndexed())
{
Value val(run);
Value::Index idx;
Value::IndexIterator ii;
ii = args[0].getFirstIndex (&idx);
while (ii != ii.END)
{
if (args[0].getIndexed(idx, &val) <= -1) return -1;
x += val.toInt ();
ii = args[0].getNextIndex (&idx, ii);
}
}
else x += args[0].toInt();
return ret.setInt (x);
}
int arrayindices (
Run& run,
Value& ret,
Value* args,
hawk_oow_t nargs,
const hawk_ooch_t* name,
hawk_oow_t len)
{
// create another array composed of array indices
// BEGIN {
// for(i=0;i<=10;i++) x[i]=i;
// y=arrayindices(x);
// for (i in y) print y[i];
// }
if (!args[0].isIndexed()) return 0;
Value::Index idx;
Value::IndexIterator ii;
long_t i;
ii = args[0].getFirstIndex (&idx);
for (i = 0; ii != ii.END ; i++)
{
Value::IntIndex iidx (i);
if (ret.setIndexedStr (iidx, idx.pointer(), idx.length()) <= -1) return -1;
ii = args[0].getNextIndex (&idx, ii);
}
return 0;
}
private:
int idLastSleep;
};
static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[])
{
hawk_t* awk = HAWK_NULL;
hawk_rtx_t* rtx = HAWK_NULL;
hawk_val_t* retv;
int i;
struct arg_t arg;
int ret = -1;
#if defined(ENABLE_CALLBACK)
static hawk_rtx_ecb_t rtx_ecb =
{
HAWK_FV(.close, HAWK_NULL),
HAWK_FV(.stmt, on_statement),
HAWK_FV(.gblset, HAWK_NULL)
};
#endif
/* TODO: change it to support multiple source files */
hawk_parsestd_t psout;
#if 0
hawk_mmgr_t* mmgr = HAWK_MMGR_GETDFL();
#endif
i = process_argv(argc, argv, &arg);
if (i <= 0)
{
print_usage (((i == 0)? stdout: stderr), argv[0]);
return i;
}
if (i == 2) return 0;
if (i == 3) return -1;
if (arg.osf)
{
psout.type = HAWK_PARSESTD_FILEB;
psout.u.fileb.path = arg.osf;
psout.u.fileb.cmgr = arg.script_cmgr;
}
#if 0
#if defined(HAWK_BUILD_DEBUG)
if (arg.failmalloc > 0)
{
debug_mmgr.ctx = &arg;
mmgr = &debug_mmgr;
}
else
#endif
if (arg.memlimit > 0)
{
xma_mmgr.ctx = hawk_xma_open(HAWK_MMGR_GETDFL(), 0, arg.memlimit);
if (xma_mmgr.ctx == HAWK_NULL)
{
print_error ("cannot open memory heap\n");
goto oops;
}
mmgr = &xma_mmgr;
}
#endif
MyHawk hawk;
if (hawk.open() <= -1);
{
//print_error ("cannot open awk - %hs\n", hawk.getErrorMessage()); // TODO: get ErrorMessage as byte string
print_error ("cannot open awk\n");
goto oops;
}
if (arg.modern) i = HAWK_MODERN;
else if (arg.classic) i = HAWK_CLASSIC;
else i = hawk.getTrait();
if (arg.opton) i |= arg.opton;
if (arg.optoff) i &= ~arg.optoff;
hawk.setTrait (i);
/* TODO: get depth from command line */
hawk.setMaxDepth (MyHawk::DEPTH_BLOCK_PARSE, 50);
hawk.setMaxDepth (MyHawk::DEPTH_EXPR_PARSE, 50);
hawk.setMaxDepth (MyHawk::DEPTH_BLOCK_RUN, 500);
hawk.setMaxDepth (MyHawk::DEPTH_EXPR_RUN, 500);
hawk.setMaxDepth (MyHawk::DEPTH_INCLUDE, 64);
if (add_gvs_to_awk(awk, &arg) <= -1)
{
print_hawk_error (awk);
goto oops;
}
MyHawk::Source* in, * out;
MyHawk::SourceString in_str (cmdline.ins);
MyHawk::SourceFile in_file (cmdline.inf);
MyHawk::SourceFile out_file (cmdline.outf);
in = (cmdline.ins)? (MyHawk::Source*)&in_str: (MyHawk::Source*)&in_file;
out = (cmdline.outf)? (MyHawk::Source*)&out_file: &MyHawk::Source::NONE;
MyHawk::Run* run = hawk.parse(*in, *out);
if (!run)
{
print_error ("parse error\n"); // TODO: include error message...
return -1;
}
if (hawk_parsestd(awk, arg.psin, ((arg.osf == HAWK_NULL)? HAWK_NULL: &psout)) <= -1)
{
print_hawk_error (awk);
goto oops;
}
rtx = hawk_rtx_openstdwithbcstr(
awk, 0, "hawk",
(arg.call? HAWK_NULL: arg.icf.ptr), /* console input */
arg.ocf.ptr, /* console output */
arg.console_cmgr
);
if (rtx == HAWK_NULL)
{
print_hawk_error (awk);
goto oops;
}
if (apply_fs_and_gvs_to_rtx(rtx, &arg) <= -1)
{
print_hawk_error (awk);
goto oops;
}
app_rtx = rtx;
#if defined(ENABLE_CALLBACK)
hawk_rtx_pushecb (rtx, &rtx_ecb);
#endif
set_intr_run ();
retv = arg.call?
hawk_rtx_callwithbcstrarr(rtx, arg.call, (const hawk_bch_t**)arg.icf.ptr, arg.icf.size):
hawk_rtx_loop(rtx);
unset_intr_run ();
if (retv)
{
hawk_int_t tmp;
hawk_rtx_refdownval (rtx, retv);
if (app_debug) dprint_return (rtx, retv);
ret = 0;
if (hawk_rtx_valtoint (rtx, retv, &tmp) >= 0) ret = tmp;
}
else
{
print_hawk_rtx_error (rtx);
goto oops;
}
oops:
if (rtx) hawk_rtx_close (rtx);
if (awk) hawk_close (awk);
#if 0
if (xma_mmgr.ctx) hawk_xma_close (xma_mmgr.ctx);
#endif
freearg (&arg);
#if defined(HAWK_BUILD_DEBUG)
/*
if (arg.failmalloc > 0)
{
hawk_fprintf (HAWK_STDERR, HAWK_T("\n"));
hawk_fprintf (HAWK_STDERR, HAWK_T("-[MALLOC COUNTS]---------------------------------------\n"));
hawk_fprintf (HAWK_STDERR, HAWK_T("ALLOC: %lu FREE: %lu: REALLOC: %lu\n"),
(unsigned long)debug_mmgr_alloc_count,
(unsigned long)debug_mmgr_free_count,
(unsigned long)debug_mmgr_realloc_count);
hawk_fprintf (HAWK_STDERR, HAWK_T("-------------------------------------------------------\n"));
}*/
#endif
return ret;
}
/* -------------------------------------------------------------------------
* END OF execute_hawk() in C++
* ------------------------------------------------------------------------- */
#else
/* -------------------------------------------------------------------------
* BEGINNING OF execute_hawk() in C
* ------------------------------------------------------------------------- */
static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[]) static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[])
{ {
hawk_t* awk = HAWK_NULL; hawk_t* awk = HAWK_NULL;
@ -1574,10 +1251,6 @@ oops:
return ret; return ret;
} }
/* -------------------------------------------------------------------------
* END OF execute_hawk() in C
* ------------------------------------------------------------------------- */
#endif
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

53
hawk/configure vendored
View File

@ -7192,7 +7192,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
lt_cv_deplibs_check_method=pass_all lt_cv_deplibs_check_method=pass_all
;; ;;
netbsd* | netbsdelf*-gnu) netbsd*)
if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$' lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
else else
@ -10894,9 +10894,6 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
openbsd* | bitrig*) openbsd* | bitrig*)
with_gnu_ld=no with_gnu_ld=no
;; ;;
linux* | k*bsd*-gnu | gnu*)
link_all_deplibs=no
;;
esac esac
ld_shlibs=yes ld_shlibs=yes
@ -11151,7 +11148,7 @@ _LT_EOF
fi fi
;; ;;
netbsd* | netbsdelf*-gnu) netbsd*)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
wlarc= wlarc=
@ -11821,7 +11818,6 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
if test yes = "$lt_cv_irix_exported_symbol"; then if test yes = "$lt_cv_irix_exported_symbol"; then
archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
fi fi
link_all_deplibs=no
else else
archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
@ -11843,7 +11839,7 @@ $as_echo "$lt_cv_irix_exported_symbol" >&6; }
esac esac
;; ;;
netbsd* | netbsdelf*-gnu) netbsd*)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
else else
@ -12938,6 +12934,9 @@ fi
# before this can be enabled. # before this can be enabled.
hardcode_into_libs=yes hardcode_into_libs=yes
# Add ABI-specific directories to the system library path.
sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
# Ideally, we could use ldconfig to report *all* directores which are # Ideally, we could use ldconfig to report *all* directores which are
# searched for libraries, however this is still not possible. Aside from not # searched for libraries, however this is still not possible. Aside from not
# being certain /sbin/ldconfig is available, command # being certain /sbin/ldconfig is available, command
@ -12946,7 +12945,7 @@ fi
# appending ld.so.conf contents (and includes) to the search path. # appending ld.so.conf contents (and includes) to the search path.
if test -f /etc/ld.so.conf; then if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
fi fi
# We used to test for /lib/ld.so.1 and disable shared libraries on # We used to test for /lib/ld.so.1 and disable shared libraries on
@ -12958,18 +12957,6 @@ fi
dynamic_linker='GNU/Linux ld.so' dynamic_linker='GNU/Linux ld.so'
;; ;;
netbsdelf*-gnu)
version_type=linux
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
dynamic_linker='NetBSD ld.elf_so'
;;
netbsd*) netbsd*)
version_type=sunos version_type=sunos
need_lib_prefix=no need_lib_prefix=no
@ -15864,7 +15851,7 @@ lt_prog_compiler_static_CXX=
;; ;;
esac esac
;; ;;
netbsd* | netbsdelf*-gnu) netbsd*)
;; ;;
*qnx* | *nto*) *qnx* | *nto*)
# QNX uses GNU C++, but need to define -shared option too, otherwise # QNX uses GNU C++, but need to define -shared option too, otherwise
@ -16239,9 +16226,6 @@ $as_echo_n "checking whether the $compiler linker ($LD) supports shared librarie
;; ;;
esac esac
;; ;;
linux* | k*bsd*-gnu | gnu*)
link_all_deplibs_CXX=no
;;
*) *)
export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
;; ;;
@ -16915,6 +16899,9 @@ fi
# before this can be enabled. # before this can be enabled.
hardcode_into_libs=yes hardcode_into_libs=yes
# Add ABI-specific directories to the system library path.
sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
# Ideally, we could use ldconfig to report *all* directores which are # Ideally, we could use ldconfig to report *all* directores which are
# searched for libraries, however this is still not possible. Aside from not # searched for libraries, however this is still not possible. Aside from not
# being certain /sbin/ldconfig is available, command # being certain /sbin/ldconfig is available, command
@ -16923,7 +16910,7 @@ fi
# appending ld.so.conf contents (and includes) to the search path. # appending ld.so.conf contents (and includes) to the search path.
if test -f /etc/ld.so.conf; then if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
fi fi
# We used to test for /lib/ld.so.1 and disable shared libraries on # We used to test for /lib/ld.so.1 and disable shared libraries on
@ -16935,18 +16922,6 @@ fi
dynamic_linker='GNU/Linux ld.so' dynamic_linker='GNU/Linux ld.so'
;; ;;
netbsdelf*-gnu)
version_type=linux
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
dynamic_linker='NetBSD ld.elf_so'
;;
netbsd*) netbsd*)
version_type=sunos version_type=sunos
need_lib_prefix=no need_lib_prefix=no
@ -23298,7 +23273,7 @@ HAWK_PROJECT_AUTHOR="${PACKAGE_BUGREPORT}"
HAWK_PROJECT_URL="${PACKAGE_URL}" HAWK_PROJECT_URL="${PACKAGE_URL}"
ac_config_files="$ac_config_files Makefile tools/Makefile lib/Makefile mod/Makefile bin/Makefile t/Makefile" ac_config_files="$ac_config_files Makefile tools/Makefile lib/Makefile mod/Makefile bin/Makefile samples/Makefile t/Makefile"
cat >confcache <<\_ACEOF cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure # This file is a shell script that caches the results of configure
@ -24468,6 +24443,7 @@ do
"lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
"mod/Makefile") CONFIG_FILES="$CONFIG_FILES mod/Makefile" ;; "mod/Makefile") CONFIG_FILES="$CONFIG_FILES mod/Makefile" ;;
"bin/Makefile") CONFIG_FILES="$CONFIG_FILES bin/Makefile" ;; "bin/Makefile") CONFIG_FILES="$CONFIG_FILES bin/Makefile" ;;
"samples/Makefile") CONFIG_FILES="$CONFIG_FILES samples/Makefile" ;;
"t/Makefile") CONFIG_FILES="$CONFIG_FILES t/Makefile" ;; "t/Makefile") CONFIG_FILES="$CONFIG_FILES t/Makefile" ;;
*) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
@ -25173,6 +25149,7 @@ See \`config.log' for more details" "$LINENO" 5; }
cat <<_LT_EOF >> "$cfgfile" cat <<_LT_EOF >> "$cfgfile"
#! $SHELL #! $SHELL
# Generated automatically by $as_me ($PACKAGE) $VERSION # Generated automatically by $as_me ($PACKAGE) $VERSION
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh. # NOTE: Changes made to this file will be lost: look at ltmain.sh.
# Provide generalized library-building support services. # Provide generalized library-building support services.

View File

@ -988,6 +988,7 @@ AC_CONFIG_FILES([
lib/Makefile lib/Makefile
mod/Makefile mod/Makefile
bin/Makefile bin/Makefile
samples/Makefile
t/Makefile t/Makefile
]) ])
AC_OUTPUT AC_OUTPUT

View File

@ -726,7 +726,9 @@ int Hawk::Value::setFlt (Run* r, flt_t v)
return n; return n;
} }
int Hawk::Value::setStr (const hawk_ooch_t* str, hawk_oow_t len, bool numeric) //////////////////////////////////////////////////////////////////
int Hawk::Value::setStr (const hawk_uch_t* str, hawk_oow_t len, bool numeric)
{ {
if (this->run == HAWK_NULL) if (this->run == HAWK_NULL)
{ {
@ -737,16 +739,12 @@ int Hawk::Value::setStr (const hawk_ooch_t* str, hawk_oow_t len, bool numeric)
return this->setStr(this->run, str, len, numeric); return this->setStr(this->run, str, len, numeric);
} }
int Hawk::Value::setStr (Run* r, const hawk_ooch_t* str, hawk_oow_t len, bool numeric) int Hawk::Value::setStr (Run* r, const hawk_uch_t* str, hawk_oow_t len, bool numeric)
{ {
hawk_val_t* tmp; hawk_val_t* tmp;
hawk_oocs_t oocs; tmp = numeric? hawk_rtx_makenstrvalwithuchars(r->rtx, str, len):
oocs.ptr = (hawk_ooch_t*)str; hawk_rtx_makestrvalwithuchars(r->rtx, str, len);
oocs.len = len;
tmp = numeric? hawk_rtx_makenstrvalwithoocs(r->rtx, &oocs):
hawk_rtx_makestrvalwithoocs(r->rtx, &oocs);
if (tmp == HAWK_NULL) if (tmp == HAWK_NULL)
{ {
r->awk->retrieveError (r); r->awk->retrieveError (r);
@ -758,17 +756,17 @@ int Hawk::Value::setStr (Run* r, const hawk_ooch_t* str, hawk_oow_t len, bool nu
return n; return n;
} }
int Hawk::Value::setStr (const hawk_ooch_t* str, bool numeric) int Hawk::Value::setStr (const hawk_uch_t* str, bool numeric)
{ {
if (this->run == HAWK_NULL) return -1; if (this->run == HAWK_NULL) return -1;
return this->setStr(this->run, str, numeric); return this->setStr(this->run, str, numeric);
} }
int Hawk::Value::setStr (Run* r, const hawk_ooch_t* str, bool numeric) int Hawk::Value::setStr (Run* r, const hawk_uch_t* str, bool numeric)
{ {
hawk_val_t* tmp; hawk_val_t* tmp;
tmp = numeric? hawk_rtx_makenstrvalwithoocstr(r->rtx, str): tmp = numeric? hawk_rtx_makenstrvalwithucstr(r->rtx, str):
hawk_rtx_makestrvalwithoocstr(r->rtx, str); hawk_rtx_makestrvalwithucstr(r->rtx, str);
if (tmp == HAWK_NULL) if (tmp == HAWK_NULL)
{ {
r->awk->retrieveError (r); r->awk->retrieveError (r);
@ -780,7 +778,59 @@ int Hawk::Value::setStr (Run* r, const hawk_ooch_t* str, bool numeric)
return n; return n;
} }
//////////////////////////////////////////////////////////////////
int Hawk::Value::setStr (const hawk_bch_t* str, hawk_oow_t len, bool numeric)
{
if (this->run == HAWK_NULL)
{
/* no runtime context assoicated. unfortunately, i can't
* set an error number for the same reason */
return -1;
}
return this->setStr(this->run, str, len, numeric);
}
int Hawk::Value::setStr (Run* r, const hawk_bch_t* str, hawk_oow_t len, bool numeric)
{
hawk_val_t* tmp;
tmp = numeric? hawk_rtx_makenstrvalwithbchars(r->rtx, str, len):
hawk_rtx_makestrvalwithbchars(r->rtx, str, len);
if (tmp == HAWK_NULL)
{
r->awk->retrieveError (r);
return -1;
}
int n = this->setVal(r, tmp);
HAWK_ASSERT (n == 0);
return n;
}
int Hawk::Value::setStr (const hawk_bch_t* str, bool numeric)
{
if (this->run == HAWK_NULL) return -1;
return this->setStr(this->run, str, numeric);
}
int Hawk::Value::setStr (Run* r, const hawk_bch_t* str, bool numeric)
{
hawk_val_t* tmp;
tmp = numeric? hawk_rtx_makenstrvalwithbcstr(r->rtx, str):
hawk_rtx_makestrvalwithbcstr(r->rtx, str);
if (tmp == HAWK_NULL)
{
r->awk->retrieveError (r);
return -1;
}
int n = this->setVal(r, tmp);
HAWK_ASSERT (n == 0);
return n;
}
//////////////////////////////////////////////////////////////////
int Hawk::Value::setMbs (const hawk_bch_t* str, hawk_oow_t len) int Hawk::Value::setMbs (const hawk_bch_t* str, hawk_oow_t len)
{ {
if (this->run == HAWK_NULL) if (this->run == HAWK_NULL)
@ -1883,7 +1933,7 @@ int Hawk::dispatch_function (Run* run, const fnc_info_t* fi)
return 0; return 0;
} }
int Hawk::xstrs_t::add (hawk_t* awk, const hawk_ooch_t* arg, hawk_oow_t len) int Hawk::xstrs_t::add (hawk_t* hawk, const hawk_uch_t* arg, hawk_oow_t len)
{ {
if (this->len >= this->capa) if (this->len >= this->capa)
{ {
@ -1891,15 +1941,50 @@ int Hawk::xstrs_t::add (hawk_t* awk, const hawk_ooch_t* arg, hawk_oow_t len)
hawk_oow_t capa = this->capa; hawk_oow_t capa = this->capa;
capa += 64; capa += 64;
ptr = (hawk_oocs_t*)hawk_reallocmem(awk, this->ptr, HAWK_SIZEOF(hawk_oocs_t)*(capa+1)); ptr = (hawk_oocs_t*)hawk_reallocmem(hawk, this->ptr, HAWK_SIZEOF(hawk_oocs_t)*(capa + 1));
if (ptr == HAWK_NULL) return -1; if (ptr == HAWK_NULL) return -1;
this->ptr = ptr; this->ptr = ptr;
this->capa = capa; this->capa = capa;
} }
#if defined(HAWK_OOCH_IS_UCH)
this->ptr[this->len].len = len; this->ptr[this->len].len = len;
this->ptr[this->len].ptr = hawk_dupoochars(awk, arg, len); this->ptr[this->len].ptr = hawk_dupuchars(hawk, arg, len);
#else
this->ptr[this->len].ptr = hawk_duputobchars(hawk, arg, len, &this->ptr[this->len].len);
#endif
if (this->ptr[this->len].ptr == HAWK_NULL) return -1;
this->len++;
this->ptr[this->len].len = 0;
this->ptr[this->len].ptr = HAWK_NULL;
return 0;
}
int Hawk::xstrs_t::add (hawk_t* hawk, const hawk_bch_t* arg, hawk_oow_t len)
{
if (this->len >= this->capa)
{
hawk_oocs_t* ptr;
hawk_oow_t capa = this->capa;
capa += 64;
ptr = (hawk_oocs_t*)hawk_reallocmem(hawk, this->ptr, HAWK_SIZEOF(hawk_oocs_t)*(capa + 1));
if (ptr == HAWK_NULL) return -1;
this->ptr = ptr;
this->capa = capa;
}
#if defined(HAWK_OOCH_IS_UCH)
this->ptr[this->len].ptr = hawk_dupbtouchars(hawk, arg, len, &this->ptr[this->len].len, 0);
#else
this->ptr[this->len].len = len;
this->ptr[this->len].ptr = hawk_dupbchars(hawk, arg, len);
#endif
if (this->ptr[this->len].ptr == HAWK_NULL) return -1; if (this->ptr[this->len].ptr == HAWK_NULL) return -1;
this->len++; this->len++;
@ -1922,19 +2007,33 @@ void Hawk::xstrs_t::clear (hawk_t* awk)
} }
} }
int Hawk::addArgument (const hawk_ooch_t* arg, hawk_oow_t len) int Hawk::addArgument (const hawk_uch_t* arg, hawk_oow_t len)
{ {
HAWK_ASSERT (awk != HAWK_NULL); HAWK_ASSERT (awk != HAWK_NULL);
int n = runarg.add(awk, arg, len); int n = this->runarg.add(awk, arg, len);
if (n <= -1) this->setError (HAWK_ENOMEM); if (n <= -1) this->setError (HAWK_ENOMEM);
return n; return n;
} }
int Hawk::addArgument (const hawk_ooch_t* arg) int Hawk::addArgument (const hawk_uch_t* arg)
{ {
return addArgument(arg, hawk_count_oocstr(arg)); return addArgument(arg, hawk_count_ucstr(arg));
} }
int Hawk::addArgument (const hawk_bch_t* arg, hawk_oow_t len)
{
HAWK_ASSERT (awk != HAWK_NULL);
int n = this->runarg.add(awk, arg, len);
if (n <= -1) this->setError (HAWK_ENOMEM);
return n;
}
int Hawk::addArgument (const hawk_bch_t* arg)
{
return this->addArgument(arg, hawk_count_bcstr(arg));
}
void Hawk::clearArguments () void Hawk::clearArguments ()
{ {
runarg.clear (awk); runarg.clear (awk);

View File

@ -1068,10 +1068,14 @@ public:
int setFlt (flt_t v); int setFlt (flt_t v);
int setFlt (Run* r, flt_t v); int setFlt (Run* r, flt_t v);
int setStr (const hawk_ooch_t* str, hawk_oow_t len, bool numeric = false); int setStr (const hawk_uch_t* str, hawk_oow_t len, bool numeric = false);
int setStr (Run* r, const hawk_ooch_t* str, hawk_oow_t len, bool numeric = false); int setStr (Run* r, const hawk_uch_t* str, hawk_oow_t len, bool numeric = false);
int setStr (const hawk_ooch_t* str, bool numeric = false); int setStr (const hawk_uch_t* str, bool numeric = false);
int setStr (Run* r, const hawk_ooch_t* str, bool numeric = false); int setStr (Run* r, const hawk_uch_t* str, bool numeric = false);
int setStr (const hawk_bch_t* str, hawk_oow_t len, bool numeric = false);
int setStr (Run* r, const hawk_bch_t* str, hawk_oow_t len, bool numeric = false);
int setStr (const hawk_bch_t* str, bool numeric = false);
int setStr (Run* r, const hawk_bch_t* str, bool numeric = false);
int setMbs (const hawk_bch_t* str, hawk_oow_t len); int setMbs (const hawk_bch_t* str, hawk_oow_t len);
int setMbs (Run* r, const hawk_bch_t* str, hawk_oow_t len); int setMbs (Run* r, const hawk_bch_t* str, hawk_oow_t len);
@ -1433,7 +1437,12 @@ public:
/// \return 0 on success, -1 on failure /// \return 0 on success, -1 on failure
/// ///
int addArgument ( int addArgument (
const hawk_ooch_t* arg, ///< string pointer const hawk_uch_t* arg, ///< string pointer
hawk_oow_t len ///< string length
);
int addArgument (
const hawk_bch_t* arg, ///< string pointer
hawk_oow_t len ///< string length hawk_oow_t len ///< string length
); );
@ -1444,7 +1453,11 @@ public:
/// \return 0 on success, -1 on failure /// \return 0 on success, -1 on failure
/// ///
int addArgument ( int addArgument (
const hawk_ooch_t* arg ///< string pointer const hawk_uch_t* arg ///< string pointer
);
int addArgument (
const hawk_bch_t* arg ///< string pointer
); );
/// ///
@ -1746,7 +1759,9 @@ protected:
{ {
xstrs_t (): ptr (HAWK_NULL), len (0), capa (0) {} xstrs_t (): ptr (HAWK_NULL), len (0), capa (0) {}
int add (hawk_t* awk, const hawk_ooch_t* arg, hawk_oow_t len); int add (hawk_t* awk, const hawk_uch_t* arg, hawk_oow_t len);
int add (hawk_t* awk, const hawk_bch_t* arg, hawk_oow_t len);
void clear (hawk_t* awk); void clear (hawk_t* awk);
hawk_oocs_t* ptr; hawk_oocs_t* ptr;

View File

@ -798,19 +798,33 @@ const hawk_cmgr_t* HawkStd::getConsoleCmgr () const
return this->console_cmgr; return this->console_cmgr;
} }
int HawkStd::addConsoleOutput (const hawk_ooch_t* arg, hawk_oow_t len) int HawkStd::addConsoleOutput (const hawk_uch_t* arg, hawk_oow_t len)
{ {
HAWK_ASSERT (awk != HAWK_NULL); HAWK_ASSERT (awk != HAWK_NULL);
int n = this->ofile.add (awk, arg, len); int n = this->ofile.add(awk, arg, len);
if (n <= -1) setError (HAWK_ENOMEM); if (n <= -1) this->setError (HAWK_ENOMEM);
return n; return n;
} }
int HawkStd::addConsoleOutput (const hawk_ooch_t* arg) int HawkStd::addConsoleOutput (const hawk_uch_t* arg)
{ {
return addConsoleOutput (arg, hawk_count_oocstr(arg)); return this->addConsoleOutput(arg, hawk_count_ucstr(arg));
} }
int HawkStd::addConsoleOutput (const hawk_bch_t* arg, hawk_oow_t len)
{
HAWK_ASSERT (awk != HAWK_NULL);
int n = this->ofile.add(awk, arg, len);
if (n <= -1) this->setError (HAWK_ENOMEM);
return n;
}
int HawkStd::addConsoleOutput (const hawk_bch_t* arg)
{
return this->addConsoleOutput(arg, hawk_count_bcstr(arg));
}
void HawkStd::clearConsoleOutputs () void HawkStd::clearConsoleOutputs ()
{ {
this->ofile.clear (awk); this->ofile.clear (awk);
@ -1283,12 +1297,21 @@ int HawkStd::SourceFile::close (Data& io)
hawk_ooi_t HawkStd::SourceFile::read (Data& io, hawk_ooch_t* buf, hawk_oow_t len) hawk_ooi_t HawkStd::SourceFile::read (Data& io, hawk_ooch_t* buf, hawk_oow_t len)
{ {
return hawk_sio_getoochars ((hawk_sio_t*)io.getHandle(), buf, len); return hawk_sio_getoochars((hawk_sio_t*)io.getHandle(), buf, len);
} }
hawk_ooi_t HawkStd::SourceFile::write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len) hawk_ooi_t HawkStd::SourceFile::write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len)
{ {
return hawk_sio_putoochars ((hawk_sio_t*)io.getHandle(), buf, len); return hawk_sio_putoochars((hawk_sio_t*)io.getHandle(), buf, len);
}
HawkStd::SourceString::~SourceString ()
{
if (this->_hawk)
{
HAWK_ASSERT (this->str != HAWK_NULL);
hawk_freemem (this->_hawk, this->str);
}
} }
int HawkStd::SourceString::open (Data& io) int HawkStd::SourceString::open (Data& io)
@ -1298,9 +1321,40 @@ int HawkStd::SourceString::open (Data& io)
if (io.getName() == HAWK_NULL) if (io.getName() == HAWK_NULL)
{ {
// open the main source file. // open the main source file.
// SourceString does not support writing. if (io.getMode() == WRITE)
if (io.getMode() == WRITE) return -1; {
ptr = str; // SourceString does not support writing.
((Hawk*)io)->setError (HAWK_ENOIMPL);
return -1;
}
if (!this->str)
{
this->_hawk = (hawk_t*)io;
if (this->_type == STR_UCH)
{
#if defined(HAWK_OOCH_IS_UCH)
this->str = hawk_dupucstr(this->_hawk, (hawk_uch_t*)this->_str, HAWK_NULL);
#else
this->str = hawk_duputobcstr(this->_hawk, (hawk_uch_t*)this->_str, HAWK_NULL);
#endif
}
else
{
#if defined(HAWK_OOCH_IS_UCH)
this->str = hawk_dupbtoucstr(this->_hawk, (hawk_bch_t*)this->_str, HAWK_NULL, 0);
#else
this->str = hawk_dupbcstr(this->_hawk, (hawk_bch_t*)this->_str, HAWK_NULL);
#endif
}
if (!this->str)
{
// TODO: check if retrieveError is needed
return -1;
}
}
this->ptr = this->str;
} }
else else
{ {
@ -1322,7 +1376,7 @@ int HawkStd::SourceString::open (Data& io)
if (outer) if (outer)
{ {
const hawk_ooch_t* base; const hawk_ooch_t* base;
base = hawk_get_base_name_oocstr(outer); base = hawk_get_base_name_oocstr(outer);
if (base != outer && ioname[0] != HAWK_T('/')) if (base != outer && ioname[0] != HAWK_T('/'))
{ {
@ -1332,20 +1386,17 @@ int HawkStd::SourceString::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(),
HAWK_SIZEOF(hawk_ooch_t) * (totlen + 1)
);
if (dbuf == HAWK_NULL) if (dbuf == HAWK_NULL)
{ {
((Hawk*)io)->setError (HAWK_ENOMEM); // TODO: check if retrieveError is needed
return -1; return -1;
} }
file = dbuf; file = dbuf;
} }
else file = fbuf; else file = fbuf;
tmplen = hawk_copy_oochars_to_oocstr_unlimited((hawk_ooch_t*)file, outer, dirlen); tmplen = hawk_copy_oochars_to_oocstr_unlimited((hawk_ooch_t*)file, outer, dirlen);
hawk_copy_oocstr_unlimited ((hawk_ooch_t*)file + tmplen, ioname); hawk_copy_oocstr_unlimited ((hawk_ooch_t*)file + tmplen, ioname);
} }
@ -1358,7 +1409,7 @@ int HawkStd::SourceString::open (Data& io)
(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 (dbuf) hawk_freemem ((hawk_t*)io, dbuf);
if (sio == HAWK_NULL) return -1; if (sio == HAWK_NULL) return -1;
io.setHandle (sio); io.setHandle (sio);

View File

@ -89,7 +89,9 @@ public:
class HAWK_EXPORT SourceString: public Source class HAWK_EXPORT SourceString: public Source
{ {
public: public:
SourceString (const hawk_ooch_t* str): str (str) {} SourceString (const hawk_uch_t* str): _type(STR_UCH), _str(str), _hawk(HAWK_NULL), str(HAWK_NULL), ptr(HAWK_NULL) {}
SourceString (const hawk_bch_t* str): _type(STR_BCH), _str(str), _hawk(HAWK_NULL), str(HAWK_NULL), ptr(HAWK_NULL) {}
~SourceString ();
int open (Data& io); int open (Data& io);
int close (Data& io); int close (Data& io);
@ -97,7 +99,15 @@ public:
hawk_ooi_t write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len); hawk_ooi_t write (Data& io, const hawk_ooch_t* buf, hawk_oow_t len);
protected: protected:
const hawk_ooch_t* str; enum
{
STR_UCH,
STR_BCH
} _type;
const void* _str;
hawk_t* _hawk;
hawk_ooch_t* str;
const hawk_ooch_t* ptr; const hawk_ooch_t* ptr;
}; };
@ -124,8 +134,10 @@ public:
/// The addConsoleOutput() function adds a file to form an /// The addConsoleOutput() function adds a file to form an
/// output console stream. /// output console stream.
int addConsoleOutput (const hawk_ooch_t* arg, hawk_oow_t len); int addConsoleOutput (const hawk_uch_t* arg, hawk_oow_t len);
int addConsoleOutput (const hawk_ooch_t* arg); int addConsoleOutput (const hawk_uch_t* arg);
int addConsoleOutput (const hawk_bch_t* arg, hawk_oow_t len);
int addConsoleOutput (const hawk_bch_t* arg);
void clearConsoleOutputs (); void clearConsoleOutputs ();

33
hawk/m4/libtool.m4 vendored
View File

@ -728,6 +728,7 @@ _LT_CONFIG_SAVE_COMMANDS([
cat <<_LT_EOF >> "$cfgfile" cat <<_LT_EOF >> "$cfgfile"
#! $SHELL #! $SHELL
# Generated automatically by $as_me ($PACKAGE) $VERSION # Generated automatically by $as_me ($PACKAGE) $VERSION
# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
# NOTE: Changes made to this file will be lost: look at ltmain.sh. # NOTE: Changes made to this file will be lost: look at ltmain.sh.
# Provide generalized library-building support services. # Provide generalized library-building support services.
@ -2866,6 +2867,9 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
# before this can be enabled. # before this can be enabled.
hardcode_into_libs=yes hardcode_into_libs=yes
# Add ABI-specific directories to the system library path.
sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
# Ideally, we could use ldconfig to report *all* directores which are # Ideally, we could use ldconfig to report *all* directores which are
# searched for libraries, however this is still not possible. Aside from not # searched for libraries, however this is still not possible. Aside from not
# being certain /sbin/ldconfig is available, command # being certain /sbin/ldconfig is available, command
@ -2874,7 +2878,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
# appending ld.so.conf contents (and includes) to the search path. # appending ld.so.conf contents (and includes) to the search path.
if test -f /etc/ld.so.conf; then if test -f /etc/ld.so.conf; then
lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
fi fi
# We used to test for /lib/ld.so.1 and disable shared libraries on # We used to test for /lib/ld.so.1 and disable shared libraries on
@ -2886,18 +2890,6 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
dynamic_linker='GNU/Linux ld.so' dynamic_linker='GNU/Linux ld.so'
;; ;;
netbsdelf*-gnu)
version_type=linux
need_lib_prefix=no
need_version=no
library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
soname_spec='${libname}${release}${shared_ext}$major'
shlibpath_var=LD_LIBRARY_PATH
shlibpath_overrides_runpath=no
hardcode_into_libs=yes
dynamic_linker='NetBSD ld.elf_so'
;;
netbsd*) netbsd*)
version_type=sunos version_type=sunos
need_lib_prefix=no need_lib_prefix=no
@ -3557,7 +3549,7 @@ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)
lt_cv_deplibs_check_method=pass_all lt_cv_deplibs_check_method=pass_all
;; ;;
netbsd* | netbsdelf*-gnu) netbsd*)
if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
else else
@ -4435,7 +4427,7 @@ m4_if([$1], [CXX], [
;; ;;
esac esac
;; ;;
netbsd* | netbsdelf*-gnu) netbsd*)
;; ;;
*qnx* | *nto*) *qnx* | *nto*)
# QNX uses GNU C++, but need to define -shared option too, otherwise # QNX uses GNU C++, but need to define -shared option too, otherwise
@ -4947,9 +4939,6 @@ m4_if([$1], [CXX], [
;; ;;
esac esac
;; ;;
linux* | k*bsd*-gnu | gnu*)
_LT_TAGVAR(link_all_deplibs, $1)=no
;;
*) *)
_LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
;; ;;
@ -5012,9 +5001,6 @@ dnl Note also adjust exclude_expsyms for C++ above.
openbsd* | bitrig*) openbsd* | bitrig*)
with_gnu_ld=no with_gnu_ld=no
;; ;;
linux* | k*bsd*-gnu | gnu*)
_LT_TAGVAR(link_all_deplibs, $1)=no
;;
esac esac
_LT_TAGVAR(ld_shlibs, $1)=yes _LT_TAGVAR(ld_shlibs, $1)=yes
@ -5269,7 +5255,7 @@ _LT_EOF
fi fi
;; ;;
netbsd* | netbsdelf*-gnu) netbsd*)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
wlarc= wlarc=
@ -5790,7 +5776,6 @@ _LT_EOF
if test yes = "$lt_cv_irix_exported_symbol"; then if test yes = "$lt_cv_irix_exported_symbol"; then
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'
fi fi
_LT_TAGVAR(link_all_deplibs, $1)=no
else else
_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'
_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'
@ -5812,7 +5797,7 @@ _LT_EOF
esac esac
;; ;;
netbsd* | netbsdelf*-gnu) netbsd*)
if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
else else

31
hawk/samples/Makefile.am Normal file
View File

@ -0,0 +1,31 @@
AUTOMAKE_OPTIONS = nostdinc
CPPFLAGS_ALL_COMMON = \
-I$(abs_builddir) \
-I$(abs_builddir)/../lib \
-I$(abs_srcdir) \
-I$(abs_srcdir)/../lib \
-I$(includedir)
LDFLAGS_ALL_COMMON = -L$(abs_builddir) -L$(abs_builddir)/../lib -L$(libdir)
CPPFLAGS_BIN_COMMON = $(CPPFLAGS_ALL_COMMON)
LDFLAGS_BIN_COMMON = $(LDFLAGS_ALL_COMMON) -version-info 1:0:0 -no-undefined
LIBADD_BIN_COMMON = $(LIBM)
bin_PROGRAMS =
if ENABLE_CXX
bin_PROGRAMS += hawk51
hawk51_SOURCES = hawk51.cpp
hawk51_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
hawk51_LDFLAGS = $(LDFLAGS_ALL_COMMON)
hawk51_LDADD = $(LIBADD_BIN_COMMON) $(SOCKET_LIBS) -lhawkxx
hawk51_DEPENDENCIES = ../lib/libhawkxx.la
endif

721
hawk/samples/Makefile.in Normal file
View File

@ -0,0 +1,721 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
VPATH = @srcdir@
am__is_gnu_make = { \
if test -z '$(MAKELEVEL)'; then \
false; \
elif test -n '$(MAKE_HOST)'; then \
true; \
elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
true; \
else \
false; \
fi; \
}
am__make_running_with_option = \
case $${target_option-} in \
?) ;; \
*) echo "am__make_running_with_option: internal error: invalid" \
"target option '$${target_option-}' specified" >&2; \
exit 1;; \
esac; \
has_opt=no; \
sane_makeflags=$$MAKEFLAGS; \
if $(am__is_gnu_make); then \
sane_makeflags=$$MFLAGS; \
else \
case $$MAKEFLAGS in \
*\\[\ \ ]*) \
bs=\\; \
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
esac; \
fi; \
skip_next=no; \
strip_trailopt () \
{ \
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
}; \
for flg in $$sane_makeflags; do \
test $$skip_next = yes && { skip_next=no; continue; }; \
case $$flg in \
*=*|--*) continue;; \
-*I) strip_trailopt 'I'; skip_next=yes;; \
-*I?*) strip_trailopt 'I';; \
-*O) strip_trailopt 'O'; skip_next=yes;; \
-*O?*) strip_trailopt 'O';; \
-*l) strip_trailopt 'l'; skip_next=yes;; \
-*l?*) strip_trailopt 'l';; \
-[dEDm]) skip_next=yes;; \
-[JT]) skip_next=yes;; \
esac; \
case $$flg in \
*$$target_option*) has_opt=yes; break;; \
esac; \
done; \
test $$has_opt = yes
am__make_dryrun = (target_option=n; $(am__make_running_with_option))
am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
pkgdatadir = $(datadir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkglibexecdir = $(libexecdir)/@PACKAGE@
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
bin_PROGRAMS = $(am__EXEEXT_1)
@ENABLE_CXX_TRUE@am__append_1 = hawk51
subdir = samples
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_sign.m4 \
$(top_srcdir)/m4/ax_cxx_namespace.m4 \
$(top_srcdir)/m4/ax_lib_mysql.m4 $(top_srcdir)/m4/ax_numval.m4 \
$(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/m4/hawk_try_cflags.m4 \
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = $(top_builddir)/lib/hawk-cfg.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@ENABLE_CXX_TRUE@am__EXEEXT_1 = hawk51$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am__hawk51_SOURCES_DIST = hawk51.cpp
@ENABLE_CXX_TRUE@am_hawk51_OBJECTS = hawk51-hawk51.$(OBJEXT)
hawk51_OBJECTS = $(am_hawk51_OBJECTS)
am__DEPENDENCIES_1 =
am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
am__v_lt_0 = --silent
am__v_lt_1 =
hawk51_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(hawk51_LDFLAGS) $(LDFLAGS) -o $@
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
am__v_P_0 = false
am__v_P_1 = :
AM_V_GEN = $(am__v_GEN_@AM_V@)
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
am__v_GEN_0 = @echo " GEN " $@;
am__v_GEN_1 =
AM_V_at = $(am__v_at_@AM_V@)
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES =
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/hawk51-hawk51.Po
am__mv = mv -f
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CXXFLAGS) $(CXXFLAGS)
AM_V_CXX = $(am__v_CXX_@AM_V@)
am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
am__v_CXX_0 = @echo " CXX " $@;
am__v_CXX_1 =
CXXLD = $(CXX)
CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
$(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
am__v_CXXLD_0 = @echo " CXXLD " $@;
am__v_CXXLD_1 =
SOURCES = $(hawk51_SOURCES)
DIST_SOURCES = $(am__hawk51_SOURCES_DIST)
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
# Read a list of newline-separated strings from the standard input,
# and print each of them once, without duplicates. Input order is
# *not* preserved.
am__uniquify_input = $(AWK) '\
BEGIN { nonempty = 0; } \
{ items[$$0] = 1; nonempty = 1; } \
END { if (nonempty) { for (i in items) print i; }; } \
'
# Make sure the list of sources is unique. This is necessary because,
# e.g., the same source file might be shared among _SOURCES variables
# for different programs/libraries.
am__define_uniq_tagged_files = \
list='$(am__tagged_files)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | $(am__uniquify_input)`
ETAGS = etags
CTAGS = ctags
am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/ac/depcomp
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMTAR = @AMTAR@
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
BUILD_MODE = @BUILD_MODE@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
DLLTOOL = @DLLTOOL@
DL_LIBS = @DL_LIBS@
DSYMUTIL = @DSYMUTIL@
DUMPBIN = @DUMPBIN@
DYNCALL_LIBS = @DYNCALL_LIBS@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
FFI_LIBS = @FFI_LIBS@
FGREP = @FGREP@
GREP = @GREP@
HAVE_CXX = @HAVE_CXX@
HAWK_PROJECT_AUTHOR = @HAWK_PROJECT_AUTHOR@
HAWK_PROJECT_URL = @HAWK_PROJECT_URL@
HAWK_SIZEOF_CHAR = @HAWK_SIZEOF_CHAR@
HAWK_SIZEOF_DOUBLE = @HAWK_SIZEOF_DOUBLE@
HAWK_SIZEOF_FLOAT = @HAWK_SIZEOF_FLOAT@
HAWK_SIZEOF_INT = @HAWK_SIZEOF_INT@
HAWK_SIZEOF_LONG = @HAWK_SIZEOF_LONG@
HAWK_SIZEOF_LONG_DOUBLE = @HAWK_SIZEOF_LONG_DOUBLE@
HAWK_SIZEOF_LONG_LONG = @HAWK_SIZEOF_LONG_LONG@
HAWK_SIZEOF_OFF64_T = @HAWK_SIZEOF_OFF64_T@
HAWK_SIZEOF_OFF_T = @HAWK_SIZEOF_OFF_T@
HAWK_SIZEOF_SHORT = @HAWK_SIZEOF_SHORT@
HAWK_SIZEOF_VOID_P = @HAWK_SIZEOF_VOID_P@
HAWK_SIZEOF_WCHAR_T = @HAWK_SIZEOF_WCHAR_T@
INSTALL = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LD = @LD@
LDFLAGS = @LDFLAGS@
LIBM = @LIBM@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LIBTOOL = @LIBTOOL@
LIBTOOL_DEPS = @LIBTOOL_DEPS@
LIPO = @LIPO@
LN_S = @LN_S@
LTDL_LIBS = @LTDL_LIBS@
LTLIBOBJS = @LTLIBOBJS@
LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
MAKEINFO = @MAKEINFO@
MANIFEST_TOOL = @MANIFEST_TOOL@
MKDIR_P = @MKDIR_P@
MYSQL_CFLAGS = @MYSQL_CFLAGS@
MYSQL_CONFIG = @MYSQL_CONFIG@
MYSQL_LDFLAGS = @MYSQL_LDFLAGS@
MYSQL_VERSION = @MYSQL_VERSION@
NM = @NM@
NMEDIT = @NMEDIT@
OBJDUMP = @OBJDUMP@
OBJEXT = @OBJEXT@
OTOOL = @OTOOL@
OTOOL64 = @OTOOL64@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_URL = @PACKAGE_URL@
PACKAGE_VERSION = @PACKAGE_VERSION@
PACKAGE_VERSION_MAJOR = @PACKAGE_VERSION_MAJOR@
PACKAGE_VERSION_MINOR = @PACKAGE_VERSION_MINOR@
PACKAGE_VERSION_PATCH = @PACKAGE_VERSION_PATCH@
PATH_SEPARATOR = @PATH_SEPARATOR@
PTHREAD_CC = @PTHREAD_CC@
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
PTHREAD_LIBS = @PTHREAD_LIBS@
QUADMATH_LIBS = @QUADMATH_LIBS@
RANLIB = @RANLIB@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
SOCKET_LIBS = @SOCKET_LIBS@
STRIP = @STRIP@
UCI_LIBS = @UCI_LIBS@
UNICOWS_LIBS = @UNICOWS_LIBS@
UNWIND_LIBS = @UNWIND_LIBS@
VERSION = @VERSION@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
abs_top_srcdir = @abs_top_srcdir@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
ax_pthread_config = @ax_pthread_config@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
datadir = @datadir@
datarootdir = @datarootdir@
docdir = @docdir@
dvidir = @dvidir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localedir = @localedir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = nostdinc
CPPFLAGS_ALL_COMMON = \
-I$(abs_builddir) \
-I$(abs_builddir)/../lib \
-I$(abs_srcdir) \
-I$(abs_srcdir)/../lib \
-I$(includedir)
LDFLAGS_ALL_COMMON = -L$(abs_builddir) -L$(abs_builddir)/../lib -L$(libdir)
CPPFLAGS_BIN_COMMON = $(CPPFLAGS_ALL_COMMON)
LDFLAGS_BIN_COMMON = $(LDFLAGS_ALL_COMMON) -version-info 1:0:0 -no-undefined
LIBADD_BIN_COMMON = $(LIBM)
@ENABLE_CXX_TRUE@hawk51_SOURCES = hawk51.cpp
@ENABLE_CXX_TRUE@hawk51_CPPFLAGS = $(CPPFLAGS_ALL_COMMON)
@ENABLE_CXX_TRUE@hawk51_LDFLAGS = $(LDFLAGS_ALL_COMMON)
@ENABLE_CXX_TRUE@hawk51_LDADD = $(LIBADD_BIN_COMMON) $(SOCKET_LIBS) -lhawkxx
@ENABLE_CXX_TRUE@hawk51_DEPENDENCIES = ../lib/libhawkxx.la
all: all-am
.SUFFIXES:
.SUFFIXES: .cpp .lo .o .obj
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
&& { if test -f $@; then exit 0; else break; fi; }; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign samples/Makefile'; \
$(am__cd) $(top_srcdir) && \
$(AUTOMAKE) --foreign samples/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(am__aclocal_m4_deps):
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
$(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
fi; \
for p in $$list; do echo "$$p $$p"; done | \
sed 's/$(EXEEXT)$$//' | \
while read p p1; do if test -f $$p \
|| test -f $$p1 \
; then echo "$$p"; echo "$$p"; else :; fi; \
done | \
sed -e 'p;s,.*/,,;n;h' \
-e 's|.*|.|' \
-e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
sed 'N;N;N;s,\n, ,g' | \
$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
{ d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
if ($$2 == $$4) files[d] = files[d] " " $$1; \
else { print "f", $$3 "/" $$4, $$1; } } \
END { for (d in files) print "f", d, files[d] }' | \
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
} \
; done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-e 's/$$/$(EXEEXT)/' \
`; \
test -n "$$list" || exit 0; \
echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
cd "$(DESTDIR)$(bindir)" && rm -f $$files
clean-binPROGRAMS:
@list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
echo " rm -f" $$list; \
rm -f $$list || exit $$?; \
test -n "$(EXEEXT)" || exit 0; \
list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
echo " rm -f" $$list; \
rm -f $$list
hawk51$(EXEEXT): $(hawk51_OBJECTS) $(hawk51_DEPENDENCIES) $(EXTRA_hawk51_DEPENDENCIES)
@rm -f hawk51$(EXEEXT)
$(AM_V_CXXLD)$(hawk51_LINK) $(hawk51_OBJECTS) $(hawk51_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hawk51-hawk51.Po@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@echo '# dummy' >$@-t && $(am__mv) $@-t $@
am--depfiles: $(am__depfiles_remade)
.cpp.o:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
.cpp.obj:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
.cpp.lo:
@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
hawk51-hawk51.o: hawk51.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk51_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT hawk51-hawk51.o -MD -MP -MF $(DEPDIR)/hawk51-hawk51.Tpo -c -o hawk51-hawk51.o `test -f 'hawk51.cpp' || echo '$(srcdir)/'`hawk51.cpp
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hawk51-hawk51.Tpo $(DEPDIR)/hawk51-hawk51.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='hawk51.cpp' object='hawk51-hawk51.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk51_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o hawk51-hawk51.o `test -f 'hawk51.cpp' || echo '$(srcdir)/'`hawk51.cpp
hawk51-hawk51.obj: hawk51.cpp
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk51_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT hawk51-hawk51.obj -MD -MP -MF $(DEPDIR)/hawk51-hawk51.Tpo -c -o hawk51-hawk51.obj `if test -f 'hawk51.cpp'; then $(CYGPATH_W) 'hawk51.cpp'; else $(CYGPATH_W) '$(srcdir)/hawk51.cpp'; fi`
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hawk51-hawk51.Tpo $(DEPDIR)/hawk51-hawk51.Po
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='hawk51.cpp' object='hawk51-hawk51.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk51_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o hawk51-hawk51.obj `if test -f 'hawk51.cpp'; then $(CYGPATH_W) 'hawk51.cpp'; else $(CYGPATH_W) '$(srcdir)/hawk51.cpp'; fi`
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
ID: $(am__tagged_files)
$(am__define_uniq_tagged_files); mkid -fID $$unique
tags: tags-am
TAGS: tags
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
set x; \
here=`pwd`; \
$(am__define_uniq_tagged_files); \
shift; \
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
if test $$# -gt 0; then \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
"$$@" $$unique; \
else \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$unique; \
fi; \
fi
ctags: ctags-am
CTAGS: ctags
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
$(am__define_uniq_tagged_files); \
test -z "$(CTAGS_ARGS)$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& $(am__cd) $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) "$$here"
cscopelist: cscopelist-am
cscopelist-am: $(am__tagged_files)
list='$(am__tagged_files)'; \
case "$(srcdir)" in \
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
*) sdir=$(subdir)/$(srcdir) ;; \
esac; \
for i in $$list; do \
if test -f "$$i"; then \
echo "$(subdir)/$$i"; \
else \
echo "$$sdir/$$i"; \
fi; \
done >> $(top_builddir)/cscope.files
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) distdir-am
distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
dist_files=`for file in $$list; do echo $$file; done | \
sed -e "s|^$$srcdirstrip/||;t" \
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
case $$dist_files in \
*/*) $(MKDIR_P) `echo "$$dist_files" | \
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
sort -u` ;; \
esac; \
for file in $$dist_files; do \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
if test -d "$(distdir)/$$file"; then \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
fi; \
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
else \
test -f "$(distdir)/$$file" \
|| cp -p $$d/$$file "$(distdir)/$$file" \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS)
installdirs:
for dir in "$(DESTDIR)$(bindir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
if test -z '$(STRIP)'; then \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
install; \
else \
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
fi
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f ./$(DEPDIR)/hawk51-hawk51.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
html-am:
info: info-am
info-am:
install-data-am:
install-dvi: install-dvi-am
install-dvi-am:
install-exec-am: install-binPROGRAMS
install-html: install-html-am
install-html-am:
install-info: install-info-am
install-info-am:
install-man:
install-pdf: install-pdf-am
install-pdf-am:
install-ps: install-ps-am
install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/hawk51-hawk51.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS
.MAKE: install-am install-strip
.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-binPROGRAMS clean-generic clean-libtool cscopelist-am \
ctags ctags-am distclean distclean-compile distclean-generic \
distclean-libtool distclean-tags distdir dvi dvi-am html \
html-am info info-am install install-am install-binPROGRAMS \
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 maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
tags tags-am uninstall uninstall-am uninstall-binPROGRAMS
.PRECIOUS: Makefile
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

497
hawk/samples/hawk51.cpp Normal file
View File

@ -0,0 +1,497 @@
/*
* $Id$
*
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <HawkStd.hpp>
#include <hawk-utl.h>
#include <hawk-fmt.h>
#include <hawk-cli.h>
#include <stdio.h>
#include <string.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <locale.h>
#include <cstring>
#if defined(_WIN32)
# include <windows.h>
#elif defined(__OS2__)
# define INCL_DOSPROCESS
# include <os2.h>
#else
# include <unistd.h>
# include <signal.h>
# include <errno.h>
#endif
/* these three definitions for doxygen cross-reference */
typedef HAWK::HawkStd HawkStd;
typedef HAWK::HawkStd::Run Run;
typedef HAWK::HawkStd::Value Value;
class MyHawk: public HawkStd
{
public:
MyHawk (HAWK::Mmgr* mmgr = HAWK_NULL): HawkStd(mmgr) { }
~MyHawk () { this->close (); }
int open ()
{
if (HawkStd::open () <= -1) return -1;
idLastSleep = this->addGlobal(HAWK_T("LAST_SLEEP"));
if (idLastSleep <= -1) goto oops;
/* this is for demonstration only.
* you can use sys::sleep() instead */
if (this->addFunction(HAWK_T("sleep"), 1, 1, HAWK_NULL, (FunctionHandler)&MyHawk::sleep) <= -1 ||
this->addFunction (HAWK_T("sumintarray"), 1, 1, HAWK_NULL, (FunctionHandler)&MyHawk::sumintarray) <= -1 ||
this->addFunction (HAWK_T("arrayindices"), 1, 1, HAWK_NULL, (FunctionHandler)&MyHawk::arrayindices) <= -1) goto oops;
return 0;
oops:
HawkStd::close ();
return -1;
}
int sleep (Run& run, Value& ret, Value* args, hawk_oow_t nargs, const hawk_ooch_t* name, hawk_oow_t len)
{
if (args[0].isIndexed())
{
run.setError (HAWK_EINVAL);
return -1;
}
hawk_int_t x = args[0].toInt();
/*Value arg;
if (run.getGlobal(idLastSleep, arg) == 0)
hawk_printf (HAWK_T("GOOD: [%d]\n"), (int)arg.toInt());
else { hawk_printf (HAWK_T("BAD:\n")); }
*/
if (run.setGlobal (idLastSleep, x) <= -1) return -1;
#if defined(_WIN32)
::Sleep ((DWORD)(x * 1000));
return ret.setInt (0);
#elif defined(__OS2__)
::DosSleep ((ULONG)(x * 1000));
return ret.setInt (0);
#else
return ret.setInt (::sleep (x));
#endif
}
int sumintarray (Run& run, Value& ret, Value* args, hawk_oow_t nargs, const hawk_ooch_t* name, hawk_oow_t len)
{
// BEGIN {
// for(i=0;i<=10;i++) x[i]=i;
// print sumintarray(x);
// }
hawk_int_t x = 0;
if (args[0].isIndexed())
{
Value val(run);
Value::Index idx;
Value::IndexIterator ii;
ii = args[0].getFirstIndex(&idx);
while (ii != ii.END)
{
if (args[0].getIndexed(idx, &val) <= -1) return -1;
x += val.toInt ();
ii = args[0].getNextIndex(&idx, ii);
}
}
else x += args[0].toInt();
return ret.setInt(x);
}
int arrayindices (Run& run, Value& ret, Value* args, hawk_oow_t nargs, const hawk_ooch_t* name, hawk_oow_t len)
{
// create another array composed of array indices
// BEGIN {
// for(i=0;i<=10;i++) x[i]=i;
// y=arrayindices(x);
// for (i in y) print y[i];
// }
if (!args[0].isIndexed()) return 0;
Value::Index idx;
Value::IndexIterator ii;
hawk_int_t i;
ii = args[0].getFirstIndex (&idx);
for (i = 0; ii != ii.END ; i++)
{
Value::IntIndex iidx (i);
if (ret.setIndexedStr (
iidx, idx.pointer(), idx.length()) <= -1) return -1;
ii = args[0].getNextIndex (&idx, ii);
}
return 0;
}
private:
int idLastSleep;
};
static MyHawk* app_hawk = HAWK_NULL;
static void print_error (const hawk_bch_t* fmt, ...)
{
va_list va;
fprintf (stderr, "ERROR: ");
va_start (va, fmt);
vfprintf (stderr, fmt, va);
va_end (va);
}
static void print_error (MyHawk& hawk)
{
hawk_loc_t loc = hawk.getErrorLocation();
if (loc.file)
{
print_error ("line %lu at %s - %s\n", (unsigned long int)loc.line, loc.file, hawk.getErrorMessage());
}
else
{
print_error ("line %lu - %s\n", (unsigned long int)loc.line, hawk.getErrorMessage());
}
}
#ifdef _WIN32
static BOOL WINAPI stop_run (DWORD ctrl_type)
{
if (ctrl_type == CTRL_C_EVENT ||
ctrl_type == CTRL_CLOSE_EVENT)
{
if (app_hawk) app_hawk->stop ();
return TRUE;
}
return FALSE;
}
#else
static int setsignal (int sig, void(*handler)(int), int restart)
{
struct sigaction sa_int;
sa_int.sa_handler = handler;
sigemptyset (&sa_int.sa_mask);
sa_int.sa_flags = 0;
if (restart)
{
#ifdef SA_RESTART
sa_int.sa_flags |= SA_RESTART;
#endif
}
else
{
#ifdef SA_INTERRUPT
sa_int.sa_flags |= SA_INTERRUPT;
#endif
}
return sigaction (sig, &sa_int, NULL);
}
static void stop_run (int sig)
{
int e = errno;
if (app_hawk) app_hawk->halt ();
errno = e;
}
#endif
static void set_signal (void)
{
#ifdef _WIN32
SetConsoleCtrlHandler (stop_run, TRUE);
#else
/*setsignal (SIGINT, stop_run, 1); TO BE MORE COMPATIBLE WITH WIN32*/
setsignal (SIGINT, stop_run, 0);
#endif
}
static void unset_signal (void)
{
#ifdef _WIN32
SetConsoleCtrlHandler (stop_run, FALSE);
#else
setsignal (SIGINT, SIG_DFL, 1);
#endif
}
static void print_usage (FILE* out, const hawk_bch_t* argv0)
{
fprintf (out, "USAGE: %s [options] -f sourcefile [ -- ] [datafile]*\n", argv0);
fprintf (out, " %s [options] [ -- ] sourcestring [datafile]*\n", argv0);
fprintf (out, "Where options are:\n");
fprintf (out, " -h print this message\n");
fprintf (out, " -f sourcefile set the source script file\n");
fprintf (out, " -d deparsedfile set the deparsing output file\n");
fprintf (out, " -o outputfile set the console output file\n");
fprintf (out, " -F string set a field separator(FS)\n");
}
struct cmdline_t
{
hawk_bch_t* ins;
hawk_bch_t* inf;
hawk_bch_t* outf;
hawk_bch_t* outc;
hawk_bch_t* fs;
};
static int handle_cmdline (MyHawk& awk, int argc, hawk_bch_t* argv[], cmdline_t* cmdline)
{
static hawk_bcli_t opt =
{
"hF:f:d:o:",
HAWK_NULL
};
hawk_bci_t c;
std::memset (cmdline, 0, HAWK_SIZEOF(*cmdline));
while ((c = hawk_get_bcli(argc, argv, &opt)) != HAWK_BCI_EOF)
{
switch (c)
{
case 'h':
print_usage (stdout, argv[0]);
return 0;
case 'F':
cmdline->fs = opt.arg;
break;
case 'f':
cmdline->inf = opt.arg;
break;
case 'd':
cmdline->outf = opt.arg;
break;
case 'o':
cmdline->outc = opt.arg;
break;
case '?':
print_error ("illegal option - '%c'\n", opt.opt);
return -1;
case ':':
print_error ("bad argument for '%c'\n", opt.opt);
return -1;
default:
print_usage (stderr, argv[0]);
return -1;
}
}
if (opt.ind < argc && !cmdline->inf) cmdline->ins = argv[opt.ind++];
while (opt.ind < argc)
{
if (awk.addArgument(argv[opt.ind++]) <= -1)
{
print_error (awk);
return -1;
}
}
if (!cmdline->ins && !cmdline->inf)
{
print_usage (stderr, argv[0]);
return -1;
}
return 1;
}
static int hawk_main (MyHawk& awk, int argc, hawk_bch_t* argv[])
{
MyHawk::Run* run;
cmdline_t cmdline;
int n;
awk.setTrait (awk.getTrait() | HAWK_FLEXMAP | HAWK_RWPIPE | HAWK_NEXTOFILE);
// ARGV[0]
if (awk.addArgument(HAWK_T("hawk25")) <= -1)
{
print_error (awk);
return -1;
}
if ((n = handle_cmdline(awk, argc, argv, &cmdline)) <= 0) return n;
MyHawk::Source* in, * out;
MyHawk::SourceString in_str(cmdline.ins);
MyHawk::SourceFile in_file(cmdline.inf);
MyHawk::SourceFile out_file(cmdline.outf);
in = (cmdline.ins)? (MyHawk::Source*)&in_str: (MyHawk::Source*)&in_file;
out = (cmdline.outf)? (MyHawk::Source*)&out_file: &MyHawk::Source::NONE;
run = awk.parse (*in, *out);
if (run == HAWK_NULL)
{
print_error (awk);
return -1;
}
if (cmdline.fs)
{
MyHawk::Value fs (run);
if (fs.setStr(cmdline.fs) <= -1)
{
print_error (awk);
return -1;
}
if (awk.setGlobal(HAWK_GBL_FS, fs) <= -1)
{
print_error (awk);
return -1;
}
}
if (cmdline.outc)
{
if (awk.addConsoleOutput(cmdline.outc) <= -1)
{
print_error (awk);
return -1;
}
}
MyHawk::Value ret;
if (awk.loop (&ret) <= -1)
{
print_error (awk);
return -1;
}
return 0;
}
static HAWK_INLINE int execute_hawk (int argc, hawk_bch_t* argv[])
{
//HAWK::HeapMmgr hm (1000000);
//MyHawk awk (&hm);
MyHawk hawk;
if (hawk.open() <= -1)
{
print_error (hawk);
return -1;
}
app_hawk = &hawk;
set_signal ();
int n = hawk_main(hawk, argc, argv);
unset_signal ();
app_hawk = HAWK_NULL;
hawk.close ();
return n;
}
/* ---------------------------------------------------------------------- */
int main (int argc, hawk_bch_t* argv[])
{
int ret;
#if defined(_WIN32)
char locale[100];
UINT codepage;
WSADATA wsadata;
int sock_inited = 0;
#elif defined(__DOS__)
extern BOOL _watt_do_exit;
int sock_inited = 0;
#else
/* nothing special */
#endif
#if defined(_WIN32)
codepage = GetConsoleOutputCP();
if (codepage == CP_UTF8)
{
/*SetConsoleOUtputCP (CP_UTF8);*/
/*hawk_setdflcmgrbyid (HAWK_CMGR_UTF8);*/
}
else
{
/* .codepage */
hawk_fmt_uintmax_to_bcstr (locale, HAWK_COUNTOF(locale), codepage, 10, -1, '\0', ".");
setlocale (LC_ALL, locale);
/* hawk_setdflcmgrbyid (HAWK_CMGR_SLMB); */
}
#else
setlocale (LC_ALL, "");
/* hawk_setdflcmgrbyid (HAWK_CMGR_SLMB); */
#endif
#if defined(_WIN32)
if (WSAStartup(MAKEWORD(2,0), &wsadata) != 0)
print_warning ("Failed to start up winsock\n");
else sock_inited = 1;
#elif defined(__DOS__)
/* TODO: add an option to skip watt-32 */
_watt_do_exit = 0; /* prevent sock_init from exiting upon failure */
if (sock_init() != 0) print_warning ("Failed to initialize watt-32\n");
else sock_inited = 1;
#endif
ret = execute_hawk(argc, argv);
#if defined(_WIN32)
if (sock_inited) WSACleanup ();
#elif defined(__DOS__)
if (sock_inited) sock_exit ();
#endif
return ret;
}