fix an error when parsing json logs

This commit is contained in:
Timothy Stack 2014-03-02 15:19:34 -08:00
parent 169a5bd732
commit 9848582239
2 changed files with 3 additions and 0 deletions

View File

@ -391,11 +391,13 @@ void load_formats(std::vector<std::string> &errors)
string format_path = dotlnav_path("formats/*/*.json");
static_root_mem<glob_t, globfree> gl;
log_info("loading formats from path: %s", format_path.c_str());
if (glob(format_path.c_str(), 0, NULL, gl.inout()) == 0) {
for (int lpc = 0; lpc < (int)gl->gl_pathc; lpc++) {
string filename(gl->gl_pathv[lpc]);
auto_fd fd;
log_info("loading formats from file: %s", filename.c_str());
yajlpp_parse_context ypc(filename, format_handlers);
if ((fd = open(gl->gl_pathv[lpc], O_RDONLY)) == -1) {
char errmsg[1024];

View File

@ -256,6 +256,7 @@ throw (line_buffer::error, logfile::error)
if (len > 0 && line[len - 1] == '\n') {
this->lf_partial_line = false;
line[len - 1] = '\0';
len -= 1;
}
else {
this->lf_partial_line = true;