Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/config Allow dependency on undefined attributes, so ...



details:   https://anonhg.NetBSD.org/src/rev/78d1ad945d9c
branches:  trunk
changeset: 332831:78d1ad945d9c
user:      uebayasi <uebayasi%NetBSD.org@localhost>
date:      Fri Oct 10 11:09:50 2014 +0000

description:
Allow dependency on undefined attributes, so that attribute definitions can
be written out-of-order, like:

        # b is not defined yet
        define  a: b
        file    a.c     a

        # b is defined here
        define  b
        fine    b.c

diffstat:

 usr.bin/config/gram.y |   4 ++--
 usr.bin/config/sem.c  |  10 ++++++----
 usr.bin/config/sem.h  |   4 ++--
 3 files changed, 10 insertions(+), 8 deletions(-)

diffs (64 lines):

diff -r 942565e2e08b -r 78d1ad945d9c usr.bin/config/gram.y
--- a/usr.bin/config/gram.y     Fri Oct 10 11:04:21 2014 +0000
+++ b/usr.bin/config/gram.y     Fri Oct 10 11:09:50 2014 +0000
@@ -1,5 +1,5 @@
 %{
-/*     $NetBSD: gram.y,v 1.42 2014/10/10 06:13:30 uebayasi Exp $       */
+/*     $NetBSD: gram.y,v 1.43 2014/10/10 11:09:50 uebayasi Exp $       */
 
 /*
  * Copyright (c) 1992, 1993
@@ -587,7 +587,7 @@
 
 /* one depend item (which is an attribute) */
 depend:
-       WORD                            { $$ = getattr($1); }
+       WORD                            { $$ = refattr($1); }
 ;
 
 /* list of option depends, may be empty */
diff -r 942565e2e08b -r 78d1ad945d9c usr.bin/config/sem.c
--- a/usr.bin/config/sem.c      Fri Oct 10 11:04:21 2014 +0000
+++ b/usr.bin/config/sem.c      Fri Oct 10 11:09:50 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sem.c,v 1.54 2014/10/10 10:16:19 uebayasi Exp $        */
+/*     $NetBSD: sem.c,v 1.55 2014/10/10 11:09:50 uebayasi Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -672,12 +672,14 @@
 /*
  * Implicit attribute definition.
  */
-void
+struct attr *
 refattr(const char *name)
 {
+       struct attr *a;
 
-       if ((ht_lookup(attrtab, name)) == NULL)
-               (void)mkattr(name);
+       if ((a = ht_lookup(attrtab, name)) == NULL)
+               a = mkattr(name);
+       return a;
 }
 
 int
diff -r 942565e2e08b -r 78d1ad945d9c usr.bin/config/sem.h
--- a/usr.bin/config/sem.h      Fri Oct 10 11:04:21 2014 +0000
+++ b/usr.bin/config/sem.h      Fri Oct 10 11:09:50 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sem.h,v 1.13 2014/10/10 07:48:50 uebayasi Exp $        */
+/*     $NetBSD: sem.h,v 1.14 2014/10/10 11:09:50 uebayasi Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -57,7 +57,7 @@
 struct deva    *getdevattach(const char *);
 struct attr    *mkattr(const char *);
 struct attr    *getattr(const char *);
-void           refattr(const char *);
+struct attr    *refattr(const char *);
 int            getrefattr(const char *, struct attr **);
 void           expandattr(struct attr *, void (*)(struct attr *));
 void           selectattr(struct attr *);



Home | Main Index | Thread Index | Old Index