This commit is contained in:
150
lib/fmt.c
150
lib/fmt.c
@ -23,7 +23,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains a formatted output routine derived from kvprintf()
|
||||
* This file contains a formatted output routine derived from kvprintf()
|
||||
* of FreeBSD. It has been heavily modified and bug-fixed.
|
||||
*/
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
|
||||
#include <stdio.h> /* for snrintf(). used for floating-point number formatting */
|
||||
#if defined(_MSC_VER) || defined(__BORLANDC__) || (defined(__WATCOMC__) && (__WATCOMC__ < 1200))
|
||||
# define snprintf _snprintf
|
||||
# define snprintf _snprintf
|
||||
# if !defined(HAVE_SNPRINTF)
|
||||
# define HAVE_SNPRINTF
|
||||
# endif
|
||||
@ -99,7 +99,7 @@ enum
|
||||
/* __float128 */
|
||||
LF_QD = (1 << 8),
|
||||
|
||||
/* intmax or fltmax passed as a pointer - introduced to work around the issue where
|
||||
/* intmax or fltmax passed as a pointer - introduced to work around the issue where
|
||||
* __float128 value is not passed properly via va_list. for example, the following clode
|
||||
* compiled with clang -O1, -O2, -O3, etc produced a wrong value instead of 9.200000
|
||||
|
||||
@ -138,7 +138,7 @@ $ clang -O0 -o a a.c
|
||||
$ ./a
|
||||
9.200000
|
||||
|
||||
* the same code printed a correct value without compiler optimization.
|
||||
* the same code printed a correct value without compiler optimization.
|
||||
*
|
||||
* passing a large value via a pointer is a safe way to work around this problem.
|
||||
* hawk_rtx_format() and hawk_rtx_formatmbs() pass 'jj' for a floating-pointer number
|
||||
@ -153,7 +153,7 @@ static struct
|
||||
{
|
||||
hawk_uint16_t flag; /* for single occurrence */
|
||||
hawk_uint16_t dflag; /* for double occurrence */
|
||||
} lm_tab[26] =
|
||||
} lm_tab[26] =
|
||||
{
|
||||
{ 0, 0 }, /* a */
|
||||
{ 0, 0 }, /* b */
|
||||
@ -184,7 +184,7 @@ static struct
|
||||
};
|
||||
|
||||
|
||||
enum
|
||||
enum
|
||||
{
|
||||
FLAGC_DOT = (1 << 0),
|
||||
FLAGC_SPACE = (1 << 1),
|
||||
@ -199,14 +199,14 @@ enum
|
||||
FLAGC_LENMOD = (1 << 10) /* length modifier */
|
||||
};
|
||||
|
||||
static const hawk_bch_t hex2ascii_lower[] =
|
||||
static const hawk_bch_t hex2ascii_lower[] =
|
||||
{
|
||||
'0','1','2','3','4','5','6','7','8','9',
|
||||
'a','b','c','d','e','f','g','h','i','j','k','l','m',
|
||||
'n','o','p','q','r','s','t','u','v','w','x','y','z'
|
||||
};
|
||||
|
||||
static const hawk_bch_t hex2ascii_upper[] =
|
||||
static const hawk_bch_t hex2ascii_upper[] =
|
||||
{
|
||||
'0','1','2','3','4','5','6','7','8','9',
|
||||
'A','B','C','D','E','F','G','H','I','J','K','L','M',
|
||||
@ -233,7 +233,7 @@ static hawk_bch_t bch_nullstr[] = { '(','n','u','l','l', ')','\0' };
|
||||
#include "fmt-imp.h"
|
||||
|
||||
int hawk_fmt_intmax_to_bcstr (
|
||||
hawk_bch_t* buf, int size,
|
||||
hawk_bch_t* buf, int size,
|
||||
hawk_intmax_t value, int base_and_flags, int prec,
|
||||
hawk_bch_t fillchar, const hawk_bch_t* prefix)
|
||||
{
|
||||
@ -265,7 +265,7 @@ int hawk_fmt_intmax_to_bcstr (
|
||||
}
|
||||
|
||||
int hawk_fmt_uintmax_to_bcstr (
|
||||
hawk_bch_t* buf, int size,
|
||||
hawk_bch_t* buf, int size,
|
||||
hawk_uintmax_t value, int base_and_flags, int prec,
|
||||
hawk_bch_t fillchar, const hawk_bch_t* prefix)
|
||||
{
|
||||
@ -291,7 +291,7 @@ int hawk_fmt_uintmax_to_bcstr (
|
||||
/* ==================== wide-char ===================================== */
|
||||
|
||||
int hawk_fmt_intmax_to_ucstr (
|
||||
hawk_uch_t* buf, int size,
|
||||
hawk_uch_t* buf, int size,
|
||||
hawk_intmax_t value, int base_and_flags, int prec,
|
||||
hawk_uch_t fillchar, const hawk_uch_t* prefix)
|
||||
{
|
||||
@ -323,7 +323,7 @@ int hawk_fmt_intmax_to_ucstr (
|
||||
}
|
||||
|
||||
int hawk_fmt_uintmax_to_ucstr (
|
||||
hawk_uch_t* buf, int size,
|
||||
hawk_uch_t* buf, int size,
|
||||
hawk_uintmax_t value, int base_and_flags, int prec,
|
||||
hawk_uch_t fillchar, const hawk_uch_t* prefix)
|
||||
{
|
||||
@ -485,10 +485,10 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
fmtptr = (const hawk_uint8_t*)fmtout->fmt_str;
|
||||
switch (fmtout->fmt_type)
|
||||
{
|
||||
case HAWK_FMTOUT_FMT_TYPE_BCH:
|
||||
case HAWK_FMTOUT_FMT_TYPE_BCH:
|
||||
fmtchsz = HAWK_SIZEOF_BCH_T;
|
||||
break;
|
||||
case HAWK_FMTOUT_FMT_TYPE_UCH:
|
||||
case HAWK_FMTOUT_FMT_TYPE_UCH:
|
||||
fmtchsz = HAWK_SIZEOF_UCH_T;
|
||||
break;
|
||||
}
|
||||
@ -520,9 +520,9 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
{
|
||||
const hawk_bch_t* start, * end;
|
||||
start = end = (const hawk_bch_t*)fmtptr;
|
||||
while ((bch = *end++) != '%' || stop)
|
||||
while ((bch = *end++) != '%' || stop)
|
||||
{
|
||||
if (bch == '\0')
|
||||
if (bch == '\0')
|
||||
{
|
||||
PUT_BCS (fmtout, start, end - start - 1);
|
||||
goto done;
|
||||
@ -538,9 +538,9 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
{
|
||||
const hawk_uch_t* start, * end;
|
||||
start = end = (const hawk_uch_t*)fmtptr;
|
||||
while ((uch = *end++) != '%' || stop)
|
||||
while ((uch = *end++) != '%' || stop)
|
||||
{
|
||||
if (uch == '\0')
|
||||
if (uch == '\0')
|
||||
{
|
||||
PUT_UCS (fmtout, start, end - start - 1);
|
||||
goto done;
|
||||
@ -553,9 +553,9 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
goto handle_percent;
|
||||
|
||||
handle_percent:
|
||||
padc = ' ';
|
||||
padc = ' ';
|
||||
width = 0; precision = 0; neg = 0; sign = 0;
|
||||
lm_flag = 0; lm_dflag = 0; flagc = 0;
|
||||
lm_flag = 0; lm_dflag = 0; flagc = 0;
|
||||
sprintn = sprintn_lower;
|
||||
|
||||
reswitch:
|
||||
@ -563,7 +563,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
* requested character type. */
|
||||
switch (fmtout->fmt_type)
|
||||
{
|
||||
case HAWK_FMTOUT_FMT_TYPE_BCH:
|
||||
case HAWK_FMTOUT_FMT_TYPE_BCH:
|
||||
uch = *(const hawk_bch_t*)fmtptr;
|
||||
break;
|
||||
case HAWK_FMTOUT_FMT_TYPE_UCH:
|
||||
@ -572,7 +572,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
}
|
||||
fmtptr += fmtchsz;
|
||||
|
||||
switch (uch)
|
||||
switch (uch)
|
||||
{
|
||||
case '%': /* %% */
|
||||
bch = uch;
|
||||
@ -584,7 +584,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
flagc |= FLAGC_DOT;
|
||||
goto reswitch;
|
||||
|
||||
case '#':
|
||||
case '#':
|
||||
if (flagc & (FLAGC_WIDTH | FLAGC_DOT | FLAGC_LENMOD)) goto invalid_format;
|
||||
flagc |= FLAGC_SHARP;
|
||||
goto reswitch;
|
||||
@ -614,34 +614,34 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
flagc &= ~FLAGC_ZEROPAD;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
goto reswitch;
|
||||
|
||||
case '*': /* take the length from the parameter */
|
||||
if (flagc & FLAGC_DOT)
|
||||
if (flagc & FLAGC_DOT)
|
||||
{
|
||||
if (flagc & (FLAGC_STAR2 | FLAGC_PRECISION)) goto invalid_format;
|
||||
flagc |= FLAGC_STAR2;
|
||||
|
||||
precision = va_arg(ap, hawk_ooi_t); /* this deviates from the standard printf that accepts 'int' */
|
||||
if (precision < 0)
|
||||
if (precision < 0)
|
||||
{
|
||||
/* if precision is less than 0,
|
||||
/* if precision is less than 0,
|
||||
* treat it as if no .precision is specified */
|
||||
flagc &= ~FLAGC_DOT;
|
||||
precision = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flagc & (FLAGC_STAR1 | FLAGC_WIDTH)) goto invalid_format;
|
||||
flagc |= FLAGC_STAR1;
|
||||
|
||||
width = va_arg(ap, hawk_ooi_t); /* it deviates from the standard printf that accepts 'int' */
|
||||
if (width < 0)
|
||||
if (width < 0)
|
||||
{
|
||||
/*
|
||||
if (flagc & FLAGC_LEFTADJ)
|
||||
if (flagc & FLAGC_LEFTADJ)
|
||||
flagc &= ~FLAGC_LEFTADJ;
|
||||
else
|
||||
*/
|
||||
@ -665,12 +665,12 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
{
|
||||
if (flagc & FLAGC_LENMOD) goto invalid_format;
|
||||
for (n = 0;; fmtptr += fmtchsz)
|
||||
for (n = 0;; fmtptr += fmtchsz)
|
||||
{
|
||||
n = n * 10 + uch - '0';
|
||||
switch (fmtout->fmt_type)
|
||||
{
|
||||
case HAWK_FMTOUT_FMT_TYPE_BCH:
|
||||
case HAWK_FMTOUT_FMT_TYPE_BCH:
|
||||
uch = *(const hawk_bch_t*)fmtptr;
|
||||
break;
|
||||
case HAWK_FMTOUT_FMT_TYPE_UCH:
|
||||
@ -679,13 +679,13 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
}
|
||||
if (uch < '0' || uch > '9') break;
|
||||
}
|
||||
if (flagc & FLAGC_DOT)
|
||||
if (flagc & FLAGC_DOT)
|
||||
{
|
||||
if (flagc & FLAGC_STAR2) goto invalid_format;
|
||||
precision = n;
|
||||
flagc |= FLAGC_PRECISION;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if (flagc & FLAGC_STAR1) goto invalid_format;
|
||||
width = n;
|
||||
@ -724,7 +724,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
goto invalid_format;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
lm_flag |= lm_tab[uch - 'a'].flag;
|
||||
goto reswitch;
|
||||
@ -732,10 +732,10 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
break;
|
||||
|
||||
case 'L': /* long double */
|
||||
if (flagc & FLAGC_LENMOD)
|
||||
if (flagc & FLAGC_LENMOD)
|
||||
{
|
||||
/* conflict with other length modifier */
|
||||
goto invalid_format;
|
||||
goto invalid_format;
|
||||
}
|
||||
flagc |= FLAGC_LENMOD;
|
||||
lm_flag |= LF_LD;
|
||||
@ -745,7 +745,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
if (flagc & FLAGC_LENMOD)
|
||||
{
|
||||
/* conflict with other length modifier */
|
||||
goto invalid_format;
|
||||
goto invalid_format;
|
||||
}
|
||||
flagc |= FLAGC_LENMOD;
|
||||
lm_flag |= LF_QD;
|
||||
@ -767,12 +767,12 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
*(va_arg(ap, short int*)) = fmtout->count;
|
||||
else if (lm_flag & LF_C) /* hh */
|
||||
*(va_arg(ap, char*)) = fmtout->count;
|
||||
else if (flagc & FLAGC_LENMOD)
|
||||
else if (flagc & FLAGC_LENMOD)
|
||||
goto invalid_format;
|
||||
else
|
||||
*(va_arg(ap, int*)) = fmtout->count;
|
||||
break;
|
||||
|
||||
|
||||
/* signed integer conversions */
|
||||
case 'd':
|
||||
case 'i': /* signed conversion */
|
||||
@ -782,7 +782,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
/* end of signed integer conversions */
|
||||
|
||||
/* unsigned integer conversions */
|
||||
case 'o':
|
||||
case 'o':
|
||||
base = 8;
|
||||
goto handle_nosign;
|
||||
case 'u':
|
||||
@ -810,7 +810,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
case 'c':
|
||||
{
|
||||
/* zeropad must not take effect for 'c' */
|
||||
if (flagc & FLAGC_ZEROPAD) padc = ' ';
|
||||
if (flagc & FLAGC_ZEROPAD) padc = ' ';
|
||||
if (lm_flag & LF_L) goto uppercase_c;
|
||||
#if defined(HAWK_OOCH_IS_UCH)
|
||||
if (lm_flag & (LF_J | LF_JJ)) goto uppercase_c;
|
||||
@ -918,12 +918,12 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
const hawk_uint8_t* bsp;
|
||||
hawk_oow_t k_hex_width;
|
||||
|
||||
/* zeropad must not take effect for 'k' and 'K'
|
||||
*
|
||||
/* zeropad must not take effect for 'k' and 'K'
|
||||
*
|
||||
* 'h' & 'l' is not used to differentiate hawk_bch_t and hawk_uch_t
|
||||
* because 'k' means hawk_byte_t.
|
||||
* 'l', results in uppercase hexadecimal letters.
|
||||
* 'h' drops the leading \x in the output
|
||||
* because 'k' means hawk_byte_t.
|
||||
* 'l', results in uppercase hexadecimal letters.
|
||||
* 'h' drops the leading \x in the output
|
||||
* --------------------------------------------------------
|
||||
* hk -> \x + non-printable in lowercase hex
|
||||
* k -> all in lowercase hex
|
||||
@ -968,9 +968,9 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
|
||||
if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (fmtout, padc, width);
|
||||
|
||||
while (n--)
|
||||
while (n--)
|
||||
{
|
||||
if ((lm_flag & LF_H) && BYTE_PRINTABLE(*bsp))
|
||||
if ((lm_flag & LF_H) && BYTE_PRINTABLE(*bsp))
|
||||
{
|
||||
PUT_BCH (fmtout, *bsp, 1);
|
||||
}
|
||||
@ -992,7 +992,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
case 'W':
|
||||
{
|
||||
/* unicode string in unicode escape sequence.
|
||||
*
|
||||
*
|
||||
* hw -> \uXXXX, \UXXXXXXXX, printable-byte(only in ascii range)
|
||||
* w -> \uXXXX, \UXXXXXXXX
|
||||
* lw -> all in \UXXXXXXXX
|
||||
@ -1006,7 +1006,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
if (flagc & FLAGC_DOT)
|
||||
{
|
||||
/* if precision is specifed, it doesn't stop at the value of zero unlike 's' or 'S' */
|
||||
for (n = 0; n < precision; n++)
|
||||
for (n = 0; n < precision; n++)
|
||||
{
|
||||
if ((lm_flag & LF_H) && BYTE_PRINTABLE(usp[n])) uwid = 1;
|
||||
else if (!(lm_flag & LF_L) && usp[n] <= 0xFFFF) uwid = 6;
|
||||
@ -1027,13 +1027,13 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
|
||||
if (!(flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (fmtout, padc, width);
|
||||
|
||||
while (n--)
|
||||
while (n--)
|
||||
{
|
||||
if ((lm_flag & LF_H) && BYTE_PRINTABLE(*usp))
|
||||
if ((lm_flag & LF_H) && BYTE_PRINTABLE(*usp))
|
||||
{
|
||||
PUT_OOCH(fmtout, *usp, 1);
|
||||
}
|
||||
else if (!(lm_flag & LF_L) && *usp <= 0xFFFF)
|
||||
else if (!(lm_flag & LF_L) && *usp <= 0xFFFF)
|
||||
{
|
||||
hawk_uint16_t u16 = *usp;
|
||||
int extra_flags = ((uch) == 'w'? HAWK_BYTE_TO_BCSTR_LOWERCASE: 0);
|
||||
@ -1121,7 +1121,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
{
|
||||
/* limited to double or long double. use hawk_fltbas_t */
|
||||
|
||||
/* precedence goes to double if sizeof(double) == sizeof(long double)
|
||||
/* precedence goes to double if sizeof(double) == sizeof(long double)
|
||||
* for example, %Lf didn't work on some old platforms.
|
||||
* so i prefer the format specifier with no modifier.
|
||||
*/
|
||||
@ -1185,18 +1185,18 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
if (flagc & FLAGC_ZEROPAD) fb.fmt.ptr[fmtlen++] = '0';
|
||||
|
||||
if (flagc & FLAGC_STAR1) fb.fmt.ptr[fmtlen++] = '*';
|
||||
else if (flagc & FLAGC_WIDTH)
|
||||
else if (flagc & FLAGC_WIDTH)
|
||||
{
|
||||
fmtlen += hawk_fmt_uintmax_to_bcstr(
|
||||
&fb.fmt.ptr[fmtlen], fb.fmt.capa - fmtlen,
|
||||
&fb.fmt.ptr[fmtlen], fb.fmt.capa - fmtlen,
|
||||
width, 10, -1, '\0', HAWK_NULL);
|
||||
}
|
||||
if (flagc & FLAGC_DOT) fb.fmt.ptr[fmtlen++] = '.';
|
||||
if (flagc & FLAGC_STAR2) fb.fmt.ptr[fmtlen++] = '*';
|
||||
else if (flagc & FLAGC_PRECISION)
|
||||
else if (flagc & FLAGC_PRECISION)
|
||||
{
|
||||
fmtlen += hawk_fmt_uintmax_to_bcstr(
|
||||
&fb.fmt.ptr[fmtlen], fb.fmt.capa - fmtlen,
|
||||
&fb.fmt.ptr[fmtlen], fb.fmt.capa - fmtlen,
|
||||
precision, 10, -1, '\0', HAWK_NULL);
|
||||
}
|
||||
|
||||
@ -1213,7 +1213,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
#if defined(HAVE_SNPRINTF)
|
||||
/* nothing special here */
|
||||
#else
|
||||
/* best effort to avoid buffer overflow when no snprintf is available.
|
||||
/* best effort to avoid buffer overflow when no snprintf is available.
|
||||
* i really can't do much if it happens. */
|
||||
newcapa = precision + width + 32;
|
||||
if (fltout->capa < newcapa)
|
||||
@ -1378,14 +1378,14 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
num = va_arg(ap, int);
|
||||
|
||||
number:
|
||||
if (sign && (hawk_intmax_t)num < 0)
|
||||
if (sign && (hawk_intmax_t)num < 0)
|
||||
{
|
||||
neg = 1;
|
||||
num = -(hawk_intmax_t)num;
|
||||
}
|
||||
|
||||
nbufp = sprintn(nbuf, num, base, &tmp);
|
||||
if ((flagc & FLAGC_SHARP) && num != 0)
|
||||
if ((flagc & FLAGC_SHARP) && num != 0)
|
||||
{
|
||||
if (base == 2 || base == 16) tmp += 2; /* 0b 0x */
|
||||
else if (tmp == 8) tmp += 1; /* 0 */
|
||||
@ -1395,7 +1395,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
else if (flagc & FLAGC_SPACE) tmp++;
|
||||
|
||||
numlen = (int)((const hawk_bch_t*)nbufp - (const hawk_bch_t*)nbuf);
|
||||
if ((flagc & FLAGC_DOT) && precision > numlen)
|
||||
if ((flagc & FLAGC_DOT) && precision > numlen)
|
||||
{
|
||||
/* extra zeros for precision specified */
|
||||
tmp += (precision - numlen);
|
||||
@ -1411,7 +1411,7 @@ static int fmt_outv (hawk_fmtout_t* fmtout, va_list ap)
|
||||
else if (flagc & FLAGC_SIGN) PUT_OOCH (fmtout, '+', 1);
|
||||
else if (flagc & FLAGC_SPACE) PUT_OOCH (fmtout, ' ', 1);
|
||||
|
||||
if ((flagc & FLAGC_SHARP) && num != 0)
|
||||
if ((flagc & FLAGC_SHARP) && num != 0)
|
||||
{
|
||||
if (base == 2)
|
||||
{
|
||||
@ -1574,11 +1574,11 @@ int hawk_ufmt_out (hawk_fmtout_t* fmtout, const hawk_uch_t* fmt, ...)
|
||||
return n;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
/* --------------------------------------------------------------------------
|
||||
* FORMATTED LOG OUTPUT
|
||||
* -------------------------------------------------------------------------- */
|
||||
|
||||
/* i don't want an error raised inside the callback to override
|
||||
/* i don't want an error raised inside the callback to override
|
||||
* the existing error number and message. */
|
||||
#define log_write(hawk,mask,ptr,len) do { \
|
||||
int shuterr = (hawk)->shuterr; \
|
||||
@ -1616,7 +1616,7 @@ redo:
|
||||
hawk_ooch_t* tmp;
|
||||
|
||||
max = HAWK_TYPE_MAX(hawk_oow_t) - hawk->log.len;
|
||||
if (len > max)
|
||||
if (len > max)
|
||||
{
|
||||
/* data too big. */
|
||||
rem += len - max;
|
||||
@ -1636,7 +1636,7 @@ redo:
|
||||
|
||||
/* +1 to handle line ending injection more easily */
|
||||
tmp = hawk_reallocmem(hawk, hawk->log.ptr, (newcapa + 1) * HAWK_SIZEOF(*tmp));
|
||||
if (!tmp)
|
||||
if (!tmp)
|
||||
{
|
||||
make_do:
|
||||
if (hawk->log.len > 0)
|
||||
@ -1732,17 +1732,17 @@ hawk_ooi_t hawk_logbfmtv (hawk_t* hawk, hawk_bitmask_t mask, const hawk_bch_t* f
|
||||
int x;
|
||||
hawk_fmtout_t fo;
|
||||
|
||||
if (hawk->log.default_type_mask & HAWK_LOG_ALL_TYPES)
|
||||
if (hawk->log.default_type_mask & HAWK_LOG_ALL_TYPES)
|
||||
{
|
||||
/* if a type is given, it's not untyped any more.
|
||||
* mask off the UNTYPED bit */
|
||||
mask &= ~HAWK_LOG_UNTYPED;
|
||||
mask &= ~HAWK_LOG_UNTYPED;
|
||||
|
||||
/* if the default_type_mask has the UNTYPED bit on,
|
||||
* it'll get turned back on */
|
||||
mask |= (hawk->log.default_type_mask & HAWK_LOG_ALL_TYPES);
|
||||
}
|
||||
else if (!(mask & HAWK_LOG_ALL_TYPES))
|
||||
else if (!(mask & HAWK_LOG_ALL_TYPES))
|
||||
{
|
||||
/* no type is set in the given mask and no default type is set.
|
||||
* make it UNTYPED. */
|
||||
@ -1785,17 +1785,17 @@ hawk_ooi_t hawk_logufmtv (hawk_t* hawk, hawk_bitmask_t mask, const hawk_uch_t* f
|
||||
int x;
|
||||
hawk_fmtout_t fo;
|
||||
|
||||
if (hawk->log.default_type_mask & HAWK_LOG_ALL_TYPES)
|
||||
if (hawk->log.default_type_mask & HAWK_LOG_ALL_TYPES)
|
||||
{
|
||||
/* if a type is given, it's not untyped any more.
|
||||
* mask off the UNTYPED bit */
|
||||
mask &= ~HAWK_LOG_UNTYPED;
|
||||
mask &= ~HAWK_LOG_UNTYPED;
|
||||
|
||||
/* if the default_type_mask has the UNTYPED bit on,
|
||||
* it'll get turned back on */
|
||||
mask |= (hawk->log.default_type_mask & HAWK_LOG_ALL_TYPES);
|
||||
}
|
||||
else if (!(mask & HAWK_LOG_ALL_TYPES))
|
||||
else if (!(mask & HAWK_LOG_ALL_TYPES))
|
||||
{
|
||||
/* no type is set in the given mask and no default type is set.
|
||||
* make it UNTYPED. */
|
||||
|
Reference in New Issue
Block a user