From 1ca68c7c4910df08c35c224037b3668903d40c19 Mon Sep 17 00:00:00 2001 From: luca0N! Date: Tue, 24 May 2022 20:35:26 -0300 Subject: [PATCH] Fix article metadata parser Fixed two issues regarding the metadata parser. The first issue caused the parser to ignore line breaks if the length of a line was equal to the length of the buffer, whereas the second issue caused the parser to ignore more than it should if it came across a comment whose length was smaller than the buffer length. --- src/Article.cxx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Article.cxx b/src/Article.cxx index 6b59367..b48fccf 100644 --- a/src/Article.cxx +++ b/src/Article.cxx @@ -54,17 +54,13 @@ namespace Article { ignore_line = false; std::list cfg_lines = { "" }; - while (fgets(buf, buflen, a) != NULL) { // Ignore blank lines or lines starting with a comment. if (buf[0] == '#') { - ignore_line = true; + if (strlen(buf) < buflen) continue; + else ignore_line = true; continue; - } else if (buf[0] == '\n') { - if (ignore_line) - ignore_line = false; - continue; - } + } int eol = -1; for (int c = 0; c < buflen; c++) { // Check if this loop has already done what it's supposed to do by checking if the title has been set. @@ -119,6 +115,7 @@ namespace Article { bool reading_article_metadata = false; for (std::string const &line : cfg_lines) { + if (line == "") continue; std::cout << "[!] " << line << "\n"; // Check namespace if (reading_article_metadata) {