Some diffs

M. Warner Losh imp at bsdimp.com
Wed Dec 19 22:25:54 PST 2007


Consider the following diffs.  The first one does a tiny cleanup of
strfile's include style (no real reason other than it bugged me when I
added stdint.h).

The second one cleans up a minor problem where ${CFLAGS} isn't used
where it should be.

The next three cleanup the compilation by not assuming sys/types.h is
included or by also including <stdint.h>

And the last, rather long, patch converts the .y in config to a form
that more versions of yacc would grok.

Comments?

Warner

==== //depot/projects/arm/src/games/fortune/strfile/strfile.c#1 - /Users/imp/p4/arm/src/games/fortune/strfile/strfile.c ====
@@ -48,16 +48,17 @@
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/games/fortune/strfile/strfile.c,v 1.28 2005/02/17 18:06:37 ru Exp $");
 
-# include	<sys/param.h>
-# include	<sys/endian.h>
-# include	<stdio.h>
-# include       <stdlib.h>
-# include	<ctype.h>
-# include       <string.h>
-# include       <time.h>
-# include       <locale.h>
-# include       <unistd.h>
-# include	"strfile.h"
+#include <sys/param.h>
+#include <sys/endian.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include <time.h>
+#include <locale.h>
+#include <unistd.h>
+#include "strfile.h"
 
 /*
  *	This program takes a file composed of strings separated by
==== //depot/projects/arm/src/lib/libmagic/Makefile#2 - /Users/imp/p4/arm/src/lib/libmagic/Makefile ====
@@ -40,8 +40,7 @@
 CLEANFILES+=	mkmagic
 build-tools: mkmagic
 mkmagic: apprentice.c funcs.c magic.c print.c
-	${CC} -DHAVE_CONFIG_H -DCOMPILE_ONLY \
-	    -I${.CURDIR} -I${CONTRDIR} -o ${.TARGET} ${.ALLSRC}
+	${CC} -DHAVE_CONFIG_H ${CFLAGS} -o ${.TARGET} ${.ALLSRC}
 
 FILEVER!= awk '$$1 == "\#define" && $$2 == "VERSION" { print $$3; exit }' \
 			${.CURDIR}/config.h
==== //depot/projects/arm/src/share/mk/bsd.prog.mk#4 - /Users/imp/p4/arm/src/share/mk/bsd.prog.mk ====
@@ -110,17 +110,18 @@
 
 .if defined(PROG)
 _EXTRADEPEND:
-.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib)
+.if !defined(FOREIGN_BUILD)
 .if defined(DPADD) && !empty(DPADD)
 	echo ${PROG}: ${DPADD} >> ${DEPENDFILE}
 .endif
-.else
+.if defined(LDFLAGS) && !empty(LDFLAGS:M-nostdlib)
 	echo ${PROG}: ${LIBC} ${DPADD} >> ${DEPENDFILE}
 .if defined(PROG_CXX)
 	echo ${PROG}: ${LIBSTDCPLUSPLUS} >> ${DEPENDFILE}
 .endif
 .endif
 .endif
+.endif
 
 .if !target(install)
 
==== //depot/projects/arm/src/usr.bin/colldef/parse.y#1 - /Users/imp/p4/arm/src/usr.bin/colldef/parse.y ====
@@ -30,6 +30,7 @@
 __FBSDID("$FreeBSD: src/usr.bin/colldef/parse.y,v 1.34 2005/05/21 09:55:05 ru Exp $");
 
 #include <arpa/inet.h>
+#include <sys/types.h>
 #include <err.h>
 #include <stdarg.h>
 #include <stdio.h>
==== //depot/projects/arm/src/usr.bin/colldef/scan.l#1 - /Users/imp/p4/arm/src/usr.bin/colldef/scan.l ====
@@ -36,6 +36,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <sysexits.h>
+#include <sys/types.h>
 #include "common.h"
 #include "y.tab.h"
 
==== //depot/projects/arm/src/usr.bin/mklocale/ldef.h#1 - /Users/imp/p4/arm/src/usr.bin/mklocale/ldef.h ====
@@ -38,6 +38,7 @@
  */
 
 #include <sys/types.h>
