usr.bin/make Code cleanup

Max Okumoto okumoto at ucsd.edu
Wed Nov 17 16:48:01 PST 2004


Taken from FreeBSD 2002/04/12 14:23:33

Reorder #include. Cast arg #2 of lseek to an off_t when constant. No need to
test if failsafe memory allocation fails, it can't. perror -> warn. Use
failsafe memory allocation provided.
And some other doc cleanup.

				Max
---------------------
PatchSet 217
Date: 2002/04/12 14:23:33
Author: charnier
Log:
Reorder #include. Cast arg #2 of lseek to an off_t when constant. No need to
test if failsafe memory allocation fails, it can't. perror -> warn. Use
failsafe memory allocation provided.

Use .Pa and .Ar. Uppercase (first letter) programname after dot.

Members: 
	job.c:1.28->1.29 
	main.c:1.51->1.52 
	make.1:1.48->1.49 

Index: job.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/job.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- job.c	22 Mar 2002 01:33:14 -0000	1.28
+++ job.c	12 Apr 2002 13:23:33 -0000	1.29
@@ -108,13 +108,14 @@
 #include <sys/file.h>
 #include <sys/time.h>
 #include <sys/wait.h>
-#include <fcntl.h>
+#include <err.h>
 #include <errno.h>
-#include <utime.h>
+#include <fcntl.h>
 #include <stdio.h>
 #include <string.h>
 #include <signal.h>
 #include <unistd.h>
+#include <utime.h>
 #include "make.h"
 #include "hash.h"
 #include "dir.h"
@@ -1062,7 +1063,7 @@
 		 * modification time, then close the file.
 		 */
 		if (read(streamID, &c, 1) == 1) {
-		    (void) lseek(streamID, 0L, SEEK_SET);
+		    (void) lseek(streamID, (off_t)0, SEEK_SET);
 		    (void) write(streamID, &c, 1);
 		}
 
@@ -1235,7 +1236,7 @@
 	if (dup2(FILENO(job->cmdFILE), 0) == -1)
 	    Punt("Cannot dup2: %s", strerror(errno));
 	(void) fcntl(0, F_SETFD, 0);
