Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/config Accept "-no" as a "no" that does not cause er...



details:   https://anonhg.NetBSD.org/src/rev/34bc8e5594d7
branches:  trunk
changeset: 346937:34bc8e5594d7
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Aug 07 10:37:24 2016 +0000

description:
Accept "-no" as a "no" that does not cause errors if the object deleted
does not exist.

diffstat:

 usr.bin/config/defs.h |   8 ++++----
 usr.bin/config/gram.y |  42 ++++++++++++++++++++++++------------------
 usr.bin/config/main.c |  34 +++++++++++++++++-----------------
 usr.bin/config/scan.l |   5 +++--
 usr.bin/config/sem.c  |  39 +++++++++++++++++++++++----------------
 usr.bin/config/sem.h  |  14 +++++++-------
 6 files changed, 78 insertions(+), 64 deletions(-)

diffs (truncated from 511 to 300 lines):

diff -r 423e57eadcd9 -r 34bc8e5594d7 usr.bin/config/defs.h
--- a/usr.bin/config/defs.h     Sun Aug 07 10:07:58 2016 +0000
+++ b/usr.bin/config/defs.h     Sun Aug 07 10:37:24 2016 +0000
@@ -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   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);
diff -r 423e57eadcd9 -r 34bc8e5594d7 usr.bin/config/gram.y
--- a/usr.bin/config/gram.y     Sun Aug 07 10:07:58 2016 +0000
+++ b/usr.bin/config/gram.y     Sun Aug 07 10:37:24 2016 +0000
@@ -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 @@
 #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 @@
 %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 @@
 %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 WORD                { $$ = new_nx($2, $1); }
 ;
 
+no:
+         NO    { $$ = 0; }
+       | CNO   { $$ = 1; }
+;
+
 /************************************************************/
 
 /*
@@ -740,11 +746,11 @@
 ;
 
 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_no_makeoptions:
-       NO MAKEOPTIONS no_mkopt_list
+       no MAKEOPTIONS { nowarn = $1; } no_mkopt_list { nowarn = 0; }
 ;
 
 select_makeoptions:
@@ -760,7 +766,7 @@
 ;
 
 select_no_options:
-       NO OPTIONS no_opt_list
+       no OPTIONS { nowarn = $1; } no_opt_list { nowarn = 0; }
 ;
 
 select_options:
@@ -776,7 +782,7 @@
 ;
 
 select_no_ident:
-       NO IDENT                        { setident(NULL); }
+       no IDENT                        { setident(NULL); }
 ;
 
 select_config:
@@ -785,11 +791,11 @@
 ;
 
 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_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 @@
 
 /* one filesystem that had NO in front */
 no_fsoption:
-       WORD                            { delfsoption($1); }
+       WORD                            { delfsoption($1, nowarn); }
 ;
 
 /* list of make options */
@@ -862,7 +868,7 @@
 /* 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 @@
 
 /* one option that had NO in front */
 no_option:
-       WORD                            { deloption($1); }
+       WORD                            { deloption($1, nowarn); }
 ;
 
 /* the name in "config name root on ..." */
diff -r 423e57eadcd9 -r 34bc8e5594d7 usr.bin/config/main.c
--- a/usr.bin/config/main.c     Sun Aug 07 10:07:58 2016 +0000
+++ b/usr.bin/config/main.c     Sun Aug 07 10:37:24 2016 +0000
@@ -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 @@
                    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 @@
 }
 
 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 @@
 }
 
 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 @@
 }
 
 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 @@
                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 @@
  */
 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 @@
                /*
                 * -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 @@
        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);
        }



Home | Main Index | Thread Index | Old Index