clearer tag mismatch exit conditions

This commit is contained in:
anon
2023-11-18 02:15:41 +01:00
parent 5485e6bdd7
commit 88b0db5fca
2 changed files with 7 additions and 10 deletions

View File

@ -5,6 +5,7 @@
#include <stack>
#include <string>
#include "exit_values.hpp"
#include "html_special.hpp"
#include "global.hpp"
@ -29,30 +30,24 @@ static const char ATTRIBUTE_VALUE_END[] = "'";
static unsigned short current_unicode_size;
static
bool push_tag() {
void push_tag() {
if (tag_candidate == "") {
exit(3);
return false;
exit(TAG_NOT_NAMED);
}
trim(tag_candidate);
tag_stack.push(tag_candidate);
tag_candidate = "";
return true;
}
static
bool pop_tag() {
void pop_tag() {
if (tag_stack.empty()) {
exit(3);
return false;
exit(TAG_NOT_FOUND);
}
tag_stack.pop();
tag_candidate = "";
return true;
}

View File

@ -4,4 +4,6 @@ enum {
IO_ERROR = 2,
UNKNOWN_SET = 3,
POPULATED_STACK = 4, // most likely signals that more tags were opened than closed, ie the user forgot adding a '}' somewhere
TAG_NOT_NAMED = 5,
TAG_NOT_FOUND = 6,
};