@@ -3,11 +3,8 @@
33#include <stdlib.h>
44#include <string.h>
55#include <assert.h>
6−#include <ctype.h>
76#include <stdio.h>
87
9−typedef int bool;
10−
118/////////////////////////////////////////////////////////////////////
129// TYPES
1310
@@ -53,20 +50,13 @@ typedef struct
5350struct document
5451{
5552 const char* body; // pointer to initial argument, not owned by us
56−
57− // things only used while parsing
58− const char* cursor; // pointer to where we are in body
59− const char* end; // pointer to one past the last char
60− // if cursor is > end we have gone past the end
53+ int body_len; // length of the body
6154
6255 char* error_message;
6356 node_buffer nodes;
6457 attr_buffer attrs;
6558};
6659
67−static inline int doc_length(const document* d) { return (int) (d->end - d->body); }
68−static inline int doc_position(const document* d) { return (int) (d->cursor - d->body); }
69−
7060
7161/////////////////////////////////////////////////////////////////////
7262// RENDER CODE
@@ -100,7 +90,7 @@ static inline void bound_str(str s, int mn, int mx)
10090
10191static void render_str(render* r, str s)
10292{
103− bound_str(s, 0, doc_length(r->d));
93+ bound_str(s, 0, r->d->body_len);
10494 for (int i = 0; i < s.length; i++)
10595 render_char(r, r->d->body[s.start + i]);
10696}
@@ -109,7 +99,7 @@ static void render_tag(render* r, const node* n);
10999
110100static void render_content(render* r, const node* n)
111101{
112− bound_str(n->inner, 0, doc_length(r->d));
102+ bound_str(n->inner, 0, r->d->body_len);
113103 bound_str(n->nodes, 0, r->d->nodes.used_front);
114104 bound_str(n->attrs, 0, r->d->attrs.used);
115105
@@ -308,8 +298,7 @@ document* hexml_document_parse(const char* s, int slen)
308298 assert(buf);
309299 document* d = &buf->document;
310300 d->body = s;
311− d->cursor = s;
312− d->end = &s[slen];
301+ d->body_len = slen;
313302 d->error_message = NULL;
314303 d->attrs.size = 1000;
315304 d->attrs.used = 0;