Received: by 10.223.185.116 with SMTP id b49csp1045248wrg; Fri, 16 Feb 2018 11:23:54 -0800 (PST) X-Google-Smtp-Source: AH8x227tmaOqFhYuQbEqWNCJbFHawKaYimQ+dIj9dT5l++LQZxZkUfE2lOkLvgXgYiJLc0SkEYys X-Received: by 10.98.208.3 with SMTP id p3mr7062153pfg.8.1518809034530; Fri, 16 Feb 2018 11:23:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518809034; cv=none; d=google.com; s=arc-20160816; b=X84QeM3Y6DhxgPe6OA7w5l6q5rE3Jme7TXQWdWYsPsLeJGZXlgR6eofw5gWab9ut0d 3PmF4FzJf/PwBNYQsnV9IQZEz1qDm7ZHuj0qaZqv/853XFxyUQSU36We8jx9MjrUSKWF H5A4AzrOwZmTqJ2r4ZcDWil3PYN3VFcMxl+h+PFd0+QTbi/Spo5Uu17XiytzG9lmRoz3 TJpPkCedkJee7qGPHiQWhGZSyoxMBhKiWhqvxZOsqw0UEAZ1yuI1M1Tox6xVzFS+078K LKkBxWSI1Llg//8rX4/jjoQaySEkqTh0tCldWUL3r+WjnazUBpnX68vg8U8fposXK4Aj ciNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter :arc-authentication-results; bh=6ZKZUGrGKtv5i28aZcukMehAO6Ar8s8CMYxI7ksDKCU=; b=DSR7oAoyLffSTeodSaXjq+ZnTNllLoUZYDyV237GbkO4Tq/iaak3opHp0OTBrR/cv4 lcRkxRgxjNM10ljnhDznspMTNXGj44AoUWyQ265fzrWGoQgdvckwBXWokt7hnD0z4WoU BrHCC5OfuC0V/BFggusTlkaz+Vt2zcYsfwwLOOjA/S8p9/a9WRulg2oGRwrxlUSB6DWF pcyLLNodrvg3uT1c5qj4md9d0ZqbbaVdUn+TO9BgZ0EGyTIjlG8ebBzPEs9AD+aqf9F3 keR0LvQ8CwGeVCqzalSe31YpHWmwUt/e6SWFzNp+7Rk1/eKHxYMhJirrq01zxie1HNmn ENjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=JcgYXRTI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y5-v6si123478pln.274.2018.02.16.11.23.40; Fri, 16 Feb 2018 11:23:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=JcgYXRTI; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753676AbeBPSpS (ORCPT + 99 others); Fri, 16 Feb 2018 13:45:18 -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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) { -- 2.7.4