diff options
author | ru <ru@FreeBSD.org> | 2005-11-25 22:25:34 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2005-11-25 22:25:34 +0000 |
commit | 1852a934be2adf2c0f31279d930c513b44f1eea1 (patch) | |
tree | bdbde0c018ad3f753fe3d13706c65f0b52477290 | |
parent | 783a6188caee1cf238ccd9ddbfe869f7c3f71fa6 (diff) | |
download | FreeBSD-src-1852a934be2adf2c0f31279d930c513b44f1eea1.zip FreeBSD-src-1852a934be2adf2c0f31279d930c513b44f1eea1.tar.gz |
Clean some code that became obfuscated over the years:
Don't keep duplicate files in the files list just to
mark the device as "known" later. XXX: Since the
device list isn't unique (there can be two "device foo"
directives, as this the case with LINT+DEFAULTS), we
have to traverse it all to mark all copies of the same
device as "used", but this is not worse than it was.
-rw-r--r-- | usr.sbin/config/config.h | 3 | ||||
-rw-r--r-- | usr.sbin/config/mkheaders.c | 13 | ||||
-rw-r--r-- | usr.sbin/config/mkmakefile.c | 62 |
3 files changed, 19 insertions, 59 deletions
diff --git a/usr.sbin/config/config.h b/usr.sbin/config/config.h index 216aa93..d1ba1ed 100644 --- a/usr.sbin/config/config.h +++ b/usr.sbin/config/config.h @@ -46,7 +46,6 @@ struct file_list { char *f_compilewith; /* special make rule if present */ char *f_depends; /* additional dependancies */ char *f_clean; /* File list to add to clean rule */ - char *f_needs; char *f_warn; /* warning message */ }; @@ -59,7 +58,6 @@ struct files_name { * Types. */ #define NORMAL 1 -#define INVISIBLE 2 #define PROFILING 3 #define NODEPEND 4 #define LOCAL 5 @@ -72,7 +70,6 @@ struct files_name { #define NO_IMPLCT_RULE 1 #define NO_OBJ 2 #define BEFORE_DEPEND 4 -#define ISDUP 8 #define NOWERROR 16 struct device { diff --git a/usr.sbin/config/mkheaders.c b/usr.sbin/config/mkheaders.c index 9babe78..fd7f1b3 100644 --- a/usr.sbin/config/mkheaders.c +++ b/usr.sbin/config/mkheaders.c @@ -50,23 +50,10 @@ static const char rcsid[] = void headers(void) { - struct file_list *fl; struct device *dp; - int match; int errors; errors = 0; - STAILQ_FOREACH(fl, &ftab, f_next) { - if (fl->f_needs != 0) { - match = 0; - STAILQ_FOREACH(dp, &dtab, d_next) { - if (eq(dp->d_name, fl->f_needs)) { - match++; - dp->d_done |= DEVDONE; - } - } - } - } STAILQ_FOREACH(dp, &dtab, d_next) { if (!(dp->d_done & DEVDONE)) { warnx("Error: device \"%s\" is unknown", diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index d4b2466..5b4f3ad 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -293,11 +293,11 @@ static void read_file(char *fname) { FILE *fp; - struct file_list *tp, *pf; + struct file_list *tp; struct device *dp; struct opt *op; - char *wd, *this, *needs, *compilewith, *depends, *clean, *warning; - int nreqs, isdup, std, filetype, + char *wd, *this, *compilewith, *depends, *clean, *warning; + int nreqs, devfound, std, filetype, imp_rule, no_obj, before_depend, mandatory, nowerror; fp = fopen(fname, "r"); @@ -331,17 +331,12 @@ next: fname, this); exit(1); } - if ((pf = fl_lookup(this)) && (pf->f_type != INVISIBLE || pf->f_flags)) - isdup = ISDUP; - else - isdup = 0; - tp = 0; + tp = fl_lookup(this); nreqs = 0; compilewith = 0; depends = 0; clean = 0; warning = 0; - needs = 0; std = mandatory = 0; imp_rule = 0; no_obj = 0; @@ -365,7 +360,7 @@ next: nextparam: next_word(fp, wd); if (wd == 0) { - if (isdup) + if (tp != NULL) goto next; goto doneparam; } @@ -443,13 +438,16 @@ nextparam: nowerror = 1; goto nextparam; } - if (needs == 0 && nreqs == 1) - needs = ns(wd); - if (isdup) - goto invis; + devfound = 0; /* XXX duplicate device entries */ STAILQ_FOREACH(dp, &dtab, d_next) - if (eq(dp->d_name, wd)) - goto nextparam; + if (eq(dp->d_name, wd)) { + dp->d_done |= DEVDONE; + devfound = 1; + } + if (devfound) + goto nextparam; + if (tp != NULL) + goto skip; if (mandatory) { printf("%s: mandatory device \"%s\" not found\n", fname, wd); @@ -461,26 +459,11 @@ nextparam: exit(1); } SLIST_FOREACH(op, &opt, op_next) - if (op->op_value == 0 && opteq(op->op_name, wd)) { - if (nreqs == 1) { - free(needs); - needs = 0; - } + if (op->op_value == 0 && opteq(op->op_name, wd)) goto nextparam; - } -invis: +skip: while ((wd = get_word(fp)) != 0) ; - if (tp == 0) - tp = new_fent(); - tp->f_fn = this; - tp->f_type = INVISIBLE; - tp->f_needs = needs; - tp->f_flags |= isdup; - tp->f_compilewith = compilewith; - tp->f_depends = depends; - tp->f_clean = clean; - tp->f_warn = warning; goto next; doneparam: @@ -497,11 +480,9 @@ doneparam: } if (filetype == PROFILING && profiling == 0) goto next; - if (tp == 0) - tp = new_fent(); + tp = new_fent(); tp->f_fn = this; tp->f_type = filetype; - tp->f_flags &= ~ISDUP; if (imp_rule) tp->f_flags |= NO_IMPLCT_RULE; if (no_obj) @@ -510,13 +491,10 @@ doneparam: tp->f_flags |= BEFORE_DEPEND; if (nowerror) tp->f_flags |= NOWERROR; - tp->f_needs = needs; tp->f_compilewith = compilewith; tp->f_depends = depends; tp->f_clean = clean; tp->f_warn = warning; - if (pf && pf->f_type == INVISIBLE) - pf->f_flags |= ISDUP; /* mark as duplicate */ goto next; } @@ -599,7 +577,7 @@ do_objs(FILE *fp) fprintf(fp, "OBJS="); lpos = 6; STAILQ_FOREACH(tp, &ftab, f_next) { - if (tp->f_type == INVISIBLE || tp->f_flags & NO_OBJ) + if (tp->f_flags & NO_OBJ) continue; sp = tail(tp->f_fn); cp = sp + (len = strlen(sp)) - 1; @@ -635,7 +613,7 @@ do_xxfiles(char *tag, FILE *fp) fprintf(fp, "%sFILES=", SUFF); lpos = 8; STAILQ_FOREACH(tp, &ftab, f_next) - if (tp->f_type != INVISIBLE && tp->f_type != NODEPEND) { + if (tp->f_type != NODEPEND) { len = strlen(tp->f_fn); if (tp->f_fn[len - slen - 1] != '.') continue; @@ -678,8 +656,6 @@ do_rules(FILE *f) char *compilewith; STAILQ_FOREACH(ftp, &ftab, f_next) { - if (ftp->f_type == INVISIBLE) - continue; if (ftp->f_warn) printf("WARNING: %s\n", ftp->f_warn); cp = (np = ftp->f_fn) + strlen(ftp->f_fn) - 1; |