staticvoid strip(char *str)
{ char *p = str; int l;
while ((isspace(*p)))
p++;
l = strlen(p); if (p != str)
memmove(str, p, l + 1); if (!l) return;
p = str + l - 1; while ((isspace(*p)))
*p-- = 0;
}
/* Helper function to facilitate fgets() by Jean Sacren. */ staticvoid xfgets(char *str, int size, FILE *in)
{ if (!fgets(str, size, in))
fprintf(stderr, "\nError in reading or end of file.\n");
/** *randomize_choice_values-randomizechoiceblock * *@choice:menuentryforthechoice
*/ staticvoid randomize_choice_values(struct menu *choice)
{ struct menu *menu; int x; int cnt = 0;
staticvoid conf_set_all_new_symbols(enum conf_def_mode mode)
{ struct menu *menu; int cnt; /* *can'tgoasthedefaultinswitch-casebelow,otherwisegccwhines *about-Wmaybe-uninitialized
*/ int pby = 50; /* probability of bool = y */ int pty = 33; /* probability of tristate = y */ int ptm = 33; /* probability of tristate = m */
if (mode == def_random) { int n, p[3]; char *env = getenv("KCONFIG_PROBABILITY");
n = 0; while (env && *env) { char *endp; int tmp = strtol(env, &endp, 10);
switch (input_mode) { case oldconfig: case syncconfig: if (sym_has_value(sym)) {
printf("%s\n", def); return0;
} /* fall through */ default:
fflush(stdout);
xfgets(line, sizeof(line), stdin); break;
}
return1;
}
staticint conf_string(struct menu *menu)
{ struct symbol *sym = menu->sym; constchar *def;
while (1) {
printf("%*s%s ", indent - 1, "", menu->prompt->text);
printf("(%s) ", sym->name);
def = sym_get_string_value(sym); if (def)
printf("[%s] ", def); if (!conf_askvalue(sym, def)) return0; switch (line[0]) { case'\n': break; case'?': /* print help */ if (line[1] == '\n') {
print_help(menu);
def = NULL; break;
} /* fall through */ default:
line[strlen(line)-1] = 0;
def = line;
} if (def && sym_set_string_value(sym, def)) return0;
}
}
staticint conf_sym(struct menu *menu)
{ struct symbol *sym = menu->sym;
tristate oldval, newval;
while (1) {
printf("%*s%s ", indent - 1, "", menu->prompt->text); if (sym->name)
printf("(%s) ", sym->name);
putchar('[');
oldval = sym_get_tristate_value(sym); switch (oldval) { case no:
putchar('N'); break; case mod:
putchar('M'); break; case yes:
putchar('Y'); break;
} if (oldval != no && sym_tristate_within_range(sym, no))
printf("/n"); if (oldval != mod && sym_tristate_within_range(sym, mod))
printf("/m"); if (oldval != yes && sym_tristate_within_range(sym, yes))
printf("/y");
printf("/?] "); if (!conf_askvalue(sym, sym_get_string_value(sym))) return0;
strip(line);
staticvoid conf_usage(constchar *progname)
{
printf("Usage: %s [options] kconfig_file\n", progname);
printf("\n");
printf("Generic options:\n");
printf(" -h, --help Print this message and exit.\n");
printf(" -s, --silent Do not print log.\n");
printf("\n");
printf("Mode options:\n");
printf(" --listnewconfig List new options\n");
printf(" --helpnewconfig List new options and help text\n");
printf(" --oldaskconfig Start a new configuration using a line-oriented program\n");
printf(" --oldconfig Update a configuration using a provided .config as base\n");
printf(" --syncconfig Similar to oldconfig but generates configuration in\n" " include/{generated/,config/}\n");
printf(" --olddefconfig Same as oldconfig but sets new symbols to their default value\n");
printf(" --defconfig <file> New config with default defined in <file>\n");
printf(" --savedefconfig <file> Save the minimal current configuration to <file>\n");
printf(" --allnoconfig New config where all options are answered with no\n");
printf(" --allyesconfig New config where all options are answered with yes\n");
printf(" --allmodconfig New config where all options are answered with mod\n");
printf(" --alldefconfig New config with all symbols set to default\n");
printf(" --randconfig New config with random answer to all options\n");
printf(" --yes2modconfig Change answers from yes to mod if possible\n");
printf(" --mod2yesconfig Change answers from mod to yes if possible\n");
printf(" --mod2noconfig Change answers from mod to no if possible\n");
printf(" (If none of the above is given, --oldaskconfig is the default)\n");
printf("\n");
printf("Arguments:\n");
printf(" kconfig_file Top-level Kconfig file.\n");
}
int main(int ac, char **av)
{ constchar *progname = av[0]; int opt; constchar *name, *defconfig_file = NULL /* gcc uninit */; int no_conf_write = 0;
switch (input_mode) { case defconfig: if (conf_read(defconfig_file)) {
fprintf(stderr, "***\n" "*** Can't find default configuration \"%s\"!\n" "***\n",
defconfig_file); exit(1);
} break; case savedefconfig: case syncconfig: case oldaskconfig: case oldconfig: case listnewconfig: case helpnewconfig: case olddefconfig: case yes2modconfig: case mod2yesconfig: case mod2noconfig:
conf_read(NULL); break; case allnoconfig: case allyesconfig: case allmodconfig: case alldefconfig: case randconfig:
name = getenv("KCONFIG_ALLCONFIG"); if (!name) break; if ((strcmp(name, "") != 0) && (strcmp(name, "1") != 0)) { if (conf_read_simple(name, S_DEF_USER)) {
fprintf(stderr, "*** Can't read seed configuration \"%s\"!\n",
name); exit(1);
} break;
} switch (input_mode) { case allnoconfig: name = "allno.config"; break; case allyesconfig: name = "allyes.config"; break; case allmodconfig: name = "allmod.config"; break; case alldefconfig: name = "alldef.config"; break; case randconfig: name = "allrandom.config"; break; default: break;
} if (conf_read_simple(name, S_DEF_USER) &&
conf_read_simple("all.config", S_DEF_USER)) {
fprintf(stderr, "*** KCONFIG_ALLCONFIG set, but no \"%s\" or \"all.config\" file found\n",
name); exit(1);
} break; default: break;
}
if (conf_errors()) exit(1);
if (sync_kconfig) {
name = getenv("KCONFIG_NOSILENTUPDATE"); if (name && *name) { if (conf_get_changed()) {
fprintf(stderr, "\n*** The configuration requires explicit update.\n\n"); return1;
}
no_conf_write = 1;
}
}
switch (input_mode) { case allnoconfig:
conf_set_all_new_symbols(def_no); break; case allyesconfig:
conf_set_all_new_symbols(def_yes); break; case allmodconfig:
conf_set_all_new_symbols(def_mod); break; case alldefconfig:
conf_set_all_new_symbols(def_default); break; case randconfig:
conf_set_all_new_symbols(def_random); break; case defconfig:
conf_set_all_new_symbols(def_default); break; case savedefconfig: break; case yes2modconfig:
conf_rewrite_tristates(yes, mod); break; case mod2yesconfig:
conf_rewrite_tristates(mod, yes); break; case mod2noconfig:
conf_rewrite_tristates(mod, no); break; case oldaskconfig:
rootEntry = &rootmenu;
conf(&rootmenu);
input_mode = oldconfig; /* fall through */ case oldconfig: case listnewconfig: case helpnewconfig: case syncconfig: /* Update until a loop caused no more changes */ do {
conf_cnt = 0;
check_conf(&rootmenu);
} while (conf_cnt); break; case olddefconfig: default: break;
}
if (sym_dep_errors()) exit(1);
if (input_mode == savedefconfig) { if (conf_write_defconfig(defconfig_file)) {
fprintf(stderr, "n*** Error while saving defconfig to: %s\n\n",
defconfig_file); return1;
}
} elseif (input_mode != listnewconfig && input_mode != helpnewconfig) { if (!no_conf_write && conf_write(NULL)) {
fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); exit(1);
}
/* *Createauto.confifitdoesnotexist. *ThispreventsGNUMake4.1orolderfromemitting *"include/config/auto.conf:Nosuchfileordirectory" *inthetop-levelMakefile * *syncconfigalwayscreatesorupdatesauto.confbecauseitis *usedduringthebuild.
*/ if (conf_write_autoconf(sync_kconfig) && sync_kconfig) {
fprintf(stderr, "\n*** Error during sync of the configuration.\n\n"); return1;
}
} return0;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.