[Midnightbsd-cvs] src [7114] trunk/usr.sbin/config: update config after lex/yacc

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sun Jul 19 10:04:14 EDT 2015


Revision: 7114
          http://svnweb.midnightbsd.org/src/?rev=7114
Author:   laffer1
Date:     2015-07-19 10:04:13 -0400 (Sun, 19 Jul 2015)
Log Message:
-----------
update config after lex/yacc

Modified Paths:
--------------
    trunk/usr.sbin/config/Makefile
    trunk/usr.sbin/config/config.5
    trunk/usr.sbin/config/config.8
    trunk/usr.sbin/config/config.h
    trunk/usr.sbin/config/config.y
    trunk/usr.sbin/config/configvers.h
    trunk/usr.sbin/config/kernconf.tmpl
    trunk/usr.sbin/config/lang.l
    trunk/usr.sbin/config/main.c
    trunk/usr.sbin/config/mkheaders.c
    trunk/usr.sbin/config/mkmakefile.c

Removed Paths:
-------------
    trunk/usr.sbin/config/SMM.doc/

Property Changed:
----------------
    trunk/usr.sbin/config/config.5
    trunk/usr.sbin/config/config.8
    trunk/usr.sbin/config/config.y
    trunk/usr.sbin/config/kernconf.tmpl
    trunk/usr.sbin/config/lang.l

Modified: trunk/usr.sbin/config/Makefile
===================================================================
--- trunk/usr.sbin/config/Makefile	2015-07-19 13:58:36 UTC (rev 7113)
+++ trunk/usr.sbin/config/Makefile	2015-07-19 14:04:13 UTC (rev 7114)
@@ -1,5 +1,5 @@
 # 	@(#)Makefile	8.1 (Berkeley) 6/6/93
-# $MidnightBSD$
+# $FreeBSD: stable/10/usr.sbin/config/Makefile 249657 2013-04-19 19:45:00Z ed $
 
 PROG=	config
 MAN=	config.5 config.8
@@ -11,6 +11,8 @@
 
 CFLAGS+= -I. -I${.CURDIR}
 
+NO_WMISSING_VARIABLE_DECLARATIONS=
+
 DPADD=	${LIBL} ${LIBSBUF}
 LDADD=	-ll -lsbuf
 

Modified: trunk/usr.sbin/config/config.5
===================================================================
--- trunk/usr.sbin/config/config.5	2015-07-19 13:58:36 UTC (rev 7113)
+++ trunk/usr.sbin/config/config.5	2015-07-19 14:04:13 UTC (rev 7114)
@@ -21,7 +21,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/config/config.5 213653 2010-10-09 11:43:00Z uqs $
 .\"
 .Dd December 3, 2005
 .Dt CONFIG 5


Property changes on: trunk/usr.sbin/config/config.5
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/config/config.8
===================================================================
--- trunk/usr.sbin/config/config.8	2015-07-19 13:58:36 UTC (rev 7113)
+++ trunk/usr.sbin/config/config.8	2015-07-19 14:04:13 UTC (rev 7114)
@@ -26,7 +26,7 @@
 .\" SUCH DAMAGE.
 .\"
 .\"     @(#)config.8	8.2 (Berkeley) 4/19/94
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/config/config.8 264325 2014-04-10 19:51:33Z asomers $
 .\"
 .Dd May 8, 2007
 .Dt CONFIG 8
@@ -37,6 +37,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl CVgp
+.Op Fl I Ar path
 .Op Fl d Ar destdir
 .Ar SYSTEM_NAME
 .Nm
@@ -69,6 +70,12 @@
 kernel image will contain full configuration files included
 literally (preserving comments).
 This flag is kept for backward compatibility.
+.It Fl I Ar path
+Search in
+.Ar path
+for any file included by the 
+.Ic include
+directive.  This option may be specified more than once.
 .It Fl d Ar destdir
 Use
 .Ar destdir


