From 79fd2ec6578a4f988e95b475af88f9c82af83632 Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 8 Apr 2013 21:03:12 +0300 Subject: [PATCH] Add all implicit matches into each disjunction. --- src/journal/journalctl.c | 44 +++++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 0a82a1c..ddb0f0a 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -524,17 +524,25 @@ static int generate_new_id128(void) { return 0; } +static int add_arg_matches(sd_journal *j); + static int add_matches(sd_journal *j, char **args) { char **i; + int r; assert(j); + r = add_arg_matches(j); + if (r < 0) + return r; + STRV_FOREACH(i, args) { - int r; - if (streq(*i, "+")) + if (streq(*i, "+")) { r = sd_journal_add_disjunction(j); - else if (path_is_absolute(*i)) { + if (r >= 0) + r = add_arg_matches(j); + } else if (path_is_absolute(*i)) { char _cleanup_free_ *p, *t = NULL; const char *path; struct stat st; @@ -646,6 +654,24 @@ static int add_priorities(sd_journal *j) { return 0; } +static int add_arg_matches(sd_journal *j) { + int r; + + r = add_this_boot(j); + if (r < 0) + return r; + + r = add_unit(j); + if (r < 0) + return r; + + r = add_priorities(j); + if (r < 0) + return r; + + return 0; +} + static int setup_keys(void) { #ifdef HAVE_GCRYPT size_t mpk_size, seed_size, state_size, i; @@ -1073,22 +1099,10 @@ int main(int argc, char *argv[]) { return EXIT_SUCCESS; } - r = add_this_boot(j); - if (r < 0) - return EXIT_FAILURE; - - r = add_unit(j); - if (r < 0) - return EXIT_FAILURE; - r = add_matches(j, argv + optind); if (r < 0) return EXIT_FAILURE; - r = add_priorities(j); - if (r < 0) - return EXIT_FAILURE; - /* Opening the fd now means the first sd_journal_wait() will actually wait */ r = sd_journal_get_fd(j); if (r < 0) -- 1.8.1.4