svn commit: r261435 - head/usr.sbin/config
Warner Losh
imp at FreeBSD.org
Mon Feb 3 15:10:44 UTC 2014
Author: imp
Date: Mon Feb 3 15:10:44 2014
New Revision: 261435
URL: http://svnweb.freebsd.org/changeset/base/261435
Log:
Slightly deobfuscate read_file() and likely pessimize the runtime
performance by epsilon.
(Translation: elminate bogus macros that hid 'returns' making it hard
to read and moved a block of code inline rather than at the end of the
fuction where it was effectively a 'gosub' kind of goto).
Modified:
head/usr.sbin/config/mkmakefile.c
Modified: head/usr.sbin/config/mkmakefile.c
==============================================================================
--- head/usr.sbin/config/mkmakefile.c Mon Feb 3 11:20:32 2014 (r261434)
+++ head/usr.sbin/config/mkmakefile.c Mon Feb 3 15:10:44 2014 (r261435)
@@ -50,21 +50,6 @@ static const char rcsid[] =
#include "config.h"
#include "configvers.h"
-#define next_word(fp, wd) \
- { char *word = get_word(fp); \
- if (word == (char *)EOF) \
- return; \
- else \
- wd = word; \
- }
-#define next_quoted_word(fp, wd) \
- { char *word = get_quoted_word(fp); \
- if (word == (char *)EOF) \
- return; \
- else \
- wd = word; \
- }
-
static char *tail(char *);
static void do_clean(FILE *);
static void do_rules(FILE *);
@@ -343,7 +328,9 @@ next:
goto next;
}
if (eq(wd, "include")) {
- next_quoted_word(fp, wd);
+ wd = get_quoted_word(fp);
+ if (wd == (char *)EOF)
+ return;
if (wd == 0) {
fprintf(stderr, "%s: missing include filename.\n",
fname);
@@ -356,7 +343,9 @@ next:
goto next;
}
this = ns(wd);
- next_word(fp, wd);
+ wd = get_word(fp);
+ if (wd == (char *)EOF)
+ return;
if (wd == 0) {
fprintf(stderr, "%s: No type for %s.\n", fname, this);
exit(1);
@@ -392,11 +381,36 @@ next:
exit(1);
}
nextparam:
- next_word(fp, wd);
+ wd = get_word(fp);
+ if (wd == (char *)EOF)
+ return;
if (wd == 0) {
compile += match;
- if (compile && tp == NULL)
- goto doneparam;
+ if (compile && tp == NULL) {
+ if (std == 0 && nreqs == 0) {
+ fprintf(stderr, "%s: what is %s optional on?\n",
+ fname, this);
+ exit(1);
+ }
+ if (filetype == PROFILING && profiling == 0)
+ goto next;
+ tp = new_fent();
+ tp->f_fn = this;
+ tp->f_type = filetype;
+ if (imp_rule)
+ tp->f_flags |= NO_IMPLCT_RULE;
+ if (no_obj)
+ tp->f_flags |= NO_OBJ;
+ if (before_depend)
+ tp->f_flags |= BEFORE_DEPEND;
+ if (nowerror)
+ tp->f_flags |= NOWERROR;
+ tp->f_compilewith = compilewith;
+ tp->f_depends = depends;
+ tp->f_clean = clean;
+ tp->f_warn = warning;
+ tp->f_objprefix = objprefix;
+ }
goto next;
}
if (eq(wd, "|")) {
@@ -428,7 +442,9 @@ nextparam:
goto nextparam;
}
if (eq(wd, "dependency")) {
- next_quoted_word(fp, wd);
+ wd = get_quoted_word(fp);
+ if (wd == (char *)EOF)
+ return;
if (wd == 0) {
fprintf(stderr,
"%s: %s missing dependency string.\n",
@@ -439,7 +455,9 @@ nextparam:
goto nextparam;
}
if (eq(wd, "clean")) {
- next_quoted_word(fp, wd);
+ wd = get_quoted_word(fp);
+ if (wd == (char *)EOF)
+ return;
if (wd == 0) {
fprintf(stderr, "%s: %s missing clean file list.\n",
fname, this);
@@ -449,7 +467,9 @@ nextparam:
goto nextparam;
}
if (eq(wd, "compile-with")) {
- next_quoted_word(fp, wd);
+ wd = get_quoted_word(fp);
+ if (wd == (char *)EOF)
+ return;
if (wd == 0) {
fprintf(stderr,
"%s: %s missing compile command string.\n",
@@ -460,7 +480,9 @@ nextparam:
goto nextparam;
}
if (eq(wd, "warning")) {
- next_quoted_word(fp, wd);
+ wd = get_quoted_word(fp);
+ if (wd == (char *)EOF)
+ return;
if (wd == 0) {
fprintf(stderr,
"%s: %s missing warning text string.\n",
@@ -471,7 +493,9 @@ nextparam:
goto nextparam;
}
if (eq(wd, "obj-prefix")) {
- next_quoted_word(fp, wd);
+ wd = get_quoted_word(fp);
+ if (wd == (char *)EOF)
+ return;
if (wd == 0) {
printf("%s: %s missing object prefix string.\n",
fname, this);
@@ -518,38 +542,6 @@ nextparam:
goto nextparam;
match = 0;
goto nextparam;
-
-doneparam:
- if (std == 0 && nreqs == 0) {
- fprintf(stderr, "%s: what is %s optional on?\n",
- fname, this);
- exit(1);
- }
-
- if (wd) {
- fprintf(stderr, "%s: syntax error describing %s\n",
- fname, this);
- exit(1);
- }
- if (filetype == PROFILING && profiling == 0)
- goto next;
- tp = new_fent();
- tp->f_fn = this;
- tp->f_type = filetype;
- if (imp_rule)
- tp->f_flags |= NO_IMPLCT_RULE;
- if (no_obj)
- tp->f_flags |= NO_OBJ;
- if (before_depend)
- tp->f_flags |= BEFORE_DEPEND;
- if (nowerror)
- tp->f_flags |= NOWERROR;
- tp->f_compilewith = compilewith;
- tp->f_depends = depends;
- tp->f_clean = clean;
- tp->f_warn = warning;
- tp->f_objprefix = objprefix;
- goto next;
}
/*
More information about the svn-src-all
mailing list