From patchwork Mon Jan 15 23:09:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 10165423 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 04895602C2 for ; Mon, 15 Jan 2018 23:09:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EA45E20416 for ; Mon, 15 Jan 2018 23:09:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE1E8262AE; Mon, 15 Jan 2018 23:09:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B4E820416 for ; Mon, 15 Jan 2018 23:09:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750750AbeAOXJp (ORCPT ); Mon, 15 Jan 2018 18:09:45 -0500 Received: from mail-wm0-f65.google.com ([74.125.82.65]:37457 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750740AbeAOXJo (ORCPT ); Mon, 15 Jan 2018 18:09:44 -0500 Received: by mail-wm0-f65.google.com with SMTP id v71so4980655wmv.2 for ; Mon, 15 Jan 2018 15:09:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=q8Oo4I8ZA1su2xC4Zh1s4gv/HpA91qLygGH8SgxMC2w=; b=PZUYTIDBBkxnT5nEDMJmTu8ezJUlsVOEf+7E1pZ6TLfQ8MV+NhKeu02O/W4uWWbRro de7FO73xFv/CC44Hus/MWyNieHuxMjIXQnLve8Fjjx2RwLi47v2MYHzpRWd/sbJQHsjV IL9iNq/tcYnCIc/8U5bJiBPtpj6MEo12BzpDrazzWVT0xAMAH+9D9SIrxxm29MmhOpje J7qAaqpTWMtfDE1TslESWsVbWhaH6kmIbi1Elxg3MraBALrL5EhK4w+koHyPi6alYQK1 sSNKp7AhH4hUY9AN/IE9IuDHrh0Wk5pFiVknzPOVRLvT1KMGIUodsRemlAaxzNVZyZWi DCeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=q8Oo4I8ZA1su2xC4Zh1s4gv/HpA91qLygGH8SgxMC2w=; b=AMfOOnAipypbIq4ANp1ih5IZhZdpvAURPiKOMv3qqceGO3tB0iKurMQTAJKoNfRAA6 3s/8lAF/9Mqk+k0Y+S34c3aXQbjYqmAYXQc4aPve7I6AwjxLrd5A392tX3uobVb3/st4 K+QdLNbclBbilovd58Zh8bYIIln7Wy0A9CoeDmsvdhhyTYwntRcyUEw3byQZLS47/C3w ME7DSpx00VpX8wnKsANFpc4uZ8KiPH7BsILZkemY1sNgxm28vtaAO8gnh5t4BuYAnU/3 vXYHarQOeZDkHB/pL4yHEZk/9ebeFce6QR/5piQMdXKpVERJo7X+xe++25WosAHgIIwf +WQg== X-Gm-Message-State: AKwxytd+gv4J9yRxVwRiHcfpfs5ORVf3xqVhaz0xp1ZlETiqORVnZN3n 6dCQ+WMAfrjDc9Z4GymyjhcteQ== X-Google-Smtp-Source: ACJfBotW5ZsNwtWGQvb4WP5tZxXFZeyR530k4PvHnryxrrf5cdYsEuHXq05KlTXcKSDB9T6q/a+YNQ== X-Received: by 10.28.58.200 with SMTP id h191mr13210093wma.79.1516057783302; Mon, 15 Jan 2018 15:09:43 -0800 (PST) Received: from localhost.localdomain ([85.119.94.113]) by smtp.gmail.com with ESMTPSA id r5sm941524wrr.1.2018.01.15.15.09.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jan 2018 15:09:42 -0800 (PST) From: Petr Vorel To: linux-kbuild@vger.kernel.org Cc: Petr Vorel , Paul Bolle , Masahiro Yamada Subject: [PATCH v4 1/1] kconfig: menuconfig make "Selected by:" and "Depends on:" readable Date: Tue, 16 Jan 2018 00:09:30 +0100 Message-Id: <20180115230930.8723-1-petr.vorel@gmail.com> X-Mailer: git-send-email 2.15.1 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP rev_dep expressions can get rather unwieldy, especially if a symbol is selected by more than a handful of other symbols. I.e. it's possible to have near endless expressions like: A && B && !C || D || F && (G || H) || [...] Chop these expressions into actually readable chunks: - A && B && !C - D - F && (G || H) - [...] I.e. transform the top level OR tokens into newlines and prepend each line with a minus. This makes the "Selected by:" blurb much easier to read. For consistency the same is done for "Depends on:" although the problem isn't that bad for it. This is done only if there is more than one top level OR. This also prevents trimming too long lines. Based on idea from Paul Bolle. Reported-by: Paul Bolle Signed-off-by: Petr Vorel Acked-by: Randy Dunlap Tested-by: Randy Dunlap --- Tested on search USB and General setup -> Kernel compression mode (Gzip) -> Help. Changes v3->v4: * Add split also for "Depends on:". This is done for consistency (reported by Masahiro Yamada). I didn't consider other symbols which call expr_gstr_print() as reasonable candidates (i.e. "Implies:" and "Range : "). * Add new line and hyphen only when there are more top level OR than one. --- scripts/kconfig/expr.c | 16 +++++++++++++--- scripts/kconfig/menu.c | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index cbf4996dd9c1..4b4309b59349 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1070,6 +1070,8 @@ struct expr *expr_simplify_unmet_dep(struct expr *e1, struct expr *e2) return expr_get_leftmost_symbol(ret); } +static int print_level = 0; + void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) { if (!e) { @@ -1077,8 +1079,11 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * return; } - if (expr_compare_type(prevtoken, e->type) > 0) + if (expr_compare_type(prevtoken, e->type) > 0) { + print_level++; fn(data, NULL, "("); + } + switch (e->type) { case E_SYMBOL: if (e->left.sym->name) @@ -1126,7 +1131,10 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * break; case E_OR: expr_print(e->left.expr, fn, data, E_OR); - fn(data, NULL, " || "); + if (print_level == 0) + fn(data, NULL, "\n - "); + else + fn(data, NULL, " || "); expr_print(e->right.expr, fn, data, E_OR); break; case E_AND: @@ -1156,8 +1164,10 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * break; } } - if (expr_compare_type(prevtoken, e->type) > 0) + if (expr_compare_type(prevtoken, e->type) > 0) { + print_level--; fn(data, NULL, ")"); + } } static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index e9357931b47d..579ed9df1409 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -668,6 +668,8 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, prop->menu->lineno); if (!expr_is_yes(prop->visible.expr)) { str_append(r, _(" Depends on: ")); + if (prop->visible.expr->type == E_OR) + str_append(r, "\n - "); expr_gstr_print(prop->visible.expr, r); str_append(r, "\n"); } @@ -676,6 +678,8 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym, get_symbol_props_str(r, sym, P_SELECT, _(" Selects: ")); if (sym->rev_dep.expr) { str_append(r, _(" Selected by: ")); + if (sym->rev_dep.expr->type == E_OR) + str_append(r, "\n - "); expr_gstr_print(sym->rev_dep.expr, r); str_append(r, "\n"); }