commit - c0b634ddc444df1c2391e8262cf707e4422287a6
commit + 27dce34fb57e3639875005f21f7ed651fad9c2db
blob - 75fbbfd2af004a74260964309e270c81b3519b15
blob + ffff9bad5b5abbed54e6cd22bc6c0d1d5350ddbf
--- gemtext.c
+++ gemtext.c
{
enum line_type t;
- t = detect_line_type(line, linelen, p->flags);
+ t = detect_line_type(line, linelen, p->flags & PARSER_IN_PRE);
if (t == LINE_PRE_START)
- p->flags = 1;
+ p->flags ^= PARSER_IN_PRE;
if (t == LINE_PRE_END)
- p->flags = 0;
+ p->flags ^= PARSER_IN_PRE;
return parsers[t](p, t, line, linelen);
}
/* flush the buffer */
if (p->len != 0) {
- t = detect_line_type(p->buf, p->len, p->flags);
+ t = detect_line_type(p->buf, p->len, p->flags & PARSER_IN_PRE);
if (!parsers[t](p, t, p->buf, p->len))
return 0;
- if (p->flags && !emit_line(p, LINE_PRE_END, NULL, NULL))
+ if ((p->flags & PARSER_IN_PRE) &&
+ !emit_line(p, LINE_PRE_END, NULL, NULL))
return 0;
}
blob - 0434603c519c7ff93382ba4dc6e6f938b55a2ad2
blob + ff6e96006043734d2287e6f8b03e476e9280c979
--- parser.c
+++ parser.c
b = p->buf;
len = p->len;
- if (!p->in_body && len < 3)
+ if (!(p->flags & PARSER_IN_BODY) && len < 3)
return 1;
- if (!p->in_body) {
- p->in_body = 1;
+ if (!(p->flags & PARSER_IN_BODY)) {
+ p->flags |= PARSER_IN_BODY;
/*
* drop the BOM: only UTF-8 is supported, and there
blob - c0397fc1e674ee0325c190c22d9ef8a6b70529ca
blob + c3bf19a86c41d7b406d8c52f127e5b90e1afa5d1
--- telescope.h
+++ telescope.h
const char *name;
char title[32+1];
char *buf;
- int in_body; /* used to deal with BOM */
size_t len;
size_t cap;
+
+#define PARSER_IN_BODY 1
+#define PARSER_IN_PRE 2
int flags;
parsechunkfn parse;
parserfreefn free;