Skip to content

Commit

Permalink
_qrintf_int_core now accepts a pointer next to the last char
Browse files Browse the repository at this point in the history
  • Loading branch information
imasahiro committed Dec 1, 2014
1 parent 6d84553 commit 7148ea6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions misc/gen-qrintf.h.pl
Expand Up @@ -347,15 +347,15 @@ sub build_x {
const char *digits = _qrintf_get_digit_table();
while (val >= 100) {
unsigned idx = val % 100 * 2;
*p-- = digits[idx + 1];
*p-- = digits[idx];
*--p = digits[idx + 1];
*--p = digits[idx];
val /= 100;
}
if (val < 10) {
*p-- = '0' + val;
*--p = '0' + val;
} else {
*p-- = digits[val * 2 + 1];
*p-- = digits[val * 2];
*--p = digits[val * 2 + 1];
*--p = digits[val * 2];
}
}
Expand All @@ -375,7 +375,7 @@ sub build_x {
ctx = _qrintf_nck_fill(ctx, fill_ch, len, width);
}
_qrintf_int_core(ctx.str + ctx.off + wlen - 1, val);
_qrintf_int_core(ctx.str + ctx.off + wlen, val);
ctx.off += len;
return ctx;
}
Expand Down Expand Up @@ -403,7 +403,7 @@ sub build_x {
ctx = _qrintf_chk_fill(ctx, fill_ch, len, width);
}
_qrintf_int_core(ctx.str + ctx.off + wlen - 1, val);
_qrintf_int_core(ctx.str + ctx.off + wlen, val);
ctx.off += len;
return ctx;
}
Expand Down
14 changes: 7 additions & 7 deletions share/qrintf/qrintf.h
Expand Up @@ -249,15 +249,15 @@ static inline void _qrintf_int_core(char *p, unsigned long long val)
const char *digits = _qrintf_get_digit_table();
while (val >= 100) {
unsigned idx = val % 100 * 2;
*p-- = digits[idx + 1];
*p-- = digits[idx];
*--p = digits[idx + 1];
*--p = digits[idx];
val /= 100;
}
if (val < 10) {
*p-- = '0' + val;
*--p = '0' + val;
} else {
*p-- = digits[val * 2 + 1];
*p-- = digits[val * 2];
*--p = digits[val * 2 + 1];
*--p = digits[val * 2];
}
}

Expand All @@ -277,7 +277,7 @@ static inline qrintf_nck_t _qrintf_nck_int_core(qrintf_nck_t ctx, int fill_ch, i
ctx = _qrintf_nck_fill(ctx, fill_ch, len, width);
}

_qrintf_int_core(ctx.str + ctx.off + wlen - 1, val);
_qrintf_int_core(ctx.str + ctx.off + wlen, val);
ctx.off += len;
return ctx;
}
Expand Down Expand Up @@ -305,7 +305,7 @@ static inline qrintf_chk_t _qrintf_chk_int_core(qrintf_chk_t ctx, int fill_ch, i
ctx = _qrintf_chk_fill(ctx, fill_ch, len, width);
}

_qrintf_int_core(ctx.str + ctx.off + wlen - 1, val);
_qrintf_int_core(ctx.str + ctx.off + wlen, val);
ctx.off += len;
return ctx;
}
Expand Down

0 comments on commit 7148ea6

Please sign in to comment.