renamed hcl to hak
This commit is contained in:
@ -24,25 +24,25 @@
|
||||
|
||||
static int fmt_uintmax (
|
||||
char_t* buf, int size,
|
||||
hcl_uintmax_t value, int base_and_flags, int prec,
|
||||
hak_uintmax_t value, int base_and_flags, int prec,
|
||||
char_t fillchar, char_t signchar, const char_t* prefix)
|
||||
{
|
||||
char_t tmp[(HCL_SIZEOF(hcl_uintmax_t) * 8)];
|
||||
char_t tmp[(HAK_SIZEOF(hak_uintmax_t) * 8)];
|
||||
int reslen, base, fillsize, reqlen, pflen, preczero;
|
||||
char_t* p, * bp, * be;
|
||||
const hcl_bch_t* xbasestr;
|
||||
const hak_bch_t* xbasestr;
|
||||
|
||||
base = base_and_flags & 0x3F;
|
||||
if (base < 2 || base > 36) return -1;
|
||||
|
||||
xbasestr = (base_and_flags & HCL_FMT_INTMAX_UPPERCASE)?
|
||||
xbasestr = (base_and_flags & HAK_FMT_INTMAX_UPPERCASE)?
|
||||
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ":
|
||||
"0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
if ((base_and_flags & HCL_FMT_INTMAX_NOZERO) && value == 0)
|
||||
if ((base_and_flags & HAK_FMT_INTMAX_NOZERO) && value == 0)
|
||||
{
|
||||
p = tmp;
|
||||
if (base_and_flags & HCL_FMT_INTMAX_ZEROLEAD)
|
||||
if (base_and_flags & HAK_FMT_INTMAX_ZEROLEAD)
|
||||
{
|
||||
/* NOZERO emits no digit, ZEROLEAD emits 1 digit.
|
||||
* so it emits '0' */
|
||||
@ -58,7 +58,7 @@ static int fmt_uintmax (
|
||||
}
|
||||
else
|
||||
{
|
||||
hcl_uintmax_t v = value;
|
||||
hak_uintmax_t v = value;
|
||||
|
||||
/* store the resulting numeric string into 'tmp' first */
|
||||
p = tmp;
|
||||
@ -87,7 +87,7 @@ static int fmt_uintmax (
|
||||
else
|
||||
{
|
||||
preczero = 0;
|
||||
if ((base_and_flags & HCL_FMT_INTMAX_ZEROLEAD) && value != 0)
|
||||
if ((base_and_flags & HAK_FMT_INTMAX_ZEROLEAD) && value != 0)
|
||||
{
|
||||
/* if value is zero, 0 is emitted from it.
|
||||
* so ZEROLEAD don't need to add another 0. */
|
||||
@ -110,23 +110,23 @@ static int fmt_uintmax (
|
||||
else pflen = 0;
|
||||
|
||||
/* get the required buffer size for lossless formatting */
|
||||
reqlen = (base_and_flags & HCL_FMT_INTMAX_NONULL)? reslen: (reslen + 1);
|
||||
reqlen = (base_and_flags & HAK_FMT_INTMAX_NONULL)? reslen: (reslen + 1);
|
||||
|
||||
if (size <= 0 ||
|
||||
((base_and_flags & HCL_FMT_INTMAX_NOTRUNC) && size < reqlen))
|
||||
((base_and_flags & HAK_FMT_INTMAX_NOTRUNC) && size < reqlen))
|
||||
{
|
||||
return -reqlen;
|
||||
}
|
||||
|
||||
/* get the size to fill with fill characters */
|
||||
fillsize = (base_and_flags & HCL_FMT_INTMAX_NONULL)? size: (size - 1);
|
||||
fillsize = (base_and_flags & HAK_FMT_INTMAX_NONULL)? size: (size - 1);
|
||||
bp = buf;
|
||||
be = buf + fillsize;
|
||||
|
||||
/* fill space */
|
||||
if (fillchar != '\0')
|
||||
{
|
||||
if (base_and_flags & HCL_FMT_INTMAX_FILLRIGHT)
|
||||
if (base_and_flags & HAK_FMT_INTMAX_FILLRIGHT)
|
||||
{
|
||||
/* emit sign */
|
||||
if (signchar && bp < be) *bp++ = signchar;
|
||||
@ -151,7 +151,7 @@ static int fmt_uintmax (
|
||||
fillsize--;
|
||||
}
|
||||
}
|
||||
else if (base_and_flags & HCL_FMT_INTMAX_FILLCENTER)
|
||||
else if (base_and_flags & HAK_FMT_INTMAX_FILLCENTER)
|
||||
{
|
||||
/* emit sign */
|
||||
if (signchar && bp < be) *bp++ = signchar;
|
||||
@ -221,6 +221,6 @@ static int fmt_uintmax (
|
||||
while (p > tmp && bp < be) *bp++ = *--p;
|
||||
}
|
||||
|
||||
if (!(base_and_flags & HCL_FMT_INTMAX_NONULL)) *bp = '\0';
|
||||
if (!(base_and_flags & HAK_FMT_INTMAX_NONULL)) *bp = '\0';
|
||||
return bp - buf;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user