importing sed code

This commit is contained in:
hyung-hwan 2022-03-31 17:14:52 +00:00
parent 7922df9b57
commit a604d40e6e
23 changed files with 1682 additions and 135 deletions

View File

@ -13,12 +13,12 @@ LDFLAGS_COMMON = -L$(abs_builddir)/../lib -L$(libdir)
##Use -l for third party libraries for automatic inclusion to DEPENDENCIES .
LIBADD_COMMON = ../lib/libhawk.la
bin_PROGRAMS = hawk
bin_PROGRAMS = hawk #hsed
##################################################
# hawk
##################################################
hawk_SOURCES = main.c
hawk_SOURCES = main-hawk.c
hawk_CPPFLAGS = $(CPPFLAGS_COMMON)
hawk_CFLAGS = $(CFLAGS_COMMON)
hawk_LDFLAGS = $(LDFLAGS_COMMON)
@ -38,3 +38,8 @@ hawk_LDFLAGS = $(LDFLAGS_COMMON)
##
hawk_LDADD = $(LIBADD_COMMON) $(LIBM)
#hsed_SOURCES = main-hsed.c
#hsed_CPPFLAGS = $(CPPFLAGS_COMMON)
#hsed_CFLAGS = $(CFLAGS_COMMON)
#hsed_LDFLAGS = $(LDFLAGS_COMMON)
#hsed_LDADD = $(LIBADD_COMMON) $(LIBM)

View File

