From owner-svn-src-all@FreeBSD.ORG Mon Feb 3 18:56:42 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 153EFB7D; Mon, 3 Feb 2014 18:56:42 +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 E95511813; Mon, 3 Feb 2014 18:56:41 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id s13Iufd5012167; Mon, 3 Feb 2014 18:56:41 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s13IufOO012166; Mon, 3 Feb 2014 18:56:41 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201402031856.s13IufOO012166@svn.freebsd.org> From: Warner Losh Date: Mon, 3 Feb 2014 18:56:41 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r261444 - 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 18:56:42 -0000 Author: imp Date: Mon Feb 3 18:56:41 2014 New Revision: 261444 URL: http://svnweb.freebsd.org/changeset/base/261444 Log: Slight cleanup to the error messaging to compress code vertically... Modified: head/usr.sbin/config/mkmakefile.c Modified: head/usr.sbin/config/mkmakefile.c ============================================================================== --- head/usr.sbin/config/mkmakefile.c Mon Feb 3 18:44:36 2014 (r261443) +++ head/usr.sbin/config/mkmakefile.c Mon Feb 3 18:56:41 2014 (r261444) @@ -43,6 +43,7 @@ static const char rcsid[] = #include #include +#include #include #include #include @@ -59,6 +60,15 @@ static void do_before_depend(FILE *); static int opteq(const char *, const char *); static void read_files(void); +static void errout(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + exit(1); +} + /* * Lookup a file, by name. */ @@ -329,11 +339,8 @@ next: } if (eq(wd, "include")) { wd = get_quoted_word(fp); - if (wd == (char *)EOF || wd == 0) { - fprintf(stderr, "%s: missing include filename.\n", - fname); - exit(1); - } + if (wd == (char *)EOF || wd == 0) + errout("%s: missing include filename.\n", fname); (void) snprintf(ifname, sizeof(ifname), "../../%s", wd); read_file(ifname); while (((wd = get_word(fp)) != (char *)EOF) && wd) @@ -344,10 +351,8 @@ next: wd = get_word(fp); if (wd == (char *)EOF) return; - if (wd == 0) { - fprintf(stderr, "%s: No type for %s.\n", fname, this); - exit(1); - } + if (wd == 0) + errout("%s: No type for %s.\n", fname, this); tp = fl_lookup(this); compile = 0; match = 1; @@ -363,14 +368,11 @@ next: nowerror = 0; filetype = NORMAL; objprefix = ""; - if (eq(wd, "standard")) { + if (eq(wd, "standard")) std = 1; - } else if (!eq(wd, "optional")) { - fprintf(stderr, - "%s: \"%s\" %s must be optional or standard\n", + else if (!eq(wd, "optional")) + errout("%s: \"%s\" %s must be optional or standard\n", fname, wd, this); - exit(1); - } nextparam: wd = get_word(fp); if (wd == (char *)EOF) @@ -378,11 +380,9 @@ nextparam: if (wd == 0) { compile += match; if (compile && tp == NULL) { - if (std == 0 && nreqs == 0) { - fprintf(stderr, "%s: what is %s optional on?\n", - fname, this); - exit(1); - } + if (std == 0 && nreqs == 0) + errout("%s: what is %s optional on?\n", + fname, this); if (filetype == PROFILING && profiling == 0) goto next; tp = new_fent(); @@ -405,11 +405,9 @@ nextparam: goto next; } if (eq(wd, "|")) { - if (nreqs == 0) { - fprintf(stderr, "%s: syntax error describing %s\n", + if (nreqs == 0) + errout("%s: syntax error describing %s\n", fname, this); - exit(1); - } compile += match; match = 1; nreqs = 0; @@ -420,11 +418,10 @@ nextparam: goto nextparam; } if (eq(wd, "no-implicit-rule")) { - if (compilewith == 0) { - fprintf(stderr, "%s: alternate rule required when " - "\"no-implicit-rule\" is specified.\n", - fname); - } + if (compilewith == 0) + errout("%s: alternate rule required when " + "\"no-implicit-rule\" is specified for %s.\n", + fname, this); imp_rule++; goto nextparam; } @@ -434,54 +431,41 @@ nextparam: } if (eq(wd, "dependency")) { wd = get_quoted_word(fp); - if (wd == (char *)EOF || wd == 0) { - fprintf(stderr, - "%s: %s missing dependency string.\n", + if (wd == (char *)EOF || wd == 0) + errout("%s: %s missing dependency string.\n", fname, this); - exit(1); - } depends = ns(wd); goto nextparam; } if (eq(wd, "clean")) { wd = get_quoted_word(fp); - if (wd == (char *)EOF || wd == 0) { - fprintf(stderr, "%s: %s missing clean file list.\n", + if (wd == (char *)EOF || wd == 0) + errout("%s: %s missing clean file list.\n", fname, this); - exit(1); - } clean = ns(wd); goto nextparam; } if (eq(wd, "compile-with")) { wd = get_quoted_word(fp); - if (wd == (char *)EOF || wd == 0) { - fprintf(stderr, - "%s: %s missing compile command string.\n", + if (wd == (char *)EOF || wd == 0) + errout("%s: %s missing compile command string.\n", fname, this); - exit(1); - } compilewith = ns(wd); goto nextparam; } if (eq(wd, "warning")) { wd = get_quoted_word(fp); - if (wd == (char *)EOF || wd == 0) { - fprintf(stderr, - "%s: %s missing warning text string.\n", + if (wd == (char *)EOF || wd == 0) + errout("%s: %s missing warning text string.\n", fname, this); - exit(1); - } warning = ns(wd); goto nextparam; } if (eq(wd, "obj-prefix")) { wd = get_quoted_word(fp); - if (wd == (char *)EOF || wd == 0) { - printf("%s: %s missing object prefix string.\n", + if (wd == (char *)EOF || wd == 0) + errout("%s: %s missing object prefix string.\n", fname, this); - exit(1); - } objprefix = ns(wd); goto nextparam; } @@ -501,12 +485,9 @@ nextparam: nowerror = 1; goto nextparam; } - if (std) { - fprintf(stderr, - "standard entry %s has optional inclusion specifier %s!\n", + if (std) + errout("standard entry %s has optional inclusion specifier %s!\n", this, wd); - exit(1); - } nreqs++; STAILQ_FOREACH(dp, &dtab, d_next) if (eq(dp->d_name, wd)) {