Property changes on: trunk/usr.sbin/config/config.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/config/config.h
===================================================================
--- trunk/usr.sbin/config/config.h	2015-07-19 13:58:36 UTC (rev 7113)
+++ trunk/usr.sbin/config/config.h	2015-07-19 14:04:13 UTC (rev 7114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1980, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -27,7 +28,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)config.h	8.1 (Berkeley) 6/6/93
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/config/config.h 264325 2014-04-10 19:51:33Z asomers $
  */
 
 /*
@@ -144,6 +145,13 @@
 
 STAILQ_HEAD(hint_head, hint) hints;
 
+struct includepath {
+	char	*path;
+	SLIST_ENTRY(includepath) path_next;
+};
+
+SLIST_HEAD(, includepath) includepath;
+
 /*
  * Tag present in the kernelconf.tmlp template file. It's mandatory for those
  * two strings to be the same. Otherwise you'll get into trouble.
@@ -171,7 +179,6 @@
 char	*raisestr(char *);
 void	remember(const char *);
 void	moveifchanged(const char *, const char *);
-int	yyparse(void);
 int	yylex(void);
 void	options(void);
 void	makefile(void);

Modified: trunk/usr.sbin/config/config.y
===================================================================
--- trunk/usr.sbin/config/config.y	2015-07-19 13:58:36 UTC (rev 7113)
+++ trunk/usr.sbin/config/config.y	2015-07-19 14:04:13 UTC (rev 7114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 %union {
 	char	*str;
 	int	val;
@@ -65,7 +66,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)config.y	8.1 (Berkeley) 6/6/93
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/config/config.y 216372 2010-12-11 09:38:12Z joel $
  */
 
 #include <assert.h>


Property changes on: trunk/usr.sbin/config/config.y
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/config/configvers.h
===================================================================
--- trunk/usr.sbin/config/configvers.h	2015-07-19 13:58:36 UTC (rev 7113)
+++ trunk/usr.sbin/config/configvers.h	2015-07-19 14:04:13 UTC (rev 7114)
@@ -1,7 +1,8 @@
+/* $MidnightBSD$ */
 /*-
  * This file is in the public domain
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/config/configvers.h 269825 2014-08-11 18:42:20Z imp $
  */
 
 /*
@@ -47,7 +48,7 @@
  *     %VERSREQ field in the Makefile.$ARCH of all the affected makefiles
  *     (typically all of them).
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/config/configvers.h 269825 2014-08-11 18:42:20Z imp $
  */
-#define	CONFIGVERS	600012
+#define	CONFIGVERS	600013
 #define	MAJOR_VERS(x)	((x) / 100000)

Modified: trunk/usr.sbin/config/kernconf.tmpl
===================================================================
--- trunk/usr.sbin/config/kernconf.tmpl	2015-07-19 13:58:36 UTC (rev 7113)
+++ trunk/usr.sbin/config/kernconf.tmpl	2015-07-19 14:04:13 UTC (rev 7114)
@@ -2,7 +2,7 @@
  * This file acts as a template for config.c that will be generated in the
  * kernel build directory after config(8) has been successfully run.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/config/kernconf.tmpl 169604 2007-05-16 16:08:04Z wkoszek $
  */
 #include "opt_config.h"
 #ifdef INCLUDE_CONFIG_FILE


