History

kconfig: move prompt handling to menu_add_prompt() from menu_add_prop()

menu_add_prompt() is the only function that calls menu_add_prop() with non-NULL prompt. So, the code inside the if-conditional block of menu_add_prop() can be moved to menu_add_prompt().

Masahiro Yamada committed 6 years ago

Commit 024352f1 parent 1be6e791 file · +34 −36Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/kconfig/menu.c+34−36
@@ -132,53 +132,51 @@ static struct property *menu_add_prop(enum prop_type type, char *prompt, struct · 131 unmodified lines
132132 prop->expr = expr;
133133 prop->visible.expr = dep;
134134
135− if (prompt) {
136− if (isspace(*prompt)) {
137− prop_warn(prop, "leading whitespace ignored");
138− while (isspace(*prompt))
139− prompt++;
140− }
141− if (current_entry->prompt)
142− prop_warn(prop, "prompt redefined");
135+ return prop;
136+}
143137
144− /* Apply all upper menus' visibilities to actual prompts. */
145− if(type == P_PROMPT) {
146− struct menu *menu = current_entry;
138+struct property *menu_add_prompt(enum prop_type type, char *prompt,
139+ struct expr *dep)
140+{
141+ struct property *prop = menu_add_prop(type, prompt, NULL, dep);
147142
148− while ((menu = menu->parent) != NULL) {
149− struct expr *dup_expr;
143+ if (isspace(*prompt)) {
144+ prop_warn(prop, "leading whitespace ignored");
145+ while (isspace(*prompt))
146+ prompt++;
147+ }
148+ if (current_entry->prompt)
149+ prop_warn(prop, "prompt redefined");
150150
151− if (!menu->visibility)
152− continue;
153− /*
154− * Do not add a reference to the
155− * menu's visibility expression but
156− * use a copy of it. Otherwise the
157− * expression reduction functions
158− * will modify expressions that have
159− * multiple references which can
160− * cause unwanted side effects.
161− */
162− dup_expr = expr_copy(menu->visibility);
151+ /* Apply all upper menus' visibilities to actual prompts. */
152+ if (type == P_PROMPT) {
153+ struct menu *menu = current_entry;
163154
164− prop->visible.expr
165− = expr_alloc_and(prop->visible.expr,
166− dup_expr);
167− }
168− }
155+ while ((menu = menu->parent) != NULL) {
156+ struct expr *dup_expr;
169157
170− current_entry->prompt = prop;
158+ if (!menu->visibility)
159+ continue;
160+ /*
161+ * Do not add a reference to the menu's visibility
162+ * expression but use a copy of it. Otherwise the
163+ * expression reduction functions will modify
164+ * expressions that have multiple references which
165+ * can cause unwanted side effects.
166+ */
167+ dup_expr = expr_copy(menu->visibility);
168+
169+ prop->visible.expr = expr_alloc_and(prop->visible.expr,
170+ dup_expr);
171+ }
171172 }
173+
174+ current_entry->prompt = prop;
172175 prop->text = prompt;
173176
174177 return prop;
175178 }
176179
177−struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep)
178−{
179− return menu_add_prop(type, prompt, NULL, dep);
180−}
181−
182180 void menu_add_visibility(struct expr *expr)
183181 {
184182 current_entry->visibility = expr_alloc_and(current_entry->visibility,

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t