Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 030f1382 authored by Tom Cherry's avatar Tom Cherry Committed by android-build-merger
Browse files

Merge "init: fix error messages when an invalid section header is found" am: 668f70f6

am: 2f57463e

Change-Id: I57ac64bc290908475c37a2aac8dcf5615627042c
parents a2dc2676 2f57463e
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -53,7 +53,12 @@ void Parser::ParseData(const std::string& filename, std::string* data) {
    int section_start_line = -1;
    std::vector<std::string> args;

    // If we encounter a bad section start, there is no valid parser object to parse the subsequent
    // sections, so we must suppress errors until the next valid section is found.
    bool bad_section_found = false;

    auto end_section = [&] {
        bad_section_found = false;
        if (section_parser == nullptr) return;

        if (auto result = section_parser->EndSection(); !result) {
@@ -101,6 +106,7 @@ void Parser::ParseData(const std::string& filename, std::string* data) {
                        parse_error_count_++;
                        LOG(ERROR) << filename << ": " << state.line << ": " << result.error();
                        section_parser = nullptr;
                        bad_section_found = true;
                    }
                } else if (section_parser) {
                    if (auto result = section_parser->ParseLineSection(std::move(args), state.line);
@@ -108,7 +114,7 @@ void Parser::ParseData(const std::string& filename, std::string* data) {
                        parse_error_count_++;
                        LOG(ERROR) << filename << ": " << state.line << ": " << result.error();
                    }
                } else {
                } else if (!bad_section_found) {
                    parse_error_count_++;
                    LOG(ERROR) << filename << ": " << state.line
                               << ": Invalid section keyword found";