@@ -256,6 +256,7 @@ static inline str gap(const char* ref, const char* start, const char* end)
256256#define P_Abort(x) return x
257257#define P_Tag \
258258 node_alloc(&d->nodes, 1); \
259+ d->nodes.used_back++; \
259260 me = &d->nodes.nodes[d->nodes.size - d->nodes.used_back]; \
260261 me->outer = gap(d->body, p, p);
261262#define P_NameStart name_start = p
@@ -277,9 +278,7 @@ static inline str gap(const char* ref, const char* start, const char* end)
277278#define P_TagClose printf("TagClose %s\n", p)
278279#define P_TagOpenClose \
279280 me->nodes = start_end(0, 0); \
280− printf("TagOpenClose %s\n", p)
281−// d->nodes.nodes[d->nodes.used_front].outer = gap(d->body, tag_start, p); \
282−
281+ me->outer.length = gap(d->body, p, p).length;
283282
284283// Given the parsed string, return either NULL (success) or an error message (failure)
285284static const char* parser(const char* p, document* d)
@@ -343,13 +342,14 @@ document* hexml_document_parse(const char* s, int slen)
343342int main()
344343{
345344 setbuf(stdout, NULL);
346− const char* example = "<bob />"; // "<test foo='123 xyz' bar='t'><inner /> value</test>";
347− const document* d = hexml_document_parse(example, -1);
345+ const char* example = "<test foo = '123 xyz' bar = 't'><inner / > value< / test>";
346+ document* d = hexml_document_parse(example, -1);
348347 char buf[1000];
349348 int len = hexml_node_render(d, hexml_document_node(d), buf, sizeof(buf));
350349 buf[len] = 0;
351350 printf("Result = %s\n", buf);
352351 printf("Used nodes = %i, attributes = %i\n", d->nodes.used_front, d->attrs.used);
352+ hexml_document_free(d);
353353 return 0;
354354}
355355