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.
This commit is contained in:
luca0N! 2022-05-24 20:35:26 -03:00
parent b58db4b9e7
commit 1ca68c7c49
Signed by: luca0N
GPG Key ID: 2E7B4655CF16D7D6
1 changed files with 4 additions and 7 deletions

View File

@ -54,17 +54,13 @@ namespace Article {
ignore_line = false;
std::list<std::string> 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) {