Property changes on: trunk/usr.sbin/config/kernconf.tmpl
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/config/lang.l
===================================================================
--- trunk/usr.sbin/config/lang.l	2015-07-19 13:58:36 UTC (rev 7113)
+++ trunk/usr.sbin/config/lang.l	2015-07-19 14:04:13 UTC (rev 7114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 %{
 /*-
  * Copyright (c) 1980, 1993
@@ -28,19 +29,17 @@
  * SUCH DAMAGE.
  *
  *	@(#)lang.l	8.1 (Berkeley) 6/6/93
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/config/lang.l 264325 2014-04-10 19:51:33Z asomers $
  */
 
 #include <assert.h>
 #include <ctype.h>
 #include <err.h>
+#include <stdlib.h>
 #include <string.h>
 #include "y.tab.h"
 #include "config.h"
 
-#define YY_NO_UNPUT
-#define YY_NO_INPUT
-
 /*
  * Data for returning to previous files from include files.
  */
@@ -96,7 +95,12 @@
 unsigned int hex(const char *);
 int yyerror(const char *);
 
+#define YY_DECL int yylex(void)
 %}
+
+%option nounput
+%option noinput
+
 ID	[A-Za-z_][-A-Za-z_0-9]*
 PATH	[./][-/.%^A-Za-z_0-9]+
 %START TOEOL
@@ -255,6 +259,7 @@
 {
 	FILE *fp;
 	struct incl *in;
+	struct includepath* ipath;
 	char *fnamebuf;
 
 	fnamebuf = NULL;
@@ -267,6 +272,17 @@
 		}
 	}
 	if (fp == NULL) {
+		SLIST_FOREACH(ipath, &includepath, path_next) {
+			asprintf(&fnamebuf, "%s/%s", ipath->path, fname);
+			if (fnamebuf != NULL) {
+				fp = fopen(fnamebuf, "r");
+				free(fnamebuf);
+			}
+			if (fp != NULL)
+				break;
+		}
+	}
+	if (fp == NULL) {
 		yyerror("cannot open included file");
 		return (-1);
 	}


