commit e6fbd25ecf457f068d3586a17ca837b27daca2e9
parent a16b7b759d4b0ef34d40e73bb335f9b12576a294
Author: rpa <rpa@grass>
Date: Sat, 26 Aug 2023 20:30:21 +0000
src/tablist: fix encoder
Diffstat:
2 files changed, 24 insertions(+), 16 deletions(-)
diff --git a/src/tablist/example.tl b/src/tablist/example.tl
@@ -1,12 +1,16 @@
-0UnoUnoUno
-1Uno 1Duo 1Tres
-3Uno
- 3Duo
- 3Tres
- 3Quad
- 5Quint
-\uno
- \duo
- \tres
- \quad
- \quint
+tutest
+ a
+ 1
+ 2
+ 3
+ b 1
+ c 2
+ d 3
+uiid
+ name
+ \alpha
+ \beta
+ \gamma
+ type \test
+ tags \untagged
+ status \ch 0
diff --git a/src/tablist/tablist.c b/src/tablist/tablist.c
@@ -227,19 +227,23 @@ _encnext(TLencoder *w, char *c)
TLnode *n = ENCTOS(w);
TLnode *fc = nil;
if (n->children->len > 0) fc = *(TLnode **)slicegetp(n->children, 0);
+
if (n->children->len == 0) {
w->cs[w->sp]++;
return _encnl(w, c);
- } else if ((n->children->len == 1) && (fc->name != nil)) {
- if (w->sp == 0) w->sp++;
+
+ } else if ( (n->children->len > 1) || (n->value != nil) ) {
+ w->sp++;
w->ns[w->sp] = n->children;
w->cs[w->sp] = 0;
- return _encsp(w, c);
+ return _encnl(w, c);
+
} else {
w->sp++;
w->ns[w->sp] = n->children;
w->cs[w->sp] = 0;
- return _encnl(w, c);
+ return _encsp(w, c);
+
}
}