diff --git a/libkc3/buf_inspect.c b/libkc3/buf_inspect.c
index 2981238..03a9c65 100644
--- a/libkc3/buf_inspect.c
+++ b/libkc3/buf_inspect.c
@@ -194,7 +194,7 @@ sw buf_inspect_array_data_size_rec (s_pretty *pretty,
while (1) {
if (dimension == array->dimension - 1) {
if (*data) {
- if ((r = data_buf_inspect_size(pretty, array->element_type,
+ if ((r = data_buf_inspect_size(array->element_type, pretty,
*data)) <= 0)
goto clean;
result += r;
@@ -916,8 +916,28 @@ sw buf_inspect_call_op_unary (s_buf *buf, const s_call *call)
sw buf_inspect_call_op_unary_size (s_pretty *pretty, const s_call *call)
{
- (void) call;
- return -1;
+ sw r;
+ sw result = 0;
+ const s_sym *sym;
+ s_ident tmp;
+ assert(pretty);
+ assert(call);
+ if (! operator_symbol(&call->ident, &sym))
+ return -1;
+ if (sym == &g_sym__paren)
+ return buf_inspect_call_paren_size(pretty, call);
+ if (operator_ident(&call->ident, &tmp) != &tmp)
+ return -1;
+ if ((r = buf_inspect_ident_size(pretty, &tmp)) < 0)
+ return r;
+ result += r;
+ if ((r = buf_write_1_size(pretty, " ")) < 0)
+ return r;
+ result += r;
+ if ((r = buf_inspect_tag_size(pretty, &call->arguments->tag)) < 0)
+ return r;
+ result += r;
+ return result;
}
sw buf_inspect_call_paren (s_buf *buf, const s_call *call)
@@ -1310,7 +1330,7 @@ sw buf_inspect_cow (s_buf *buf, const s_cow *cow)
sw buf_inspect_cow_size (s_pretty *pretty, const s_cow *cow)
{
sw r;
- sw result;
+ sw result = 0;
if ((r = buf_write_1_size(pretty, "cow ")) < 0)
return r;
result += r;
@@ -1391,11 +1411,67 @@ sw buf_inspect_f32 (s_buf *buf, const f32 *f)
sw buf_inspect_f32_size (s_pretty *pretty, const f32 *f)
{
- char b[32];
- s_buf buf;
+ s32 exp;
+ u8 i;
+ u8 j;
+ sw r;
+ sw result = 0;
+ f32 x;
+ assert(pretty);
assert(f);
- buf_init(&buf, false, sizeof(b), b);
- return buf_inspect_f32(&buf, f);
+ exp = 0;
+ x = *f;
+ if (x == 0.0)
+ return buf_write_1_size(pretty, "0.0f");
+ if (x < 0) {
+ if ((r = buf_write_1_size(pretty, "-")) <= 0)
+ return r;
+ result += r;
+ x = -x;
+ }
+ if (x >= 1.0)
+ while (x >= 10.0) {
+ x /= 10.0;
+ exp++;
+ }
+ else
+ while (x < 1.0) {
+ x *= 10.0;
+ exp--;
+ }
+ i = (u8) x;
+ x -= i;
+ i += '0';
+ result += 1;
+ if ((r = buf_write_1_size(pretty, ".")) <= 0)
+ return r;
+ result += r;
+ j = 6;
+ do {
+ x *= 10;
+ i = (u8) x;
+ x -= i;
+ i += '0';
+ result += 1;
+ j--;
+ } while (x >= pow(0.1, j) && j);
+ if (exp) {
+ if ((r = buf_write_1_size(pretty, "e")) <= 0)
+ return r;
+ result += r;
+ if (exp > 0) {
+ if ((r = buf_write_1_size(pretty, "+")) <= 0)
+ return r;
+ result += r;
+ }
+ if ((r = buf_inspect_s32_decimal_size(pretty, &exp)) <= 0)
+ return r;
+ result += r;
+ }
+ if ((r = buf_write_1_size(pretty, "f")) <= 0)
+ return r;
+ result += r;
+ return result;
}
sw buf_inspect_f64 (s_buf *buf, const f64 *f)
@@ -1464,13 +1540,66 @@ sw buf_inspect_f64 (s_buf *buf, const f64 *f)
return result;
}
-sw buf_inspect_f64_size (s_pretty *pretty, const f64 *x)
+sw buf_inspect_f64_size (s_pretty *pretty, const f64 *f)
{
- char b[64];
- s_buf buf;
- assert(x);
- buf_init(&buf, false, sizeof(b), b);
- return buf_inspect_f64(&buf, x);
+ s64 exp;
+ u8 i;
+ u8 j;
+ sw r;
+ sw result = 0;
+ f64 x;
+ assert(pretty);
+ assert(f);
+ exp = 0.0;
+ x = *f;
+ if (x == 0.0)
+ return buf_write_1_size(pretty, "0.0");
+ if (x < 0) {
+ if ((r = buf_write_1_size(pretty, "-")) <= 0)
+ return r;
+ result += r;
+ x = -x;
+ }
+ if (x >= 1.0)
+ while (x >= 10.0) {
+ x /= 10.0;
+ exp++;
+ }
+ else
+ while (x < 1.0) {
+ x *= 10.0;
+ exp--;
+ }
+ i = (u8) x;
+ x -= i;
+ i += '0';
+ result += 1;
+ if ((r = buf_write_1_size(pretty, ".")) <= 0)
+ return r;
+ result += r;
+ j = 14;
+ do {
+ x *= 10;
+ i = (u8) x;
+ x -= i;
+ i += '0';
+ result += 1;
+ j--;
+ } while (x > pow(0.1, j) && j);
+ if (exp) {
+ if ((r = buf_write_1_size(pretty, "e")) <= 0)
+ return r;
+ result += r;
+ if (exp > 0) {
+ if ((r = buf_write_1_size(pretty, "+")) <= 0)
+ return r;
+ result += r;
+ }
+ if ((r = buf_inspect_s64_decimal_size(pretty, &exp)) <= 0)
+ return r;
+ result += r;
+ }
+ return result;
}
sw buf_inspect_f128 (s_buf *buf, const f128 *x)
@@ -1541,11 +1670,64 @@ sw buf_inspect_f128 (s_buf *buf, const f128 *x)
sw buf_inspect_f128_size (s_pretty *pretty, const f128 *x)
{
- char b[128];
- s_buf buf;
+ s64 exp;
+ u8 i;
+ u8 j;
+ sw r;
+ sw result = 0;
+ f128 y;
+ assert(pretty);
assert(x);
- buf_init(&buf, false, sizeof(b), b);
- return buf_inspect_f128(&buf, x);
+ exp = 0.0;
+ y = *x;
+ if (y == 0.0)
+ return buf_write_1_size(pretty, "0.0");
+ if (y < 0) {
+ if ((r = buf_write_1_size(pretty, "-")) <= 0)
+ return r;
+ result += r;
+ y = -y;
+ }
+ if (y >= 1.0)
+ while (y >= 10.0) {
+ y /= 10.0;
+ exp++;
+ }
+ else
+ while (y < 1.0) {
+ y *= 10.0;
+ exp--;
+ }
+ i = (u8) y;
+ y -= i;
+ i += '0';
+ result += 1;
+ if ((r = buf_write_1_size(pretty, ".")) <= 0)
+ return r;
+ result += r;
+ j = 33;
+ do {
+ y *= 10;
+ i = (u8) y;
+ y -= i;
+ i += '0';
+ result += 1;
+ j--;
+ } while (y > pow(0.1, j) && j);
+ if (exp) {
+ if ((r = buf_write_1_size(pretty, "e")) <= 0)
+ return r;
+ result += r;
+ if (exp > 0) {
+ if ((r = buf_write_1_size(pretty, "+")) <= 0)
+ return r;
+ result += r;
+ }
+ if ((r = buf_inspect_s64_size(pretty, &exp)) <= 0)
+ return r;
+ result += r;
+ }
+ return result;
}
sw buf_inspect_fact (s_buf *buf, const s_fact *fact)
@@ -1848,7 +2030,7 @@ sw buf_inspect_ident_size (s_pretty *pretty, const s_ident *ident)
return r;
result += r;
}
- if ((r = buf_inspect_ident_sym_size(ident->sym)) < 0)
+ if ((r = buf_inspect_ident_sym_size(pretty, ident->sym)) < 0)
return r;
result += r;
return result;
@@ -1865,31 +2047,31 @@ sw buf_inspect_ident_sym (s_buf *buf, const s_sym *sym)
sw buf_inspect_ident_sym_reserved (s_buf *buf, const s_sym *sym)
{
- sw size;
+ sw r;
+ sw result = 0;
assert(buf);
assert(sym);
- size = buf_inspect_ident_sym_reserved_size(sym);
- if (buf->wpos + size > buf->size) {
- assert(! "buffer overflow");
- return -1;
- }
- buf_write_1(buf, "_");
- buf_inspect_str(buf, &sym->str);
- return size;
+ if ((r = buf_write_1(buf, "_")) < 0)
+ return r;
+ result += r;
+ if ((r = buf_inspect_str(buf, &sym->str)) < 0)
+ return r;
+ result += r;
+ return result;
}
sw buf_inspect_ident_sym_reserved_size (s_pretty *pretty, const s_sym *sym)
{
sw r;
- sw size;
+ sw result = 0;
assert(sym);
if ((r = buf_write_1_size(pretty, "_")) < 0)
return r;
- size += r;
+ result += r;
if ((r = buf_inspect_str_size(pretty, &sym->str)) < 0)
return r;
- size += r;
- return size;
+ result += r;
+ return result;
}
sw buf_inspect_ident_sym_size (s_pretty *pretty, const s_sym *sym)
@@ -1897,7 +2079,7 @@ sw buf_inspect_ident_sym_size (s_pretty *pretty, const s_sym *sym)
if (sym->str.size == 0)
return buf_write_1_size(pretty, "_\"\"");
if (sym_has_ident_reserved_characters(sym))
- return buf_inspect_ident_sym_reserved_size(sym);
+ return buf_inspect_ident_sym_reserved_size(pretty, sym);
return sym->str.size;
}
@@ -1911,7 +2093,7 @@ sw buf_inspect_integer (s_buf *buf, const s_integer *x)
const mp_digit radix = 10;
s32 size = 0;
mp_int t;
- if (mp_radix_size(pretty, &x->mp_int, radix, &size) != MP_OKAY)
+ if (mp_radix_size(&x->mp_int, radix, &size) != MP_OKAY)
return -1;
maxlen = size;
if (MP_IS_ZERO(&x->mp_int))
@@ -1946,10 +2128,16 @@ sw buf_inspect_integer (s_buf *buf, const s_integer *x)
sw buf_inspect_integer_size (s_pretty *pretty, const s_integer *x)
{
- int size;
- if (mp_radix_size(pretty, &x->mp_int, 10, &size) != MP_OKAY)
+ const mp_digit radix = 10;
+ sw result = 0;
+ s32 size = 0;
+ (void) pretty;
+ if (mp_radix_size(&x->mp_int, radix, &size) != MP_OKAY)
return -1;
- return size - 1;
+ result = size;
+ if (MP_IS_ZERO(&x->mp_int))
+ return 1;
+ return result;
}
sw buf_inspect_list (s_buf *buf, const s_list * const *x)
@@ -2180,6 +2368,7 @@ sw buf_inspect_map_size (s_pretty *pretty, const s_map *map)
{
uw i = 0;
s_tag *k;
+ sw r;
sw result = 0;
assert(map);
if ((r = buf_write_1_size(pretty, "%{")) < 0)
@@ -2296,6 +2485,7 @@ sw buf_inspect_ptag (s_buf *buf, const p_tag *ptag)
sw buf_inspect_ptag_size (s_pretty *pretty, const p_tag *ptag)
{
+ sw r;
sw result = 0;
(void) ptag;
if ((r = buf_write_1_size(pretty, "@0x")) < 0)
@@ -2338,6 +2528,7 @@ sw buf_inspect_ptr_free (s_buf *buf, const u_ptr_w *ptr_free)
sw buf_inspect_ptr_free_size (s_pretty *pretty, const u_ptr_w *ptr)
{
+ sw r;
sw result = 0;
(void) ptr;
if ((r = buf_write_1_size(pretty, "(PtrFree) 0x")) < 0)
@@ -2351,12 +2542,15 @@ sw buf_inspect_ptr_free_size (s_pretty *pretty, const u_ptr_w *ptr)
sw buf_inspect_ptr_size (s_pretty *pretty, const u_ptr_w *ptr)
{
+ sw r;
sw result = 0;
(void) ptr;
if ((r = buf_write_1_size(pretty, "(Ptr) 0x")) < 0)
return r;
result += r;
- if ((r = buf_inspect_uw_hexadecimal_size((uw *) &ptr->p);
+ if ((r = buf_inspect_uw_hexadecimal_size(pretty, (uw *) &ptr->p)) < 0)
+ return r;
+ result += r;
return result;
}
@@ -2449,7 +2643,7 @@ sw buf_inspect_str (s_buf *buf, const s_str *str)
if ((r = buf_write_u8(buf, '"')) <= 0)
goto clean;
result += r;
- if ((r = buf_write_str(buf, str)) < 0)
+ if ((r = buf_write_str_memcpy(buf, str)) < 0)
goto restore;
result += r;
if ((r = buf_write_u8(buf, '"')) <= 0)
@@ -2497,10 +2691,10 @@ sw buf_inspect_str_byte_size (s_pretty *pretty, const u8 *byte)
sw r;
sw result = 0;
(void) byte;
- r = buf_write_1_size(pretty, "\\")) < 0)
+ if ((r = buf_write_1_size(pretty, "\\")) < 0)
return r;
result += r;
- r = buf_write_1_size(pretty, "x")) < 0)
+ if ((r = buf_write_1_size(pretty, "x")) < 0)
return r;
result += r;
r = 2;
@@ -2571,6 +2765,7 @@ sw buf_inspect_str_character_size (s_pretty *pretty, const character *c)
{
sw csize;
sw size;
+ (void) pretty;
if (! str_character_is_reserved(*c))
return character_utf8_size(*c);
size = 0;
@@ -2628,8 +2823,34 @@ sw buf_inspect_str_eval (s_buf *buf, const s_list *list)
sw buf_inspect_str_eval_size (s_pretty *pretty, const s_list *list)
{
- (void) list;
- return -1;
+ const s_list *l;
+ sw r;
+ sw result = 0;
+ const s_tag *tag;
+ if ((r = buf_write_1_size(pretty, "\"")) < 0)
+ return r;
+ l = list;
+ while (l) {
+ if (l->tag.type == TAG_STR) {
+ if ((r = buf_write_str_size(pretty, &l->tag.data.str)) < 0)
+ return r;
+ }
+ else {
+ if ((r = buf_write_1_size(pretty, "#{")) < 0)
+ return r;
+ tag = &l->tag;
+ if (tag_is_cast(tag, &g_sym_Str))
+ tag = &list_next(tag->data.call.arguments)->tag;
+ if ((r = buf_inspect_tag_size(pretty, tag)) < 0)
+ return r;
+ if ((r = buf_write_1_size(pretty, "}")) < 0)
+ return r;
+ }
+ l = list_next(l);
+ }
+ if ((r = buf_write_1_size(pretty, "\"")) < 0)
+ return r;
+ return result;
}
/* keep in sync with buf_inspect_str_reserved_size */
@@ -2717,10 +2938,8 @@ sw buf_inspect_str_reserved_size (s_pretty *pretty, const s_str *str)
sw buf_inspect_str_size (s_pretty *pretty, const s_str *str)
{
bool b;
- const sw quote_size;
sw r;
sw result = 0;
- sw size;
if (! str_has_reserved_characters(str, &b))
return -1;
if (b)
@@ -2732,7 +2951,7 @@ sw buf_inspect_str_size (s_pretty *pretty, const s_str *str)
if ((r = buf_write_1_size(pretty, "\"")) < 0)
return r;
result += r;
- return size;
+ return result;
}
sw buf_inspect_struct (s_buf *buf, const s_struct *s)
@@ -2854,13 +3073,14 @@ sw buf_inspect_struct_size (s_pretty *pretty, const s_struct *s)
if (! tag_type(s->type->map.value + i, &type))
return -1;
assert(s->type->offset[i] < s->type->size);
- if ((r = data_buf_inspect_size(type, (char *) s->data +
+ if ((r = data_buf_inspect_size(type, pretty,
+ (char *) s->data +
s->type->offset[i])) < 0)
return r;
result += r;
}
else if (s->tag) {
- if ((r = buf_inspect_tag_size(s->tag + i)) < 0)
+ if ((r = buf_inspect_tag_size(pretty, s->tag + i)) < 0)
return r;
result += r;
}
@@ -2931,7 +3151,7 @@ sw buf_inspect_struct_type_size (s_pretty *pretty, const s_struct_type *st)
s_array offset_array;
uw offset_array_dimension;
sw r;
- sw result;
+ sw result = 0;
assert(st);
assert(sym_is_module(st->module));
assert(st->offset);
@@ -3004,7 +3224,7 @@ sw buf_inspect_sym_size (s_pretty *pretty, const s_sym * const *sym)
if (x->str.size == 0)
return 3;
if (sym_has_reserved_characters(x))
- return buf_inspect_sym_reserved_size(x);
+ return buf_inspect_sym_reserved_size(pretty, x);
if (sym_is_module(x) || sym_is_array_type(x))
return x->str.size;
return x->str.size + colon_size;
@@ -3109,9 +3329,9 @@ sw buf_inspect_tag_size (s_pretty *pretty, const s_tag *tag)
case TAG_CHARACTER:
return buf_inspect_character_size(pretty, &tag->data.character);
case TAG_COMPLEX:
- return buf_inspect_complex_size(tag->data.complex);
+ return buf_inspect_complex_size(pretty, tag->data.complex);
case TAG_COW:
- return buf_inspect_cow_size(tag->data.cow);
+ return buf_inspect_cow_size(pretty, tag->data.cow);
case TAG_F32:
return buf_inspect_f32_size(pretty, &tag->data.f32);
case TAG_F64:
@@ -3195,7 +3415,7 @@ sw buf_inspect_tag_type (s_buf *buf, e_tag_type type)
return buf_write_1(buf, s);
}
-sw buf_inspect_tag_type_size (e_tag_type type)
+sw buf_inspect_tag_type_size (s_pretty *pretty, e_tag_type type)
{
const char *s;
s = tag_type_to_string(type);
@@ -3286,7 +3506,7 @@ sw buf_inspect_tuple_size (s_pretty *pretty, const s_tuple *tuple)
result += r;
if (tuple->count) {
while (i < tuple->count - 1) {
- if ((r = buf_inspect_tag_size(tuple->tag + i)) < 0)
+ if ((r = buf_inspect_tag_size(pretty, tuple->tag + i)) < 0)
return r;
result += r;
if ((r = buf_write_1_size(pretty, ", ")) < 0)
@@ -3294,7 +3514,7 @@ sw buf_inspect_tuple_size (s_pretty *pretty, const s_tuple *tuple)
result += r;
i++;
}
- if ((r = buf_inspect_tag_size(tuple->tag + i)) < 0)
+ if ((r = buf_inspect_tag_size(pretty, tuple->tag + i)) < 0)
return r;
result += r;
}
@@ -3369,7 +3589,7 @@ sw buf_inspect_var_size (s_pretty *pretty, const s_tag *tag)
sw result = 0;
if (tag->data.var.type == &g_sym_Tag)
return buf_write_1_size(pretty, "?");
- if ((r = buf_inspect_paren_sym_size(tag->data.var.type)) < 0)
+ if ((r = buf_inspect_paren_sym_size(pretty, tag->data.var.type)) < 0)
return r;
result += r;
if ((r = buf_write_1_size(pretty, " ?")) < 0)
diff --git a/libkc3/buf_inspect_s.c.in b/libkc3/buf_inspect_s.c.in
index 948255e..08cd82b 100644
--- a/libkc3/buf_inspect_s.c.in
+++ b/libkc3/buf_inspect_s.c.in
@@ -56,14 +56,20 @@ sw buf_inspect_s_bits$_size (s_pretty *pretty, const s_bits$ *s)
if ((r = buf_inspect_paren_sym_size(pretty, &g_sym_S_bits$)) < 0)
return r;
result += r;
- result += strlen(" ");
+ if ((r = buf_write_1_size(pretty, " ")) < 0)
+ return r;
+ result += r;
}
if (*s < 0) {
- result += strlen("-");
+ if ((r = buf_write_1_size(pretty, "-")) < 0)
+ return r;
+ result += r;
u = -*s;
}
else
u = *s;
- result += buf_inspect_u_bits$_decimal_size(&u);
+ if ((r = buf_inspect_u_bits$_decimal_size(pretty, &u)) < 0)
+ return r;
+ result += r;
return result;
}
diff --git a/libkc3/buf_inspect_s16.c b/libkc3/buf_inspect_s16.c
index 1d22cdd..655c8fb 100644
--- a/libkc3/buf_inspect_s16.c
+++ b/libkc3/buf_inspect_s16.c
@@ -56,14 +56,20 @@ sw buf_inspect_s16_size (s_pretty *pretty, const s16 *s)
if ((r = buf_inspect_paren_sym_size(pretty, &g_sym_S16)) < 0)
return r;
result += r;
- result += strlen(" ");
+ if ((r = buf_write_1_size(pretty, " ")) < 0)
+ return r;
+ result += r;
}
if (*s < 0) {
- result += strlen("-");
+ if ((r = buf_write_1_size(pretty, "-")) < 0)
+ return r;
+ result += r;
u = -*s;
}
else
u = *s;
- result += buf_inspect_u16_decimal_size(&u);
+ if ((r = buf_inspect_u16_decimal_size(pretty, &u)) < 0)
+ return r;
+ result += r;
return result;
}
diff --git a/libkc3/buf_inspect_s16_binary.c b/libkc3/buf_inspect_s16_binary.c
index d2e2851..50ed2ff 100644
--- a/libkc3/buf_inspect_s16_binary.c
+++ b/libkc3/buf_inspect_s16_binary.c
@@ -33,7 +33,7 @@ sw buf_inspect_s16_binary (s_buf *buf, const s16 *s)
return result;
}
-sw buf_inspect_s16_binary_size (const s16 *s)
+sw buf_inspect_s16_binary_size (s_pretty *pretty, const s16 *s)
{
sw result = 0;
u16 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s16_binary_size (const s16 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u16_binary_size(&u);
+ result += buf_inspect_u16_binary_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s16_decimal.c b/libkc3/buf_inspect_s16_decimal.c
index 26dbc4a..17ca6f4 100644
--- a/libkc3/buf_inspect_s16_decimal.c
+++ b/libkc3/buf_inspect_s16_decimal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s16_decimal (s_buf *buf, const s16 *s)
return result;
}
-sw buf_inspect_s16_decimal_size (const s16 *s)
+sw buf_inspect_s16_decimal_size (s_pretty *pretty, const s16 *s)
{
sw result = 0;
u16 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s16_decimal_size (const s16 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u16_decimal_size(&u);
+ result += buf_inspect_u16_decimal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s16_decimal.h b/libkc3/buf_inspect_s16_decimal.h
index 9e84b62..97722d0 100644
--- a/libkc3/buf_inspect_s16_decimal.h
+++ b/libkc3/buf_inspect_s16_decimal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_s16_decimal (s_buf *buf, const s16 *s);
-sw buf_inspect_s16_decimal_size (const s16 *s);
+sw buf_inspect_s16_decimal_size (s_pretty *pretty, const s16 *s);
#endif /* LIBKC3_BUF_INSPECT_S16_decimal_H */
diff --git a/libkc3/buf_inspect_s16_hexadecimal.c b/libkc3/buf_inspect_s16_hexadecimal.c
index 2da51f3..0409697 100644
--- a/libkc3/buf_inspect_s16_hexadecimal.c
+++ b/libkc3/buf_inspect_s16_hexadecimal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s16_hexadecimal (s_buf *buf, const s16 *s)
return result;
}
-sw buf_inspect_s16_hexadecimal_size (const s16 *s)
+sw buf_inspect_s16_hexadecimal_size (s_pretty *pretty, const s16 *s)
{
sw result = 0;
u16 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s16_hexadecimal_size (const s16 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u16_hexadecimal_size(&u);
+ result += buf_inspect_u16_hexadecimal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s16_octal.c b/libkc3/buf_inspect_s16_octal.c
index d316612..583559b 100644
--- a/libkc3/buf_inspect_s16_octal.c
+++ b/libkc3/buf_inspect_s16_octal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s16_octal (s_buf *buf, const s16 *s)
return result;
}
-sw buf_inspect_s16_octal_size (const s16 *s)
+sw buf_inspect_s16_octal_size (s_pretty *pretty, const s16 *s)
{
sw result = 0;
u16 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s16_octal_size (const s16 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u16_octal_size(&u);
+ result += buf_inspect_u16_octal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s32.c b/libkc3/buf_inspect_s32.c
index 5e9b075..2e345cd 100644
--- a/libkc3/buf_inspect_s32.c
+++ b/libkc3/buf_inspect_s32.c
@@ -56,14 +56,20 @@ sw buf_inspect_s32_size (s_pretty *pretty, const s32 *s)
if ((r = buf_inspect_paren_sym_size(pretty, &g_sym_S32)) < 0)
return r;
result += r;
- result += strlen(" ");
+ if ((r = buf_write_1_size(pretty, " ")) < 0)
+ return r;
+ result += r;
}
if (*s < 0) {
- result += strlen("-");
+ if ((r = buf_write_1_size(pretty, "-")) < 0)
+ return r;
+ result += r;
u = -*s;
}
else
u = *s;
- result += buf_inspect_u32_decimal_size(&u);
+ if ((r = buf_inspect_u32_decimal_size(pretty, &u)) < 0)
+ return r;
+ result += r;
return result;
}
diff --git a/libkc3/buf_inspect_s32_binary.c b/libkc3/buf_inspect_s32_binary.c
index fdc2839..b2015e0 100644
--- a/libkc3/buf_inspect_s32_binary.c
+++ b/libkc3/buf_inspect_s32_binary.c
@@ -33,7 +33,7 @@ sw buf_inspect_s32_binary (s_buf *buf, const s32 *s)
return result;
}
-sw buf_inspect_s32_binary_size (const s32 *s)
+sw buf_inspect_s32_binary_size (s_pretty *pretty, const s32 *s)
{
sw result = 0;
u32 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s32_binary_size (const s32 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u32_binary_size(&u);
+ result += buf_inspect_u32_binary_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s32_decimal.c b/libkc3/buf_inspect_s32_decimal.c
index 25ed77e..46db772 100644
--- a/libkc3/buf_inspect_s32_decimal.c
+++ b/libkc3/buf_inspect_s32_decimal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s32_decimal (s_buf *buf, const s32 *s)
return result;
}
-sw buf_inspect_s32_decimal_size (const s32 *s)
+sw buf_inspect_s32_decimal_size (s_pretty *pretty, const s32 *s)
{
sw result = 0;
u32 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s32_decimal_size (const s32 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u32_decimal_size(&u);
+ result += buf_inspect_u32_decimal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s32_decimal.h b/libkc3/buf_inspect_s32_decimal.h
index f8c1a09..06638f9 100644
--- a/libkc3/buf_inspect_s32_decimal.h
+++ b/libkc3/buf_inspect_s32_decimal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_s32_decimal (s_buf *buf, const s32 *s);
-sw buf_inspect_s32_decimal_size (const s32 *s);
+sw buf_inspect_s32_decimal_size (s_pretty *pretty, const s32 *s);
#endif /* LIBKC3_BUF_INSPECT_S32_decimal_H */
diff --git a/libkc3/buf_inspect_s32_hexadecimal.c b/libkc3/buf_inspect_s32_hexadecimal.c
index b7367ae..c507580 100644
--- a/libkc3/buf_inspect_s32_hexadecimal.c
+++ b/libkc3/buf_inspect_s32_hexadecimal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s32_hexadecimal (s_buf *buf, const s32 *s)
return result;
}
-sw buf_inspect_s32_hexadecimal_size (const s32 *s)
+sw buf_inspect_s32_hexadecimal_size (s_pretty *pretty, const s32 *s)
{
sw result = 0;
u32 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s32_hexadecimal_size (const s32 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u32_hexadecimal_size(&u);
+ result += buf_inspect_u32_hexadecimal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s32_octal.c b/libkc3/buf_inspect_s32_octal.c
index 2bb75c5..62abbb5 100644
--- a/libkc3/buf_inspect_s32_octal.c
+++ b/libkc3/buf_inspect_s32_octal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s32_octal (s_buf *buf, const s32 *s)
return result;
}
-sw buf_inspect_s32_octal_size (const s32 *s)
+sw buf_inspect_s32_octal_size (s_pretty *pretty, const s32 *s)
{
sw result = 0;
u32 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s32_octal_size (const s32 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u32_octal_size(&u);
+ result += buf_inspect_u32_octal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s64.c b/libkc3/buf_inspect_s64.c
index 54bf247..ad12915 100644
--- a/libkc3/buf_inspect_s64.c
+++ b/libkc3/buf_inspect_s64.c
@@ -56,14 +56,20 @@ sw buf_inspect_s64_size (s_pretty *pretty, const s64 *s)
if ((r = buf_inspect_paren_sym_size(pretty, &g_sym_S64)) < 0)
return r;
result += r;
- result += strlen(" ");
+ if ((r = buf_write_1_size(pretty, " ")) < 0)
+ return r;
+ result += r;
}
if (*s < 0) {
- result += strlen("-");
+ if ((r = buf_write_1_size(pretty, "-")) < 0)
+ return r;
+ result += r;
u = -*s;
}
else
u = *s;
- result += buf_inspect_u64_decimal_size(&u);
+ if ((r = buf_inspect_u64_decimal_size(pretty, &u)) < 0)
+ return r;
+ result += r;
return result;
}
diff --git a/libkc3/buf_inspect_s64_binary.c b/libkc3/buf_inspect_s64_binary.c
index 65a5abf..6c48859 100644
--- a/libkc3/buf_inspect_s64_binary.c
+++ b/libkc3/buf_inspect_s64_binary.c
@@ -33,7 +33,7 @@ sw buf_inspect_s64_binary (s_buf *buf, const s64 *s)
return result;
}
-sw buf_inspect_s64_binary_size (const s64 *s)
+sw buf_inspect_s64_binary_size (s_pretty *pretty, const s64 *s)
{
sw result = 0;
u64 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s64_binary_size (const s64 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u64_binary_size(&u);
+ result += buf_inspect_u64_binary_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s64_decimal.c b/libkc3/buf_inspect_s64_decimal.c
index e39e9eb..ff9e798 100644
--- a/libkc3/buf_inspect_s64_decimal.c
+++ b/libkc3/buf_inspect_s64_decimal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s64_decimal (s_buf *buf, const s64 *s)
return result;
}
-sw buf_inspect_s64_decimal_size (const s64 *s)
+sw buf_inspect_s64_decimal_size (s_pretty *pretty, const s64 *s)
{
sw result = 0;
u64 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s64_decimal_size (const s64 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u64_decimal_size(&u);
+ result += buf_inspect_u64_decimal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s64_decimal.h b/libkc3/buf_inspect_s64_decimal.h
index 33eb178..b7f33a9 100644
--- a/libkc3/buf_inspect_s64_decimal.h
+++ b/libkc3/buf_inspect_s64_decimal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_s64_decimal (s_buf *buf, const s64 *s);
-sw buf_inspect_s64_decimal_size (const s64 *s);
+sw buf_inspect_s64_decimal_size (s_pretty *pretty, const s64 *s);
#endif /* LIBKC3_BUF_INSPECT_S64_decimal_H */
diff --git a/libkc3/buf_inspect_s64_hexadecimal.c b/libkc3/buf_inspect_s64_hexadecimal.c
index 0a8ce43..9847ae0 100644
--- a/libkc3/buf_inspect_s64_hexadecimal.c
+++ b/libkc3/buf_inspect_s64_hexadecimal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s64_hexadecimal (s_buf *buf, const s64 *s)
return result;
}
-sw buf_inspect_s64_hexadecimal_size (const s64 *s)
+sw buf_inspect_s64_hexadecimal_size (s_pretty *pretty, const s64 *s)
{
sw result = 0;
u64 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s64_hexadecimal_size (const s64 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u64_hexadecimal_size(&u);
+ result += buf_inspect_u64_hexadecimal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s64_octal.c b/libkc3/buf_inspect_s64_octal.c
index 8c15928..1361a65 100644
--- a/libkc3/buf_inspect_s64_octal.c
+++ b/libkc3/buf_inspect_s64_octal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s64_octal (s_buf *buf, const s64 *s)
return result;
}
-sw buf_inspect_s64_octal_size (const s64 *s)
+sw buf_inspect_s64_octal_size (s_pretty *pretty, const s64 *s)
{
sw result = 0;
u64 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s64_octal_size (const s64 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u64_octal_size(&u);
+ result += buf_inspect_u64_octal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s8.c b/libkc3/buf_inspect_s8.c
index 33682a3..8f57b86 100644
--- a/libkc3/buf_inspect_s8.c
+++ b/libkc3/buf_inspect_s8.c
@@ -56,14 +56,20 @@ sw buf_inspect_s8_size (s_pretty *pretty, const s8 *s)
if ((r = buf_inspect_paren_sym_size(pretty, &g_sym_S8)) < 0)
return r;
result += r;
- result += strlen(" ");
+ if ((r = buf_write_1_size(pretty, " ")) < 0)
+ return r;
+ result += r;
}
if (*s < 0) {
- result += strlen("-");
+ if ((r = buf_write_1_size(pretty, "-")) < 0)
+ return r;
+ result += r;
u = -*s;
}
else
u = *s;
- result += buf_inspect_u8_decimal_size(&u);
+ if ((r = buf_inspect_u8_decimal_size(pretty, &u)) < 0)
+ return r;
+ result += r;
return result;
}
diff --git a/libkc3/buf_inspect_s8_binary.c b/libkc3/buf_inspect_s8_binary.c
index 5eeb666..ae937e6 100644
--- a/libkc3/buf_inspect_s8_binary.c
+++ b/libkc3/buf_inspect_s8_binary.c
@@ -33,7 +33,7 @@ sw buf_inspect_s8_binary (s_buf *buf, const s8 *s)
return result;
}
-sw buf_inspect_s8_binary_size (const s8 *s)
+sw buf_inspect_s8_binary_size (s_pretty *pretty, const s8 *s)
{
sw result = 0;
u8 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s8_binary_size (const s8 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u8_binary_size(&u);
+ result += buf_inspect_u8_binary_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s8_decimal.c b/libkc3/buf_inspect_s8_decimal.c
index 3b01291..c848662 100644
--- a/libkc3/buf_inspect_s8_decimal.c
+++ b/libkc3/buf_inspect_s8_decimal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s8_decimal (s_buf *buf, const s8 *s)
return result;
}
-sw buf_inspect_s8_decimal_size (const s8 *s)
+sw buf_inspect_s8_decimal_size (s_pretty *pretty, const s8 *s)
{
sw result = 0;
u8 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s8_decimal_size (const s8 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u8_decimal_size(&u);
+ result += buf_inspect_u8_decimal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s8_decimal.h b/libkc3/buf_inspect_s8_decimal.h
index 4a5029d..a316350 100644
--- a/libkc3/buf_inspect_s8_decimal.h
+++ b/libkc3/buf_inspect_s8_decimal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_s8_decimal (s_buf *buf, const s8 *s);
-sw buf_inspect_s8_decimal_size (const s8 *s);
+sw buf_inspect_s8_decimal_size (s_pretty *pretty, const s8 *s);
#endif /* LIBKC3_BUF_INSPECT_S8_decimal_H */
diff --git a/libkc3/buf_inspect_s8_hexadecimal.c b/libkc3/buf_inspect_s8_hexadecimal.c
index fee3eb6..988e477 100644
--- a/libkc3/buf_inspect_s8_hexadecimal.c
+++ b/libkc3/buf_inspect_s8_hexadecimal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s8_hexadecimal (s_buf *buf, const s8 *s)
return result;
}
-sw buf_inspect_s8_hexadecimal_size (const s8 *s)
+sw buf_inspect_s8_hexadecimal_size (s_pretty *pretty, const s8 *s)
{
sw result = 0;
u8 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s8_hexadecimal_size (const s8 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u8_hexadecimal_size(&u);
+ result += buf_inspect_u8_hexadecimal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s8_octal.c b/libkc3/buf_inspect_s8_octal.c
index 0bc4b70..592824c 100644
--- a/libkc3/buf_inspect_s8_octal.c
+++ b/libkc3/buf_inspect_s8_octal.c
@@ -33,7 +33,7 @@ sw buf_inspect_s8_octal (s_buf *buf, const s8 *s)
return result;
}
-sw buf_inspect_s8_octal_size (const s8 *s)
+sw buf_inspect_s8_octal_size (s_pretty *pretty, const s8 *s)
{
sw result = 0;
u8 u;
@@ -42,6 +42,6 @@ sw buf_inspect_s8_octal_size (const s8 *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u8_octal_size(&u);
+ result += buf_inspect_u8_octal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s_base.c.in b/libkc3/buf_inspect_s_base.c.in
index 45cbac4..7283a81 100644
--- a/libkc3/buf_inspect_s_base.c.in
+++ b/libkc3/buf_inspect_s_base.c.in
@@ -33,7 +33,7 @@ sw buf_inspect_s_bits$__BASE$ (s_buf *buf, const s_bits$ *s)
return result;
}
-sw buf_inspect_s_bits$__BASE$_size (const s_bits$ *s)
+sw buf_inspect_s_bits$__BASE$_size (s_pretty *pretty, const s_bits$ *s)
{
sw result = 0;
u_bits$ u;
@@ -42,6 +42,6 @@ sw buf_inspect_s_bits$__BASE$_size (const s_bits$ *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_u_bits$__BASE$_size(&u);
+ result += buf_inspect_u_bits$__BASE$_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_s_base.h.in b/libkc3/buf_inspect_s_base.h.in
index cde1fe9..83f53fe 100644
--- a/libkc3/buf_inspect_s_base.h.in
+++ b/libkc3/buf_inspect_s_base.h.in
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_s_bits$__BASE$ (s_buf *buf, const s_bits$ *s);
-sw buf_inspect_s_bits$__BASE$_size (const s_bits$ *s);
+sw buf_inspect_s_bits$__BASE$_size (s_pretty *pretty, const s_bits$ *s);
#endif /* LIBKC3_BUF_INSPECT_S_BITS$__BASE$_H */
diff --git a/libkc3/buf_inspect_sw.c b/libkc3/buf_inspect_sw.c
index 59df1ab..489e104 100644
--- a/libkc3/buf_inspect_sw.c
+++ b/libkc3/buf_inspect_sw.c
@@ -56,14 +56,20 @@ sw buf_inspect_sw_size (s_pretty *pretty, const sw *s)
if ((r = buf_inspect_paren_sym_size(pretty, &g_sym_Sw)) < 0)
return r;
result += r;
- result += strlen(" ");
+ if ((r = buf_write_1_size(pretty, " ")) < 0)
+ return r;
+ result += r;
}
if (*s < 0) {
- result += strlen("-");
+ if ((r = buf_write_1_size(pretty, "-")) < 0)
+ return r;
+ result += r;
u = -*s;
}
else
u = *s;
- result += buf_inspect_uw_decimal_size(&u);
+ if ((r = buf_inspect_uw_decimal_size(pretty, &u)) < 0)
+ return r;
+ result += r;
return result;
}
diff --git a/libkc3/buf_inspect_sw_binary.c b/libkc3/buf_inspect_sw_binary.c
index 1ffcd82..bd3ce81 100644
--- a/libkc3/buf_inspect_sw_binary.c
+++ b/libkc3/buf_inspect_sw_binary.c
@@ -33,7 +33,7 @@ sw buf_inspect_sw_binary (s_buf *buf, const sw *s)
return result;
}
-sw buf_inspect_sw_binary_size (const sw *s)
+sw buf_inspect_sw_binary_size (s_pretty *pretty, const sw *s)
{
sw result = 0;
uw u;
@@ -42,6 +42,6 @@ sw buf_inspect_sw_binary_size (const sw *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_uw_binary_size(&u);
+ result += buf_inspect_uw_binary_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_sw_decimal.c b/libkc3/buf_inspect_sw_decimal.c
index eae7fe9..f40662e 100644
--- a/libkc3/buf_inspect_sw_decimal.c
+++ b/libkc3/buf_inspect_sw_decimal.c
@@ -33,7 +33,7 @@ sw buf_inspect_sw_decimal (s_buf *buf, const sw *s)
return result;
}
-sw buf_inspect_sw_decimal_size (const sw *s)
+sw buf_inspect_sw_decimal_size (s_pretty *pretty, const sw *s)
{
sw result = 0;
uw u;
@@ -42,6 +42,6 @@ sw buf_inspect_sw_decimal_size (const sw *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_uw_decimal_size(&u);
+ result += buf_inspect_uw_decimal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_sw_decimal.h b/libkc3/buf_inspect_sw_decimal.h
index c45fe5f..8af989a 100644
--- a/libkc3/buf_inspect_sw_decimal.h
+++ b/libkc3/buf_inspect_sw_decimal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_sw_decimal (s_buf *buf, const sw *s);
-sw buf_inspect_sw_decimal_size (const sw *s);
+sw buf_inspect_sw_decimal_size (s_pretty *pretty, const sw *s);
#endif /* LIBKC3_BUF_INSPECT_SW_decimal_H */
diff --git a/libkc3/buf_inspect_sw_hexadecimal.c b/libkc3/buf_inspect_sw_hexadecimal.c
index 5f08a12..571d551 100644
--- a/libkc3/buf_inspect_sw_hexadecimal.c
+++ b/libkc3/buf_inspect_sw_hexadecimal.c
@@ -33,7 +33,7 @@ sw buf_inspect_sw_hexadecimal (s_buf *buf, const sw *s)
return result;
}
-sw buf_inspect_sw_hexadecimal_size (const sw *s)
+sw buf_inspect_sw_hexadecimal_size (s_pretty *pretty, const sw *s)
{
sw result = 0;
uw u;
@@ -42,6 +42,6 @@ sw buf_inspect_sw_hexadecimal_size (const sw *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_uw_hexadecimal_size(&u);
+ result += buf_inspect_uw_hexadecimal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_sw_octal.c b/libkc3/buf_inspect_sw_octal.c
index 91e57a1..42942dc 100644
--- a/libkc3/buf_inspect_sw_octal.c
+++ b/libkc3/buf_inspect_sw_octal.c
@@ -33,7 +33,7 @@ sw buf_inspect_sw_octal (s_buf *buf, const sw *s)
return result;
}
-sw buf_inspect_sw_octal_size (const sw *s)
+sw buf_inspect_sw_octal_size (s_pretty *pretty, const sw *s)
{
sw result = 0;
uw u;
@@ -42,6 +42,6 @@ sw buf_inspect_sw_octal_size (const sw *s)
result += strlen("-");
u = -*s;
}
- result += buf_inspect_uw_octal_size(&u);
+ result += buf_inspect_uw_octal_size(pretty, &u);
return result;
}
diff --git a/libkc3/buf_inspect_u.c.in b/libkc3/buf_inspect_u.c.in
index cf71184..18bd5c1 100644
--- a/libkc3/buf_inspect_u.c.in
+++ b/libkc3/buf_inspect_u.c.in
@@ -21,26 +21,26 @@
#include "str.h"
#include "sym.h"
-sw buf_inspect_u_bits$ (s_pretty *pretty, s_buf *buf, const u_bits$ *u)
+sw buf_inspect_u_bits$ (s_buf *buf, const u_bits$ *u)
{
sw r;
sw result = 0;
if (g_buf_inspect_type != &g_sym_U_bits$ &&
cast_needed_u_bits$(*u)) {
- if ((r = buf_inspect_paren_sym(pretty, buf, &g_sym_U_bits$)) < 0)
+ if ((r = buf_inspect_paren_sym(buf, &g_sym_U_bits$)) < 0)
return r;
result += r;
if ((r = buf_write_1(buf, " ")) < 0)
return r;
result += r;
}
- if ((r = buf_inspect_u_bits$_base(pretty, buf, &g_kc3_base_decimal, u)) < 0)
+ if ((r = buf_inspect_u_bits$_base(buf, &g_kc3_base_decimal, u)) < 0)
return r;
result += r;
return result;
}
-sw buf_inspect_u_bits$_base (s_pretty *pretty, s_buf *buf,
+sw buf_inspect_u_bits$_base (s_buf *buf,
const s_str *base,
const u_bits$ *u)
{
@@ -60,7 +60,7 @@ sw buf_inspect_u_bits$_base (s_pretty *pretty, s_buf *buf,
return -1;
return buf_write_character_utf8(buf, zero);
}
- size = buf_inspect_u_bits$_base_digits(pretty, base, u);
+ size = buf_inspect_u_bits$_base_digits(base, u);
c = alloc(size * sizeof(character));
buf_save_init(buf, &save);
radix = base->size;
@@ -89,7 +89,7 @@ sw buf_inspect_u_bits$_base (s_pretty *pretty, s_buf *buf,
return r;
}
-sw buf_inspect_u_bits$_base_digits (s_pretty *pretty, const s_str *base,
+sw buf_inspect_u_bits$_base_digits (const s_str *base,
const u_bits$ *u)
{
uw radix;
diff --git a/libkc3/buf_inspect_u16.c b/libkc3/buf_inspect_u16.c
index 4cbc7e0..ae4b4d0 100644
--- a/libkc3/buf_inspect_u16.c
+++ b/libkc3/buf_inspect_u16.c
@@ -21,26 +21,26 @@
#include "str.h"
#include "sym.h"
-sw buf_inspect_u16 (s_pretty *pretty, s_buf *buf, const u16 *u)
+sw buf_inspect_u16 (s_buf *buf, const u16 *u)
{
sw r;
sw result = 0;
if (g_buf_inspect_type != &g_sym_U16 &&
cast_needed_u16(*u)) {
- if ((r = buf_inspect_paren_sym(pretty, buf, &g_sym_U16)) < 0)
+ if ((r = buf_inspect_paren_sym(buf, &g_sym_U16)) < 0)
return r;
result += r;
if ((r = buf_write_1(buf, " ")) < 0)
return r;
result += r;
}
- if ((r = buf_inspect_u16_base(pretty, buf, &g_kc3_base_decimal, u)) < 0)
+ if ((r = buf_inspect_u16_base(buf, &g_kc3_base_decimal, u)) < 0)
return r;
result += r;
return result;
}
-sw buf_inspect_u16_base (s_pretty *pretty, s_buf *buf,
+sw buf_inspect_u16_base (s_buf *buf,
const s_str *base,
const u16 *u)
{
@@ -60,7 +60,7 @@ sw buf_inspect_u16_base (s_pretty *pretty, s_buf *buf,
return -1;
return buf_write_character_utf8(buf, zero);
}
- size = buf_inspect_u16_base_digits(pretty, base, u);
+ size = buf_inspect_u16_base_digits(base, u);
c = alloc(size * sizeof(character));
buf_save_init(buf, &save);
radix = base->size;
@@ -89,7 +89,7 @@ sw buf_inspect_u16_base (s_pretty *pretty, s_buf *buf,
return r;
}
-sw buf_inspect_u16_base_digits (s_pretty *pretty, const s_str *base,
+sw buf_inspect_u16_base_digits (const s_str *base,
const u16 *u)
{
uw radix;
diff --git a/libkc3/buf_inspect_u16_binary.c b/libkc3/buf_inspect_u16_binary.c
index 7d742f9..36c9fff 100644
--- a/libkc3/buf_inspect_u16_binary.c
+++ b/libkc3/buf_inspect_u16_binary.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u16_binary (s_pretty *pretty, s_buf *buf, const u16 *u)
+sw buf_inspect_u16_binary (s_buf *buf, const u16 *u)
{
- return buf_inspect_u16_base(pretty, buf,
+ return buf_inspect_u16_base(buf,
&g_kc3_base_binary,
u);
}
diff --git a/libkc3/buf_inspect_u16_binary.h b/libkc3/buf_inspect_u16_binary.h
index 6b68553..df999f2 100644
--- a/libkc3/buf_inspect_u16_binary.h
+++ b/libkc3/buf_inspect_u16_binary.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u16_binary (s_buf *buf, const u16 *u);
-sw buf_inspect_u16_binary_size (const u16 *u);
+sw buf_inspect_u16_binary_size (s_pretty *pretty, const u16 *u);
#endif /* LIBKC3_BUF_INSPECT_U16_binary_H */
diff --git a/libkc3/buf_inspect_u16_decimal.c b/libkc3/buf_inspect_u16_decimal.c
index 46e0030..c545e9a 100644
--- a/libkc3/buf_inspect_u16_decimal.c
+++ b/libkc3/buf_inspect_u16_decimal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u16_decimal (s_pretty *pretty, s_buf *buf, const u16 *u)
+sw buf_inspect_u16_decimal (s_buf *buf, const u16 *u)
{
- return buf_inspect_u16_base(pretty, buf,
+ return buf_inspect_u16_base(buf,
&g_kc3_base_decimal,
u);
}
diff --git a/libkc3/buf_inspect_u16_hexadecimal.c b/libkc3/buf_inspect_u16_hexadecimal.c
index dd496d1..2618bc1 100644
--- a/libkc3/buf_inspect_u16_hexadecimal.c
+++ b/libkc3/buf_inspect_u16_hexadecimal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u16_hexadecimal (s_pretty *pretty, s_buf *buf, const u16 *u)
+sw buf_inspect_u16_hexadecimal (s_buf *buf, const u16 *u)
{
- return buf_inspect_u16_base(pretty, buf,
+ return buf_inspect_u16_base(buf,
&g_kc3_base_hexadecimal,
u);
}
diff --git a/libkc3/buf_inspect_u16_hexadecimal.h b/libkc3/buf_inspect_u16_hexadecimal.h
index bcfb45e..1e892ee 100644
--- a/libkc3/buf_inspect_u16_hexadecimal.h
+++ b/libkc3/buf_inspect_u16_hexadecimal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u16_hexadecimal (s_buf *buf, const u16 *u);
-sw buf_inspect_u16_hexadecimal_size (const u16 *u);
+sw buf_inspect_u16_hexadecimal_size (s_pretty *pretty, const u16 *u);
#endif /* LIBKC3_BUF_INSPECT_U16_hexadecimal_H */
diff --git a/libkc3/buf_inspect_u16_octal.c b/libkc3/buf_inspect_u16_octal.c
index 1e16660..262eb81 100644
--- a/libkc3/buf_inspect_u16_octal.c
+++ b/libkc3/buf_inspect_u16_octal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u16_octal (s_pretty *pretty, s_buf *buf, const u16 *u)
+sw buf_inspect_u16_octal (s_buf *buf, const u16 *u)
{
- return buf_inspect_u16_base(pretty, buf,
+ return buf_inspect_u16_base(buf,
&g_kc3_base_octal,
u);
}
diff --git a/libkc3/buf_inspect_u16_octal.h b/libkc3/buf_inspect_u16_octal.h
index 90437cb..b2e6723 100644
--- a/libkc3/buf_inspect_u16_octal.h
+++ b/libkc3/buf_inspect_u16_octal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u16_octal (s_buf *buf, const u16 *u);
-sw buf_inspect_u16_octal_size (const u16 *u);
+sw buf_inspect_u16_octal_size (s_pretty *pretty, const u16 *u);
#endif /* LIBKC3_BUF_INSPECT_U16_octal_H */
diff --git a/libkc3/buf_inspect_u32.c b/libkc3/buf_inspect_u32.c
index 84b632d..048d4a2 100644
--- a/libkc3/buf_inspect_u32.c
+++ b/libkc3/buf_inspect_u32.c
@@ -21,26 +21,26 @@
#include "str.h"
#include "sym.h"
-sw buf_inspect_u32 (s_pretty *pretty, s_buf *buf, const u32 *u)
+sw buf_inspect_u32 (s_buf *buf, const u32 *u)
{
sw r;
sw result = 0;
if (g_buf_inspect_type != &g_sym_U32 &&
cast_needed_u32(*u)) {
- if ((r = buf_inspect_paren_sym(pretty, buf, &g_sym_U32)) < 0)
+ if ((r = buf_inspect_paren_sym(buf, &g_sym_U32)) < 0)
return r;
result += r;
if ((r = buf_write_1(buf, " ")) < 0)
return r;
result += r;
}
- if ((r = buf_inspect_u32_base(pretty, buf, &g_kc3_base_decimal, u)) < 0)
+ if ((r = buf_inspect_u32_base(buf, &g_kc3_base_decimal, u)) < 0)
return r;
result += r;
return result;
}
-sw buf_inspect_u32_base (s_pretty *pretty, s_buf *buf,
+sw buf_inspect_u32_base (s_buf *buf,
const s_str *base,
const u32 *u)
{
@@ -60,7 +60,7 @@ sw buf_inspect_u32_base (s_pretty *pretty, s_buf *buf,
return -1;
return buf_write_character_utf8(buf, zero);
}
- size = buf_inspect_u32_base_digits(pretty, base, u);
+ size = buf_inspect_u32_base_digits(base, u);
c = alloc(size * sizeof(character));
buf_save_init(buf, &save);
radix = base->size;
@@ -89,7 +89,7 @@ sw buf_inspect_u32_base (s_pretty *pretty, s_buf *buf,
return r;
}
-sw buf_inspect_u32_base_digits (s_pretty *pretty, const s_str *base,
+sw buf_inspect_u32_base_digits (const s_str *base,
const u32 *u)
{
uw radix;
diff --git a/libkc3/buf_inspect_u32_binary.c b/libkc3/buf_inspect_u32_binary.c
index 7449fb9..cee6107 100644
--- a/libkc3/buf_inspect_u32_binary.c
+++ b/libkc3/buf_inspect_u32_binary.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u32_binary (s_pretty *pretty, s_buf *buf, const u32 *u)
+sw buf_inspect_u32_binary (s_buf *buf, const u32 *u)
{
- return buf_inspect_u32_base(pretty, buf,
+ return buf_inspect_u32_base(buf,
&g_kc3_base_binary,
u);
}
diff --git a/libkc3/buf_inspect_u32_binary.h b/libkc3/buf_inspect_u32_binary.h
index d112693..90d82a7 100644
--- a/libkc3/buf_inspect_u32_binary.h
+++ b/libkc3/buf_inspect_u32_binary.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u32_binary (s_buf *buf, const u32 *u);
-sw buf_inspect_u32_binary_size (const u32 *u);
+sw buf_inspect_u32_binary_size (s_pretty *pretty, const u32 *u);
#endif /* LIBKC3_BUF_INSPECT_U32_binary_H */
diff --git a/libkc3/buf_inspect_u32_decimal.c b/libkc3/buf_inspect_u32_decimal.c
index 91efb35..f97643c 100644
--- a/libkc3/buf_inspect_u32_decimal.c
+++ b/libkc3/buf_inspect_u32_decimal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u32_decimal (s_pretty *pretty, s_buf *buf, const u32 *u)
+sw buf_inspect_u32_decimal (s_buf *buf, const u32 *u)
{
- return buf_inspect_u32_base(pretty, buf,
+ return buf_inspect_u32_base(buf,
&g_kc3_base_decimal,
u);
}
diff --git a/libkc3/buf_inspect_u32_hexadecimal.c b/libkc3/buf_inspect_u32_hexadecimal.c
index 5f2b768..3b72dae 100644
--- a/libkc3/buf_inspect_u32_hexadecimal.c
+++ b/libkc3/buf_inspect_u32_hexadecimal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u32_hexadecimal (s_pretty *pretty, s_buf *buf, const u32 *u)
+sw buf_inspect_u32_hexadecimal (s_buf *buf, const u32 *u)
{
- return buf_inspect_u32_base(pretty, buf,
+ return buf_inspect_u32_base(buf,
&g_kc3_base_hexadecimal,
u);
}
diff --git a/libkc3/buf_inspect_u32_hexadecimal.h b/libkc3/buf_inspect_u32_hexadecimal.h
index fa58305..1f15a7d 100644
--- a/libkc3/buf_inspect_u32_hexadecimal.h
+++ b/libkc3/buf_inspect_u32_hexadecimal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u32_hexadecimal (s_buf *buf, const u32 *u);
-sw buf_inspect_u32_hexadecimal_size (const u32 *u);
+sw buf_inspect_u32_hexadecimal_size (s_pretty *pretty, const u32 *u);
#endif /* LIBKC3_BUF_INSPECT_U32_hexadecimal_H */
diff --git a/libkc3/buf_inspect_u32_octal.c b/libkc3/buf_inspect_u32_octal.c
index ff22ef2..41b03c9 100644
--- a/libkc3/buf_inspect_u32_octal.c
+++ b/libkc3/buf_inspect_u32_octal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u32_octal (s_pretty *pretty, s_buf *buf, const u32 *u)
+sw buf_inspect_u32_octal (s_buf *buf, const u32 *u)
{
- return buf_inspect_u32_base(pretty, buf,
+ return buf_inspect_u32_base(buf,
&g_kc3_base_octal,
u);
}
diff --git a/libkc3/buf_inspect_u32_octal.h b/libkc3/buf_inspect_u32_octal.h
index 3e18298..6cfbea5 100644
--- a/libkc3/buf_inspect_u32_octal.h
+++ b/libkc3/buf_inspect_u32_octal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u32_octal (s_buf *buf, const u32 *u);
-sw buf_inspect_u32_octal_size (const u32 *u);
+sw buf_inspect_u32_octal_size (s_pretty *pretty, const u32 *u);
#endif /* LIBKC3_BUF_INSPECT_U32_octal_H */
diff --git a/libkc3/buf_inspect_u64.c b/libkc3/buf_inspect_u64.c
index 1e060c4..b4f1c41 100644
--- a/libkc3/buf_inspect_u64.c
+++ b/libkc3/buf_inspect_u64.c
@@ -21,26 +21,26 @@
#include "str.h"
#include "sym.h"
-sw buf_inspect_u64 (s_pretty *pretty, s_buf *buf, const u64 *u)
+sw buf_inspect_u64 (s_buf *buf, const u64 *u)
{
sw r;
sw result = 0;
if (g_buf_inspect_type != &g_sym_U64 &&
cast_needed_u64(*u)) {
- if ((r = buf_inspect_paren_sym(pretty, buf, &g_sym_U64)) < 0)
+ if ((r = buf_inspect_paren_sym(buf, &g_sym_U64)) < 0)
return r;
result += r;
if ((r = buf_write_1(buf, " ")) < 0)
return r;
result += r;
}
- if ((r = buf_inspect_u64_base(pretty, buf, &g_kc3_base_decimal, u)) < 0)
+ if ((r = buf_inspect_u64_base(buf, &g_kc3_base_decimal, u)) < 0)
return r;
result += r;
return result;
}
-sw buf_inspect_u64_base (s_pretty *pretty, s_buf *buf,
+sw buf_inspect_u64_base (s_buf *buf,
const s_str *base,
const u64 *u)
{
@@ -60,7 +60,7 @@ sw buf_inspect_u64_base (s_pretty *pretty, s_buf *buf,
return -1;
return buf_write_character_utf8(buf, zero);
}
- size = buf_inspect_u64_base_digits(pretty, base, u);
+ size = buf_inspect_u64_base_digits(base, u);
c = alloc(size * sizeof(character));
buf_save_init(buf, &save);
radix = base->size;
@@ -89,7 +89,7 @@ sw buf_inspect_u64_base (s_pretty *pretty, s_buf *buf,
return r;
}
-sw buf_inspect_u64_base_digits (s_pretty *pretty, const s_str *base,
+sw buf_inspect_u64_base_digits (const s_str *base,
const u64 *u)
{
uw radix;
diff --git a/libkc3/buf_inspect_u64_binary.c b/libkc3/buf_inspect_u64_binary.c
index edc0363..c630bad 100644
--- a/libkc3/buf_inspect_u64_binary.c
+++ b/libkc3/buf_inspect_u64_binary.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u64_binary (s_pretty *pretty, s_buf *buf, const u64 *u)
+sw buf_inspect_u64_binary (s_buf *buf, const u64 *u)
{
- return buf_inspect_u64_base(pretty, buf,
+ return buf_inspect_u64_base(buf,
&g_kc3_base_binary,
u);
}
diff --git a/libkc3/buf_inspect_u64_binary.h b/libkc3/buf_inspect_u64_binary.h
index 53e9a8b..e233264 100644
--- a/libkc3/buf_inspect_u64_binary.h
+++ b/libkc3/buf_inspect_u64_binary.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u64_binary (s_buf *buf, const u64 *u);
-sw buf_inspect_u64_binary_size (const u64 *u);
+sw buf_inspect_u64_binary_size (s_pretty *pretty, const u64 *u);
#endif /* LIBKC3_BUF_INSPECT_U64_binary_H */
diff --git a/libkc3/buf_inspect_u64_decimal.c b/libkc3/buf_inspect_u64_decimal.c
index c525598..08c962a 100644
--- a/libkc3/buf_inspect_u64_decimal.c
+++ b/libkc3/buf_inspect_u64_decimal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u64_decimal (s_pretty *pretty, s_buf *buf, const u64 *u)
+sw buf_inspect_u64_decimal (s_buf *buf, const u64 *u)
{
- return buf_inspect_u64_base(pretty, buf,
+ return buf_inspect_u64_base(buf,
&g_kc3_base_decimal,
u);
}
diff --git a/libkc3/buf_inspect_u64_hexadecimal.c b/libkc3/buf_inspect_u64_hexadecimal.c
index 8c22a73..e9f1dbb 100644
--- a/libkc3/buf_inspect_u64_hexadecimal.c
+++ b/libkc3/buf_inspect_u64_hexadecimal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u64_hexadecimal (s_pretty *pretty, s_buf *buf, const u64 *u)
+sw buf_inspect_u64_hexadecimal (s_buf *buf, const u64 *u)
{
- return buf_inspect_u64_base(pretty, buf,
+ return buf_inspect_u64_base(buf,
&g_kc3_base_hexadecimal,
u);
}
diff --git a/libkc3/buf_inspect_u64_hexadecimal.h b/libkc3/buf_inspect_u64_hexadecimal.h
index 326c9cf..9b7697c 100644
--- a/libkc3/buf_inspect_u64_hexadecimal.h
+++ b/libkc3/buf_inspect_u64_hexadecimal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u64_hexadecimal (s_buf *buf, const u64 *u);
-sw buf_inspect_u64_hexadecimal_size (const u64 *u);
+sw buf_inspect_u64_hexadecimal_size (s_pretty *pretty, const u64 *u);
#endif /* LIBKC3_BUF_INSPECT_U64_hexadecimal_H */
diff --git a/libkc3/buf_inspect_u64_octal.c b/libkc3/buf_inspect_u64_octal.c
index 56495bf..436be49 100644
--- a/libkc3/buf_inspect_u64_octal.c
+++ b/libkc3/buf_inspect_u64_octal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u64_octal (s_pretty *pretty, s_buf *buf, const u64 *u)
+sw buf_inspect_u64_octal (s_buf *buf, const u64 *u)
{
- return buf_inspect_u64_base(pretty, buf,
+ return buf_inspect_u64_base(buf,
&g_kc3_base_octal,
u);
}
diff --git a/libkc3/buf_inspect_u64_octal.h b/libkc3/buf_inspect_u64_octal.h
index b88fb92..763e282 100644
--- a/libkc3/buf_inspect_u64_octal.h
+++ b/libkc3/buf_inspect_u64_octal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u64_octal (s_buf *buf, const u64 *u);
-sw buf_inspect_u64_octal_size (const u64 *u);
+sw buf_inspect_u64_octal_size (s_pretty *pretty, const u64 *u);
#endif /* LIBKC3_BUF_INSPECT_U64_octal_H */
diff --git a/libkc3/buf_inspect_u8.c b/libkc3/buf_inspect_u8.c
index 79c69b2..3ff52fd 100644
--- a/libkc3/buf_inspect_u8.c
+++ b/libkc3/buf_inspect_u8.c
@@ -21,26 +21,26 @@
#include "str.h"
#include "sym.h"
-sw buf_inspect_u8 (s_pretty *pretty, s_buf *buf, const u8 *u)
+sw buf_inspect_u8 (s_buf *buf, const u8 *u)
{
sw r;
sw result = 0;
if (g_buf_inspect_type != &g_sym_U8 &&
cast_needed_u8(*u)) {
- if ((r = buf_inspect_paren_sym(pretty, buf, &g_sym_U8)) < 0)
+ if ((r = buf_inspect_paren_sym(buf, &g_sym_U8)) < 0)
return r;
result += r;
if ((r = buf_write_1(buf, " ")) < 0)
return r;
result += r;
}
- if ((r = buf_inspect_u8_base(pretty, buf, &g_kc3_base_decimal, u)) < 0)
+ if ((r = buf_inspect_u8_base(buf, &g_kc3_base_decimal, u)) < 0)
return r;
result += r;
return result;
}
-sw buf_inspect_u8_base (s_pretty *pretty, s_buf *buf,
+sw buf_inspect_u8_base (s_buf *buf,
const s_str *base,
const u8 *u)
{
@@ -60,7 +60,7 @@ sw buf_inspect_u8_base (s_pretty *pretty, s_buf *buf,
return -1;
return buf_write_character_utf8(buf, zero);
}
- size = buf_inspect_u8_base_digits(pretty, base, u);
+ size = buf_inspect_u8_base_digits(base, u);
c = alloc(size * sizeof(character));
buf_save_init(buf, &save);
radix = base->size;
@@ -89,7 +89,7 @@ sw buf_inspect_u8_base (s_pretty *pretty, s_buf *buf,
return r;
}
-sw buf_inspect_u8_base_digits (s_pretty *pretty, const s_str *base,
+sw buf_inspect_u8_base_digits (const s_str *base,
const u8 *u)
{
uw radix;
diff --git a/libkc3/buf_inspect_u8_binary.c b/libkc3/buf_inspect_u8_binary.c
index dbb2e25..e57785d 100644
--- a/libkc3/buf_inspect_u8_binary.c
+++ b/libkc3/buf_inspect_u8_binary.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u8_binary (s_pretty *pretty, s_buf *buf, const u8 *u)
+sw buf_inspect_u8_binary (s_buf *buf, const u8 *u)
{
- return buf_inspect_u8_base(pretty, buf,
+ return buf_inspect_u8_base(buf,
&g_kc3_base_binary,
u);
}
diff --git a/libkc3/buf_inspect_u8_binary.h b/libkc3/buf_inspect_u8_binary.h
index aa7c5af..22b8635 100644
--- a/libkc3/buf_inspect_u8_binary.h
+++ b/libkc3/buf_inspect_u8_binary.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u8_binary (s_buf *buf, const u8 *u);
-sw buf_inspect_u8_binary_size (const u8 *u);
+sw buf_inspect_u8_binary_size (s_pretty *pretty, const u8 *u);
#endif /* LIBKC3_BUF_INSPECT_U8_binary_H */
diff --git a/libkc3/buf_inspect_u8_decimal.c b/libkc3/buf_inspect_u8_decimal.c
index c7fe7f6..7ff121b 100644
--- a/libkc3/buf_inspect_u8_decimal.c
+++ b/libkc3/buf_inspect_u8_decimal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u8_decimal (s_pretty *pretty, s_buf *buf, const u8 *u)
+sw buf_inspect_u8_decimal (s_buf *buf, const u8 *u)
{
- return buf_inspect_u8_base(pretty, buf,
+ return buf_inspect_u8_base(buf,
&g_kc3_base_decimal,
u);
}
diff --git a/libkc3/buf_inspect_u8_hexadecimal.c b/libkc3/buf_inspect_u8_hexadecimal.c
index 34dc3f9..5fc4edd 100644
--- a/libkc3/buf_inspect_u8_hexadecimal.c
+++ b/libkc3/buf_inspect_u8_hexadecimal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u8_hexadecimal (s_pretty *pretty, s_buf *buf, const u8 *u)
+sw buf_inspect_u8_hexadecimal (s_buf *buf, const u8 *u)
{
- return buf_inspect_u8_base(pretty, buf,
+ return buf_inspect_u8_base(buf,
&g_kc3_base_hexadecimal,
u);
}
diff --git a/libkc3/buf_inspect_u8_hexadecimal.h b/libkc3/buf_inspect_u8_hexadecimal.h
index f2d9232..f38e4e7 100644
--- a/libkc3/buf_inspect_u8_hexadecimal.h
+++ b/libkc3/buf_inspect_u8_hexadecimal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u8_hexadecimal (s_buf *buf, const u8 *u);
-sw buf_inspect_u8_hexadecimal_size (const u8 *u);
+sw buf_inspect_u8_hexadecimal_size (s_pretty *pretty, const u8 *u);
#endif /* LIBKC3_BUF_INSPECT_U8_hexadecimal_H */
diff --git a/libkc3/buf_inspect_u8_octal.c b/libkc3/buf_inspect_u8_octal.c
index d44ee4f..ac0960d 100644
--- a/libkc3/buf_inspect_u8_octal.c
+++ b/libkc3/buf_inspect_u8_octal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u8_octal (s_pretty *pretty, s_buf *buf, const u8 *u)
+sw buf_inspect_u8_octal (s_buf *buf, const u8 *u)
{
- return buf_inspect_u8_base(pretty, buf,
+ return buf_inspect_u8_base(buf,
&g_kc3_base_octal,
u);
}
diff --git a/libkc3/buf_inspect_u8_octal.h b/libkc3/buf_inspect_u8_octal.h
index d403cf7..189d1c0 100644
--- a/libkc3/buf_inspect_u8_octal.h
+++ b/libkc3/buf_inspect_u8_octal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_u8_octal (s_buf *buf, const u8 *u);
-sw buf_inspect_u8_octal_size (const u8 *u);
+sw buf_inspect_u8_octal_size (s_pretty *pretty, const u8 *u);
#endif /* LIBKC3_BUF_INSPECT_U8_octal_H */
diff --git a/libkc3/buf_inspect_u_base.c.in b/libkc3/buf_inspect_u_base.c.in
index 363084e..9515480 100644
--- a/libkc3/buf_inspect_u_base.c.in
+++ b/libkc3/buf_inspect_u_base.c.in
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_u_bits$__BASE$ (s_pretty *pretty, s_buf *buf, const u_bits$ *u)
+sw buf_inspect_u_bits$__BASE$ (s_buf *buf, const u_bits$ *u)
{
- return buf_inspect_u_bits$_base(pretty, buf,
+ return buf_inspect_u_bits$_base(buf,
&g_kc3_base__BASE$,
u);
}
diff --git a/libkc3/buf_inspect_uw.c b/libkc3/buf_inspect_uw.c
index 4339bb2..7515f2b 100644
--- a/libkc3/buf_inspect_uw.c
+++ b/libkc3/buf_inspect_uw.c
@@ -21,26 +21,26 @@
#include "str.h"
#include "sym.h"
-sw buf_inspect_uw (s_pretty *pretty, s_buf *buf, const uw *u)
+sw buf_inspect_uw (s_buf *buf, const uw *u)
{
sw r;
sw result = 0;
if (g_buf_inspect_type != &g_sym_Uw &&
cast_needed_uw(*u)) {
- if ((r = buf_inspect_paren_sym(pretty, buf, &g_sym_Uw)) < 0)
+ if ((r = buf_inspect_paren_sym(buf, &g_sym_Uw)) < 0)
return r;
result += r;
if ((r = buf_write_1(buf, " ")) < 0)
return r;
result += r;
}
- if ((r = buf_inspect_uw_base(pretty, buf, &g_kc3_base_decimal, u)) < 0)
+ if ((r = buf_inspect_uw_base(buf, &g_kc3_base_decimal, u)) < 0)
return r;
result += r;
return result;
}
-sw buf_inspect_uw_base (s_pretty *pretty, s_buf *buf,
+sw buf_inspect_uw_base (s_buf *buf,
const s_str *base,
const uw *u)
{
@@ -60,7 +60,7 @@ sw buf_inspect_uw_base (s_pretty *pretty, s_buf *buf,
return -1;
return buf_write_character_utf8(buf, zero);
}
- size = buf_inspect_uw_base_digits(pretty, base, u);
+ size = buf_inspect_uw_base_digits(base, u);
c = alloc(size * sizeof(character));
buf_save_init(buf, &save);
radix = base->size;
@@ -89,7 +89,7 @@ sw buf_inspect_uw_base (s_pretty *pretty, s_buf *buf,
return r;
}
-sw buf_inspect_uw_base_digits (s_pretty *pretty, const s_str *base,
+sw buf_inspect_uw_base_digits (const s_str *base,
const uw *u)
{
uw radix;
diff --git a/libkc3/buf_inspect_uw_binary.c b/libkc3/buf_inspect_uw_binary.c
index 30c05cc..e31483e 100644
--- a/libkc3/buf_inspect_uw_binary.c
+++ b/libkc3/buf_inspect_uw_binary.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_uw_binary (s_pretty *pretty, s_buf *buf, const uw *u)
+sw buf_inspect_uw_binary (s_buf *buf, const uw *u)
{
- return buf_inspect_uw_base(pretty, buf,
+ return buf_inspect_uw_base(buf,
&g_kc3_base_binary,
u);
}
diff --git a/libkc3/buf_inspect_uw_binary.h b/libkc3/buf_inspect_uw_binary.h
index 1cda236..378f6da 100644
--- a/libkc3/buf_inspect_uw_binary.h
+++ b/libkc3/buf_inspect_uw_binary.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_uw_binary (s_buf *buf, const uw *u);
-sw buf_inspect_uw_binary_size (const uw *u);
+sw buf_inspect_uw_binary_size (s_pretty *pretty, const uw *u);
#endif /* LIBKC3_BUF_INSPECT_UW_binary_H */
diff --git a/libkc3/buf_inspect_uw_decimal.c b/libkc3/buf_inspect_uw_decimal.c
index 593e005..c540f30 100644
--- a/libkc3/buf_inspect_uw_decimal.c
+++ b/libkc3/buf_inspect_uw_decimal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_uw_decimal (s_pretty *pretty, s_buf *buf, const uw *u)
+sw buf_inspect_uw_decimal (s_buf *buf, const uw *u)
{
- return buf_inspect_uw_base(pretty, buf,
+ return buf_inspect_uw_base(buf,
&g_kc3_base_decimal,
u);
}
diff --git a/libkc3/buf_inspect_uw_hexadecimal.c b/libkc3/buf_inspect_uw_hexadecimal.c
index 23bbbe4..e0e3a5d 100644
--- a/libkc3/buf_inspect_uw_hexadecimal.c
+++ b/libkc3/buf_inspect_uw_hexadecimal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_uw_hexadecimal (s_pretty *pretty, s_buf *buf, const uw *u)
+sw buf_inspect_uw_hexadecimal (s_buf *buf, const uw *u)
{
- return buf_inspect_uw_base(pretty, buf,
+ return buf_inspect_uw_base(buf,
&g_kc3_base_hexadecimal,
u);
}
diff --git a/libkc3/buf_inspect_uw_hexadecimal.h b/libkc3/buf_inspect_uw_hexadecimal.h
index ad329a4..436e90c 100644
--- a/libkc3/buf_inspect_uw_hexadecimal.h
+++ b/libkc3/buf_inspect_uw_hexadecimal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_uw_hexadecimal (s_buf *buf, const uw *u);
-sw buf_inspect_uw_hexadecimal_size (const uw *u);
+sw buf_inspect_uw_hexadecimal_size (s_pretty *pretty, const uw *u);
#endif /* LIBKC3_BUF_INSPECT_UW_hexadecimal_H */
diff --git a/libkc3/buf_inspect_uw_octal.c b/libkc3/buf_inspect_uw_octal.c
index 488348c..1c8228c 100644
--- a/libkc3/buf_inspect_uw_octal.c
+++ b/libkc3/buf_inspect_uw_octal.c
@@ -14,9 +14,9 @@
#include "buf_inspect.h"
#include "kc3_main.h"
-sw buf_inspect_uw_octal (s_pretty *pretty, s_buf *buf, const uw *u)
+sw buf_inspect_uw_octal (s_buf *buf, const uw *u)
{
- return buf_inspect_uw_base(pretty, buf,
+ return buf_inspect_uw_base(buf,
&g_kc3_base_octal,
u);
}
diff --git a/libkc3/buf_inspect_uw_octal.h b/libkc3/buf_inspect_uw_octal.h
index eedf4fa..67ea602 100644
--- a/libkc3/buf_inspect_uw_octal.h
+++ b/libkc3/buf_inspect_uw_octal.h
@@ -17,6 +17,6 @@
#include "types.h"
sw buf_inspect_uw_octal (s_buf *buf, const uw *u);
-sw buf_inspect_uw_octal_size (const uw *u);
+sw buf_inspect_uw_octal_size (s_pretty *pretty, const uw *u);
#endif /* LIBKC3_BUF_INSPECT_UW_octal_H */
diff --git a/libkc3/call.c b/libkc3/call.c
index e4a14f1..b0e574f 100644
--- a/libkc3/call.c
+++ b/libkc3/call.c
@@ -155,18 +155,3 @@ s_call * call_init_op_unary (s_call *call)
*call = tmp;
return call;
}
-
-s_str * call_inspect (const s_call *call, s_str *dest)
-{
- sw size;
- s_buf tmp = {0};
- size = buf_inspect_call_size(call);
- if (size < 0) {
- assert(! "error");
- return NULL;
- }
- buf_init_alloc(&tmp, size);
- buf_inspect_call(&tmp, call);
- assert(tmp.wpos == tmp.size);
- return buf_to_str(&tmp, dest);
-}
diff --git a/libkc3/cow.c b/libkc3/cow.c
index ee7f0a5..d8b8272 100644
--- a/libkc3/cow.c
+++ b/libkc3/cow.c
@@ -158,26 +158,6 @@ s_cow * cow_init_tag_copy (s_cow *cow, const s_sym *type,
return cow;
}
-s_str * cow_inspect (const s_cow *cow, s_str *dest)
-{
- s_buf buf;
- sw size;
- assert(cow);
- assert(dest);
- if ((size = buf_inspect_cow_size(cow)) < 0) {
- err_puts("tag_inspect: size error");
- assert(! "tag_inspect: size error");
- return NULL;
- }
- buf_init_alloc(&buf, size);
- if (buf_inspect_cow(&buf, cow) != size) {
- err_puts("tag_inspect: inspect error");
- assert(! "tag_inspect: inspect error");
- return NULL;
- }
- return buf_to_str(&buf, dest);
-}
-
s_cow * cow_new (const s_sym *type)
{
s_cow *cow;
diff --git a/libkc3/data.c b/libkc3/data.c
index 8437ae6..5a24b0c 100644
--- a/libkc3/data.c
+++ b/libkc3/data.c
@@ -99,85 +99,86 @@ sw data_buf_inspect (const s_sym *type, s_buf *buf, const void *data)
return -1;
}
-sw data_buf_inspect_size (const s_sym *type, const void *data)
+sw data_buf_inspect_size (const s_sym *type, s_pretty *pretty,
+ const void *data)
{
s_struct s = {0};
const s_struct_type *st;
if (type == &g_sym_Array ||
sym_is_array_type(type))
- return buf_inspect_array_size(data);
+ return buf_inspect_array_size(pretty, data);
if (type == &g_sym_Bool)
- return buf_inspect_bool_size(data);
+ return buf_inspect_bool_size(pretty, data);
if (type == &g_sym_Call)
- return buf_inspect_call_size(data);
+ return buf_inspect_call_size(pretty, data);
if (type == &g_sym_Cfn)
- return buf_inspect_cfn_size(data);
+ return buf_inspect_cfn_size(pretty, data);
if (type == &g_sym_Character)
- return buf_inspect_character_size(data);
+ return buf_inspect_character_size(pretty, data);
if (type == &g_sym_F32)
- return buf_inspect_f32_size(data);
+ return buf_inspect_f32_size(pretty, data);
if (type == &g_sym_F64)
- return buf_inspect_f64_size(data);
+ return buf_inspect_f64_size(pretty, data);
if (type == &g_sym_Fact)
- return buf_inspect_fact_size(data);
+ return buf_inspect_fact_size(pretty, data);
if (type == &g_sym_Fn)
- return buf_inspect_fn_size(data);
+ return buf_inspect_fn_size(pretty, data);
if (type == &g_sym_Ident)
- return buf_inspect_ident_size(data);
+ return buf_inspect_ident_size(pretty, data);
if (type == &g_sym_Integer)
- return buf_inspect_integer_size(data);
+ return buf_inspect_integer_size(pretty, data);
if (type == &g_sym_List)
- return buf_inspect_list_size(data);
+ return buf_inspect_list_size(pretty, data);
if (type == &g_sym_Map)
- return buf_inspect_map_size(data);
+ return buf_inspect_map_size(pretty, data);
if (type == &g_sym_Ptag)
- return buf_inspect_ptag_size(data);
+ return buf_inspect_ptag_size(pretty, data);
if (type == &g_sym_Ptr)
- return buf_inspect_ptr_size(data);
+ return buf_inspect_ptr_size(pretty, data);
if (type == &g_sym_PtrFree)
- return buf_inspect_ptr_free_size(data);
+ return buf_inspect_ptr_free_size(pretty, data);
if (type == &g_sym_Quote)
- return buf_inspect_quote_size(data);
+ return buf_inspect_quote_size(pretty, data);
if (type == &g_sym_S8)
- return buf_inspect_s8_size(data);
+ return buf_inspect_s8_size(pretty, data);
if (type == &g_sym_S16)
- return buf_inspect_s16_size(data);
+ return buf_inspect_s16_size(pretty, data);
if (type == &g_sym_S32)
- return buf_inspect_s32_size(data);
+ return buf_inspect_s32_size(pretty, data);
if (type == &g_sym_S64)
- return buf_inspect_s64_size(data);
+ return buf_inspect_s64_size(pretty, data);
if (type == &g_sym_Str)
- return buf_inspect_str_size(data);
+ return buf_inspect_str_size(pretty, data);
if (type == &g_sym_Struct)
- return buf_inspect_struct_size(data);
+ return buf_inspect_struct_size(pretty, data);
if (type == &g_sym_StructType)
- return buf_inspect_struct_type_size(data);
+ return buf_inspect_struct_type_size(pretty, data);
if (type == &g_sym_Sw)
- return buf_inspect_sw_size(data);
+ return buf_inspect_sw_size(pretty, data);
if (type == &g_sym_Sym)
- return buf_inspect_sym_size(data);
+ return buf_inspect_sym_size(pretty, data);
if (type == &g_sym_Tuple)
- return buf_inspect_tuple_size(data);
+ return buf_inspect_tuple_size(pretty, data);
if (type == &g_sym_U8)
- return buf_inspect_u8_size(data);
+ return buf_inspect_u8_size(pretty, data);
if (type == &g_sym_U16)
- return buf_inspect_u16_size(data);
+ return buf_inspect_u16_size(pretty, data);
if (type == &g_sym_U32)
- return buf_inspect_u32_size(data);
+ return buf_inspect_u32_size(pretty, data);
if (type == &g_sym_U64)
- return buf_inspect_u64_size(data);
+ return buf_inspect_u64_size(pretty, data);
if (type == &g_sym_Uw)
- return buf_inspect_uw_size(data);
+ return buf_inspect_uw_size(pretty, data);
if (type == &g_sym_Var)
- return buf_inspect_var_size(data);
+ return buf_inspect_var_size(pretty, data);
if (type == &g_sym_Void)
- return buf_inspect_void_size(data);
+ return buf_inspect_void_size(pretty, data);
if (! struct_type_find(type, &st))
return -1;
if (st) {
s.type = st;
s.data = (void *) data;
- return buf_inspect_struct_size(&s);
+ return buf_inspect_struct_size(pretty, &s);
}
err_write_1("data_buf_inspect_size: unknown type: ");
err_inspect_sym(&type);
diff --git a/libkc3/data.h b/libkc3/data.h
index 8561ca6..b121a0a 100644
--- a/libkc3/data.h
+++ b/libkc3/data.h
@@ -22,7 +22,7 @@
#include "types.h"
sw data_buf_inspect (const s_sym *type, s_buf *buf, const void *v);
-sw data_buf_inspect_size (s_pretty *pretty, const s_sym *type,
+sw data_buf_inspect_size (const s_sym *type, s_pretty *pretty,
const void *v);
bool data_clean (const s_sym *type, void *v);
bool data_compare (const s_sym *type, const void *a, const void *b);
diff --git a/libkc3/fact.c b/libkc3/fact.c
index 8067fb3..dd6d9fc 100644
--- a/libkc3/fact.c
+++ b/libkc3/fact.c
@@ -73,24 +73,6 @@ s_fact * fact_init_copy (s_fact *fact, const s_fact *src)
return fact;
}
-s_str * fact_inspect (const s_fact *fact, s_str *dest)
-{
- s_buf buf;
- sw size;
- if ((size = buf_inspect_fact_size(fact)) < 0) {
- err_puts("fact_inspect: size error");
- assert(! "fact_inspect: size error");
- return NULL;
- }
- buf_init_alloc(&buf, size);
- if (buf_inspect_fact(&buf, fact) != size) {
- err_puts("fact_inspect: inspect error");
- assert(! "fact_inspect: inspect error");
- return NULL;
- }
- return buf_to_str(&buf, dest);
-}
-
void fact_r (const s_fact_w *fact, s_fact *dest)
{
s_fact tmp = {0};
diff --git a/libkc3/ident.c b/libkc3/ident.c
index c38aa46..7323d37 100644
--- a/libkc3/ident.c
+++ b/libkc3/ident.c
@@ -108,23 +108,6 @@ s_ident * ident_init_copy (s_ident *ident, const s_ident *src)
return ident;
}
-s_str * ident_inspect (const s_ident *ident, s_str *dest)
-{
- sw r;
- sw size;
- s_buf buf;
- size = buf_inspect_ident_size(ident);
- if (size < 0)
- return NULL;
- buf_init_alloc(&buf, size);
- r = buf_inspect_ident(&buf, ident);
- if (r != size) {
- buf_clean(&buf);
- return NULL;
- }
- return buf_to_str(&buf, dest);
-}
-
bool * ident_is_special_operator (const s_ident *ident, bool *dest)
{
return env_ident_is_special_operator(&g_kc3_env, ident, dest);
diff --git a/libkc3/inspect.c b/libkc3/inspect.c
index 6561eb0..c10ccb2 100644
--- a/libkc3/inspect.c
+++ b/libkc3/inspect.c
@@ -27,7 +27,7 @@ s_str * inspect_array (const s_array *array, s_str *dest)
return NULL;
}
buf_init_alloc(&tmp, size);
- buf_inspect_array(&pretty, &tmp, array);
+ buf_inspect_array(&tmp, array);
if (tmp.wpos != tmp.size) {
err_puts("inspect_array: tmp.wpos != tmp.size");
assert(! "inspect_array: tmp.wpos != tmp.size");
@@ -51,7 +51,7 @@ s_str * inspect_block (const s_block *x, s_str *dest)
}
if (! buf_init_alloc(&buf, size))
return NULL;
- if ((r = buf_inspect_block(&pretty, &buf, x)) < 0)
+ if ((r = buf_inspect_block(&buf, x)) < 0)
goto error;
assert(r == size);
if (r != size)
@@ -64,8 +64,9 @@ s_str * inspect_block (const s_block *x, s_str *dest)
s_str * inspect_bool (bool *b, s_str *dest)
{
+ s_buf buf;
+ s_pretty pretty = {0};
sw size;
- s_buf tmp;
size = buf_inspect_bool_size(&pretty, b);
if (size < 0) {
err_write_1("inspect_bool: error: ");
@@ -73,35 +74,165 @@ s_str * inspect_bool (bool *b, s_str *dest)
assert(! "inspect_bool: error");
return NULL;
}
- buf_init_alloc(&tmp, size);
- buf_inspect_bool(&pretty, &tmp, b);
- assert(tmp.wpos == tmp.size);
- if (tmp.wpos != tmp.size) {
- buf_clean(&tmp);
+ buf_init_alloc(&buf, size);
+ buf_inspect_bool(&buf, b);
+ assert(buf.wpos == buf.size);
+ if (buf.wpos != buf.size) {
+ buf_clean(&buf);
err_write_1("inspect_bool: buf_inspect_bool");
return NULL;
}
- return buf_to_str(&tmp, dest);
+ return buf_to_str(&buf, dest);
+}
+
+s_str * inspect_call (const s_call *call, s_str *dest)
+{
+ s_buf buf;
+ s_pretty pretty = {0};
+ sw size;
+ size = buf_inspect_call_size(&pretty, call);
+ if (size < 0) {
+ err_puts("inspect_call: buf_inspect_call_size");
+ assert(! "inspect_call: buf_inspect_call_size");
+ return NULL;
+ }
+ buf_init_alloc(&buf, size);
+ buf_inspect_call(&buf, call);
+ assert(buf.wpos == buf.size);
+ if (buf.wpos != buf.size) {
+ buf_clean(&buf);
+ err_puts("inspect_call: buf_inspect_call");
+ assert(! "inspect_call: buf_inspect_call");
+ return NULL;
+ }
+ return buf_to_str(&buf, dest);
+}
+
+s_str * inspect_cow (const s_cow *cow, s_str *dest)
+{
+ s_buf buf;
+ s_pretty pretty = {0};
+ sw size;
+ assert(cow);
+ assert(dest);
+ if ((size = buf_inspect_cow_size(&pretty, cow)) < 0) {
+ err_puts("inspect_cow: size error");
+ assert(! "inspect_cow: size error");
+ return NULL;
+ }
+ buf_init_alloc(&buf, size);
+ if (buf_inspect_cow(&buf, cow) != size) {
+ err_puts("inspect_cow: inspect error");
+ assert(! "inspect_cow: inspect error");
+ return NULL;
+ }
+ return buf_to_str(&buf, dest);
+}
+
+s_str * inspect_fact (const s_fact *fact, s_str *dest)
+{
+ s_buf buf;
+ s_pretty pretty = {0};
+ sw size;
+ if ((size = buf_inspect_fact_size(&pretty, fact)) < 0) {
+ err_puts("inspect_fact: size error");
+ assert(! "inspect_fact: size error");
+ return NULL;
+ }
+ buf_init_alloc(&buf, size);
+ if (buf_inspect_fact(&buf, fact) != size) {
+ err_puts("inspect_fact: inspect error");
+ assert(! "inspect_fact: inspect error");
+ return NULL;
+ }
+ return buf_to_str(&buf, dest);
+}
+
+s_str * inspect_ident (const s_ident *ident, s_str *dest)
+{
+ s_buf buf;
+ s_pretty pretty = {0};
+ sw r;
+ sw size;
+ size = buf_inspect_ident_size(&pretty, ident);
+ if (size < 0)
+ return NULL;
+ buf_init_alloc(&buf, size);
+ r = buf_inspect_ident(&buf, ident);
+ if (r != size) {
+ buf_clean(&buf);
+ return NULL;
+ }
+ return buf_to_str(&buf, dest);
+}
+
+s_str * inspect_list (const s_list *x, s_str *dest)
+{
+ s_buf buf;
+ s_pretty pretty = {0};
+ sw r;
+ sw size;
+ size = buf_inspect_list_size(&pretty, &x);
+ buf_init_alloc(&buf, size);
+ if ((r = buf_inspect_list(&buf, &x)) < 0)
+ goto error;
+ assert(r == size);
+ if (r != size)
+ goto error;
+ return buf_to_str(&buf, dest);
+ error:
+ buf_clean(&buf);
+ return NULL;
+}
+
+s_str * ratio_inspect (const s_ratio *src, s_str *dest)
+{
+ s_buf buf;
+ s_pretty pretty = {0};
+ sw r;
+ sw size;
+ assert(src);
+ assert(dest);
+ assert(integer_is_positive(&src->denominator));
+ size = buf_inspect_ratio_size(&pretty, src);
+ if (size <= 0)
+ return NULL;
+ if (! buf_init_alloc(&buf, size))
+ return NULL;
+ r = buf_inspect_ratio(&buf, src);
+ if (r != size) {
+ err_write_1("ratio_inspect: ");
+ err_inspect_sw(&r);
+ err_write_1(" != ");
+ err_inspect_sw(&size);
+ err_write_1("\n");
+ assert(! "ratio_inspect: invalid ratio");
+ return NULL;
+ }
+ assert(buf.wpos == (uw) size);
+ return buf_to_str(&buf, dest);
}
s_str * inspect_sym (const s_sym *sym, s_str *dest)
{
+ s_buf buf;
+ s_pretty pretty = {0};
sw size;
- s_buf tmp = {0};
size = buf_inspect_sym_size(&pretty, &sym);
if (size < 0) {
assert(! "error");
return NULL;
}
- buf_init_alloc(&tmp, size);
- buf_inspect_sym(&pretty, &tmp, &sym);
- assert(tmp.wpos == tmp.size);
- return buf_to_str(&tmp, dest);
+ buf_init_alloc(&buf, size);
+ buf_inspect_sym(&buf, &sym);
+ assert(buf.wpos == buf.size);
+ return buf_to_str(&buf, dest);
}
s_str * inspect_tag (const s_tag *tag, s_str *dest)
{
s_buf buf;
+ s_pretty pretty = {0};
sw size;
assert(tag);
assert(dest);
@@ -111,7 +242,7 @@ s_str * inspect_tag (const s_tag *tag, s_str *dest)
return NULL;
}
buf_init_alloc(&buf, size);
- if (buf_inspect_tag(&pretty, &buf, tag) != size) {
+ if (buf_inspect_tag(&buf, tag) != size) {
err_puts("tag_inspect: inspect error");
assert(! "tag_inspect: inspect error");
return NULL;
diff --git a/libkc3/list.c b/libkc3/list.c
index fe8b0ac..79a581d 100644
--- a/libkc3/list.c
+++ b/libkc3/list.c
@@ -134,24 +134,6 @@ s_list * list_init_tag_copy (s_list *list, const s_tag *tag, s_list *next)
return list;
}
-s_str * list_inspect (const s_list *x, s_str *dest)
-{
- s_buf buf;
- sw r;
- sw size;
- size = buf_inspect_list_size(&x);
- buf_init_alloc(&buf, size);
- if ((r = buf_inspect_list(&buf, &x)) < 0)
- goto error;
- assert(r == size);
- if (r != size)
- goto error;
- return buf_to_str(&buf, dest);
- error:
- buf_clean(&buf);
- return NULL;
-}
-
bool list_is_alist (const s_list * const *list)
{
const s_list *l;
diff --git a/libkc3/ratio.c b/libkc3/ratio.c
index 259a38f..3df9032 100644
--- a/libkc3/ratio.c
+++ b/libkc3/ratio.c
@@ -345,33 +345,6 @@ s_ratio * ratio_init_zero (s_ratio *r)
return r;
}
-s_str * ratio_inspect (const s_ratio *src, s_str *dest)
-{
- s_buf buf;
- sw r;
- sw size;
- assert(src);
- assert(dest);
- assert(integer_is_positive(&src->denominator));
- size = buf_inspect_ratio_size(src);
- if (size <= 0)
- return NULL;
- if (! buf_init_alloc(&buf, size))
- return NULL;
- r = buf_inspect_ratio(&buf, src);
- if (r != size) {
- err_write_1("ratio_inspect: ");
- err_inspect_sw(&r);
- err_write_1(" != ");
- err_inspect_sw(&size);
- err_write_1("\n");
- assert(! "ratio_inspect: invalid ratio");
- return NULL;
- }
- assert(buf.wpos == (uw) size);
- return buf_to_str(&buf, dest);
-}
-
bool ratio_is_negative (const s_ratio *r)
{
assert(r);