From patchwork Fri Feb 16 18:38:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 10225407 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 4AB96601E7 for ; Fri, 16 Feb 2018 18:45:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 384982966B for ; Fri, 16 Feb 2018 18:45:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AF2B2966D; Fri, 16 Feb 2018 18:45:12 +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_SIGNED, 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 9F3C82966B for ; Fri, 16 Feb 2018 18:45:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751303AbeBPSpJ (ORCPT ); Fri, 16 Feb 2018 13:45:09 -0500 Received: from conuserg-07.nifty.com ([210.131.2.74]:57777 "EHLO conuserg-07.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752694AbeBPSlT (ORCPT ); Fri, 16 Feb 2018 13:41:19 -0500 Received: from grover.sesame (FL1-125-199-20-195.osk.mesh.ad.jp [125.199.20.195]) (authenticated) by conuserg-07.nifty.com with ESMTP id w1GIdBTG013418; Sat, 17 Feb 2018 03:39:25 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com w1GIdBTG013418 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518806365; bh=6ZKZUGrGKtv5i28aZcukMehAO6Ar8s8CMYxI7ksDKCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JcgYXRTIPxugz1or4Pb3XhIBHdnssIOxB6d9rp1yBZxo6Bs2EYjln4XMK1Ppna0Y7 uR5HfWMtykmkarYJ4LqXhxHlwfYdevmTM2WicLScwo5ZFCh+85JwM2QtRoepLntglQ 7bC8aOjfnqXeME/Awsk96O/bONvwe9VkmRPlYTOUKQtspug6dON3Wd5ifIAW1B2PUs ml4qhWXTyUdoDecllqocICvBc0YRUD1SCc9iZ4QOXdB4cJGJrdCdDcDhZ5SB1u8Ter 6SbVM8M/VecHm/HpYDqjgWiXgY477Zu3ywquy9XyeZ1VBtAHaTNtV56piIEtDsdB2N zwpDM6O8s0EfA== X-Nifty-SrcIP: [125.199.20.195] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org, Linus Torvalds Cc: Greg Kroah-Hartman , Arnd Bergmann , Kees Cook , Randy Dunlap , Ulf Magnusson , Sam Ravnborg , Michal Marek , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 13/23] kconfig: expand environments/functions in (main)menu, comment, prompt Date: Sat, 17 Feb 2018 03:38:41 +0900 Message-Id: <1518806331-7101-14-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> References: <1518806331-7101-1-git-send-email-yamada.masahiro@socionext.com> 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 Expand the prompt passed to menu_add_prompt(). This affects 'mainmenu', 'menu', 'prompt', 'comment'. Another good thing is, I am fixing the memory leak for the case without mainmenu. The 'mainmenu' should be independent of user configuration. So, its prompt can be expanded in the first parse phase. The ugly hack for no_mainmenu_stmt is gone. Signed-off-by: Masahiro Yamada --- scripts/kconfig/menu.c | 2 +- scripts/kconfig/zconf.y | 30 +++++++++++------------------- 2 files changed, 12 insertions(+), 20 deletions(-) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index a9d0ccc..462b995 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -176,7 +176,7 @@ static struct property *menu_add_prop(enum prop_type type, char *prompt, struct struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep) { - return menu_add_prop(type, prompt, NULL, dep); + return menu_add_prop(type, expand_string_value(prompt), NULL, dep); } void menu_add_visibility(struct expr *expr) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 19452b6..ef006be 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -110,28 +110,16 @@ static struct menu *current_menu, *current_entry; %% input: nl start | start; -start: mainmenu_stmt stmt_list | no_mainmenu_stmt stmt_list; +start: mainmenu_stmt stmt_list | stmt_list; /* mainmenu entry */ mainmenu_stmt: T_MAINMENU prompt nl { menu_add_prompt(P_MENU, $2, NULL); + free($2); }; -/* Default main menu, if there's no mainmenu entry */ - -no_mainmenu_stmt: /* empty */ -{ - /* - * Hack: Keep the main menu title on the heap so we can safely free it - * later regardless of whether it comes from the 'prompt' in - * mainmenu_stmt or here - */ - menu_add_prompt(P_MENU, xstrdup("Linux Kernel Configuration"), NULL); -}; - - stmt_list: /* empty */ | stmt_list common_stmt @@ -217,6 +205,7 @@ config_option: T_TYPE prompt_stmt_opt T_EOL config_option: T_PROMPT prompt if_expr T_EOL { menu_add_prompt(P_PROMPT, $2, $3); + free($2); printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); }; @@ -316,6 +305,7 @@ choice_option_list: choice_option: T_PROMPT prompt if_expr T_EOL { menu_add_prompt(P_PROMPT, $2, $3); + free($2); printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); }; @@ -385,6 +375,7 @@ menu: T_MENU prompt T_EOL { menu_add_entry(NULL); menu_add_prompt(P_MENU, $2, NULL); + free($2); printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); }; @@ -424,6 +415,7 @@ comment: T_COMMENT prompt T_EOL { menu_add_entry(NULL); menu_add_prompt(P_COMMENT, $2, NULL); + free($2); printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); }; @@ -489,6 +481,7 @@ prompt_stmt_opt: | prompt if_expr { menu_add_prompt(P_PROMPT, $1, $2); + free($1); }; prompt: T_WORD @@ -536,7 +529,6 @@ word_opt: /* empty */ { $$ = NULL; } void conf_parse(const char *name) { - const char *tmp; struct symbol *sym; int i; @@ -560,10 +552,10 @@ void conf_parse(const char *name) if (!modules_sym) modules_sym = sym_find( "n" ); - tmp = rootmenu.prompt->text; - rootmenu.prompt->text = _(rootmenu.prompt->text); - rootmenu.prompt->text = expand_string_value(rootmenu.prompt->text); - free((char*)tmp); + if (!menu_has_prompt(&rootmenu)) { + current_entry = &rootmenu; + menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); + } menu_finalize(&rootmenu); for_all_symbols(i, sym) {