Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

+75 -107
+2 -2
scripts/kconfig/Makefile
··· 174 174 175 175 # nconf: Used for the nconfig target based on ncurses 176 176 hostprogs += nconf 177 - nconf-objs := nconf.o nconf.gui.o $(common-objs) 177 + nconf-objs := nconf.o nconf.gui.o mnconf-common.o $(common-objs) 178 178 179 179 HOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs) 180 180 HOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags) ··· 187 187 hostprogs += mconf 188 188 lxdialog := $(addprefix lxdialog/, \ 189 189 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) 190 - mconf-objs := mconf.o $(lxdialog) $(common-objs) 190 + mconf-objs := mconf.o $(lxdialog) mnconf-common.o $(common-objs) 191 191 192 192 HOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs) 193 193 $(foreach f, mconf.o $(lxdialog), \
+1 -53
scripts/kconfig/mconf.c
··· 21 21 22 22 #include "lkc.h" 23 23 #include "lxdialog/dialog.h" 24 + #include "mnconf-common.h" 24 25 25 26 static const char mconf_readme[] = 26 27 "Overview\n" ··· 287 286 static int show_all_options; 288 287 static int save_and_exit; 289 288 static int silent; 290 - static int jump_key_char; 291 289 292 290 static void conf(struct menu *menu, struct menu *active_menu); 293 291 ··· 376 376 377 377 show_helptext(menu_get_prompt(menu), str_get(&help)); 378 378 str_free(&help); 379 - } 380 - 381 - struct search_data { 382 - struct list_head *head; 383 - struct menu *target; 384 - }; 385 - 386 - static int next_jump_key(int key) 387 - { 388 - if (key < '1' || key > '9') 389 - return '1'; 390 - 391 - key++; 392 - 393 - if (key > '9') 394 - key = '1'; 395 - 396 - return key; 397 - } 398 - 399 - static int handle_search_keys(int key, size_t start, size_t end, void *_data) 400 - { 401 - struct search_data *data = _data; 402 - struct jump_key *pos; 403 - int index = 0; 404 - 405 - if (key < '1' || key > '9') 406 - return 0; 407 - 408 - list_for_each_entry(pos, data->head, entries) { 409 - index = next_jump_key(index); 410 - 411 - if (pos->offset < start) 412 - continue; 413 - 414 - if (pos->offset >= end) 415 - break; 416 - 417 - if (key == index) { 418 - data->target = pos->target; 419 - return 1; 420 - } 421 - } 422 - 423 - return 0; 424 - } 425 - 426 - int get_jump_key_char(void) 427 - { 428 - jump_key_char = next_jump_key(jump_key_char); 429 - 430 - return jump_key_char; 431 379 } 432 380 433 381 static void search_conf(void)
+53
scripts/kconfig/mnconf-common.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + #include "expr.h" 3 + #include "list.h" 4 + #include "mnconf-common.h" 5 + 6 + int jump_key_char; 7 + 8 + int next_jump_key(int key) 9 + { 10 + if (key < '1' || key > '9') 11 + return '1'; 12 + 13 + key++; 14 + 15 + if (key > '9') 16 + key = '1'; 17 + 18 + return key; 19 + } 20 + 21 + int handle_search_keys(int key, size_t start, size_t end, void *_data) 22 + { 23 + struct search_data *data = _data; 24 + struct jump_key *pos; 25 + int index = 0; 26 + 27 + if (key < '1' || key > '9') 28 + return 0; 29 + 30 + list_for_each_entry(pos, data->head, entries) { 31 + index = next_jump_key(index); 32 + 33 + if (pos->offset < start) 34 + continue; 35 + 36 + if (pos->offset >= end) 37 + break; 38 + 39 + if (key == index) { 40 + data->target = pos->target; 41 + return 1; 42 + } 43 + } 44 + 45 + return 0; 46 + } 47 + 48 + int get_jump_key_char(void) 49 + { 50 + jump_key_char = next_jump_key(jump_key_char); 51 + 52 + return jump_key_char; 53 + }
+18
scripts/kconfig/mnconf-common.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-only */ 2 + #ifndef MNCONF_COMMON_H 3 + #define MNCONF_COMMON_H 4 + 5 + #include <stddef.h> 6 + 7 + struct search_data { 8 + struct list_head *head; 9 + struct menu *target; 10 + }; 11 + 12 + extern int jump_key_char; 13 + 14 + int next_jump_key(int key); 15 + int handle_search_keys(int key, size_t start, size_t end, void *_data); 16 + int get_jump_key_char(void); 17 + 18 + #endif /* MNCONF_COMMON_H */
+1 -52
scripts/kconfig/nconf.c
··· 12 12 #include <stdlib.h> 13 13 14 14 #include "lkc.h" 15 + #include "mnconf-common.h" 15 16 #include "nconf.h" 16 17 #include <ctype.h> 17 18 ··· 280 279 281 280 static char *dialog_input_result; 282 281 static int dialog_input_result_len; 283 - static int jump_key_char; 284 282 285 283 static void selected_conf(struct menu *menu, struct menu *active_menu); 286 284 static void conf(struct menu *menu); ··· 691 691 return 0; 692 692 } 693 693 694 - struct search_data { 695 - struct list_head *head; 696 - struct menu *target; 697 - }; 698 - 699 - static int next_jump_key(int key) 700 - { 701 - if (key < '1' || key > '9') 702 - return '1'; 703 - 704 - key++; 705 - 706 - if (key > '9') 707 - key = '1'; 708 - 709 - return key; 710 - } 711 - 712 - static int handle_search_keys(int key, size_t start, size_t end, void *_data) 713 - { 714 - struct search_data *data = _data; 715 - struct jump_key *pos; 716 - int index = 0; 717 - 718 - if (key < '1' || key > '9') 719 - return 0; 720 - 721 - list_for_each_entry(pos, data->head, entries) { 722 - index = next_jump_key(index); 723 - 724 - if (pos->offset < start) 725 - continue; 726 - 727 - if (pos->offset >= end) 728 - break; 729 - 730 - if (key == index) { 731 - data->target = pos->target; 732 - return 1; 733 - } 734 - } 735 - 736 - return 0; 737 - } 738 - 739 - int get_jump_key_char(void) 740 - { 741 - jump_key_char = next_jump_key(jump_key_char); 742 - 743 - return jump_key_char; 744 - } 745 694 746 695 static void search_conf(void) 747 696 {