Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/815911/?format=api
{ "id": 815911, "url": "http://patchwork.ozlabs.org/api/patches/815911/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/20170919220125.32535-29-blp@ovn.org/", "project": { "id": 47, "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api", "name": "Open vSwitch", "link_name": "openvswitch", "list_id": "ovs-dev.openvswitch.org", "list_email": "ovs-dev@openvswitch.org", "web_url": "http://openvswitch.org/", "scm_url": "git@github.com:openvswitch/ovs.git", "webscm_url": "https://github.com/openvswitch/ovs", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170919220125.32535-29-blp@ovn.org>", "list_archive_url": null, "date": "2017-09-19T22:01:01", "name": "[ovs-dev,RFC,28/52] table: Add --max-column-width option.", "commit_ref": null, "pull_url": null, "state": "rfc", "archived": false, "hash": "a499cf00aba76d4130c67ed742792e510228da52", "submitter": { "id": 67603, "url": "http://patchwork.ozlabs.org/api/people/67603/?format=api", "name": "Ben Pfaff", "email": "blp@ovn.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/20170919220125.32535-29-blp@ovn.org/mbox/", "series": [ { "id": 3975, "url": "http://patchwork.ozlabs.org/api/series/3975/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=3975", "date": "2017-09-19T22:00:34", "name": "clustering implementation", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/3975/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/815911/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/815911/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<ovs-dev-bounces@openvswitch.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "dev@openvswitch.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "ovs-dev@mail.linuxfoundation.org" ], "Authentication-Results": "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=openvswitch.org\n\t(client-ip=140.211.169.12; helo=mail.linuxfoundation.org;\n\tenvelope-from=ovs-dev-bounces@openvswitch.org;\n\treceiver=<UNKNOWN>)", "Received": [ "from mail.linuxfoundation.org (mail.linuxfoundation.org\n\t[140.211.169.12])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xxd110wh5z9sBW\n\tfor <incoming@patchwork.ozlabs.org>;\n\tWed, 20 Sep 2017 08:32:36 +1000 (AEST)", "from mail.linux-foundation.org (localhost [127.0.0.1])\n\tby mail.linuxfoundation.org (Postfix) with ESMTP id 57357DB8;\n\tTue, 19 Sep 2017 22:21:39 +0000 (UTC)", "from smtp1.linuxfoundation.org (smtp1.linux-foundation.org\n\t[172.17.192.35])\n\tby mail.linuxfoundation.org (Postfix) with ESMTPS id 1C825D69\n\tfor <dev@openvswitch.org>; Tue, 19 Sep 2017 22:21:38 +0000 (UTC)", "from slow1-d.mail.gandi.net (slow1-d.mail.gandi.net\n\t[217.70.178.86])\n\tby smtp1.linuxfoundation.org (Postfix) with ESMTP id 89DBB174\n\tfor <dev@openvswitch.org>; Tue, 19 Sep 2017 22:21:37 +0000 (UTC)", "from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby slow1-d.mail.gandi.net (Postfix) with ESMTP id 5485B534EBF\n\tfor <dev@openvswitch.org>; Wed, 20 Sep 2017 00:02:17 +0200 (CEST)", "from sigabrt.benpfaff.org (unknown [208.91.2.3])\n\t(Authenticated sender: blp@ovn.org)\n\tby relay4-d.mail.gandi.net (Postfix) with ESMTPSA id A75041720A4;\n\tWed, 20 Sep 2017 00:02:15 +0200 (CEST)" ], "X-Greylist": "from auto-whitelisted by SQLgrey-1.7.6", "X-Originating-IP": "208.91.2.3", "From": "Ben Pfaff <blp@ovn.org>", "To": "dev@openvswitch.org", "Date": "Tue, 19 Sep 2017 15:01:01 -0700", "Message-Id": "<20170919220125.32535-29-blp@ovn.org>", "X-Mailer": "git-send-email 2.10.2", "In-Reply-To": "<20170919220125.32535-1-blp@ovn.org>", "References": "<20170919220125.32535-1-blp@ovn.org>", "X-Spam-Status": "No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW\n\tautolearn=disabled version=3.3.1", "X-Spam-Checker-Version": "SpamAssassin 3.3.1 (2010-03-16) on\n\tsmtp1.linux-foundation.org", "Cc": "Ben Pfaff <blp@ovn.org>", "Subject": "[ovs-dev] [PATCH RFC 28/52] table: Add --max-column-width option.", "X-BeenThere": "ovs-dev@openvswitch.org", "X-Mailman-Version": "2.1.12", "Precedence": "list", "List-Id": "<ovs-dev.openvswitch.org>", "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>", "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>", "List-Post": "<mailto:ovs-dev@openvswitch.org>", "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>", "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n\t<mailto:ovs-dev-request@openvswitch.org?subject=subscribe>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Sender": "ovs-dev-bounces@openvswitch.org", "Errors-To": "ovs-dev-bounces@openvswitch.org" }, "content": "This can make it easier to read tables that contain wide data in some\ncolumns.\n\nSigned-off-by: Ben Pfaff <blp@ovn.org>\n---\n NEWS | 2 ++\n lib/table.c | 22 +++++++++++++++++-----\n lib/table.h | 13 ++++++++++---\n lib/table.man | 5 +++++\n 4 files changed, 34 insertions(+), 8 deletions(-)", "diff": "diff --git a/NEWS b/NEWS\nindex 6a5d2bf98d35..8392ccc89a02 100644\n--- a/NEWS\n+++ b/NEWS\n@@ -1,5 +1,7 @@\n Post-v2.8.0\n --------------------\n+ - ovs-vsctl and other commands that display data in tables now support a\n+ --max-column-width option to limit column width.\n - OVN:\n * The \"requested-chassis\" option for a logical switch port now accepts a\n chassis \"hostname\" in addition to a chassis \"name\".\ndiff --git a/lib/table.c b/lib/table.c\nindex c8e9f4153d3a..98599d67cfcf 100644\n--- a/lib/table.c\n+++ b/lib/table.c\n@@ -255,19 +255,31 @@ table_print_table__(const struct table *table, const struct table_style *style)\n puts(table->caption);\n }\n \n- widths = xmalloc(table->n_columns * sizeof *widths);\n+ widths = xzalloc(table->n_columns * sizeof *widths);\n for (x = 0; x < table->n_columns; x++) {\n const struct column *column = &table->columns[x];\n \n- widths[x] = strlen(column->heading);\n+ int w = 0;\n for (y = 0; y < table->n_rows; y++) {\n const char *text = cell_to_text(table_cell__(table, y, x), style);\n size_t length = strlen(text);\n \n- if (length > widths[x]) {\n- widths[x] = length;\n+ if (length > w) {\n+ w = length;\n }\n }\n+\n+ int max = style->max_column_width;\n+ if (max > 0 && w > max) {\n+ w = max;\n+ }\n+ if (style->headings) {\n+ int min = strlen(column->heading);\n+ if (w < min) {\n+ w = min;\n+ }\n+ }\n+ widths[x] = w;\n }\n \n if (style->headings) {\n@@ -295,7 +307,7 @@ table_print_table__(const struct table *table, const struct table_style *style)\n if (x) {\n ds_put_char(&line, ' ');\n }\n- ds_put_format(&line, \"%-*s\", widths[x], text);\n+ ds_put_format(&line, \"%-*.*s\", widths[x], widths[x], text);\n }\n table_print_table_line__(&line);\n }\ndiff --git a/lib/table.h b/lib/table.h\nindex fee36897f81f..f1221716a8f3 100644\n--- a/lib/table.h\n+++ b/lib/table.h\n@@ -78,21 +78,24 @@ struct table_style {\n enum cell_format cell_format; /* CF_*. */\n bool headings; /* Include headings? */\n int json_flags; /* CF_JSON: Flags for json_to_string(). */\n+ int max_column_width; /* CF_STRING: Limit for column width. */\n };\n \n-#define TABLE_STYLE_DEFAULT { TF_LIST, CF_STRING, true, JSSF_SORT }\n+#define TABLE_STYLE_DEFAULT { TF_LIST, CF_STRING, true, JSSF_SORT, 0 }\n \n #define TABLE_OPTION_ENUMS \\\n OPT_NO_HEADINGS, \\\n OPT_PRETTY, \\\n- OPT_BARE\n+ OPT_BARE, \\\n+ OPT_MAX_COLUMN_WIDTH\n \n #define TABLE_LONG_OPTIONS \\\n {\"format\", required_argument, NULL, 'f'}, \\\n {\"data\", required_argument, NULL, 'd'}, \\\n {\"no-headings\", no_argument, NULL, OPT_NO_HEADINGS}, \\\n {\"pretty\", no_argument, NULL, OPT_PRETTY}, \\\n- {\"bare\", no_argument, NULL, OPT_BARE}\n+ {\"bare\", no_argument, NULL, OPT_BARE}, \\\n+ {\"max-column-width\", required_argument, NULL, OPT_MAX_COLUMN_WIDTH}\n \n #define TABLE_OPTION_HANDLERS(STYLE) \\\n case 'f': \\\n@@ -115,6 +118,10 @@ struct table_style {\n (STYLE)->format = TF_LIST; \\\n (STYLE)->cell_format = CF_BARE; \\\n (STYLE)->headings = false; \\\n+ break; \\\n+ \\\n+ case OPT_MAX_COLUMN_WIDTH: \\\n+ (STYLE)->max_column_width = atoi(optarg); \\\n break;\n \n void table_parse_format(struct table_style *, const char *format);\ndiff --git a/lib/table.man b/lib/table.man\nindex 2b38741105d5..bec8292c6862 100644\n--- a/lib/table.man\n+++ b/lib/table.man\n@@ -69,3 +69,8 @@ This option does not affect JSON in tables, which is always printed\n compactly.\n .IP \"\\fB\\-\\-bare\\fR\"\n Equivalent to \\fB\\-\\-format=list \\-\\-data=bare \\-\\-no\\-headings\\fR.\n+.IP \"\\fB\\-\\-max\\-column-width=\\fIn\\fR\"\n+For table output only, limits the width of any column in the output to\n+\\fIn\\fR columns. Longer cell data is truncated to fit, as necessary.\n+Columns are always wide enough to display the column names, if the\n+heading row is printed.\n", "prefixes": [ "ovs-dev", "RFC", "28/52" ] }