Property changes on: trunk/usr.sbin/config/lang.l
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/config/main.c
===================================================================
--- trunk/usr.sbin/config/main.c	2015-07-19 13:58:36 UTC (rev 7113)
+++ trunk/usr.sbin/config/main.c	2015-07-19 14:04:13 UTC (rev 7114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1980, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -38,7 +39,7 @@
 static char sccsid[] = "@(#)main.c	8.1 (Berkeley) 6/6/93";
 #endif
 static const char rcsid[] =
-  "$MidnightBSD$";
+  "$FreeBSD: stable/10/usr.sbin/config/main.c 276280 2014-12-27 03:19:04Z ian $";
 #endif /* not lint */
 
 #include <sys/types.h>
@@ -91,6 +92,7 @@
 static void cleanheaders(char *);
 static void kernconfdump(const char *);
 static void checkversion(void);
+extern int yyparse(void);
 
 struct hdr_list {
 	char *h_name;
@@ -109,15 +111,25 @@
 	int ch, len;
 	char *p;
 	char *kernfile;
+	struct includepath* ipath;
 	int printmachine;
 
 	printmachine = 0;
 	kernfile = NULL;
-	while ((ch = getopt(argc, argv, "Cd:gmpVx:")) != -1)
+	SLIST_INIT(&includepath);
+	while ((ch = getopt(argc, argv, "CI:d:gmpVx:")) != -1)
 		switch (ch) {
 		case 'C':
 			filebased = 1;
 			break;
+		case 'I':
+			ipath = (struct includepath *) \
+			    	calloc(1, sizeof (struct includepath));
+			if (ipath == NULL)
+				err(EXIT_FAILURE, "calloc");
+			ipath->path = optarg;
+			SLIST_INSERT_HEAD(&includepath, ipath, path_next);
+			break;
 		case 'm':
 			printmachine = 1;
 			break;
@@ -303,6 +315,11 @@
 	}
 	cp = line;
 	*cp++ = ch;
+	/* Negation operator is a word by itself. */
+	if (ch == '!') {
+		*cp = 0;
+		return (line);
+	}
 	while ((ch = getc(fp)) != EOF) {
 		if (isspace(ch))
 			break;
@@ -350,16 +367,24 @@
 	if (ch == '"' || ch == '\'') {
 		int quote = ch;
 
+		escaped_nl = 0;
 		while ((ch = getc(fp)) != EOF) {
-			if (ch == quote)
+			if (ch == quote && !escaped_nl)
 				break;
-			if (ch == '\n') {
+			if (ch == '\n' && !escaped_nl) {
 				*cp = 0;
 				printf("config: missing quote reading `%s'\n",
 					line);
 				exit(2);
 			}
+			if (ch == '\\' && !escaped_nl) {
+				escaped_nl = 1;
+				continue;
+			}
+			if (ch != quote && escaped_nl)
+				*cp++ = '\\';
 			*cp++ = ch;
+			escaped_nl = 0;
 		}
 	} else {
 		*cp++ = ch;
@@ -626,7 +651,7 @@
 	else
 		s = ns(file);
 
-	if (index(s, '_') && strncmp(s, "opt_", 4) != 0) {
+	if (strchr(s, '_') && strncmp(s, "opt_", 4) != 0) {
 		free(s);
 		return;
 	}
@@ -697,17 +722,11 @@
 		r = fgetc(fp);
 		if (r == EOF)
 			break;
-		/* 
-		 * If '\0' is present in the middle of the configuration
-		 * string, this means something very weird is happening.
-		 * Make such case very visible.  However, some architectures
-		 * pad the length of the section with NULs to a multiple of
-		 * sh_addralign, allow a NUL in that part of the section.
-		 */
-		if (r == '\0' && (size - i) < align)
+		if (r == '\0') {
+			assert(i == size - 1 &&
+			    ("\\0 found in the middle of a file"));
 			break;
-		assert(r != '\0' && ("Char present in the configuration "
-		    "string mustn't be equal to 0"));
+		}
 		fputc(r, stdout);
 	}
 	fclose(fp);

Modified: trunk/usr.sbin/config/mkheaders.c
===================================================================
--- trunk/usr.sbin/config/mkheaders.c	2015-07-19 13:58:36 UTC (rev 7113)
+++ trunk/usr.sbin/config/mkheaders.c	2015-07-19 14:04:13 UTC (rev 7114)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1980, 1993
  *	The Regents of the University of California.  All rights reserved.
@@ -32,7 +33,7 @@
 static char sccsid[] = "@(#)mkheaders.c	8.1 (Berkeley) 6/6/93";
 #endif
 static const char rcsid[] =
-  "$MidnightBSD$";
+  "$FreeBSD: stable/10/usr.sbin/config/mkheaders.c 152811 2005-11-25 22:25:34Z ru $";
 #endif /* not lint */
 
 /*

Modified: trunk/usr.sbin/config/mkmakefile.c
===================================================================
--- trunk/usr.sbin/config/mkmakefile.c	2015-07-19 13:58:36 UTC (rev 7113)
+++ trunk/usr.sbin/config/mkmakefile.c	2015-07-19 14:04:13 UTC (rev 7114)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1993, 19801990
+ * Copyright (c) 1980, 1990, 1993
  *	The Regents of the University of California.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -43,6 +43,7 @@
 
 #include <ctype.h>
 #include <err.h>
+#include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
 #include <sys/param.h>
@@ -50,21 +51,6 @@
 #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 *);
@@ -74,6 +60,16 @@
 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.
  */
@@ -154,7 +150,7 @@
 		fprintf(ofp, "PROFLEVEL=%d\n", profiling);
 	if (*srcdir != '\0')
 		fprintf(ofp,"S=%s\n", srcdir);
-	while (fgets(line, BUFSIZ, ifp) != 0) {
+	while (fgets(line, BUFSIZ, ifp) != NULL) {
 		if (*line != '%') {
 			fprintf(ofp, "%s", line);
 			continue;
@@ -204,14 +200,14 @@
 		ifp = fopen(hint->hint_name, "r");
 		if (ifp == NULL)
 			err(1, "%s", hint->hint_name);
-		while (fgets(line, BUFSIZ, ifp) != 0) {
+		while (fgets(line, BUFSIZ, ifp) != NULL) {
 			/* zap trailing CR and/or LF */
-			while ((s = rindex(line, '\n')) != NULL)
+			while ((s = strrchr(line, '\n')) != NULL)
 				*s = '\0';
-			while ((s = rindex(line, '\r')) != NULL)
+			while ((s = strrchr(line, '\r')) != NULL)
 				*s = '\0';
 			/* remove # comments */
-			s = index(line, '#');
+			s = strchr(line, '#');
 			if (s)
 				*s = '\0';
 			/* remove any whitespace and " characters */
@@ -266,14 +262,14 @@
 	fprintf(ofp, "int envmode = %d;\n", envmode);
 	fprintf(ofp, "char static_env[] = {\n");
 	if (ifp) {
-		while (fgets(line, BUFSIZ, ifp) != 0) {
+		while (fgets(line, BUFSIZ, ifp) != NULL) {
 			/* zap trailing CR and/or LF */
-			while ((s = rindex(line, '\n')) != NULL)
+			while ((s = strrchr(line, '\n')) != NULL)
 				*s = '\0';
-			while ((s = rindex(line, '\r')) != NULL)
+			while ((s = strrchr(line, '\r')) != NULL)
 				*s = '\0';
 			/* remove # comments */
-			s = index(line, '#');
+			s = strchr(line, '#');
 			if (s)
 				*s = '\0';
 			/* remove any whitespace and " characters */
@@ -313,8 +309,8 @@
 	struct opt *op;
 	char *wd, *this, *compilewith, *depends, *clean, *warning;
 	const char *objprefix;
-	int compile, match, nreqs, std, filetype,
-	    imp_rule, no_obj, before_depend, mandatory, nowerror;
+	int compile, match, nreqs, std, filetype, not,
+	    imp_rule, no_obj, before_depend, nowerror;
 
 	fp = fopen(fname, "r");
 	if (fp == 0)
@@ -322,7 +318,7 @@
 next:
 	/*
 	 * include "filename"
-	 * filename    [ standard | mandatory | optional ]
+	 * filename    [ standard | optional ]
 	 *	[ dev* [ | dev* ... ] | profiling-routine ] [ no-obj ]
 	 *	[ compile-with "compile rule" [no-implicit-rule] ]
 	 *      [ dependency "dependency-list"] [ before-depend ]
@@ -343,12 +339,9 @@
 		goto next;
 	}
 	if (eq(wd, "include")) {
-		next_quoted_word(fp, wd);
-		if (wd == 0) {
-			fprintf(stderr, "%s: missing include filename.\n",
-			    fname);
-			exit(1);
-		}
+		wd = get_quoted_word(fp);
+		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)
@@ -356,11 +349,11 @@
 		goto next;
 	}
 	this = ns(wd);
-	next_word(fp, wd);
-	if (wd == 0) {
-		fprintf(stderr, "%s: No type for %s.\n", fname, this);
-		exit(1);
-	}
+	wd = get_word(fp);
+	if (wd == (char *)EOF)
+		return;
+	if (wd == 0)
+		errout("%s: No type for %s.\n", fname, this);
 	tp = fl_lookup(this);
 	compile = 0;
 	match = 1;
@@ -369,186 +362,154 @@
 	depends = 0;
 	clean = 0;
 	warning = 0;
-	std = mandatory = 0;
+	std = 0;
 	imp_rule = 0;
 	no_obj = 0;
 	before_depend = 0;
 	nowerror = 0;
+	not = 0;
 	filetype = NORMAL;
 	objprefix = "";
-	if (eq(wd, "standard")) {
+	if (eq(wd, "standard"))
 		std = 1;
-	/*
-	 * If an entry is marked "mandatory", config will abort if it's
-	 * not called by a configuration line in the config file.  Apart
-	 * from this, the device is handled like one marked "optional".
-	 */
-	} else if (eq(wd, "mandatory")) {
-		mandatory = 1;
-	} else if (!eq(wd, "optional")) {
-		fprintf(stderr,
-		    "%s: \"%s\" %s must be optional, mandatory or standard\n",
+	else if (!eq(wd, "optional"))
+		errout("%s: \"%s\" %s must be optional or standard\n",
 		    fname, wd, this);
-		exit(1);
-	}
-nextparam:
-	next_word(fp, wd);
-	if (wd == 0) {
-		compile += match;
-		if (compile && tp == NULL)
-			goto doneparam;
-		goto next;
-	}
-	if (eq(wd, "|")) {
-		if (nreqs == 0) {
-			fprintf(stderr, "%s: syntax error describing %s\n",
-			    fname, this);
-			exit(1);
+	for (wd = get_word(fp); wd; wd = get_word(fp)) {
+		if (wd == (char *)EOF)
+			return;
+		if (eq(wd, "!")) {
+			not = 1;
+			continue;
 		}
-		compile += match;
-		match = 1;
-		nreqs = 0;
-		goto nextparam;
-	}
-	if (eq(wd, "no-obj")) {
-		no_obj++;
-		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 (eq(wd, "|")) {
+			if (nreqs == 0)
+				errout("%s: syntax error describing %s\n",
+				       fname, this);
+			compile += match;
+			match = 1;
+			nreqs = 0;
+			continue;
 		}
-		imp_rule++;
-		goto nextparam;
-	}
-	if (eq(wd, "before-depend")) {
-		before_depend++;
-		goto nextparam;
-	}
-	if (eq(wd, "dependency")) {
-		next_quoted_word(fp, wd);
-		if (wd == 0) {
-			fprintf(stderr,
-			    "%s: %s missing compile command string.\n",
-			    fname, this);
-			exit(1);
+		if (eq(wd, "no-obj")) {
+			no_obj++;
+			continue;
 		}
-		depends = ns(wd);
-		goto nextparam;
-	}
-	if (eq(wd, "clean")) {
-		next_quoted_word(fp, wd);
-		if (wd == 0) {
-			fprintf(stderr, "%s: %s missing clean file list.\n",
-			    fname, this);
-			exit(1);
+		if (eq(wd, "no-implicit-rule")) {
+			if (compilewith == 0)
+				errout("%s: alternate rule required when "
+				       "\"no-implicit-rule\" is specified for"
+				       " %s.\n",
+				       fname, this);
+			imp_rule++;
+			continue;
 		}
-		clean = ns(wd);
-		goto nextparam;
-	}
-	if (eq(wd, "compile-with")) {
-		next_quoted_word(fp, wd);
-		if (wd == 0) {
-			fprintf(stderr,
-			    "%s: %s missing compile command string.\n",
-			    fname, this);
-			exit(1);
+		if (eq(wd, "before-depend")) {
+			before_depend++;
+			continue;
 		}
-		compilewith = ns(wd);
-		goto nextparam;
-	}
-	if (eq(wd, "warning")) {
-		next_quoted_word(fp, wd);
-		if (wd == 0) {
-			fprintf(stderr,
-			    "%s: %s missing warning text string.\n",
-			    fname, this);
-			exit(1);
+		if (eq(wd, "dependency")) {
+			wd = get_quoted_word(fp);
+			if (wd == (char *)EOF || wd == 0)
+				errout("%s: %s missing dependency string.\n",
+				       fname, this);
+			depends = ns(wd);
+			continue;
 		}
-		warning = ns(wd);
-		goto nextparam;
-	}
-	if (eq(wd, "obj-prefix")) {
-		next_quoted_word(fp, wd);
-		if (wd == 0) {
-			printf("%s: %s missing object prefix string.\n",
-				fname, this);
-			exit(1);
+		if (eq(wd, "clean")) {
+			wd = get_quoted_word(fp);
+			if (wd == (char *)EOF || wd == 0)
+				errout("%s: %s missing clean file list.\n",
+				       fname, this);
+			clean = ns(wd);
+			continue;
 		}
-		objprefix = ns(wd);
-		goto nextparam;
-	}
-	nreqs++;
-	if (eq(wd, "local")) {
-		filetype = LOCAL;
-		goto nextparam;
-	}
-	if (eq(wd, "no-depend")) {
-		filetype = NODEPEND;
-		goto nextparam;
-	}
-	if (eq(wd, "profiling-routine")) {
-		filetype = PROFILING;
-		goto nextparam;
-	}
-	if (eq(wd, "nowerror")) {
-		nowerror = 1;
-		goto nextparam;
-	}
-	STAILQ_FOREACH(dp, &dtab, d_next)
-		if (eq(dp->d_name, wd)) {
-			dp->d_done |= DEVDONE;
-			goto nextparam;
+		if (eq(wd, "compile-with")) {
+			wd = get_quoted_word(fp);
+			if (wd == (char *)EOF || wd == 0)
+				errout("%s: %s missing compile command string.\n",
+				       fname, this);
+			compilewith = ns(wd);
+			continue;
 		}
-	if (mandatory) {
-		fprintf(stderr, "%s: mandatory device \"%s\" not found\n",
-		       fname, wd);
-		exit(1);
+		if (eq(wd, "warning")) {
+			wd = get_quoted_word(fp);
+			if (wd == (char *)EOF || wd == 0)
+				errout("%s: %s missing warning text string.\n",
+				       fname, this);
+			warning = ns(wd);
+			continue;
+		}
+		if (eq(wd, "obj-prefix")) {
+			wd = get_quoted_word(fp);
+			if (wd == (char *)EOF || wd == 0)
+				errout("%s: %s missing object prefix string.\n",
+				       fname, this);
+			objprefix = ns(wd);
+			continue;
+		}
+		if (eq(wd, "nowerror")) {
+			nowerror = 1;
+			continue;
+		}
+		if (eq(wd, "local")) {
+			filetype = LOCAL;
+			continue;
+		}
+		if (eq(wd, "no-depend")) {
+			filetype = NODEPEND;
+			continue;
+		}
+		nreqs++;
+		if (eq(wd, "profiling-routine")) {
+			filetype = PROFILING;
+			continue;
+		}
+		if (std)
+			errout("standard entry %s has optional inclusion specifier %s!\n",
+			       this, wd);
+		STAILQ_FOREACH(dp, &dtab, d_next)
+			if (eq(dp->d_name, wd)) {
+				if (not)
+					match = 0;
+				else
+					dp->d_done |= DEVDONE;
+				goto nextparam;
+			}
+		SLIST_FOREACH(op, &opt, op_next)
+			if (op->op_value == 0 && opteq(op->op_name, wd)) {
+				if (not)
+					match = 0;
+				goto nextparam;
+			}
+		match &= not;
+nextparam:;
+		not = 0;
 	}
-	if (std) {
-		fprintf(stderr,
-		    "standard entry %s has a device keyword - %s!\n",
-		    this, wd);
-		exit(1);
+	compile += match;
+	if (compile && tp == NULL) {
+		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();
+		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;
 	}
-	SLIST_FOREACH(op, &opt, op_next)
-		if (op->op_value == 0 && opteq(op->op_name, wd))
-			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;
 }
 
@@ -689,7 +650,7 @@
 {
 	char *cp;
 
-	cp = rindex(fn, '/');
+	cp = strrchr(fn, '/');
 	if (cp == 0)
 		return (fn);
 	return (cp+1);
@@ -762,7 +723,7 @@
 				break;
 			}
 			snprintf(cmd, sizeof(cmd),
-			    "${%s_%c%s}\n\t@${NORMAL_CTFCONVERT}", ftype,
+			    "${%s_%c%s}", ftype,
 			    toupper(och),
 			    ftp->f_flags & NOWERROR ? "_NOWERROR" : "");
 			compilewith = cmd;
@@ -769,9 +730,14 @@
 		}
 		*cp = och;
 		if (strlen(ftp->f_objprefix))
-			fprintf(f, "\t%s $S/%s\n\n", compilewith, np);
+			fprintf(f, "\t%s $S/%s\n", compilewith, np);
 		else
-			fprintf(f, "\t%s\n\n", compilewith);
+			fprintf(f, "\t%s\n", compilewith);
+
+		if (!(ftp->f_flags & NO_OBJ))
+			fprintf(f, "\t${NORMAL_CTFCONVERT}\n\n");
+		else
+			fprintf(f, "\n");
 	}
 }
 



More information about the Midnightbsd-cvs mailing list