diff mbox series

[v4,05/31] kconfig: remove string expansion for mainmenu after yyparse()

Message ID 1526537830-22606-6-git-send-email-yamada.masahiro@socionext.com
State Superseded
Headers show
Series kconfig: move compiler capability tests to Kconfig | expand

Commit Message

Masahiro Yamada May 17, 2018, 6:16 a.m. UTC
Now that environments are expanded in the lexer, conf_parse() does
not need to expand them explicitly.

The hack introduced by commit 0724a7c32a54 ("kconfig: Don't leak
main menus during parsing") can go away.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>

---

Changes in v4: None
Changes in v3: None
Changes in v2:
  - Simplify the patch.  Just remove the text expansion.

 scripts/kconfig/zconf.y | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

-- 
2.7.4

Comments

Sam Ravnborg May 20, 2018, 2:39 p.m. UTC | #1
On Thu, May 17, 2018 at 03:16:44PM +0900, Masahiro Yamada wrote:
> Now that environments are expanded in the lexer, conf_parse() does

> not need to expand them explicitly.

> 

> The hack introduced by commit 0724a7c32a54 ("kconfig: Don't leak

> main menus during parsing") can go away.

> 

> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>

> Reviewed-by: Kees Cook <keescook@chromium.org>

> Reviewed-by: Ulf Magnusson <ulfalizer@gmail.com>

> ---

> 

> Changes in v4: None

> Changes in v3: None

> Changes in v2:

>   - Simplify the patch.  Just remove the text expansion.

> 

>  scripts/kconfig/zconf.y | 24 +++++-------------------

>  1 file changed, 5 insertions(+), 19 deletions(-)

> 

> diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y

> index 3a4a0fa..22e318c 100644

> --- a/scripts/kconfig/zconf.y

> +++ b/scripts/kconfig/zconf.y

> @@ -109,7 +109,7 @@ 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 */

>  

> @@ -118,19 +118,6 @@ mainmenu_stmt: T_MAINMENU prompt nl

>  	menu_add_prompt(P_MENU, $2, NULL);

>  };

>  

> -/* 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

> @@ -528,7 +515,6 @@ word_opt: /* empty */			{ $$ = NULL; }

>  

>  void conf_parse(const char *name)

>  {

> -	const char *tmp;

>  	struct symbol *sym;

>  	int i;

>  

> @@ -544,10 +530,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 = sym_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);


Could this be something less specific?
To help the other users of kconfig out is the wild.

For example:

	menu_add_prompt(P_MENU, _("Main menu"), NULL);

Note, the added _() to make the text translateable.

	Sam
Masahiro Yamada May 21, 2018, 5:38 a.m. UTC | #2
2018-05-20 23:39 GMT+09:00 Sam Ravnborg <sam@ravnborg.org>:

>> @@ -544,10 +530,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 = sym_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);

>

> Could this be something less specific?

> To help the other users of kconfig out is the wild.

>

> For example:

>

>         menu_add_prompt(P_MENU, _("Main menu"), NULL);



OK, but this should be done as a separate work.

I am keeping the current string "Linux Kernel Configuration"



> Note, the added _() to make the text translateable.

>


Hmm, I just wonder how much helpful gettext things are...

Rather, it looks maintenance burden to me.
Once we add messages, it is difficult to change.


-- 
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 3a4a0fa..22e318c 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -109,7 +109,7 @@  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 */
 
@@ -118,19 +118,6 @@  mainmenu_stmt: T_MAINMENU prompt nl
 	menu_add_prompt(P_MENU, $2, NULL);
 };
 
-/* 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
@@ -528,7 +515,6 @@  word_opt: /* empty */			{ $$ = NULL; }
 
 void conf_parse(const char *name)
 {
-	const char *tmp;
 	struct symbol *sym;
 	int i;
 
@@ -544,10 +530,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 = sym_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) {