added a build option to use qse_intmax_t for integers in awk.
made relevant changes to support the option
This commit is contained in:
parent
2a5dd843dd
commit
ea55e0d7ee
@ -349,7 +349,7 @@ static void dprint_return (qse_awk_rtx_t* rtx, qse_awk_val_t* ret)
|
||||
#ifdef ENABLE_CALLBACK
|
||||
static void on_statement (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde)
|
||||
{
|
||||
dprint (QSE_T("running %d at line %d\n"), (int)nde->type, (int)nde->loc.line);
|
||||
dprint (QSE_T("running %d at line %zu\n"), (int)nde->type, (qse_size_t)nde->loc.line);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -864,10 +864,10 @@ static void print_awkerr (qse_awk_t* awk)
|
||||
const qse_awk_loc_t* loc = qse_awk_geterrloc (awk);
|
||||
|
||||
print_error (
|
||||
QSE_T("CODE %d LINE %u COLUMN %u %s%s%s- %s\n"),
|
||||
QSE_T("CODE %d LINE %zu COLUMN %zu %s%s%s- %s\n"),
|
||||
qse_awk_geterrnum(awk),
|
||||
(unsigned int)loc->line,
|
||||
(unsigned int)loc->colm,
|
||||
(qse_size_t)loc->line,
|
||||
(qse_size_t)loc->colm,
|
||||
((loc->file == QSE_NULL)? QSE_T(""): QSE_T("FILE ")),
|
||||
((loc->file == QSE_NULL)? QSE_T(""): loc->file),
|
||||
((loc->file == QSE_NULL)? QSE_T(""): QSE_T(" ")),
|
||||
@ -880,10 +880,10 @@ static void print_rtxerr (qse_awk_rtx_t* rtx)
|
||||
const qse_awk_loc_t* loc = qse_awk_rtx_geterrloc (rtx);
|
||||
|
||||
print_error (
|
||||
QSE_T("CODE %d LINE %u COLUMN %u %s%s%s- %s\n"),
|
||||
QSE_T("CODE %d LINE %zu COLUMN %zu %s%s%s- %s\n"),
|
||||
qse_awk_rtx_geterrnum(rtx),
|
||||
(unsigned int)loc->line,
|
||||
(unsigned int)loc->colm,
|
||||
(qse_size_t)loc->line,
|
||||
(qse_size_t)loc->colm,
|
||||
((loc->file == QSE_NULL)? QSE_T(""): QSE_T("FILE ")),
|
||||
((loc->file == QSE_NULL)? QSE_T(""): loc->file),
|
||||
((loc->file == QSE_NULL)? QSE_T(""): QSE_T(" ")),
|
||||
@ -1095,13 +1095,13 @@ static int awk_main (int argc, qse_char_t* argv[])
|
||||
|
||||
if (retv)
|
||||
{
|
||||
qse_long_t tmp;
|
||||
qse_awk_int_t tmp;
|
||||
|
||||
qse_awk_rtx_refdownval (rtx, retv);
|
||||
if (app_debug) dprint_return (rtx, retv);
|
||||
|
||||
ret = 0;
|
||||
if (qse_awk_rtx_valtolong (rtx, retv, &tmp) >= 0) ret = tmp;
|
||||
if (qse_awk_rtx_valtoint (rtx, retv, &tmp) >= 0) ret = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
21
qse/configure
vendored
21
qse/configure
vendored
@ -839,6 +839,7 @@ enable_syscall
|
||||
enable_debug
|
||||
enable_cxx
|
||||
enable_reentrant
|
||||
enable_awk_intmax
|
||||
enable_awk_fltmax
|
||||
enable_sed_tracer
|
||||
'
|
||||
@ -1498,6 +1499,7 @@ 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-awk-intmax use qse_intmax_t for integers in AWK (default. no)
|
||||
--enable-awk-fltmax use qse_fltmax_t for floating-point numbers in AWK
|
||||
(default. no)
|
||||
--enable-sed-tracer enable qse_sed_setexectracer() (default. yes)
|
||||
@ -18985,6 +18987,8 @@ _ACEOF
|
||||
fi
|
||||
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for va_copy" >&5
|
||||
$as_echo_n "checking for va_copy... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <stdarg.h>
|
||||
@ -19015,6 +19019,8 @@ fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __va_copy" >&5
|
||||
$as_echo_n "checking for __va_copy... " >&6; }
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
#include <stdarg.h>
|
||||
@ -21008,6 +21014,21 @@ then
|
||||
CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"
|
||||
fi
|
||||
|
||||
# Check whether --enable-awk-intmax was given.
|
||||
if test "${enable_awk_intmax+set}" = set; then :
|
||||
enableval=$enable_awk_intmax; enable_awk_intmax_is=$enableval
|
||||
else
|
||||
enable_awk_intmax_is=no
|
||||
|
||||
fi
|
||||
|
||||
if test "${enable_awk_intmax_is}" = "yes"
|
||||
then
|
||||
|
||||
$as_echo "#define QSE_USE_AWK_INTMAX /**/" >>confdefs.h
|
||||
|
||||
fi
|
||||
|
||||
# Check whether --enable-awk-fltmax was given.
|
||||
if test "${enable_awk_fltmax+set}" = set; then :
|
||||
enableval=$enable_awk_fltmax; enable_awk_fltmax_is=$enableval
|
||||
|
@ -335,6 +335,7 @@ AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], [], [],
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>])
|
||||
|
||||
AC_MSG_CHECKING([for va_copy])
|
||||
AC_TRY_LINK(
|
||||
[#include <stdarg.h>],
|
||||
[
|
||||
@ -348,6 +349,7 @@ AC_TRY_LINK(
|
||||
[AC_MSG_RESULT(no)]
|
||||
)
|
||||
|
||||
AC_MSG_CHECKING([for __va_copy])
|
||||
AC_TRY_LINK(
|
||||
[#include <stdarg.h>],
|
||||
[
|
||||
@ -560,6 +562,16 @@ then
|
||||
[CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS"]
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE([awk-intmax],
|
||||
[AS_HELP_STRING([--enable-awk-intmax],[use qse_intmax_t for integers in AWK (default. no)])],
|
||||
enable_awk_intmax_is=$enableval,
|
||||
enable_awk_intmax_is=no
|
||||
)
|
||||
if test "${enable_awk_intmax_is}" = "yes"
|
||||
then
|
||||
AC_DEFINE([QSE_USE_AWK_INTMAX],[],[use qse_intmax_t for integers in AWK])
|
||||
fi
|
||||
|
||||
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,
|
||||
|
@ -49,7 +49,9 @@ public:
|
||||
|
||||
// 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_flt_t flt_t;
|
||||
typedef qse_awk_int_t int_t;
|
||||
typedef qse_awk_uint_t uint_t;
|
||||
|
||||
typedef qse_awk_loc_t loc_t;
|
||||
typedef qse_awk_errnum_t errnum_t;
|
||||
@ -490,7 +492,7 @@ public:
|
||||
Mode getMode () const;
|
||||
|
||||
int setFileName (const char_t* name);
|
||||
int setFNR (long_t fnr);
|
||||
int setFNR (int_t fnr);
|
||||
|
||||
protected:
|
||||
char_t* filename;
|
||||
@ -583,7 +585,7 @@ public:
|
||||
class QSE_EXPORT IntIndex: public Index
|
||||
{
|
||||
public:
|
||||
IntIndex (long_t num);
|
||||
IntIndex (int_t num);
|
||||
|
||||
protected:
|
||||
// 2^32: 4294967296
|
||||
@ -593,7 +595,7 @@ public:
|
||||
// -(2^64/2): -9223372036854775808
|
||||
// -(2^128/2): -170141183460469231731687303715884105728
|
||||
#if QSE_SIZEOF_LONG_T > 16
|
||||
# error SIZEOF(qse_long_t) TOO LARGE.
|
||||
# error SIZEOF(int_t) TOO LARGE.
|
||||
# error INCREASE THE BUFFER SIZE TO SUPPORT IT.
|
||||
#elif QSE_SIZEOF_LONG_T == 16
|
||||
char_t buf[41];
|
||||
@ -676,7 +678,7 @@ public:
|
||||
void clear ();
|
||||
|
||||
operator val_t* () const { return val; }
|
||||
operator long_t () const;
|
||||
operator int_t () const;
|
||||
operator flt_t () const;
|
||||
operator const char_t* () const;
|
||||
|
||||
@ -685,9 +687,9 @@ public:
|
||||
return operator val_t* ();
|
||||
}
|
||||
|
||||
long_t toInt () const
|
||||
int_t toInt () const
|
||||
{
|
||||
return operator long_t ();
|
||||
return operator int_t ();
|
||||
}
|
||||
|
||||
flt_t toFlt () const
|
||||
@ -710,16 +712,16 @@ public:
|
||||
return p;
|
||||
}
|
||||
|
||||
int getInt (long_t* v) const;
|
||||
int getInt (int_t* v) const;
|
||||
int getFlt (flt_t* v) const;
|
||||
int getNum (long_t* lv, flt_t* fv) const;
|
||||
int getNum (int_t* lv, flt_t* fv) const;
|
||||
int getStr (const char_t** str, size_t* len) const;
|
||||
|
||||
int setVal (val_t* v);
|
||||
int setVal (Run* r, val_t* v);
|
||||
|
||||
int setInt (long_t v);
|
||||
int setInt (Run* r, long_t v);
|
||||
int setInt (int_t v);
|
||||
int setInt (Run* r, int_t v);
|
||||
int setFlt (flt_t v);
|
||||
int setFlt (Run* r, flt_t v);
|
||||
int setStr (const char_t* str, size_t len, bool numeric = false);
|
||||
@ -740,13 +742,13 @@ public:
|
||||
|
||||
int setIndexedInt (
|
||||
const Index& idx,
|
||||
long_t v
|
||||
int_t v
|
||||
);
|
||||
|
||||
int setIndexedInt (
|
||||
Run* r,
|
||||
const Index& idx,
|
||||
long_t v);
|
||||
int_t v);
|
||||
|
||||
int setIndexedFlt (
|
||||
const Index& idx,
|
||||
@ -884,7 +886,7 @@ public:
|
||||
/// to @a v.
|
||||
/// @return 0 on success, -1 on failure
|
||||
///
|
||||
int setGlobal (int id, long_t v);
|
||||
int setGlobal (int id, int_t v);
|
||||
|
||||
///
|
||||
/// The setGlobal() function sets the value of a global
|
||||
|
@ -173,8 +173,8 @@ protected:
|
||||
void* modsym (void* handle, const char_t* name);
|
||||
|
||||
protected:
|
||||
qse_long_t seed;
|
||||
qse_ulong_t prand;
|
||||
int_t seed;
|
||||
uint_t prand;
|
||||
qse_htb_t cmgrtab;
|
||||
bool cmgrtab_inited;
|
||||
|
||||
|
@ -35,6 +35,14 @@
|
||||
* - consider something like ${1:3,5} => $1, $2, $3, and $5 concatenated
|
||||
*/
|
||||
|
||||
#if defined(QSE_USE_AWK_INTMAX)
|
||||
typedef qse_intmax_t qse_awk_int_t;
|
||||
typedef qse_uintmax_t qse_awk_uint_t;
|
||||
#else
|
||||
typedef qse_long_t qse_awk_int_t;
|
||||
typedef qse_ulong_t qse_awk_uint_t;
|
||||
#endif
|
||||
|
||||
#if defined(QSE_USE_AWK_FLTMAX)
|
||||
typedef qse_fltmax_t qse_awk_flt_t;
|
||||
#else
|
||||
@ -117,7 +125,7 @@ typedef struct qse_awk_loc_t qse_awk_loc_t;
|
||||
* - type - type of a value from #qse_awk_val_type_t
|
||||
* - ref - reference count
|
||||
* - stat - static value
|
||||
* - nstr - numeric string marker, 1 -> long, 2 -> real
|
||||
* - nstr - numeric string marker, 1 -> integer, 2 -> floating-point number
|
||||
*/
|
||||
/*
|
||||
#define QSE_AWK_VAL_HDR \
|
||||
@ -161,8 +169,8 @@ typedef struct qse_awk_val_nil_t qse_awk_val_nil_t;
|
||||
struct qse_awk_val_int_t
|
||||
{
|
||||
QSE_AWK_VAL_HDR;
|
||||
qse_long_t val;
|
||||
void* nde;
|
||||
qse_awk_int_t val;
|
||||
void* nde;
|
||||
};
|
||||
typedef struct qse_awk_val_int_t qse_awk_val_int_t;
|
||||
|
||||
@ -854,7 +862,7 @@ typedef struct qse_awk_mod_sym_flt_t qse_awk_mod_sym_flt_t;
|
||||
|
||||
struct qse_awk_mod_sym_int_t
|
||||
{
|
||||
qse_long_t val;
|
||||
qse_awk_int_t val;
|
||||
};
|
||||
|
||||
struct qse_awk_mod_sym_flt_t
|
||||
@ -1406,9 +1414,9 @@ typedef struct qse_awk_rtx_valtostr_out_t qse_awk_rtx_valtostr_out_t;
|
||||
/* record filter using NR */
|
||||
struct qse_awk_nrflt_t
|
||||
{
|
||||
qse_long_t limit;
|
||||
qse_long_t size;
|
||||
qse_long_t rank;
|
||||
qse_awk_int_t limit;
|
||||
qse_awk_int_t size;
|
||||
qse_awk_int_t rank;
|
||||
};
|
||||
typedef struct qse_awk_nrflt_t qse_awk_nrflt_t;
|
||||
|
||||
@ -1837,9 +1845,9 @@ QSE_EXPORT qse_char_t* qse_awk_cstrdup (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_strxtolong() function converts a string to an integer.
|
||||
* The qse_awk_strxtoint() function converts a string to an integer.
|
||||
*/
|
||||
QSE_EXPORT qse_long_t qse_awk_strxtolong (
|
||||
QSE_EXPORT qse_awk_int_t qse_awk_strxtoint (
|
||||
qse_awk_t* awk,
|
||||
const qse_char_t* str,
|
||||
qse_size_t len,
|
||||
@ -1859,11 +1867,11 @@ QSE_EXPORT qse_awk_flt_t qse_awk_strxtoflt (
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_longtostr() functon convers an integer to a string.
|
||||
* The qse_awk_longtostr() functon converts an integer to a string.
|
||||
*/
|
||||
QSE_EXPORT qse_size_t qse_awk_longtostr (
|
||||
QSE_EXPORT qse_size_t qse_awk_inttostr (
|
||||
qse_awk_t* awk,
|
||||
qse_long_t value,
|
||||
qse_awk_int_t value,
|
||||
int radix,
|
||||
const qse_char_t* prefix,
|
||||
qse_char_t* buf,
|
||||
@ -2271,7 +2279,7 @@ QSE_EXPORT qse_awk_val_t* qse_awk_rtx_makenilval (
|
||||
*/
|
||||
QSE_EXPORT qse_awk_val_t* qse_awk_rtx_makeintval (
|
||||
qse_awk_rtx_t* rtx,
|
||||
qse_long_t v
|
||||
qse_awk_int_t v
|
||||
);
|
||||
|
||||
/**
|
||||
@ -2642,7 +2650,7 @@ QSE_EXPORT qse_wchar_t* qse_awk_rtx_valtowcsdup (
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_valtonum() function converts a value to a number.
|
||||
* If the value is converted to a long number, it is stored in the memory
|
||||
* If the value is converted to an integer, it is stored in the memory
|
||||
* pointed to by l and 0 is returned. If the value is converted to a real
|
||||
* number, it is stored in the memory pointed to by r and 1 is returned.
|
||||
* The function never fails as long as \a val points to a valid value.
|
||||
@ -2651,29 +2659,29 @@ QSE_EXPORT qse_wchar_t* qse_awk_rtx_valtowcsdup (
|
||||
* if it is an integer or a floating-point number.
|
||||
*
|
||||
* \code
|
||||
* qse_long_t l;
|
||||
* qse_awk_int_t l;
|
||||
* qse_awk_flt_t r;
|
||||
* int n;
|
||||
* n = qse_awk_rtx_valtonum (v, &l, &r);
|
||||
* if (n <= -1) error ();
|
||||
* else if (n == 0) print_long (l);
|
||||
* else if (n >= 1) print_real (r);
|
||||
* else if (n == 0) print_int (l);
|
||||
* else if (n >= 1) print_flt (r);
|
||||
* \endcode
|
||||
*
|
||||
* \return -1 on failure, 0 if converted to a long number, 1 if converted to
|
||||
* \return -1 on failure, 0 if converted to an integer, 1 if converted to
|
||||
* a floating-point number.
|
||||
*/
|
||||
QSE_EXPORT int qse_awk_rtx_valtonum (
|
||||
qse_awk_rtx_t* rtx,
|
||||
const qse_awk_val_t* val,
|
||||
qse_long_t* l,
|
||||
qse_awk_int_t* l,
|
||||
qse_awk_flt_t* r
|
||||
);
|
||||
|
||||
QSE_EXPORT int qse_awk_rtx_valtolong (
|
||||
QSE_EXPORT int qse_awk_rtx_valtoint (
|
||||
qse_awk_rtx_t* rtx,
|
||||
const qse_awk_val_t* val,
|
||||
qse_long_t* l
|
||||
qse_awk_int_t* l
|
||||
);
|
||||
|
||||
QSE_EXPORT int qse_awk_rtx_valtoflt (
|
||||
@ -2701,7 +2709,7 @@ QSE_EXPORT int qse_awk_rtx_strtonum (
|
||||
int strict, /**< determines to perform strict check */
|
||||
const qse_char_t* ptr, /**< points to a string to convert */
|
||||
qse_size_t len, /**< number of characters in a string */
|
||||
qse_long_t* l, /**< stores a converted integer */
|
||||
qse_awk_int_t* l, /**< stores a converted integer */
|
||||
qse_awk_flt_t* r /**< stores a converted floating-poing number */
|
||||
);
|
||||
|
||||
@ -2709,7 +2717,7 @@ QSE_EXPORT int qse_awk_rtx_strtonum (
|
||||
* The qse_awk_rtx_hashval() function hashes a simple value
|
||||
* to a positive integer. It returns -1 for a inhashable value.
|
||||
*/
|
||||
QSE_EXPORT qse_long_t qse_awk_rtx_hashval (
|
||||
QSE_EXPORT qse_awk_int_t qse_awk_rtx_hashval (
|
||||
qse_awk_rtx_t* rtx,
|
||||
qse_awk_val_t* v
|
||||
);
|
||||
|
@ -158,7 +158,19 @@ QSE_EXPORT qse_uint64_t qse_randxs64 (
|
||||
);
|
||||
#endif
|
||||
|
||||
#if (QSE_SIZEOF_ULONG_T == QSE_SIZEOF_UINT64_T)
|
||||
#if (QSE_SIZEOF_UINT128_T > 0)
|
||||
/**
|
||||
* The qse_randxs128() function implements the xorshift random number generator
|
||||
* by George Marsaglia.
|
||||
*/
|
||||
QSE_EXPORT qse_uint128_t qse_randxs128 (
|
||||
qse_uint128_t seed
|
||||
);
|
||||
#endif
|
||||
|
||||
#if (QSE_SIZEOF_ULONG_T == QSE_SIZEOF_UINT128_T)
|
||||
# define qse_randxsulong(seed) qse_randxs128(seed)
|
||||
#elif (QSE_SIZEOF_ULONG_T == QSE_SIZEOF_UINT64_T)
|
||||
# define qse_randxsulong(seed) qse_randxs64(seed)
|
||||
#elif (QSE_SIZEOF_ULONG_T == QSE_SIZEOF_UINT32_T)
|
||||
# define qse_randxsulong(seed) qse_randxs32(seed)
|
||||
@ -166,7 +178,9 @@ QSE_EXPORT qse_uint64_t qse_randxs64 (
|
||||
# error Unsupported
|
||||
#endif
|
||||
|
||||
#if (QSE_SIZEOF_UINT_T == QSE_SIZEOF_UINT64_T)
|
||||
#if (QSE_SIZEOF_UINT_T == QSE_SIZEOF_UINT128_T)
|
||||
# define qse_randxsuint(seed) qse_randxs128(seed)
|
||||
#elif (QSE_SIZEOF_UINT_T == QSE_SIZEOF_UINT64_T)
|
||||
# define qse_randxsuint(seed) qse_randxs64(seed)
|
||||
#elif (QSE_SIZEOF_UINT_T == QSE_SIZEOF_UINT32_T)
|
||||
# define qse_randxsuint(seed) qse_randxs32(seed)
|
||||
@ -174,6 +188,16 @@ QSE_EXPORT qse_uint64_t qse_randxs64 (
|
||||
# error Unsupported
|
||||
#endif
|
||||
|
||||
#if (QSE_SIZEOF_UINTMAX_T == QSE_SIZEOF_UINT128_T)
|
||||
# define qse_randxsuintmax(seed) qse_randxs128(seed)
|
||||
#elif (QSE_SIZEOF_UINTMAX_T == QSE_SIZEOF_UINT64_T)
|
||||
# define qse_randxsuintmax(seed) qse_randxs64(seed)
|
||||
#elif (QSE_SIZEOF_UINTMAX_T == QSE_SIZEOF_UINT32_T)
|
||||
# define qse_randxsuintmax(seed) qse_randxs32(seed)
|
||||
#else
|
||||
# error Unsupported
|
||||
#endif
|
||||
|
||||
QSE_EXPORT qse_size_t qse_enbase64 (
|
||||
const void* in,
|
||||
qse_size_t isz,
|
||||
|
@ -826,6 +826,9 @@
|
||||
/* use qse_fltmax_t for floating-point numbers in AWK */
|
||||
#undef QSE_USE_AWK_FLTMAX
|
||||
|
||||
/* use qse_intmax_t for integers in AWK */
|
||||
#undef QSE_USE_AWK_INTMAX
|
||||
|
||||
/* use the syscall() function to invoke a system call */
|
||||
#undef QSE_USE_SYSCALL
|
||||
|
||||
|
@ -164,7 +164,7 @@ int Awk::Console::setFileName (const char_t* name)
|
||||
}
|
||||
}
|
||||
|
||||
int Awk::Console::setFNR (long_t fnr)
|
||||
int Awk::Console::setFNR (int_t fnr)
|
||||
{
|
||||
val_t* tmp;
|
||||
int n;
|
||||
@ -196,7 +196,7 @@ const Awk::char_t* Awk::Value::getEmptyStr()
|
||||
return EMPTY_STRING;
|
||||
}
|
||||
|
||||
Awk::Value::IntIndex::IntIndex (long_t x)
|
||||
Awk::Value::IntIndex::IntIndex (int_t x)
|
||||
{
|
||||
ptr = buf;
|
||||
len = 0;
|
||||
@ -204,8 +204,8 @@ Awk::Value::IntIndex::IntIndex (long_t x)
|
||||
#define NTOC(n) (QSE_T("0123456789")[n])
|
||||
|
||||
int base = 10;
|
||||
long_t last = x % base;
|
||||
long_t y = 0;
|
||||
int_t last = x % base;
|
||||
int_t y = 0;
|
||||
int dig = 0;
|
||||
|
||||
if (x < 0) buf[len++] = QSE_T('-');
|
||||
@ -361,9 +361,9 @@ void Awk::Value::clear ()
|
||||
}
|
||||
}
|
||||
|
||||
Awk::Value::operator Awk::long_t () const
|
||||
Awk::Value::operator Awk::int_t () const
|
||||
{
|
||||
long_t v;
|
||||
int_t v;
|
||||
if (getInt (&v) <= -1) v = 0;
|
||||
return v;
|
||||
}
|
||||
@ -383,15 +383,15 @@ Awk::Value::operator const Awk::char_t* () const
|
||||
return ptr;
|
||||
}
|
||||
|
||||
int Awk::Value::getInt (long_t* v) const
|
||||
int Awk::Value::getInt (int_t* v) const
|
||||
{
|
||||
long_t lv = 0;
|
||||
int_t lv = 0;
|
||||
|
||||
QSE_ASSERT (this->val != QSE_NULL);
|
||||
|
||||
if (run != QSE_NULL)
|
||||
{
|
||||
int n = qse_awk_rtx_valtolong (this->run->rtx, this->val, &lv);
|
||||
int n = qse_awk_rtx_valtoint (this->run->rtx, this->val, &lv);
|
||||
if (n <= -1)
|
||||
{
|
||||
run->awk->retrieveError (this->run);
|
||||
@ -423,7 +423,7 @@ int Awk::Value::getFlt (flt_t* v) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Awk::Value::getNum (long_t* lv, flt_t* fv) const
|
||||
int Awk::Value::getNum (int_t* lv, flt_t* fv) const
|
||||
{
|
||||
QSE_ASSERT (this->val != QSE_NULL);
|
||||
|
||||
@ -521,7 +521,7 @@ int Awk::Value::setVal (Run* r, val_t* v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Awk::Value::setInt (long_t v)
|
||||
int Awk::Value::setInt (int_t v)
|
||||
{
|
||||
if (this->run == QSE_NULL)
|
||||
{
|
||||
@ -532,7 +532,7 @@ int Awk::Value::setInt (long_t v)
|
||||
return setInt (this->run, v);
|
||||
}
|
||||
|
||||
int Awk::Value::setInt (Run* r, long_t v)
|
||||
int Awk::Value::setInt (Run* r, int_t v)
|
||||
{
|
||||
val_t* tmp;
|
||||
tmp = qse_awk_rtx_makeintval (r->rtx, v);
|
||||
@ -696,13 +696,13 @@ int Awk::Value::setIndexedVal (Run* r, const Index& idx, val_t* v)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Awk::Value::setIndexedInt (const Index& idx, long_t v)
|
||||
int Awk::Value::setIndexedInt (const Index& idx, int_t v)
|
||||
{
|
||||
if (run == QSE_NULL) return -1;
|
||||
return setIndexedInt (run, idx, v);
|
||||
}
|
||||
|
||||
int Awk::Value::setIndexedInt (Run* r, const Index& idx, long_t v)
|
||||
int Awk::Value::setIndexedInt (Run* r, const Index& idx, int_t v)
|
||||
{
|
||||
val_t* tmp = qse_awk_rtx_makeintval (r->rtx, v);
|
||||
if (tmp == QSE_NULL)
|
||||
@ -943,7 +943,7 @@ void Awk::Run::setErrorWithMessage (
|
||||
qse_awk_rtx_seterrinf (this->rtx, &errinf);
|
||||
}
|
||||
|
||||
int Awk::Run::setGlobal (int id, long_t v)
|
||||
int Awk::Run::setGlobal (int id, int_t v)
|
||||
{
|
||||
QSE_ASSERT (this->rtx != QSE_NULL);
|
||||
|
||||
|
@ -151,10 +151,10 @@ int StdAwk::open ()
|
||||
|
||||
qse_ntime_t now;
|
||||
|
||||
this->seed = (qse_gettime(&now) <= -1)? 0u: ((long_t)now.sec + (long_t)now.nsec);
|
||||
this->seed = (qse_gettime(&now) <= -1)? 0u: ((int_t)now.sec + (int_t)now.nsec);
|
||||
/* i don't care if the seed becomes negative or overflows.
|
||||
* i just convert the signed value to the unsigned one. */
|
||||
this->prand = (qse_ulong_t)(this->seed * this->seed * this->seed);
|
||||
this->prand = (uint_t)(this->seed * this->seed * this->seed);
|
||||
/* make sure that the actual seeding is not 0 */
|
||||
if (this->prand == 0) this->prand++;
|
||||
|
||||
@ -230,7 +230,7 @@ int StdAwk::build_argcv (Run* run)
|
||||
this->runarg.ptr[i].len, true) <= -1) return -1;
|
||||
}
|
||||
|
||||
run->setGlobal (this->gbl_argc, (long_t)this->runarg.len);
|
||||
run->setGlobal (this->gbl_argc, (int_t)this->runarg.len);
|
||||
run->setGlobal (this->gbl_argv, argv);
|
||||
return 0;
|
||||
}
|
||||
@ -343,9 +343,15 @@ int StdAwk::make_additional_globals (Run* run)
|
||||
int StdAwk::rand (Run& run, Value& ret, Value* args, size_t nargs,
|
||||
const char_t* name, size_t len)
|
||||
{
|
||||
#define RANDV_MAX QSE_TYPE_MAX(long_t)
|
||||
#define RANDV_MAX QSE_TYPE_MAX(int_t)
|
||||
|
||||
#if defined(QSE_USE_AWK_INTMAX)
|
||||
this->prand = qse_randxsuintmax (this->prand);
|
||||
#else
|
||||
this->prand = qse_randxsulong (this->prand);
|
||||
long_t randv = this->prand % RANDV_MAX;
|
||||
#endif
|
||||
|
||||
int_t randv = this->prand % RANDV_MAX;
|
||||
return ret.setFlt ((flt_t)randv / RANDV_MAX);
|
||||
#undef RANDV_MAX
|
||||
}
|
||||
@ -353,14 +359,14 @@ int StdAwk::rand (Run& run, Value& ret, Value* args, size_t nargs,
|
||||
int StdAwk::srand (Run& run, Value& ret, Value* args, size_t nargs,
|
||||
const char_t* name, size_t len)
|
||||
{
|
||||
long_t prevSeed = (long_t)this->seed;
|
||||
int_t prevSeed = (int_t)this->seed;
|
||||
|
||||
qse_ntime_t now;
|
||||
|
||||
if (nargs <= 0)
|
||||
{
|
||||
this->seed = (qse_gettime (&now) <= -1)?
|
||||
(this->seed * this->seed): ((long_t)now.sec + (long_t)now.nsec);
|
||||
(this->seed * this->seed): ((int_t)now.sec + (int_t)now.nsec);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -369,11 +375,11 @@ int StdAwk::srand (Run& run, Value& ret, Value* args, size_t nargs,
|
||||
|
||||
/* i don't care if the seed becomes negative or overflows.
|
||||
* i just convert the signed value to the unsigned one. */
|
||||
this->prand = (qse_ulong_t)(this->seed * this->seed * this->seed);
|
||||
this->prand = (uint_t)(this->seed * this->seed * this->seed);
|
||||
/* make sure that the actual seeding is not 0 */
|
||||
if (this->prand == 0) this->prand++;
|
||||
|
||||
return ret.setInt ((long_t)prevSeed);
|
||||
return ret.setInt ((int_t)prevSeed);
|
||||
}
|
||||
|
||||
int StdAwk::system (Run& run, Value& ret, Value* args, size_t nargs,
|
||||
@ -383,15 +389,15 @@ int StdAwk::system (Run& run, Value& ret, Value* args, size_t nargs,
|
||||
const char_t* ptr = args[0].toStr(&l);
|
||||
|
||||
#if defined(_WIN32)
|
||||
return ret.setInt ((long_t)::_tsystem(ptr));
|
||||
return ret.setInt ((int_t)::_tsystem(ptr));
|
||||
#elif defined(QSE_CHAR_IS_MCHAR)
|
||||
return ret.setInt ((long_t)::system(ptr));
|
||||
return ret.setInt ((int_t)::system(ptr));
|
||||
#else
|
||||
|
||||
qse_mchar_t* mbs;
|
||||
mbs = qse_wcstombsdup (ptr, QSE_NULL, ((Awk*)run)->getMmgr());
|
||||
if (mbs == QSE_NULL) return -1;
|
||||
int n = ret.setInt ((long_t)::system(mbs));
|
||||
int n = ret.setInt ((int_t)::system(mbs));
|
||||
QSE_MMGR_FREE (((Awk*)run)->getMmgr(), mbs);
|
||||
return n;
|
||||
#endif
|
||||
@ -464,13 +470,13 @@ int StdAwk::setioattr (
|
||||
qse_strxchr (ptr[1], l[1], QSE_T('\0')) ||
|
||||
qse_strxchr (ptr[2], l[2], QSE_T('\0')))
|
||||
{
|
||||
return ret.setInt ((long_t)-1);
|
||||
return ret.setInt ((int_t)-1);
|
||||
}
|
||||
|
||||
int tmout;
|
||||
if ((tmout = timeout_code (ptr[1])) >= 0)
|
||||
{
|
||||
long_t lv;
|
||||
int_t lv;
|
||||
flt_t fv;
|
||||
int n;
|
||||
|
||||
@ -488,11 +494,11 @@ int StdAwk::setioattr (
|
||||
else
|
||||
{
|
||||
qse_awk_flt_t nsec;
|
||||
ioattr->tmout[tmout].sec = (qse_long_t)fv;
|
||||
ioattr->tmout[tmout].sec = (qse_int_t)fv;
|
||||
nsec = fv - ioattr->tmout[tmout].sec;
|
||||
ioattr->tmout[tmout].nsec = QSE_SEC_TO_NSEC(nsec);
|
||||
}
|
||||
return ret.setInt ((long_t)0);
|
||||
return ret.setInt ((int_t)0);
|
||||
}
|
||||
#if defined(QSE_CHAR_IS_WCHAR)
|
||||
else if (qse_strcasecmp (ptr[1], QSE_T("codepage")) == 0)
|
||||
@ -504,7 +510,7 @@ int StdAwk::setioattr (
|
||||
else
|
||||
{
|
||||
cmgr = qse_findcmgr (ptr[2]);
|
||||
if (cmgr == QSE_NULL) return ret.setInt ((long_t)-1);
|
||||
if (cmgr == QSE_NULL) return ret.setInt ((int_t)-1);
|
||||
}
|
||||
|
||||
ioattr = find_or_make_ioattr (ptr[0], l[0]);
|
||||
@ -518,7 +524,7 @@ int StdAwk::setioattr (
|
||||
else
|
||||
{
|
||||
// unknown attribute name
|
||||
return ret.setInt ((long_t)-1);
|
||||
return ret.setInt ((int_t)-1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -546,7 +552,7 @@ int StdAwk::getioattr (
|
||||
if ((tmout = timeout_code(ptr[1])) >= 0)
|
||||
{
|
||||
if (ioattr->tmout[tmout].nsec == 0)
|
||||
xx = args[2].setInt ((long_t)ioattr->tmout[tmout].sec);
|
||||
xx = args[2].setInt ((int_t)ioattr->tmout[tmout].sec);
|
||||
else
|
||||
xx = args[2].setFlt ((qse_awk_flt_t)ioattr->tmout[tmout].sec + QSE_NSEC_TO_SEC((qse_awk_flt_t)ioattr->tmout[tmout].nsec));
|
||||
}
|
||||
@ -559,7 +565,7 @@ int StdAwk::getioattr (
|
||||
}
|
||||
|
||||
// unknown attribute name or errors
|
||||
return ret.setInt ((long_t)xx);
|
||||
return ret.setInt ((int_t)xx);
|
||||
}
|
||||
|
||||
int StdAwk::open_nwio (Pipe& io, int flags, void* nwad)
|
||||
@ -919,7 +925,7 @@ int StdAwk::open_console_in (Console& io)
|
||||
|
||||
// ok to find ARGV[this->runarg_index] as ARGV[0]
|
||||
// has been skipped.
|
||||
ibuflen = qse_awk_longtostr (
|
||||
ibuflen = qse_awk_inttostr (
|
||||
rtx->awk, this->runarg_index,
|
||||
10, QSE_NULL,
|
||||
ibuf, QSE_COUNTOF(ibuf)
|
||||
|
@ -311,8 +311,8 @@ struct qse_awk_rtx_t
|
||||
void* fs[2];
|
||||
int ignorecase;
|
||||
|
||||
qse_long_t nr;
|
||||
qse_long_t fnr;
|
||||
qse_awk_int_t nr;
|
||||
qse_awk_int_t fnr;
|
||||
|
||||
qse_xstr_t convfmt;
|
||||
qse_xstr_t ofmt;
|
||||
|
@ -296,7 +296,7 @@ skip_close:
|
||||
|
||||
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, name);
|
||||
|
||||
v = qse_awk_rtx_makeintval (rtx, (qse_long_t)n);
|
||||
v = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)n);
|
||||
if (v == QSE_NULL) return -1;
|
||||
|
||||
qse_awk_rtx_setretval (rtx, v);
|
||||
@ -434,7 +434,7 @@ static int fnc_fflush (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
|
||||
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str0);
|
||||
}
|
||||
|
||||
a0 = qse_awk_rtx_makeintval (run, (qse_long_t)n);
|
||||
a0 = qse_awk_rtx_makeintval (run, (qse_awk_int_t)n);
|
||||
if (a0 == QSE_NULL) return -1;
|
||||
|
||||
qse_awk_rtx_setretval (run, a0);
|
||||
@ -447,7 +447,7 @@ static int fnc_index (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
qse_awk_val_t* a0, * a1;
|
||||
qse_char_t* str0, * str1, * ptr;
|
||||
qse_size_t len0, len1;
|
||||
qse_long_t idx, start = 1;
|
||||
qse_awk_int_t idx, start = 1;
|
||||
|
||||
nargs = qse_awk_rtx_getnargs (rtx);
|
||||
QSE_ASSERT (nargs >= 2 && nargs <= 3);
|
||||
@ -461,7 +461,7 @@ static int fnc_index (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
int n;
|
||||
|
||||
a2 = qse_awk_rtx_getarg (rtx, 2);
|
||||
n = qse_awk_rtx_valtolong (rtx, a2, &start);
|
||||
n = qse_awk_rtx_valtoint (rtx, a2, &start);
|
||||
if (n <= -1) return -1;
|
||||
}
|
||||
|
||||
@ -500,7 +500,7 @@ static int fnc_index (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
qse_strxncasestr (&str0[start-1], len0-start+1, str1, len1):
|
||||
qse_strxnstr (&str0[start-1], len0-start+1, str1, len1);
|
||||
|
||||
idx = (ptr == QSE_NULL)? 0: ((qse_long_t)(ptr-str0) + 1);
|
||||
idx = (ptr == QSE_NULL)? 0: ((qse_awk_int_t)(ptr-str0) + 1);
|
||||
|
||||
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str0);
|
||||
if (a1->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str1);
|
||||
@ -562,7 +562,7 @@ static int fnc_substr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
qse_awk_val_t* a0, * a1, * a2, * r;
|
||||
qse_char_t* str;
|
||||
qse_size_t len;
|
||||
qse_long_t lindex, lcount;
|
||||
qse_awk_int_t lindex, lcount;
|
||||
int n;
|
||||
|
||||
nargs = qse_awk_rtx_getnargs (rtx);
|
||||
@ -583,17 +583,17 @@ static int fnc_substr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
if (str == QSE_NULL) return -1;
|
||||
}
|
||||
|
||||
n = qse_awk_rtx_valtolong (rtx, a1, &lindex);
|
||||
n = qse_awk_rtx_valtoint (rtx, a1, &lindex);
|
||||
if (n <= -1)
|
||||
{
|
||||
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (a2 == QSE_NULL) lcount = (qse_long_t)len;
|
||||
if (a2 == QSE_NULL) lcount = (qse_awk_int_t)len;
|
||||
else
|
||||
{
|
||||
n = qse_awk_rtx_valtolong (rtx, a2, &lcount);
|
||||
n = qse_awk_rtx_valtoint (rtx, a2, &lcount);
|
||||
if (n <= -1)
|
||||
{
|
||||
if (a0->type != QSE_AWK_VAL_STR)
|
||||
@ -603,13 +603,13 @@ static int fnc_substr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
}
|
||||
|
||||
lindex = lindex - 1;
|
||||
if (lindex >= (qse_long_t)len) lindex = (qse_long_t)len;
|
||||
if (lindex >= (qse_awk_int_t)len) lindex = (qse_awk_int_t)len;
|
||||
else if (lindex < 0) lindex = 0;
|
||||
|
||||
if (lcount < 0) lcount = 0;
|
||||
else if (lcount > (qse_long_t)len - lindex)
|
||||
else if (lcount > (qse_awk_int_t)len - lindex)
|
||||
{
|
||||
lcount = (qse_long_t)len - lindex;
|
||||
lcount = (qse_awk_int_t)len - lindex;
|
||||
}
|
||||
|
||||
r = qse_awk_rtx_makestrval (rtx, &str[lindex], (qse_size_t)lcount);
|
||||
@ -637,7 +637,7 @@ static int fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
void* fs_rex_free = QSE_NULL;
|
||||
|
||||
qse_cstr_t tok;
|
||||
qse_long_t nflds;
|
||||
qse_awk_int_t nflds;
|
||||
|
||||
qse_awk_errnum_t errnum;
|
||||
int x;
|
||||
@ -743,7 +743,7 @@ static int fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
while (p != QSE_NULL)
|
||||
{
|
||||
qse_char_t key_buf[QSE_SIZEOF(qse_long_t)*8+2];
|
||||
qse_char_t key_buf[QSE_SIZEOF(qse_awk_int_t)*8+2];
|
||||
qse_size_t key_len;
|
||||
|
||||
if (fs.len <= 1)
|
||||
@ -779,7 +779,7 @@ static int fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
if (t2 == QSE_NULL) goto oops;
|
||||
|
||||
/* put it into the map */
|
||||
key_len = qse_awk_longtostr (
|
||||
key_len = qse_awk_inttostr (
|
||||
rtx->awk, ++nflds, 10, QSE_NULL, key_buf, QSE_COUNTOF(key_buf));
|
||||
QSE_ASSERT (key_len != (qse_size_t)-1);
|
||||
|
||||
@ -899,7 +899,7 @@ static int fnc_toupper (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
|
||||
static int __substitute (qse_awk_rtx_t* run, qse_awk_int_t max_count)
|
||||
{
|
||||
qse_size_t nargs;
|
||||
qse_awk_val_t* a0, * a1, * a2, * v;
|
||||
@ -919,7 +919,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
|
||||
|
||||
qse_cstr_t mat, pmat, cur;
|
||||
|
||||
qse_long_t sub_count;
|
||||
qse_awk_int_t sub_count;
|
||||
|
||||
nargs = qse_awk_rtx_getnargs (run);
|
||||
QSE_ASSERT (nargs >= 2 && nargs <= 3);
|
||||
@ -1176,7 +1176,7 @@ static int fnc_match (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
qse_awk_val_t* a0, * a1;
|
||||
qse_char_t* str0;
|
||||
qse_size_t len0;
|
||||
qse_long_t idx, start = 1;
|
||||
qse_awk_int_t idx, start = 1;
|
||||
int n;
|
||||
qse_cstr_t mat;
|
||||
|
||||
@ -1206,7 +1206,7 @@ static int fnc_match (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
/* if the 3rd parameter is not an array,
|
||||
* it is treated as a match start index */
|
||||
n = qse_awk_rtx_valtolong (rtx, a2, &start);
|
||||
n = qse_awk_rtx_valtoint (rtx, a2, &start);
|
||||
if (n <= -1) return -1;
|
||||
}
|
||||
}
|
||||
@ -1240,7 +1240,7 @@ static int fnc_match (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str0);
|
||||
|
||||
idx = (n == 0)? 0: ((qse_long_t)(mat.ptr-str0) + 1);
|
||||
idx = (n == 0)? 0: ((qse_awk_int_t)(mat.ptr-str0) + 1);
|
||||
|
||||
a0 = qse_awk_rtx_makeintval (rtx, idx);
|
||||
if (a0 == QSE_NULL) return -1;
|
||||
@ -1248,7 +1248,7 @@ static int fnc_match (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
qse_awk_rtx_refupval (rtx, a0);
|
||||
|
||||
a1 = qse_awk_rtx_makeintval (rtx,
|
||||
((n == 0)? (qse_long_t)-1: (qse_long_t)mat.len));
|
||||
((n == 0)? (qse_awk_int_t)-1: (qse_awk_int_t)mat.len));
|
||||
if (a1 == QSE_NULL)
|
||||
{
|
||||
qse_awk_rtx_refdownval (rtx, a0);
|
||||
@ -1427,7 +1427,7 @@ static int fnc_int (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_size_t nargs;
|
||||
qse_awk_val_t* a0;
|
||||
qse_long_t lv;
|
||||
qse_awk_int_t lv;
|
||||
qse_awk_val_t* r;
|
||||
int n;
|
||||
|
||||
@ -1436,7 +1436,7 @@ static int fnc_int (qse_awk_rtx_t* run, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
a0 = qse_awk_rtx_getarg (run, 0);
|
||||
|
||||
n = qse_awk_rtx_valtolong (run, a0, &lv);
|
||||
n = qse_awk_rtx_valtoint (run, a0, &lv);
|
||||
if (n <= -1) return -1;
|
||||
|
||||
r = qse_awk_rtx_makeintval (run, lv);
|
||||
|
@ -76,11 +76,11 @@ qse_char_t* qse_awk_cstrdup (qse_awk_t* awk, const qse_cstr_t* s)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
qse_long_t qse_awk_strxtolong (
|
||||
qse_awk_int_t qse_awk_strxtoint (
|
||||
qse_awk_t* awk, const qse_char_t* str, qse_size_t len,
|
||||
int base, const qse_char_t** endptr)
|
||||
{
|
||||
qse_long_t n = 0;
|
||||
qse_awk_int_t n = 0;
|
||||
const qse_char_t* p;
|
||||
const qse_char_t* end;
|
||||
qse_size_t rem;
|
||||
@ -581,11 +581,11 @@ done:
|
||||
return (negative)? -fraction: fraction;
|
||||
}
|
||||
|
||||
qse_size_t qse_awk_longtostr (
|
||||
qse_awk_t* awk, qse_long_t value,
|
||||
qse_size_t qse_awk_inttostr (
|
||||
qse_awk_t* awk, qse_awk_int_t value,
|
||||
int radix, const qse_char_t* prefix, qse_char_t* buf, qse_size_t size)
|
||||
{
|
||||
qse_long_t t, rem;
|
||||
qse_awk_int_t t, rem;
|
||||
qse_size_t len, ret, i;
|
||||
qse_size_t prefix_len;
|
||||
|
||||
|
@ -231,7 +231,7 @@ static void free_dir_node (qse_awk_rtx_t* rtx, dir_list_t* list, dir_node_t* nod
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static int close_byid (qse_awk_rtx_t* rtx, dir_list_t* list, qse_long_t id)
|
||||
static int close_byid (qse_awk_rtx_t* rtx, dir_list_t* list, qse_awk_int_t id)
|
||||
{
|
||||
if (id >= 0 && id < list->map.high && list->map.tab[id])
|
||||
{
|
||||
@ -245,7 +245,7 @@ static int close_byid (qse_awk_rtx_t* rtx, dir_list_t* list, qse_long_t id)
|
||||
}
|
||||
}
|
||||
|
||||
static int reset_byid (qse_awk_rtx_t* rtx, dir_list_t* list, qse_long_t id, const qse_char_t* path)
|
||||
static int reset_byid (qse_awk_rtx_t* rtx, dir_list_t* list, qse_awk_int_t id, const qse_char_t* path)
|
||||
{
|
||||
if (id >= 0 && id < list->map.high && list->map.tab[id])
|
||||
{
|
||||
@ -263,7 +263,7 @@ static int reset_byid (qse_awk_rtx_t* rtx, dir_list_t* list, qse_long_t id, cons
|
||||
}
|
||||
}
|
||||
|
||||
static int read_byid (qse_awk_rtx_t* rtx, dir_list_t* list, qse_long_t id, qse_awk_val_ref_t* ref)
|
||||
static int read_byid (qse_awk_rtx_t* rtx, dir_list_t* list, qse_awk_int_t id, qse_awk_val_ref_t* ref)
|
||||
{
|
||||
if (id >= 0 && id < list->map.high && list->map.tab[id])
|
||||
{
|
||||
@ -345,12 +345,12 @@ static int fnc_dir_errstr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
dir_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t errnum;
|
||||
qse_awk_int_t errnum;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
if (qse_awk_rtx_getnargs (rtx) <= 0 ||
|
||||
qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &errnum) <= -1)
|
||||
qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &errnum) <= -1)
|
||||
{
|
||||
errnum = list->errnum;
|
||||
}
|
||||
@ -368,7 +368,7 @@ static int fnc_dir_open (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
dir_list_t* list;
|
||||
dir_node_t* node = QSE_NULL;
|
||||
qse_long_t ret;
|
||||
qse_awk_int_t ret;
|
||||
qse_char_t* path;
|
||||
qse_awk_val_t* retv;
|
||||
|
||||
@ -404,12 +404,12 @@ static int fnc_dir_open (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
static int fnc_dir_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
dir_list_t* list;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1)
|
||||
{
|
||||
list->errnum = awk_err_to_errnum (qse_awk_rtx_geterrnum (rtx));
|
||||
@ -427,13 +427,13 @@ static int fnc_dir_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
static int fnc_dir_reset (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
dir_list_t* list;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
qse_char_t* path;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1)
|
||||
{
|
||||
list->errnum = awk_err_to_errnum (qse_awk_rtx_geterrnum (rtx));
|
||||
@ -462,12 +462,12 @@ static int fnc_dir_reset (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
static int fnc_dir_read (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
dir_list_t* list;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1)
|
||||
{
|
||||
list->errnum = awk_err_to_errnum (qse_awk_rtx_geterrnum (rtx));
|
||||
|
@ -57,7 +57,7 @@ static int fnc_rank (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
static int fnc_hash (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t hv;
|
||||
qse_awk_int_t hv;
|
||||
|
||||
hv = qse_awk_rtx_hashval (rtx, qse_awk_rtx_getarg (rtx, 0));
|
||||
|
||||
@ -71,10 +71,10 @@ static int fnc_hash (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
static int fnc_assign (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t limit;
|
||||
qse_awk_int_t limit;
|
||||
int rx;
|
||||
|
||||
rx = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &limit);
|
||||
rx = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &limit);
|
||||
if (rx >= 0)
|
||||
{
|
||||
qse_awk_nrflt_t nrflt;
|
||||
@ -98,7 +98,7 @@ static int fnc_assign (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
static int fnc_reduce (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t opidx, lv;
|
||||
qse_awk_int_t opidx, lv;
|
||||
qse_awk_flt_t rv;
|
||||
int n;
|
||||
|
||||
@ -112,14 +112,14 @@ static int fnc_reduce (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
MPI_LOR
|
||||
};
|
||||
|
||||
if (qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 1), &opidx) <= -1 ||
|
||||
if (qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 1), &opidx) <= -1 ||
|
||||
(opidx < 0 || opidx >= QSE_COUNTOF(optab)) ||
|
||||
(n = qse_awk_rtx_valtonum (rtx, qse_awk_rtx_getarg (rtx, 0), &lv, &rv)) <= -1) goto softfail;
|
||||
|
||||
/* TODO: determine it to be MPI_LONG or MPI_INT, OR MPI_LONG_LONG_INT depending on the size of qse_long_t */
|
||||
/* TODO: determine it to be MPI_LONG or MPI_INT, OR MPI_LONG_LONG_INT depending on the size of qse_awk_int_t */
|
||||
if (n == 0)
|
||||
{
|
||||
qse_long_t lout;
|
||||
qse_awk_int_t lout;
|
||||
if (MPI_Allreduce (&lv, &lout, 1, MPI_LONG_LONG_INT, optab[opidx], MPI_COMM_WORLD) != MPI_SUCCESS) goto softfail;
|
||||
retv = qse_awk_rtx_makeintval (rtx, lout);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ static int index_or_rindex (qse_awk_rtx_t* rtx, int rindex)
|
||||
qse_awk_val_t* a0, * a1;
|
||||
qse_char_t* str0, * str1, * ptr;
|
||||
qse_size_t len0, len1;
|
||||
qse_long_t idx, boundary = 1;
|
||||
qse_awk_int_t idx, boundary = 1;
|
||||
|
||||
nargs = qse_awk_rtx_getnargs (rtx);
|
||||
a0 = qse_awk_rtx_getarg (rtx, 0);
|
||||
@ -101,7 +101,7 @@ static int index_or_rindex (qse_awk_rtx_t* rtx, int rindex)
|
||||
int n;
|
||||
|
||||
a2 = qse_awk_rtx_getarg (rtx, 2);
|
||||
n = qse_awk_rtx_valtolong (rtx, a2, &boundary);
|
||||
n = qse_awk_rtx_valtoint (rtx, a2, &boundary);
|
||||
if (n <= -1) return -1;
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ static int index_or_rindex (qse_awk_rtx_t* rtx, int rindex)
|
||||
QSE_NULL: qse_strxnstr (&str0[boundary-1], len0-boundary+1, str1, len1);
|
||||
}
|
||||
|
||||
idx = (ptr == QSE_NULL)? 0: ((qse_long_t)(ptr-str0) + 1);
|
||||
idx = (ptr == QSE_NULL)? 0: ((qse_awk_int_t)(ptr-str0) + 1);
|
||||
|
||||
if (a0->type != QSE_AWK_VAL_STR) qse_awk_rtx_freemem (rtx, str0);
|
||||
if (a1->type != QSE_AWK_VAL_STR) qse_awk_rtx_freemem (rtx, str1);
|
||||
|
@ -46,7 +46,7 @@
|
||||
|
||||
static int fnc_fork (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_long_t pid;
|
||||
qse_awk_int_t pid;
|
||||
qse_awk_val_t* retv;
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -74,13 +74,13 @@ static int fnc_fork (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
static int fnc_wait (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_long_t pid;
|
||||
qse_awk_int_t pid;
|
||||
qse_awk_val_t* retv;
|
||||
int rx;
|
||||
|
||||
/* TODO: handle more parameters */
|
||||
|
||||
rx = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &pid);
|
||||
rx = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &pid);
|
||||
if (rx >= 0)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
@ -106,12 +106,12 @@ static int fnc_wait (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
static int fnc_kill (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_long_t pid, sig;
|
||||
qse_awk_int_t pid, sig;
|
||||
qse_awk_val_t* retv;
|
||||
int rx;
|
||||
|
||||
if (qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &pid) <= -1 ||
|
||||
qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 1), &sig) <= -1)
|
||||
if (qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &pid) <= -1 ||
|
||||
qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 1), &sig) <= -1)
|
||||
{
|
||||
rx = -1;
|
||||
}
|
||||
@ -140,7 +140,7 @@ static int fnc_kill (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
static int fnc_getpgrp (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_long_t pid;
|
||||
qse_awk_int_t pid;
|
||||
qse_awk_val_t* retv;
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -168,7 +168,7 @@ static int fnc_getpgrp (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
static int fnc_getpid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_long_t pid;
|
||||
qse_awk_int_t pid;
|
||||
qse_awk_val_t* retv;
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -225,7 +225,7 @@ static int fnc_gettid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
retv = qse_awk_rtx_makeintval (rtx, (qse_long_t)pid);
|
||||
retv = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)pid);
|
||||
if (retv == QSE_NULL) return -1;
|
||||
|
||||
qse_awk_rtx_setretval (rtx, retv);
|
||||
@ -234,7 +234,7 @@ static int fnc_gettid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
static int fnc_getppid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_long_t pid;
|
||||
qse_awk_int_t pid;
|
||||
qse_awk_val_t* retv;
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -262,7 +262,7 @@ static int fnc_getppid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
static int fnc_getuid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_long_t uid;
|
||||
qse_awk_int_t uid;
|
||||
qse_awk_val_t* retv;
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -290,7 +290,7 @@ static int fnc_getuid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
static int fnc_getgid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_long_t gid;
|
||||
qse_awk_int_t gid;
|
||||
qse_awk_val_t* retv;
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -318,7 +318,7 @@ static int fnc_getgid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
static int fnc_geteuid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_long_t uid;
|
||||
qse_awk_int_t uid;
|
||||
qse_awk_val_t* retv;
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -346,7 +346,7 @@ static int fnc_geteuid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
static int fnc_getegid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_long_t gid;
|
||||
qse_awk_int_t gid;
|
||||
qse_awk_val_t* retv;
|
||||
|
||||
#if defined(_WIN32)
|
||||
@ -374,7 +374,7 @@ static int fnc_getegid (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
static int fnc_sleep (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_long_t lv;
|
||||
qse_awk_int_t lv;
|
||||
qse_awk_flt_t fv;
|
||||
qse_awk_val_t* retv;
|
||||
int rx;
|
||||
@ -409,20 +409,20 @@ static int fnc_sleep (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
rx = 0;
|
||||
#elif defined(__DOS__)
|
||||
/* no high-resolution sleep() is available */
|
||||
rx = sleep ((qse_long_t)fv);
|
||||
rx = sleep ((qse_awk_int_t)fv);
|
||||
#elif defined(HAVE_NANOSLEEP)
|
||||
struct timespec req;
|
||||
req.tv_sec = (qse_long_t)fv;
|
||||
req.tv_sec = (qse_awk_int_t)fv;
|
||||
req.tv_nsec = QSE_SEC_TO_NSEC(fv - req.tv_sec);
|
||||
rx = nanosleep (&req, QSE_NULL);
|
||||
#elif defined(HAVE_SELECT)
|
||||
struct timeval req;
|
||||
req.tv_sec = (qse_long_t)fv;
|
||||
req.tv_sec = (qse_awk_int_t)fv;
|
||||
req.tv_nsec = QSE_SEC_TO_USEC(fv - req.tv_sec);
|
||||
rx = select (0, QSE_NULL, QSE_NULL, QSE_NULL, &req);
|
||||
#else
|
||||
/* no high-resolution sleep() is available */
|
||||
rx = sleep ((qse_long_t)fv);
|
||||
rx = sleep ((qse_awk_int_t)fv);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -455,7 +455,7 @@ static int fnc_settime (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
now.nsec = 0;
|
||||
|
||||
if (qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &now.sec) <= -1 ||
|
||||
if (qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &now.sec) <= -1 ||
|
||||
qse_settime (&now) <= -1) rx = -1;
|
||||
else rx = 0;
|
||||
|
||||
@ -504,10 +504,10 @@ static int fnc_getnwifcfg (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
out.u.cplcpy.len = QSE_COUNTOF(cfg.name);
|
||||
if (qse_awk_rtx_valtostr (rtx, qse_awk_rtx_getarg (rtx, 0), &out) >= 0)
|
||||
{
|
||||
qse_long_t type;
|
||||
qse_awk_int_t type;
|
||||
int rx;
|
||||
|
||||
rx = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 1), &type);
|
||||
rx = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 1), &type);
|
||||
if (rx >= 0)
|
||||
{
|
||||
cfg.type = type;
|
||||
@ -515,7 +515,7 @@ static int fnc_getnwifcfg (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
if (qse_getnwifcfg (&cfg) >= 0)
|
||||
{
|
||||
/* make a map value containg configuration */
|
||||
qse_long_t index, mtu;
|
||||
qse_awk_int_t index, mtu;
|
||||
qse_char_t addr[128];
|
||||
qse_char_t mask[128];
|
||||
qse_char_t ethw[32];
|
||||
|
@ -174,7 +174,7 @@ static void free_uctx_node (qse_awk_rtx_t* rtx, uctx_list_t* list, uctx_node_t*
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
static int close_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id)
|
||||
static int close_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -188,7 +188,7 @@ static int close_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id)
|
||||
}
|
||||
|
||||
static int load_byid (
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* path)
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* path)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -200,7 +200,7 @@ static int load_byid (
|
||||
return -x;
|
||||
}
|
||||
|
||||
static int unload_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id)
|
||||
static int unload_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -213,7 +213,7 @@ static int unload_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id)
|
||||
return -x;
|
||||
}
|
||||
|
||||
static int save_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* item)
|
||||
static int save_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -236,7 +236,7 @@ static int save_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_
|
||||
return -x;
|
||||
}
|
||||
|
||||
static int commit_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* item)
|
||||
static int commit_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -258,7 +258,7 @@ static int commit_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qs
|
||||
return -x;
|
||||
}
|
||||
|
||||
static int revert_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* item)
|
||||
static int revert_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -280,7 +280,7 @@ static int revert_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qs
|
||||
return -x;
|
||||
}
|
||||
|
||||
static int delete_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* item)
|
||||
static int delete_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -302,7 +302,7 @@ static int delete_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qs
|
||||
return -x;
|
||||
}
|
||||
|
||||
static int rename_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* item)
|
||||
static int rename_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -324,7 +324,7 @@ static int rename_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qs
|
||||
return -x;
|
||||
}
|
||||
|
||||
static int set_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* item)
|
||||
static int set_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -343,7 +343,7 @@ static int set_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_m
|
||||
return -x;
|
||||
}
|
||||
|
||||
static int addsection_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* item, qse_mchar_t* type)
|
||||
static int addsection_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item, qse_mchar_t* type)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -366,7 +366,7 @@ static int addsection_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id
|
||||
return -x;
|
||||
}
|
||||
|
||||
static int addlist_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* item)
|
||||
static int addlist_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* item)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -386,7 +386,7 @@ static int addlist_byid (qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, q
|
||||
}
|
||||
|
||||
static int setconfdir_byid (
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* path)
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* path)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -399,7 +399,7 @@ static int setconfdir_byid (
|
||||
}
|
||||
|
||||
static int setsavedir_byid (
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* path)
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* path)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -412,7 +412,7 @@ static int setsavedir_byid (
|
||||
}
|
||||
|
||||
static int adddeltapath_byid (
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id, qse_mchar_t* path)
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id, qse_mchar_t* path)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
|
||||
@ -425,7 +425,7 @@ static int adddeltapath_byid (
|
||||
}
|
||||
|
||||
static int getsection_byid (
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id,
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id,
|
||||
qse_mchar_t* tuple, qse_awk_val_ref_t* ref)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
@ -447,7 +447,7 @@ static int getsection_byid (
|
||||
if (e->type == UCI_TYPE_SECTION)
|
||||
{
|
||||
qse_awk_val_map_data_t md[4];
|
||||
qse_long_t lv;
|
||||
qse_awk_int_t lv;
|
||||
qse_awk_val_t* tmp;
|
||||
|
||||
QSE_MEMSET (md, 0, QSE_SIZEOF(md));
|
||||
@ -490,7 +490,7 @@ static int getsection_byid (
|
||||
}
|
||||
|
||||
static int getoption_byid (
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_long_t id,
|
||||
qse_awk_rtx_t* rtx, uctx_list_t* list, qse_awk_int_t id,
|
||||
qse_mchar_t* tuple, qse_awk_val_ref_t* ref)
|
||||
{
|
||||
int x = UCI_ERR_INVAL;
|
||||
@ -550,7 +550,7 @@ static int getoption_byid (
|
||||
qse_awk_val_t* map, * fld;
|
||||
qse_awk_val_map_data_t md[3];
|
||||
struct uci_element* tmp;
|
||||
qse_long_t count;
|
||||
qse_awk_int_t count;
|
||||
|
||||
count = 0;
|
||||
uci_foreach_element(&uo->v.list, tmp) { count++; }
|
||||
@ -680,12 +680,12 @@ static int fnc_uci_errstr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t errnum;
|
||||
qse_awk_int_t errnum;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
if (qse_awk_rtx_getnargs (rtx) <= 0 ||
|
||||
qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &errnum) <= -1)
|
||||
qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &errnum) <= -1)
|
||||
{
|
||||
errnum = list->errnum;
|
||||
}
|
||||
@ -703,7 +703,7 @@ static int fnc_uci_open (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
uctx_node_t* node;
|
||||
qse_long_t ret;
|
||||
qse_awk_int_t ret;
|
||||
qse_awk_val_t* retv;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
@ -727,12 +727,12 @@ static int fnc_uci_close (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else ret = close_byid (rtx, list, id);
|
||||
|
||||
@ -753,12 +753,12 @@ static int fnc_uci_load (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -790,12 +790,12 @@ static int fnc_uci_unload (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else ret = unload_byid (rtx, list, id);
|
||||
|
||||
@ -816,12 +816,12 @@ static int fnc_uci_save (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -853,12 +853,12 @@ static int fnc_uci_commit (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -890,12 +890,12 @@ static int fnc_uci_revert (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -927,12 +927,12 @@ static int fnc_uci_delete (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -964,12 +964,12 @@ static int fnc_uci_rename (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -1001,12 +1001,12 @@ static int fnc_uci_set (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -1038,12 +1038,12 @@ static int fnc_uci_addsection (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -1078,12 +1078,12 @@ static int fnc_uci_addlist (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -1115,12 +1115,12 @@ static int fnc_uci_setconfdir (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -1153,12 +1153,12 @@ static int fnc_uci_setsavedir (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -1190,12 +1190,12 @@ static int fnc_uci_adddeltapath (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t*
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_awk_val_t* retv;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -1226,12 +1226,12 @@ static int fnc_uci_adddeltapath (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t*
|
||||
static int fnc_uci_getoption (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
@ -1261,12 +1261,12 @@ static int fnc_uci_getoption (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
static int fnc_uci_getsection (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
uctx_list_t* list;
|
||||
qse_long_t id;
|
||||
qse_awk_int_t id;
|
||||
int ret;
|
||||
|
||||
list = rtx_to_list (rtx, fi);
|
||||
|
||||
ret = qse_awk_rtx_valtolong (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
ret = qse_awk_rtx_valtoint (rtx, qse_awk_rtx_getarg (rtx, 0), &id);
|
||||
if (ret <= -1) ret = -UCI_ERR_INVAL;
|
||||
else
|
||||
{
|
||||
|
@ -3253,7 +3253,7 @@ static qse_awk_nde_t* parse_expr_withdc (
|
||||
|
||||
union folded_t
|
||||
{
|
||||
qse_long_t l;
|
||||
qse_awk_int_t l;
|
||||
qse_awk_flt_t r;
|
||||
};
|
||||
typedef union folded_t folded_t;
|
||||
@ -3330,7 +3330,7 @@ static int fold_constants_for_binop (
|
||||
break;
|
||||
|
||||
case QSE_AWK_BINOP_IDIV:
|
||||
folded->l = (qse_long_t)FLT_BINOP_FLT(left,/,right);
|
||||
folded->l = (qse_awk_int_t)FLT_BINOP_FLT(left,/,right);
|
||||
fold = QSE_AWK_NDE_INT;
|
||||
break;
|
||||
|
||||
@ -3370,7 +3370,7 @@ static int fold_constants_for_binop (
|
||||
break;
|
||||
|
||||
case QSE_AWK_BINOP_IDIV:
|
||||
folded->l = (qse_long_t)
|
||||
folded->l = (qse_awk_int_t)
|
||||
((qse_awk_flt_t)((qse_awk_nde_int_t*)left)->val /
|
||||
((qse_awk_nde_flt_t*)right)->val);
|
||||
fold = QSE_AWK_NDE_INT;
|
||||
@ -3412,7 +3412,7 @@ static int fold_constants_for_binop (
|
||||
break;
|
||||
|
||||
case QSE_AWK_BINOP_IDIV:
|
||||
folded->l = (qse_long_t)
|
||||
folded->l = (qse_awk_int_t)
|
||||
(((qse_awk_nde_int_t*)left)->val /
|
||||
(qse_awk_flt_t)((qse_awk_nde_int_t*)right)->val);
|
||||
fold = QSE_AWK_NDE_INT;
|
||||
@ -3456,7 +3456,7 @@ static qse_awk_nde_t* new_exp_bin_node (
|
||||
}
|
||||
|
||||
static qse_awk_nde_t* new_int_node (
|
||||
qse_awk_t* awk, qse_long_t lv, const qse_awk_loc_t* loc)
|
||||
qse_awk_t* awk, qse_awk_int_t lv, const qse_awk_loc_t* loc)
|
||||
{
|
||||
qse_awk_nde_int_t* tmp;
|
||||
|
||||
@ -3490,7 +3490,7 @@ static qse_awk_nde_t* new_flt_node (
|
||||
}
|
||||
|
||||
static QSE_INLINE void update_int_node (
|
||||
qse_awk_t* awk, qse_awk_nde_int_t* node, qse_long_t lv)
|
||||
qse_awk_t* awk, qse_awk_nde_int_t* node, qse_awk_int_t lv)
|
||||
{
|
||||
node->val = lv;
|
||||
if (node->str)
|
||||
@ -3948,7 +3948,7 @@ static qse_awk_nde_t* parse_unary (qse_awk_t* awk, const qse_awk_loc_t* xloc)
|
||||
break;
|
||||
|
||||
case QSE_AWK_UNROP_BNOT:
|
||||
folded.l = ~((qse_long_t)((qse_awk_nde_flt_t*)left)->val);
|
||||
folded.l = ~((qse_awk_int_t)((qse_awk_nde_flt_t*)left)->val);
|
||||
fold = QSE_AWK_NDE_INT;
|
||||
break;
|
||||
|
||||
@ -4228,7 +4228,7 @@ static qse_awk_nde_t* parse_primary_int (qse_awk_t* awk, const qse_awk_loc_t* x
|
||||
/* create the node for the literal */
|
||||
nde = (qse_awk_nde_int_t*)new_int_node (
|
||||
awk,
|
||||
qse_awk_strxtolong (awk,
|
||||
qse_awk_strxtoint (awk,
|
||||
QSE_STR_PTR(awk->tok.name),
|
||||
QSE_STR_LEN(awk->tok.name),
|
||||
0, QSE_NULL
|
||||
@ -6304,8 +6304,8 @@ static int deparse (qse_awk_t* awk)
|
||||
}
|
||||
else
|
||||
{
|
||||
len = qse_awk_longtostr (
|
||||
awk, (qse_long_t)i,
|
||||
len = qse_awk_inttostr (
|
||||
awk, (qse_awk_int_t)i,
|
||||
10, QSE_T("__g"), tmp, QSE_COUNTOF(tmp));
|
||||
QSE_ASSERT (len != (qse_size_t)-1);
|
||||
if (qse_awk_putsrcstrn (awk, tmp, len) <= -1)
|
||||
@ -6329,8 +6329,8 @@ static int deparse (qse_awk_t* awk)
|
||||
}
|
||||
else
|
||||
{
|
||||
len = qse_awk_longtostr (
|
||||
awk, (qse_long_t)i,
|
||||
len = qse_awk_inttostr (
|
||||
awk, (qse_awk_int_t)i,
|
||||
10, QSE_T("__g"), tmp, QSE_COUNTOF(tmp));
|
||||
QSE_ASSERT (len != (qse_size_t)-1);
|
||||
if (qse_awk_putsrcstrn (awk, tmp, len) <= -1)
|
||||
@ -6500,7 +6500,7 @@ static qse_htb_walk_t deparse_func (
|
||||
|
||||
for (i = 0; i < fun->nargs; )
|
||||
{
|
||||
n = qse_awk_longtostr (
|
||||
n = qse_awk_inttostr (
|
||||
df->awk, i++, 10,
|
||||
QSE_T("__p"), df->tmp, df->tmp_len);
|
||||
QSE_ASSERT (n != (qse_size_t)-1);
|
||||
|
@ -337,7 +337,7 @@ static int split_record (qse_awk_rtx_t* rtx)
|
||||
if (fs_free != QSE_NULL) QSE_AWK_FREE (rtx->awk, fs_free);
|
||||
|
||||
/* set the number of fields */
|
||||
v = qse_awk_rtx_makeintval (rtx, (qse_long_t)rtx->inrec.nflds);
|
||||
v = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)rtx->inrec.nflds);
|
||||
if (v == QSE_NULL) return -1;
|
||||
|
||||
qse_awk_rtx_refupval (rtx, v);
|
||||
@ -510,7 +510,7 @@ static int recomp_record_fields (
|
||||
|
||||
if (((qse_awk_val_int_t*)v)->val != max)
|
||||
{
|
||||
v = qse_awk_rtx_makeintval (run, (qse_long_t)max);
|
||||
v = qse_awk_rtx_makeintval (run, (qse_awk_int_t)max);
|
||||
if (v == QSE_NULL) return -1;
|
||||
|
||||
qse_awk_rtx_refupval (run, v);
|
||||
|
@ -67,7 +67,7 @@ struct pafv
|
||||
* equal to sizeof(qse_size_t). */
|
||||
#define IS_VALID_POSIDX(idx) \
|
||||
((idx) >= 0 && \
|
||||
(idx) <= QSE_TYPE_MAX(qse_long_t) && \
|
||||
(idx) <= QSE_TYPE_MAX(qse_awk_int_t) && \
|
||||
(idx) <= QSE_TYPE_MAX(qse_size_t))
|
||||
|
||||
#define SETERR_ARGX_LOC(rtx,code,ea,loc) \
|
||||
@ -429,9 +429,9 @@ static int set_global (
|
||||
case QSE_AWK_GBL_FNR:
|
||||
{
|
||||
int n;
|
||||
qse_long_t lv;
|
||||
qse_awk_int_t lv;
|
||||
|
||||
n = qse_awk_rtx_valtolong (rtx, val, &lv);
|
||||
n = qse_awk_rtx_valtoint (rtx, val, &lv);
|
||||
if (n <= -1) return -1;
|
||||
|
||||
rtx->gbl.fnr = lv;
|
||||
@ -502,12 +502,12 @@ static int set_global (
|
||||
case QSE_AWK_GBL_NF:
|
||||
{
|
||||
int n;
|
||||
qse_long_t lv;
|
||||
qse_awk_int_t lv;
|
||||
|
||||
n = qse_awk_rtx_valtolong (rtx, val, &lv);
|
||||
n = qse_awk_rtx_valtoint (rtx, val, &lv);
|
||||
if (n <= -1) return -1;
|
||||
|
||||
if (lv < (qse_long_t)rtx->inrec.nflds)
|
||||
if (lv < (qse_awk_int_t)rtx->inrec.nflds)
|
||||
{
|
||||
if (shorten_record (rtx, (qse_size_t)lv) == -1)
|
||||
{
|
||||
@ -524,9 +524,9 @@ static int set_global (
|
||||
case QSE_AWK_GBL_NR:
|
||||
{
|
||||
int n;
|
||||
qse_long_t lv;
|
||||
qse_awk_int_t lv;
|
||||
|
||||
n = qse_awk_rtx_valtolong (rtx, val, &lv);
|
||||
n = qse_awk_rtx_valtoint (rtx, val, &lv);
|
||||
if (n <= -1) return -1;
|
||||
|
||||
rtx->gbl.nr = lv;
|
||||
@ -1170,7 +1170,7 @@ static void fini_rtx (qse_awk_rtx_t* rtx, int fini_globals)
|
||||
rtx->vmgr.rchunk = QSE_NULL;
|
||||
}
|
||||
|
||||
static int update_fnr (qse_awk_rtx_t* rtx, qse_long_t fnr, qse_long_t nr)
|
||||
static int update_fnr (qse_awk_rtx_t* rtx, qse_awk_int_t fnr, qse_awk_int_t nr)
|
||||
{
|
||||
qse_awk_val_t* tmp1, * tmp2;
|
||||
|
||||
@ -3779,7 +3779,7 @@ static qse_awk_val_t* do_assignment_pos (
|
||||
qse_awk_rtx_t* run, qse_awk_nde_pos_t* pos, qse_awk_val_t* val)
|
||||
{
|
||||
qse_awk_val_t* v;
|
||||
qse_long_t lv;
|
||||
qse_awk_int_t lv;
|
||||
qse_xstr_t str;
|
||||
int n;
|
||||
|
||||
@ -3787,7 +3787,7 @@ static qse_awk_val_t* do_assignment_pos (
|
||||
if (v == QSE_NULL) return QSE_NULL;
|
||||
|
||||
qse_awk_rtx_refupval (run, v);
|
||||
n = qse_awk_rtx_valtolong (run, v, &lv);
|
||||
n = qse_awk_rtx_valtoint (run, v, &lv);
|
||||
qse_awk_rtx_refdownval (run, v);
|
||||
|
||||
if (n <= -1)
|
||||
@ -4099,10 +4099,10 @@ static qse_awk_val_t* eval_binop_in (
|
||||
static qse_awk_val_t* eval_binop_bor (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
|
||||
if (qse_awk_rtx_valtolong (rtx, left, &l1) <= -1 ||
|
||||
qse_awk_rtx_valtolong (rtx, right, &l2) <= -1)
|
||||
if (qse_awk_rtx_valtoint (rtx, left, &l1) <= -1 ||
|
||||
qse_awk_rtx_valtoint (rtx, right, &l2) <= -1)
|
||||
{
|
||||
SETERR_COD (rtx, QSE_AWK_EOPERAND);
|
||||
return QSE_NULL;
|
||||
@ -4114,10 +4114,10 @@ static qse_awk_val_t* eval_binop_bor (
|
||||
static qse_awk_val_t* eval_binop_bxor (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
|
||||
if (qse_awk_rtx_valtolong (rtx, left, &l1) <= -1 ||
|
||||
qse_awk_rtx_valtolong (rtx, right, &l2) <= -1)
|
||||
if (qse_awk_rtx_valtoint (rtx, left, &l1) <= -1 ||
|
||||
qse_awk_rtx_valtoint (rtx, right, &l2) <= -1)
|
||||
{
|
||||
SETERR_COD (rtx, QSE_AWK_EOPERAND);
|
||||
return QSE_NULL;
|
||||
@ -4129,10 +4129,10 @@ static qse_awk_val_t* eval_binop_bxor (
|
||||
static qse_awk_val_t* eval_binop_band (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
|
||||
if (qse_awk_rtx_valtolong (rtx, left, &l1) <= -1 ||
|
||||
qse_awk_rtx_valtolong (rtx, right, &l2) <= -1)
|
||||
if (qse_awk_rtx_valtoint (rtx, left, &l1) <= -1 ||
|
||||
qse_awk_rtx_valtoint (rtx, right, &l2) <= -1)
|
||||
{
|
||||
SETERR_COD (rtx, QSE_AWK_EOPERAND);
|
||||
return QSE_NULL;
|
||||
@ -4206,7 +4206,7 @@ static int __cmp_int_str (
|
||||
/* SCO CC doesn't seem to handle right->nstr > 0 properly */
|
||||
if (rtx->awk->opt.trait & QSE_AWK_NCMPONSTR || right->nstr /*> 0*/)
|
||||
{
|
||||
qse_long_t ll;
|
||||
qse_awk_int_t ll;
|
||||
qse_awk_flt_t rr;
|
||||
|
||||
n = qse_awk_rtx_strtonum (
|
||||
@ -4371,16 +4371,16 @@ static int __cmp_str_str (
|
||||
|
||||
if (ls->nstr == 1)
|
||||
{
|
||||
qse_long_t ll;
|
||||
qse_awk_int_t ll;
|
||||
|
||||
ll = qse_awk_strxtolong (
|
||||
ll = qse_awk_strxtoint (
|
||||
rtx->awk, ls->val.ptr, ls->val.len, 0, QSE_NULL);
|
||||
|
||||
if (rs->nstr == 1)
|
||||
{
|
||||
qse_long_t rr;
|
||||
qse_awk_int_t rr;
|
||||
|
||||
rr = qse_awk_strxtolong (
|
||||
rr = qse_awk_strxtoint (
|
||||
rtx->awk, rs->val.ptr, rs->val.len, 0, QSE_NULL);
|
||||
|
||||
return (ll > rr)? 1:
|
||||
@ -4410,9 +4410,9 @@ static int __cmp_str_str (
|
||||
|
||||
if (rs->nstr == 1)
|
||||
{
|
||||
qse_long_t rr;
|
||||
qse_awk_int_t rr;
|
||||
|
||||
rr = qse_awk_strxtolong (
|
||||
rr = qse_awk_strxtoint (
|
||||
rtx->awk, rs->val.ptr, rs->val.len, 0, QSE_NULL);
|
||||
|
||||
return (ll > rr)? 1:
|
||||
@ -4573,10 +4573,10 @@ static qse_awk_val_t* eval_binop_le (
|
||||
static qse_awk_val_t* eval_binop_lshift (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
|
||||
if (qse_awk_rtx_valtolong (rtx, left, &l1) <= -1 ||
|
||||
qse_awk_rtx_valtolong (rtx, right, &l2) <= -1)
|
||||
if (qse_awk_rtx_valtoint (rtx, left, &l1) <= -1 ||
|
||||
qse_awk_rtx_valtoint (rtx, right, &l2) <= -1)
|
||||
{
|
||||
SETERR_COD (rtx, QSE_AWK_EOPERAND);
|
||||
return QSE_NULL;
|
||||
@ -4588,10 +4588,10 @@ static qse_awk_val_t* eval_binop_lshift (
|
||||
static qse_awk_val_t* eval_binop_rshift (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
|
||||
if (qse_awk_rtx_valtolong (rtx, left, &l1) <= -1 ||
|
||||
qse_awk_rtx_valtolong (rtx, right, &l2) <= -1)
|
||||
if (qse_awk_rtx_valtoint (rtx, left, &l1) <= -1 ||
|
||||
qse_awk_rtx_valtoint (rtx, right, &l2) <= -1)
|
||||
{
|
||||
SETERR_COD (rtx, QSE_AWK_EOPERAND);
|
||||
return QSE_NULL;
|
||||
@ -4604,7 +4604,7 @@ static qse_awk_val_t* eval_binop_plus (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
int n1, n2, n3;
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
qse_awk_flt_t r1, r2;
|
||||
|
||||
n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1);
|
||||
@ -4625,7 +4625,7 @@ static qse_awk_val_t* eval_binop_plus (
|
||||
n3 = n1 + (n2 << 1);
|
||||
QSE_ASSERT (n3 >= 0 && n3 <= 3);
|
||||
|
||||
return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_long_t)l1+(qse_long_t)l2):
|
||||
return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_awk_int_t)l1+(qse_awk_int_t)l2):
|
||||
(n3 == 1)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1+(qse_awk_flt_t)l2):
|
||||
(n3 == 2)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)l1+(qse_awk_flt_t)r2):
|
||||
qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1+(qse_awk_flt_t)r2);
|
||||
@ -4635,7 +4635,7 @@ static qse_awk_val_t* eval_binop_minus (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
int n1, n2, n3;
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
qse_awk_flt_t r1, r2;
|
||||
|
||||
n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1);
|
||||
@ -4649,7 +4649,7 @@ static qse_awk_val_t* eval_binop_minus (
|
||||
|
||||
n3 = n1 + (n2 << 1);
|
||||
QSE_ASSERT (n3 >= 0 && n3 <= 3);
|
||||
return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_long_t)l1-(qse_long_t)l2):
|
||||
return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_awk_int_t)l1-(qse_awk_int_t)l2):
|
||||
(n3 == 1)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1-(qse_awk_flt_t)l2):
|
||||
(n3 == 2)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)l1-(qse_awk_flt_t)r2):
|
||||
qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1-(qse_awk_flt_t)r2);
|
||||
@ -4659,7 +4659,7 @@ static qse_awk_val_t* eval_binop_mul (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
int n1, n2, n3;
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
qse_awk_flt_t r1, r2;
|
||||
|
||||
n1 = qse_awk_rtx_valtonum (rtx, left, &l1, &r1);
|
||||
@ -4673,7 +4673,7 @@ static qse_awk_val_t* eval_binop_mul (
|
||||
|
||||
n3 = n1 + (n2 << 1);
|
||||
QSE_ASSERT (n3 >= 0 && n3 <= 3);
|
||||
return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_long_t)l1*(qse_long_t)l2):
|
||||
return (n3 == 0)? qse_awk_rtx_makeintval(rtx,(qse_awk_int_t)l1*(qse_awk_int_t)l2):
|
||||
(n3 == 1)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1*(qse_awk_flt_t)l2):
|
||||
(n3 == 2)? qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)l1*(qse_awk_flt_t)r2):
|
||||
qse_awk_rtx_makefltval(rtx,(qse_awk_flt_t)r1*(qse_awk_flt_t)r2);
|
||||
@ -4683,7 +4683,7 @@ static qse_awk_val_t* eval_binop_div (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
int n1, n2, n3;
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
qse_awk_flt_t r1, r2;
|
||||
qse_awk_val_t* res;
|
||||
|
||||
@ -4706,10 +4706,10 @@ static qse_awk_val_t* eval_binop_div (
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
if (((qse_long_t)l1 % (qse_long_t)l2) == 0)
|
||||
if (((qse_awk_int_t)l1 % (qse_awk_int_t)l2) == 0)
|
||||
{
|
||||
res = qse_awk_rtx_makeintval (
|
||||
rtx, (qse_long_t)l1 / (qse_long_t)l2);
|
||||
rtx, (qse_awk_int_t)l1 / (qse_awk_int_t)l2);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -4741,7 +4741,7 @@ static qse_awk_val_t* eval_binop_idiv (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
int n1, n2, n3;
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
qse_awk_flt_t r1, r2, quo;
|
||||
qse_awk_val_t* res;
|
||||
|
||||
@ -4764,22 +4764,22 @@ static qse_awk_val_t* eval_binop_idiv (
|
||||
return QSE_NULL;
|
||||
}
|
||||
res = qse_awk_rtx_makeintval (
|
||||
rtx, (qse_long_t)l1 / (qse_long_t)l2);
|
||||
rtx, (qse_awk_int_t)l1 / (qse_awk_int_t)l2);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
quo = (qse_awk_flt_t)r1 / (qse_awk_flt_t)l2;
|
||||
res = qse_awk_rtx_makeintval (rtx, (qse_long_t)quo);
|
||||
res = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)quo);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
quo = (qse_awk_flt_t)l1 / (qse_awk_flt_t)r2;
|
||||
res = qse_awk_rtx_makeintval (rtx, (qse_long_t)quo);
|
||||
res = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)quo);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
quo = (qse_awk_flt_t)r1 / (qse_awk_flt_t)r2;
|
||||
res = qse_awk_rtx_makeintval (rtx, (qse_long_t)quo);
|
||||
res = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)quo);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -4790,7 +4790,7 @@ static qse_awk_val_t* eval_binop_mod (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
int n1, n2, n3;
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
qse_awk_flt_t r1, r2;
|
||||
qse_awk_val_t* res;
|
||||
|
||||
@ -4816,7 +4816,7 @@ static qse_awk_val_t* eval_binop_mod (
|
||||
return QSE_NULL;
|
||||
}
|
||||
res = qse_awk_rtx_makeintval (
|
||||
rtx, (qse_long_t)l1 % (qse_long_t)l2);
|
||||
rtx, (qse_awk_int_t)l1 % (qse_awk_int_t)l2);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@ -4848,7 +4848,7 @@ static qse_awk_val_t* eval_binop_exp (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
int n1, n2, n3;
|
||||
qse_long_t l1, l2;
|
||||
qse_awk_int_t l1, l2;
|
||||
qse_awk_flt_t r1, r2;
|
||||
qse_awk_val_t* res;
|
||||
|
||||
@ -4868,7 +4868,7 @@ static qse_awk_val_t* eval_binop_exp (
|
||||
/* left - int, right - int */
|
||||
if (l2 >= 0)
|
||||
{
|
||||
qse_long_t v = 1;
|
||||
qse_awk_int_t v = 1;
|
||||
while (l2-- > 0) v *= l1;
|
||||
res = qse_awk_rtx_makeintval (rtx, v);
|
||||
}
|
||||
@ -5078,7 +5078,7 @@ static qse_awk_val_t* eval_unary (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
qse_awk_val_t* left, * res = QSE_NULL;
|
||||
qse_awk_nde_exp_t* exp = (qse_awk_nde_exp_t*)nde;
|
||||
int n;
|
||||
qse_long_t l;
|
||||
qse_awk_int_t l;
|
||||
qse_awk_flt_t r;
|
||||
|
||||
QSE_ASSERT (
|
||||
@ -5125,7 +5125,7 @@ static qse_awk_val_t* eval_unary (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
break;
|
||||
|
||||
case QSE_AWK_UNROP_BNOT:
|
||||
n = qse_awk_rtx_valtolong (run, left, &l);
|
||||
n = qse_awk_rtx_valtoint (run, left, &l);
|
||||
if (n <= -1) goto exit_func;
|
||||
|
||||
res = qse_awk_rtx_makeintval (run, ~l);
|
||||
@ -5180,7 +5180,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
{
|
||||
if (left->type == QSE_AWK_VAL_INT)
|
||||
{
|
||||
qse_long_t r = ((qse_awk_val_int_t*)left)->val;
|
||||
qse_awk_int_t r = ((qse_awk_val_int_t*)left)->val;
|
||||
res = qse_awk_rtx_makeintval (run, r + 1);
|
||||
if (res == QSE_NULL)
|
||||
{
|
||||
@ -5202,7 +5202,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_long_t v1;
|
||||
qse_awk_int_t v1;
|
||||
qse_awk_flt_t v2;
|
||||
int n;
|
||||
|
||||
@ -5236,7 +5236,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
{
|
||||
if (left->type == QSE_AWK_VAL_INT)
|
||||
{
|
||||
qse_long_t r = ((qse_awk_val_int_t*)left)->val;
|
||||
qse_awk_int_t r = ((qse_awk_val_int_t*)left)->val;
|
||||
res = qse_awk_rtx_makeintval (run, r - 1);
|
||||
if (res == QSE_NULL)
|
||||
{
|
||||
@ -5258,7 +5258,7 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_long_t v1;
|
||||
qse_awk_int_t v1;
|
||||
qse_awk_flt_t v2;
|
||||
int n;
|
||||
|
||||
@ -5335,7 +5335,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
{
|
||||
if (left->type == QSE_AWK_VAL_INT)
|
||||
{
|
||||
qse_long_t r = ((qse_awk_val_int_t*)left)->val;
|
||||
qse_awk_int_t r = ((qse_awk_val_int_t*)left)->val;
|
||||
res = qse_awk_rtx_makeintval (run, r);
|
||||
if (res == QSE_NULL)
|
||||
{
|
||||
@ -5375,7 +5375,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_long_t v1;
|
||||
qse_awk_int_t v1;
|
||||
qse_awk_flt_t v2;
|
||||
int n;
|
||||
|
||||
@ -5432,7 +5432,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
{
|
||||
if (left->type == QSE_AWK_VAL_INT)
|
||||
{
|
||||
qse_long_t r = ((qse_awk_val_int_t*)left)->val;
|
||||
qse_awk_int_t r = ((qse_awk_val_int_t*)left)->val;
|
||||
res = qse_awk_rtx_makeintval (run, r);
|
||||
if (res == QSE_NULL)
|
||||
{
|
||||
@ -5472,7 +5472,7 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_long_t v1;
|
||||
qse_awk_int_t v1;
|
||||
qse_awk_flt_t v2;
|
||||
int n;
|
||||
|
||||
@ -5708,8 +5708,8 @@ static qse_awk_val_t* __eval_call (
|
||||
saved_stack_top = run->stack_top;
|
||||
|
||||
#ifdef DEBUG_RUN
|
||||
qse_errputstrf (QSE_T("setting up function stack frame top=%ld base=%ld\n"),
|
||||
(long)run->stack_top, (long)run->stack_base);
|
||||
qse_errputstrf (QSE_T("setting up function stack frame top=%zd base=%zd\n"),
|
||||
(qse_size_t)run->stack_top, (qse_size_t)run->stack_base);
|
||||
#endif
|
||||
if (__raw_push(run,(void*)run->stack_base) == -1)
|
||||
{
|
||||
@ -5889,8 +5889,8 @@ static qse_awk_val_t* __eval_call (
|
||||
if (run->exit_level == EXIT_FUNCTION) run->exit_level = EXIT_NONE;
|
||||
|
||||
#ifdef DEBUG_RUN
|
||||
qse_errputstrf (QSE_T("returning from function top=%ld, base=%ld\n"),
|
||||
(long)run->stack_top, (long)run->stack_base);
|
||||
qse_errputstrf (QSE_T("returning from function top=%zd, base=%zd\n"),
|
||||
(qse_size_t)run->stack_top, (qse_size_t)run->stack_base);
|
||||
#endif
|
||||
return (n == -1)? QSE_NULL: v;
|
||||
}
|
||||
@ -6103,7 +6103,7 @@ static int get_reference (
|
||||
case QSE_AWK_NDE_POS:
|
||||
{
|
||||
int n;
|
||||
qse_long_t lv;
|
||||
qse_awk_int_t lv;
|
||||
qse_awk_val_t* v;
|
||||
|
||||
/* the position number is returned for the positional
|
||||
@ -6112,7 +6112,7 @@ static int get_reference (
|
||||
if (v == QSE_NULL) return -1;
|
||||
|
||||
qse_awk_rtx_refupval (run, v);
|
||||
n = qse_awk_rtx_valtolong (run, v, &lv);
|
||||
n = qse_awk_rtx_valtoint (run, v, &lv);
|
||||
qse_awk_rtx_refdownval (run, v);
|
||||
|
||||
if (n <= -1)
|
||||
@ -6357,14 +6357,14 @@ static qse_awk_val_t* eval_pos (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
{
|
||||
qse_awk_nde_pos_t* pos = (qse_awk_nde_pos_t*)nde;
|
||||
qse_awk_val_t* v;
|
||||
qse_long_t lv;
|
||||
qse_awk_int_t lv;
|
||||
int n;
|
||||
|
||||
v = eval_expression (run, pos->val);
|
||||
if (v == QSE_NULL) return QSE_NULL;
|
||||
|
||||
qse_awk_rtx_refupval (run, v);
|
||||
n = qse_awk_rtx_valtolong (run, v, &lv);
|
||||
n = qse_awk_rtx_valtoint (run, v, &lv);
|
||||
qse_awk_rtx_refdownval (run, v);
|
||||
if (n <= -1)
|
||||
{
|
||||
@ -6378,7 +6378,7 @@ static qse_awk_val_t* eval_pos (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
return QSE_NULL;
|
||||
}
|
||||
if (lv == 0) v = run->inrec.d0;
|
||||
else if (lv > 0 && lv <= (qse_long_t)run->inrec.nflds)
|
||||
else if (lv > 0 && lv <= (qse_awk_int_t)run->inrec.nflds)
|
||||
v = run->inrec.flds[lv-1].val;
|
||||
else v = qse_awk_val_zls; /*qse_awk_val_nil;*/
|
||||
|
||||
@ -6914,7 +6914,7 @@ qse_char_t* qse_awk_rtx_format (
|
||||
|
||||
for (i = 0; i < fmt_len; i++)
|
||||
{
|
||||
qse_long_t wp[2];
|
||||
qse_awk_int_t wp[2];
|
||||
int wp_idx;
|
||||
#define WP_WIDTH 0
|
||||
#define WP_PRECISION 1
|
||||
@ -7012,7 +7012,7 @@ wp_mod_main:
|
||||
}
|
||||
|
||||
qse_awk_rtx_refupval (rtx, v);
|
||||
n = qse_awk_rtx_valtolong (rtx, v, &wp[wp_idx]);
|
||||
n = qse_awk_rtx_valtoint (rtx, v, &wp[wp_idx]);
|
||||
qse_awk_rtx_refdownval (rtx, v);
|
||||
if (n <= -1) return QSE_NULL;
|
||||
|
||||
@ -7077,7 +7077,7 @@ wp_mod_main:
|
||||
fmt[i] == QSE_T('o'))
|
||||
{
|
||||
qse_awk_val_t* v;
|
||||
qse_long_t l;
|
||||
qse_awk_int_t l;
|
||||
int n;
|
||||
|
||||
int fmt_flags;
|
||||
@ -7114,7 +7114,7 @@ wp_mod_main:
|
||||
}
|
||||
|
||||
qse_awk_rtx_refupval (rtx, v);
|
||||
n = qse_awk_rtx_valtolong (rtx, v, &l);
|
||||
n = qse_awk_rtx_valtoint (rtx, v, &l);
|
||||
qse_awk_rtx_refdownval (rtx, v);
|
||||
if (n <= -1) return QSE_NULL;
|
||||
|
||||
@ -7231,25 +7231,25 @@ wp_mod_main:
|
||||
{
|
||||
if (fmt_uint)
|
||||
{
|
||||
/* Explicit type-casting for 'l' from qse_long_t
|
||||
* to qse_ulong_t is needed before passing it to
|
||||
/* Explicit type-casting for 'l' from qse_awk_int_t
|
||||
* to qse_awk_uint_t is needed before passing it to
|
||||
* qse_fmtuintmax().
|
||||
*
|
||||
* Consider a value of -1 for example.
|
||||
* -1 is a value with all bits set.
|
||||
* If qse_long_t is 4 bytes and qse_uintmax_t
|
||||
* If qse_awk_int_t is 4 bytes and qse_uintmax_t
|
||||
* is 8 bytes, the value is shown below for
|
||||
* each type respectively .
|
||||
* -1 - 0xFFFFFFFF (qse_long_t)
|
||||
* -1 - 0xFFFFFFFF (qse_awk_int_t)
|
||||
* -1 - 0xFFFFFFFFFFFFFFFF (qse_uintmax_t)
|
||||
* Implicit typecasting of -1 from qse_long_t to
|
||||
* Implicit typecasting of -1 from qse_awk_int_t to
|
||||
* to qse_uintmax_t results in 0xFFFFFFFFFFFFFFFF,
|
||||
* though 0xFFFFFFF is expected in hexadecimal.
|
||||
*/
|
||||
n = qse_fmtuintmax (
|
||||
rtx->format.tmp.ptr,
|
||||
fmt_width,
|
||||
(qse_ulong_t)l,
|
||||
(qse_awk_uint_t)l,
|
||||
fmt_flags,
|
||||
wp[WP_PRECISION],
|
||||
fmt_fill,
|
||||
@ -7402,9 +7402,9 @@ wp_mod_main:
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
if (wp[WP_PRECISION] == -1 || wp[WP_PRECISION] == 0 || wp[WP_PRECISION] > (qse_long_t)ch_len)
|
||||
if (wp[WP_PRECISION] == -1 || wp[WP_PRECISION] == 0 || wp[WP_PRECISION] > (qse_awk_int_t)ch_len)
|
||||
{
|
||||
wp[WP_PRECISION] = (qse_long_t)ch_len;
|
||||
wp[WP_PRECISION] = (qse_awk_int_t)ch_len;
|
||||
}
|
||||
|
||||
if (wp[WP_PRECISION] > wp[WP_WIDTH]) wp[WP_WIDTH] = wp[WP_PRECISION];
|
||||
@ -7455,7 +7455,7 @@ wp_mod_main:
|
||||
{
|
||||
qse_char_t* str_ptr, * str_free = QSE_NULL;
|
||||
qse_size_t str_len;
|
||||
qse_long_t k;
|
||||
qse_awk_int_t k;
|
||||
qse_awk_val_t* v;
|
||||
|
||||
if (args == QSE_NULL)
|
||||
@ -7519,7 +7519,7 @@ wp_mod_main:
|
||||
str_free = str_ptr;
|
||||
}
|
||||
|
||||
if (wp[WP_PRECISION] == -1 || wp[WP_PRECISION] > (qse_long_t)str_len) wp[WP_PRECISION] = (qse_long_t)str_len;
|
||||
if (wp[WP_PRECISION] == -1 || wp[WP_PRECISION] > (qse_awk_int_t)str_len) wp[WP_PRECISION] = (qse_awk_int_t)str_len;
|
||||
if (wp[WP_PRECISION] > wp[WP_WIDTH]) wp[WP_WIDTH] = wp[WP_PRECISION];
|
||||
|
||||
if (!(flags & FLAG_MINUS))
|
||||
|
@ -122,8 +122,8 @@ typedef struct xtn_t
|
||||
|
||||
typedef struct rxtn_t
|
||||
{
|
||||
qse_long_t seed;
|
||||
qse_ulong_t prand; /* last random value returned */
|
||||
qse_awk_int_t seed;
|
||||
qse_awk_uint_t prand; /* last random value returned */
|
||||
|
||||
struct
|
||||
{
|
||||
@ -1551,7 +1551,7 @@ static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
|
||||
map = ((qse_awk_val_map_t*)argv)->map;
|
||||
QSE_ASSERT (map != QSE_NULL);
|
||||
|
||||
ibuflen = qse_awk_longtostr (
|
||||
ibuflen = qse_awk_inttostr (
|
||||
rtx->awk, rxtn->c.in.index + 1, 10, QSE_NULL,
|
||||
ibuf, QSE_COUNTOF(ibuf));
|
||||
|
||||
@ -1781,7 +1781,7 @@ static int build_argcv (
|
||||
qse_awk_val_t* v_argc;
|
||||
qse_awk_val_t* v_argv;
|
||||
qse_awk_val_t* v_tmp;
|
||||
qse_char_t key[QSE_SIZEOF(qse_long_t)*8+2];
|
||||
qse_char_t key[QSE_SIZEOF(qse_awk_int_t)*8+2];
|
||||
qse_size_t key_len;
|
||||
|
||||
v_argv = qse_awk_rtx_makemapval (rtx);
|
||||
@ -1832,7 +1832,7 @@ static int build_argcv (
|
||||
return -1;
|
||||
}
|
||||
|
||||
key_len = qse_awk_longtostr (
|
||||
key_len = qse_awk_inttostr (
|
||||
rtx->awk, argc, 10,
|
||||
QSE_NULL, key, QSE_COUNTOF(key));
|
||||
QSE_ASSERT (key_len != (qse_size_t)-1);
|
||||
@ -1852,7 +1852,7 @@ static int build_argcv (
|
||||
}
|
||||
else argc = 1;
|
||||
|
||||
v_argc = qse_awk_rtx_makeintval (rtx, (qse_long_t)argc);
|
||||
v_argc = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)argc);
|
||||
if (v_argc == QSE_NULL)
|
||||
{
|
||||
qse_awk_rtx_refdownval (rtx, v_argv);
|
||||
@ -2089,10 +2089,10 @@ qse_awk_rtx_t* qse_awk_rtx_openstd (
|
||||
rxtn->ecb.close = fini_rxtn;
|
||||
qse_awk_rtx_pushecb (rtx, &rxtn->ecb);
|
||||
|
||||
rxtn->seed = (qse_gettime (&now) <= -1)? 0u: ((qse_long_t)now.sec + (qse_long_t)now.nsec);
|
||||
rxtn->seed = (qse_gettime (&now) <= -1)? 0u: ((qse_awk_int_t)now.sec + (qse_awk_int_t)now.nsec);
|
||||
/* i don't care if the seed becomes negative or overflows.
|
||||
* i just convert the signed value to the unsigned one. */
|
||||
rxtn->prand = (qse_ulong_t)(rxtn->seed * rxtn->seed * rxtn->seed);
|
||||
rxtn->prand = (qse_awk_uint_t)(rxtn->seed * rxtn->seed * rxtn->seed);
|
||||
/* make sure that the actual seeding is not 0 */
|
||||
if (rxtn->prand == 0) rxtn->prand++;
|
||||
|
||||
@ -2143,14 +2143,18 @@ void* qse_awk_rtx_getxtnstd (qse_awk_rtx_t* rtx)
|
||||
|
||||
static int fnc_rand (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
#define RANDV_MAX QSE_TYPE_MAX(qse_long_t)
|
||||
#define RANDV_MAX QSE_TYPE_MAX(qse_awk_int_t)
|
||||
qse_awk_val_t* r;
|
||||
qse_long_t randv;
|
||||
qse_awk_int_t randv;
|
||||
rxtn_t* rxtn;
|
||||
|
||||
rxtn = (rxtn_t*) QSE_XTN (rtx);
|
||||
|
||||
#if defined(QSE_USE_AWK_INTMAX)
|
||||
rxtn->prand = qse_randxsuintmax (rxtn->prand);
|
||||
#else
|
||||
rxtn->prand = qse_randxsulong (rxtn->prand);
|
||||
#endif
|
||||
randv = rxtn->prand % RANDV_MAX;
|
||||
|
||||
r = qse_awk_rtx_makefltval (rtx, (qse_awk_flt_t)randv / RANDV_MAX);
|
||||
@ -2165,10 +2169,10 @@ static int fnc_srand (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
qse_size_t nargs;
|
||||
qse_awk_val_t* a0;
|
||||
qse_long_t lv;
|
||||
qse_awk_int_t lv;
|
||||
qse_awk_val_t* r;
|
||||
int n;
|
||||
qse_long_t prev;
|
||||
qse_awk_int_t prev;
|
||||
qse_ntime_t now;
|
||||
rxtn_t* rxtn;
|
||||
|
||||
@ -2181,18 +2185,18 @@ static int fnc_srand (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
if (nargs <= 0)
|
||||
{
|
||||
rxtn->seed = (qse_gettime (&now) <= -1)?
|
||||
(rxtn->seed * rxtn->seed): ((qse_long_t)now.sec + (qse_long_t)now.nsec);
|
||||
(rxtn->seed * rxtn->seed): ((qse_awk_int_t)now.sec + (qse_awk_int_t)now.nsec);
|
||||
}
|
||||
else
|
||||
{
|
||||
a0 = qse_awk_rtx_getarg (rtx, 0);
|
||||
n = qse_awk_rtx_valtolong (rtx, a0, &lv);
|
||||
n = qse_awk_rtx_valtoint (rtx, a0, &lv);
|
||||
if (n <= -1) return -1;
|
||||
rxtn->seed = lv;
|
||||
}
|
||||
/* i don't care if the seed becomes negative or overflows.
|
||||
* i just convert the signed value to the unsigned one. */
|
||||
rxtn->prand = (qse_ulong_t)(rxtn->seed * rxtn->seed * rxtn->seed);
|
||||
rxtn->prand = (qse_awk_uint_t)(rxtn->seed * rxtn->seed * rxtn->seed);
|
||||
/* make sure that the actual seeding is not 0 */
|
||||
if (rxtn->prand == 0) rxtn->prand++;
|
||||
|
||||
@ -2253,7 +2257,7 @@ static int fnc_system (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
skip_system:
|
||||
if (v->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (rtx->awk, str);
|
||||
|
||||
v = qse_awk_rtx_makeintval (rtx, (qse_long_t)n);
|
||||
v = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)n);
|
||||
if (v == QSE_NULL) return -1;
|
||||
|
||||
qse_awk_rtx_setretval (rtx, v);
|
||||
@ -2355,7 +2359,7 @@ static int fnc_setioattr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
ioattr_t* ioattr;
|
||||
|
||||
qse_long_t l;
|
||||
qse_awk_int_t l;
|
||||
qse_awk_flt_t r;
|
||||
int x;
|
||||
|
||||
@ -2379,7 +2383,7 @@ static int fnc_setioattr (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
else if (x >= 1)
|
||||
{
|
||||
qse_awk_flt_t nsec;
|
||||
ioattr->tmout[tmout].sec = (qse_long_t)r;
|
||||
ioattr->tmout[tmout].sec = (qse_awk_int_t)r;
|
||||
nsec = r - ioattr->tmout[tmout].sec;
|
||||
ioattr->tmout[tmout].nsec = QSE_SEC_TO_NSEC(nsec);
|
||||
}
|
||||
@ -2432,7 +2436,7 @@ done:
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
v[0] = qse_awk_rtx_makeintval (rtx, (qse_long_t)fret);
|
||||
v[0] = qse_awk_rtx_makeintval (rtx, (qse_awk_int_t)fret);
|
||||
if (v[0] == QSE_NULL) return -1;
|
||||
qse_awk_rtx_setretval (rtx, v[0]);
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde)
|
||||
* 8 -9223372036854775808 19 1
|
||||
* 16 -170141183460469231731687303715884105728 39 1
|
||||
*/
|
||||
qse_char_t buf[QSE_SIZEOF(qse_long_t) * 3 + 2];
|
||||
qse_char_t buf[QSE_SIZEOF(qse_awk_int_t) * 3 + 2];
|
||||
|
||||
qse_fmtintmax (
|
||||
buf, QSE_COUNTOF(buf),
|
||||
@ -423,12 +423,12 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde)
|
||||
|
||||
case QSE_AWK_NDE_ARG:
|
||||
{
|
||||
qse_char_t tmp[QSE_SIZEOF(qse_long_t)*8+2];
|
||||
qse_char_t tmp[QSE_SIZEOF(qse_awk_int_t)*8+2];
|
||||
qse_size_t n;
|
||||
qse_awk_nde_var_t* px = (qse_awk_nde_var_t*)nde;
|
||||
QSE_ASSERT (px->id.idxa != (qse_size_t)-1);
|
||||
|
||||
n = qse_awk_longtostr (
|
||||
n = qse_awk_inttostr (
|
||||
awk,
|
||||
px->id.idxa,
|
||||
10, QSE_NULL, tmp, QSE_COUNTOF(tmp)
|
||||
@ -449,7 +449,7 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde)
|
||||
QSE_ASSERT (px->idx != QSE_NULL);
|
||||
|
||||
PUT_SRCSTR (awk, QSE_T("__p"));
|
||||
n = qse_awk_longtostr (
|
||||
n = qse_awk_inttostr (
|
||||
awk,
|
||||
px->id.idxa, 10, QSE_NULL,
|
||||
awk->tmp.fmt, QSE_COUNTOF(awk->tmp.fmt)
|
||||
@ -504,11 +504,11 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde)
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_char_t tmp[QSE_SIZEOF(qse_long_t)*8+2];
|
||||
qse_char_t tmp[QSE_SIZEOF(qse_awk_int_t)*8+2];
|
||||
qse_size_t n;
|
||||
|
||||
PUT_SRCSTR (awk, QSE_T("__g"));
|
||||
n = qse_awk_longtostr (
|
||||
n = qse_awk_inttostr (
|
||||
awk,
|
||||
px->id.idxa,
|
||||
10,
|
||||
@ -545,11 +545,11 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde)
|
||||
}
|
||||
else
|
||||
{
|
||||
qse_char_t tmp[QSE_SIZEOF(qse_long_t)*8+2];
|
||||
qse_char_t tmp[QSE_SIZEOF(qse_awk_int_t)*8+2];
|
||||
qse_size_t n;
|
||||
|
||||
PUT_SRCSTR (awk, QSE_T("__g"));
|
||||
n = qse_awk_longtostr (
|
||||
n = qse_awk_inttostr (
|
||||
awk,
|
||||
px->id.idxa,
|
||||
10,
|
||||
@ -579,7 +579,7 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde)
|
||||
if (px->id.idxa != (qse_size_t)-1)
|
||||
{
|
||||
PUT_SRCSTR (awk, QSE_T("__l"));
|
||||
n = qse_awk_longtostr (
|
||||
n = qse_awk_inttostr (
|
||||
awk,
|
||||
px->id.idxa,
|
||||
10,
|
||||
@ -605,7 +605,7 @@ static int print_expr (qse_awk_t* awk, qse_awk_nde_t* nde)
|
||||
if (px->id.idxa != (qse_size_t)-1)
|
||||
{
|
||||
PUT_SRCSTR (awk, QSE_T("__l"));
|
||||
n = qse_awk_longtostr (
|
||||
n = qse_awk_inttostr (
|
||||
awk,
|
||||
px->id.idxa,
|
||||
10,
|
||||
@ -759,7 +759,7 @@ static int print_stmt (qse_awk_t* awk, qse_awk_nde_t* p, int depth)
|
||||
for (i = 0; i < px->nlcls - 1; i++)
|
||||
{
|
||||
PUT_SRCSTR (awk, QSE_T("__l"));
|
||||
n = qse_awk_longtostr (
|
||||
n = qse_awk_inttostr (
|
||||
awk,
|
||||
i,
|
||||
10,
|
||||
@ -772,7 +772,7 @@ static int print_stmt (qse_awk_t* awk, qse_awk_nde_t* p, int depth)
|
||||
}
|
||||
|
||||
PUT_SRCSTR (awk, QSE_T("__l"));
|
||||
n = qse_awk_longtostr (
|
||||
n = qse_awk_inttostr (
|
||||
awk,
|
||||
i,
|
||||
10,
|
||||
|
@ -128,18 +128,18 @@ struct qse_awk_nde_pos_t
|
||||
struct qse_awk_nde_int_t
|
||||
{
|
||||
QSE_AWK_NDE_HDR;
|
||||
qse_long_t val;
|
||||
qse_char_t* str;
|
||||
qse_size_t len;
|
||||
qse_awk_int_t val;
|
||||
qse_char_t* str;
|
||||
qse_size_t len;
|
||||
};
|
||||
|
||||
/* QSE_AWK_NDE_FLT */
|
||||
struct qse_awk_nde_flt_t
|
||||
{
|
||||
QSE_AWK_NDE_HDR;
|
||||
qse_awk_flt_t val;
|
||||
qse_char_t* str;
|
||||
qse_size_t len;
|
||||
qse_awk_flt_t val;
|
||||
qse_char_t* str;
|
||||
qse_size_t len;
|
||||
};
|
||||
|
||||
/* QSE_AWK_NDE_STR */
|
||||
|
@ -79,7 +79,7 @@ qse_awk_val_t* qse_awk_rtx_makenilval (qse_awk_rtx_t* rtx)
|
||||
return (qse_awk_val_t*)&awk_nil;
|
||||
}
|
||||
|
||||
qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* rtx, qse_long_t v)
|
||||
qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* rtx, qse_awk_int_t v)
|
||||
{
|
||||
qse_awk_val_int_t* val;
|
||||
|
||||
@ -140,7 +140,7 @@ qse_awk_val_t* qse_awk_rtx_makeintval (qse_awk_rtx_t* rtx, qse_long_t v)
|
||||
val->nde = QSE_NULL;
|
||||
|
||||
#ifdef DEBUG_VAL
|
||||
qse_errputstrf (QSE_T("makeintval => %ld [%p]\n"), (long)v, val);
|
||||
qse_errputstrf (QSE_T("makeintval => %jd [%p]\n"), (qse_intmax_t)v, val);
|
||||
#endif
|
||||
return (qse_awk_val_t*)val;
|
||||
}
|
||||
@ -419,7 +419,7 @@ qse_awk_val_t* qse_awk_rtx_makenstrvalwithcstr (qse_awk_rtx_t* rtx, const qse_cs
|
||||
{
|
||||
int x;
|
||||
qse_awk_val_t* v;
|
||||
qse_long_t l;
|
||||
qse_awk_int_t l;
|
||||
qse_awk_flt_t r;
|
||||
|
||||
x = qse_awk_rtx_strtonum (rtx, 1, str->ptr, str->len, &l, &r);
|
||||
@ -588,7 +588,7 @@ qse_awk_val_t* qse_awk_rtx_makemapvalwithdata (qse_awk_rtx_t* rtx, qse_awk_val_m
|
||||
switch (p->type)
|
||||
{
|
||||
case QSE_AWK_VAL_MAP_DATA_INT:
|
||||
tmp = qse_awk_rtx_makeintval (rtx, *(qse_long_t*)p->vptr);
|
||||
tmp = qse_awk_rtx_makeintval (rtx, *(qse_awk_int_t*)p->vptr);
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_MAP_DATA_FLT:
|
||||
@ -1063,7 +1063,7 @@ static int val_int_to_str (
|
||||
qse_awk_rtx_valtostr_out_t* out)
|
||||
{
|
||||
qse_char_t* tmp;
|
||||
qse_ulong_t t;
|
||||
qse_awk_uint_t t;
|
||||
qse_size_t rlen = 0;
|
||||
int type = out->type & ~QSE_AWK_RTX_VALTOSTR_PRINT;
|
||||
|
||||
@ -1472,7 +1472,7 @@ qse_wchar_t* qse_awk_rtx_valtowcsdup (
|
||||
}
|
||||
|
||||
static int val_ref_to_num (
|
||||
qse_awk_rtx_t* rtx, const qse_awk_val_ref_t* ref, qse_long_t* l, qse_awk_flt_t* r)
|
||||
qse_awk_rtx_t* rtx, const qse_awk_val_ref_t* ref, qse_awk_int_t* l, qse_awk_flt_t* r)
|
||||
{
|
||||
switch (ref->id)
|
||||
{
|
||||
@ -1530,7 +1530,7 @@ static int val_ref_to_num (
|
||||
|
||||
|
||||
int qse_awk_rtx_valtonum (
|
||||
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_long_t* l, qse_awk_flt_t* r)
|
||||
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_awk_int_t* l, qse_awk_flt_t* r)
|
||||
{
|
||||
switch (v->type)
|
||||
{
|
||||
@ -1579,8 +1579,8 @@ int qse_awk_rtx_valtonum (
|
||||
return -1; /* error */
|
||||
}
|
||||
|
||||
int qse_awk_rtx_valtolong (
|
||||
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_long_t* l)
|
||||
int qse_awk_rtx_valtoint (
|
||||
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_awk_int_t* l)
|
||||
{
|
||||
int n;
|
||||
qse_awk_flt_t r;
|
||||
@ -1588,7 +1588,7 @@ int qse_awk_rtx_valtolong (
|
||||
n = qse_awk_rtx_valtonum (rtx, v, l, &r);
|
||||
if (n == 1)
|
||||
{
|
||||
*l = (qse_long_t)r;
|
||||
*l = (qse_awk_int_t)r;
|
||||
n = 0;
|
||||
}
|
||||
|
||||
@ -1599,7 +1599,7 @@ int qse_awk_rtx_valtoflt (
|
||||
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_awk_flt_t* r)
|
||||
{
|
||||
int n;
|
||||
qse_long_t l;
|
||||
qse_awk_int_t l;
|
||||
|
||||
n = qse_awk_rtx_valtonum (rtx, v, &l, r);
|
||||
if (n == 0) *r = (qse_awk_flt_t)l;
|
||||
@ -1611,11 +1611,11 @@ int qse_awk_rtx_valtoflt (
|
||||
int qse_awk_rtx_strtonum (
|
||||
qse_awk_rtx_t* rtx, int strict,
|
||||
const qse_char_t* ptr, qse_size_t len,
|
||||
qse_long_t* l, qse_awk_flt_t* r)
|
||||
qse_awk_int_t* l, qse_awk_flt_t* r)
|
||||
{
|
||||
const qse_char_t* endptr;
|
||||
|
||||
*l = qse_awk_strxtolong (rtx->awk, ptr, len, 0, &endptr);
|
||||
*l = qse_awk_strxtoint (rtx->awk, ptr, len, 0, &endptr);
|
||||
if (endptr < ptr + len &&
|
||||
(*endptr == QSE_T('.') ||
|
||||
*endptr == QSE_T('E') ||
|
||||
@ -1623,23 +1623,23 @@ int qse_awk_rtx_strtonum (
|
||||
{
|
||||
*r = qse_awk_strxtoflt (rtx->awk, ptr, len, &endptr);
|
||||
if (strict && endptr < ptr + len) return -1;
|
||||
return 1; /* real */
|
||||
return 1; /* flt */
|
||||
}
|
||||
|
||||
if (strict && endptr < ptr + len) return -1;
|
||||
return 0; /* long */
|
||||
return 0; /* int */
|
||||
}
|
||||
|
||||
static qse_ulong_t hash (qse_uint8_t* ptr, qse_size_t len)
|
||||
static qse_awk_uint_t hash (qse_uint8_t* ptr, qse_size_t len)
|
||||
{
|
||||
qse_ulong_t h = 5381;
|
||||
qse_awk_uint_t h = 5381;
|
||||
while (len > 0) h = ((h << 5) + h) + ptr[--len];
|
||||
return h;
|
||||
}
|
||||
|
||||
qse_long_t qse_awk_rtx_hashval (qse_awk_rtx_t* rtx, qse_awk_val_t* v)
|
||||
qse_awk_int_t qse_awk_rtx_hashval (qse_awk_rtx_t* rtx, qse_awk_val_t* v)
|
||||
{
|
||||
qse_long_t hv;
|
||||
qse_awk_int_t hv;
|
||||
|
||||
switch (v->type)
|
||||
{
|
||||
@ -1649,19 +1649,19 @@ qse_long_t qse_awk_rtx_hashval (qse_awk_rtx_t* rtx, qse_awk_val_t* v)
|
||||
|
||||
case QSE_AWK_VAL_INT:
|
||||
/*hv = ((qse_awk_val_int_t*)v)->val;*/
|
||||
hv = (qse_long_t)hash (
|
||||
hv = (qse_awk_int_t)hash (
|
||||
(qse_uint8_t*)&((qse_awk_val_int_t*)v)->val,
|
||||
QSE_SIZEOF(((qse_awk_val_int_t*)v)->val));
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_FLT:
|
||||
hv = (qse_long_t)hash (
|
||||
hv = (qse_awk_int_t)hash (
|
||||
(qse_uint8_t*)&((qse_awk_val_flt_t*)v)->val,
|
||||
QSE_SIZEOF(((qse_awk_val_flt_t*)v)->val));
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_STR:
|
||||
hv = (qse_long_t)hash (
|
||||
hv = (qse_awk_int_t)hash (
|
||||
(qse_uint8_t*)((qse_awk_val_str_t*)v)->val.ptr,
|
||||
((qse_awk_val_str_t*)v)->val.len * QSE_SIZEOF(qse_char_t));
|
||||
break;
|
||||
@ -1679,7 +1679,7 @@ qse_long_t qse_awk_rtx_hashval (qse_awk_rtx_t* rtx, qse_awk_val_t* v)
|
||||
}
|
||||
|
||||
/* turn off the sign bit */
|
||||
return hv & ~(((qse_ulong_t)1) << ((QSE_SIZEOF(qse_ulong_t) * 8) - 1));
|
||||
return hv & ~(((qse_awk_uint_t)1) << ((QSE_SIZEOF(qse_awk_uint_t) * 8) - 1));
|
||||
}
|
||||
|
||||
int qse_awk_rtx_setrefval (qse_awk_rtx_t* rtx, qse_awk_val_ref_t* ref, qse_awk_val_t* val)
|
||||
@ -1802,8 +1802,7 @@ int qse_awk_rtx_setrefval (qse_awk_rtx_t* rtx, qse_awk_val_ref_t* ref, qse_awk_v
|
||||
|
||||
#if 0
|
||||
|
||||
#define DPRINTF run->awk->prmfns->dprintf
|
||||
#define DCUSTOM run->awk->prmfns->data
|
||||
#define qse_errputstrf qse_errputstrf
|
||||
|
||||
static qse_htb_walk_t print_pair (
|
||||
qse_htb_t* map, qse_htb_pair_t* pair, void* arg)
|
||||
@ -1812,10 +1811,10 @@ static qse_htb_walk_t print_pair (
|
||||
|
||||
QSE_ASSERT (run == *(qse_awk_rtx_t**)QSE_XTN(map));
|
||||
|
||||
DPRINTF (DCUSTOM, QSE_T(" %.*s=>"),
|
||||
qse_errputstrf (QSE_T(" %.*s=>"),
|
||||
(int)QSE_HTB_KLEN(pair), QSE_HTB_KPTR(pair));
|
||||
qse_awk_dprintval ((qse_awk_rtx_t*)arg, QSE_HTB_VPTR(pair));
|
||||
DPRINTF (DCUSTOM, QSE_T(" "));
|
||||
qse_errputstrf (QSE_T(" "));
|
||||
|
||||
return QSE_HTB_WALK_FORWARD;
|
||||
}
|
||||
@ -1827,59 +1826,41 @@ void qse_awk_dprintval (qse_awk_rtx_t* run, qse_awk_val_t* val)
|
||||
switch (val->type)
|
||||
{
|
||||
case QSE_AWK_VAL_NIL:
|
||||
DPRINTF (DCUSTOM, QSE_T("nil"));
|
||||
qse_errputstrf (QSE_T("nil"));
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_INT:
|
||||
#if QSE_SIZEOF_LONG_LONG > 0
|
||||
DPRINTF (DCUSTOM, QSE_T("%lld"),
|
||||
(long long)((qse_awk_val_int_t*)val)->val);
|
||||
#elif QSE_SIZEOF___INT64 > 0
|
||||
DPRINTF (DCUSTOM, QSE_T("%I64d"),
|
||||
(__int64)((qse_awk_val_int_t*)val)->val);
|
||||
#elif QSE_SIZEOF_LONG > 0
|
||||
DPRINTF (DCUSTOM, QSE_T("%ld"),
|
||||
(long)((qse_awk_val_int_t*)val)->val);
|
||||
#elif QSE_SIZEOF_INT > 0
|
||||
DPRINTF (DCUSTOM, QSE_T("%d"),
|
||||
(int)((qse_awk_val_int_t*)val)->val);
|
||||
#else
|
||||
#error unsupported size
|
||||
#endif
|
||||
qse_errputstrf (QSE_T("%jd"),
|
||||
(qse_intmax_t)((qse_awk_val_int_t*)val)->val);
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_FLT:
|
||||
#if defined(__MINGW32__)
|
||||
DPRINTF (DCUSTOM, QSE_T("%Lf"),
|
||||
(double)((qse_awk_val_flt_t*)val)->val);
|
||||
#else
|
||||
DPRINTF (DCUSTOM, QSE_T("%Lf"),
|
||||
(long double)((qse_awk_val_flt_t*)val)->val);
|
||||
#endif
|
||||
qse_errputstrf (QSE_T("%jf"),
|
||||
(qse_fltmax_t)((qse_awk_val_flt_t*)val)->val);
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_STR:
|
||||
DPRINTF (DCUSTOM, QSE_T("%s"), ((qse_awk_val_str_t*)val)->ptr);
|
||||
qse_errputstrf (QSE_T("%s"), ((qse_awk_val_str_t*)val)->ptr);
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_REX:
|
||||
DPRINTF (DCUSTOM, QSE_T("REX[%s]"), ((qse_awk_val_rex_t*)val)->ptr);
|
||||
qse_errputstrf (QSE_T("REX[%s]"), ((qse_awk_val_rex_t*)val)->ptr);
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_MAP:
|
||||
DPRINTF (DCUSTOM, QSE_T("MAP["));
|
||||
qse_errputstrf (QSE_T("MAP["));
|
||||
qse_htb_walk (((qse_awk_val_map_t*)val)->map, print_pair, run);
|
||||
DPRINTF (DCUSTOM, QSE_T("]"));
|
||||
qse_errputstrf (QSE_T("]"));
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_REF:
|
||||
DPRINTF (DCUSTOM, QSE_T("REF[id=%d,val="), ((qse_awk_val_ref_t*)val)->id);
|
||||
qse_errputstrf (QSE_T("REF[id=%d,val="), ((qse_awk_val_ref_t*)val)->id);
|
||||
qse_awk_dprintval (run, *((qse_awk_val_ref_t*)val)->adr);
|
||||
DPRINTF (DCUSTOM, QSE_T("]"));
|
||||
qse_errputstrf (QSE_T("]"));
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINTF (DCUSTOM, QSE_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n"));
|
||||
qse_errputstrf (QSE_T("**** INTERNAL ERROR - INVALID VALUE TYPE ****\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,3 +85,20 @@ qse_uint64_t qse_randxs64 (qse_uint64_t seed)
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (QSE_SIZEOF_UINT128_T > 0)
|
||||
qse_uint128_t qse_randxs128 (qse_uint128_t seed)
|
||||
{
|
||||
qse_uint128_t x;
|
||||
|
||||
QSE_ASSERT (seed != 0);
|
||||
|
||||
x = seed;
|
||||
|
||||
x ^= (x << 42);
|
||||
x ^= (x >> 71);
|
||||
x ^= (x << 3);
|
||||
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user