-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kconfig: factor out common code shared by mconf and nconf
Separate out the duplicated code to mnconf-common.c. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
- Loading branch information
Masahiro Yamada
committed
Dec 10, 2023
1 parent
d821f8a
commit 6c07fd8
Showing
5 changed files
with
75 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
#include "expr.h" | ||
#include "list.h" | ||
#include "mnconf-common.h" | ||
|
||
int jump_key_char; | ||
|
||
int next_jump_key(int key) | ||
{ | ||
if (key < '1' || key > '9') | ||
return '1'; | ||
|
||
key++; | ||
|
||
if (key > '9') | ||
key = '1'; | ||
|
||
return key; | ||
} | ||
|
||
int handle_search_keys(int key, size_t start, size_t end, void *_data) | ||
{ | ||
struct search_data *data = _data; | ||
struct jump_key *pos; | ||
int index = 0; | ||
|
||
if (key < '1' || key > '9') | ||
return 0; | ||
|
||
list_for_each_entry(pos, data->head, entries) { | ||
index = next_jump_key(index); | ||
|
||
if (pos->offset < start) | ||
continue; | ||
|
||
if (pos->offset >= end) | ||
break; | ||
|
||
if (key == index) { | ||
data->target = pos->target; | ||
return 1; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
int get_jump_key_char(void) | ||
{ | ||
jump_key_char = next_jump_key(jump_key_char); | ||
|
||
return jump_key_char; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
#ifndef MNCONF_COMMON_H | ||
#define MNCONF_COMMON_H | ||
|
||
#include <stddef.h> | ||
|
||
struct search_data { | ||
struct list_head *head; | ||
struct menu *target; | ||
}; | ||
|
||
extern int jump_key_char; | ||
|
||
int next_jump_key(int key); | ||
int handle_search_keys(int key, size_t start, size_t end, void *_data); | ||
int get_jump_key_char(void); | ||
|
||
#endif /* MNCONF_COMMON_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters