init: remove unused parts of parser.cpp
Now that ueventd is using init's parser, we no longer need anything other than the tokenizer from parser.cpp. Test: Boot bullhead Change-Id: I1f70f2c4479af576174bd74dd919d81817500216
This commit is contained in:
parent
fe062055cb
commit
ad6741c6f8
3 changed files with 4 additions and 35 deletions
|
|
@ -48,7 +48,6 @@ void Parser::ParseData(const std::string& filename, const std::string& data) {
|
|||
data_copy.push_back('\0');
|
||||
|
||||
parse_state state;
|
||||
state.filename = filename.c_str();
|
||||
state.line = 0;
|
||||
state.ptr = &data_copy[0];
|
||||
state.nexttoken = 0;
|
||||
|
|
@ -76,7 +75,7 @@ void Parser::ParseData(const std::string& filename, const std::string& data) {
|
|||
|
||||
std::string ret_err;
|
||||
if (!callback(std::move(args), &ret_err)) {
|
||||
parse_error(&state, "%s\n", ret_err.c_str());
|
||||
LOG(ERROR) << filename << ": " << state.line << ": " << ret_err;
|
||||
}
|
||||
section_parser = nullptr;
|
||||
break;
|
||||
|
|
@ -88,15 +87,14 @@ void Parser::ParseData(const std::string& filename, const std::string& data) {
|
|||
}
|
||||
section_parser = section_parsers_[args[0]].get();
|
||||
std::string ret_err;
|
||||
if (!section_parser->ParseSection(std::move(args), state.filename, state.line,
|
||||
&ret_err)) {
|
||||
parse_error(&state, "%s\n", ret_err.c_str());
|
||||
if (!section_parser->ParseSection(std::move(args), filename, state.line, &ret_err)) {
|
||||
LOG(ERROR) << filename << ": " << state.line << ": " << ret_err;
|
||||
section_parser = nullptr;
|
||||
}
|
||||
} else if (section_parser) {
|
||||
std::string ret_err;
|
||||
if (!section_parser->ParseLineSection(std::move(args), state.line, &ret_err)) {
|
||||
parse_error(&state, "%s\n", ret_err.c_str());
|
||||
LOG(ERROR) << filename << ": " << state.line << ": " << ret_err;
|
||||
}
|
||||
}
|
||||
args.clear();
|
||||
|
|
|
|||
|
|
@ -1,28 +1,5 @@
|
|||
#include "parser.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
void parse_error(struct parse_state *state, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char buf[128];
|
||||
int off;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s: %d: ", state->filename, state->line);
|
||||
buf[127] = 0;
|
||||
off = strlen(buf);
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(buf + off, 128 - off, fmt, ap);
|
||||
va_end(ap);
|
||||
buf[127] = 0;
|
||||
LOG(ERROR) << buf;
|
||||
}
|
||||
|
||||
int next_token(struct parse_state *state)
|
||||
{
|
||||
char *x = state->ptr;
|
||||
|
|
|
|||
|
|
@ -27,14 +27,8 @@ struct parse_state
|
|||
char *text;
|
||||
int line;
|
||||
int nexttoken;
|
||||
void *context;
|
||||
void (*parse_line)(struct parse_state *state, int nargs, char **args);
|
||||
const char *filename;
|
||||
void *priv;
|
||||
};
|
||||
|
||||
void dump_parser_state(void);
|
||||
int next_token(struct parse_state *state);
|
||||
void parse_error(struct parse_state *state, const char *fmt, ...);
|
||||
|
||||
#endif /* PARSER_H_ */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue