enhanced qse_awk_flt_t handling

This commit is contained in:
hyung-hwan 2013-11-05 02:53:01 +00:00
parent ca1d1ede66
commit 2a5dd843dd
12 changed files with 95 additions and 48 deletions

View File

@ -10,6 +10,7 @@
suffix ".htm" = "text/html";
suffix ".html" = "text/html";
suffix ".txt" = "text/plain";
suffix ".log" = "text/plain";
suffix ".css" = "text/css";
suffix ".xml" = "text/xml";
suffix ".js" = "application/javascript";

35
qse/configure vendored
View File

@ -839,7 +839,8 @@ enable_syscall
enable_debug
enable_cxx
enable_reentrant
enable_sedtracer
enable_awk_fltmax
enable_sed_tracer
'
ac_precious_vars='build_alias
host_alias
@ -1497,7 +1498,9 @@ Optional Features:
--enable-cxx build the library for C++ if a C++ compiler is
available (default. yes)
--enable-reentrant add thread options (default. no)
--enable-sedtracer enable qse_sed_setexectracer() (default. yes)
--enable-awk-fltmax use qse_fltmax_t for floating-point numbers in AWK
(default. no)
--enable-sed-tracer enable qse_sed_setexectracer() (default. yes)
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@ -21005,17 +21008,33 @@ then
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
fi
# Check whether --enable-sedtracer was given.
if test "${enable_sedtracer+set}" = set; then :
enableval=$enable_sedtracer; enable_sedtracer_is=$enableval
# Check whether --enable-awk-fltmax was given.
if test "${enable_awk_fltmax+set}" = set; then :
enableval=$enable_awk_fltmax; enable_awk_fltmax_is=$enableval
else
enable_sedtracer_is=yes
enable_awk_fltmax_is=no
fi
if test "${enable_sedtracer_is}" = "yes"
if test "${enable_awk_fltmax_is}" = "yes"
then
$as_echo "#define QSE_ENABLE_SEDTRACER /**/" >>confdefs.h
$as_echo "#define QSE_USE_AWK_FLTMAX /**/" >>confdefs.h
fi
# Check whether --enable-sed-tracer was given.
if test "${enable_sed_tracer+set}" = set; then :
enableval=$enable_sed_tracer; enable_sed_tracer_is=$enableval
else
enable_sed_tracer_is=yes
fi
if test "${enable_sed_tracer_is}" = "yes"
then
$as_echo "#define QSE_ENABLE_SED_TRACER /**/" >>confdefs.h
fi

View File

