Merge "ueventd: fix extraneous 'Invalid section' error"
This commit is contained in:
commit
86e65e9cac
1 changed files with 11 additions and 11 deletions
|
|
@ -70,24 +70,23 @@ void Parser::ParseData(const std::string& filename, const std::string& data) {
|
||||||
case T_EOF:
|
case T_EOF:
|
||||||
end_section();
|
end_section();
|
||||||
return;
|
return;
|
||||||
case T_NEWLINE:
|
case T_NEWLINE: {
|
||||||
state.line++;
|
state.line++;
|
||||||
if (args.empty()) break;
|
if (args.empty()) break;
|
||||||
// If we have a line matching a prefix we recognize, call its callback and unset any
|
// If we have a line matching a prefix we recognize, call its callback and unset any
|
||||||
// current section parsers. This is meant for /sys/ and /dev/ line entries for
|
// current section parsers. This is meant for /sys/ and /dev/ line entries for
|
||||||
// uevent.
|
// uevent.
|
||||||
for (const auto& [prefix, callback] : line_callbacks_) {
|
auto line_callback = std::find_if(
|
||||||
if (android::base::StartsWith(args[0], prefix)) {
|
line_callbacks_.begin(), line_callbacks_.end(),
|
||||||
end_section();
|
[&args](const auto& c) { return android::base::StartsWith(args[0], c.first); });
|
||||||
|
if (line_callback != line_callbacks_.end()) {
|
||||||
|
end_section();
|
||||||
|
|
||||||
if (auto result = callback(std::move(args)); !result) {
|
if (auto result = line_callback->second(std::move(args)); !result) {
|
||||||
parse_error_count_++;
|
parse_error_count_++;
|
||||||
LOG(ERROR) << filename << ": " << state.line << ": " << result.error();
|
LOG(ERROR) << filename << ": " << state.line << ": " << result.error();
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
} else if (section_parsers_.count(args[0])) {
|
||||||
if (section_parsers_.count(args[0])) {
|
|
||||||
end_section();
|
end_section();
|
||||||
section_parser = section_parsers_[args[0]].get();
|
section_parser = section_parsers_[args[0]].get();
|
||||||
section_start_line = state.line;
|
section_start_line = state.line;
|
||||||
|
|
@ -111,6 +110,7 @@ void Parser::ParseData(const std::string& filename, const std::string& data) {
|
||||||
}
|
}
|
||||||
args.clear();
|
args.clear();
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case T_TEXT:
|
case T_TEXT:
|
||||||
args.emplace_back(state.text);
|
args.emplace_back(state.text);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue