diff --git a/libc3/buf_inspect.c b/libc3/buf_inspect.c
index c6b7094..0155e48 100644
--- a/libc3/buf_inspect.c
+++ b/libc3/buf_inspect.c
@@ -229,24 +229,21 @@ sw buf_inspect_block (s_buf *buf, const s_block *block)
u64 i = 0;
sw r;
sw result = 0;
- if ((r = buf_write_1(buf, "do\n ")) < 0)
+ if (! block->count)
+ return buf_write_1(buf, "do end");
+ if ((r = buf_write_1(buf, "do")) < 0)
return r;
result += r;
- if (block->count) {
- while (i < block->count - 1) {
- if ((r = buf_inspect_tag(buf, block->tag + i)) < 0)
- return r;
- result += r;
- if ((r = buf_write_1(buf, "\n ")) < 0)
- return r;
- result += r;
- i++;
- }
+ while (i < block->count) {
+ if ((r = buf_write_1(buf, "\n ")) < 0)
+ return r;
+ result += r;
if ((r = buf_inspect_tag(buf, block->tag + i)) < 0)
return r;
result += r;
+ i++;
}
- if ((r = buf_write_1(buf, "end")) < 0)
+ if ((r = buf_write_1(buf, "\nend")) < 0)
return r;
result += r;
return result;
@@ -259,18 +256,13 @@ sw buf_inspect_block_size (const s_block *block)
sw result;
if (! block->count)
result = strlen("do end");
- result = strlen("do\n ");
- if (block->count) {
- while (i < block->count - 1) {
- if ((r = buf_inspect_tag_size(block->tag + i)) < 0)
- return r;
- result += r;
- result += strlen("\n ");
- i++;
- }
+ result = strlen("do");
+ while (i < block->count) {
+ result += strlen("\n ");
if ((r = buf_inspect_tag_size(block->tag + i)) < 0)
return r;
result += r;
+ i++;
}
result += strlen("\nend");
return result;
diff --git a/libc3/buf_parse.c b/libc3/buf_parse.c
index 39d109e..3e2473f 100644
--- a/libc3/buf_parse.c
+++ b/libc3/buf_parse.c
@@ -401,7 +401,6 @@ sw buf_parse_array_dimensions_rec (s_buf *buf, s_array *dest,
sw buf_parse_block (s_buf *buf, s_block *block)
{
- character c;
s_list **i;
s_list *list = 0;
sw r;
@@ -443,19 +442,14 @@ sw buf_parse_block (s_buf *buf, s_block *block)
if ((r = buf_ignore_spaces(buf)) < 0)
goto restore;
result += r;
- if ((r = buf_read_1(buf, "end")) < 0)
+ if ((r = buf_read_sym(buf, &g_sym_end)) < 0)
goto restore;
- if (r > 0 && ((r = buf_peek_character_utf8(buf, &c)) <= 0 ||
- sym_character_is_reserved(c))) {
+ if (r > 0) {
sw i;
s_list *j;
sw k;
result += r;
i = list_length(list);
- if (i < 2) {
- r = 0;
- goto restore;
- }
block_init(&tmp, i);
j = list;
k = 0;
diff --git a/libc3/sym.c b/libc3/sym.c
index 1f04492..2ba94a8 100644
--- a/libc3/sym.c
+++ b/libc3/sym.c
@@ -59,9 +59,10 @@ const s_sym g_sym_Uw = {{{NULL}, 2, {"Uw"}}};
const s_sym g_sym_Uw_brackets = {{{NULL}, 4, {"Uw[]"}}};
const s_sym g_sym_Var = {{{NULL}, 3, {"Var"}}};
const s_sym g_sym_Void = {{{NULL}, 4, {"Void"}}};
+const s_sym g_sym_cast = {{{NULL}, 4, {"cast"}}};
const s_sym g_sym_defstruct = {{{NULL}, 9, {"defstruct"}}};
const s_sym g_sym_do = {{{NULL}, 2, {"do"}}};
-const s_sym g_sym_cast = {{{NULL}, 4, {"cast"}}};
+const s_sym g_sym_end = {{{NULL}, 3, {"end"}}};
const s_sym g_sym_load_time = {{{NULL}, 9, {"load_time"}}};
const s_sym g_sym_r = {{{NULL}, 1, {"r"}}};
const s_sym g_sym_rw = {{{NULL}, 2, {"rw"}}};
@@ -297,6 +298,7 @@ void sym_init_g_sym (void)
sym_intern(&g_sym_cast, NULL);
sym_intern(&g_sym_defstruct, NULL);
sym_intern(&g_sym_do, NULL);
+ sym_intern(&g_sym_end, NULL);
sym_intern(&g_sym_load_time, NULL);
sym_intern(&g_sym_r, NULL);
sym_intern(&g_sym_rw, NULL);
diff --git a/libc3/sym.h b/libc3/sym.h
index 80684d6..d86194e 100644
--- a/libc3/sym.h
+++ b/libc3/sym.h
@@ -74,6 +74,7 @@ extern const s_sym g_sym_Void;
extern const s_sym g_sym_cast;
extern const s_sym g_sym_defstruct;
extern const s_sym g_sym_do;
+extern const s_sym g_sym_end;
extern const s_sym g_sym_load_time;
extern const s_sym g_sym_r;
extern const s_sym g_sym_rw;