+#include <stdint.h>
 
 /*
  * This should look a LOT like a _RuneEntry
==== //depot/projects/arm/src/usr.sbin/config/config.y#9 - /Users/imp/p4/arm/src/usr.sbin/config/config.y ====
@@ -95,6 +95,12 @@
 void yyerror(const char *s);
 int yywrap(void);
 
+static void newdev(char *name);
+static void newfile(char *name);
+static void rmdev_schedule(struct device_head *dh, char *name);
+static void newopt(struct opt_head *list, char *name, char *value);
+static void rmopt_schedule(struct opt_head *list, char *name);
+
 static char *
 devopt(char *dev)
 {
@@ -122,14 +128,12 @@
 		|
 	Config_spec SEMICOLON
 		|
-	INCLUDE ID SEMICOLON
-	      = {
+	INCLUDE ID SEMICOLON {
 	          if (incignore == 0)
 		  	include($2, 0);
 		};
 		|
-	FILES ID SEMICOLON
-	      = { newfile($2); };
+	FILES ID SEMICOLON { newfile($2); };
 	        |
 	SEMICOLON
 		|
@@ -137,16 +141,14 @@
 		;
 
 Config_spec:
-	ARCH Save_id
-	    = {
+	ARCH Save_id {
 		if (machinename != NULL && !eq($2, machinename))
 		    errx(1, "%s:%d: only one machine directive is allowed",
 			yyfile, yyline);
 		machinename = $2;
 		machinearch = $2;
 	      } |
-	ARCH Save_id Save_id
-	    = {
+	ARCH Save_id Save_id {
 		if (machinename != NULL &&
 		    !(eq($2, machinename) && eq($3, machinearch)))
 		    errx(1, "%s:%d: only one machine directive is allowed",
@@ -154,15 +156,13 @@
 		machinename = $2;
 		machinearch = $3;
 	      } |
-	CPU Save_id
-	      = {
+	CPU Save_id {
 		struct cputype *cp =
 		    (struct cputype *)calloc(1, sizeof (struct cputype));
 		cp->cpu_name = $2;
 		SLIST_INSERT_HEAD(&cputype, cp, cpu_next);
 	      } |
-	NOCPU Save_id
-	      = {
+	NOCPU Save_id {
 		struct cputype *cp, *cp2;
 		SLIST_FOREACH_SAFE(cp, &cputype, cpu_next, cp2) {
 			if (eq(cp->cpu_name, $2)) {
@@ -173,27 +173,20 @@
 	      } |
 	OPTIONS Opt_list
 		|
-	NOOPTION Save_id
-	      = { rmopt_schedule(&opt, $2); } |
+	NOOPTION Save_id { rmopt_schedule(&opt, $2); } |
 	MAKEOPTIONS Mkopt_list
 		|
-	NOMAKEOPTION Save_id
-	      = { rmopt_schedule(&mkopt, $2); } |
-	IDENT ID
-	      = { ident = $2; } |
+	NOMAKEOPTION Save_id { rmopt_schedule(&mkopt, $2); } |
+	IDENT ID { ident = $2; } |
 	System_spec
 		|
-	MAXUSERS NUMBER
-	      = { maxusers = $2; } |
-	PROFILE NUMBER
-	      = { profiling = $2; } |
-	ENV ID
-	      = {
+	MAXUSERS NUMBER { maxusers = $2; } |
+	PROFILE NUMBER { profiling = $2; } |
+	ENV ID {
 		env = $2;
 		envmode = 1;
 		} |
-	HINTS ID
-	      = {
+	HINTS ID {
 		struct hint *hint;
 
 		hint = (struct hint *)calloc(1, sizeof (struct hint));
@@ -203,16 +196,16 @@
 	        }
 
 System_spec:
-	CONFIG System_id System_parameter_list
-	  = { errx(1, "%s:%d: root/dump/swap specifications obsolete",
-	      yyfile, yyline);}
+	CONFIG System_id System_parameter_list {
+		errx(1, "%s:%d: root/dump/swap specifications obsolete",
+		      yyfile, yyline);
+		}
 	  |
 	CONFIG System_id
 	  ;
 
 System_id:
-	Save_id
-	      = { newopt(&mkopt, ns("KERNEL"), $1); };
+	Save_id { newopt(&mkopt, ns("KERNEL"), $1); };
 
 System_parameter_list:
 	  System_parameter_list ID
@@ -226,23 +219,19 @@
 		;
 
 Option:
-	Save_id
-	      = {
+	Save_id {
 		newopt(&opt, $1, NULL);
 		if (strchr($1, '=') != NULL)
 			errx(1, "%s:%d: The `=' in options should not be "
 			    "quoted", yyfile, yyline);
 	      } |
-	Save_id EQUALS Opt_value
-	      = {
+	Save_id EQUALS Opt_value {
 		newopt(&opt, $1, $3);
 	      } ;
 
 Opt_value:
-	ID
-		= { $$ = $1; } |
-	NUMBER
-		= {
+	ID { $$ = $1; } |
+	NUMBER {
 			char buf[80];
 
 			(void) snprintf(buf, sizeof(buf), "%d", $1);
@@ -250,8 +239,7 @@
 		} ;
 
 Save_id:
-	ID
-	      = { $$ = $1; }
+	ID { $$ = $1; }
 	;
 
 Mkopt_list:
@@ -261,14 +249,11 @@
 		;
 
 Mkoption:
-	Save_id
-	      = { newopt(&mkopt, $1, ns("")); } |
-	Save_id EQUALS Opt_value
-	      = { newopt(&mkopt, $1, $3); } ;
+	Save_id { newopt(&mkopt, $1, ns("")); } |
+	Save_id EQUALS Opt_value { newopt(&mkopt, $1, $3); } ;
 
 Dev:
-	ID
-	      = { $$ = $1; }
+	ID { $$ = $1; }
 	;
 
 Device_spec:
@@ -290,16 +275,14 @@
 		;
 
 Device:
-	Dev
-	      = {
+	Dev {
 		newopt(&opt, devopt($1), ns("1"));
 		/* and the device part */
 		newdev($1);
 		}
 
 NoDevice:
-	Dev
-	      = {
+	Dev {
 		char *s = devopt($1);
 
 		rmopt_schedule(&opt, s);


More information about the freebsd-hackers mailing list