added the return type check for unsetenv() in configure.ac
This commit is contained in:
parent
49efdd3caf
commit
749f3d30b6
@ -354,6 +354,7 @@ pdfdir = @pdfdir@
|
|||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
program_transform_name = @program_transform_name@
|
program_transform_name = @program_transform_name@
|
||||||
psdir = @psdir@
|
psdir = @psdir@
|
||||||
|
runstatedir = @runstatedir@
|
||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
@ -323,6 +323,7 @@ pdfdir = @pdfdir@
|
|||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
program_transform_name = @program_transform_name@
|
program_transform_name = @program_transform_name@
|
||||||
psdir = @psdir@
|
psdir = @psdir@
|
||||||
|
runstatedir = @runstatedir@
|
||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
52
hawk/configure
vendored
52
hawk/configure
vendored
@ -785,6 +785,7 @@ infodir
|
|||||||
docdir
|
docdir
|
||||||
oldincludedir
|
oldincludedir
|
||||||
includedir
|
includedir
|
||||||
|
runstatedir
|
||||||
localstatedir
|
localstatedir
|
||||||
sharedstatedir
|
sharedstatedir
|
||||||
sysconfdir
|
sysconfdir
|
||||||
@ -886,6 +887,7 @@ datadir='${datarootdir}'
|
|||||||
sysconfdir='${prefix}/etc'
|
sysconfdir='${prefix}/etc'
|
||||||
sharedstatedir='${prefix}/com'
|
sharedstatedir='${prefix}/com'
|
||||||
localstatedir='${prefix}/var'
|
localstatedir='${prefix}/var'
|
||||||
|
runstatedir='${localstatedir}/run'
|
||||||
includedir='${prefix}/include'
|
includedir='${prefix}/include'
|
||||||
oldincludedir='/usr/include'
|
oldincludedir='/usr/include'
|
||||||
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
|
||||||
@ -1138,6 +1140,15 @@ do
|
|||||||
| -silent | --silent | --silen | --sile | --sil)
|
| -silent | --silent | --silen | --sile | --sil)
|
||||||
silent=yes ;;
|
silent=yes ;;
|
||||||
|
|
||||||
|
-runstatedir | --runstatedir | --runstatedi | --runstated \
|
||||||
|
| --runstate | --runstat | --runsta | --runst | --runs \
|
||||||
|
| --run | --ru | --r)
|
||||||
|
ac_prev=runstatedir ;;
|
||||||
|
-runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
|
||||||
|
| --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
|
||||||
|
| --run=* | --ru=* | --r=*)
|
||||||
|
runstatedir=$ac_optarg ;;
|
||||||
|
|
||||||
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
|
||||||
ac_prev=sbindir ;;
|
ac_prev=sbindir ;;
|
||||||
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
|
||||||
@ -1275,7 +1286,7 @@ fi
|
|||||||
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
|
||||||
datadir sysconfdir sharedstatedir localstatedir includedir \
|
datadir sysconfdir sharedstatedir localstatedir includedir \
|
||||||
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
|
||||||
libdir localedir mandir
|
libdir localedir mandir runstatedir
|
||||||
do
|
do
|
||||||
eval ac_val=\$$ac_var
|
eval ac_val=\$$ac_var
|
||||||
# Remove trailing slashes.
|
# Remove trailing slashes.
|
||||||
@ -1428,6 +1439,7 @@ Fine tuning of the installation directories:
|
|||||||
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
|
||||||
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
|
||||||
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
|
||||||
|
--runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
|
||||||
--libdir=DIR object code libraries [EPREFIX/lib]
|
--libdir=DIR object code libraries [EPREFIX/lib]
|
||||||
--includedir=DIR C header files [PREFIX/include]
|
--includedir=DIR C header files [PREFIX/include]
|
||||||
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
--oldincludedir=DIR C header files for non-gcc [/usr/include]
|
||||||
@ -18050,7 +18062,7 @@ else
|
|||||||
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||||
since some C++ compilers masquerading as C compilers
|
since some C++ compilers masquerading as C compilers
|
||||||
incorrectly reject 9223372036854775807. */
|
incorrectly reject 9223372036854775807. */
|
||||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||||
&& LARGE_OFF_T % 2147483647 == 1)
|
&& LARGE_OFF_T % 2147483647 == 1)
|
||||||
? 1 : -1];
|
? 1 : -1];
|
||||||
@ -18096,7 +18108,7 @@ else
|
|||||||
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||||
since some C++ compilers masquerading as C compilers
|
since some C++ compilers masquerading as C compilers
|
||||||
incorrectly reject 9223372036854775807. */
|
incorrectly reject 9223372036854775807. */
|
||||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||||
&& LARGE_OFF_T % 2147483647 == 1)
|
&& LARGE_OFF_T % 2147483647 == 1)
|
||||||
? 1 : -1];
|
? 1 : -1];
|
||||||
@ -18120,7 +18132,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
|||||||
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||||
since some C++ compilers masquerading as C compilers
|
since some C++ compilers masquerading as C compilers
|
||||||
incorrectly reject 9223372036854775807. */
|
incorrectly reject 9223372036854775807. */
|
||||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||||
&& LARGE_OFF_T % 2147483647 == 1)
|
&& LARGE_OFF_T % 2147483647 == 1)
|
||||||
? 1 : -1];
|
? 1 : -1];
|
||||||
@ -18165,7 +18177,7 @@ else
|
|||||||
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||||
since some C++ compilers masquerading as C compilers
|
since some C++ compilers masquerading as C compilers
|
||||||
incorrectly reject 9223372036854775807. */
|
incorrectly reject 9223372036854775807. */
|
||||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||||
&& LARGE_OFF_T % 2147483647 == 1)
|
&& LARGE_OFF_T % 2147483647 == 1)
|
||||||
? 1 : -1];
|
? 1 : -1];
|
||||||
@ -18189,7 +18201,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
|||||||
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
We can't simply define LARGE_OFF_T to be 9223372036854775807,
|
||||||
since some C++ compilers masquerading as C compilers
|
since some C++ compilers masquerading as C compilers
|
||||||
incorrectly reject 9223372036854775807. */
|
incorrectly reject 9223372036854775807. */
|
||||||
#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
|
#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
|
||||||
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
|
||||||
&& LARGE_OFF_T % 2147483647 == 1)
|
&& LARGE_OFF_T % 2147483647 == 1)
|
||||||
? 1 : -1];
|
? 1 : -1];
|
||||||
@ -20808,6 +20820,34 @@ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of unsetenv()" >&5
|
||||||
|
$as_echo_n "checking return type of unsetenv()... " >&6; }
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
#include <stdlib.h>
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
|
||||||
|
return unsetenv("foo");
|
||||||
|
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
if ac_fn_c_try_compile "$LINENO"; then :
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: int" >&5
|
||||||
|
$as_echo "int" >&6; }
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: void" >&5
|
||||||
|
$as_echo "void" >&6; }
|
||||||
|
|
||||||
|
$as_echo "#define UNSETENV_RETURNS_VOID 1" >>confdefs.h
|
||||||
|
|
||||||
|
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
|
||||||
|
|
||||||
ac_header_dirent=no
|
ac_header_dirent=no
|
||||||
for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
|
for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
|
||||||
as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
|
as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
|
||||||
|
@ -454,6 +454,18 @@ AC_TRY_RUN(
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([return type of unsetenv()])
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM( [#include <stdlib.h>], [
|
||||||
|
return unsetenv("foo");
|
||||||
|
])],
|
||||||
|
|
||||||
|
[AC_MSG_RESULT(int)]
|
||||||
|
|
||||||
|
[AC_MSG_RESULT(void)
|
||||||
|
AC_DEFINE([UNSETENV_RETURNS_VOID], [1], [unsetenv returns int])]
|
||||||
|
)
|
||||||
|
|
||||||
dnl check struct members
|
dnl check struct members
|
||||||
AC_STRUCT_DIRENT_D_TYPE
|
AC_STRUCT_DIRENT_D_TYPE
|
||||||
AC_CHECK_MEMBERS([DIR.d_fd, DIR.dd_fd],,,[[#include <dirent.h>]])
|
AC_CHECK_MEMBERS([DIR.d_fd, DIR.dd_fd],,,[[#include <dirent.h>]])
|
||||||
|
@ -562,6 +562,7 @@ pdfdir = @pdfdir@
|
|||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
program_transform_name = @program_transform_name@
|
program_transform_name = @program_transform_name@
|
||||||
psdir = @psdir@
|
psdir = @psdir@
|
||||||
|
runstatedir = @runstatedir@
|
||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
@ -1036,6 +1036,9 @@
|
|||||||
/* Define to 1 if you have the ANSI C header files. */
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
#undef STDC_HEADERS
|
#undef STDC_HEADERS
|
||||||
|
|
||||||
|
/* unsetenv returns int */
|
||||||
|
#undef UNSETENV_RETURNS_VOID
|
||||||
|
|
||||||
/* Version number of package */
|
/* Version number of package */
|
||||||
#undef VERSION
|
#undef VERSION
|
||||||
|
|
||||||
|
@ -613,27 +613,93 @@ int hawk_buildrex (hawk_t* hawk, const hawk_ooch_t* ptn, hawk_oow_t len, hawk_tr
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
int hawk_finmodsymfnc (hawk_t* hawk, hawk_mod_fnc_tab_t* fnctab, hawk_oow_t count, const hawk_ooch_t* name, hawk_oow_t namelen, hawk_mod_sym_t* sym)
|
int hawk_findmodsymfnc_noerr (hawk_t* hawk, hawk_mod_fnc_tab_t* fnctab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
/* binary search */
|
/* binary search */
|
||||||
/* [NOTE] this algorithm is underflow safe with hawk_oow_t types */
|
|
||||||
hawk_oow_t base, mid, lim;
|
hawk_oow_t base, mid, lim;
|
||||||
|
|
||||||
for (base = 0, lim = count; lim > 0; lim >>= 1)
|
for (base = 0, lim = count; lim > 0; lim >>= 1)
|
||||||
{
|
{
|
||||||
mid = base + (lim >> 1);
|
mid = base + (lim >> 1);
|
||||||
n = hawk_comp_oochars_oocstr(name, namelen, fnctab[mid].name);
|
n = hawk_comp_oocstr(name, fnctab[mid].name, 0);
|
||||||
if (n == 0)
|
if (n == 0)
|
||||||
{
|
{
|
||||||
sym->type = HAWK_MOD_FNC;
|
sym->type = HAWK_MOD_FNC;
|
||||||
sym->u.fnc = fnctab[mid].info;
|
sym->u.fnc_ = fnctab[mid].info;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (n > 0) { base = mid + 1; lim--; }
|
if (n > 0) { base = mid + 1; lim--; }
|
||||||
}
|
}
|
||||||
|
|
||||||
hawk_seterrbfmt (hawk, HAWK_NULL, HAWK_ENOENT, "'%js' not found", name);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int hawk_findmodsymint_noerr (hawk_t* hawk, hawk_mod_int_tab_t* inttab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
/* binary search */
|
||||||
|
hawk_oow_t base, mid, lim;
|
||||||
|
|
||||||
|
for (base = 0, lim = count; lim > 0; lim >>= 1)
|
||||||
|
{
|
||||||
|
mid = base + (lim >> 1);
|
||||||
|
n = hawk_comp_oocstr(name, inttab[mid].name, 0);
|
||||||
|
if (n == 0)
|
||||||
|
{
|
||||||
|
sym->type = HAWK_MOD_INT;
|
||||||
|
sym->u.int_ = inttab[mid].info;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (n > 0) { base = mid + 1; lim--; }
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hawk_findmodsymflt_noerr (hawk_t* hawk, hawk_mod_flt_tab_t* flttab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
/* binary search */
|
||||||
|
hawk_oow_t base, mid, lim;
|
||||||
|
|
||||||
|
for (base = 0, lim = count; lim > 0; lim >>= 1)
|
||||||
|
{
|
||||||
|
mid = base + (lim >> 1);
|
||||||
|
n = hawk_comp_oocstr(name, flttab[mid].name, 0);
|
||||||
|
if (n == 0)
|
||||||
|
{
|
||||||
|
sym->type = HAWK_MOD_FLT;
|
||||||
|
sym->u.flt_ = flttab[mid].info;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (n > 0) { base = mid + 1; lim--; }
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hawk_findmodsymfnc (hawk_t* hawk, hawk_mod_fnc_tab_t* fnctab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
|
{
|
||||||
|
int n = hawk_findmodsymfnc_noerr(hawk, fnctab, count, name, sym);
|
||||||
|
if (n <= -1) hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hawk_findmodsymint (hawk_t* hawk, hawk_mod_int_tab_t* inttab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
|
{
|
||||||
|
int n = hawk_findmodsymint_noerr(hawk, inttab, count, name, sym);
|
||||||
|
if (n <= -1) hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
int hawk_findmodsymflt (hawk_t* hawk, hawk_mod_flt_tab_t* flttab, hawk_oow_t count, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
|
{
|
||||||
|
int n = hawk_findmodsymflt_noerr(hawk, flttab, count, name, sym);
|
||||||
|
if (n <= -1) hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
@ -1028,11 +1028,13 @@ typedef struct hawk_mod_sym_flt_t hawk_mod_sym_flt_t;
|
|||||||
struct hawk_mod_sym_int_t
|
struct hawk_mod_sym_int_t
|
||||||
{
|
{
|
||||||
hawk_int_t val;
|
hawk_int_t val;
|
||||||
|
int trait;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hawk_mod_sym_flt_t
|
struct hawk_mod_sym_flt_t
|
||||||
{
|
{
|
||||||
hawk_flt_t val;
|
hawk_flt_t val;
|
||||||
|
int trait;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct hawk_mod_sym_t
|
struct hawk_mod_sym_t
|
||||||
@ -1040,9 +1042,9 @@ struct hawk_mod_sym_t
|
|||||||
hawk_mod_sym_type_t type;
|
hawk_mod_sym_type_t type;
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
hawk_mod_sym_fnc_t fnc;
|
hawk_mod_sym_fnc_t fnc_;
|
||||||
hawk_mod_sym_int_t in;
|
hawk_mod_sym_int_t int_;
|
||||||
hawk_mod_sym_flt_t flt;
|
hawk_mod_sym_flt_t flt_;
|
||||||
} u;
|
} u;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1055,6 +1057,20 @@ struct hawk_mod_fnc_tab_t
|
|||||||
hawk_mod_sym_fnc_t info;
|
hawk_mod_sym_fnc_t info;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct hawk_mod_int_tab_t hawk_mod_int_tab_t;
|
||||||
|
struct hawk_mod_int_tab_t
|
||||||
|
{
|
||||||
|
const hawk_ooch_t* name;
|
||||||
|
hawk_mod_sym_int_t info;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct hawk_mod_flt_tab_t hawk_mod_flt_tab_t;
|
||||||
|
struct hawk_mod_flt_tab_t
|
||||||
|
{
|
||||||
|
const hawk_ooch_t* name;
|
||||||
|
hawk_mod_sym_flt_t info;
|
||||||
|
};
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1910,6 +1926,58 @@ HAWK_EXPORT int hawk_isvalidident (
|
|||||||
const hawk_ooch_t* str
|
const hawk_ooch_t* str
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
HAWK_EXPORT int hawk_findmodsymfnc_noerr (
|
||||||
|
hawk_t* hawk,
|
||||||
|
hawk_mod_fnc_tab_t* fnctab,
|
||||||
|
hawk_oow_t count,
|
||||||
|
const hawk_ooch_t* name,
|
||||||
|
hawk_mod_sym_t* sym
|
||||||
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT int hawk_findmodsymint_noerr (
|
||||||
|
hawk_t* hawk,
|
||||||
|
hawk_mod_int_tab_t* inttab,
|
||||||
|
hawk_oow_t count,
|
||||||
|
const hawk_ooch_t* name,
|
||||||
|
hawk_mod_sym_t* sym
|
||||||
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT int hawk_findmodsymflt_noerr (
|
||||||
|
hawk_t* hawk,
|
||||||
|
hawk_mod_flt_tab_t* flttab,
|
||||||
|
hawk_oow_t count,
|
||||||
|
const hawk_ooch_t* name,
|
||||||
|
hawk_mod_sym_t* sym
|
||||||
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT int hawk_findmodsymfnc (
|
||||||
|
hawk_t* hawk,
|
||||||
|
hawk_mod_fnc_tab_t* fnctab,
|
||||||
|
hawk_oow_t count,
|
||||||
|
const hawk_ooch_t* name,
|
||||||
|
hawk_mod_sym_t* sym
|
||||||
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT int hawk_findmodsymint (
|
||||||
|
hawk_t* hawk,
|
||||||
|
hawk_mod_int_tab_t* inttab,
|
||||||
|
hawk_oow_t count,
|
||||||
|
const hawk_ooch_t* name,
|
||||||
|
hawk_mod_sym_t* sym
|
||||||
|
);
|
||||||
|
|
||||||
|
HAWK_EXPORT int hawk_findmodsymflt (
|
||||||
|
hawk_t* hawk,
|
||||||
|
hawk_mod_flt_tab_t* flttab,
|
||||||
|
hawk_oow_t count,
|
||||||
|
const hawk_ooch_t* name,
|
||||||
|
hawk_mod_sym_t* sym
|
||||||
|
);
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
#if defined(HAWK_HAVE_INLINE)
|
#if defined(HAWK_HAVE_INLINE)
|
||||||
static HAWK_INLINE void* hawk_allocmem (hawk_t* hawk, hawk_oow_t size) { return hawk_gem_allocmem(hawk_getgem(hawk), size); }
|
static HAWK_INLINE void* hawk_allocmem (hawk_t* hawk, hawk_oow_t size) { return hawk_gem_allocmem(hawk_getgem(hawk), size); }
|
||||||
static HAWK_INLINE void* hawk_reallocmem (hawk_t* hawk, void* ptr, hawk_oow_t size) { return hawk_gem_reallocmem(hawk_getgem(hawk), ptr, size); }
|
static HAWK_INLINE void* hawk_reallocmem (hawk_t* hawk, void* ptr, hawk_oow_t size) { return hawk_gem_reallocmem(hawk_getgem(hawk), ptr, size); }
|
||||||
|
@ -393,23 +393,9 @@ static int fnc_typename (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
|||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct fnctab_t fnctab_t;
|
|
||||||
struct fnctab_t
|
|
||||||
{
|
|
||||||
const hawk_ooch_t* name;
|
|
||||||
hawk_mod_sym_fnc_t info;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct inttab_t inttab_t;
|
|
||||||
struct inttab_t
|
|
||||||
{
|
|
||||||
const hawk_ooch_t* name;
|
|
||||||
hawk_mod_sym_int_t info;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define A_MAX HAWK_TYPE_MAX(hawk_oow_t)
|
#define A_MAX HAWK_TYPE_MAX(hawk_oow_t)
|
||||||
|
|
||||||
static fnctab_t fnctab[] =
|
static hawk_mod_fnc_tab_t fnctab[] =
|
||||||
{
|
{
|
||||||
/* keep this table sorted for binary search in query(). */
|
/* keep this table sorted for binary search in query(). */
|
||||||
{ HAWK_T("array"), { { 0, A_MAX, HAWK_NULL }, fnc_array, 0 } },
|
{ HAWK_T("array"), { { 0, A_MAX, HAWK_NULL }, fnc_array, 0 } },
|
||||||
@ -428,7 +414,7 @@ static fnctab_t fnctab[] =
|
|||||||
{ HAWK_T("typename"), { { 1, 1, HAWK_NULL }, fnc_typename, 0 } }
|
{ HAWK_T("typename"), { { 1, 1, HAWK_NULL }, fnc_typename, 0 } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static inttab_t inttab[] =
|
static hawk_mod_int_tab_t inttab[] =
|
||||||
{
|
{
|
||||||
/* keep this table sorted for binary search in query(). */
|
/* keep this table sorted for binary search in query(). */
|
||||||
{ HAWK_T("GC_NUM_GENS"), { HAWK_GC_NUM_GENS } }
|
{ HAWK_T("GC_NUM_GENS"), { HAWK_GC_NUM_GENS } }
|
||||||
@ -436,43 +422,8 @@ static inttab_t inttab[] =
|
|||||||
|
|
||||||
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
{
|
{
|
||||||
int left, right, mid, n;
|
if (hawk_findmodsymfnc_noerr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||||
|
return hawk_findmodsymint(hawk, inttab, HAWK_COUNTOF(inttab), name, sym);
|
||||||
left = 0; right = HAWK_COUNTOF(fnctab) - 1;
|
|
||||||
|
|
||||||
while (left <= right)
|
|
||||||
{
|
|
||||||
mid = left + (right - left) / 2;
|
|
||||||
|
|
||||||
n = hawk_comp_oocstr(fnctab[mid].name, name, 0);
|
|
||||||
if (n > 0) right = mid - 1;
|
|
||||||
else if (n < 0) left = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sym->type = HAWK_MOD_FNC;
|
|
||||||
sym->u.fnc = fnctab[mid].info;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
left = 0; right = HAWK_COUNTOF(inttab) - 1;
|
|
||||||
while (left <= right)
|
|
||||||
{
|
|
||||||
mid = left + (right - left) / 2;
|
|
||||||
|
|
||||||
n = hawk_comp_oocstr(inttab[mid].name, name, 0);
|
|
||||||
if (n > 0) right = mid - 1;
|
|
||||||
else if (n < 0) left = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sym->type = HAWK_MOD_INT;
|
|
||||||
sym->u.in = inttab[mid].info;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init (hawk_mod_t* mod, hawk_rtx_t* rtx)
|
static int init (hawk_mod_t* mod, hawk_rtx_t* rtx)
|
||||||
|
@ -605,14 +605,7 @@ static int fnc_srand (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
|||||||
|
|
||||||
/* ----------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct fnctab_t fnctab_t;
|
static hawk_mod_fnc_tab_t fnctab[] =
|
||||||
struct fnctab_t
|
|
||||||
{
|
|
||||||
const hawk_ooch_t* name;
|
|
||||||
hawk_mod_sym_fnc_t info;
|
|
||||||
};
|
|
||||||
|
|
||||||
static fnctab_t fnctab[] =
|
|
||||||
{
|
{
|
||||||
/* keep this table sorted for binary search in query(). */
|
/* keep this table sorted for binary search in query(). */
|
||||||
{ HAWK_T("acos"), { { 1, 1, HAWK_NULL }, fnc_acos, 0 } },
|
{ HAWK_T("acos"), { { 1, 1, HAWK_NULL }, fnc_acos, 0 } },
|
||||||
@ -639,45 +632,7 @@ static fnctab_t fnctab[] =
|
|||||||
|
|
||||||
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
{
|
{
|
||||||
int left, right, mid, n;
|
return hawk_findmodsymfnc(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym);
|
||||||
|
|
||||||
left = 0; right = HAWK_COUNTOF(fnctab) - 1;
|
|
||||||
|
|
||||||
while (left <= right)
|
|
||||||
{
|
|
||||||
mid = left + (right - left) / 2;
|
|
||||||
|
|
||||||
n = hawk_comp_oocstr(fnctab[mid].name, name, 0);
|
|
||||||
if (n > 0) right = mid - 1;
|
|
||||||
else if (n < 0) left = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sym->type = HAWK_MOD_FNC;
|
|
||||||
sym->u.fnc = fnctab[mid].info;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
left = 0; right = HAWK_COUNTOF(inttab) - 1;
|
|
||||||
while (left <= right)
|
|
||||||
{
|
|
||||||
mid = left + (right - left) / 2;
|
|
||||||
|
|
||||||
n = hawk_comp_oocstr(inttab[mid].name, name, 0);
|
|
||||||
if (n > 0) right = mid - 1;
|
|
||||||
else if (n < 0) left = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sym->type = HAWK_MOD_INT;
|
|
||||||
sym->u.in = inttab[mid].info;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: proper resource management */
|
/* TODO: proper resource management */
|
||||||
|
@ -745,23 +745,11 @@ static int fnc_subchar (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct fnctab_t fnctab_t;
|
/* ----------------------------------------------------------------------- */
|
||||||
struct fnctab_t
|
|
||||||
{
|
|
||||||
const hawk_ooch_t* name;
|
|
||||||
hawk_mod_sym_fnc_t info;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct inttab_t inttab_t;
|
|
||||||
struct inttab_t
|
|
||||||
{
|
|
||||||
const hawk_ooch_t* name;
|
|
||||||
hawk_mod_sym_int_t info;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define A_MAX HAWK_TYPE_MAX(hawk_oow_t)
|
#define A_MAX HAWK_TYPE_MAX(hawk_oow_t)
|
||||||
|
|
||||||
static fnctab_t fnctab[] =
|
static hawk_mod_fnc_tab_t fnctab[] =
|
||||||
{
|
{
|
||||||
/* keep this table sorted for binary search in query(). */
|
/* keep this table sorted for binary search in query(). */
|
||||||
{ HAWK_T("frombcharcode"), { { 0, A_MAX, HAWK_NULL }, fnc_frombcharcode, 0 } },
|
{ HAWK_T("frombcharcode"), { { 0, A_MAX, HAWK_NULL }, fnc_frombcharcode, 0 } },
|
||||||
@ -801,7 +789,7 @@ static fnctab_t fnctab[] =
|
|||||||
{ HAWK_T("trim"), { { 1, 2, HAWK_NULL }, fnc_trim, 0 } }
|
{ HAWK_T("trim"), { { 1, 2, HAWK_NULL }, fnc_trim, 0 } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static inttab_t inttab[] =
|
static hawk_mod_int_tab_t inttab[] =
|
||||||
{
|
{
|
||||||
/* keep this table sorted for binary search in query(). */
|
/* keep this table sorted for binary search in query(). */
|
||||||
{ HAWK_T("TRIM_PAC_SPACES"), { TRIM_FLAG_PAC_SPACES } }
|
{ HAWK_T("TRIM_PAC_SPACES"), { TRIM_FLAG_PAC_SPACES } }
|
||||||
@ -809,43 +797,8 @@ static inttab_t inttab[] =
|
|||||||
|
|
||||||
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
{
|
{
|
||||||
int left, right, mid, n;
|
if (hawk_findmodsymfnc_noerr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||||
|
return hawk_findmodsymint(hawk, inttab, HAWK_COUNTOF(inttab), name, sym);
|
||||||
left = 0; right = HAWK_COUNTOF(fnctab) - 1;
|
|
||||||
|
|
||||||
while (left <= right)
|
|
||||||
{
|
|
||||||
mid = left + (right - left) / 2;
|
|
||||||
|
|
||||||
n = hawk_comp_oocstr(fnctab[mid].name, name, 0);
|
|
||||||
if (n > 0) right = mid - 1;
|
|
||||||
else if (n < 0) left = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sym->type = HAWK_MOD_FNC;
|
|
||||||
sym->u.fnc = fnctab[mid].info;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
left = 0; right = HAWK_COUNTOF(inttab) - 1;
|
|
||||||
while (left <= right)
|
|
||||||
{
|
|
||||||
mid = left + (right - left) / 2;
|
|
||||||
|
|
||||||
n = hawk_comp_oocstr(inttab[mid].name, name, 0);
|
|
||||||
if (n > 0) right = mid - 1;
|
|
||||||
else if (n < 0) left = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sym->type = HAWK_MOD_INT;
|
|
||||||
sym->u.in = inttab[mid].info;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: proper resource management */
|
/* TODO: proper resource management */
|
||||||
|
@ -2832,8 +2832,13 @@ static int fnc_unsetenv (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(UNSETENV_RETURNS_VOID)
|
||||||
|
unsetenv(str);
|
||||||
|
rx = 0;
|
||||||
|
#else
|
||||||
rx = unsetenv(str);
|
rx = unsetenv(str);
|
||||||
if (rx <= -1) rx = set_error_on_sys_list_with_errno(rtx, sys_list, HAWK_NULL);
|
if (rx <= -1) rx = set_error_on_sys_list_with_errno(rtx, sys_list, HAWK_NULL);
|
||||||
|
#endif
|
||||||
|
|
||||||
done:
|
done:
|
||||||
if (str) hawk_rtx_freevalbcstr (rtx, a0, str);
|
if (str) hawk_rtx_freevalbcstr (rtx, a0, str);
|
||||||
@ -5794,25 +5799,11 @@ fail:
|
|||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------- */
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
typedef struct fnctab_t fnctab_t;
|
|
||||||
struct fnctab_t
|
|
||||||
{
|
|
||||||
const hawk_ooch_t* name;
|
|
||||||
hawk_mod_sym_fnc_t info;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct inttab_t inttab_t;
|
|
||||||
struct inttab_t
|
|
||||||
{
|
|
||||||
const hawk_ooch_t* name;
|
|
||||||
hawk_mod_sym_int_t info;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define A_MAX HAWK_TYPE_MAX(hawk_oow_t)
|
#define A_MAX HAWK_TYPE_MAX(hawk_oow_t)
|
||||||
|
|
||||||
static fnctab_t fnctab[] =
|
static hawk_mod_fnc_tab_t fnctab[] =
|
||||||
{
|
{
|
||||||
/* keep this table sorted for binary search in query(). */
|
/* keep this table sorted for binary search in query(). */
|
||||||
|
|
||||||
@ -5921,7 +5912,7 @@ static fnctab_t fnctab[] =
|
|||||||
# define SIGTERM 15
|
# define SIGTERM 15
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inttab_t inttab[] =
|
static hawk_mod_int_tab_t inttab[] =
|
||||||
{
|
{
|
||||||
/* keep this table sorted for binary search in query(). */
|
/* keep this table sorted for binary search in query(). */
|
||||||
|
|
||||||
@ -6217,43 +6208,8 @@ static inttab_t inttab[] =
|
|||||||
|
|
||||||
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
{
|
{
|
||||||
int left, right, mid, n;
|
if (hawk_findmodsymfnc_noerr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||||
|
return hawk_findmodsymint(hawk, inttab, HAWK_COUNTOF(inttab), name, sym);
|
||||||
left = 0; right = HAWK_COUNTOF(fnctab) - 1;
|
|
||||||
|
|
||||||
while (left <= right)
|
|
||||||
{
|
|
||||||
mid = left + (right - left) / 2;
|
|
||||||
|
|
||||||
n = hawk_comp_oocstr(fnctab[mid].name, name, 0);
|
|
||||||
if (n > 0) right = mid - 1;
|
|
||||||
else if (n < 0) left = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sym->type = HAWK_MOD_FNC;
|
|
||||||
sym->u.fnc = fnctab[mid].info;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
left = 0; right = HAWK_COUNTOF(inttab) - 1;
|
|
||||||
while (left <= right)
|
|
||||||
{
|
|
||||||
mid = left + (right - left) / 2;
|
|
||||||
|
|
||||||
n = hawk_comp_oocstr(inttab[mid].name, name, 0);
|
|
||||||
if (n > 0) right = mid - 1;
|
|
||||||
else if (n < 0) left = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sym->type = HAWK_MOD_INT;
|
|
||||||
sym->u.in = inttab[mid].info;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hawk_seterrfmt (hawk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: proper resource management */
|
/* TODO: proper resource management */
|
||||||
|
@ -5639,7 +5639,7 @@ static hawk_nde_t* parse_primary_ident_segs (hawk_t* hawk, const hawk_loc_t* xlo
|
|||||||
hawk_fnc_t fnc;
|
hawk_fnc_t fnc;
|
||||||
|
|
||||||
mod = query_module(hawk, segs, nsegs, &sym);
|
mod = query_module(hawk, segs, nsegs, &sym);
|
||||||
if (mod == HAWK_NULL)
|
if (!mod)
|
||||||
{
|
{
|
||||||
ADJERR_LOC (hawk, xloc);
|
ADJERR_LOC (hawk, xloc);
|
||||||
}
|
}
|
||||||
@ -5648,7 +5648,7 @@ static hawk_nde_t* parse_primary_ident_segs (hawk_t* hawk, const hawk_loc_t* xlo
|
|||||||
switch (sym.type)
|
switch (sym.type)
|
||||||
{
|
{
|
||||||
case HAWK_MOD_FNC:
|
case HAWK_MOD_FNC:
|
||||||
if ((hawk->opt.trait & sym.u.fnc.trait) != sym.u.fnc.trait)
|
if ((hawk->opt.trait & sym.u.fnc_.trait) != sym.u.fnc_.trait)
|
||||||
{
|
{
|
||||||
hawk_seterrfmt (hawk, xloc, HAWK_EUNDEF, FMT_EUNDEF, full->len, full->ptr);
|
hawk_seterrfmt (hawk, xloc, HAWK_EUNDEF, FMT_EUNDEF, full->len, full->ptr);
|
||||||
break;
|
break;
|
||||||
@ -5659,7 +5659,7 @@ static hawk_nde_t* parse_primary_ident_segs (hawk_t* hawk, const hawk_loc_t* xlo
|
|||||||
HAWK_MEMSET (&fnc, 0, HAWK_SIZEOF(fnc));
|
HAWK_MEMSET (&fnc, 0, HAWK_SIZEOF(fnc));
|
||||||
fnc.name.ptr = full->ptr;
|
fnc.name.ptr = full->ptr;
|
||||||
fnc.name.len = full->len;
|
fnc.name.len = full->len;
|
||||||
fnc.spec = sym.u.fnc;
|
fnc.spec = sym.u.fnc_;
|
||||||
fnc.mod = mod;
|
fnc.mod = mod;
|
||||||
nde = parse_fncall(hawk, full, &fnc, xloc, 0);
|
nde = parse_fncall(hawk, full, &fnc, xloc, 0);
|
||||||
}
|
}
|
||||||
@ -5670,12 +5670,24 @@ static hawk_nde_t* parse_primary_ident_segs (hawk_t* hawk, const hawk_loc_t* xlo
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HAWK_MOD_INT:
|
case HAWK_MOD_INT:
|
||||||
nde = new_int_node(hawk, sym.u.in.val, xloc);
|
if ((hawk->opt.trait & sym.u.int_.trait) != sym.u.int_.trait)
|
||||||
|
{
|
||||||
|
hawk_seterrfmt (hawk, xloc, HAWK_EUNDEF, FMT_EUNDEF, full->len, full->ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
nde = new_int_node(hawk, sym.u.int_.val, xloc);
|
||||||
/* i don't remember the symbol in the original form */
|
/* i don't remember the symbol in the original form */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HAWK_MOD_FLT:
|
case HAWK_MOD_FLT:
|
||||||
nde = new_flt_node(hawk, sym.u.flt.val, xloc);
|
if ((hawk->opt.trait & sym.u.flt_.trait) != sym.u.flt_.trait)
|
||||||
|
{
|
||||||
|
hawk_seterrfmt (hawk, xloc, HAWK_EUNDEF, FMT_EUNDEF, full->len, full->ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
nde = new_flt_node(hawk, sym.u.flt_.val, xloc);
|
||||||
/* i don't remember the symbol in the original form */
|
/* i don't remember the symbol in the original form */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -399,6 +399,7 @@ pdfdir = @pdfdir@
|
|||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
program_transform_name = @program_transform_name@
|
program_transform_name = @program_transform_name@
|
||||||
psdir = @psdir@
|
psdir = @psdir@
|
||||||
|
runstatedir = @runstatedir@
|
||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
@ -23,10 +23,11 @@
|
|||||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
#if 0
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
#include "mod-ffi.h"
|
#include "mod-ffi.h"
|
||||||
#include <hawk-utl.h>
|
#include <hawk-utl.h>
|
||||||
|
#include "../lib/hawk-prv.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -154,6 +155,17 @@ struct ffi_t
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#define __IDMAP_NODE_T_DATA ffi_t ffi;
|
||||||
|
#define __IDMAP_LIST_T_DATA int errnum; hawk_ooch_t errmsg[256];
|
||||||
|
#define __IDMAP_LIST_T ffi_list_t
|
||||||
|
#define __IDMAP_NODE_T ffi_node_t
|
||||||
|
#define __INIT_IDMAP_LIST __init_ffi_list
|
||||||
|
#define __FINI_IDMAP_LIST __fini_ffi_list
|
||||||
|
#define __MAKE_IDMAP_NODE __new_ffi_node
|
||||||
|
#define __FREE_IDMAP_NODE __free_ffi_node
|
||||||
|
#include "../lib/idmap-imp.h"
|
||||||
|
|
||||||
|
|
||||||
static HAWK_INLINE void link_ca (ffi_t* ffi, void* ptr)
|
static HAWK_INLINE void link_ca (ffi_t* ffi, void* ptr)
|
||||||
{
|
{
|
||||||
link_t* l = (link_t*)((hawk_oob_t*)ptr - HAWK_SIZEOF_VOID_P);
|
link_t* l = (link_t*)((hawk_oob_t*)ptr - HAWK_SIZEOF_VOID_P);
|
||||||
@ -172,39 +184,17 @@ static void free_linked_cas (hawk_t* hawk, ffi_t* ffi)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static hawk_pfrc_t fnc_open (hawk_t* hawk, hawk_mod_t* mod, hawk_ooi_t nargs)
|
static int fnc_open (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||||
{
|
{
|
||||||
|
hawk_t* hawk = hawk_rtx_gethawk(rtx);
|
||||||
ffi_t* ffi;
|
ffi_t* ffi;
|
||||||
hawk_oop_t name;
|
hawk_mod_spec_t spec;
|
||||||
void* handle;
|
void* handle;
|
||||||
#if defined(USE_DYNCALL)
|
#if defined(USE_DYNCALL)
|
||||||
DCCallVM* dc;
|
DCCallVM* dc;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HAWK_ASSERT (hawk, nargs == 1);
|
handle = hawk->prm.modopen(hawk, &spec);
|
||||||
|
|
||||||
ffi = (ffi_t*)hawk_getobjtrailer(hawk, HAWK_STACK_GETRCV(hawk, nargs), HAWK_NULL);
|
|
||||||
name = HAWK_STACK_GETARG(hawk, nargs, 0);
|
|
||||||
|
|
||||||
if (!HAWK_OBJ_IS_CHAR_POINTER(name))
|
|
||||||
{
|
|
||||||
hawk_seterrnum (hawk, HAWK_EINVAL);
|
|
||||||
goto softfail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hawk->vmprim.dl_open)
|
|
||||||
{
|
|
||||||
hawk_seterrnum (hawk, HAWK_ENOIMPL);
|
|
||||||
goto softfail;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ffi->handle)
|
|
||||||
{
|
|
||||||
hawk_seterrnum (hawk, HAWK_EPERM); /* no allowed to open again */
|
|
||||||
goto softfail;
|
|
||||||
}
|
|
||||||
|
|
||||||
handle = hawk->vmprim.dl_open(hawk, HAWK_OBJ_GET_CHAR_SLOT(name), 0);
|
|
||||||
if (!handle) goto softfail;
|
if (!handle) goto softfail;
|
||||||
|
|
||||||
#if defined(USE_DYNCALL)
|
#if defined(USE_DYNCALL)
|
||||||
@ -254,7 +244,6 @@ static hawk_pfrc_t fnc_open (hawk_t* hawk, hawk_mod_t* mod, hawk_ooi_t nargs)
|
|||||||
ffi->fmtc_to_type[1][FMTC_UCS] = &ffi_type_pointer;
|
ffi->fmtc_to_type[1][FMTC_UCS] = &ffi_type_pointer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HAWK_DEBUG3 (hawk, "<ffi.open> %.*js => %p\n", HAWK_OBJ_GET_SIZE(name), HAWK_OBJ_GET_CHAR_SLOT(name), ffi->handle);
|
|
||||||
HAWK_STACK_SETRETTORCV (hawk, nargs);
|
HAWK_STACK_SETRETTORCV (hawk, nargs);
|
||||||
return HAWK_PF_SUCCESS;
|
return HAWK_PF_SUCCESS;
|
||||||
|
|
||||||
@ -1199,12 +1188,7 @@ softfail:
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
#define C HAWK_METHOD_CLASS
|
static hawk_mod_fnc_tab_t fnctab[] =
|
||||||
#define I HAWK_METHOD_INSTANCE
|
|
||||||
|
|
||||||
#define MA HAWK_TYPE_MAX(hawk_oow_t)
|
|
||||||
|
|
||||||
static hawk_mod_fnc_tab_t pfinfos[] =
|
|
||||||
{
|
{
|
||||||
{ HAWK_T("call"), { { 3, 3, HAWK_NULL }, fnc_call, 0 } },
|
{ HAWK_T("call"), { { 3, 3, HAWK_NULL }, fnc_call, 0 } },
|
||||||
{ HAWK_T("close"), { { 0, 0, HAWK_NULL }, fnc_close, 0 } },
|
{ HAWK_T("close"), { { 0, 0, HAWK_NULL }, fnc_close, 0 } },
|
||||||
@ -1214,18 +1198,11 @@ static hawk_mod_fnc_tab_t pfinfos[] =
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
static int import (hawk_t* hawk, hawk_mod_t* mod, hawk_oop_class_t _class)
|
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
{
|
{
|
||||||
if (hawk_setclasstrsize(hawk, _class, HAWK_SIZEOF(ffi_t), HAWK_NULL) <= -1) return -1;
|
return hawk_findmodsymfnc(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
|
||||||
{
|
|
||||||
///hawk_findmodsymfnc(hawk, pfinfos, HAWK_COUNTOF(pfinfos), name, namelen);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void unload (hawk_t* hawk, hawk_mod_t* mod)
|
static void unload (hawk_t* hawk, hawk_mod_t* mod)
|
||||||
{
|
{
|
||||||
/* TODO: anything? close open open dll handles? For that, fnc_open must store the value it returns to mod->ctx or somewhere..*/
|
/* TODO: anything? close open open dll handles? For that, fnc_open must store the value it returns to mod->ctx or somewhere..*/
|
||||||
@ -1234,12 +1211,9 @@ static void unload (hawk_t* hawk, hawk_mod_t* mod)
|
|||||||
|
|
||||||
int hawk_mod_ffi (hawk_t* hawk, hawk_mod_t* mod)
|
int hawk_mod_ffi (hawk_t* hawk, hawk_mod_t* mod)
|
||||||
{
|
{
|
||||||
mod->import = import;
|
|
||||||
mod->query = query;
|
mod->query = query;
|
||||||
mod->unload = unload;
|
mod->unload = unload;
|
||||||
mod->ctx = HAWK_NULL;
|
mod->ctx = HAWK_NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1773,24 +1773,12 @@ done:
|
|||||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret));
|
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, ret));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
typedef struct fnctab_t fnctab_t;
|
|
||||||
struct fnctab_t
|
|
||||||
{
|
|
||||||
const hawk_ooch_t* name;
|
|
||||||
hawk_mod_sym_fnc_t info;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct inttab_t inttab_t;
|
|
||||||
struct inttab_t
|
|
||||||
{
|
|
||||||
const hawk_ooch_t* name;
|
|
||||||
hawk_mod_sym_int_t info;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/* ----------------------------------------------------------------------- */
|
||||||
|
|
||||||
#define A_MAX HAWK_TYPE_MAX(int)
|
#define A_MAX HAWK_TYPE_MAX(int)
|
||||||
|
|
||||||
static fnctab_t fnctab[] =
|
static hawk_mod_fnc_tab_t fnctab[] =
|
||||||
{
|
{
|
||||||
/* keep this table sorted for binary search in query(). */
|
/* keep this table sorted for binary search in query(). */
|
||||||
{ HAWK_T("affected_rows"), { { 2, 2, HAWK_T("vr") }, fnc_affected_rows, 0 } },
|
{ HAWK_T("affected_rows"), { { 2, 2, HAWK_T("vr") }, fnc_affected_rows, 0 } },
|
||||||
@ -1822,7 +1810,7 @@ static fnctab_t fnctab[] =
|
|||||||
{ HAWK_T("store_result"), { { 1, 1, HAWK_NULL }, fnc_store_result, 0 } }
|
{ HAWK_T("store_result"), { { 1, 1, HAWK_NULL }, fnc_store_result, 0 } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static inttab_t inttab[] =
|
static hawk_mod_int_tab_t inttab[] =
|
||||||
{
|
{
|
||||||
/* keep this table sorted for binary search in query(). */
|
/* keep this table sorted for binary search in query(). */
|
||||||
{ HAWK_T("OPT_CONNECT_TIMEOUT"), { MYSQL_OPT_CONNECT_TIMEOUT } },
|
{ HAWK_T("OPT_CONNECT_TIMEOUT"), { MYSQL_OPT_CONNECT_TIMEOUT } },
|
||||||
@ -1840,46 +1828,10 @@ static inttab_t inttab[] =
|
|||||||
{ HAWK_T("TYPE_STR"), { MYSQL_TYPE_STRING } }
|
{ HAWK_T("TYPE_STR"), { MYSQL_TYPE_STRING } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
static int query (hawk_mod_t* mod, hawk_t* hawk, const hawk_ooch_t* name, hawk_mod_sym_t* sym)
|
||||||
{
|
{
|
||||||
int left, right, mid, n;
|
if (hawk_findmodsymfnc_noerr(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym) >= 0) return 0;
|
||||||
|
return hawk_findmodsymint(hawk, inttab, HAWK_COUNTOF(inttab), name, sym);
|
||||||
left = 0; right = HAWK_COUNTOF(fnctab) - 1;
|
|
||||||
|
|
||||||
while (left <= right)
|
|
||||||
{
|
|
||||||
mid = left + (right - left) / 2;
|
|
||||||
|
|
||||||
n = hawk_comp_oocstr(fnctab[mid].name, name, 0);
|
|
||||||
if (n > 0) right = mid - 1;
|
|
||||||
else if (n < 0) left = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sym->type = HAWK_MOD_FNC;
|
|
||||||
sym->u.fnc = fnctab[mid].info;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
left = 0; right = HAWK_COUNTOF(inttab) - 1;
|
|
||||||
while (left <= right)
|
|
||||||
{
|
|
||||||
mid = left + (right - left) / 2;
|
|
||||||
|
|
||||||
n = hawk_comp_oocstr(inttab[mid].name, name, 0);
|
|
||||||
if (n > 0) right = mid - 1;
|
|
||||||
else if (n < 0) left = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sym->type = HAWK_MOD_INT;
|
|
||||||
sym->u.in = inttab[mid].info;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init (hawk_mod_t* mod, hawk_rtx_t* rtx)
|
static int init (hawk_mod_t* mod, hawk_rtx_t* rtx)
|
||||||
@ -1955,7 +1907,6 @@ int hawk_mod_mysql (hawk_mod_t* mod, hawk_t* hawk)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
HAWK_EXPORT int hawk_mod_mysql_init (int argc, char* argv[])
|
HAWK_EXPORT int hawk_mod_mysql_init (int argc, char* argv[])
|
||||||
{
|
{
|
||||||
if (mysql_library_init(argc, argv, HAWK_NULL) != 0) return -1;
|
if (mysql_library_init(argc, argv, HAWK_NULL) != 0) return -1;
|
||||||
|
@ -1301,14 +1301,7 @@ static int fnc_uci_getsection (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------ */
|
/* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
typedef struct fnctab_t fnctab_t;
|
static hawk_mod_fnc_tab_t fnctab[] =
|
||||||
struct fnctab_t
|
|
||||||
{
|
|
||||||
const hawk_char_t* name;
|
|
||||||
hawk_mod_sym_fnc_t info;
|
|
||||||
};
|
|
||||||
|
|
||||||
static fnctab_t fnctab[] =
|
|
||||||
{
|
{
|
||||||
{ HAWK_T("adddeltapath"), { { 2, 2, HAWK_NULL }, fnc_uci_adddeltapath, 0 } },
|
{ HAWK_T("adddeltapath"), { { 2, 2, HAWK_NULL }, fnc_uci_adddeltapath, 0 } },
|
||||||
{ HAWK_T("addlist"), { { 2, 2, HAWK_NULL }, fnc_uci_addlist, 0 } },
|
{ HAWK_T("addlist"), { { 2, 2, HAWK_NULL }, fnc_uci_addlist, 0 } },
|
||||||
@ -1335,27 +1328,7 @@ static fnctab_t fnctab[] =
|
|||||||
|
|
||||||
static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_char_t* name, hawk_mod_sym_t* sym)
|
static int query (hawk_mod_t* mod, hawk_t* awk, const hawk_char_t* name, hawk_mod_sym_t* sym)
|
||||||
{
|
{
|
||||||
int left, right, mid, n;
|
return hawk_findmodsymfnc(hawk, fnctab, HAWK_COUNTOF(fnctab), name, sym);
|
||||||
|
|
||||||
left = 0; right = HAWK_COUNTOF(fnctab) - 1;
|
|
||||||
|
|
||||||
while (left <= right)
|
|
||||||
{
|
|
||||||
mid = left + (right - left) / 2;
|
|
||||||
|
|
||||||
n = hawk_strcmp (fnctab[mid].name, name);
|
|
||||||
if (n > 0) right = mid - 1;
|
|
||||||
else if (n < 0) left = mid + 1;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sym->type = HAWK_MOD_FNC;
|
|
||||||
sym->u.fnc = fnctab[mid].info;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
hawk_seterrfmt (awk, HAWK_NULL, HAWK_ENOENT, HAWK_T("'%js' not found"), name);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int init (hawk_mod_t* mod, hawk_rtx_t* rtx)
|
static int init (hawk_mod_t* mod, hawk_rtx_t* rtx)
|
||||||
|
@ -353,6 +353,7 @@ pdfdir = @pdfdir@
|
|||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
program_transform_name = @program_transform_name@
|
program_transform_name = @program_transform_name@
|
||||||
psdir = @psdir@
|
psdir = @psdir@
|
||||||
|
runstatedir = @runstatedir@
|
||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
@ -558,6 +558,7 @@ pdfdir = @pdfdir@
|
|||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
program_transform_name = @program_transform_name@
|
program_transform_name = @program_transform_name@
|
||||||
psdir = @psdir@
|
psdir = @psdir@
|
||||||
|
runstatedir = @runstatedir@
|
||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
@ -330,6 +330,7 @@ pdfdir = @pdfdir@
|
|||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
program_transform_name = @program_transform_name@
|
program_transform_name = @program_transform_name@
|
||||||
psdir = @psdir@
|
psdir = @psdir@
|
||||||
|
runstatedir = @runstatedir@
|
||||||
sbindir = @sbindir@
|
sbindir = @sbindir@
|
||||||
sharedstatedir = @sharedstatedir@
|
sharedstatedir = @sharedstatedir@
|
||||||
srcdir = @srcdir@
|
srcdir = @srcdir@
|
||||||
|
Loading…
Reference in New Issue
Block a user