From 8908e2569f4cbf56460891e38401b6b0b10a8b15 Mon Sep 17 00:00:00 2001 From: Timothy Stack Date: Sun, 23 Jun 2013 06:11:37 -0700 Subject: [PATCH] [parser] fix some parser issues; and a fix for my last checkin --- src/data_parser.hh | 1 + src/data_scanner.cc | 6 ++++-- src/data_scanner.hh | 1 + src/log_format_impls.cc | 5 ++++- src/logfile_sub_source.cc | 6 +++--- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/data_parser.hh b/src/data_parser.hh index 28986068..e9885856 100644 --- a/src/data_parser.hh +++ b/src/data_parser.hh @@ -712,6 +712,7 @@ private: case DT_UUID: case DT_URL: case DT_PATH: + case DT_DATE: case DT_TIME: case DT_PERCENTAGE: { element_list_t ELEMENT_LIST_T(pair_subs); diff --git a/src/data_scanner.cc b/src/data_scanner.cc index 7a6fb56f..f120089f 100644 --- a/src/data_scanner.cc +++ b/src/data_scanner.cc @@ -50,8 +50,10 @@ static struct { }, { "mac", pcrepp( "\\A([0-9a-fA-F][0-9a-fA-F](?::[0-9a-fA-F][0-9a-fA-F]){5})"), }, + { "date", + pcrepp("\\A(\\d{4}/\\d{1,2}/\\d{1,2}|\\d{4}-\\d{1,2}-\\d{1,2})"), }, { "time", pcrepp( - "\\A(\\d?\\d:\\d\\d(:\\d\\d)?(:\\d\\d)?([,.]\\d{3})?)\\b"), }, /* XXX be more specific */ + "\\A(\\d?\\d:\\d\\d(:\\d\\d)?(:\\d\\d)?([,.]\\d{3,6})?)\\b"), }, /* XXX be more specific */ /* { "qual", pcrepp("\\A([^\\s:=]+:[^\\s:=,]+(?!,)(?::[^\\s:=,]+)*)"), }, */ { "ipv6", pcrepp("\\A(::|[:\\da-fA-f\\.]+[a-fA-f\\d])"), }, @@ -130,7 +132,7 @@ const char *DNT_NAMES[DNT_MAX - DNT_KEY] = { "meas", "var", "rang", - "date", + "dt", "grp", }; diff --git a/src/data_scanner.hh b/src/data_scanner.hh index 5174417f..9c617409 100644 --- a/src/data_scanner.hh +++ b/src/data_scanner.hh @@ -41,6 +41,7 @@ enum data_token_t { DT_URL, DT_PATH, DT_MAC_ADDRESS, + DT_DATE, DT_TIME, DT_IPV6_ADDRESS, /* DT_QUALIFIED_NAME, */ diff --git a/src/log_format_impls.cc b/src/log_format_impls.cc index bfb67cc8..e706f720 100644 --- a/src/log_format_impls.cc +++ b/src/log_format_impls.cc @@ -544,10 +544,13 @@ class generic_log_format : public log_format { /* Try to pull out the milliseconds value. */ if (last_pos[0] == ',' || last_pos[0] == '.') { - sscanf(last_pos + 1, "%hd", &millis); + int subsec_len = 0; + + sscanf(last_pos + 1, "%hd%n", &millis, &subsec_len); if (millis >= 1000) { millis = 0; } + this->lf_time_fmt_len += 1 + subsec_len; } dst.push_back(logline(offset, line_time, diff --git a/src/logfile_sub_source.cc b/src/logfile_sub_source.cc index 58b733df..6c0562e7 100644 --- a/src/logfile_sub_source.cc +++ b/src/logfile_sub_source.cc @@ -416,10 +416,9 @@ bool logfile_sub_source::rebuild_index(observer *obs, bool force) ld->ld_file->size()); } - ld->ld_indexing.ld_last = con_line; if (!(lf_iter->get_level() & logline::LEVEL_CONTINUED)) { if (action_for_prev_line == logfile_filter::INCLUDE) { - while (last_owner->ld_indexing.ld_start < + while (last_owner->ld_indexing.ld_start <= last_owner->ld_indexing.ld_last) { this->lss_index.push_back(last_owner->ld_indexing.ld_start); ++last_owner->ld_indexing.ld_start; @@ -431,6 +430,7 @@ bool logfile_sub_source::rebuild_index(observer *obs, bool force) ld->ld_indexing.ld_start = con_line; } + ld->ld_indexing.ld_last = con_line; action_for_prev_line = ld->ld_file->check_filter( lf_iter, this->lss_filter_generation, this->lss_filters); @@ -440,7 +440,7 @@ bool logfile_sub_source::rebuild_index(observer *obs, bool force) } if (action_for_prev_line == logfile_filter::INCLUDE) { - while (last_owner->ld_indexing.ld_start < + while (last_owner->ld_indexing.ld_start <= last_owner->ld_indexing.ld_last) { this->lss_index.push_back(last_owner->ld_indexing.ld_start); ++last_owner->ld_indexing.ld_start;