From owner-svn-src-all@FreeBSD.ORG Mon Feb 3 15:10:44 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id D427C19B; Mon, 3 Feb 2014 15:10:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B5E01124C; Mon, 3 Feb 2014 15:10:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s13FAiw0028381; Mon, 3 Feb 2014 15:10:44 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s13FAiUS028380; Mon, 3 Feb 2014 15:10:44 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201402031510.s13FAiUS028380@svn.freebsd.org> From: Warner Losh Date: Mon, 3 Feb 2014 15:10:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261435 - head/usr.sbin/config X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Feb 2014 15:10:44 -0000 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; } /*