-	(void) lseek(0, 0, SEEK_SET);
+	(void) lseek(0, (off_t)0, SEEK_SET);
 
 	if (usePipes) {
 	    /*
@@ -1681,9 +1682,6 @@
 	job = previous;
     } else {
 	job = (Job *) emalloc(sizeof(Job));
-	if (job == NULL) {
-	    Punt("JobStart out of memory");
-	}
 	flags |= JOB_FIRST;
     }
 
Index: main.c
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/main.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- main.c	23 Mar 2002 23:30:30 -0000	1.51
+++ main.c	12 Apr 2002 13:23:33 -0000	1.52
@@ -273,9 +273,7 @@
 			break;
 		}
 		case 'E':
-			p = malloc(strlen(optarg) + 1);
-			if (!p)
-				Punt("make: cannot allocate memory.");
+			p = emalloc(strlen(optarg) + 1);
 			(void)strcpy(p, optarg);
 			(void)Lst_AtEnd(envFirstVars, (void *)p);
 			Var_Append(MAKEFLAGS, "-E", VAR_GLOBAL);
@@ -817,9 +813,7 @@
 		    ln = Lst_Succ(ln)) {
 			char *value;
 			if (expandVars) {
-				p1 = malloc(strlen((char *)Lst_Datum(ln)) + 1 + 3);
-				if (!p1)
-					Punt("make: cannot allocate memory.");
+				p1 = emalloc(strlen((char *)Lst_Datum(ln)) + 1 + 3);
 				/* This sprintf is safe, because of the malloc above */
 				(void)sprintf(p1, "${%s}", (char *)Lst_Datum(ln));
 				value = Var_Subst(NULL, p1, VAR_GLOBAL, FALSE);
Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- make.1	10 Aug 2001 13:45:27 -0000	1.48
+++ make.1	12 Apr 2002 13:23:33 -0000	1.49
@@ -139,7 +139,9 @@
 Specify that environment values override macro assignments within
 makefiles for all variables.
 .It Fl f Ar makefile
-Specify a makefile to read instead of the default
+Specify a
+.Ar makefile
+to read instead of the default
 .Ql Pa makefile
 and
 .Ql Pa Makefile .
@@ -170,8 +172,9 @@
 Continue processing after errors are encountered, but only on those targets
 that do not depend on the target whose creation caused the error.
 .It Fl m Ar directory
-Specify a directory in which to search for sys.mk and makefiles included
-via the <...> style.
+Specify a directory in which to search for
+.Pa sys.mk
+and makefiles included via the <...> style.
 Multiple directories can be added to form a search path.
 This path will override the default system include path:
 .Pa /usr/share/mk .
@@ -510,7 +513,7 @@
 is unable to change into any of the remaining three directories,
 then the current directory is used.
 .Pp
-.Nm
+.Nm Make
 sets
 .Va .OBJDIR
 to the canonical path given by
@@ -569,9 +572,7 @@
 .Va VPATH .
 These directories will be searched for source files by
 .Nm
-after
-.Nm
-has finished parsing all input makefiles.
+after it has finished parsing all input makefiles.
 .El
 .Pp
 Variable expansion may be modified to select or modify each word of the
@@ -643,7 +644,7 @@
 .It Cm Q
 Quotes every shell meta-character in the variable, so that it can be passed
 safely through recursive invocations of
-.Nm .
+.Nm Ns .
 .It Cm R
 Replaces each word in the variable with everything but its suffix.
 .Sm off
@@ -719,7 +720,7 @@
 .Sh DIRECTIVES, CONDITIONALS, AND FOR LOOPS
 Directives, conditionals, and for loops reminiscent
 of the C programming language are provided in
-.Nm .
+.Nm Ns .
 All such structures are identified by a line beginning with a single
 dot
 .Pq Ql \&.
@@ -844,7 +845,8 @@
 may be any one of the following:
 .Bl -tag -width "Cm XX"
 .It Cm \&|\&|
-logical OR
+logical
+.Tn OR
 .It Cm \&&&
 Logical
 .Tn AND ;
@@ -1097,7 +1099,9 @@
 .It Ic .NOTPARALLEL
 Disable parallel mode.
 .It Ic .NO_PARALLEL
-Same as above, for compatibility with other pmake variants.
+Same as above, for compatibility with other
+.Nm pmake
+variants.
 .It Ic .ORDER
 The named targets are made in sequence.
 .\" XXX: NOT YET!!!!
@@ -1149,7 +1153,7 @@
 command in the file.
 .It Ic .SUFFIXES
 Each source specifies a suffix to
-.Nm .
+.Nm Ns .
 If no sources are specified, any previous specified suffices are deleted.
 .El
 .Sh COMPATIBILITY
---------------------
PatchSet 218
Date: 2002/04/12 17:05:53
Author: charnier
Log:
Un.Ar makefile. The add of .Ar was part of my last commit.
Asked by:	ru

Members: 
	make.1:1.49->1.50 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- make.1	12 Apr 2002 13:23:33 -0000	1.49
+++ make.1	12 Apr 2002 16:05:53 -0000	1.50
@@ -139,9 +139,7 @@
 Specify that environment values override macro assignments within
 makefiles for all variables.
 .It Fl f Ar makefile
-Specify a
-.Ar makefile
-to read instead of the default
+Specify a makefile to read instead of the default
 .Ql Pa makefile
 and
 .Ql Pa Makefile .
---------------------
PatchSet 226
Date: 2002/04/19 05:08:35
Author: obrien
Log:
Move the sysV variable substitution up with the BSD feature that replaced it.

Members: 
	make.1:1.52->1.53 

Index: make.1
===================================================================
RCS file: /usr/home/okumoto/Work/make/fbsd-cvs/src/usr.bin/make/make.1,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- make.1	13 Apr 2002 12:17:59 -0000	1.52
+++ make.1	19 Apr 2002 04:08:35 -0000	1.53
@@ -691,8 +691,6 @@
 of a dollar sign
 .Pq Ql \&$ ,
 not a preceding dollar sign as is usual.
-.It Cm T
-Replaces each word in the variable with its last component.
 .It Ar old_string=new_string
 This is the
 .At V
@@ -713,6 +711,8 @@
 .Ar old_string
 to be replaced in
 .Ar new_string
+.It Cm T
+Replaces each word in the variable with its last component.
 .It Cm U
 Converts variable to upper-case letters.
 .El




More information about the Submit mailing list