Moved time setting from tm struct to its own routine.
@@ -997,13 +997,19 @@ spec_err (GLogItem * logitem, int code, const char spec, const char *tkn) {
}
static void
-set_tm_dt_logitem(GLogItem *logitem, struct tm tm)
-{
+set_tm_dt_logitem (GLogItem * logitem, struct tm tm) {
logitem->dt.tm_year = tm.tm_year;
logitem->dt.tm_mon = tm.tm_mon;
logitem->dt.tm_mday = tm.tm_mday;
}
+static void
+set_tm_tm_logitem (GLogItem * logitem, struct tm tm) {
+ logitem->dt.tm_hour = tm.tm_hour;
+ logitem->dt.tm_min = tm.tm_min;
+ logitem->dt.tm_sec = tm.tm_sec;
+}
+
#pragma GCC diagnostic warning "-Wformat-nonliteral"
/* Parse the log string given log format rule.
@@ -1054,9 +1060,7 @@ parse_specifier (GLogItem * logitem, char **str, const char *p, const char *end)
free (tkn);
return 1;
}
- logitem->dt.tm_hour = tm.tm_hour;
- logitem->dt.tm_min = tm.tm_min;
- logitem->dt.tm_sec = tm.tm_sec;
+ set_tm_tm_logitem (logitem, tm);
free (tkn);
break;
/* date/time as decimal, i.e., timestamps, ms/us */
@@ -1074,10 +1078,7 @@ parse_specifier (GLogItem * logitem, char **str, const char *p, const char *end)
}
set_tm_dt_logitem (logitem, tm);
-
- logitem->dt.tm_hour = tm.tm_hour;
- logitem->dt.tm_min = tm.tm_min;
- logitem->dt.tm_sec = tm.tm_sec;
+ set_tm_tm_logitem (logitem, tm);
break;
/* Virtual Host */
case 'v':
