From a30c831081e5c7c541b5687ef3b19447211a9786 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Thu, 6 Nov 2014 17:41:20 +0000 Subject: [PATCH] redefined IDXBUFSIZE --- qse/include/qse/awk/awk.h | 4 ++++ qse/lib/awk/run.c | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/qse/include/qse/awk/awk.h b/qse/include/qse/awk/awk.h index 705b6716..ddcc2254 100644 --- a/qse/include/qse/awk/awk.h +++ b/qse/include/qse/awk/awk.h @@ -38,15 +38,19 @@ #if defined(QSE_USE_AWK_INTMAX) typedef qse_intmax_t qse_awk_int_t; typedef qse_uintmax_t qse_awk_uint_t; +#define QSE_AWK_SIZEOF_INT_T QSE_SIZEZOF_INTMAX_T #else typedef qse_long_t qse_awk_int_t; typedef qse_ulong_t qse_awk_uint_t; +#define QSE_AWK_SIZEOF_INT_T QSE_SIZEZOF_LONG_T #endif #if defined(QSE_USE_AWK_FLTMAX) typedef qse_fltmax_t qse_awk_flt_t; +#define QSE_AWK_SIZEOF_FLT_T QSE_SIZEOF_FLTMAX_T #else typedef qse_flt_t qse_awk_flt_t; +#define QSE_AWK_SIZEOF_FLT_T QSE_SIZEOF_FLT_T #endif /** \struct qse_awk_t diff --git a/qse/lib/awk/run.c b/qse/lib/awk/run.c index 4212db49..472f4e1f 100644 --- a/qse/lib/awk/run.c +++ b/qse/lib/awk/run.c @@ -31,7 +31,20 @@ #define DEF_BUF_CAPA 256 #define RTX_STACK_INCREMENT 512 -#define IDXBUFSIZE 64 +/* Don't forget to grow IDXBUFSIZE if qse_awk_int_t is very large */ +#if (QSE_AWK_SIZEOF_INT_T <= 16) /* 128 bits */ +# define IDXBUFSIZE 64 +#elif (QSE_AWK_SIZEOF_INT_T <= 32) /* 256 bits */ +# define IDXBUFSIZE 128 +#elif (QSE_AWK_SIZEOF_INT_T <= 64) /* 512 bits */ +# define IDXBUFSIZE 192 +#elif (QSE_AWK_SIZEOF_INT_T <= 128) /* 1024 bits */ +# define IDXBUFSIZE 384 +#elif (QSE_AWK_SIZEOF_INT_T <= 256) /* 2048 bits */ +# define IDXBUFSIZE 640 +#else +# error unsupported. qse_awk_int_t too big +#endif #define MMGR(rtx) ((rtx)->awk->mmgr) @@ -549,7 +562,7 @@ static int set_global ( } case QSE_AWK_GBL_OFS: - { + { qse_awk_rtx_valtostr_out_t out; out.type = QSE_AWK_RTX_VALTOSTR_CPLDUP; @@ -6454,7 +6467,7 @@ read_console_again: skip_read: tmp = qse_awk_rtx_makeintval (rtx, n); - if (tmp == QSE_NULL) ADJERR_LOC (rtx, &nde->loc); + if (!tmp) ADJERR_LOC (rtx, &nde->loc); return tmp; }