fixed the processed length calculation bug in feed_json_data() in xli/json.c

This commit is contained in:
hyung-hwan 2019-06-13 05:45:47 +00:00
parent df7a5eda5f
commit 4d556c475a
3 changed files with 12 additions and 12 deletions

View File

@ -529,9 +529,9 @@ static int fnc_sleep (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
struct timespec req;
req.tv_sec = lv;
req.tv_nsec = 0;
rx = nanosleep (&req, QSE_NULL);
rx = nanosleep(&req, QSE_NULL);
#else
rx = sleep (lv);
rx = sleep(lv);
#endif
}
else if (rx >= 1)
@ -548,25 +548,25 @@ static int fnc_sleep (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
sleep ((qse_awk_int_t)fv);
rx = 0;
#else
rx = sleep ((qse_awk_int_t)fv);
rx = sleep((qse_awk_int_t)fv);
#endif;
#elif defined(HAVE_NANOSLEEP)
struct timespec req;
req.tv_sec = (qse_awk_int_t)fv;
req.tv_nsec = QSE_SEC_TO_NSEC(fv - req.tv_sec);
rx = nanosleep (&req, QSE_NULL);
rx = nanosleep(&req, QSE_NULL);
#elif defined(HAVE_SELECT)
struct timeval req;
req.tv_sec = (qse_awk_int_t)fv;
req.tv_usec = QSE_SEC_TO_USEC(fv - req.tv_sec);
rx = select (0, QSE_NULL, QSE_NULL, QSE_NULL, &req);
rx = select(0, QSE_NULL, QSE_NULL, QSE_NULL, &req);
#else
/* no high-resolution sleep() is available */
rx = sleep ((qse_awk_int_t)fv);
rx = sleep((qse_awk_int_t)fv);
#endif
}
retv = qse_awk_rtx_makeintval (rtx, rx);
retv = qse_awk_rtx_makeintval(rtx, rx);
if (retv == QSE_NULL) return -1;
qse_awk_rtx_setretval (rtx, retv);

View File

@ -3071,7 +3071,7 @@ static int run_printf (qse_awk_rtx_t* rtx, qse_awk_nde_print_t* nde)
case QSE_AWK_VAL_MBS:
/* perform the formatted output */
n = output_formatted_bytes (rtx, nde->out_type, dst, ((qse_awk_val_mbs_t*)v)->val.ptr, ((qse_awk_val_mbs_t*)v)->val.len, head->next);
n = output_formatted_bytes(rtx, nde->out_type, dst, ((qse_awk_val_mbs_t*)v)->val.ptr, ((qse_awk_val_mbs_t*)v)->val.len, head->next);
qse_awk_rtx_refdownval (rtx, v);
if (n <= -1)
{

View File

@ -796,7 +796,7 @@ static int feed_json_data (qse_json_t* json, const qse_mchar_t* data, qse_size_t
else if (n > bcslen)
{
/* incomplete sequence */
*xlen = bcslen; /* need at lease this much */
*xlen = ptr - data; /* didn't manage to process in full */
return 0; /* feed more for incomplete sequence */
}