diff options
author | Antti-Juhani Kaijanaho <ajk@debian.org> | 2011-12-14 20:36:48 +0200 |
---|---|---|
committer | Antti-Juhani Kaijanaho <ajk@debian.org> | 2011-12-14 20:39:13 +0200 |
commit | 34ce3e24a1d922b8778ec0b764540e5bc43155b4 (patch) | |
tree | a29ed01eb8f0afcaa26943e7b45f99ca80d368a3 /grep-dctrl | |
parent | fd8f94781f285d202662afea4bd98f68fd7b19d4 (diff) | |
download | dctrl-tools-34ce3e24a1d922b8778ec0b764540e5bc43155b4.tar.gz |
Bug #652034: Handle multiple instances of the same field gracefully.
For grep-dctrl, this means having -F search for all of the same-name
fields disjunctively. The -s option selects all same-name fields for
printing.
For the other tools, all but the first are ignored.
No string changes, so committing to maint-2.20 for release with 2.20.1.
Signed-off-by: Antti-Juhani Kaijanaho <ajk@debian.org>
Diffstat (limited to 'grep-dctrl')
-rw-r--r-- | grep-dctrl/grep-dctrl.c | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/grep-dctrl/grep-dctrl.c b/grep-dctrl/grep-dctrl.c index 9e661bb..99ea398 100644 --- a/grep-dctrl/grep-dctrl.c +++ b/grep-dctrl/grep-dctrl.c @@ -753,36 +753,38 @@ static void show_field(struct arguments *args, struct paragraph *para, struct field_attr *fa) { - struct field_data *fd = + struct field_data fds = find_field_wr(para, fa->inx, GET_BACKUP_FIELD(fa->application_data)); - if (fd == NULL) return; - struct fsaf_read_rv r = - fsaf_read(para->common->fp, fd->start, fd->end - fd->start); - - if (args->short_descr && - fa == description_attr) { - char * nl = memchr(r.b, '\n', r.len); - if (nl != 0) r.len = nl - r.b; - } + for (struct field_datum *fd = fds.first; fd != NULL; fd = fd->next) { + struct fsaf_read_rv r = + fsaf_read(para->common->fp, + fd->start, fd->end - fd->start); - if (r.len == 0) { - /* don't display a field with an empty value */ - return; - } + if (args->short_descr && + fa == description_attr) { + char * nl = memchr(r.b, '\n', r.len); + if (nl != 0) r.len = nl - r.b; + } - if (args->show_field_name) { - struct fsaf_read_rv rn = - fsaf_read(para->common->fp, - fd->name_start, - fd->name_end - fd->name_start); - fwrite(rn.b, 1, rn.len, stdout); - fputs(": ", stdout); - } + if (r.len == 0) { + /* don't display a field with an empty value */ + break; + } + + if (args->show_field_name) { + struct fsaf_read_rv rn = + fsaf_read(para->common->fp, + fd->name_start, + fd->name_end - fd->name_start); + fwrite(rn.b, 1, rn.len, stdout); + fputs(": ", stdout); + } - fwrite(r.b, 1, r.len, stdout); - puts(""); + fwrite(r.b, 1, r.len, stdout); + puts(""); + } } static struct argp argp = { .options = options, |