From 88b0db5fca6aa209657d0ea99ecbb47135502f38 Mon Sep 17 00:00:00 2001 From: anon Date: Sat, 18 Nov 2023 02:15:41 +0100 Subject: [PATCH] clearer tag mismatch exit conditions --- source/csml.l | 15 +++++---------- source/exit_values.hpp | 2 ++ 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/source/csml.l b/source/csml.l index a12392c..ef7c4c6 100644 --- a/source/csml.l +++ b/source/csml.l @@ -5,6 +5,7 @@ #include #include +#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; } diff --git a/source/exit_values.hpp b/source/exit_values.hpp index c91ef8c..bc9eb55 100644 --- a/source/exit_values.hpp +++ b/source/exit_values.hpp @@ -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, };