diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-30 03:17:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-30 03:17:06 -0400 |
commit | 1d3fe4a75b691285cded47c9f1a91b30d25287b0 (patch) | |
tree | d967425c1e961133ff0df98b986e81fae9162ba7 /scripts | |
parent | 664a41b8a91bf78a01a751e15175e0008977685a (diff) | |
parent | 2a11c8ea20bf850b3a2c60db8c2e7497d28aba99 (diff) |
Merge branch 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6
* 'kconfig' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6: (25 commits)
kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE()
xconfig: Abort close if configuration cannot be saved
kconfig: fix missing "0x" prefix from S_HEX symbol in autoconf.h
kconfig/nconf: remove useless conditionnal
kconfig/nconf: prevent segfault on empty menu
kconfig/nconf: use the generic menu_get_ext_help()
nconfig: Avoid Wunused-but-set warning
kconfig/conf: mark xfgets() private
kconfig: remove pending prototypes for kconfig_load()
kconfig/conf: add command line options' description
kconfig/conf: reduce the scope of `defconfig_file'
kconfig: use calloc() for expr allocation
kconfig: introduce specialized printer
kconfig: do not overwrite symbol direct dependency in assignment
kconfig/gconf: silent missing prototype warnings
kconfig/gconf: kill deadcode
kconfig: nuke LKC_DIRECT_LINK cruft
kconfig: nuke reference to SWIG
kconfig: add missing <stdlib.h> inclusion
kconfig: add missing <ctype.h> inclusion
...
Fix up conflicts in scripts/kconfig/Makefile
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/kconfig/Makefile | 23 | ||||
-rw-r--r-- | scripts/kconfig/conf.c | 48 | ||||
-rw-r--r-- | scripts/kconfig/confdata.c | 295 | ||||
-rw-r--r-- | scripts/kconfig/expr.c | 13 | ||||
-rw-r--r-- | scripts/kconfig/expr.h | 3 | ||||
-rw-r--r-- | scripts/kconfig/gconf.c | 38 | ||||
-rw-r--r-- | scripts/kconfig/kconfig_load.c | 35 | ||||
-rw-r--r-- | scripts/kconfig/kxgettext.c | 1 | ||||
-rw-r--r-- | scripts/kconfig/lkc.h | 16 | ||||
-rw-r--r-- | scripts/kconfig/lkc_proto.h | 1 | ||||
-rw-r--r-- | scripts/kconfig/mconf.c | 2 | ||||
-rw-r--r-- | scripts/kconfig/menu.c | 5 | ||||
-rw-r--r-- | scripts/kconfig/nconf.c | 30 | ||||
-rw-r--r-- | scripts/kconfig/qconf.cc | 17 | ||||
-rw-r--r-- | scripts/kconfig/qconf.h | 2 | ||||
-rw-r--r-- | scripts/kconfig/symbol.c | 47 | ||||
-rw-r--r-- | scripts/kconfig/util.c | 2 | ||||
-rw-r--r-- | scripts/kconfig/zconf.l | 1 | ||||
-rw-r--r-- | scripts/kconfig/zconf.lex.c_shipped | 1 | ||||
-rw-r--r-- | scripts/kconfig/zconf.tab.c_shipped | 1 | ||||
-rw-r--r-- | scripts/kconfig/zconf.y | 1 |
21 files changed, 323 insertions, 259 deletions
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 0b4276c047b2..82d2eb285b70 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile | |||
@@ -170,8 +170,8 @@ mconf-objs := mconf.o zconf.tab.o $(lxdialog) | |||
170 | nconf-objs := nconf.o zconf.tab.o nconf.gui.o | 170 | nconf-objs := nconf.o zconf.tab.o nconf.gui.o |
171 | kxgettext-objs := kxgettext.o zconf.tab.o | 171 | kxgettext-objs := kxgettext.o zconf.tab.o |
172 | qconf-cxxobjs := qconf.o | 172 | qconf-cxxobjs := qconf.o |
173 | qconf-objs := kconfig_load.o zconf.tab.o | 173 | qconf-objs := zconf.tab.o |
174 | gconf-objs := gconf.o kconfig_load.o zconf.tab.o | 174 | gconf-objs := gconf.o zconf.tab.o |
175 | 175 | ||
176 | hostprogs-y := conf | 176 | hostprogs-y := conf |
177 | 177 | ||
@@ -203,7 +203,7 @@ ifeq ($(gconf-target),1) | |||
203 | hostprogs-y += gconf | 203 | hostprogs-y += gconf |
204 | endif | 204 | endif |
205 | 205 | ||
206 | clean-files := lkc_defs.h qconf.moc .tmp_qtcheck .tmp_gtkcheck | 206 | clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck |
207 | clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h | 207 | clean-files += zconf.tab.c zconf.lex.c zconf.hash.c gconf.glade.h |
208 | clean-files += mconf qconf gconf nconf | 208 | clean-files += mconf qconf gconf nconf |
209 | clean-files += config.pot linux.pot | 209 | clean-files += config.pot linux.pot |
@@ -226,12 +226,12 @@ HOSTCFLAGS_zconf.tab.o := -I$(src) | |||
226 | LEX_PREFIX_zconf := zconf | 226 | LEX_PREFIX_zconf := zconf |
227 | YACC_PREFIX_zconf := zconf | 227 | YACC_PREFIX_zconf := zconf |
228 | 228 | ||
229 | HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl | 229 | HOSTLOADLIBES_qconf = $(KC_QT_LIBS) |
230 | HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK | 230 | HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) |
231 | 231 | ||
232 | HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` -ldl | 232 | HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` |
233 | HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ | 233 | HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ |
234 | -D LKC_DIRECT_LINK | 234 | -Wno-missing-prototypes |
235 | 235 | ||
236 | HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) | 236 | HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) |
237 | 237 | ||
@@ -321,18 +321,11 @@ endif | |||
321 | 321 | ||
322 | $(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c | 322 | $(obj)/zconf.tab.o: $(obj)/zconf.lex.c $(obj)/zconf.hash.c |
323 | 323 | ||
324 | $(obj)/kconfig_load.o: $(obj)/lkc_defs.h | 324 | $(obj)/qconf.o: $(obj)/qconf.moc |
325 | |||
326 | $(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h | ||
327 | |||
328 | $(obj)/gconf.o: $(obj)/lkc_defs.h | ||
329 | 325 | ||
330 | $(obj)/%.moc: $(src)/%.h | 326 | $(obj)/%.moc: $(src)/%.h |
331 | $(KC_QT_MOC) -i $< -o $@ | 327 | $(KC_QT_MOC) -i $< -o $@ |
332 | 328 | ||
333 | $(obj)/lkc_defs.h: $(src)/lkc_proto.h | ||
334 | $(Q)sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' | ||
335 | |||
336 | # Extract gconf menu items for I18N support | 329 | # Extract gconf menu items for I18N support |
337 | $(obj)/gconf.glade.h: $(obj)/gconf.glade | 330 | $(obj)/gconf.glade.h: $(obj)/gconf.glade |
338 | $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \ | 331 | $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \ |
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 006ad817cd5f..f208f900ed3a 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
@@ -14,11 +14,11 @@ | |||
14 | #include <sys/stat.h> | 14 | #include <sys/stat.h> |
15 | #include <sys/time.h> | 15 | #include <sys/time.h> |
16 | 16 | ||
17 | #define LKC_DIRECT_LINK | ||
18 | #include "lkc.h" | 17 | #include "lkc.h" |
19 | 18 | ||
20 | static void conf(struct menu *menu); | 19 | static void conf(struct menu *menu); |
21 | static void check_conf(struct menu *menu); | 20 | static void check_conf(struct menu *menu); |
21 | static void xfgets(char *str, int size, FILE *in); | ||
22 | 22 | ||
23 | enum input_mode { | 23 | enum input_mode { |
24 | oldaskconfig, | 24 | oldaskconfig, |
@@ -35,8 +35,6 @@ enum input_mode { | |||
35 | oldnoconfig, | 35 | oldnoconfig, |
36 | } input_mode = oldaskconfig; | 36 | } input_mode = oldaskconfig; |
37 | 37 | ||
38 | char *defconfig_file; | ||
39 | |||
40 | static int indent = 1; | 38 | static int indent = 1; |
41 | static int valid_stdin = 1; | 39 | static int valid_stdin = 1; |
42 | static int sync_kconfig; | 40 | static int sync_kconfig; |
@@ -106,6 +104,7 @@ static int conf_askvalue(struct symbol *sym, const char *def) | |||
106 | return 0; | 104 | return 0; |
107 | } | 105 | } |
108 | check_stdin(); | 106 | check_stdin(); |
107 | /* fall through */ | ||
109 | case oldaskconfig: | 108 | case oldaskconfig: |
110 | fflush(stdout); | 109 | fflush(stdout); |
111 | xfgets(line, 128, stdin); | 110 | xfgets(line, 128, stdin); |
@@ -150,6 +149,7 @@ static int conf_string(struct menu *menu) | |||
150 | def = NULL; | 149 | def = NULL; |
151 | break; | 150 | break; |
152 | } | 151 | } |
152 | /* fall through */ | ||
153 | default: | 153 | default: |
154 | line[strlen(line)-1] = 0; | 154 | line[strlen(line)-1] = 0; |
155 | def = line; | 155 | def = line; |
@@ -304,6 +304,7 @@ static int conf_choice(struct menu *menu) | |||
304 | break; | 304 | break; |
305 | } | 305 | } |
306 | check_stdin(); | 306 | check_stdin(); |
307 | /* fall through */ | ||
307 | case oldaskconfig: | 308 | case oldaskconfig: |
308 | fflush(stdout); | 309 | fflush(stdout); |
309 | xfgets(line, 128, stdin); | 310 | xfgets(line, 128, stdin); |
@@ -369,6 +370,7 @@ static void conf(struct menu *menu) | |||
369 | check_conf(menu); | 370 | check_conf(menu); |
370 | return; | 371 | return; |
371 | } | 372 | } |
373 | /* fall through */ | ||
372 | case P_COMMENT: | 374 | case P_COMMENT: |
373 | prompt = menu_get_prompt(menu); | 375 | prompt = menu_get_prompt(menu); |
374 | if (prompt) | 376 | if (prompt) |
@@ -456,10 +458,30 @@ static struct option long_opts[] = { | |||
456 | {NULL, 0, NULL, 0} | 458 | {NULL, 0, NULL, 0} |
457 | }; | 459 | }; |
458 | 460 | ||
461 | static void conf_usage(const char *progname) | ||
462 | { | ||
463 | |||
464 | printf("Usage: %s [option] <kconfig-file>\n", progname); | ||
465 | printf("[option] is _one_ of the following:\n"); | ||
466 | printf(" --listnewconfig List new options\n"); | ||
467 | printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); | ||
468 | printf(" --oldconfig Update a configuration using a provided .config as base\n"); | ||
469 | printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n"); | ||
470 | printf(" --oldnoconfig Same as silentoldconfig but set new symbols to no\n"); | ||
471 | printf(" --defconfig <file> New config with default defined in <file>\n"); | ||
472 | printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n"); | ||
473 | printf(" --allnoconfig New config where all options are answered with no\n"); | ||
474 | printf(" --allyesconfig New config where all options are answered with yes\n"); | ||
475 | printf(" --allmodconfig New config where all options are answered with mod\n"); | ||
476 | printf(" --alldefconfig New config with all symbols set to default\n"); | ||
477 | printf(" --randconfig New config with random answer to all options\n"); | ||
478 | } | ||
479 | |||
459 | int main(int ac, char **av) | 480 | int main(int ac, char **av) |
460 | { | 481 | { |
482 | const char *progname = av[0]; | ||
461 | int opt; | 483 | int opt; |
462 | const char *name; | 484 | const char *name, *defconfig_file = NULL /* gcc uninit */; |
463 | struct stat tmpstat; | 485 | struct stat tmpstat; |
464 | 486 | ||
465 | setlocale(LC_ALL, ""); | 487 | setlocale(LC_ALL, ""); |
@@ -491,14 +513,24 @@ int main(int ac, char **av) | |||
491 | srand(seed); | 513 | srand(seed); |
492 | break; | 514 | break; |
493 | } | 515 | } |
516 | case oldaskconfig: | ||
517 | case oldconfig: | ||
518 | case allnoconfig: | ||
519 | case allyesconfig: | ||
520 | case allmodconfig: | ||
521 | case alldefconfig: | ||
522 | case listnewconfig: | ||
523 | case oldnoconfig: | ||
524 | break; | ||
494 | case '?': | 525 | case '?': |
495 | fprintf(stderr, _("See README for usage info\n")); | 526 | conf_usage(progname); |
496 | exit(1); | 527 | exit(1); |
497 | break; | 528 | break; |
498 | } | 529 | } |
499 | } | 530 | } |
500 | if (ac == optind) { | 531 | if (ac == optind) { |
501 | printf(_("%s: Kconfig file missing\n"), av[0]); | 532 | printf(_("%s: Kconfig file missing\n"), av[0]); |
533 | conf_usage(progname); | ||
502 | exit(1); | 534 | exit(1); |
503 | } | 535 | } |
504 | name = av[optind]; | 536 | name = av[optind]; |
@@ -641,13 +673,11 @@ int main(int ac, char **av) | |||
641 | } | 673 | } |
642 | return 0; | 674 | return 0; |
643 | } | 675 | } |
676 | |||
644 | /* | 677 | /* |
645 | * Helper function to facilitate fgets() by Jean Sacren. | 678 | * Helper function to facilitate fgets() by Jean Sacren. |
646 | */ | 679 | */ |
647 | void xfgets(str, size, in) | 680 | void xfgets(char *str, int size, FILE *in) |
648 | char *str; | ||
649 | int size; | ||
650 | FILE *in; | ||
651 | { | 681 | { |
652 | if (fgets(str, size, in) == NULL) | 682 | if (fgets(str, size, in) == NULL) |
653 | fprintf(stderr, "\nError in reading or end of file.\n"); | 683 | fprintf(stderr, "\nError in reading or end of file.\n"); |
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 2bafd9a7c8da..59b667cae5f3 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
@@ -7,13 +7,13 @@ | |||
7 | #include <ctype.h> | 7 | #include <ctype.h> |
8 | #include <errno.h> | 8 | #include <errno.h> |
9 | #include <fcntl.h> | 9 | #include <fcntl.h> |
10 | #include <stdarg.h> | ||
10 | #include <stdio.h> | 11 | #include <stdio.h> |
11 | #include <stdlib.h> | 12 | #include <stdlib.h> |
12 | #include <string.h> | 13 | #include <string.h> |
13 | #include <time.h> | 14 | #include <time.h> |
14 | #include <unistd.h> | 15 | #include <unistd.h> |
15 | 16 | ||
16 | #define LKC_DIRECT_LINK | ||
17 | #include "lkc.h" | 17 | #include "lkc.h" |
18 | 18 | ||
19 | static void conf_warning(const char *fmt, ...) | 19 | static void conf_warning(const char *fmt, ...) |
@@ -128,6 +128,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) | |||
128 | sym->flags |= def_flags; | 128 | sym->flags |= def_flags; |
129 | break; | 129 | break; |
130 | } | 130 | } |
131 | /* fall through */ | ||
131 | case S_BOOLEAN: | 132 | case S_BOOLEAN: |
132 | if (p[0] == 'y') { | 133 | if (p[0] == 'y') { |
133 | sym->def[def].tri = yes; | 134 | sym->def[def].tri = yes; |
@@ -140,7 +141,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) | |||
140 | break; | 141 | break; |
141 | } | 142 | } |
142 | conf_warning("symbol value '%s' invalid for %s", p, sym->name); | 143 | conf_warning("symbol value '%s' invalid for %s", p, sym->name); |
143 | break; | 144 | return 1; |
144 | case S_OTHER: | 145 | case S_OTHER: |
145 | if (*p != '"') { | 146 | if (*p != '"') { |
146 | for (p2 = p; *p2 && !isspace(*p2); p2++) | 147 | for (p2 = p; *p2 && !isspace(*p2); p2++) |
@@ -148,6 +149,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) | |||
148 | sym->type = S_STRING; | 149 | sym->type = S_STRING; |
149 | goto done; | 150 | goto done; |
150 | } | 151 | } |
152 | /* fall through */ | ||
151 | case S_STRING: | 153 | case S_STRING: |
152 | if (*p++ != '"') | 154 | if (*p++ != '"') |
153 | break; | 155 | break; |
@@ -162,6 +164,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) | |||
162 | conf_warning("invalid string found"); | 164 | conf_warning("invalid string found"); |
163 | return 1; | 165 | return 1; |
164 | } | 166 | } |
167 | /* fall through */ | ||
165 | case S_INT: | 168 | case S_INT: |
166 | case S_HEX: | 169 | case S_HEX: |
167 | done: | 170 | done: |
@@ -237,6 +240,7 @@ load: | |||
237 | case S_STRING: | 240 | case S_STRING: |
238 | if (sym->def[def].val) | 241 | if (sym->def[def].val) |
239 | free(sym->def[def].val); | 242 | free(sym->def[def].val); |
243 | /* fall through */ | ||
240 | default: | 244 | default: |
241 | sym->def[def].val = NULL; | 245 | sym->def[def].val = NULL; |
242 | sym->def[def].tri = no; | 246 | sym->def[def].tri = no; |
@@ -363,6 +367,7 @@ int conf_read(const char *name) | |||
363 | break; | 367 | break; |
364 | if (!sym_is_choice(sym)) | 368 | if (!sym_is_choice(sym)) |
365 | goto sym_ok; | 369 | goto sym_ok; |
370 | /* fall through */ | ||
366 | default: | 371 | default: |
367 | if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val)) | 372 | if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val)) |
368 | goto sym_ok; | 373 | goto sym_ok; |
@@ -417,64 +422,202 @@ int conf_read(const char *name) | |||
417 | return 0; | 422 | return 0; |
418 | } | 423 | } |
419 | 424 | ||
420 | /* Write a S_STRING */ | 425 | /* |
421 | static void conf_write_string(bool headerfile, const char *name, | 426 | * Kconfig configuration printer |
422 | const char *str, FILE *out) | 427 | * |
428 | * This printer is used when generating the resulting configuration after | ||
429 | * kconfig invocation and `defconfig' files. Unset symbol might be omitted by | ||
430 | * passing a non-NULL argument to the printer. | ||
431 | * | ||
432 | */ | ||
433 | static void | ||
434 | kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) | ||
423 | { | 435 | { |
424 | int l; | 436 | |
425 | if (headerfile) | 437 | switch (sym->type) { |
426 | fprintf(out, "#define %s%s \"", CONFIG_, name); | 438 | case S_BOOLEAN: |
427 | else | 439 | case S_TRISTATE: |
428 | fprintf(out, "%s%s=\"", CONFIG_, name); | 440 | if (*value == 'n') { |
429 | 441 | bool skip_unset = (arg != NULL); | |
430 | while (1) { | 442 | |
431 | l = strcspn(str, "\"\\"); | 443 | if (!skip_unset) |
444 | fprintf(fp, "# %s%s is not set\n", | ||
445 | CONFIG_, sym->name); | ||
446 | return; | ||
447 | } | ||
448 | break; | ||
449 | default: | ||
450 | break; | ||
451 | } | ||
452 | |||
453 | fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value); | ||
454 | } | ||
455 | |||
456 | static void | ||
457 | kconfig_print_comment(FILE *fp, const char *value, void *arg) | ||
458 | { | ||
459 | const char *p = value; | ||
460 | size_t l; | ||
461 | |||
462 | for (;;) { | ||
463 | l = strcspn(p, "\n"); | ||
464 | fprintf(fp, "#"); | ||
432 | if (l) { | 465 | if (l) { |
433 | xfwrite(str, l, 1, out); | 466 | fprintf(fp, " "); |
434 | str += l; | 467 | fwrite(p, l, 1, fp); |
468 | p += l; | ||
435 | } | 469 | } |
436 | if (!*str) | 470 | fprintf(fp, "\n"); |
471 | if (*p++ == '\0') | ||
437 | break; | 472 | break; |
438 | fprintf(out, "\\%c", *str++); | ||
439 | } | 473 | } |
440 | fputs("\"\n", out); | ||
441 | } | 474 | } |
442 | 475 | ||
443 | static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no) | 476 | static struct conf_printer kconfig_printer_cb = |
477 | { | ||
478 | .print_symbol = kconfig_print_symbol, | ||
479 | .print_comment = kconfig_print_comment, | ||
480 | }; | ||
481 | |||
482 | /* | ||
483 | * Header printer | ||
484 | * | ||
485 | * This printer is used when generating the `include/generated/autoconf.h' file. | ||
486 | */ | ||
487 | static void | ||
488 | header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) | ||
444 | { | 489 | { |
445 | const char *str; | ||
446 | 490 | ||
447 | switch (sym->type) { | 491 | switch (sym->type) { |
448 | case S_BOOLEAN: | 492 | case S_BOOLEAN: |
449 | case S_TRISTATE: | 493 | case S_TRISTATE: { |
450 | switch (sym_get_tristate_value(sym)) { | 494 | const char *suffix = ""; |
451 | case no: | 495 | |
452 | if (write_no) | 496 | switch (*value) { |
453 | fprintf(out, "# %s%s is not set\n", | 497 | case 'n': |
454 | CONFIG_, sym->name); | ||
455 | break; | ||
456 | case mod: | ||
457 | fprintf(out, "%s%s=m\n", CONFIG_, sym->name); | ||
458 | break; | ||
459 | case yes: | ||
460 | fprintf(out, "%s%s=y\n", CONFIG_, sym->name); | ||
461 | break; | 498 | break; |
499 | case 'm': | ||
500 | suffix = "_MODULE"; | ||
501 | /* fall through */ | ||
502 | default: | ||
503 | fprintf(fp, "#define %s%s%s 1\n", | ||
504 | CONFIG_, sym->name, suffix); | ||
462 | } | 505 | } |
506 | /* | ||
507 | * Generate the __enabled_CONFIG_* and | ||
508 | * __enabled_CONFIG_*_MODULE macros for use by the | ||
509 | * IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is | ||
510 | * generated even for booleans so that the IS_ENABLED() macro | ||
511 | * works. | ||
512 | */ | ||
513 | fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n", | ||
514 | sym->name, (*value == 'y')); | ||
515 | fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n", | ||
516 | sym->name, (*value == 'm')); | ||
463 | break; | 517 | break; |
464 | case S_STRING: | 518 | } |
465 | conf_write_string(false, sym->name, sym_get_string_value(sym), out); | 519 | case S_HEX: { |
520 | const char *prefix = ""; | ||
521 | |||
522 | if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X')) | ||
523 | prefix = "0x"; | ||
524 | fprintf(fp, "#define %s%s %s%s\n", | ||
525 | CONFIG_, sym->name, prefix, value); | ||
466 | break; | 526 | break; |
467 | case S_HEX: | 527 | } |
528 | case S_STRING: | ||
468 | case S_INT: | 529 | case S_INT: |
469 | str = sym_get_string_value(sym); | 530 | fprintf(fp, "#define %s%s %s\n", |
470 | fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str); | 531 | CONFIG_, sym->name, value); |
532 | break; | ||
533 | default: | ||
471 | break; | 534 | break; |
535 | } | ||
536 | |||
537 | } | ||
538 | |||
539 | static void | ||
540 | header_print_comment(FILE *fp, const char *value, void *arg) | ||
541 | { | ||
542 | const char *p = value; | ||
543 | size_t l; | ||
544 | |||
545 | fprintf(fp, "/*\n"); | ||
546 | for (;;) { | ||
547 | l = strcspn(p, "\n"); | ||
548 | fprintf(fp, " *"); | ||
549 | if (l) { | ||
550 | fprintf(fp, " "); | ||
551 | fwrite(p, l, 1, fp); | ||
552 | p += l; | ||
553 | } | ||
554 | fprintf(fp, "\n"); | ||
555 | if (*p++ == '\0') | ||
556 | break; | ||
557 | } | ||
558 | fprintf(fp, " */\n"); | ||
559 | } | ||
560 | |||
561 | static struct conf_printer header_printer_cb = | ||
562 | { | ||
563 | .print_symbol = header_print_symbol, | ||
564 | .print_comment = header_print_comment, | ||
565 | }; | ||
566 | |||
567 | /* | ||
568 | * Tristate printer | ||
569 | * | ||
570 | * This printer is used when generating the `include/config/tristate.conf' file. | ||
571 | */ | ||
572 | static void | ||
573 | tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) | ||
574 | { | ||
575 | |||
576 | if (sym->type == S_TRISTATE && *value != 'n') | ||
577 | fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value)); | ||
578 | } | ||
579 | |||
580 | static struct conf_printer tristate_printer_cb = | ||
581 | { | ||
582 | .print_symbol = tristate_print_symbol, | ||
583 | .print_comment = kconfig_print_comment, | ||
584 | }; | ||
585 | |||
586 | static void conf_write_symbol(FILE *fp, struct symbol *sym, | ||
587 | struct conf_printer *printer, void *printer_arg) | ||
588 | { | ||
589 | const char *str; | ||
590 | |||
591 | switch (sym->type) { | ||
472 | case S_OTHER: | 592 | case S_OTHER: |
473 | case S_UNKNOWN: | 593 | case S_UNKNOWN: |
474 | break; | 594 | break; |
595 | case S_STRING: | ||
596 | str = sym_get_string_value(sym); | ||
597 | str = sym_escape_string_value(str); | ||
598 | printer->print_symbol(fp, sym, str, printer_arg); | ||
599 | free((void *)str); | ||
600 | break; | ||
601 | default: | ||
602 | str = sym_get_string_value(sym); | ||
603 | printer->print_symbol(fp, sym, str, printer_arg); | ||
475 | } | 604 | } |
476 | } | 605 | } |
477 | 606 | ||
607 | static void | ||
608 | conf_write_heading(FILE *fp, struct conf_printer *printer, void *printer_arg) | ||
609 | { | ||
610 | char buf[256]; | ||
611 | |||
612 | snprintf(buf, sizeof(buf), | ||
613 | "\n" | ||
614 | "Automatically generated file; DO NOT EDIT.\n" | ||
615 | "%s\n", | ||
616 | rootmenu.prompt->text); | ||
617 | |||
618 | printer->print_comment(fp, buf, printer_arg); | ||
619 | } | ||
620 | |||
478 | /* | 621 | /* |
479 | * Write out a minimal config. | 622 | * Write out a minimal config. |
480 | * All values that has default values are skipped as this is redundant. | 623 | * All values that has default values are skipped as this is redundant. |
@@ -531,7 +674,7 @@ int conf_write_defconfig(const char *filename) | |||
531 | goto next_menu; | 674 | goto next_menu; |
532 | } | 675 | } |
533 | } | 676 | } |
534 | conf_write_symbol(sym, out, true); | 677 | conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); |
535 | } | 678 | } |
536 | next_menu: | 679 | next_menu: |
537 | if (menu->list != NULL) { | 680 | if (menu->list != NULL) { |
@@ -596,11 +739,7 @@ int conf_write(const char *name) | |||
596 | if (!out) | 739 | if (!out) |
597 | return 1; | 740 | return 1; |
598 | 741 | ||
599 | fprintf(out, _("#\n" | 742 | conf_write_heading(out, &kconfig_printer_cb, NULL); |
600 | "# Automatically generated make config: don't edit\n" | ||
601 | "# %s\n" | ||
602 | "#\n"), | ||
603 | rootmenu.prompt->text); | ||
604 | 743 | ||
605 | if (!conf_get_changed()) | 744 | if (!conf_get_changed()) |
606 | sym_clear_all_valid(); | 745 | sym_clear_all_valid(); |
@@ -621,8 +760,8 @@ int conf_write(const char *name) | |||
621 | if (!(sym->flags & SYMBOL_WRITE)) | 760 | if (!(sym->flags & SYMBOL_WRITE)) |
622 | goto next; | 761 | goto next; |
623 | sym->flags &= ~SYMBOL_WRITE; | 762 | sym->flags &= ~SYMBOL_WRITE; |
624 | /* Write config symbol to file */ | 763 | |
625 | conf_write_symbol(sym, out, true); | 764 | conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); |
626 | } | 765 | } |
627 | 766 | ||
628 | next: | 767 | next: |
@@ -771,7 +910,6 @@ out: | |||
771 | int conf_write_autoconf(void) | 910 | int conf_write_autoconf(void) |
772 | { | 911 | { |
773 | struct symbol *sym; | 912 | struct symbol *sym; |
774 | const char *str; | ||
775 | const char *name; | 913 | const char *name; |
776 | FILE *out, *tristate, *out_h; | 914 | FILE *out, *tristate, *out_h; |
777 | int i; | 915 | int i; |
@@ -800,68 +938,23 @@ int conf_write_autoconf(void) | |||
800 | return 1; | 938 | return 1; |
801 | } | 939 | } |
802 | 940 | ||
803 | fprintf(out, "#\n" | 941 | conf_write_heading(out, &kconfig_printer_cb, NULL); |
804 | "# Automatically generated make config: don't edit\n" | 942 | |
805 | "# %s\n" | 943 | conf_write_heading(tristate, &tristate_printer_cb, NULL); |
806 | "#\n", | 944 | |
807 | rootmenu.prompt->text); | 945 | conf_write_heading(out_h, &header_printer_cb, NULL); |
808 | fprintf(tristate, "#\n" | ||
809 | "# Automatically generated - do not edit\n" | ||
810 | "\n"); | ||
811 | fprintf(out_h, "/*\n" | ||
812 | " * Automatically generated C config: don't edit\n" | ||
813 | " * %s\n" | ||
814 | " */\n", | ||
815 | rootmenu.prompt->text); | ||
816 | 946 | ||
817 | for_all_symbols(i, sym) { | 947 | for_all_symbols(i, sym) { |
818 | sym_calc_value(sym); | 948 | sym_calc_value(sym); |
819 | if (!(sym->flags & SYMBOL_WRITE) || !sym->name) | 949 | if (!(sym->flags & SYMBOL_WRITE) || !sym->name) |
820 | continue; | 950 | continue; |
821 | 951 | ||
822 | /* write symbol to config file */ | 952 | /* write symbol to auto.conf, tristate and header files */ |
823 | conf_write_symbol(sym, out, false); | 953 | conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1); |
824 | 954 | ||
825 | /* update autoconf and tristate files */ | 955 | conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1); |
826 | switch (sym->type) { | 956 | |
827 | case S_BOOLEAN: | 957 | conf_write_symbol(out_h, sym, &header_printer_cb, NULL); |
828 | case S_TRISTATE: | ||
829 | switch (sym_get_tristate_value(sym)) { | ||
830 | case no: | ||
831 | break; | ||
832 | case mod: | ||
833 | fprintf(tristate, "%s%s=M\n", | ||
834 | CONFIG_, sym->name); | ||
835 | fprintf(out_h, "#define %s%s_MODULE 1\n", | ||
836 | CONFIG_, sym->name); | ||
837 | break; | ||
838 | case yes: | ||
839 | if (sym->type == S_TRISTATE) | ||
840 | fprintf(tristate,"%s%s=Y\n", | ||
841 | CONFIG_, sym->name); | ||
842 | fprintf(out_h, "#define %s%s 1\n", | ||
843 | CONFIG_, sym->name); | ||
844 | break; | ||
845 | } | ||
846 | break; | ||
847 | case S_STRING: | ||
848 | conf_write_string(true, sym->name, sym_get_string_value(sym), out_h); | ||
849 | break; | ||
850 | case S_HEX: | ||
851 | str = sym_get_string_value(sym); | ||
852 | if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { | ||
853 | fprintf(out_h, "#define %s%s 0x%s\n", | ||
854 | CONFIG_, sym->name, str); | ||
855 | break; | ||
856 | } | ||
857 | case S_INT: | ||
858 | str = sym_get_string_value(sym); | ||
859 | fprintf(out_h, "#define %s%s %s\n", | ||
860 | CONFIG_, sym->name, str); | ||
861 | break; | ||
862 | default: | ||
863 | break; | ||
864 | } | ||
865 | } | 958 | } |
866 | fclose(out); | 959 | fclose(out); |
867 | fclose(tristate); | 960 | fclose(tristate); |
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 001003452f68..290ce41f8ba4 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c | |||
@@ -7,15 +7,13 @@ | |||
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <string.h> | 8 | #include <string.h> |
9 | 9 | ||
10 | #define LKC_DIRECT_LINK | ||
11 | #include "lkc.h" | 10 | #include "lkc.h" |
12 | 11 | ||
13 | #define DEBUG_EXPR 0 | 12 | #define DEBUG_EXPR 0 |
14 | 13 | ||
15 | struct expr *expr_alloc_symbol(struct symbol *sym) | 14 | struct expr *expr_alloc_symbol(struct symbol *sym) |
16 | { | 15 | { |
17 | struct expr *e = malloc(sizeof(*e)); | 16 | struct expr *e = calloc(1, sizeof(*e)); |
18 | memset(e, 0, sizeof(*e)); | ||
19 | e->type = E_SYMBOL; | 17 | e->type = E_SYMBOL; |
20 | e->left.sym = sym; | 18 | e->left.sym = sym; |
21 | return e; | 19 | return e; |
@@ -23,8 +21,7 @@ struct expr *expr_alloc_symbol(struct symbol *sym) | |||
23 | 21 | ||
24 | struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) | 22 | struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) |
25 | { | 23 | { |
26 | struct expr *e = malloc(sizeof(*e)); | 24 | struct expr *e = calloc(1, sizeof(*e)); |
27 | memset(e, 0, sizeof(*e)); | ||
28 | e->type = type; | 25 | e->type = type; |
29 | e->left.expr = ce; | 26 | e->left.expr = ce; |
30 | return e; | 27 | return e; |
@@ -32,8 +29,7 @@ struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) | |||
32 | 29 | ||
33 | struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) | 30 | struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) |
34 | { | 31 | { |
35 | struct expr *e = malloc(sizeof(*e)); | 32 | struct expr *e = calloc(1, sizeof(*e)); |
36 | memset(e, 0, sizeof(*e)); | ||
37 | e->type = type; | 33 | e->type = type; |
38 | e->left.expr = e1; | 34 | e->left.expr = e1; |
39 | e->right.expr = e2; | 35 | e->right.expr = e2; |
@@ -42,8 +38,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e | |||
42 | 38 | ||
43 | struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) | 39 | struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) |
44 | { | 40 | { |
45 | struct expr *e = malloc(sizeof(*e)); | 41 | struct expr *e = calloc(1, sizeof(*e)); |
46 | memset(e, 0, sizeof(*e)); | ||
47 | e->type = type; | 42 | e->type = type; |
48 | e->left.sym = s1; | 43 | e->left.sym = s1; |
49 | e->right.sym = s2; | 44 | e->right.sym = s2; |
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 16bfae2d3217..80fce57080cc 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
@@ -172,8 +172,6 @@ struct menu { | |||
172 | #define MENU_CHANGED 0x0001 | 172 | #define MENU_CHANGED 0x0001 |
173 | #define MENU_ROOT 0x0002 | 173 | #define MENU_ROOT 0x0002 |
174 | 174 | ||
175 | #ifndef SWIG | ||
176 | |||
177 | extern struct file *file_list; | 175 | extern struct file *file_list; |
178 | extern struct file *current_file; | 176 | extern struct file *current_file; |
179 | struct file *lookup_file(const char *name); | 177 | struct file *lookup_file(const char *name); |
@@ -218,7 +216,6 @@ static inline int expr_is_no(struct expr *e) | |||
218 | { | 216 | { |
219 | return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); | 217 | return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); |
220 | } | 218 | } |
221 | #endif | ||
222 | 219 | ||
223 | #ifdef __cplusplus | 220 | #ifdef __cplusplus |
224 | } | 221 | } |
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index a11d5f7b9eeb..9f4438027df4 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c | |||
@@ -285,8 +285,6 @@ void init_left_tree(void) | |||
285 | static void renderer_edited(GtkCellRendererText * cell, | 285 | static void renderer_edited(GtkCellRendererText * cell, |
286 | const gchar * path_string, | 286 | const gchar * path_string, |
287 | const gchar * new_text, gpointer user_data); | 287 | const gchar * new_text, gpointer user_data); |
288 | static void renderer_toggled(GtkCellRendererToggle * cellrenderertoggle, | ||
289 | gchar * arg1, gpointer user_data); | ||
290 | 288 | ||
291 | void init_right_tree(void) | 289 | void init_right_tree(void) |
292 | { | 290 | { |
@@ -320,8 +318,6 @@ void init_right_tree(void) | |||
320 | "inconsistent", COL_BTNINC, | 318 | "inconsistent", COL_BTNINC, |
321 | "visible", COL_BTNVIS, | 319 | "visible", COL_BTNVIS, |
322 | "radio", COL_BTNRAD, NULL); | 320 | "radio", COL_BTNRAD, NULL); |
323 | /*g_signal_connect(G_OBJECT(renderer), "toggled", | ||
324 | G_CALLBACK(renderer_toggled), NULL); */ | ||
325 | renderer = gtk_cell_renderer_text_new(); | 321 | renderer = gtk_cell_renderer_text_new(); |
326 | gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), | 322 | gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), |
327 | renderer, FALSE); | 323 | renderer, FALSE); |
@@ -888,35 +884,6 @@ static void toggle_sym_value(struct menu *menu) | |||
888 | display_tree_part(); //fixme: keep exp/coll | 884 | display_tree_part(); //fixme: keep exp/coll |
889 | } | 885 | } |
890 | 886 | ||
891 | static void renderer_toggled(GtkCellRendererToggle * cell, | ||
892 | gchar * path_string, gpointer user_data) | ||
893 | { | ||
894 | GtkTreePath *path, *sel_path = NULL; | ||
895 | GtkTreeIter iter, sel_iter; | ||
896 | GtkTreeSelection *sel; | ||
897 | struct menu *menu; | ||
898 | |||
899 | path = gtk_tree_path_new_from_string(path_string); | ||
900 | if (!gtk_tree_model_get_iter(model2, &iter, path)) | ||
901 | return; | ||
902 | |||
903 | sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree2_w)); | ||
904 | if (gtk_tree_selection_get_selected(sel, NULL, &sel_iter)) | ||
905 | sel_path = gtk_tree_model_get_path(model2, &sel_iter); | ||
906 | if (!sel_path) | ||
907 | goto out1; | ||
908 | if (gtk_tree_path_compare(path, sel_path)) | ||
909 | goto out2; | ||
910 | |||
911 | gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1); | ||
912 | toggle_sym_value(menu); | ||
913 | |||
914 | out2: | ||
915 | gtk_tree_path_free(sel_path); | ||
916 | out1: | ||
917 | gtk_tree_path_free(path); | ||
918 | } | ||
919 | |||
920 | static gint column2index(GtkTreeViewColumn * column) | 887 | static gint column2index(GtkTreeViewColumn * column) |
921 | { | 888 | { |
922 | gint i; | 889 | gint i; |
@@ -1172,6 +1139,7 @@ static gchar **fill_row(struct menu *menu) | |||
1172 | row[COL_BTNVIS] = GINT_TO_POINTER(TRUE); | 1139 | row[COL_BTNVIS] = GINT_TO_POINTER(TRUE); |
1173 | if (sym_is_choice(sym)) | 1140 | if (sym_is_choice(sym)) |
1174 | break; | 1141 | break; |
1142 | /* fall through */ | ||
1175 | case S_TRISTATE: | 1143 | case S_TRISTATE: |
1176 | val = sym_get_tristate_value(sym); | 1144 | val = sym_get_tristate_value(sym); |
1177 | switch (val) { | 1145 | switch (val) { |
@@ -1506,10 +1474,6 @@ int main(int ac, char *av[]) | |||
1506 | char *env; | 1474 | char *env; |
1507 | gchar *glade_file; | 1475 | gchar *glade_file; |
1508 | 1476 | ||
1509 | #ifndef LKC_DIRECT_LINK | ||
1510 | kconfig_load(); | ||
1511 | #endif | ||
1512 | |||
1513 | bindtextdomain(PACKAGE, LOCALEDIR); | 1477 | bindtextdomain(PACKAGE, LOCALEDIR); |
1514 | bind_textdomain_codeset(PACKAGE, "UTF-8"); | 1478 | bind_textdomain_codeset(PACKAGE, "UTF-8"); |
1515 | textdomain(PACKAGE); | 1479 | textdomain(PACKAGE); |
diff --git a/scripts/kconfig/kconfig_load.c b/scripts/kconfig/kconfig_load.c deleted file mode 100644 index dbdcaad82325..000000000000 --- a/scripts/kconfig/kconfig_load.c +++ /dev/null | |||
@@ -1,35 +0,0 @@ | |||
1 | #include <dlfcn.h> | ||
2 | #include <stdio.h> | ||
3 | #include <stdlib.h> | ||
4 | |||
5 | #include "lkc.h" | ||
6 | |||
7 | #define P(name,type,arg) type (*name ## _p) arg | ||
8 | #include "lkc_proto.h" | ||
9 | #undef P | ||
10 | |||
11 | void kconfig_load(void) | ||
12 | { | ||
13 | void *handle; | ||
14 | char *error; | ||
15 | |||
16 | handle = dlopen("./libkconfig.so", RTLD_LAZY); | ||
17 | if (!handle) { | ||
18 | handle = dlopen("./scripts/kconfig/libkconfig.so", RTLD_LAZY); | ||
19 | if (!handle) { | ||
20 | fprintf(stderr, "%s\n", dlerror()); | ||
21 | exit(1); | ||
22 | } | ||
23 | } | ||
24 | |||
25 | #define P(name,type,arg) \ | ||
26 | { \ | ||
27 | name ## _p = dlsym(handle, #name); \ | ||
28 | if ((error = dlerror())) { \ | ||
29 | fprintf(stderr, "%s\n", error); \ | ||
30 | exit(1); \ | ||
31 | } \ | ||
32 | } | ||
33 | #include "lkc_proto.h" | ||
34 | #undef P | ||
35 | } | ||
diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c index e9d8e791bf0d..2858738b22d5 100644 --- a/scripts/kconfig/kxgettext.c +++ b/scripts/kconfig/kxgettext.c | |||
@@ -7,7 +7,6 @@ | |||
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <string.h> | 8 | #include <string.h> |
9 | 9 | ||
10 | #define LKC_DIRECT_LINK | ||
11 | #include "lkc.h" | 10 | #include "lkc.h" |
12 | 11 | ||
13 | static char *escape(const char* text, char *bf, int len) | 12 | static char *escape(const char* text, char *bf, int len) |
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index f34a0a9b50f1..b633bdb9f3d4 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
@@ -21,12 +21,7 @@ static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; | |||
21 | extern "C" { | 21 | extern "C" { |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | #ifdef LKC_DIRECT_LINK | ||
25 | #define P(name,type,arg) extern type name arg | 24 | #define P(name,type,arg) extern type name arg |
26 | #else | ||
27 | #include "lkc_defs.h" | ||
28 | #define P(name,type,arg) extern type (*name ## _p) arg | ||
29 | #endif | ||
30 | #include "lkc_proto.h" | 25 | #include "lkc_proto.h" |
31 | #undef P | 26 | #undef P |
32 | 27 | ||
@@ -79,9 +74,6 @@ void zconf_nextfile(const char *name); | |||
79 | int zconf_lineno(void); | 74 | int zconf_lineno(void); |
80 | const char *zconf_curname(void); | 75 | const char *zconf_curname(void); |
81 | 76 | ||
82 | /* conf.c */ | ||
83 | void xfgets(char *str, int size, FILE *in); | ||
84 | |||
85 | /* confdata.c */ | 77 | /* confdata.c */ |
86 | const char *conf_get_configname(void); | 78 | const char *conf_get_configname(void); |
87 | const char *conf_get_autoconfig_name(void); | 79 | const char *conf_get_autoconfig_name(void); |
@@ -90,6 +82,11 @@ void sym_set_change_count(int count); | |||
90 | void sym_add_change_count(int count); | 82 | void sym_add_change_count(int count); |
91 | void conf_set_all_new_symbols(enum conf_def_mode mode); | 83 | void conf_set_all_new_symbols(enum conf_def_mode mode); |
92 | 84 | ||
85 | struct conf_printer { | ||
86 | void (*print_symbol)(FILE *, struct symbol *, const char *, void *); | ||
87 | void (*print_comment)(FILE *, const char *, void *); | ||
88 | }; | ||
89 | |||
93 | /* confdata.c and expr.c */ | 90 | /* confdata.c and expr.c */ |
94 | static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) | 91 | static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) |
95 | { | 92 | { |
@@ -97,9 +94,6 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) | |||
97 | fprintf(stderr, "\nError in writing or end of file.\n"); | 94 | fprintf(stderr, "\nError in writing or end of file.\n"); |
98 | } | 95 | } |
99 | 96 | ||
100 | /* kconfig_load.c */ | ||
101 | void kconfig_load(void); | ||
102 | |||
103 | /* menu.c */ | 97 | /* menu.c */ |
104 | void _menu_init(void); | 98 | void _menu_init(void); |
105 | void menu_warn(struct menu *menu, const char *fmt, ...); | 99 | void menu_warn(struct menu *menu, const char *fmt, ...); |
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 17342fef38b9..47fe9c340f9a 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h | |||
@@ -31,6 +31,7 @@ P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); | |||
31 | P(sym_lookup,struct symbol *,(const char *name, int flags)); | 31 | P(sym_lookup,struct symbol *,(const char *name, int flags)); |
32 | P(sym_find,struct symbol *,(const char *name)); | 32 | P(sym_find,struct symbol *,(const char *name)); |
33 | P(sym_expand_string_value,const char *,(const char *in)); | 33 | P(sym_expand_string_value,const char *,(const char *in)); |
34 | P(sym_escape_string_value, const char *,(const char *in)); | ||
34 | P(sym_re_search,struct symbol **,(const char *pattern)); | 35 | P(sym_re_search,struct symbol **,(const char *pattern)); |
35 | P(sym_type_name,const char *,(enum symbol_type type)); | 36 | P(sym_type_name,const char *,(enum symbol_type type)); |
36 | P(sym_calc_value,void,(struct symbol *sym)); | 37 | P(sym_calc_value,void,(struct symbol *sym)); |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index d433c7a24745..820d2b6800fb 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <unistd.h> | 18 | #include <unistd.h> |
19 | #include <locale.h> | 19 | #include <locale.h> |
20 | 20 | ||
21 | #define LKC_DIRECT_LINK | ||
22 | #include "lkc.h" | 21 | #include "lkc.h" |
23 | #include "lxdialog/dialog.h" | 22 | #include "lxdialog/dialog.h" |
24 | 23 | ||
@@ -845,6 +844,7 @@ int main(int ac, char **av) | |||
845 | "\n\n")); | 844 | "\n\n")); |
846 | return 1; | 845 | return 1; |
847 | } | 846 | } |
847 | /* fall through */ | ||
848 | case -1: | 848 | case -1: |
849 | printf(_("\n\n" | 849 | printf(_("\n\n" |
850 | "*** End of the configuration.\n" | 850 | "*** End of the configuration.\n" |
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 5fdf10dc1d8a..d66008639a43 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c | |||
@@ -3,10 +3,11 @@ | |||
3 | * Released under the terms of the GNU GPL v2.0. | 3 | * Released under the terms of the GNU GPL v2.0. |
4 | */ | 4 | */ |
5 | 5 | ||
6 | #include <ctype.h> | ||
7 | #include <stdarg.h> | ||
6 | #include <stdlib.h> | 8 | #include <stdlib.h> |
7 | #include <string.h> | 9 | #include <string.h> |
8 | 10 | ||
9 | #define LKC_DIRECT_LINK | ||
10 | #include "lkc.h" | 11 | #include "lkc.h" |
11 | 12 | ||
12 | static const char nohelp_text[] = N_( | 13 | static const char nohelp_text[] = N_( |
@@ -350,7 +351,7 @@ void menu_finalize(struct menu *parent) | |||
350 | last_menu->next = NULL; | 351 | last_menu->next = NULL; |
351 | } | 352 | } |
352 | 353 | ||
353 | sym->dir_dep.expr = parent->dep; | 354 | sym->dir_dep.expr = expr_alloc_or(sym->dir_dep.expr, parent->dep); |
354 | } | 355 | } |
355 | for (menu = parent->list; menu; menu = menu->next) { | 356 | for (menu = parent->list; menu; menu = menu->next) { |
356 | if (sym && sym_is_choice(sym) && | 357 | if (sym && sym_is_choice(sym) && |
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 488dd7410787..39ca1f1640ea 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c | |||
@@ -7,7 +7,7 @@ | |||
7 | */ | 7 | */ |
8 | #define _GNU_SOURCE | 8 | #define _GNU_SOURCE |
9 | #include <string.h> | 9 | #include <string.h> |
10 | #define LKC_DIRECT_LINK | 10 | |
11 | #include "lkc.h" | 11 | #include "lkc.h" |
12 | #include "nconf.h" | 12 | #include "nconf.h" |
13 | #include <ctype.h> | 13 | #include <ctype.h> |
@@ -1067,7 +1067,6 @@ static void conf(struct menu *menu) | |||
1067 | struct menu *submenu = 0; | 1067 | struct menu *submenu = 0; |
1068 | const char *prompt = menu_get_prompt(menu); | 1068 | const char *prompt = menu_get_prompt(menu); |
1069 | struct symbol *sym; | 1069 | struct symbol *sym; |
1070 | struct menu *active_menu = NULL; | ||
1071 | int res; | 1070 | int res; |
1072 | int current_index = 0; | 1071 | int current_index = 0; |
1073 | int last_top_row = 0; | 1072 | int last_top_row = 0; |
@@ -1152,13 +1151,9 @@ static void conf(struct menu *menu) | |||
1152 | continue; | 1151 | continue; |
1153 | 1152 | ||
1154 | submenu = (struct menu *) item_data(); | 1153 | submenu = (struct menu *) item_data(); |
1155 | active_menu = (struct menu *)item_data(); | ||
1156 | if (!submenu || !menu_is_visible(submenu)) | 1154 | if (!submenu || !menu_is_visible(submenu)) |
1157 | continue; | 1155 | continue; |
1158 | if (submenu) | 1156 | sym = submenu->sym; |
1159 | sym = submenu->sym; | ||
1160 | else | ||
1161 | sym = NULL; | ||
1162 | 1157 | ||
1163 | switch (res) { | 1158 | switch (res) { |
1164 | case ' ': | 1159 | case ' ': |
@@ -1222,20 +1217,13 @@ static void conf_message_callback(const char *fmt, va_list ap) | |||
1222 | 1217 | ||
1223 | static void show_help(struct menu *menu) | 1218 | static void show_help(struct menu *menu) |
1224 | { | 1219 | { |
1225 | struct gstr help = str_new(); | 1220 | struct gstr help; |
1226 | 1221 | ||
1227 | if (menu && menu->sym && menu_has_help(menu)) { | 1222 | if (!menu) |
1228 | if (menu->sym->name) { | 1223 | return; |
1229 | str_printf(&help, "%s%s:\n\n", CONFIG_, menu->sym->name); | 1224 | |
1230 | str_append(&help, _(menu_get_help(menu))); | 1225 | help = str_new(); |
1231 | str_append(&help, "\n"); | 1226 | menu_get_ext_help(menu, &help); |
1232 | get_symbol_str(&help, menu->sym); | ||
1233 | } else { | ||
1234 | str_append(&help, _(menu_get_help(menu))); | ||
1235 | } | ||
1236 | } else { | ||
1237 | str_append(&help, nohelp_text); | ||
1238 | } | ||
1239 | show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help)); | 1227 | show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help)); |
1240 | str_free(&help); | 1228 | str_free(&help); |
1241 | } | 1229 | } |
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index c2796b866f8f..df274febb3e5 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc | |||
@@ -1478,10 +1478,13 @@ void ConfigMainWindow::loadConfig(void) | |||
1478 | ConfigView::updateListAll(); | 1478 | ConfigView::updateListAll(); |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | void ConfigMainWindow::saveConfig(void) | 1481 | bool ConfigMainWindow::saveConfig(void) |
1482 | { | 1482 | { |
1483 | if (conf_write(NULL)) | 1483 | if (conf_write(NULL)) { |
1484 | QMessageBox::information(this, "qconf", _("Unable to save configuration!")); | 1484 | QMessageBox::information(this, "qconf", _("Unable to save configuration!")); |
1485 | return false; | ||
1486 | } | ||
1487 | return true; | ||
1485 | } | 1488 | } |
1486 | 1489 | ||
1487 | void ConfigMainWindow::saveConfigAs(void) | 1490 | void ConfigMainWindow::saveConfigAs(void) |
@@ -1642,7 +1645,11 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e) | |||
1642 | mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit")); | 1645 | mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit")); |
1643 | switch (mb.exec()) { | 1646 | switch (mb.exec()) { |
1644 | case QMessageBox::Yes: | 1647 | case QMessageBox::Yes: |
1645 | saveConfig(); | 1648 | if (saveConfig()) |
1649 | e->accept(); | ||
1650 | else | ||
1651 | e->ignore(); | ||
1652 | break; | ||
1646 | case QMessageBox::No: | 1653 | case QMessageBox::No: |
1647 | e->accept(); | 1654 | e->accept(); |
1648 | break; | 1655 | break; |
@@ -1745,10 +1752,6 @@ int main(int ac, char** av) | |||
1745 | bindtextdomain(PACKAGE, LOCALEDIR); | 1752 | bindtextdomain(PACKAGE, LOCALEDIR); |
1746 | textdomain(PACKAGE); | 1753 | textdomain(PACKAGE); |
1747 | 1754 | ||
1748 | #ifndef LKC_DIRECT_LINK | ||
1749 | kconfig_load(); | ||
1750 | #endif | ||
1751 | |||
1752 | progname = av[0]; | 1755 | progname = av[0]; |
1753 | configApp = new QApplication(ac, av); | 1756 | configApp = new QApplication(ac, av); |
1754 | if (ac > 1 && av[1][0] == '-') { | 1757 | if (ac > 1 && av[1][0] == '-') { |
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 91677d900dbd..3715b3e7212c 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h | |||
@@ -311,7 +311,7 @@ public slots: | |||
311 | void listFocusChanged(void); | 311 | void listFocusChanged(void); |
312 | void goBack(void); | 312 | void goBack(void); |
313 | void loadConfig(void); | 313 | void loadConfig(void); |
314 | void saveConfig(void); | 314 | bool saveConfig(void); |
315 | void saveConfigAs(void); | 315 | void saveConfigAs(void); |
316 | void searchConfig(void); | 316 | void searchConfig(void); |
317 | void showSingleView(void); | 317 | void showSingleView(void); |
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index a796c95fe8a0..071f00c3046e 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
@@ -9,7 +9,6 @@ | |||
9 | #include <regex.h> | 9 | #include <regex.h> |
10 | #include <sys/utsname.h> | 10 | #include <sys/utsname.h> |
11 | 11 | ||
12 | #define LKC_DIRECT_LINK | ||
13 | #include "lkc.h" | 12 | #include "lkc.h" |
14 | 13 | ||
15 | struct symbol symbol_yes = { | 14 | struct symbol symbol_yes = { |
@@ -751,7 +750,8 @@ const char *sym_get_string_value(struct symbol *sym) | |||
751 | case no: | 750 | case no: |
752 | return "n"; | 751 | return "n"; |
753 | case mod: | 752 | case mod: |
754 | return "m"; | 753 | sym_calc_value(modules_sym); |
754 | return (modules_sym->curr.tri == no) ? "n" : "m"; | ||
755 | case yes: | 755 | case yes: |
756 | return "y"; | 756 | return "y"; |
757 | } | 757 | } |
@@ -893,6 +893,49 @@ const char *sym_expand_string_value(const char *in) | |||
893 | return res; | 893 | return res; |
894 | } | 894 | } |
895 | 895 | ||
896 | const char *sym_escape_string_value(const char *in) | ||
897 | { | ||
898 | const char *p; | ||
899 | size_t reslen; | ||
900 | char *res; | ||
901 | size_t l; | ||
902 | |||
903 | reslen = strlen(in) + strlen("\"\"") + 1; | ||
904 | |||
905 | p = in; | ||
906 | for (;;) { | ||
907 | l = strcspn(p, "\"\\"); | ||
908 | p += l; | ||
909 | |||
910 | if (p[0] == '\0') | ||
911 | break; | ||
912 | |||
913 | reslen++; | ||
914 | p++; | ||
915 | } | ||
916 | |||
917 | res = malloc(reslen); | ||
918 | res[0] = '\0'; | ||
919 | |||
920 | strcat(res, "\""); | ||
921 | |||
922 | p = in; | ||
923 | for (;;) { | ||
924 | l = strcspn(p, "\"\\"); | ||
925 | strncat(res, p, l); | ||
926 | p += l; | ||
927 | |||
928 | if (p[0] == '\0') | ||
929 | break; | ||
930 | |||
931 | strcat(res, "\\"); | ||
932 | strncat(res, p++, 1); | ||
933 | } | ||
934 | |||
935 | strcat(res, "\""); | ||
936 | return res; | ||
937 | } | ||
938 | |||
896 | struct symbol **sym_re_search(const char *pattern) | 939 | struct symbol **sym_re_search(const char *pattern) |
897 | { | 940 | { |
898 | struct symbol *sym, **sym_arr = NULL; | 941 | struct symbol *sym, **sym_arr = NULL; |
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 6330cc871a47..d0b8b2318e48 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c | |||
@@ -5,6 +5,8 @@ | |||
5 | * Released under the terms of the GNU GPL v2.0. | 5 | * Released under the terms of the GNU GPL v2.0. |
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <stdarg.h> | ||
9 | #include <stdlib.h> | ||
8 | #include <string.h> | 10 | #include <string.h> |
9 | #include "lkc.h" | 11 | #include "lkc.h" |
10 | 12 | ||
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index ddee5fc51811..00f9d3a9cf8b 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <string.h> | 14 | #include <string.h> |
15 | #include <unistd.h> | 15 | #include <unistd.h> |
16 | 16 | ||
17 | #define LKC_DIRECT_LINK | ||
18 | #include "lkc.h" | 17 | #include "lkc.h" |
19 | 18 | ||
20 | #define START_STRSIZE 16 | 19 | #define START_STRSIZE 16 |
diff --git a/scripts/kconfig/zconf.lex.c_shipped b/scripts/kconfig/zconf.lex.c_shipped index 906c09911748..c32b1a49f5a3 100644 --- a/scripts/kconfig/zconf.lex.c_shipped +++ b/scripts/kconfig/zconf.lex.c_shipped | |||
@@ -776,7 +776,6 @@ char *zconftext; | |||
776 | #include <string.h> | 776 | #include <string.h> |
777 | #include <unistd.h> | 777 | #include <unistd.h> |
778 | 778 | ||
779 | #define LKC_DIRECT_LINK | ||
780 | #include "lkc.h" | 779 | #include "lkc.h" |
781 | 780 | ||
782 | #define START_STRSIZE 16 | 781 | #define START_STRSIZE 16 |
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped index 211e1a277037..f636141e7bfd 100644 --- a/scripts/kconfig/zconf.tab.c_shipped +++ b/scripts/kconfig/zconf.tab.c_shipped | |||
@@ -87,7 +87,6 @@ | |||
87 | #include <string.h> | 87 | #include <string.h> |
88 | #include <stdbool.h> | 88 | #include <stdbool.h> |
89 | 89 | ||
90 | #define LKC_DIRECT_LINK | ||
91 | #include "lkc.h" | 90 | #include "lkc.h" |
92 | 91 | ||
93 | #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) | 92 | #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) |
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index c38cc5aa8ed1..864da07ba4aa 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y | |||
@@ -11,7 +11,6 @@ | |||
11 | #include <string.h> | 11 | #include <string.h> |
12 | #include <stdbool.h> | 12 | #include <stdbool.h> |
13 | 13 | ||
14 | #define LKC_DIRECT_LINK | ||
15 | #include "lkc.h" | 14 | #include "lkc.h" |
16 | 15 | ||
17 | #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) | 16 | #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) |