@ -109,7 +109,7 @@ CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
am__installdirs = "$(DESTDIR)$(bindir)"
PROGRAMS = $(bin_PROGRAMS)
am_hawk_OBJECTS = hawk-main.$(OBJEXT)
am_hawk_OBJECTS = hawk-main-hawk.$(OBJEXT)
hawk_OBJECTS = $(am_hawk_OBJECTS)
am__DEPENDENCIES_1 =
hawk_DEPENDENCIES = $(LIBADD_COMMON) $(am__DEPENDENCIES_1)
@ -135,7 +135,7 @@ am__v_at_1 =
DEFAULT_INCLUDES =
depcomp = $(SHELL) $(top_srcdir)/ac/depcomp
am__maybe_remake_depfiles = depfiles
am__depfiles_remade = ./$(DEPDIR)/hawk-main.Po
am__depfiles_remade = ./$(DEPDIR)/hawk-main-hawk.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@ -346,7 +346,7 @@ LIBADD_COMMON = ../lib/libhawk.la
##################################################
# hawk
##################################################
hawk_SOURCES = main.c
hawk_SOURCES = main-hawk.c
hawk_CPPFLAGS = $(CPPFLAGS_COMMON)
hawk_CFLAGS = $(CFLAGS_COMMON)
hawk_LDFLAGS = $(LDFLAGS_COMMON)
@ -444,7 +444,7 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hawk-main.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hawk-main-hawk.Po@am__quote@ # am--include-marker
$(am__depfiles_remade):
@$(MKDIR_P) $(@D)
@ -476,19 +476,19 @@ am--depfiles: $(am__depfiles_remade)
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
hawk-main.o: main.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk_CPPFLAGS) $(CPPFLAGS) $(hawk_CFLAGS) $(CFLAGS) -MT hawk-main.o -MD -MP -MF $(DEPDIR)/hawk-main.Tpo -c -o hawk-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hawk-main.Tpo $(DEPDIR)/hawk-main.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='hawk-main.o' libtool=no @AMDEPBACKSLASH@
hawk-main-hawk.o: main-hawk.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk_CPPFLAGS) $(CPPFLAGS) $(hawk_CFLAGS) $(CFLAGS) -MT hawk-main-hawk.o -MD -MP -MF $(DEPDIR)/hawk-main-hawk.Tpo -c -o hawk-main-hawk.o `test -f 'main-hawk.c' || echo '$(srcdir)/'`main-hawk.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hawk-main-hawk.Tpo $(DEPDIR)/hawk-main-hawk.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main-hawk.c' object='hawk-main-hawk.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk_CPPFLAGS) $(CPPFLAGS) $(hawk_CFLAGS) $(CFLAGS) -c -o hawk-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk_CPPFLAGS) $(CPPFLAGS) $(hawk_CFLAGS) $(CFLAGS) -c -o hawk-main-hawk.o `test -f 'main-hawk.c' || echo '$(srcdir)/'`main-hawk.c
hawk-main.obj: main.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk_CPPFLAGS) $(CPPFLAGS) $(hawk_CFLAGS) $(CFLAGS) -MT hawk-main.obj -MD -MP -MF $(DEPDIR)/hawk-main.Tpo -c -o hawk-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hawk-main.Tpo $(DEPDIR)/hawk-main.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main.c' object='hawk-main.obj' libtool=no @AMDEPBACKSLASH@
hawk-main-hawk.obj: main-hawk.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk_CPPFLAGS) $(CPPFLAGS) $(hawk_CFLAGS) $(CFLAGS) -MT hawk-main-hawk.obj -MD -MP -MF $(DEPDIR)/hawk-main-hawk.Tpo -c -o hawk-main-hawk.obj `if test -f 'main-hawk.c'; then $(CYGPATH_W) 'main-hawk.c'; else $(CYGPATH_W) '$(srcdir)/main-hawk.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/hawk-main-hawk.Tpo $(DEPDIR)/hawk-main-hawk.Po
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='main-hawk.c' object='hawk-main-hawk.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk_CPPFLAGS) $(CPPFLAGS) $(hawk_CFLAGS) $(CFLAGS) -c -o hawk-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(hawk_CPPFLAGS) $(CPPFLAGS) $(hawk_CFLAGS) $(CFLAGS) -c -o hawk-main-hawk.obj `if test -f 'main-hawk.c'; then $(CYGPATH_W) 'main-hawk.c'; else $(CYGPATH_W) '$(srcdir)/main-hawk.c'; fi`
mostlyclean-libtool:
-rm -f *.lo
@ -623,7 +623,7 @@ clean: clean-am
clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
distclean: distclean-am
-rm -f ./$(DEPDIR)/hawk-main.Po
-rm -f ./$(DEPDIR)/hawk-main-hawk.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
@ -669,7 +669,7 @@ install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/hawk-main.Po
-rm -f ./$(DEPDIR)/hawk-main-hawk.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
@ -707,6 +707,12 @@ uninstall-am: uninstall-binPROGRAMS
.PRECIOUS: Makefile
#hsed_SOURCES = main-hsed.c
#hsed_CPPFLAGS = $(CPPFLAGS_COMMON)
#hsed_CFLAGS = $(CFLAGS_COMMON)
#hsed_LDFLAGS = $(LDFLAGS_COMMON)
#hsed_LDADD = $(LIBADD_COMMON) $(LIBM)
# 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:

View File

@ -465,7 +465,7 @@ static void on_statement (hawk_rtx_t* rtx, hawk_nde_t* nde)
static void print_version (const hawk_bch_t* argv0)
{
printf ("%s %s\n", hawk_get_base_name_bcstr(argv0), HAWK_PACKAGE_VERSION);
printf ("Copyright 2006-2020 Chung, Hyung-Hwan\n");
printf ("Copyright 2006-2022 Chung, Hyung-Hwan\n");
}
static void print_error (const hawk_bch_t* fmt, ...)

15
hawk/configure vendored
View File

@ -19303,6 +19303,21 @@ fi
OLDLIBS="$LIBS"
LIBS="$FFI_LIBS $LIBS"
for ac_func in ffi_prep_cif_var
do :
ac_fn_c_check_func "$LINENO" "ffi_prep_cif_var" "ac_cv_func_ffi_prep_cif_var"
if test "x$ac_cv_func_ffi_prep_cif_var" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_FFI_PREP_CIF_VAR 1
_ACEOF
fi
done
LIBS="$OLDLIBS"
if test "x${ac_cv_header_libunwind_h}" = "xyes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for unw_backtrace in -lunwind" >&5

View File

@ -311,6 +311,11 @@ AC_CHECK_LIB([ffi], [ffi_call],
)
AC_SUBST(FFI_LIBS)
OLDLIBS="$LIBS"
LIBS="$FFI_LIBS $LIBS"
AC_CHECK_FUNCS([ffi_prep_cif_var])
LIBS="$OLDLIBS"
if test "x${ac_cv_header_libunwind_h}" = "xyes"
then
AC_CHECK_LIB([unwind], [unw_backtrace],

View File

@ -124,6 +124,7 @@ libhawk_la_SOURCES = \
utf16.c \
utf8.c \
utl-ass.c \
utl-rnd.c\
utl-sort.c \
utl-str.c \
utl-sys.c \
@ -148,7 +149,8 @@ libhawk_la_SOURCES += \
syscall.h \
tio.c \
std-prv.h \
std.c
std.c \
std-sed.c
libhawk_la_CPPFLAGS = $(CPPFLAGS_ALL_COMMON) $(CPPFLAGS_PFMOD)
libhawk_la_CFLAGS = $(CFLAGS_ALL_COMMON)

View File

@ -240,12 +240,13 @@ am__libhawk_la_SOURCES_DIST = hawk.h hawk-arr.h hawk-chr.h hawk-cmn.h \
tre-compile.c tre-compile.h tre-match-bt.c tre-match-pa.c \
tre-match-ut.h tre-mem.c tre-mem.h tre-parse.c tre-parse.h \
tre-stack.h tre-stack.c tre.c tree-prv.h tree.c uch-prop.h \
uch-case.h utf16.c utf8.c utl-ass.c utl-sort.c utl-str.c \
utl-sys.c utl.c val-prv.h val.c xma.c hawk-cli.h hawk-fio.h \
hawk-mtx.h hawk-pio.h hawk-sio.h hawk-tio.h cli-imp.h cli.c \
fio.c mtx.c pio.c sio.c syscall.h tio.c std-prv.h std.c \
Hawk.cpp HawkStd.cpp mod-hawk.c mod-hawk.h mod-math.c \
mod-math.h mod-str.c mod-str.h mod-sys.c mod-sys.h
uch-case.h utf16.c utf8.c utl-ass.c utl-rnd.c utl-sort.c \
utl-str.c utl-sys.c utl.c val-prv.h val.c xma.c hawk-cli.h \
hawk-fio.h hawk-mtx.h hawk-pio.h hawk-sio.h hawk-tio.h \
cli-imp.h cli.c fio.c mtx.c pio.c sio.c syscall.h tio.c \
std-prv.h std.c std-sed.c Hawk.cpp HawkStd.cpp mod-hawk.c \
mod-hawk.h mod-math.c mod-math.h mod-str.c mod-str.h mod-sys.c \
mod-sys.h
am__objects_1 =
am__objects_2 = $(am__objects_1)
@ENABLE_CXX_TRUE@am__objects_3 = libhawk_la-Hawk.lo \
@ -267,13 +268,13 @@ am_libhawk_la_OBJECTS = $(am__objects_2) libhawk_la-arr.lo \
libhawk_la-tre-match-pa.lo libhawk_la-tre-mem.lo \
libhawk_la-tre-parse.lo libhawk_la-tre-stack.lo \
libhawk_la-tre.lo libhawk_la-tree.lo libhawk_la-utf16.lo \
libhawk_la-utf8.lo libhawk_la-utl-ass.lo \
libhawk_la-utf8.lo libhawk_la-utl-ass.lo libhawk_la-utl-rnd.lo \
libhawk_la-utl-sort.lo libhawk_la-utl-str.lo \
libhawk_la-utl-sys.lo libhawk_la-utl.lo libhawk_la-val.lo \
libhawk_la-xma.lo libhawk_la-cli.lo libhawk_la-fio.lo \
libhawk_la-mtx.lo libhawk_la-pio.lo libhawk_la-sio.lo \
libhawk_la-tio.lo libhawk_la-std.lo $(am__objects_3) \
$(am__objects_4)
libhawk_la-tio.lo libhawk_la-std.lo libhawk_la-std-sed.lo \
$(am__objects_3) $(am__objects_4)
libhawk_la_OBJECTS = $(am_libhawk_la_OBJECTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
@ -314,6 +315,7 @@ am__depfiles_remade = ./$(DEPDIR)/libhawk_hawk_la-mod-hawk.Plo \
./$(DEPDIR)/libhawk_la-rec.Plo ./$(DEPDIR)/libhawk_la-rio.Plo \
./$(DEPDIR)/libhawk_la-run.Plo ./$(DEPDIR)/libhawk_la-sed.Plo \
./$(DEPDIR)/libhawk_la-sio.Plo ./$(DEPDIR)/libhawk_la-skad.Plo \
./$(DEPDIR)/libhawk_la-std-sed.Plo \
./$(DEPDIR)/libhawk_la-std.Plo ./$(DEPDIR)/libhawk_la-tio.Plo \
./$(DEPDIR)/libhawk_la-tre-ast.Plo \
./$(DEPDIR)/libhawk_la-tre-compile.Plo \
@ -326,6 +328,7 @@ am__depfiles_remade = ./$(DEPDIR)/libhawk_hawk_la-mod-hawk.Plo \
./$(DEPDIR)/libhawk_la-utf16.Plo \
./$(DEPDIR)/libhawk_la-utf8.Plo \
./$(DEPDIR)/libhawk_la-utl-ass.Plo \
./$(DEPDIR)/libhawk_la-utl-rnd.Plo \
./$(DEPDIR)/libhawk_la-utl-sort.Plo \
./$(DEPDIR)/libhawk_la-utl-str.Plo \
./$(DEPDIR)/libhawk_la-utl-sys.Plo \
@ -610,11 +613,11 @@ libhawk_la_SOURCES = $(pkginclude_HEADERS) arr.c chr.c dir.c ecs-imp.h \
tre-compile.c tre-compile.h tre-match-bt.c tre-match-pa.c \
tre-match-ut.h tre-mem.c tre-mem.h tre-parse.c tre-parse.h \
tre-stack.h tre-stack.c tre.c tree-prv.h tree.c uch-prop.h \
uch-case.h utf16.c utf8.c utl-ass.c utl-sort.c utl-str.c \
utl-sys.c utl.c val-prv.h val.c xma.c hawk-cli.h hawk-fio.h \
hawk-mtx.h hawk-pio.h hawk-sio.h hawk-tio.h cli-imp.h cli.c \
fio.c mtx.c pio.c sio.c syscall.h tio.c std-prv.h std.c \
$(am__append_8) $(am__append_9)
uch-case.h utf16.c utf8.c utl-ass.c utl-rnd.c utl-sort.c \
utl-str.c utl-sys.c utl.c val-prv.h val.c xma.c hawk-cli.h \
hawk-fio.h hawk-mtx.h hawk-pio.h hawk-sio.h hawk-tio.h \
cli-imp.h cli.c fio.c mtx.c pio.c sio.c syscall.h tio.c \
std-prv.h std.c std-sed.c $(am__append_8) $(am__append_9)
libhawk_la_CPPFLAGS = $(CPPFLAGS_ALL_COMMON) $(CPPFLAGS_PFMOD) \
$(am__append_3)
libhawk_la_CFLAGS = $(CFLAGS_ALL_COMMON)
@ -806,6 +809,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-sed.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-sio.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-skad.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-std-sed.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-std.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-tio.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-tre-ast.Plo@am__quote@ # am--include-marker
@ -820,6 +824,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utf16.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utf8.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utl-ass.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utl-rnd.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utl-sort.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utl-str.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libhawk_la-utl-sys.Plo@am__quote@ # am--include-marker
@ -1126,6 +1131,13 @@ libhawk_la-utl-ass.lo: utl-ass.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -c -o libhawk_la-utl-ass.lo `test -f 'utl-ass.c' || echo '$(srcdir)/'`utl-ass.c
libhawk_la-utl-rnd.lo: utl-rnd.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -MT libhawk_la-utl-rnd.lo -MD -MP -MF $(DEPDIR)/libhawk_la-utl-rnd.Tpo -c -o libhawk_la-utl-rnd.lo `test -f 'utl-rnd.c' || echo '$(srcdir)/'`utl-rnd.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-utl-rnd.Tpo $(DEPDIR)/libhawk_la-utl-rnd.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='utl-rnd.c' object='libhawk_la-utl-rnd.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -c -o libhawk_la-utl-rnd.lo `test -f 'utl-rnd.c' || echo '$(srcdir)/'`utl-rnd.c
libhawk_la-utl-sort.lo: utl-sort.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -MT libhawk_la-utl-sort.lo -MD -MP -MF $(DEPDIR)/libhawk_la-utl-sort.Tpo -c -o libhawk_la-utl-sort.lo `test -f 'utl-sort.c' || echo '$(srcdir)/'`utl-sort.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-utl-sort.Tpo $(DEPDIR)/libhawk_la-utl-sort.Plo
@ -1217,6 +1229,13 @@ libhawk_la-std.lo: std.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -c -o libhawk_la-std.lo `test -f 'std.c' || echo '$(srcdir)/'`std.c
libhawk_la-std-sed.lo: std-sed.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -MT libhawk_la-std-sed.lo -MD -MP -MF $(DEPDIR)/libhawk_la-std-sed.Tpo -c -o libhawk_la-std-sed.lo `test -f 'std-sed.c' || echo '$(srcdir)/'`std-sed.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-std-sed.Tpo $(DEPDIR)/libhawk_la-std-sed.Plo
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='std-sed.c' object='libhawk_la-std-sed.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -c -o libhawk_la-std-sed.lo `test -f 'std-sed.c' || echo '$(srcdir)/'`std-sed.c
libhawk_la-mod-hawk.lo: mod-hawk.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libhawk_la_CPPFLAGS) $(CPPFLAGS) $(libhawk_la_CFLAGS) $(CFLAGS) -MT libhawk_la-mod-hawk.lo -MD -MP -MF $(DEPDIR)/libhawk_la-mod-hawk.Tpo -c -o libhawk_la-mod-hawk.lo `test -f 'mod-hawk.c' || echo '$(srcdir)/'`mod-hawk.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libhawk_la-mod-hawk.Tpo $(DEPDIR)/libhawk_la-mod-hawk.Plo
@ -1472,6 +1491,7 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/libhawk_la-sed.Plo
-rm -f ./$(DEPDIR)/libhawk_la-sio.Plo
-rm -f ./$(DEPDIR)/libhawk_la-skad.Plo
-rm -f ./$(DEPDIR)/libhawk_la-std-sed.Plo
-rm -f ./$(DEPDIR)/libhawk_la-std.Plo
-rm -f ./$(DEPDIR)/libhawk_la-tio.Plo
-rm -f ./$(DEPDIR)/libhawk_la-tre-ast.Plo
@ -1486,6 +1506,7 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/libhawk_la-utf16.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utf8.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utl-ass.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utl-rnd.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utl-sort.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utl-str.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utl-sys.Plo
@ -1575,6 +1596,7 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/libhawk_la-sed.Plo
-rm -f ./$(DEPDIR)/libhawk_la-sio.Plo
-rm -f ./$(DEPDIR)/libhawk_la-skad.Plo
-rm -f ./$(DEPDIR)/libhawk_la-std-sed.Plo
-rm -f ./$(DEPDIR)/libhawk_la-std.Plo
-rm -f ./$(DEPDIR)/libhawk_la-tio.Plo
-rm -f ./$(DEPDIR)/libhawk_la-tre-ast.Plo
@ -1589,6 +1611,7 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/libhawk_la-utf16.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utf8.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utl-ass.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utl-rnd.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utl-sort.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utl-str.Plo
-rm -f ./$(DEPDIR)/libhawk_la-utl-sys.Plo

View File

@ -224,11 +224,6 @@ hawk_errstr_t hawk_geterrstr (hawk_t* hawk)
/* ------------------------------------------------------------------------- */
const hawk_loc_t* hawk_geterrloc (hawk_t* hawk)
{
return &hawk->_gem.errloc;
}
const hawk_bch_t* hawk_geterrbmsg (hawk_t* hawk)
{
return hawk_gem_geterrbmsg(hawk_getgem(hawk));
@ -286,13 +281,13 @@ void hawk_seterruvfmt (hawk_t* hawk, const hawk_loc_t* errloc, hawk_errnum_t err
hawk_gem_seterruvfmt (hawk_getgem(hawk), errloc, errnum, errfmt, ap);
}
/* ------------------------------------------------------------------------- */
const hawk_loc_t* hawk_rtx_geterrloc (hawk_rtx_t* rtx)
void hawk_seterror (hawk_t* hawk, const hawk_loc_t* errloc, hawk_errnum_t errnum, const hawk_oocs_t* errarg)
{
return &rtx->_gem.errloc;
hawk_gem_seterror (hawk_getgem(hawk), errloc, errnum, errarg);
}
/* ------------------------------------------------------------------------- */
const hawk_bch_t* hawk_rtx_geterrbmsg (hawk_rtx_t* rtx)
{
return hawk_gem_geterrbmsg(hawk_rtx_getgem(rtx));
@ -350,6 +345,11 @@ void hawk_rtx_seterruvfmt (hawk_rtx_t* rtx, const hawk_loc_t* errloc, hawk_errnu
hawk_gem_seterruvfmt (hawk_rtx_getgem(rtx), errloc, errnum, errfmt, ap);
}
void hawk_rtx_seterror (hawk_rtx_t* rtx, const hawk_loc_t* errloc, hawk_errnum_t errnum, const hawk_oocs_t* errarg)
{
hawk_gem_seterror (hawk_rtx_getgem(rtx), errloc, errnum, errarg);
}
void hawk_rtx_errortohawk (hawk_rtx_t* rtx, hawk_t* hawk)
{
/* copy error information in 'rtx' to the 'hawk' object */
@ -408,8 +408,6 @@ const hawk_uch_t* hawk_gem_geterrumsg (hawk_gem_t* gem)
#endif
}
void hawk_gem_seterrnum (hawk_gem_t* gem, const hawk_loc_t* errloc, hawk_errnum_t errnum)
{
gem->errnum = errnum;
@ -550,7 +548,7 @@ void hawk_gem_seterruvfmt (hawk_gem_t* gem, const hawk_loc_t* errloc, hawk_errnu
gem->errloc = (errloc? *errloc: _nullloc);
}
void hawk_gem_seterror (hawk_gem_t* gem, hawk_errnum_t errnum, const hawk_oocs_t* errarg, const hawk_loc_t* errloc)
void hawk_gem_seterror (hawk_gem_t* gem, const hawk_loc_t* errloc, hawk_errnum_t errnum, const hawk_oocs_t* errarg)
{
const hawk_ooch_t* errfmt;
@ -559,7 +557,7 @@ void hawk_gem_seterror (hawk_gem_t* gem, hawk_errnum_t errnum, const hawk_oocs_t
errfmt = gem->errstr(gem->errnum);
HAWK_ASSERT (errfmt != HAWK_NULL);
hawk_copy_oocses_to_oochars (gem->errmsg, HAWK_COUNTOF(gem->errmsg), errfmt, errarg);
hawk_copy_oofcs_to_oochars (gem->errmsg, HAWK_COUNTOF(gem->errmsg), errfmt, errarg);
if (errloc != HAWK_NULL) gem->errloc = *errloc;
else HAWK_MEMSET (&gem->errloc, 0, HAWK_SIZEOF(gem->errloc));

View File

@ -140,6 +140,11 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
{
hawk_fio_hnd_t handle;
hawk_uint32_t temp_no;
hawk_ooch_t* temp_ptr;
hawk_bch_t* temp_ptr_b;
hawk_oow_t temp_tries;
#if defined(_WIN32)
int fellback = 0;
#endif
@ -180,6 +185,102 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
if (flags & HAWK_FIO_NOCLOSE)
fio->status |= STATUS_NOCLOSE;
if (flags & HAWK_FIO_TEMPORARY)
{
hawk_ntime_t now;
/*if (flags & (HAWK_FIO_HANDLE | HAWK_FIO_BCSTRPATH))*/
if (flags & HAWK_FIO_HANDLE)
{
/* HAWK_FIO_TEMPORARY and HAWK_FIO_HANDLE/HAWK_FIO_BCSTRPATH
* are mutually exclusive */
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_EINVAL);
return -1;
}
temp_no = 0;
if (flags & HAWK_FIO_BCSTRPATH)
{
for (temp_ptr_b = (hawk_bch_t*)path; *temp_ptr_b; temp_ptr_b++)
temp_no += *temp_ptr_b;
if (temp_ptr_b - (hawk_bch_t*)path < 4)
{
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_EINVAL);
return -1;
}
temp_ptr_b -= 4;
}
else
{
/* if HAWK_FIO_TEMPORARY is used, the path name must be writable. */
for (temp_ptr = (hawk_ooch_t*)path; *temp_ptr; temp_ptr++)
temp_no += *temp_ptr;
/* The path name template must be at least 4 characters long
* excluding the terminating null. this function fails if not */
if (temp_ptr - path < 4)
{
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_EINVAL);
return -1;
}
temp_ptr -= 4;
}
hawk_get_ntime (&now);
temp_no += (now.sec & 0xFFFFFFFFlu);
temp_tries = 0;
retry_temporary:
temp_tries++;
/* Fails after 5000 tries. 5000 randomly chosen */
if (temp_tries > 5000)
{
hawk_gem_seterrnum (fio->gem, HAWK_NULL, HAWK_EINVAL);
return -1;
}
/* Generate the next random number to use to make a
* new path name */
temp_no = hawk_rand31(temp_no);
/*
* You must not pass a constant string for a path name
* when HAWK_FIO_TEMPORARY is set, because it changes
* the path name with a random number generated
*/
if (flags & HAWK_FIO_BCSTRPATH)
{
hawk_fmt_uintmax_to_bcstr (
temp_ptr_b,
4,
temp_no % 0x10000,
16 | HAWK_FMT_UINTMAX_NOTRUNC | HAWK_FMT_UINTMAX_NONULL,
4,
'\0',
HAWK_NULL
);
}
else
{
hawk_fmt_uintmax_to_oocstr (
temp_ptr,
4,
temp_no % 0x10000,
16 | HAWK_FMT_UINTMAX_NOTRUNC | HAWK_FMT_UINTMAX_NONULL,
4,
HAWK_T('\0'),
HAWK_NULL
);
}
}
#if defined(_WIN32)
if (flags & HAWK_FIO_HANDLE)
{
@ -256,7 +357,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
if (flags & HAWK_FIO_SEQUENTIAL)
flag_and_attr |= FILE_FLAG_SEQUENTIAL_SCAN;
if (flags & HAWK_FIO_MBSPATH)
if (flags & HAWK_FIO_BCSTRPATH)
{
handle = CreateFileA(
(const hawk_bch_t*)path, desired_access, share_mode,
@ -291,7 +392,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
desired_access |= GENERIC_WRITE;
}
if (flags & HAWK_FIO_MBSPATH)
if (flags & HAWK_FIO_BCSTRPATH)
{
handle = CreateFileA(
(const hawk_bch_t*)path, desired_access, share_mode,
@ -309,12 +410,14 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
}
if (handle == INVALID_HANDLE_VALUE)
{
i if (flags & HAWK_FIO_TEMPORARY) goto retry_temporary;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, hawk_syserr_to_errnum(GetLastError()));
return -1;
}
}
else
{
if (flags & HAWK_FIO_TEMPORARY) goto retry_temporary;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, hawk_syserr_to_errnum(e));
return -1;
}
@ -353,7 +456,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
hawk_oow_t wl, ml;
int px;
if (flags & HAWK_FIO_MBSPATH)
if (flags & HAWK_FIO_BCSTRPATH)
{
path_mb = (hawk_bch_t*)path;
}
@ -460,6 +563,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
if (ret != NO_ERROR)
{
if (flags & HAWK_FIO_TEMPORARY) goto retry_temporary;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, hawk_syserr_to_errnum(ret));
return -1;
}
@ -486,7 +590,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
hawk_oow_t wl, ml;
int px;
if (flags & HAWK_FIO_MBSPATH)
if (flags & HAWK_FIO_BCSTRPATH)
{
path_mb = (hawk_bch_t*)path;
}
@ -546,6 +650,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
if (handle <= -1)
{
if (flags & HAWK_FIO_TEMPORARY) goto retry_temporary;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, hawk_syserr_to_errnum(errno));
return -1;
}
@ -573,7 +678,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
hawk_oow_t wl, ml;
int px;
if (flags & HAWK_FIO_MBSPATH)
if (flags & HAWK_FIO_BCSTRPATH)
{
path_mb = (hawk_bch_t*)path;
}
@ -695,7 +800,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
hawk_oow_t wl, ml;
int px;
if (flags & HAWK_FIO_MBSPATH)
if (flags & HAWK_FIO_BCSTRPATH)
{
path_mb = (hawk_bch_t*)path;
}
@ -768,6 +873,7 @@ int hawk_fio_init (hawk_fio_t* fio, hawk_gem_t* gem, const hawk_ooch_t* path, in
#endif
if (handle == -1)
{
if (flags & HAWK_FIO_TEMPORARY) goto retry_temporary;
hawk_gem_seterrnum (fio->gem, HAWK_NULL, hawk_syserr_to_errnum(errno));
return -1;
}

View File

@ -169,6 +169,9 @@
/* libffi library is available */
#undef HAVE_FFI_LIB
/* Define to 1 if you have the `ffi_prep_cif_var' function. */
#undef HAVE_FFI_PREP_CIF_VAR
/* Define to 1 if you have the `floor' function. */
#undef HAVE_FLOOR

