Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 1, 2024
1 parent d8f125e commit f1984cd
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .gitpicker.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
"user": "torvalds",
"repo": "linux",
"branch": "9f16d5e6f220661f73b36a4be1b21575651d8833",
"branch": "cfd47302ac64b595beb0a67a337b81942146448a",
"data": [
{
"root": "scripts/kconfig",
Expand Down
1 change: 1 addition & 0 deletions lkc_proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ bool sym_string_valid(struct symbol *sym, const char *newval);
bool sym_string_within_range(struct symbol *sym, const char *str);
bool sym_set_string_value(struct symbol *sym, const char *newval);
bool sym_is_changeable(const struct symbol *sym);
struct menu *sym_get_prompt_menu(const struct symbol *sym);
struct menu *sym_get_choice_menu(const struct symbol *sym);
const char * sym_get_string_value(struct symbol *sym);

Expand Down
28 changes: 5 additions & 23 deletions parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
int cdebug = PRINTD;

static void yyerror(const char *err);
static void zconfprint(const char *err, ...);
static void zconf_error(const char *err, ...);
static bool zconf_endtoken(const char *tokenname,
const char *expected_tokenname);
Expand Down Expand Up @@ -183,7 +182,7 @@ menuconfig_stmt: menuconfig_entry_start config_option_list
if (current_entry->prompt)
current_entry->prompt->type = P_MENU;
else
zconfprint("warning: menuconfig statement without prompt");
zconf_error("menuconfig statement without prompt");
printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno);
};

Expand Down Expand Up @@ -293,12 +292,6 @@ choice_option: T_PROMPT T_WORD_QUOTE if_expr T_EOL
printd(DEBUG_PARSE, "%s:%d:prompt\n", cur_filename, cur_lineno);
};

choice_option: T_BOOL T_WORD_QUOTE if_expr T_EOL
{
menu_add_prompt(P_PROMPT, $2, $3);
printd(DEBUG_PARSE, "%s:%d:bool\n", cur_filename, cur_lineno);
};

choice_option: T_DEFAULT nonconst_symbol if_expr T_EOL
{
menu_add_symbol(P_DEFAULT, $2, $3);
Expand Down Expand Up @@ -408,14 +401,14 @@ help: help_start T_HELPTEXT
{
if (current_entry->help) {
free(current_entry->help);
zconfprint("warning: '%s' defined with more than one help text -- only the last one will be used",
current_entry->sym->name ?: "<choice>");
zconf_error("'%s' defined with more than one help text",
current_entry->sym->name ?: "<choice>");
}

/* Is the help text empty or all whitespace? */
if ($2[strspn($2, " \f\n\r\t\v")] == '\0')
zconfprint("warning: '%s' defined with blank help text",
current_entry->sym->name ?: "<choice>");
zconf_error("'%s' defined with blank help text",
current_entry->sym->name ?: "<choice>");

current_entry->help = $2;
};
Expand Down Expand Up @@ -598,17 +591,6 @@ static bool zconf_endtoken(const char *tokenname,
return true;
}

static void zconfprint(const char *err, ...)
{
va_list ap;

fprintf(stderr, "%s:%d: ", cur_filename, cur_lineno);
va_start(ap, err);
vfprintf(stderr, err, ap);
va_end(ap);
fprintf(stderr, "\n");
}

static void zconf_error(const char *err, ...)
{
va_list ap;
Expand Down
26 changes: 19 additions & 7 deletions symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ const char *sym_type_name(enum symbol_type type)
return "???";
}

/**
* sym_get_prompt_menu - get the menu entry with a prompt
*
* @sym: a symbol pointer
*
* Return: the menu entry with a prompt.
*/
struct menu *sym_get_prompt_menu(const struct symbol *sym)
{
struct menu *m;

list_for_each_entry(m, &sym->menus, link)
if (m->prompt)
return m;

return NULL;
}

/**
* sym_get_choice_menu - get the parent choice menu if present
*
Expand All @@ -80,18 +98,12 @@ const char *sym_type_name(enum symbol_type type)
struct menu *sym_get_choice_menu(const struct symbol *sym)
{
struct menu *menu = NULL;
struct menu *m;

/*
* Choice members must have a prompt. Find a menu entry with a prompt,
* and assume it resides inside a choice block.
*/
list_for_each_entry(m, &sym->menus, link)
if (m->prompt) {
menu = m;
break;
}

menu = sym_get_prompt_menu(sym);
if (!menu)
return NULL;

Expand Down

0 comments on commit f1984cd

Please sign in to comment.