Commit a7d4f58e authored by Masahiro Yamada's avatar Masahiro Yamada
Browse files

kconfig: fix missing '# end of' for empty menu



Currently, "# end of ..." is inserted when the menu goes back to its
parent.

Hence, an empty menu:

  menu "Foo"
  endmenu

... ends up with unbalanced menu comments, like this:

  #
  # Foo
  #

Let's close the menu comments properly:

  #
  # Foo
  #
  # end of Foo

Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 868653f4
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -903,19 +903,20 @@ int conf_write(const char *name)
			menu = menu->list;
			continue;
		}
		if (menu->next)
			menu = menu->next;
		else while ((menu = menu->parent)) {
			if (!menu->sym && menu_is_visible(menu) &&
			    menu != &rootmenu) {
				str = menu_get_prompt(menu);
				fprintf(out, "# end of %s\n", str);

end_check:
		if (!menu->sym && menu_is_visible(menu) && menu != &rootmenu &&
		    menu->prompt->type == P_MENU) {
			fprintf(out, "# end of %s\n", menu_get_prompt(menu));
			need_newline = true;
		}

		if (menu->next) {
			menu = menu->next;
				break;
			}
		} else {
			menu = menu->parent;
			if (menu)
				goto end_check;
		}
	}
	fclose(out);