Module Name: src Committed By: christos Date: Sun Aug 7 10:37:24 UTC 2016
Modified Files: src/usr.bin/config: defs.h gram.y main.c scan.l sem.c sem.h Log Message: Accept "-no" as a "no" that does not cause errors if the object deleted does not exist. To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/usr.bin/config/defs.h cvs rdiff -u -r1.53 -r1.54 src/usr.bin/config/gram.y cvs rdiff -u -r1.89 -r1.90 src/usr.bin/config/main.c cvs rdiff -u -r1.25 -r1.26 src/usr.bin/config/scan.l cvs rdiff -u -r1.74 -r1.75 src/usr.bin/config/sem.c cvs rdiff -u -r1.19 -r1.20 src/usr.bin/config/sem.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/config/defs.h diff -u src/usr.bin/config/defs.h:1.95 src/usr.bin/config/defs.h:1.96 --- src/usr.bin/config/defs.h:1.95 Fri Mar 18 11:05:49 2016 +++ src/usr.bin/config/defs.h Sun Aug 7 06:37:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: defs.h,v 1.95 2016/03/18 15:05:49 christos Exp $ */ +/* $NetBSD: defs.h,v 1.96 2016/08/07 10:37:24 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -569,9 +569,9 @@ void deffilesystem(struct nvlist *, stru void defoption(const char *, struct defoptlist *, struct nvlist *); void defflag(const char *, struct defoptlist *, struct nvlist *, int); void defparam(const char *, struct defoptlist *, struct nvlist *, int); -void deloption(const char *); -void delfsoption(const char *); -void delmkoption(const char *); +void deloption(const char *, int); +void delfsoption(const char *, int); +void delmkoption(const char *, int); int devbase_has_instances(struct devbase *, int); int is_declared_option(const char *); int deva_has_instances(struct deva *, int); Index: src/usr.bin/config/gram.y diff -u src/usr.bin/config/gram.y:1.53 src/usr.bin/config/gram.y:1.54 --- src/usr.bin/config/gram.y:1.53 Fri Apr 29 14:18:22 2016 +++ src/usr.bin/config/gram.y Sun Aug 7 06:37:24 2016 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: gram.y,v 1.53 2016/04/29 18:18:22 mlelstv Exp $ */ +/* $NetBSD: gram.y,v 1.54 2016/08/07 10:37:24 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: gram.y,v 1.53 2016/04/29 18:18:22 mlelstv Exp $"); +__RCSID("$NetBSD: gram.y,v 1.54 2016/08/07 10:37:24 christos Exp $"); #include <sys/types.h> #include <sys/param.h> @@ -60,6 +60,7 @@ __RCSID("$NetBSD: gram.y,v 1.53 2016/04/ #define stop(s) cfgerror(s), exit(1) static struct config conf; /* at most one active at a time */ +static int nowarn; /* if warning suppression is on */ /* @@ -178,7 +179,7 @@ static struct loclist *namelocvals(const %token IDENT IOCONF %token LINKZERO %token XMACHINE MAJOR MAKEOPTIONS MAXUSERS MAXPARTITIONS MINOR -%token NEEDS_COUNT NEEDS_FLAG NO +%token NEEDS_COUNT NEEDS_FLAG NO CNO %token XOBJECT OBSOLETE ON OPTIONS %token PACKAGE PLUSEQ PREFIX BUILDPREFIX PSEUDO_DEVICE PSEUDO_ROOT %token ROOT @@ -213,7 +214,7 @@ static struct loclist *namelocvals(const %type <str> value %type <val> major_minor %type <num> signed_number -%type <i32> int32 npseudo device_flags +%type <i32> int32 npseudo device_flags no %type <str> deffs %type <list> deffses %type <defoptlist> defopt @@ -292,6 +293,11 @@ subarches: | subarches WORD { $$ = new_nx($2, $1); } ; +no: + NO { $$ = 0; } + | CNO { $$ = 1; } +; + /************************************************************/ /* @@ -740,11 +746,11 @@ select_attr: ; select_no_attr: - NO SELECT WORD { delattr($3); } + no SELECT WORD { delattr($3, $1); } ; select_no_filesystems: - NO FILE_SYSTEM no_fs_list + no FILE_SYSTEM { nowarn = $1; } no_fs_list { nowarn = 0; } ; select_filesystems: @@ -752,7 +758,7 @@ select_filesystems: ; select_no_makeoptions: - NO MAKEOPTIONS no_mkopt_list + no MAKEOPTIONS { nowarn = $1; } no_mkopt_list { nowarn = 0; } ; select_makeoptions: @@ -760,7 +766,7 @@ select_makeoptions: ; select_no_options: - NO OPTIONS no_opt_list + no OPTIONS { nowarn = $1; } no_opt_list { nowarn = 0; } ; select_options: @@ -776,7 +782,7 @@ select_ident: ; select_no_ident: - NO IDENT { setident(NULL); } + no IDENT { setident(NULL); } ; select_config: @@ -785,11 +791,11 @@ select_config: ; select_no_config: - NO CONFIG WORD { delconf($3); } + no CONFIG WORD { delconf($3, $1); } ; select_no_pseudodev: - NO PSEUDO_DEVICE WORD { delpseudo($3); } + no PSEUDO_DEVICE WORD { delpseudo($3, $1); } ; select_pseudodev: @@ -801,16 +807,16 @@ select_pseudoroot: ; select_no_device_instance_attachment: - NO device_instance AT attachment - { deldevi($2, $4); } + no device_instance AT attachment + { deldevi($2, $4, $1); } ; select_no_device_attachment: - NO DEVICE AT attachment { deldeva($4); } + no DEVICE AT attachment { deldeva($4, $1); } ; select_no_device_instance: - NO device_instance { deldev($2); } + no device_instance { deldev($2, $1); } ; select_device_instance: @@ -837,7 +843,7 @@ no_fs_list: /* one filesystem that had NO in front */ no_fsoption: - WORD { delfsoption($1); } + WORD { delfsoption($1, nowarn); } ; /* list of make options */ @@ -862,7 +868,7 @@ no_mkopt_list: /* one make option that had NO in front */ /* XXX shouldn't this be mkvarname rather than WORD? */ no_mkoption: - WORD { delmkoption($1); } + WORD { delmkoption($1, nowarn); } ; /* list of options */ @@ -885,7 +891,7 @@ no_opt_list: /* one option that had NO in front */ no_option: - WORD { deloption($1); } + WORD { deloption($1, nowarn); } ; /* the name in "config name root on ..." */ Index: src/usr.bin/config/main.c diff -u src/usr.bin/config/main.c:1.89 src/usr.bin/config/main.c:1.90 --- src/usr.bin/config/main.c:1.89 Fri Sep 4 02:01:40 2015 +++ src/usr.bin/config/main.c Sun Aug 7 06:37:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.89 2015/09/04 06:01:40 uebayasi Exp $ */ +/* $NetBSD: main.c,v 1.90 2016/08/07 10:37:24 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: main.c,v 1.89 2015/09/04 06:01:40 uebayasi Exp $"); +__RCSID("$NetBSD: main.c,v 1.90 2016/08/07 10:37:24 christos Exp $"); #ifndef MAKE_BOOTSTRAP #include <sys/cdefs.h> @@ -119,7 +119,7 @@ static int do_option(struct hashtab *, s struct nvlist ***, const char *, const char *, const char *, struct hashtab *); static int undo_option(struct hashtab *, struct nvlist **, - struct nvlist ***, const char *, const char *); + struct nvlist ***, const char *, const char *, int); static int crosscheck(void); static int badstar(void); int main(int, char **); @@ -1082,13 +1082,13 @@ addoption(const char *name, const char * } void -deloption(const char *name) +deloption(const char *name, int nowarn) { CFGDBG(4, "deselecting opt `%s'", name); - if (undo_option(opttab, &options, &nextopt, name, "options")) + if (undo_option(opttab, &options, &nextopt, name, "options", nowarn)) return; - if (undo_option(selecttab, NULL, NULL, strtolower(name), "options")) + if (undo_option(selecttab, NULL, NULL, strtolower(name), "options", nowarn)) return; } @@ -1131,15 +1131,15 @@ addfsoption(const char *name) } void -delfsoption(const char *name) +delfsoption(const char *name, int nowarn) { const char *n; CFGDBG(4, "deselecting fs `%s'", name); n = strtolower(name); - if (undo_option(fsopttab, &fsoptions, &nextfsopt, name, "file-system")) + if (undo_option(fsopttab, &fsoptions, &nextfsopt, name, "file-system", nowarn)) return; - if (undo_option(selecttab, NULL, NULL, n, "file-system")) + if (undo_option(selecttab, NULL, NULL, n, "file-system", nowarn)) return; } @@ -1155,12 +1155,12 @@ addmkoption(const char *name, const char } void -delmkoption(const char *name) +delmkoption(const char *name, int nowarn) { CFGDBG(4, "deselecting mkopt `%s'", name); (void)undo_option(mkopttab, &mkoptions, &nextmkopt, name, - "makeoptions"); + "makeoptions", nowarn); } /* @@ -1243,10 +1243,10 @@ do_option(struct hashtab *ht, struct nvl else cfgwarn("already have %s `%s'", type, name); - if (undo_option(ht, npp, next, name, type)) + if (undo_option(ht, npp, next, name, type, 0)) panic("do_option 2"); if (stab != NULL && - undo_option(stab, NULL, NULL, strtolower(name), type)) + undo_option(stab, NULL, NULL, strtolower(name), type, 0)) panic("do_option 3"); /* now try adding it again */ @@ -1267,7 +1267,7 @@ do_option(struct hashtab *ht, struct nvl */ static int undo_option(struct hashtab *ht, struct nvlist **npp, - struct nvlist ***next, const char *name, const char *type) + struct nvlist ***next, const char *name, const char *type, int nowarn) { struct nvlist *nv; @@ -1275,7 +1275,7 @@ undo_option(struct hashtab *ht, struct n /* * -U command line option removals are always silent */ - if (!handling_cmdlineopts) + if (!handling_cmdlineopts && !nowarn) cfgwarn("%s `%s' is not defined", type, name); return (1); } @@ -2018,7 +2018,7 @@ handle_cmdline_makeoptions(void) handling_cmdlineopts = 1; for (p = cmdlineundefs; p; p = n) { n = p->nv_next; - delmkoption(intern(p->nv_name)); + delmkoption(intern(p->nv_name), 0); free(__UNCONST(p->nv_name)); nvfree(p); } @@ -2026,7 +2026,7 @@ handle_cmdline_makeoptions(void) const char *name = intern(p->nv_name); n = p->nv_next; - delmkoption(name); + delmkoption(name, 0); addmkoption(name, intern(p->nv_str)); free(__UNCONST(p->nv_name)); free(__UNCONST(p->nv_str)); Index: src/usr.bin/config/scan.l diff -u src/usr.bin/config/scan.l:1.25 src/usr.bin/config/scan.l:1.26 --- src/usr.bin/config/scan.l:1.25 Fri Sep 4 06:16:35 2015 +++ src/usr.bin/config/scan.l Sun Aug 7 06:37:24 2016 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: scan.l,v 1.25 2015/09/04 10:16:35 uebayasi Exp $ */ +/* $NetBSD: scan.l,v 1.26 2016/08/07 10:37:24 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: scan.l,v 1.25 2015/09/04 10:16:35 uebayasi Exp $"); +__RCSID("$NetBSD: scan.l,v 1.26 2016/08/07 10:37:24 christos Exp $"); #include <sys/param.h> #include <errno.h> @@ -159,6 +159,7 @@ minor return MINOR; needs-count return NEEDS_COUNT; needs-flag return NEEDS_FLAG; no return NO; +-no return CNO; object return XOBJECT; obsolete return OBSOLETE; on return ON; Index: src/usr.bin/config/sem.c diff -u src/usr.bin/config/sem.c:1.74 src/usr.bin/config/sem.c:1.75 --- src/usr.bin/config/sem.c:1.74 Fri Apr 29 14:18:22 2016 +++ src/usr.bin/config/sem.c Sun Aug 7 06:37:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: sem.c,v 1.74 2016/04/29 18:18:22 mlelstv Exp $ */ +/* $NetBSD: sem.c,v 1.75 2016/08/07 10:37:24 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -45,7 +45,7 @@ #endif #include <sys/cdefs.h> -__RCSID("$NetBSD: sem.c,v 1.74 2016/04/29 18:18:22 mlelstv Exp $"); +__RCSID("$NetBSD: sem.c,v 1.75 2016/08/07 10:37:24 christos Exp $"); #include <sys/param.h> #include <ctype.h> @@ -1051,13 +1051,14 @@ setconf(struct nvlist **npp, const char } void -delconf(const char *name) +delconf(const char *name, int nowarn) { struct config *cf; CFGDBG(5, "deselecting config `%s'", name); if (ht_lookup(cfhashtab, name) == NULL) { - cfgerror("configuration `%s' undefined", name); + if (!nowarn) + cfgerror("configuration `%s' undefined", name); return; } (void)ht_remove(cfhashtab, name); @@ -1266,7 +1267,7 @@ adddev(const char *name, const char *at, } void -deldevi(const char *name, const char *at) +deldevi(const char *name, const char *at, int nowarn) { struct devi *firsti, *i; struct devbase *d; @@ -1275,12 +1276,15 @@ deldevi(const char *name, const char *at CFGDBG(5, "deselecting devi `%s'", name); if (split(name, strlen(name), base, sizeof base, &unit)) { - cfgerror("invalid device name `%s'", name); - return; + if (!nowarn) { + cfgerror("invalid device name `%s'", name); + return; + } } d = ht_lookup(devbasetab, intern(base)); if (d == NULL) { - cfgerror("%s: unknown device `%s'", name, base); + if (!nowarn) + cfgerror("%s: unknown device `%s'", name, base); return; } if (d->d_ispseudo) { @@ -1466,7 +1470,7 @@ remove_devi(struct devi *i) } void -deldeva(const char *at) +deldeva(const char *at, int nowarn) { int unit; const char *cp; @@ -1565,7 +1569,7 @@ out: } void -deldev(const char *name) +deldev(const char *name, int nowarn) { size_t l; struct devi *firsti, *i; @@ -1581,7 +1585,8 @@ deldev(const char *name) firsti = ht_lookup(devitab, name); if (firsti == NULL) { out: - cfgerror("unknown instance %s", name); + if (!nowarn) + cfgerror("unknown instance %s", name); return; } for (i = firsti; i != NULL; i = i->i_alias) @@ -1721,7 +1726,7 @@ addpseudo(const char *name, int number) } void -delpseudo(const char *name) +delpseudo(const char *name, int nowarn) { struct devbase *d; struct devi *i; @@ -1729,7 +1734,8 @@ delpseudo(const char *name) CFGDBG(5, "deselecting pseudo `%s'", name); d = ht_lookup(devbasetab, name); if (d == NULL) { - cfgerror("undefined pseudo-device %s", name); + if (!nowarn) + cfgerror("undefined pseudo-device %s", name); return; } if (!d->d_ispseudo) { @@ -1737,7 +1743,8 @@ delpseudo(const char *name) return; } if ((i = ht_lookup(devitab, name)) == NULL) { - cfgerror("`%s' not defined", name); + if (!nowarn) + cfgerror("`%s' not defined", name); return; } d->d_umax = 0; /* clear neads-count entries */ @@ -1969,7 +1976,7 @@ addattr(const char *name) } void -delattr(const char *name) +delattr(const char *name, int nowarn) { struct attr *a; @@ -1999,7 +2006,7 @@ deselectattrcb2(const char *name1, const const char *name = arg; if (strcmp(name, name2) == 0) - delattr(name1); + delattr(name1, 0); return 0; } Index: src/usr.bin/config/sem.h diff -u src/usr.bin/config/sem.h:1.19 src/usr.bin/config/sem.h:1.20 --- src/usr.bin/config/sem.h:1.19 Fri Nov 21 15:46:56 2014 +++ src/usr.bin/config/sem.h Sun Aug 7 06:37:24 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: sem.h,v 1.19 2014/11/21 20:46:56 christos Exp $ */ +/* $NetBSD: sem.h,v 1.20 2016/08/07 10:37:24 christos Exp $ */ /* * Copyright (c) 1992, 1993 @@ -61,21 +61,21 @@ struct attr *refattr(const char *); int getrefattr(const char *, struct attr **); void expandattr(struct attr *, void (*)(struct attr *)); void addattr(const char *); -void delattr(const char *); +void delattr(const char *, int); void selectattr(struct attr *); void deselectattr(struct attr *); void dependattrs(void); void setmajor(struct devbase *, int); void addconf(struct config *); void setconf(struct nvlist **, const char *, struct nvlist *); -void delconf(const char *); +void delconf(const char *, int); void setfstype(const char **, const char *); void adddev(const char *, const char *, struct loclist *, int); -void deldevi(const char *, const char *); -void deldeva(const char *); -void deldev(const char *); +void deldevi(const char *, const char *, int); +void deldeva(const char *, int); +void deldev(const char *, int); void addpseudo(const char *, int); -void delpseudo(const char *); +void delpseudo(const char *, int); void addpseudoroot(const char *); void adddevm(const char *, devmajor_t, devmajor_t, struct condexpr *, struct nvlist *);