[Dctrl-tools-devel] [SCM] Debian control file query tools branch, master, updated. 2.22.2-16-g672a5ab
Antti-Juhani Kaijanaho
ajk at debian.org
Fri Jul 13 21:47:30 UTC 2012
The following commit has been merged in the master branch:
commit 42a13071adf04bb721e60978c28093d288cf8473
Author: Antti-Juhani Kaijanaho <ajk at debian.org>
Date: Tue Jul 3 15:34:26 2012 +0300
grep-dctrl: Extract print_para out of main.
Signed-off-by: Antti-Juhani Kaijanaho <ajk at debian.org>
diff --git a/grep-dctrl/grep-dctrl.c b/grep-dctrl/grep-dctrl.c
index dd2e085..7ff6e44 100644
--- a/grep-dctrl/grep-dctrl.c
+++ b/grep-dctrl/grep-dctrl.c
@@ -773,6 +773,39 @@ static void show_field(struct arguments *args,
}
}
+static void print_para(struct arguments *args,
+ struct paragraph *para)
+{
+ if (args->num_show_fields == 0) {
+ struct fsaf_read_rv r = get_whole_para(para);
+ fwrite(r.b, 1, r.len, stdout);
+ putchar('\n');
+ putchar('\n');
+ return;
+ }
+ if (args->invert_show) {
+ for (size_t j = 0;
+ j < fieldtrie_count() && j < para->nfields;
+ j++) {
+ struct field_attr *fa = fieldtrie_get(j);
+ if (fa->is_show_field) continue;
+ show_field(args, para, fa);
+ }
+ } else {
+ for (size_t j = 0; j < args->num_show_fields; j++) {
+ size_t inx = args->show_fields[j];
+ struct field_attr *fa = fieldtrie_get(inx);
+ assert(fa->is_show_field);
+ show_field(args, para, fa);
+ }
+ if ((args->show_field_name && args->ensure_dctrl) ||
+ args->num_show_fields > 1) {
+ puts("");
+ }
+ }
+}
+
+
static struct argp argp = { .options = options,
.parser = parse_opt,
.args_doc = argsdoc,
@@ -904,40 +937,8 @@ int main (int argc, char * argv[])
++count;
continue;
}
- if (args.num_show_fields == 0) {
- struct fsaf_read_rv r = get_whole_para(¶);
- fwrite(r.b, 1, r.len, stdout);
- putchar('\n');
- putchar('\n');
- continue;
- }
- if (args.invert_show) {
- for (size_t j = 0;
- j < fieldtrie_count() &&
- j < para.nfields;
- j++) {
- struct field_attr *fa =
- fieldtrie_get(j);
- if (fa->is_show_field) {
- continue;
- }
- show_field(&args, ¶, fa);
- }
- } else {
- for (size_t j = 0;
- j < args.num_show_fields; j++) {
- size_t inx = args.show_fields[j];
- struct field_attr *fa =
- fieldtrie_get(inx);
- assert(fa->is_show_field);
- show_field(&args, ¶, fa);
- }
- if ((args.show_field_name &&
- args.ensure_dctrl) ||
- args.num_show_fields > 1) puts("");
- }
- }
-
+ print_para(&args, ¶);
+ }
fsaf_close(fp);
close_ifile(fname, fd);
}
--
Debian control file query tools
More information about the Dctrl-tools-devel
mailing list