mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
refactor: move field width calculation and sort preparation from _do_report_object to dm_report_output
This also prepares code for repeated dm_report_output calls.
This commit is contained in:
parent
102cc4c1e2
commit
0ba5f4b8e9
@ -1,5 +1,6 @@
|
|||||||
Version 1.02.128 -
|
Version 1.02.128 -
|
||||||
=================================
|
=================================
|
||||||
|
Move field width handling/sort init from dm_report_object to dm_report_output.
|
||||||
Add _LOG_BYPASS_REPORT flag for bypassing any log report currently set.
|
Add _LOG_BYPASS_REPORT flag for bypassing any log report currently set.
|
||||||
Introduce DM_REPORT_GROUP_JSON for report group with JSON output format.
|
Introduce DM_REPORT_GROUP_JSON for report group with JSON output format.
|
||||||
Introduce DM_REPORT_GROUP_BASIC for report group with basic report output.
|
Introduce DM_REPORT_GROUP_BASIC for report group with basic report output.
|
||||||
|
@ -1913,7 +1913,6 @@ static int _do_report_object(struct dm_report *rh, void *object, int do_output,
|
|||||||
struct row *row = NULL;
|
struct row *row = NULL;
|
||||||
struct dm_report_field *field;
|
struct dm_report_field *field;
|
||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
int len;
|
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
if (!rh) {
|
if (!rh) {
|
||||||
@ -2021,17 +2020,6 @@ static int _do_report_object(struct dm_report *rh, void *object, int do_output,
|
|||||||
|
|
||||||
dm_list_add(&rh->rows, &row->list);
|
dm_list_add(&rh->rows, &row->list);
|
||||||
|
|
||||||
dm_list_iterate_items(field, &row->fields) {
|
|
||||||
len = (int) strlen(field->report_string);
|
|
||||||
if ((len > field->props->width))
|
|
||||||
field->props->width = len;
|
|
||||||
|
|
||||||
if ((rh->flags & RH_SORT_REQUIRED) &&
|
|
||||||
(field->props->flags & FLD_SORT_KEY)) {
|
|
||||||
(*row->sort_fields)[field->props->sort_posn] = field;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(rh->flags & DM_REPORT_OUTPUT_BUFFERED))
|
if (!(rh->flags & DM_REPORT_OUTPUT_BUFFERED))
|
||||||
return dm_report_output(rh);
|
return dm_report_output(rh);
|
||||||
out:
|
out:
|
||||||
@ -4627,6 +4615,9 @@ static int _print_basic_report_header(struct dm_report *rh)
|
|||||||
|
|
||||||
int dm_report_output(struct dm_report *rh)
|
int dm_report_output(struct dm_report *rh)
|
||||||
{
|
{
|
||||||
|
struct row *row;
|
||||||
|
struct dm_report_field *field;
|
||||||
|
size_t len;
|
||||||
int r = 0;
|
int r = 0;
|
||||||
|
|
||||||
if (_is_json_report(rh) &&
|
if (_is_json_report(rh) &&
|
||||||
@ -4638,6 +4629,19 @@ int dm_report_output(struct dm_report *rh)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dm_list_iterate_items(row, &rh->rows) {
|
||||||
|
dm_list_iterate_items(field, &row->fields) {
|
||||||
|
len = (int) strlen(field->report_string);
|
||||||
|
if ((len > field->props->width))
|
||||||
|
field->props->width = len;
|
||||||
|
|
||||||
|
if ((rh->flags & RH_SORT_REQUIRED) &&
|
||||||
|
(field->props->flags & FLD_SORT_KEY)) {
|
||||||
|
(*row->sort_fields)[field->props->sort_posn] = field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((rh->flags & RH_SORT_REQUIRED))
|
if ((rh->flags & RH_SORT_REQUIRED))
|
||||||
_sort_rows(rh);
|
_sort_rows(rh);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user