fixed the premature termination issue in logfmtv

This commit is contained in:
hyung-hwan 2018-02-21 08:48:47 +00:00
parent ed7f580e54
commit 14b3013c79
3 changed files with 15 additions and 11 deletions

View File

@ -73,16 +73,20 @@
#define PUT_OOCH(c,n) do { \
int xx; \
if ((xx = data->putch (hcl, data->mask, c, n)) <= -1) goto oops; \
if (xx == 0) goto done; \
data->count += n; \
if (n > 0) { \
if ((xx = data->putch (hcl, data->mask, c, n)) <= -1) goto oops; \
if (xx == 0) goto done; \
data->count += n; \
} \
} while (0)
#define PUT_OOCS(ptr,len) do { \
int xx; \
if ((xx = data->putcs (hcl, data->mask, ptr, len)) <= -1) goto oops; \
if (xx == 0) goto done; \
data->count += len; \
if (len > 0) { \
if ((xx = data->putcs (hcl, data->mask, ptr, len)) <= -1) goto oops; \
if (xx == 0) goto done; \
data->count += len; \
} \
} while (0)
static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_list ap, hcl_outbfmt_t outbfmt)
@ -119,7 +123,6 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis
fltout->capa = HCL_COUNTOF(fltout->buf) - 1;
#endif
while (1)
{
#if defined(FMTCHAR_IS_OOCH)
@ -134,6 +137,7 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis
}
PUT_OOCS (checkpoint, fmt - checkpoint - 1);
#else
while ((ch = *fmt++) != '%' || stop)
{
if (ch == '\0') goto done;
@ -142,6 +146,7 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis
#endif
percent = fmt - 1;
padc = ' ';
width = 0; precision = 0;
neg = 0; sign = 0;
@ -384,6 +389,7 @@ reswitch:
if (lm_flag & LF_J) goto uppercase_c;
#endif
lowercase_c:
bch = HCL_SIZEOF(hcl_bch_t) < HCL_SIZEOF(int)? va_arg(ap, int): va_arg(ap, hcl_bch_t);
print_lowercase_c:

View File

@ -405,7 +405,7 @@ static HCL_INLINE hcl_ooi_t write_output (hcl_t* hcl, hcl_iooutarg_t* arg)
ucslen = arg->len - donelen;
if (ucslen > bcslen) ucslen = bcslen;
else if (ucslen < bcslen) bcslen = ucslen;
hcl_copybchars (&arg->ptr[donelen], bcsbuf, bcslen);
hcl_copybchars (bcsbuf, &arg->ptr[donelen], bcslen);
#endif
if (fwrite (bcsbuf, HCL_SIZEOF(bcsbuf[0]), bcslen, (FILE*)arg->handle) < bcslen)

View File

@ -284,7 +284,6 @@ next:
if (outbfmt(hcl, mask, "\"") <= -1) return -1;
for (i = 0; i < HCL_OBJ_GET_SIZE(obj); i++)
{
ch = ((hcl_oop_char_t)obj)->slot[i];
if (print_single_char(hcl, mask, ch, outbfmt) <= -1) return -1;
}
@ -363,7 +362,7 @@ next:
* label. */
ps.type = PRINT_STACK_CONS;
ps.obj = hcl->_nil;
x = push (hcl, &ps);
x = push(hcl, &ps);
if (x <= -1) return -1;
/* Make a jump to 'next' to print the CDR part */
@ -570,7 +569,6 @@ next:
case HCL_BRAND_PRIM:
word_index = WORD_PRIM;
goto print_word;
case HCL_BRAND_CONTEXT:
word_index = WORD_CONTEXT;