View File

@ -38,17 +38,15 @@ enum hawk_fio_flag_t
/** treat the file name pointer as a handle pointer */
HAWK_FIO_HANDLE = (1 << 8),
#if 0
/** treat the file name pointer as a pointer to file name
* template to use when making a temporary file name */
HAWK_FIO_TEMPORARY = (1 << 9),
#endif
/** don't close an I/O handle in hawk_fio_fini() and hawk_fio_close() */
HAWK_FIO_NOCLOSE = (1 << 10),
/** treat the path name as a multi-byte string */
HAWK_FIO_MBSPATH = (1 << 11),
HAWK_FIO_BCSTRPATH = (1 << 11),
/* normal open flags */
HAWK_FIO_READ = (1 << 14),

View File

@ -435,8 +435,10 @@ HAWK_EXPORT int hawk_gem_getifcfg (
#if defined(HAWK_HAVE_INLINE)
static HAWK_INLINE hawk_errnum_t hawk_gem_geterrnum (hawk_gem_t* gem) { return gem->errnum; }
static HAWK_INLINE const hawk_loc_t* hawk_gem_geterrloc (hawk_gem_t* gem) { return &gem->errloc; }
#else
#define hawk_gem_geterrnum(gem) (((hawk_gem_t*)(gem))->errnum)
#define hawk_gem_geterrloc(gem) (&((hawk_gem_t*)(gem))->errloc)
#endif
HAWK_EXPORT void hawk_gem_geterrinf (
@ -464,6 +466,13 @@ HAWK_EXPORT void hawk_gem_seterrinf (
const hawk_errinf_t* errinf
);
HAWK_EXPORT void hawk_gem_seterror (
hawk_gem_t* gem,
const hawk_loc_t* errloc,
hawk_errnum_t errnum,
const hawk_oocs_t* errarg
);
HAWK_EXPORT void hawk_gem_seterrnum (
hawk_gem_t* gem,
const hawk_loc_t* errloc,

View File

@ -29,6 +29,7 @@
#include <hawk-cmn.h>
#include <hawk-gem.h>
#include <hawk-sio.h>
/** @file
* This file defines data types and functions to use for creating a custom
@ -353,6 +354,92 @@ enum hawk_sed_space_t
};
typedef enum hawk_sed_space_t hawk_sed_space_t;
/* ------------------------------------------------------------------------ */
/**
* This section defines easier-to-use helper interface for a stream editor.
* If you don't care about the details of memory management and I/O handling,
* you can choose to use the helper functions provided here. It is
* a higher-level interface that is easier to use as it implements
* default handlers for I/O and memory management.
*/
/**
* The hawk_sed_iostd_type_t type defines types of standard
* I/O resources.
*/
enum hawk_sed_iostd_type_t
{
HAWK_SED_IOSTD_NULL, /**< null resource type */
HAWK_SED_IOSTD_FILE, /**< file */
HAWK_SED_IOSTD_FILEB, /**< file */
HAWK_SED_IOSTD_FILEU, /**< file */
HAWK_SED_IOSTD_STR, /**< string */
HAWK_SED_IOSTD_SIO /**< sio */
};
typedef enum hawk_sed_iostd_type_t hawk_sed_iostd_type_t;
/**
* The hawk_sed_iostd_t type defines a standard I/O resource.
*/
struct hawk_sed_iostd_t
{
/** resource type */
hawk_sed_iostd_type_t type;
/** union describing the resource of the specified type */
union
{
/** file path with character encoding */
struct
{
/** file path to open. #HAWK_NULL or '-' for stdin/stdout. */
const hawk_ooch_t* path;
/** a stream created with the file path is set with this
* cmgr if it is not #HAWK_NULL. */
hawk_cmgr_t* cmgr;
} file;
struct
{
const hawk_bch_t* path;
hawk_cmgr_t* cmgr;
} fileb;
struct
{
const hawk_uch_t* path;
hawk_cmgr_t* cmgr;
} fileu;
/**
* input string or dynamically allocated output string
*
* For input, the ptr and the len field of str indicates the
* pointer and the length of a string to read. You must set
* these two fields before calling hawk_sed_execstd().
*
* For output, the ptr and the len field of str indicates the
* pointer and the length of produced output. The output
* string is dynamically allocated. You don't need to set these
* fields before calling hawk_sed_execstd() because they are
* set by hawk_sed_execstd() and valid while the relevant sed
* object is alive. You must free the memory chunk pointed to by
* the ptr field with hawk_sed_freemem() once you're done with it
* to avoid memory leaks.
*/
hawk_oocs_t str;
/** pre-opened sio stream */
hawk_sio_t* sio;
} u;
};
typedef struct hawk_sed_iostd_t hawk_sed_iostd_t;
/* ------------------------------------------------------------------------ */
#if defined(__cplusplus)
extern "C" {
#endif
@ -370,6 +457,7 @@ extern "C" {
HAWK_EXPORT hawk_sed_t* hawk_sed_open (
hawk_mmgr_t* mmgr, /**< memory manager */
hawk_oow_t xtnsize, /**< extension size in bytes */
hawk_cmgr_t* cmgr,
hawk_errnum_t* errnum
);
@ -448,27 +536,17 @@ HAWK_EXPORT int hawk_sed_setopt (
*/
#if defined(HAWK_HAVE_INLINE)
static HAWK_INLINE hawk_errnum_t hawk_sed_geterrnum (hawk_sed_t* sed) { return ((hawk_sed_alt_t*)sed)->_gem.errnum; }
static HAWK_INLINE hawk_errnum_t hawk_sed_geterrnum (hawk_sed_t* sed) { return hawk_gem_geterrnum(hawk_sed_getgem(sed)); }
static HAWK_INLINE const hawk_loc_t* hawk_sed_geterrloc (hawk_sed_t* sed) { return hawk_gem_geterrloc(hawk_sed_getgem(sed)); }
static HAWK_INLINE const hawk_bch_t* hawk_sed_geterrbmsg (hawk_sed_t* sed) { return hawk_gem_geterrbmsg(hawk_sed_getgem(sed)); }
static HAWK_INLINE const hawk_uch_t* hawk_sed_geterrumsg (hawk_sed_t* sed) { return hawk_gem_geterrumsg(hawk_sed_getgem(sed)); }
#else
# define hawk_sed_geterrnum(sed) (((hawk_sed_alt_t*)(sed))->_gem.errnum)
#define hawk_sed_geterrnum(sed) hawk_gem_geterrnum(hawk_sed_getgem(sed))
#define hawk_sed_geterrloc(sed) hawk_gem_geterrloc(hawk_sed_getgem(sed))
#define hawk_sed_geterrbmsg(sed) hawk_gem_geterrbmsg(hawk_sed_getgem(sed))
#define hawk_sed_geterrumsg(sed) hawk_gem_geterrumsg(hawk_sed_getgem(sed))
#endif
/**
* The hawk_sed_geterrloc() function gets the location where the last error
* has occurred.
* @return error location
*/
HAWK_EXPORT const hawk_loc_t* hawk_sed_geterrloc (
hawk_sed_t* sed /**< stream editor */
);
/**
* The hawk_sed_geterrmsg() function gets a string describing the last error.
* @return error message pointer
*/
HAWK_EXPORT const hawk_ooch_t* hawk_sed_geterrmsg (
hawk_sed_t* sed /**< stream editor */
);
/**
* The hawk_sed_geterror() function gets an error number, an error location,
@ -490,33 +568,12 @@ HAWK_EXPORT void hawk_sed_geterror (
*/
#if defined(HAWK_HAVE_INLINE)
static HAWK_INLINE void hawk_sed_seterrnum (hawk_sed_t* sed, const hawk_loc_t* errloc, hawk_errnum_t errnum) { hawk_gem_seterrnum (hawk_sed_getgem(sed), errloc, errnum); }
static HAWK_INLINE void hawk_sed_seterror (hawk_sed_t* sed, const hawk_loc_t* errloc, hawk_errnum_t errnum, const hawk_oocs_t* errarg) { hawk_gem_seterror(hawk_sed_getgem(sed), errloc, errnum, errarg); }
#else
#define hawk_sed_seterrnum(sed, errloc, errnum) hawk_sed_gem_seterrnum(hawk_sed_getgem(sed), errloc, errnum)
#define hawk_sed_seterrnum(sed, errloc, errnum) hawk_gem_seterrnum(hawk_sed_getgem(sed), errloc, errnum)
#define hawk_set_seterror(sed, errloc, errnum, errarg) hawk_sed_seterror(hawk_sed_getgem(sed), errloc, errnum, errarg)
#endif
/**
* The hawk_sed_seterrmsg() function sets error information with a customized
* message for a given error number.
*/
HAWK_EXPORT void hawk_sed_seterrmsg (
hawk_sed_t* sed, /**< stream editor */
hawk_errnum_t errnum, /**< error number */
const hawk_ooch_t* errmsg, /**< error message */
const hawk_loc_t* errloc /**< error location */
);
/**
* The hawk_sed_seterror() function sets an error number, an error location, and
* an error message. An error string is composed of a formatting string
* and an array of formatting parameters.
*/
HAWK_EXPORT void hawk_sed_seterror (
hawk_sed_t* sed, /**< stream editor */
hawk_errnum_t errnum, /**< error number */
const hawk_oocs_t* errarg, /**< array of arguments for formatting an error message */
const hawk_loc_t* errloc /**< error location */
);
/**
* The hawk_sed_popecb() function pops an sed event callback set
* and returns the pointer to it. If no callback set can be popped,
@ -654,6 +711,151 @@ HAWK_EXPORT void hawk_sed_getspace (
hawk_oocs_t* str
);
/* ------------------------------------------------------------------------ */
/**
* The hawk_sed_openstd() function creates a stream editor with the default
* memory manager and initializes it.
* \return pointer to a stream editor on success, #HAWK_NULL on failure.
*/
HAWK_EXPORT hawk_sed_t* hawk_sed_openstd (
hawk_oow_t xtnsize, /**< extension size in bytes */
hawk_errnum_t* errnum
);
/**
* The hawk_sed_openstdwithmmgr() function creates a stream editor with a
* user-defined memory manager. It is equivalent to hawk_sed_openstd(),
* except that you can specify your own memory manager.
* \return pointer to a stream editor on success, #HAWK_NULL on failure.
*/
HAWK_EXPORT hawk_sed_t* hawk_sed_openstdwithmmgr (
hawk_mmgr_t* mmgr, /**< memory manager */
hawk_oow_t xtnsize, /**< extension size in bytes */
hawk_cmgr_t* cmgr,
hawk_errnum_t* errnum
);
/**
* The hawk_sed_compstd() function compiles sed scripts specified in
* an array of stream resources. The end of the array is indicated
* by an element whose type is #HAWK_SED_IOSTD_NULL. However, the type
* of the first element shall not be #HAWK_SED_IOSTD_NULL. The output
* parameter \a count is set to the count of stream resources
* opened on both success and failure. You can pass #HAWK_NULL to \a
* count if the count is not needed.
*
* \return 0 on success, -1 on failure
*/
HAWK_EXPORT int hawk_sed_compstd (
hawk_sed_t* sed, /**< stream editor */
hawk_sed_iostd_t in[], /**< input scripts */
hawk_oow_t* count /**< number of input scripts opened */
);
/**
* The hawk_sed_compstdfile() function compiles a sed script from
* a single file \a infile. If \a infile is #HAWK_NULL, it reads
* the script from the standard input.
* When #HAWK_OOCH_IS_UCH is defined, it converts the multibyte
* sequences in the file \a infile to wide characters via the
* #hawk_cmgr_t interface \a cmgr. If \a cmgr is #HAWK_NULL, it uses
* the default interface. It calls cmgr->mbtowc() for conversion.
* \return 0 on success, -1 on failure
*/
HAWK_EXPORT int hawk_sed_compstdfile (
hawk_sed_t* sed,
const hawk_ooch_t* infile,
hawk_cmgr_t* cmgr
);
HAWK_EXPORT int hawk_sed_compstdfileb (
hawk_sed_t* sed,
const hawk_bch_t* infile,
hawk_cmgr_t* cmgr
);
HAWK_EXPORT int hawk_sed_compstdfileu (
hawk_sed_t* sed,
const hawk_uch_t* infile,
hawk_cmgr_t* cmgr
);
/**
* The hawk_sed_compstdstr() function compiles a sed script stored
* in a null-terminated string pointed to by \a script.
* \return 0 on success, -1 on failure
*/
HAWK_EXPORT int hawk_sed_compstdstr (
hawk_sed_t* sed,
const hawk_ooch_t* script
);
/**
* The hawk_sed_compstdxstr() function compiles a sed script of the
* length \a script->len pointed to by \a script->ptr.
* \return 0 on success, -1 on failure
*/
HAWK_EXPORT int hawk_sed_compstdxstr (
hawk_sed_t* sed,
const hawk_oocs_t* script
);
/**
* The hawk_sed_execstd() function executes a compiled script
* over input streams \a in and an output stream \a out.
*
* If \a in is not #HAWK_NULL, it must point to an array of stream
* resources whose end is indicated by an element with #HAWK_SED_IOSTD_NULL
* type. However, the type of the first element \a in[0].type show not
* be #HAWK_SED_IOSTD_NULL. It requires at least 1 valid resource to be
* included in the array.
*
* If \a in is #HAWK_NULL, the standard console input is used.
* If \a out is #HAWK_NULL, the standard console output is used.
*
* \return 0 on success, -1 on failure
*/
HAWK_EXPORT int hawk_sed_execstd (
hawk_sed_t* sed,
hawk_sed_iostd_t in[],
hawk_sed_iostd_t* out
);
/**
* The hawk_sed_execstdfile() function executes a compiled script
* over a single input file \a infile and a single output file \a
* outfile.
*
* If \a infile is #HAWK_NULL, the standard console input is used.
* If \a outfile is #HAWK_NULL, the standard console output is used.
*
* \return 0 on success, -1 on failure
*/
HAWK_EXPORT int hawk_sed_execstdfile (
hawk_sed_t* sed,
const hawk_ooch_t* infile,
const hawk_ooch_t* outfile,
hawk_cmgr_t* cmgr
);
/**
* The hawk_sed_execstdfile() function executes a compiled script
* over a single input string \a instr and a dynamically allocated buffer.
* It copies the buffer pointer and length to the location pointed to
* by \a outstr on success. The buffer pointer copied to \a outstr
* must be released with hawk_sed_freemem().
*
* \return 0 on success, -1 on failure
*/
HAWK_EXPORT int hawk_sed_execstdxstr (
hawk_sed_t* sed,
const hawk_oocs_t* instr,
hawk_oocs_t* outstr,
hawk_cmgr_t* cmgr
);
#if defined(__cplusplus)
}
#endif

View File

@ -48,7 +48,9 @@ enum hawk_sio_flag_t
/* ensure that the following enumerators are one of
* hawk_fio_flags_t enumerators */
HAWK_SIO_HANDLE = HAWK_FIO_HANDLE,
HAWK_SIO_TEMPORARY = HAWK_FIO_TEMPORARY,
HAWK_SIO_NOCLOSE = HAWK_FIO_NOCLOSE,
HAWK_SIO_BCSTRPATH = HAWK_FIO_BCSTRPATH,
HAWK_SIO_READ = HAWK_FIO_READ,
HAWK_SIO_WRITE = HAWK_FIO_WRITE,
HAWK_SIO_APPEND = HAWK_FIO_APPEND,

View File

@ -567,6 +567,20 @@ HAWK_EXPORT hawk_oow_t hawk_copy_bcstr_unlimited (
const hawk_bch_t* src
);
HAWK_EXPORT hawk_oow_t hawk_copy_ufcs_to_uchars (
hawk_uch_t* buf,
hawk_oow_t bsz,
const hawk_uch_t* fmt,
const hawk_ucs_t str[]
);
HAWK_EXPORT hawk_oow_t hawk_copy_bfcs_to_bchars (
hawk_bch_t* buf,
hawk_oow_t bsz,
const hawk_bch_t* fmt,
const hawk_bcs_t str[]
);
HAWK_EXPORT hawk_oow_t hawk_count_ucstr (
const hawk_uch_t* str
);
@ -585,7 +599,6 @@ HAWK_EXPORT hawk_oow_t hawk_count_bcstr_limited (
hawk_oow_t maxlen
);
HAWK_EXPORT void hawk_fill_uchars (
hawk_uch_t* dst,
const hawk_uch_t ch,
@ -810,6 +823,8 @@ HAWK_EXPORT hawk_oow_t hawk_subst_for_bcstr_to_bcstr (
# define hawk_copy_oocstr hawk_copy_ucstr
# define hawk_copy_oocstr_unlimited hawk_copy_ucstr_unlimited
# define hawk_copy_oofcs_to_oochars hawk_copy_ufcs_to_uchars
# define hawk_count_oocstr hawk_count_ucstr
# define hawk_count_oocstr_limited hawk_count_ucstr_limited
@ -853,6 +868,8 @@ HAWK_EXPORT hawk_oow_t hawk_subst_for_bcstr_to_bcstr (
# define hawk_copy_oocstr hawk_copy_bcstr
# define hawk_copy_oocstr_unlimited hawk_copy_bcstr_unlimited
# define hawk_copy_oofcs_to_oochars hawk_copy_bfcs_to_bchars
# define hawk_count_oocstr hawk_count_bcstr
# define hawk_count_oocstr_limited hawk_count_bcstr_limited
@ -1651,6 +1668,12 @@ HAWK_EXPORT void hawk_sub_ntime (
const hawk_ntime_t* y
);
/* =========================================================================
* RANDOM NUMBER GENERATOR
* ========================================================================= */
HAWK_EXPORT hawk_uint32_t hawk_rand31 (
hawk_uint32_t seed
);
/* =========================================================================
* ASSERTION

View File

@ -1584,19 +1584,18 @@ HAWK_EXPORT hawk_errstr_t hawk_geterrstr (
* \return error number
*/
#if defined(HAWK_HAVE_INLINE)
static HAWK_INLINE hawk_errnum_t hawk_geterrnum (hawk_t* hawk) { return ((hawk_alt_t*)hawk)->_gem.errnum; }
#else
# define hawk_geterrnum(hawk) (((hawk_alt_t*)(hawk))->_gem.errnum)
#endif
/**
* The hawk_geterrloc() function returns the location where the
* last error has occurred.
*/
HAWK_EXPORT const hawk_loc_t* hawk_geterrloc (
hawk_t* hawk /**< hawk */
);
#if defined(HAWK_HAVE_INLINE)
static HAWK_INLINE hawk_errnum_t hawk_geterrnum (hawk_t* hawk) { return ((hawk_alt_t*)hawk)->_gem.errnum; }
static HAWK_INLINE const hawk_loc_t* hawk_geterrloc (hawk_t* hawk) { return hawk_gem_geterrloc(hawk_getgem(hawk)); }
#else
# define hawk_geterrnum(hawk) (((hawk_alt_t*)(hawk))->_gem.errnum)
# define hawk_geterrloc(hawk) (hawk_gem_geterrloc(hawk_getgem(hawk)))
#endif
/**
* The hawk_geterrbmsg() function returns the error message describing
@ -1703,6 +1702,13 @@ HAWK_EXPORT void hawk_seterrinf (
);
HAWK_EXPORT void hawk_seterror (
hawk_t* hawk,
const hawk_loc_t* errloc,
hawk_errnum_t errnum,
const hawk_oocs_t* errarg
);
/**
* The hawk_geterror() function gets error information via parameters.
*/
@ -2566,20 +2572,19 @@ HAWK_EXPORT hawk_htb_t* hawk_rtx_getnvmap (
* occurred during runtime.
* \return error number
*/
#if defined(HAWK_HAVE_INLINE)
static HAWK_INLINE hawk_errnum_t hawk_rtx_geterrnum (hawk_rtx_t* rtx) { return ((hawk_rtx_alt_t*)rtx)->_gem.errnum; }
#else
# define hawk_rtx_geterrnum(hawk) (((hawk_rtx_alt_t*)(rtx))->_gem.errnum)
#endif
/**
* The hawk_rtx_geterrloc() function gets the location of the last error
* occurred during runtime. The
* \return error location
*/
HAWK_EXPORT const hawk_loc_t* hawk_rtx_geterrloc (
hawk_rtx_t* rtx /**< runtime context */
);
#if defined(HAWK_HAVE_INLINE)
static HAWK_INLINE hawk_errnum_t hawk_rtx_geterrnum (hawk_rtx_t* rtx) { return ((hawk_rtx_alt_t*)rtx)->_gem.errnum; }
static HAWK_INLINE const hawk_loc_t* hawk_rtx_geterrloc (hawk_rtx_t* rtx) { return hawk_gem_geterrloc(hawk_rtx_getgem(rtx)); }
#else
# define hawk_rtx_geterrnum(rtx) (((hawk_rtx_alt_t*)(rtx))->_gem.errnum)
# define hawk_rtx_geterrloc(rtx) (hawk_gem_geterrloc(hawk_rtx_getgem(rtx)))
#endif
/**
* The hawk_rtx_geterrbmsg() function gets the string describing the last
@ -2645,6 +2650,13 @@ HAWK_EXPORT void hawk_rtx_seterrinf (
const hawk_errinf_t* errinf /**< error information */
);
HAWK_EXPORT void hawk_rtx_seterror (
hawk_rtx_t* rtx,
const hawk_loc_t* errloc,
hawk_errnum_t errnum,
const hawk_oocs_t* errarg
);
HAWK_EXPORT void hawk_rtx_seterrbfmt (
hawk_rtx_t* rtx,
const hawk_loc_t* errloc,

View File

@ -223,7 +223,8 @@ extern "C" {
int hawk_sed_init (
hawk_sed_t* sed,
hawk_mmgr_t* mmgr
hawk_mmgr_t* mmgr,
hawk_cmgr_t* cmgr
);
void hawk_sed_fini (

View File

@ -51,14 +51,14 @@ do { \
static void free_all_cut_selector_blocks (hawk_sed_t* sed, hawk_sed_cmd_t* cmd);
hawk_sed_t* hawk_sed_open (hawk_mmgr_t* mmgr, hawk_oow_t xtnsize, hawk_errnum_t* errnum)
hawk_sed_t* hawk_sed_open (hawk_mmgr_t* mmgr, hawk_oow_t xtnsize, hawk_cmgr_t* cmgr, hawk_errnum_t* errnum)
{
hawk_sed_t* sed;
sed = (hawk_sed_t*)HAWK_MMGR_ALLOC(mmgr, HAWK_SIZEOF(hawk_sed_t) + xtnsize);
if (HAWK_LIKELY(sed))
{
if (hawk_sed_init(sed, mmgr) <= -1)
if (hawk_sed_init(sed, mmgr, cmgr) <= -1)
{
if (errnum) *errnum = hawk_sed_geterrnum(sed);
HAWK_MMGR_FREE (mmgr, sed);
@ -82,13 +82,13 @@ void hawk_sed_close (hawk_sed_t* sed)
HAWK_MMGR_FREE (hawk_sed_getmmgr(sed), sed);
}
int hawk_sed_init (hawk_sed_t* sed, hawk_mmgr_t* mmgr)
int hawk_sed_init (hawk_sed_t* sed, hawk_mmgr_t* mmgr, hawk_cmgr_t* cmgr)
{
HAWK_MEMSET (sed, 0, HAWK_SIZEOF(*sed));
sed->_instsize = HAWK_SIZEOF(*sed);
sed->_gem.mmgr = mmgr;
sed->_gem.cmgr = HAWK_NULL; /* no cmgr used */
sed->_gem.cmgr = cmgr;
/* initialize error handling fields */
sed->_gem.errnum = HAWK_ENOERR;
@ -1889,7 +1889,7 @@ int hawk_sed_comp (hawk_sed_t* sed, hawk_sed_io_impl_t inf)
/* process the first address */
a1_loc = sed->src.loc;
if (get_address (sed, &cmd->a1, 0) == HAWK_NULL)
if (get_address(sed, &cmd->a1, 0) == HAWK_NULL)
{
cmd = HAWK_NULL;
hawk_sed_seterrnum (sed, &sed->src.loc, HAWK_SED_EA1MOI);

View File

@ -135,7 +135,22 @@ int hawk_sio_init (hawk_sio_t* sio, hawk_gem_t* gem, const hawk_ooch_t* path, in
if ((flags & HAWK_SIO_KEEPPATH) && !(flags & HAWK_SIO_HANDLE))
{
#if defined(HAWK_OOCH_IS_BCH)
sio->path = hawk_gem_dupoocstr(gem, path, HAWK_NULL);
#else
if (flags & HAWK_SIO_BCSTRPATH)
{
/* the stored path is always of the hawk_ooch_t type.
* and the conversion uses the cmgr set on the gem object.
* note that cmgr for the actual file content can be set
* with hawk_sio_setcmgr(). */
sio->path = hawk_gem_dupbtoucstr(gem, (const hawk_bch_t*)path, HAWK_NULL, 1);
}
else
{
sio->path = hawk_gem_dupoocstr(gem, path, HAWK_NULL);
}
#endif
if (sio->path == HAWK_NULL) goto oops02;
}
@ -173,7 +188,7 @@ int hawk_sio_initstd (hawk_sio_t* sio, hawk_gem_t* gem, hawk_sio_std_t std, int
int n;
hawk_fio_hnd_t hnd;
if (hawk_get_std_fio_handle (std, &hnd) <= -1) return -1;
if (hawk_get_std_fio_handle(std, &hnd) <= -1) return -1;
n = hawk_sio_init(sio, gem, (const hawk_ooch_t*)&hnd, flags | HAWK_SIO_HANDLE | HAWK_SIO_NOCLOSE);
@ -219,7 +234,9 @@ hawk_sio_hnd_t hawk_sio_gethnd (const hawk_sio_t* sio)
const hawk_ooch_t* hawk_sio_getpath (hawk_sio_t* sio)
{
/* this path is valid if HAWK_SIO_HANDLE is off and HAWK_SIO_KEEPPATH is on */
/* this path is valid if HAWK_SIO_HANDLE is off and HAWK_SIO_KEEPPATH is on.
* HAWK_SIO_BCSTRPATH doesn't affect this value. The opening side ensures it
* to be in the hawk_ooch_type. */
return sio->path;
}

1059
hawk/lib/std-sed.c Normal file

File diff suppressed because it is too large Load Diff

49
hawk/lib/utl-rnd.c Normal file
View File

@ -0,0 +1,49 @@
/*
* $Id$
*
Copyright (c) 2006-2020 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 <hawk-utl.h>
/* Park-Miller "minimal standard" 31 bit
* pseudo-random number generator, implemented
* with David G. Carta's optimisation: with
* 32 bit math and without division.
*/
hawk_uint32_t hawk_rand31 (hawk_uint32_t seed)
{
hawk_uint32_t hi, lo;
if (seed == 0) seed++;
lo = 16807 * (seed & 0xFFFF);
hi = 16807 * (seed >> 16);
lo += (hi & 0x7FFF) << 16;
lo += hi >> 15;
if (lo > 0x7FFFFFFFul) lo -= 0x7FFFFFFFul;
return lo;
}

View File

@ -660,7 +660,7 @@ fini:
hawk_oow_t hawk_copy_ucses_to_uchars (hawk_uch_t* buf, hawk_oow_t bsz, const hawk_uch_t* fmt, const hawk_ucs_t str[])
hawk_oow_t hawk_copy_ufcs_to_uchars (hawk_uch_t* buf, hawk_oow_t bsz, const hawk_uch_t* fmt, const hawk_ucs_t str[])
{
hawk_uch_t* b = buf;
hawk_uch_t* end = buf + bsz - 1;
@ -722,11 +722,11 @@ fini:
return b - buf;
}
hawk_oow_t hawk_copy_bcses_to_bchars (hawk_bch* buf, hawk_oow_t bsz, const hawk_bch* fmt, const hawk_bcs_t str[])
hawk_oow_t hawk_copy_bfcs_to_bchars (hawk_bch_t* buf, hawk_oow_t bsz, const hawk_bch_t* fmt, const hawk_bcs_t str[])
{
hawk_bch* b = buf;
hawk_bch* end = buf + bsz - 1;
const hawk_bch* f = fmt;
hawk_bch_t* b = buf;
hawk_bch_t* end = buf + bsz - 1;
const hawk_bch_t* f = fmt;
if (bsz <= 0) return 0;
@ -744,7 +744,7 @@ hawk_oow_t hawk_copy_bcses_to_bchars (hawk_bch* buf, hawk_oow_t bsz, const hawk_
if (f[1] == HAWK_BT('{') &&
(f[2] >= HAWK_BT('0') && f[2] <= HAWK_BT('9')))
{
const hawk_bch* tmp, * tmpend;
const hawk_bch_t* tmp, * tmpend;
hawk_oow_t idx = 0;
tmp = f;

View File

@ -847,7 +847,7 @@ static int fnc_call (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
if (add_ffi_arg(rtx, ffi_list, ffi_node, fmtc, _unsigned, hawk_rtx_getarg(rtx, j + FNC_CALL_ARG_BASE), &ret) <= -1) goto done;
_unsigned = 0;
j++;
j++; /* increment the total number of arguments */
}
while (i < sig.len && sig.ptr[i] == ' ') i++; /* skip all spaces after > */
@ -868,8 +868,20 @@ static int fnc_call (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
goto done;
}
fs = (nfixedargs == j)? ffi_prep_cif(&ffi->cif, FFI_DEFAULT_ABI, j, ffi->fmtc_to_type[0][fmtc], ffi->arg_types):
ffi_prep_cif_var(&ffi->cif, FFI_DEFAULT_ABI, nfixedargs, j, ffi->fmtc_to_type[0][fmtc], ffi->arg_types);
if (nfixedargs == j)
{
fs = ffi_prep_cif(&ffi->cif, FFI_DEFAULT_ABI, j, ffi->fmtc_to_type[0][fmtc], ffi->arg_types);
}
else
{
#if defined(HAVE_FFI_PREP_CIF_VAR)
fs = ffi_prep_cif_var(&ffi->cif, FFI_DEFAULT_ABI, nfixedargs, j, ffi->fmtc_to_type[0][fmtc], ffi->arg_types);
#else
ret = set_error_on_ffi_list(rtx, ffi_list, HAWK_ENOIMPL, HAWK_T("variadic arguments not supported"));
goto done;
#endif
}
if (fs != FFI_OK)
{
ret = set_error_on_ffi_list(rtx, ffi_list, HAWK_ESYSERR, HAWK_T("unable to prepare the ffi_cif structure"));