int c, nopager = 0;
int console_level = 0;
int klog_rc = 0;
- int delta = 0;
ssize_t n;
static struct dmesg_control ctl = {
.filename = NULL,
ctl.action = SYSLOG_ACTION_CONSOLE_OFF;
break;
case 'd':
- delta = 1;
+ include_time_fmt(&ctl, DMESG_TIMEFTM_TIME_DELTA);
break;
case 'E':
ctl.action = SYSLOG_ACTION_CONSOLE_ON;
include_time_fmt(&ctl, DMESG_TIMEFTM_CTIME);
break;
case 't':
- reset_time_fmts(&ctl);
include_time_fmt(&ctl, DMESG_TIMEFTM_NONE);
break;
case 'u':
if (ctl.json) {
reset_time_fmts(&ctl);
ctl.ntime_fmts = 0;
- delta = 0;
ctl.force_prefix = 0;
ctl.raw = 0;
ctl.noesc = 1;
ctl.suspended_time = dmesg_get_suspended_time();
}
- if (delta || is_time_fmt_set(&ctl, DMESG_TIMEFTM_DELTA)) {
+ /* -d uses TIME_DELTA; merge with -T (CTIME) if both specified */
+ if (is_time_fmt_set(&ctl, DMESG_TIMEFTM_TIME_DELTA)
+ && is_time_fmt_set(&ctl, DMESG_TIMEFTM_CTIME)) {
+ exclude_time_fmt(&ctl, DMESG_TIMEFTM_TIME_DELTA);
+ for (n = 0; (size_t) n < ctl.ntime_fmts; n++) {
+ if (ctl.time_fmts[n] == DMESG_TIMEFTM_CTIME) {
+ ctl.time_fmts[n] = DMESG_TIMEFTM_CTIME_DELTA;
+ break;
+ }
+ }
+ }
+
+ /* --time-format delta: merge with TIME or CTIME if also specified */
+ if (is_time_fmt_set(&ctl, DMESG_TIMEFTM_DELTA)) {
if (is_time_fmt_set(&ctl, DMESG_TIMEFTM_TIME)) {
- if (ctl.ntime_fmts == 0) {
- ctl.time_fmts[ctl.ntime_fmts++] = DMESG_TIMEFTM_TIME_DELTA;
- } else {
- exclude_time_fmt(&ctl, DMESG_TIMEFTM_DELTA);
- for (n = 0; (size_t) n < ctl.ntime_fmts; n++) {
- if (ctl.time_fmts[n] == DMESG_TIMEFTM_TIME) {
- ctl.time_fmts[n] = DMESG_TIMEFTM_TIME_DELTA;
- break;
- }
+ exclude_time_fmt(&ctl, DMESG_TIMEFTM_DELTA);
+ for (n = 0; (size_t) n < ctl.ntime_fmts; n++) {
+ if (ctl.time_fmts[n] == DMESG_TIMEFTM_TIME) {
+ ctl.time_fmts[n] = DMESG_TIMEFTM_TIME_DELTA;
+ break;
}
}
} else if (is_time_fmt_set(&ctl, DMESG_TIMEFTM_CTIME)) {
break;
}
}
- } else {
- include_time_fmt(&ctl, DMESG_TIMEFTM_DELTA);
}
}