svn commit: r342362 - head/usr.sbin/config
Kyle Evans
kevans at FreeBSD.org
Sat Dec 22 06:02:36 UTC 2018
Author: kevans
Date: Sat Dec 22 06:02:34 2018
New Revision: 342362
URL: https://svnweb.freebsd.org/changeset/base/342362
Log:
config(8): Allow duplicate options to be specified
config(8)'s option handling has been written to allow duplicate options; if
the value changes, then the latest value is used and an informative message
is printed to stderr like so:
/usr/src/sys/amd64/conf/TEST: option "VERBOSE_SYSINIT" redefined from 0 to 1
Currently, this is only a possibility for cpu types, MAXUSERS, and
MACHINE_ARCH. Anything else duplicated in a config file will use the first
value set and error about duplicated options on subsequent appearances,
which is arguably unfriendly since one could specify:
include GENERIC
nooptions VERBOSE_SYSINIT
options VERBOSE_SYSINIT
to redefine the value later anyways.
Reported by: mmacy
MFC after: 1 week
Modified:
head/usr.sbin/config/config.y
Modified: head/usr.sbin/config/config.y
==============================================================================
--- head/usr.sbin/config/config.y Fri Dec 21 23:33:28 2018 (r342361)
+++ head/usr.sbin/config/config.y Sat Dec 22 06:02:34 2018 (r342362)
@@ -99,7 +99,7 @@ static void newdev(char *name);
static void newfile(char *name);
static void newenvvar(char *name, bool is_file);
static void rmdev_schedule(struct device_head *dh, char *name);
-static void newopt(struct opt_head *list, char *name, char *value, int append);
+static void newopt(struct opt_head *list, char *name, char *value, int append, int dupe);
static void rmopt_schedule(struct opt_head *list, char *name);
static char *
@@ -212,7 +212,7 @@ System_spec:
;
System_id:
- Save_id { newopt(&mkopt, ns("KERNEL"), $1, 0); };
+ Save_id { newopt(&mkopt, ns("KERNEL"), $1, 0, 0); };
System_parameter_list:
System_parameter_list ID
@@ -232,13 +232,13 @@ NoOpt_list:
;
Option:
Save_id {
- newopt(&opt, $1, NULL, 0);
+ newopt(&opt, $1, NULL, 0, 1);
if (strchr($1, '=') != NULL)
errx(1, "%s:%d: The `=' in options should not be "
"quoted", yyfile, yyline);
} |
Save_id EQUALS Opt_value {
- newopt(&opt, $1, $3, 0);
+ newopt(&opt, $1, $3, 0, 1);
} ;
NoOption:
@@ -266,10 +266,10 @@ Mkopt_list:
;
Mkoption:
- Save_id { newopt(&mkopt, $1, ns(""), 0); } |
- Save_id EQUALS { newopt(&mkopt, $1, ns(""), 0); } |
- Save_id EQUALS Opt_value { newopt(&mkopt, $1, $3, 0); } |
- Save_id PLUSEQUALS Opt_value { newopt(&mkopt, $1, $3, 1); } ;
+ Save_id { newopt(&mkopt, $1, ns(""), 0, 0); } |
+ Save_id EQUALS { newopt(&mkopt, $1, ns(""), 0, 0); } |
+ Save_id EQUALS Opt_value { newopt(&mkopt, $1, $3, 0, 0); } |
+ Save_id PLUSEQUALS Opt_value { newopt(&mkopt, $1, $3, 1, 0); } ;
Dev:
ID { $$ = $1; }
@@ -295,7 +295,7 @@ NoDev_list:
Device:
Dev {
- newopt(&opt, devopt($1), ns("1"), 0);
+ newopt(&opt, devopt($1), ns("1"), 0, 0);
/* and the device part */
newdev($1);
}
@@ -432,7 +432,7 @@ findopt(struct opt_head *list, char *name)
* Add an option to the list of options.
*/
static void
-newopt(struct opt_head *list, char *name, char *value, int append)
+newopt(struct opt_head *list, char *name, char *value, int append, int dupe)
{
struct opt *op, *op2;
@@ -445,7 +445,7 @@ newopt(struct opt_head *list, char *name, char *value,
}
op2 = findopt(list, name);
- if (op2 != NULL && !append) {
+ if (op2 != NULL && !append && !dupe) {
fprintf(stderr,
"WARNING: duplicate option `%s' encountered.\n", name);
return;
@@ -458,9 +458,15 @@ newopt(struct opt_head *list, char *name, char *value,
op->op_ownfile = 0;
op->op_value = value;
if (op2 != NULL) {
- while (SLIST_NEXT(op2, op_append) != NULL)
- op2 = SLIST_NEXT(op2, op_append);
- SLIST_NEXT(op2, op_append) = op;
+ if (append) {
+ while (SLIST_NEXT(op2, op_append) != NULL)
+ op2 = SLIST_NEXT(op2, op_append);
+ SLIST_NEXT(op2, op_append) = op;
+ } else {
+ while (SLIST_NEXT(op2, op_next) != NULL)
+ op2 = SLIST_NEXT(op2, op_next);
+ SLIST_NEXT(op2, op_next) = op;
+ }
} else
SLIST_INSERT_HEAD(list, op, op_next);
}
More information about the svn-src-all
mailing list