@ -560,11 +560,24 @@ then
[CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"]
fi
AC_ARG_ENABLE([sedtracer], [AS_HELP_STRING([--enable-sedtracer],[enable qse_sed_setexectracer() (default. yes)])],
enable_sedtracer_is=$enableval,enable_sedtracer_is=yes)
if test "${enable_sedtracer_is}" = "yes"
AC_ARG_ENABLE([awk-fltmax],
[AS_HELP_STRING([--enable-awk-fltmax],[use qse_fltmax_t for floating-point numbers in AWK (default. no)])],
enable_awk_fltmax_is=$enableval,
enable_awk_fltmax_is=no
)
if test "${enable_awk_fltmax_is}" = "yes"
then
AC_DEFINE([QSE_ENABLE_SEDTRACER],[],[enable qse_sed_setexectracer()])
AC_DEFINE([QSE_USE_AWK_FLTMAX],[],[use qse_fltmax_t for floating-point numbers in AWK])
fi
AC_ARG_ENABLE([sed-tracer],
[AS_HELP_STRING([--enable-sed-tracer],[enable qse_sed_setexectracer() (default. yes)])],
enable_sed_tracer_is=$enableval,
enable_sed_tracer_is=yes
)
if test "${enable_sed_tracer_is}" = "yes"
then
AC_DEFINE([QSE_ENABLE_SED_TRACER],[],[enable qse_sed_setexectracer()])
fi
AC_MSG_CHECKING([for socklen_t in sys/socket.h])

View File

@ -44,9 +44,13 @@ public:
typedef qse_htb_t htb_t;
typedef qse_htb_pair_t pair_t;
/** Defines a primitive handle */
// define a primitive handle
typedef qse_awk_t awk_t;
// redefine flt_t. To access Types::flt_t, use the fully qualified
// name as it's overriding Types::flt_t.
typedef qse_awk_flt_t flt_t;
typedef qse_awk_loc_t loc_t;
typedef qse_awk_errnum_t errnum_t;
typedef qse_awk_errstr_t errstr_t;

View File

@ -35,8 +35,8 @@
* - consider something like ${1:3,5} => $1, $2, $3, and $5 concatenated
*/
#if defined(QSE_AWK_USE_FLTMAX_T)
typedef qse_flt_t qse_awk_fltmax_t;
#if defined(QSE_USE_AWK_FLTMAX)
typedef qse_fltmax_t qse_awk_flt_t;
#else
typedef qse_flt_t qse_awk_flt_t;
#endif

View File

@ -716,7 +716,7 @@
#undef QSE_ENABLE_BUNDLED_UNICODE
/* enable qse_sed_setexectracer() */
#undef QSE_ENABLE_SEDTRACER
#undef QSE_ENABLE_SED_TRACER
/* link modules statically into the main library */
#undef QSE_ENABLE_STATIC_MODULE
@ -823,6 +823,9 @@
/* sizeof(__int8) */
#undef QSE_SIZEOF___INT8
/* use qse_fltmax_t for floating-point numbers in AWK */
#undef QSE_USE_AWK_FLTMAX
/* use the syscall() function to invoke a system call */
#undef QSE_USE_SYSCALL

View File

@ -1168,7 +1168,7 @@ void StdAwk::freeMem (void* ptr)
StdAwk::flt_t StdAwk::pow (flt_t x, flt_t y)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_POWQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_POWQ)
return ::powq (x, y);
#elif defined(HAVE_POWL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::powl (x, y);
@ -1183,7 +1183,7 @@ StdAwk::flt_t StdAwk::pow (flt_t x, flt_t y)
StdAwk::flt_t StdAwk::mod (flt_t x, flt_t y)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_FMODQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_FMODQ)
return ::fmodq (x, y);
#elif defined(HAVE_FMODL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::fmodl (x, y);
@ -1198,7 +1198,7 @@ StdAwk::flt_t StdAwk::mod (flt_t x, flt_t y)
StdAwk::flt_t StdAwk::sin (flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_SINQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_SINQ)
return ::sinq (x);
#elif defined(HAVE_SINL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::sinl (x);
@ -1213,7 +1213,7 @@ StdAwk::flt_t StdAwk::sin (flt_t x)
StdAwk::flt_t StdAwk::cos (flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_COSQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_COSQ)
return ::cosq (x);
#elif defined(HAVE_COSL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::cosl (x);
@ -1228,7 +1228,7 @@ StdAwk::flt_t StdAwk::cos (flt_t x)
StdAwk::flt_t StdAwk::tan (flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_TANQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_TANQ)
return ::tanq (x);
#elif defined(HAVE_TANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::tanl (x);
@ -1243,7 +1243,7 @@ StdAwk::flt_t StdAwk::tan (flt_t x)
StdAwk::flt_t StdAwk::atan (flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_ATANQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_ATANQ)
return ::atanq (x);
#elif defined(HAVE_ATANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::atanl (x);
@ -1258,7 +1258,7 @@ StdAwk::flt_t StdAwk::atan (flt_t x)
StdAwk::flt_t StdAwk::atan2 (flt_t x, flt_t y)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_ATAN2Q)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_ATAN2Q)
return ::atan2q (x, y);
#elif defined(HAVE_ATAN2L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::atan2l (x, y);
@ -1274,7 +1274,7 @@ StdAwk::flt_t StdAwk::atan2 (flt_t x, flt_t y)
StdAwk::flt_t StdAwk::log (flt_t x)
{
/* natural logarithm */
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_LOGQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_LOGQ)
return ::logq (x);
#elif defined(HAVE_LOGL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::logl (x);
@ -1290,7 +1290,7 @@ StdAwk::flt_t StdAwk::log (flt_t x)
StdAwk::flt_t StdAwk::log10 (flt_t x)
{
/* common logarithm */
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_LOG10Q)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_LOG10Q)
return ::log10q (x);
#elif defined(HAVE_LOG10L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::log10l (x);
@ -1305,7 +1305,7 @@ StdAwk::flt_t StdAwk::log10 (flt_t x)
StdAwk::flt_t StdAwk::exp (flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_EXPQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_EXPQ)
return ::expq (x);
#elif defined(HAVE_EXPL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::expl (x);
@ -1320,7 +1320,7 @@ StdAwk::flt_t StdAwk::exp (flt_t x)
StdAwk::flt_t StdAwk::sqrt (flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_SQRTQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_SQRTQ)
return ::sqrtq (x);
#elif defined(HAVE_SQRTL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return ::sqrtl (x);

