Allow option aliasing. Lines of the form:
OLD_OPT = NEW_OPT in options* files will now map OLD_OPT to NEW_OPT with a friendly message. This is indented for situations where we need to preserve an interface in the config file in an upwards compatible fashion on a stable branch. Reviewed by: nwhitehorn@ MFC after: 3 days
This commit is contained in:
parent
2a29e09f38
commit
e1a4e3fa37
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=206664
@ -129,6 +129,8 @@ SLIST_HEAD(opt_head, opt) opt, mkopt, rmopts;
|
||||
struct opt_list {
|
||||
char *o_name;
|
||||
char *o_file;
|
||||
int o_flags;
|
||||
#define OL_ALIAS 1
|
||||
SLIST_ENTRY(opt_list) o_next;
|
||||
};
|
||||
|
||||
|
@ -94,6 +94,17 @@ options(void)
|
||||
SLIST_INSERT_HEAD(&opt, op, op_next);
|
||||
|
||||
read_options();
|
||||
SLIST_FOREACH(op, &opt, op_next) {
|
||||
SLIST_FOREACH(ol, &otab, o_next) {
|
||||
if (eq(op->op_name, ol->o_name) &&
|
||||
(ol->o_flags & OL_ALIAS)) {
|
||||
printf("Mapping option %s to %s.\n",
|
||||
op->op_name, ol->o_file);
|
||||
op->op_name = ol->o_file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
SLIST_FOREACH(ol, &otab, o_next)
|
||||
do_option(ol->o_name);
|
||||
SLIST_FOREACH(op, &opt, op_next) {
|
||||
@ -124,7 +135,6 @@ do_option(char *name)
|
||||
int tidy;
|
||||
|
||||
file = tooption(name);
|
||||
|
||||
/*
|
||||
* Check to see if the option was specified..
|
||||
*/
|
||||
@ -292,6 +302,7 @@ read_options(void)
|
||||
struct opt_list *po;
|
||||
int first = 1;
|
||||
char genopt[MAXPATHLEN];
|
||||
int flags = 0;
|
||||
|
||||
SLIST_INIT(&otab);
|
||||
(void) snprintf(fname, sizeof(fname), "../../conf/options");
|
||||
@ -301,6 +312,7 @@ read_options(void)
|
||||
return;
|
||||
}
|
||||
next:
|
||||
flags = 0;
|
||||
wd = get_word(fp);
|
||||
if (wd == (char *)EOF) {
|
||||
(void) fclose(fp);
|
||||
@ -332,6 +344,18 @@ read_options(void)
|
||||
(void) snprintf(genopt, sizeof(genopt), "opt_%s.h", lower(s));
|
||||
val = genopt;
|
||||
free(s);
|
||||
} else if (eq(val, "=")) {
|
||||
val = get_word(fp);
|
||||
if (val == (char *)EOF) {
|
||||
printf("%s: unexpected end of file\n", fname);
|
||||
exit(1);
|
||||
}
|
||||
if (val == 0) {
|
||||
printf("%s: Expected a right hand side at %s\n", fname,
|
||||
this);
|
||||
exit(1);
|
||||
}
|
||||
flags |= OL_ALIAS;
|
||||
}
|
||||
val = ns(val);
|
||||
|
||||
@ -348,6 +372,7 @@ read_options(void)
|
||||
err(EXIT_FAILURE, "calloc");
|
||||
po->o_name = this;
|
||||
po->o_file = val;
|
||||
po->o_flags = flags;
|
||||
SLIST_INSERT_HEAD(&otab, po, o_next);
|
||||
|
||||
goto next;
|
||||
|
Loading…
Reference in New Issue
Block a user