fixed the premature termination issue in logfmtv
This commit is contained in:
parent
ed7f580e54
commit
14b3013c79
@ -73,16 +73,20 @@
|
|||||||
|
|
||||||
#define PUT_OOCH(c,n) do { \
|
#define PUT_OOCH(c,n) do { \
|
||||||
int xx; \
|
int xx; \
|
||||||
if ((xx = data->putch (hcl, data->mask, c, n)) <= -1) goto oops; \
|
if (n > 0) { \
|
||||||
if (xx == 0) goto done; \
|
if ((xx = data->putch (hcl, data->mask, c, n)) <= -1) goto oops; \
|
||||||
data->count += n; \
|
if (xx == 0) goto done; \
|
||||||
|
data->count += n; \
|
||||||
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define PUT_OOCS(ptr,len) do { \
|
#define PUT_OOCS(ptr,len) do { \
|
||||||
int xx; \
|
int xx; \
|
||||||
if ((xx = data->putcs (hcl, data->mask, ptr, len)) <= -1) goto oops; \
|
if (len > 0) { \
|
||||||
if (xx == 0) goto done; \
|
if ((xx = data->putcs (hcl, data->mask, ptr, len)) <= -1) goto oops; \
|
||||||
data->count += len; \
|
if (xx == 0) goto done; \
|
||||||
|
data->count += len; \
|
||||||
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_list ap, hcl_outbfmt_t outbfmt)
|
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;
|
fltout->capa = HCL_COUNTOF(fltout->buf) - 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
#if defined(FMTCHAR_IS_OOCH)
|
#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);
|
PUT_OOCS (checkpoint, fmt - checkpoint - 1);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
while ((ch = *fmt++) != '%' || stop)
|
while ((ch = *fmt++) != '%' || stop)
|
||||||
{
|
{
|
||||||
if (ch == '\0') goto done;
|
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
|
#endif
|
||||||
percent = fmt - 1;
|
percent = fmt - 1;
|
||||||
|
|
||||||
|
|
||||||
padc = ' ';
|
padc = ' ';
|
||||||
width = 0; precision = 0;
|
width = 0; precision = 0;
|
||||||
neg = 0; sign = 0;
|
neg = 0; sign = 0;
|
||||||
@ -384,6 +389,7 @@ reswitch:
|
|||||||
if (lm_flag & LF_J) goto uppercase_c;
|
if (lm_flag & LF_J) goto uppercase_c;
|
||||||
#endif
|
#endif
|
||||||
lowercase_c:
|
lowercase_c:
|
||||||
|
|
||||||
bch = HCL_SIZEOF(hcl_bch_t) < HCL_SIZEOF(int)? va_arg(ap, int): va_arg(ap, hcl_bch_t);
|
bch = HCL_SIZEOF(hcl_bch_t) < HCL_SIZEOF(int)? va_arg(ap, int): va_arg(ap, hcl_bch_t);
|
||||||
|
|
||||||
print_lowercase_c:
|
print_lowercase_c:
|
||||||
|
@ -405,7 +405,7 @@ static HCL_INLINE hcl_ooi_t write_output (hcl_t* hcl, hcl_iooutarg_t* arg)
|
|||||||
ucslen = arg->len - donelen;
|
ucslen = arg->len - donelen;
|
||||||
if (ucslen > bcslen) ucslen = bcslen;
|
if (ucslen > bcslen) ucslen = bcslen;
|
||||||
else if (ucslen < bcslen) bcslen = ucslen;
|
else if (ucslen < bcslen) bcslen = ucslen;
|
||||||
hcl_copybchars (&arg->ptr[donelen], bcsbuf, bcslen);
|
hcl_copybchars (bcsbuf, &arg->ptr[donelen], bcslen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fwrite (bcsbuf, HCL_SIZEOF(bcsbuf[0]), bcslen, (FILE*)arg->handle) < bcslen)
|
if (fwrite (bcsbuf, HCL_SIZEOF(bcsbuf[0]), bcslen, (FILE*)arg->handle) < bcslen)
|
||||||
|
@ -284,7 +284,6 @@ next:
|
|||||||
if (outbfmt(hcl, mask, "\"") <= -1) return -1;
|
if (outbfmt(hcl, mask, "\"") <= -1) return -1;
|
||||||
for (i = 0; i < HCL_OBJ_GET_SIZE(obj); i++)
|
for (i = 0; i < HCL_OBJ_GET_SIZE(obj); i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
ch = ((hcl_oop_char_t)obj)->slot[i];
|
ch = ((hcl_oop_char_t)obj)->slot[i];
|
||||||
if (print_single_char(hcl, mask, ch, outbfmt) <= -1) return -1;
|
if (print_single_char(hcl, mask, ch, outbfmt) <= -1) return -1;
|
||||||
}
|
}
|
||||||
@ -363,7 +362,7 @@ next:
|
|||||||
* label. */
|
* label. */
|
||||||
ps.type = PRINT_STACK_CONS;
|
ps.type = PRINT_STACK_CONS;
|
||||||
ps.obj = hcl->_nil;
|
ps.obj = hcl->_nil;
|
||||||
x = push (hcl, &ps);
|
x = push(hcl, &ps);
|
||||||
if (x <= -1) return -1;
|
if (x <= -1) return -1;
|
||||||
|
|
||||||
/* Make a jump to 'next' to print the CDR part */
|
/* Make a jump to 'next' to print the CDR part */
|
||||||
@ -570,7 +569,6 @@ next:
|
|||||||
case HCL_BRAND_PRIM:
|
case HCL_BRAND_PRIM:
|
||||||
word_index = WORD_PRIM;
|
word_index = WORD_PRIM;
|
||||||
goto print_word;
|
goto print_word;
|
||||||
|
|
||||||
|
|
||||||
case HCL_BRAND_CONTEXT:
|
case HCL_BRAND_CONTEXT:
|
||||||
word_index = WORD_CONTEXT;
|
word_index = WORD_CONTEXT;
|
||||||
|
Loading…
Reference in New Issue
Block a user