@@ -152,6 +152,30 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
return 0;
}
+/**
+ * Read remarks from -remarks file:
+ */
+void conf_read_remarks(const char *remfile)
+{
+ FILE *in;
+ char line[1024], *p, *p2;
+ struct symbol *sym;
+
+ sprintf(line, "%s-remarks", remfile ? remfile : conf_get_configname());
+ if (!(in = zconf_fopen(line)))
+ return;
+ while (fgets(line, sizeof(line), in)) {
+ if (!(p = strchr(line, ' '))) /* ' ' is our delimiter */
+ continue; /* skip lines without one */
+ *p++ = '\0'; /* put a \0 there, advance */
+ if ((p2 = strchr(p, '\n'))) /* look for \n after remark */
+ *p2 = '\0'; /* remove it, no \n in remarks */
+ if ((sym = sym_find(line))) /* find the matching sym */
+ sym->remark = strdup(p); /* and register the remark */
+ }
+ fclose(in);
+}
+
int conf_read_simple(const char *name, int def)
{
FILE *in = NULL;
@@ -393,16 +417,18 @@ int conf_read(const char *name)
sym_add_change_count(conf_warnings || conf_unsaved);
+ conf_read_remarks(name);
return 0;
}
int conf_write(const char *name)
{
- FILE *out;
+ FILE *out, *rem;
+ struct stat sb;
struct symbol *sym;
struct menu *menu;
const char *basename;
- char dirname[128], tmpname[128], newname[128];
+ char dirname[128], tmpname[128], newname[128], tmprem[128], newrem[128];
int type, l;
const char *str;
time_t now;
@@ -432,15 +458,19 @@ int conf_write(const char *name)
basename = conf_get_configname();
sprintf(newname, "%s%s", dirname, basename);
+ sprintf(newrem, "%s%s-remarks", dirname, basename);
env = getenv("KCONFIG_OVERWRITECONFIG");
if (!env || !*env) {
sprintf(tmpname, "%s.tmpconfig.%d", dirname, (int)getpid());
out = fopen(tmpname, "w");
+ sprintf(tmprem, "%s.tmpconfig-remarks.%d", dirname, (int)getpid());
+ rem = fopen(tmprem, "w");
} else {
*tmpname = 0;
out = fopen(newname, "w");
+ rem = fopen(newrem, "w");
}
- if (!out)
+ if (!out || !rem)
return 1;
sym = sym_lookup("KERNELVERSION", 0);
@@ -528,6 +558,8 @@ int conf_write(const char *name)
}
next:
+ if (sym && sym->remark)
+ fprintf(rem, "%s %s\n", sym->name, sym->remark);
if (menu->list) {
menu = menu->list;
continue;
@@ -542,6 +574,7 @@ int conf_write(const char *name)
}
}
fclose(out);
+ fclose(rem);
if (*tmpname) {
strcat(dirname, basename);
@@ -549,7 +582,13 @@ int conf_write(const char *name)
rename(newname, dirname);
if (rename(tmpname, newname))
return 1;
+ sprintf(dirname, "%s.old", newrem);
+ rename(newrem, dirname);
+ if (rename(tmprem, newrem))
+ conf_warning("moving %s to %s failed!", tmprem, newrem);
}
+ if (!stat(newrem, &sb) && !sb.st_size)
+ unlink(newrem);
printf(_("#\n"
"# configuration written to %s\n"
@@ -77,6 +77,7 @@ enum {
struct symbol {
struct symbol *next;
char *name;
+ char *remark;
enum symbol_type type;
struct symbol_value curr;
struct symbol_value def[S_DEF_COUNT];