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

View file

@ -54,15 +54,11 @@ namespace Article {
ignore_line = false; ignore_line = false;
std::list<std::string> cfg_lines = { "" }; std::list<std::string> cfg_lines = { "" };
while (fgets(buf, buflen, a) != NULL) { while (fgets(buf, buflen, a) != NULL) {
// Ignore blank lines or lines starting with a comment. // Ignore blank lines or lines starting with a comment.
if (buf[0] == '#') { if (buf[0] == '#') {
ignore_line = true; if (strlen(buf) < buflen) continue;
continue; else ignore_line = true;
} else if (buf[0] == '\n') {
if (ignore_line)
ignore_line = false;
continue; continue;
} }
int eol = -1; int eol = -1;
@ -119,6 +115,7 @@ namespace Article {
bool reading_article_metadata = false; bool reading_article_metadata = false;
for (std::string const &line : cfg_lines) { for (std::string const &line : cfg_lines) {
if (line == "") continue;
std::cout << "[!] " << line << "\n"; std::cout << "[!] " << line << "\n";
// Check namespace // Check namespace
if (reading_article_metadata) { if (reading_article_metadata) {