Add __archive_strappend_int to format a decimal
number into a variable-length archive_string.
This commit is contained in:
parent
2ae4fec062
commit
c2a15e64c5
@ -96,3 +96,18 @@ __archive_strappend_char(struct archive_string *as, char c)
|
||||
{
|
||||
return (__archive_string_append(as, &c, 1));
|
||||
}
|
||||
|
||||
struct archive_string *
|
||||
__archive_strappend_int(struct archive_string *as, int d, int base)
|
||||
{
|
||||
static const char *digits = "0123457890abcdef";
|
||||
|
||||
if (d < 0) {
|
||||
__archive_strappend_char(as, '-');
|
||||
d = -d;
|
||||
}
|
||||
if (d >= base)
|
||||
__archive_strappend_int(as, d/base, base);
|
||||
__archive_strappend_char(as, digits[d % base]);
|
||||
return (as);
|
||||
}
|
||||
|
@ -64,6 +64,10 @@ struct archive_string *
|
||||
__archive_strappend_char_UTF8(struct archive_string *, int);
|
||||
#define archive_strappend_char_UTF8 __archive_strappend_char_UTF8
|
||||
|
||||
/* Append an integer in the specified base (2 <= base <= 16). */
|
||||
struct archive_string *
|
||||
__archive_strappend_int(struct archive_string *as, int d, int base);
|
||||
|
||||
/* Basic append operation. */
|
||||
struct archive_string *
|
||||
__archive_string_append(struct archive_string *as, const char *p, size_t s);
|
||||
|
Loading…
Reference in New Issue
Block a user