on master help sign in
Don't do get before set_error
commita9e0ab299bc28e202b1ea500d2f41e0a352158a0 authorNeil Mitchell <ndmitchell@gmail.com> dateWed 14 Dec 2016, 21:06 (10 years ago) parent2900cde
1 file changed+7−4
cbits/hexml.c+7−4
cbits/hexml.c+7−4
@@ -334,11 +334,12 @@ static inline str parse_name(document* d)
334334static inline str parse_attrval(document* d)
335335{
336336 trim(d);
337− if (get(d) != '=')
337+ if (peek(d) != '=')
338338 {
339339 set_error(d, "Expected = in attribute, but missing");
340340 return start_length(0, 0);
341341 }
342+ skip(d, 1);
342343 trim(d);
343344 char c = peek(d);
344345 if (c == '\"' || c == '\'')
@@ -403,10 +404,10 @@ static inline void parse_tag(document* d)
403404 me->attrs = parse_attributes(d);
404405 if (d->error_message != NULL) return;
405406
406− c = get(d);
407− if ((c == '/' || c == '?') && peek(d) == '>')
407+ c = peek(d);
408+ if ((c == '/' || c == '?') && peekAt(d, 1) == '>')
408409 {
409− skip(d, 1);
410+ skip(d, 2);
410411 me->nodes = start_length(0, 0);
411412 me->outer.length = start_end(me->outer.start, doc_position(d)).length;
412413 me->inner = start_length(doc_position(d), 0);
@@ -417,6 +418,8 @@ static inline void parse_tag(document* d)
417418 set_error(d, "Gunk at the end of the tag");
418419 return;
419420 }
421+ else
422+ skip(d, 1);
420423 me->inner.start = doc_position(d);
421424 str content = parse_content(d);
422425