View File

@ -182,6 +182,13 @@ qse_long_t qse_awk_strxtolong (
* express or implied warranty.
*/
/*
* double(64bits) extended(80-bits) quadruple(128-bits)
* exponent 11 bits 15 bits 15 bits
* fraction 52 bits 63 bits 112 bits
* sign 1 bit 1 bit 1 bit
* integer 1 bit
*/
#define MAX_EXPONENT 511
qse_awk_flt_t qse_awk_strtoflt (qse_awk_t* awk, const qse_char_t* str)
@ -199,10 +206,10 @@ qse_awk_flt_t qse_awk_strtoflt (qse_awk_t* awk, const qse_char_t* str)
qse_awk_flt_t fraction, dbl_exp, * d;
const qse_char_t* p;
qse_cint_t c;
int exp = 0; /* Esseonent read from "EX" field */
int exp = 0; /* Exponent read from "EX" field */
/*
* Esseonent that derives from the fractional part. Under normal
* Exponent that derives from the fractional part. Under normal
* circumstatnces, it is the negative of the number of digits in F.
* However, if I is very long, the last digits of I get dropped
* (otherwise a long I with a large negative exponent could cause an
@ -391,10 +398,10 @@ qse_awk_flt_t qse_awk_strxtoflt (
qse_awk_flt_t fraction, dbl_exp, * d;
const qse_char_t* p, * end;
qse_cint_t c;
int exp = 0; /* Esseonent read from "EX" field */
int exp = 0; /* Exponent read from "EX" field */
/*
* Esseonent that derives from the fractional part. Under normal
* Exponent that derives from the fractional part. Under normal
* circumstatnces, it is the negative of the number of digits in F.
* However, if I is very long, the last digits of I get dropped
* (otherwise a long I with a large negative exponent could cause an

View File

@ -7290,7 +7290,7 @@ wp_mod_main:
qse_awk_flt_t r;
int n;
#if defined(QSE_AWK_USE_FLTMAX_T)
#if defined(QSE_USE_AWK_FLTMAX)
FMT_CHAR (QSE_T('j'));
#else
FMT_CHAR (QSE_T('z'));

View File

@ -160,7 +160,7 @@ static ioattr_t* get_ioattr (qse_htb_t* tab, const qse_char_t* ptr, qse_size_t l
static qse_awk_flt_t custom_awk_pow (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_flt_t y)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_POWQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_POWQ)
return powq (x, y);
#elif defined(HAVE_POWL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return powl (x, y);
@ -175,7 +175,7 @@ static qse_awk_flt_t custom_awk_pow (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_fl
static qse_awk_flt_t custom_awk_mod (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_flt_t y)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_FMODQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_FMODQ)
return fmodq (x, y);
#elif defined(HAVE_FMODL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return fmodl (x, y);
@ -190,7 +190,7 @@ static qse_awk_flt_t custom_awk_mod (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_fl
static qse_awk_flt_t custom_awk_sin (qse_awk_t* awk, qse_awk_flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_SINQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_SINQ)
return sinq (x);
#elif defined(HAVE_SINL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return sinl (x);
@ -205,7 +205,7 @@ static qse_awk_flt_t custom_awk_sin (qse_awk_t* awk, qse_awk_flt_t x)
static qse_awk_flt_t custom_awk_cos (qse_awk_t* awk, qse_awk_flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_COSQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_COSQ)
return cosq (x);
#elif defined(HAVE_COSL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return cosl (x);
@ -220,7 +220,7 @@ static qse_awk_flt_t custom_awk_cos (qse_awk_t* awk, qse_awk_flt_t x)
static qse_awk_flt_t custom_awk_tan (qse_awk_t* awk, qse_awk_flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_TANQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_TANQ)
return tanq (x);
#elif defined(HAVE_TANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return tanl (x);
@ -235,7 +235,7 @@ static qse_awk_flt_t custom_awk_tan (qse_awk_t* awk, qse_awk_flt_t x)
static qse_awk_flt_t custom_awk_atan (qse_awk_t* awk, qse_awk_flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_ATANQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_ATANQ)
return atanq (x);
#elif defined(HAVE_ATANL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return atanl (x);
@ -250,7 +250,7 @@ static qse_awk_flt_t custom_awk_atan (qse_awk_t* awk, qse_awk_flt_t x)
static qse_awk_flt_t custom_awk_atan2 (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_flt_t y)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_ATAN2Q)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_ATAN2Q)
return atan2q (x, y);
#elif defined(HAVE_ATAN2L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return atan2l (x, y);
@ -265,7 +265,7 @@ static qse_awk_flt_t custom_awk_atan2 (qse_awk_t* awk, qse_awk_flt_t x, qse_awk_
static qse_awk_flt_t custom_awk_log (qse_awk_t* awk, qse_awk_flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_LOGQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_LOGQ)
return logq (x);
#elif defined(HAVE_LOGL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return logl (x);
@ -280,7 +280,7 @@ static qse_awk_flt_t custom_awk_log (qse_awk_t* awk, qse_awk_flt_t x)
static qse_awk_flt_t custom_awk_log10 (qse_awk_t* awk, qse_awk_flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_LOG10Q)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_LOG10Q)
return log10q (x);
#elif defined(HAVE_LOG10L) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return log10l (x);
@ -295,7 +295,7 @@ static qse_awk_flt_t custom_awk_log10 (qse_awk_t* awk, qse_awk_flt_t x)
static qse_awk_flt_t custom_awk_exp (qse_awk_t* awk, qse_awk_flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_EXPQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_EXPQ)
return expq (x);
#elif defined(HAVE_EXPL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return expl (x);
@ -310,7 +310,7 @@ static qse_awk_flt_t custom_awk_exp (qse_awk_t* awk, qse_awk_flt_t x)
static qse_awk_flt_t custom_awk_sqrt (qse_awk_t* awk, qse_awk_flt_t x)
{
#if defined(QSE_AWK_USE_FLTMAX_T) && defined(HAVE_SQRTQ)
#if defined(QSE_USE_AWK_FLTMAX) && defined(HAVE_SQRTQ)
return sqrtq (x);
#elif defined(HAVE_SQRTL) && (QSE_SIZEOF_LONG_DOUBLE > QSE_SIZEOF_DOUBLE)
return sqrtl (x);

View File

@ -345,7 +345,7 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde)
qse_strxfmt (
buf, QSE_COUNTOF(buf),
#if defined(QSE_AWK_USE_FLTMAX_T)
#if defined(QSE_USE_AWK_FLTMAX)
QSE_T("%jf"),
#else
QSE_T("%zf"),

View File

@ -3999,7 +3999,7 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_impl_t inf, qse_sed_io_impl_t outf)
while (!sed->e.stopreq)
{
#if defined(QSE_ENABLE_SEDTRACER)
#if defined(QSE_ENABLE_SED_TRACER)
if (sed->opt.tracer) sed->opt.tracer (sed, QSE_SED_TRACER_READ, QSE_NULL);
#endif
@ -4020,7 +4020,7 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_impl_t inf, qse_sed_io_impl_t outf)
while (c != &sed->cmd.over)
{
#if defined(QSE_ENABLE_SEDTRACER)
#if defined(QSE_ENABLE_SED_TRACER)
if (sed->opt.tracer) sed->opt.tracer (sed, QSE_SED_TRACER_MATCH, c);
#endif
@ -4034,7 +4034,7 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_impl_t inf, qse_sed_io_impl_t outf)
continue;
}
#if defined(QSE_ENABLE_SEDTRACER)
#if defined(QSE_ENABLE_SED_TRACER)
if (sed->opt.tracer) sed->opt.tracer (sed, QSE_SED_TRACER_EXEC, c);
#endif
j = exec_cmd (sed, c);
@ -4053,7 +4053,7 @@ int qse_sed_exec (qse_sed_t* sed, qse_sed_io_impl_t inf, qse_sed_io_impl_t outf)
}
}
#if defined(QSE_ENABLE_SEDTRACER)
#if defined(QSE_ENABLE_SED_TRACER)
if (sed->opt.tracer) sed->opt.tracer (sed, QSE_SED_TRACER_WRITE, QSE_NULL);
#endif
if (emit_output (sed, 0) <= -1) { ret = -1; goto done; }