summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config/mkmakefile.c
diff options
context:
space:
mode:
authorru <ru@FreeBSD.org>2005-11-25 22:25:34 +0000
committerru <ru@FreeBSD.org>2005-11-25 22:25:34 +0000
commit1852a934be2adf2c0f31279d930c513b44f1eea1 (patch)
treebdbde0c018ad3f753fe3d13706c65f0b52477290 /usr.sbin/config/mkmakefile.c
parent783a6188caee1cf238ccd9ddbfe869f7c3f71fa6 (diff)
downloadFreeBSD-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.
Diffstat (limited to 'usr.sbin/config/mkmakefile.c')
-rw-r--r--usr.sbin/config/mkmakefile.c62
1 files changed, 19 insertions, 43 deletions
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;
OpenPOWER on IntegriCloud