svn commit: r296635 - in vendor/NetBSD/bmake/dist: . mk unit-tests

Simon J. Gerraty sjg at FreeBSD.org
Fri Mar 11 00:37:05 UTC 2016


Author: sjg
Date: Fri Mar 11 00:37:02 2016
New Revision: 296635
URL: https://svnweb.freebsd.org/changeset/base/296635

Log:
  Import bmake-20160307

Modified:
  vendor/NetBSD/bmake/dist/ChangeLog
  vendor/NetBSD/bmake/dist/Makefile
  vendor/NetBSD/bmake/dist/arch.c
  vendor/NetBSD/bmake/dist/bmake.1
  vendor/NetBSD/bmake/dist/bmake.cat1
  vendor/NetBSD/bmake/dist/compat.c
  vendor/NetBSD/bmake/dist/cond.c
  vendor/NetBSD/bmake/dist/dirname.c
  vendor/NetBSD/bmake/dist/for.c
  vendor/NetBSD/bmake/dist/getopt.c
  vendor/NetBSD/bmake/dist/job.c
  vendor/NetBSD/bmake/dist/main.c
  vendor/NetBSD/bmake/dist/make.1
  vendor/NetBSD/bmake/dist/make.c
  vendor/NetBSD/bmake/dist/make.h
  vendor/NetBSD/bmake/dist/meta.c
  vendor/NetBSD/bmake/dist/meta.h
  vendor/NetBSD/bmake/dist/mk/ChangeLog
  vendor/NetBSD/bmake/dist/mk/auto.dep.mk
  vendor/NetBSD/bmake/dist/mk/dirdeps.mk
  vendor/NetBSD/bmake/dist/mk/gendirdeps.mk
  vendor/NetBSD/bmake/dist/mk/install-mk
  vendor/NetBSD/bmake/dist/mk/meta.autodep.mk
  vendor/NetBSD/bmake/dist/mk/meta.stage.mk
  vendor/NetBSD/bmake/dist/mk/meta.sys.mk
  vendor/NetBSD/bmake/dist/mk/meta2deps.sh
  vendor/NetBSD/bmake/dist/mk/sys.clean-env.mk
  vendor/NetBSD/bmake/dist/mk/sys.dependfile.mk
  vendor/NetBSD/bmake/dist/mk/warnings.mk
  vendor/NetBSD/bmake/dist/nonints.h
  vendor/NetBSD/bmake/dist/parse.c
  vendor/NetBSD/bmake/dist/suff.c
  vendor/NetBSD/bmake/dist/targ.c
  vendor/NetBSD/bmake/dist/unit-tests/export-env.exp
  vendor/NetBSD/bmake/dist/unit-tests/export-env.mk
  vendor/NetBSD/bmake/dist/unit-tests/modts.exp
  vendor/NetBSD/bmake/dist/unit-tests/modts.mk
  vendor/NetBSD/bmake/dist/var.c

Modified: vendor/NetBSD/bmake/dist/ChangeLog
==============================================================================
--- vendor/NetBSD/bmake/dist/ChangeLog	Fri Mar 11 00:23:10 2016	(r296634)
+++ vendor/NetBSD/bmake/dist/ChangeLog	Fri Mar 11 00:37:02 2016	(r296635)
@@ -1,3 +1,41 @@
+2016-03-07  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20160307
+	  Merge with NetBSD make, pick up
+	  o var.c: fix :ts\nnn to be octal by default.
+	  o meta.c: meta_finish() to cleanup memory.
+
+2016-02-26  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20160226
+	  Merge with NetBSD make, pick up
+	  o meta.c: allow meta file for makeDepend if makefiles want it.
+
+2016-02-19  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* var.c: default .MAKE.SAVE_DOLLARS to FALSE
+	  for backwards compatability.
+
+	* Makefile (MAKE_VERSION): 20160220
+	  Merge with NetBSD make, pick up
+	  o var.c: add knob to control handling of '$$' in :=
+
+2016-02-18  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20160218
+	  Merge with NetBSD make, pick up
+	  o var.c: add .export-literal allows us to fix sys.clean-env.mk
+	    post the changes to Var_Subst.
+	    Var_Subst now takes flags, and does not consume '$$' in :=
+
+2016-02-17  Simon J. Gerraty  <sjg at bad.crufty.net>
+
+	* Makefile (MAKE_VERSION): 20160217
+	  Merge with NetBSD make, pick up
+	  o var.c: preserve '$$' in :=
+	  o parse.c: add .dinclude for handling included 
+	    makefile like .depend
+
 2015-12-20  Simon J. Gerraty  <sjg at bad.crufty.net>
 
 	* Makefile (MAKE_VERSION): 20151220

Modified: vendor/NetBSD/bmake/dist/Makefile
==============================================================================
--- vendor/NetBSD/bmake/dist/Makefile	Fri Mar 11 00:23:10 2016	(r296634)
+++ vendor/NetBSD/bmake/dist/Makefile	Fri Mar 11 00:37:02 2016	(r296635)
@@ -1,7 +1,7 @@
-#	$Id: Makefile,v 1.49 2015/12/20 22:54:40 sjg Exp $
+#	$Id: Makefile,v 1.55 2016/03/07 22:02:47 sjg Exp $
 
 # Base version on src date
-MAKE_VERSION= 20151220
+MAKE_VERSION= 20160307
 
 PROG=	bmake
 

Modified: vendor/NetBSD/bmake/dist/arch.c
==============================================================================
--- vendor/NetBSD/bmake/dist/arch.c	Fri Mar 11 00:23:10 2016	(r296634)
+++ vendor/NetBSD/bmake/dist/arch.c	Fri Mar 11 00:37:02 2016	(r296635)
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.64 2015/10/11 04:51:24 sjg Exp $	*/
+/*	$NetBSD: arch.c,v 1.68 2016/02/18 18:29:14 christos Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: arch.c,v 1.64 2015/10/11 04:51:24 sjg Exp $";
+static char rcsid[] = "$NetBSD: arch.c,v 1.68 2016/02/18 18:29:14 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)arch.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: arch.c,v 1.64 2015/10/11 04:51:24 sjg Exp $");
+__RCSID("$NetBSD: arch.c,v 1.68 2016/02/18 18:29:14 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -136,7 +136,6 @@ __RCSID("$NetBSD: arch.c,v 1.64 2015/10/
 #include    <sys/stat.h>
 #include    <sys/time.h>
 #include    <sys/param.h>
-#include    <ctype.h>
 #ifdef HAVE_AR_H
 #include    <ar.h>
 #else
@@ -156,7 +155,6 @@ struct ar_hdr {
 #if defined(HAVE_RANLIB_H) && !(defined(__ELF__) || defined(NO_RANLIB))
 #include    <ranlib.h>
 #endif
-#include    <fcntl.h>
 #include    <stdio.h>
 #include    <stdlib.h>
 #ifdef HAVE_UTIME_H
@@ -254,8 +252,7 @@ ArchFree(void *ap)
 	free(Hash_GetValue(entry));
 
     free(a->name);
-    if (a->fnametab)
-	free(a->fnametab);
+    free(a->fnametab);
     Hash_DeleteTable(&a->members);
     free(a);
 }
@@ -310,9 +307,10 @@ Arch_ParseArchive(char **linePtr, Lst no
 	    void	*freeIt;
 	    char	*result;
 
-	    result = Var_Parse(cp, ctxt, TRUE, TRUE, &length, &freeIt);
-	    if (freeIt)
-		free(freeIt);
+	    result = Var_Parse(cp, ctxt, VARF_UNDEFERR|VARF_WANTRES,
+			       &length, &freeIt);
+	    free(freeIt);
+
 	    if (result == var_Error) {
 		return(FAILURE);
 	    } else {
@@ -325,7 +323,7 @@ Arch_ParseArchive(char **linePtr, Lst no
 
     *cp++ = '\0';
     if (subLibName) {
-	libName = Var_Subst(NULL, libName, ctxt, TRUE, TRUE);
+	libName = Var_Subst(NULL, libName, ctxt, VARF_UNDEFERR|VARF_WANTRES);
     }
 
 
@@ -351,9 +349,10 @@ Arch_ParseArchive(char **linePtr, Lst no
 		void	*freeIt;
 		char	*result;
 
-		result = Var_Parse(cp, ctxt, TRUE, TRUE, &length, &freeIt);
-		if (freeIt)
-		    free(freeIt);
+		result = Var_Parse(cp, ctxt, VARF_UNDEFERR|VARF_WANTRES,
+				   &length, &freeIt);
+		free(freeIt);
+
 		if (result == var_Error) {
 		    return(FAILURE);
 		} else {
@@ -404,7 +403,8 @@ Arch_ParseArchive(char **linePtr, Lst no
 	    char    *oldMemName = memName;
 	    size_t   sz;
 
-	    memName = Var_Subst(NULL, memName, ctxt, TRUE, TRUE);
+	    memName = Var_Subst(NULL, memName, ctxt,
+				VARF_UNDEFERR|VARF_WANTRES);
 
 	    /*
 	     * Now form an archive spec and recurse to deal with nested
@@ -759,8 +759,7 @@ ArchStatMember(char *archive, char *memb
 badarch:
     fclose(arch);
     Hash_DeleteTable(&ar->members);
-    if (ar->fnametab)
-	free(ar->fnametab);
+    free(ar->fnametab);
     free(ar);
     return NULL;
 }
@@ -1045,10 +1044,10 @@ Arch_Touch(GNode *gn)
     arch = ArchFindMember(Var_Value(ARCHIVE, gn, &p1),
 			  Var_Value(MEMBER, gn, &p2),
 			  &arh, "r+");
-    if (p1)
-	free(p1);
-    if (p2)
-	free(p2);
+
+    free(p1);
+    free(p2);
+
     snprintf(arh.AR_DATE, sizeof(arh.AR_DATE), "%-12ld", (long) now);
 
     if (arch != NULL) {
@@ -1127,10 +1126,9 @@ Arch_MTime(GNode *gn)
     arhPtr = ArchStatMember(Var_Value(ARCHIVE, gn, &p1),
 			     Var_Value(MEMBER, gn, &p2),
 			     TRUE);
-    if (p1)
-	free(p1);
-    if (p2)
-	free(p2);
+
+    free(p1);
+    free(p2);
 
     if (arhPtr != NULL) {
 	modTime = (time_t)strtol(arhPtr->AR_DATE, NULL, 10);

Modified: vendor/NetBSD/bmake/dist/bmake.1
==============================================================================
--- vendor/NetBSD/bmake/dist/bmake.1	Fri Mar 11 00:23:10 2016	(r296634)
+++ vendor/NetBSD/bmake/dist/bmake.1	Fri Mar 11 00:37:02 2016	(r296635)
@@ -1,4 +1,4 @@
-.\"	$NetBSD: make.1,v 1.249 2015/06/05 07:33:40 wiz Exp $
+.\"	$NetBSD: make.1,v 1.254 2016/02/20 01:43:28 wiz Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"	from: @(#)make.1	8.4 (Berkeley) 3/19/94
 .\"
-.Dd June 4, 2015
+.Dd February 19, 2016
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -293,7 +293,7 @@ then
 will search for the specified file or directory named in the remaining part
 of the argument string.
 The search starts with the current directory of
-the Makefile and then works upward towards the root of the filesystem.
+the Makefile and then works upward towards the root of the file system.
 If the search is successful, then the resulting directory replaces the
 .Qq \&.../
 specification in the
@@ -868,7 +868,7 @@ This can be overridden by setting
 .Va bf
 to a value which represents True.
 .It Pa env
-For debugging, it can be useful to inlcude the environment
+For debugging, it can be useful to include the environment
 in the .meta file.
 .It Pa verbose
 If in "meta" mode, print a clue about the target being built.
@@ -918,7 +918,7 @@ The default value is:
 This variable is used to record the names of variables assigned to
 on the command line, so that they may be exported as part of
 .Ql Ev MAKEFLAGS .
-This behaviour can be disabled by assigning an empty value to
+This behavior can be disabled by assigning an empty value to
 .Ql Va .MAKEOVERRIDES
 within a makefile.
 Extra variables can be exported from a makefile
@@ -941,6 +941,19 @@ The process-id of
 .It Va .MAKE.PPID
 The parent process-id of
 .Nm .
+.It Va .MAKE.SAVE_DOLLARS
+value should be a boolean that controls whether
+.Ql $$
+are preserved when doing
+.Ql :=
+assignments.
+The default is false, for backwards compatibility.
+Set to true for compatability with other makes.
+If set to false,
+.Ql $$
+becomes
+.Ql $
+per normal evaluation rules.
 .It Va MAKE_PRINT_VAR_ON_ERROR
 When
 .Nm
@@ -1044,7 +1057,7 @@ sets
 to the value of
 .Ql Ev PWD
 instead.
-This behaviour is disabled if
+This behavior is disabled if
 .Ql Ev MAKEOBJDIRPREFIX
 is set or
 .Ql Ev MAKEOBJDIR
@@ -1114,7 +1127,7 @@ The wildcard characters may be escaped w
 As a consequence of the way values are split into words, matched,
 and then joined, a construct like
 .Dl ${VAR:M*}
-will normalise the inter-word spacing, removing all leading and
+will normalize the inter-word spacing, removing all leading and
 trailing space, and converting multiple consecutive spaces
 to single spaces.
 .
@@ -1134,7 +1147,7 @@ Randomize words in variable.
 The results will be different each time you are referring to the
 modified variable; use the assignment with expansion
 .Pq Ql Cm \&:=
-to prevent such behaviour.
+to prevent such behavior.
 For example,
 .Bd -literal -offset indent
 LIST=			uno due tre quattro
@@ -1166,7 +1179,7 @@ The value is a format string for
 using the current
 .Xr gmtime 3 .
 .It Cm \&:hash
-Compute a 32bit hash of the value and encode it as hex digits.
+Compute a 32-bit hash of the value and encode it as hex digits.
 .It Cm \&:localtime
 The value is a format string for
 .Xr strftime 3 ,
@@ -1444,7 +1457,7 @@ value is divided into words.
 .Pp
 Ordinarily, a value is treated as a sequence of words
 delimited by white space.
-Some modifiers suppress this behaviour,
+Some modifiers suppress this behavior,
 causing a value to be treated as a single word
 (possibly containing embedded white space).
 An empty value, or a value that consists entirely of white-space,
@@ -1530,12 +1543,20 @@ For compatibility with other versions of
 .Nm
 .Ql include file ...
 is also accepted.
+.Pp
 If the include statement is written as
 .Cm .-include
 or as
 .Cm .sinclude
 then errors locating and/or opening include files are ignored.
 .Pp
+If the include statement is written as
+.Cm .dinclude
+not only are errors locating and/or opening include files ignored,
+but stale dependencies within the included file will be ignored
+just like
+.Va .MAKE.DEPENDFILE .
+.Pp
 Conditional expressions are also preceded by a single dot as the first
 character of a line.
 The possible conditionals are as follows:
@@ -1571,6 +1592,10 @@ This allows exporting a value to the env
 used by
 .Nm
 internally.
+.It Ic .export-literal Ar variable ...
+The same as
+.Ql .export-env ,
+except that variables in the value are not expanded.
 .It Ic .info Ar message
 The message is printed along with the name of the makefile and line number.
 .It Ic .undef Ar variable
@@ -2068,7 +2093,7 @@ The sources are a set of
 pairs.
 .Bl -tag -width hasErrCtls
 .It Ar name
-This is the minimal specification, used to select one of the builtin
+This is the minimal specification, used to select one of the built-in
 shell specs;
 .Ar sh ,
 .Ar ksh ,

Modified: vendor/NetBSD/bmake/dist/bmake.cat1
==============================================================================
--- vendor/NetBSD/bmake/dist/bmake.cat1	Fri Mar 11 00:23:10 2016	(r296634)
+++ vendor/NetBSD/bmake/dist/bmake.cat1	Fri Mar 11 00:37:02 2016	(r296635)
@@ -178,11 +178,11 @@ DDEESSCCRRIIPPTTIIOONN
              then bbmmaakkee will search for the specified file or directory named
              in the remaining part of the argument string.  The search starts
              with the current directory of the Makefile and then works upward
-             towards the root of the filesystem.  If the search is successful,
-             then the resulting directory replaces the ".../" specification in
-             the --mm argument.  If used, this feature allows bbmmaakkee to easily
-             search in the current source tree for customized sys.mk files
-             (e.g., by using ".../mk/sys.mk" as an argument).
+             towards the root of the file system.  If the search is success-
+             ful, then the resulting directory replaces the ".../" specifica-
+             tion in the --mm argument.  If used, this feature allows bbmmaakkee to
+             easily search in the current source tree for customized sys.mk
+             files (e.g., by using ".../mk/sys.mk" as an argument).
 
      --nn      Display the commands that would have been executed, but do not
              actually execute them unless the target depends on the .MAKE spe-
@@ -543,7 +543,7 @@ VVAARRIIAABBLLEE AASSSSIIGG
                                  in `_._C_U_R_D_I_R'.  This can be overridden by set-
                                  ting _b_f to a value which represents True.
 
-                     _e_n_v         For debugging, it can be useful to inlcude
+                     _e_n_v         For debugging, it can be useful to include
                                  the environment in the .meta file.
 
                      _v_e_r_b_o_s_e     If in "meta" mode, print a clue about the
@@ -591,7 +591,7 @@ VVAARRIIAABBLLEE AASSSSIIGG
 
      _._M_A_K_E_O_V_E_R_R_I_D_E_S  This variable is used to record the names of variables
                      assigned to on the command line, so that they may be
-                     exported as part of `MAKEFLAGS'.  This behaviour can be
+                     exported as part of `MAKEFLAGS'.  This behavior can be
                      disabled by assigning an empty value to `_._M_A_K_E_O_V_E_R_R_I_D_E_S'
                      within a makefile.  Extra variables can be exported from
                      a makefile by appending their names to `_._M_A_K_E_O_V_E_R_R_I_D_E_S'.
@@ -607,6 +607,13 @@ VVAARRIIAABBLLEE AASSSSIIGG
 
      _._M_A_K_E_._P_P_I_D      The parent process-id of bbmmaakkee.
 
+     _._M_A_K_E_._S_A_V_E___D_O_L_L_A_R_S
+                     value should be a boolean that controls whether `$$' are
+                     preserved when doing `:=' assignments.  The default is
+                     false, for backwards compatibility.  Set to true for com-
+                     patability with other makes.  If set to false, `$$'
+                     becomes `$' per normal evaluation rules.
+
      _M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R
                      When bbmmaakkee stops due to an error, it prints its name and
                      the value of `_._C_U_R_D_I_R' as well as the value of any vari-
@@ -670,7 +677,7 @@ VVAARRIIAABBLLEE AASSSSIIGG
                      sets `_._C_U_R_D_I_R' to the canonical path given by getcwd(3).
                      However, if the environment variable `PWD' is set and
                      gives a path to the current directory, then bbmmaakkee sets
-                     `_._C_U_R_D_I_R' to the value of `PWD' instead.  This behaviour
+                     `_._C_U_R_D_I_R' to the value of `PWD' instead.  This behavior
                      is disabled if `MAKEOBJDIRPREFIX' is set or `MAKEOBJDIR'
                      contains a variable transform.  `PWD' is set to the value
                      of `_._O_B_J_D_I_R' for all programs which bbmmaakkee executes.
@@ -717,7 +724,7 @@ VVAARRIIAABBLLEE AASSSSIIGG
           of the way values are split into words, matched, and then joined, a
           construct like
                 ${VAR:M*}
-          will normalise the inter-word spacing, removing all leading and
+          will normalize the inter-word spacing, removing all leading and
           trailing space, and converting multiple consecutive spaces to single
           spaces.
 
@@ -730,7 +737,7 @@ VVAARRIIAABBLLEE AASSSSIIGG
 
      ::OOxx  Randomize words in variable.  The results will be different each
           time you are referring to the modified variable; use the assignment
-          with expansion (`::==') to prevent such behaviour.  For example,
+          with expansion (`::==') to prevent such behavior.  For example,
 
                 LIST=                   uno due tre quattro
                 RANDOM_LIST=            ${LIST:Ox}
@@ -758,7 +765,7 @@ VVAARRIIAABBLLEE AASSSSIIGG
           gmtime(3).
 
      ::hhaasshh
-          Compute a 32bit hash of the value and encode it as hex digits.
+          Compute a 32-bit hash of the value and encode it as hex digits.
 
      ::llooccaallttiimmee
           The value is a format string for strftime(3), using the current
@@ -914,13 +921,13 @@ VVAARRIIAABBLLEE AASSSSIIGG
           tions related to the way in which the value is divided into words.
 
           Ordinarily, a value is treated as a sequence of words delimited by
-          white space.  Some modifiers suppress this behaviour, causing a
-          value to be treated as a single word (possibly containing embedded
-          white space).  An empty value, or a value that consists entirely of
-          white-space, is treated as a single word.  For the purposes of the
-          `::[[]]' modifier, the words are indexed both forwards using positive
-          integers (where index 1 represents the first word), and backwards
-          using negative integers (where index -1 represents the last word).
+          white space.  Some modifiers suppress this behavior, causing a value
+          to be treated as a single word (possibly containing embedded white
+          space).  An empty value, or a value that consists entirely of white-
+          space, is treated as a single word.  For the purposes of the `::[[]]'
+          modifier, the words are indexed both forwards using positive inte-
+          gers (where index 1 represents the first word), and backwards using
+          negative integers (where index -1 represents the last word).
 
           The _r_a_n_g_e is subjected to variable expansion, and the expanded
           result is then interpreted as follows:
@@ -957,8 +964,14 @@ IINNCCLLUUDDEE SSTTAATTEEMM
      used, the including makefile's directory and any directories specified
      using the --II option are searched before the system makefile directory.
      For compatibility with other versions of bbmmaakkee `include file ...' is also
-     accepted.  If the include statement is written as ..--iinncclluuddee or as
-     ..ssiinncclluuddee then errors locating and/or opening include files are ignored.
+     accepted.
+
+     If the include statement is written as ..--iinncclluuddee or as ..ssiinncclluuddee then
+     errors locating and/or opening include files are ignored.
+
+     If the include statement is written as ..ddiinncclluuddee not only are errors
+     locating and/or opening include files ignored, but stale dependencies
+     within the included file will be ignored just like _._M_A_K_E_._D_E_P_E_N_D_F_I_L_E.
 
      Conditional expressions are also preceded by a single dot as the first
      character of a line.  The possible conditionals are as follows:
@@ -982,6 +995,10 @@ IINNCCLLUUDDEE SSTTAATTEEMM
              to _._M_A_K_E_._E_X_P_O_R_T_E_D.  This allows exporting a value to the environ-
              ment which is different from that used by bbmmaakkee internally.
 
+     ..eexxppoorrtt--lliitteerraall _v_a_r_i_a_b_l_e _._._.
+             The same as `.export-env', except that variables in the value are
+             not expanded.
+
      ..iinnffoo _m_e_s_s_a_g_e
              The message is printed along with the name of the makefile and
              line number.
@@ -1307,7 +1324,7 @@ SSPPEECCIIAALL TTAARRGGEETT
               sources are a set of _f_i_e_l_d_=_v_a_l_u_e pairs.
 
               _n_a_m_e        This is the minimal specification, used to select
-                          one of the builtin shell specs; _s_h, _k_s_h, and _c_s_h.
+                          one of the built-in shell specs; _s_h, _k_s_h, and _c_s_h.
 
               _p_a_t_h        Specifies the path to the shell.
 
@@ -1452,4 +1469,4 @@ BBUUGGSS
 
      There is no way of escaping a space character in a filename.
 
-NetBSD 5.1                       June 4, 2015                       NetBSD 5.1
+NetBSD 5.1                     February 19, 2016                    NetBSD 5.1

Modified: vendor/NetBSD/bmake/dist/compat.c
==============================================================================
--- vendor/NetBSD/bmake/dist/compat.c	Fri Mar 11 00:23:10 2016	(r296634)
+++ vendor/NetBSD/bmake/dist/compat.c	Fri Mar 11 00:37:02 2016	(r296635)
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg Exp $	*/
+/*	$NetBSD: compat.c,v 1.104 2016/02/18 18:29:14 christos Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg Exp $";
+static char rcsid[] = "$NetBSD: compat.c,v 1.104 2016/02/18 18:29:14 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)compat.c	8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: compat.c,v 1.101 2015/10/11 04:51:24 sjg Exp $");
+__RCSID("$NetBSD: compat.c,v 1.104 2016/02/18 18:29:14 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -146,8 +146,8 @@ CompatInterrupt(int signo)
 	if (!noExecute && eunlink(file) != -1) {
 	    Error("*** %s removed", file);
 	}
-	if (p1)
-	    free(p1);
+
+	free(p1);
 
 	/*
 	 * Run .INTERRUPT only if hit with interrupt signal
@@ -213,7 +213,7 @@ CompatRunCommand(void *cmdp, void *gnp)
     doIt = FALSE;
     
     cmdNode = Lst_Member(gn->commands, cmd);
-    cmdStart = Var_Subst(NULL, cmd, gn, FALSE, TRUE);
+    cmdStart = Var_Subst(NULL, cmd, gn, VARF_WANTRES);
 
     /*
      * brk_string will return an argv with a NULL in av[0], thus causing
@@ -374,10 +374,10 @@ again:
 	execError("exec", av[0]);
 	_exit(1);
     }
-    if (mav)
-	free(mav);
-    if (bp)
-	free(bp);
+
+    free(mav);
+    free(bp);
+
     Lst_Replace(cmdNode, NULL);
 
 #ifdef USE_META
@@ -516,8 +516,7 @@ Compat_Make(void *gnp, void *pgnp)
 	if (Lst_Member(gn->iParents, pgn) != NULL) {
 	    char *p1;
 	    Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
-	    if (p1)
-		free(p1);
+	    free(p1);
 	}
 
 	/*
@@ -620,8 +619,7 @@ Compat_Make(void *gnp, void *pgnp)
 	if (Lst_Member(gn->iParents, pgn) != NULL) {
 	    char *p1;
 	    Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0);
-	    if (p1)
-		free(p1);
+	    free(p1);
 	}
 	switch(gn->made) {
 	    case BEINGMADE:

Modified: vendor/NetBSD/bmake/dist/cond.c
==============================================================================
--- vendor/NetBSD/bmake/dist/cond.c	Fri Mar 11 00:23:10 2016	(r296634)
+++ vendor/NetBSD/bmake/dist/cond.c	Fri Mar 11 00:37:02 2016	(r296635)
@@ -1,4 +1,4 @@
-/*	$NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $	*/
+/*	$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $";
+static char rcsid[] = "$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)cond.c	8.2 (Berkeley) 1/2/94";
 #else
-__RCSID("$NetBSD: cond.c,v 1.71 2015/12/02 00:28:24 sjg Exp $");
+__RCSID("$NetBSD: cond.c,v 1.74 2016/02/18 18:29:14 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -289,10 +289,10 @@ CondGetArg(char **linePtr, char **argPtr
 	    int		len;
 	    void	*freeIt;
 
-	    cp2 = Var_Parse(cp, VAR_CMD, TRUE, TRUE, &len, &freeIt);
+	    cp2 = Var_Parse(cp, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES,
+			    &len, &freeIt);
 	    Buf_AddBytes(&buf, strlen(cp2), cp2);
-	    if (freeIt)
-		free(freeIt);
+	    free(freeIt);
 	    cp += len;
 	    continue;
 	}
@@ -346,8 +346,8 @@ CondDoDefined(int argLen MAKE_ATTR_UNUSE
     } else {
 	result = FALSE;
     }
-    if (p1)
-	free(p1);
+
+    free(p1);
     return (result);
 }
 

@@ -574,8 +574,9 @@ CondGetString(Boolean doEval, Boolean *q
 	    break;
 	case '$':
 	    /* if we are in quotes, then an undefined variable is ok */
-	    str = Var_Parse(condExpr, VAR_CMD, (qt ? 0 : doEval),
-			    TRUE, &len, freeIt);
+	    str = Var_Parse(condExpr, VAR_CMD,
+			    ((!qt && doEval) ? VARF_UNDEFERR : 0) |
+			    VARF_WANTRES, &len, freeIt);
 	    if (str == var_Error) {
 		if (*freeIt) {
 		    free(*freeIt);
@@ -805,10 +806,8 @@ do_string_compare:
     }
 
 done:
-    if (lhsFree)
-	free(lhsFree);
-    if (rhsFree)
-	free(rhsFree);
+    free(lhsFree);
+    free(rhsFree);
     return t;
 }
 
@@ -827,7 +826,7 @@ get_mpt_arg(char **linePtr, char **argPt
     /* We do all the work here and return the result as the length */
     *argPtr = NULL;
 
-    val = Var_Parse(cp - 1, VAR_CMD, FALSE, TRUE, &length, &freeIt);
+    val = Var_Parse(cp - 1, VAR_CMD, VARF_WANTRES, &length, &freeIt);
     /*
      * Advance *linePtr to beyond the closing ). Note that
      * we subtract one because 'length' is calculated from 'cp - 1'.
@@ -848,8 +847,7 @@ get_mpt_arg(char **linePtr, char **argPt
      * true/false here.
      */
     length = *val ? 2 : 1;
-    if (freeIt)
-	free(freeIt);
+    free(freeIt);
     return length;
 }
 
@@ -900,8 +898,7 @@ compare_function(Boolean doEval)
 	}
 	/* Evaluate the argument using the required function. */
 	t = !doEval || fn_def->fn_proc(arglen, arg);
-	if (arg)
-	    free(arg);
+	free(arg);
 	condExpr = cp;
 	return t;
     }
@@ -933,8 +930,7 @@ compare_function(Boolean doEval)
      * be empty - even if it contained a variable expansion.
      */
     t = !doEval || if_info->defProc(arglen, arg) != if_info->doNot;
-    if (arg)
-	free(arg);
+    free(arg);
     return t;
 }
 

Modified: vendor/NetBSD/bmake/dist/dirname.c
==============================================================================
--- vendor/NetBSD/bmake/dist/dirname.c	Fri Mar 11 00:23:10 2016	(r296634)
+++ vendor/NetBSD/bmake/dist/dirname.c	Fri Mar 11 00:37:02 2016	(r296635)
@@ -1,4 +1,4 @@
-/*	$NetBSD: dirname.c,v 1.11 2009/11/24 13:34:20 tnozaki Exp $	*/
+/*	$NetBSD: dirname.c,v 1.13 2014/07/16 10:52:26 christos Exp $	*/
 
 /*-
  * Copyright (c) 1997, 2002 The NetBSD Foundation, Inc.
@@ -35,7 +35,10 @@
 #ifndef HAVE_DIRNAME
 
 #include <sys/cdefs.h>
-
+#include <sys/param.h>
+#ifdef HAVE_LIBGEN_H
+#include <libgen.h>
+#endif
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
@@ -45,51 +48,73 @@
 #ifndef PATH_MAX
 # define PATH_MAX 1024
 #endif
+#ifndef MIN
+# define MIN(a, b) ((a < b) ? a : b)
+#endif
 
-char *
-dirname(char *path)
+
+static size_t
+xdirname_r(const char *path, char *buf, size_t buflen)
 {
-	static char result[PATH_MAX];
-	const char *lastp;
+	const char *endp;
 	size_t len;
 
 	/*
 	 * If `path' is a null pointer or points to an empty string,
 	 * return a pointer to the string ".".
 	 */
-	if ((path == NULL) || (*path == '\0'))
-		goto singledot;
-
+	if (path == NULL || *path == '\0') {
+		path = ".";
+		len = 1;
+		goto out;
+	}
 
 	/* Strip trailing slashes, if any. */
-	lastp = path + strlen(path) - 1;
-	while (lastp != path && *lastp == '/')
-		lastp--;
-
-	/* Terminate path at the last occurence of '/'. */
-	do {
-		if (*lastp == '/') {
-			/* Strip trailing slashes, if any. */
-			while (lastp != path && *lastp == '/')
-				lastp--;
-
-			/* ...and copy the result into the result buffer. */
-			len = (lastp - path) + 1 /* last char */;
-			if (len > (PATH_MAX - 1))
-				len = PATH_MAX - 1;
-
-			memcpy(result, path, len);
-			result[len] = '\0';
-
-			return (result);
-		}
-	} while (--lastp >= path);
-
-	/* No /'s found, return a pointer to the string ".". */
-singledot:
-	result[0] = '.';
-	result[1] = '\0';
+	endp = path + strlen(path) - 1;
+	while (endp != path && *endp == '/')
+		endp--;
+
+	/* Find the start of the dir */
+	while (endp > path && *endp != '/')
+		endp--;
+
+	if (endp == path) {
+		path = *endp == '/' ? "/" : ".";
+		len = 1;
+		goto out;
+	}
+
+	do
+		endp--;
+	while (endp > path && *endp == '/');
+
+	len = endp - path + 1;
+out:
+	if (buf != NULL && buflen != 0) {
+		buflen = MIN(len, buflen - 1);
+		memcpy(buf, path, buflen);
+		buf[buflen] = '\0';
+	}
+	return len;
+}
 
-	return (result);
+char *
+dirname(char *path)
+{
+	static char result[PATH_MAX];
+	(void)xdirname_r(path, result, sizeof(result));
+	return result;
 }
+
+#ifdef MAIN
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main(int argc, char *argv[])
+{
+	printf("%s\n", dirname(argv[1]));
+	exit(0);
+}
+#endif
 #endif

Modified: vendor/NetBSD/bmake/dist/for.c
==============================================================================
--- vendor/NetBSD/bmake/dist/for.c	Fri Mar 11 00:23:10 2016	(r296634)
+++ vendor/NetBSD/bmake/dist/for.c	Fri Mar 11 00:37:02 2016	(r296635)
@@ -1,4 +1,4 @@
-/*	$NetBSD: for.c,v 1.50 2015/10/11 04:51:24 sjg Exp $	*/
+/*	$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $	*/
 
 /*
  * Copyright (c) 1992, The Regents of the University of California.
@@ -30,14 +30,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: for.c,v 1.50 2015/10/11 04:51:24 sjg Exp $";
+static char rcsid[] = "$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)for.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: for.c,v 1.50 2015/10/11 04:51:24 sjg Exp $");
+__RCSID("$NetBSD: for.c,v 1.52 2016/02/18 18:29:14 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -216,7 +216,7 @@ For_Eval(char *line)
      * We can't do the escapes here - because we don't know whether
      * we are substuting into ${...} or $(...).
      */
-    sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE, TRUE);
+    sub = Var_Subst(NULL, ptr, VAR_GLOBAL, VARF_WANTRES);
 
     /*
      * Split into words allowing for quoted strings.

Modified: vendor/NetBSD/bmake/dist/getopt.c
==============================================================================
--- vendor/NetBSD/bmake/dist/getopt.c	Fri Mar 11 00:23:10 2016	(r296634)
+++ vendor/NetBSD/bmake/dist/getopt.c	Fri Mar 11 00:37:02 2016	(r296635)
@@ -1,3 +1,5 @@
+/*	$NetBSD: getopt.c,v 1.29 2014/06/05 22:00:22 christos Exp $	*/
+
 /*
  * Copyright (c) 1987, 1993, 1994
  *	The Regents of the University of California.  All rights reserved.
@@ -10,11 +12,7 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *    notice, this list of conditions and the following disclaimer in the
  *    documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
+ * 3. Neither the name of the University nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
  *
@@ -35,11 +33,7 @@
 # include "config.h"
 #endif
 #if !defined(HAVE_GETOPT) || defined(WANT_GETOPT_LONG) || defined(BROKEN_GETOPT)
-
-#if defined(LIBC_SCCS) && !defined(lint)
-/* static char sccsid[] = "from: @(#)getopt.c	8.2 (Berkeley) 4/2/94"; */
-static char *rcsid = "$Id: getopt.c,v 1.3 1999/01/08 02:14:18 sjg Exp $";
-#endif /* LIBC_SCCS and not lint */
+#include <sys/cdefs.h>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -61,13 +55,10 @@ char	*optarg;		/* argument associated wi
  *	Parse argc/argv argument vector.
  */
 int
-getopt(nargc, nargv, ostr)
-	int nargc;
-	char * const *nargv;
-	const char *ostr;
+getopt(int nargc, char * const nargv[], const char *ostr)
 {
 	extern char *__progname;
-	static char *place = EMSG;		/* option letter processing */
+	static const char *place = EMSG; 	/* option letter processing */
 	char *oli;				/* option letter list index */
 
 #ifndef BSD4_4
@@ -79,43 +70,63 @@ getopt(nargc, nargv, ostr)
 	}
 #endif
 	
-	if (optreset || !*place) {		/* update scanning pointer */
+	if (optreset || *place == 0) {		/* update scanning pointer */
 		optreset = 0;
-		if (optind >= nargc || *(place = nargv[optind]) != '-') {
+		place = nargv[optind];
+		if (optind >= nargc || *place++ != '-') {
+			/* Argument is absent or is not an option */
 			place = EMSG;
 			return (-1);
 		}
-		if (place[1] && *++place == '-'	/* found "--" */
-		    && !place[1]) {		/* and not "--foo" */
+		optopt = *place++;
+		if (optopt == '-' && *place == 0) {
+			/* "--" => end of options */
 			++optind;
 			place = EMSG;
 			return (-1);
 		}
-	}					/* option letter okay? */
-	if ((optopt = (int)*place++) == (int)':' ||
-	    !(oli = strchr(ostr, optopt))) {
-		/*
-		 * if the user didn't specify '-' as an option,
-		 * assume it means -1.
-		 */
-		if (optopt == (int)'-')
-			return (-1);
-		if (!*place)
+		if (optopt == 0) {
+			/* Solitary '-', treat as a '-' option
+			   if the program (eg su) is looking for it. */
+			place = EMSG;
+			if (strchr(ostr, '-') == NULL)
+				return -1;
+			optopt = '-';
+		}
+	} else
+		optopt = *place++;
+
+	/* See if option letter is one the caller wanted... */
+	if (optopt == ':' || (oli = strchr(ostr, optopt)) == NULL) {
+		if (*place == 0)
 			++optind;
 		if (opterr && *ostr != ':')
 			(void)fprintf(stderr,
-			    "%s: illegal option -- %c\n", __progname, optopt);
+			    "%s: unknown option -- %c\n", __progname, optopt);
 		return (BADCH);
 	}
-	if (*++oli != ':') {			/* don't need argument */
+
+	/* Does this option need an argument? */
+	if (oli[1] != ':') {
+		/* don't need argument */
 		optarg = NULL;
-		if (!*place)
+		if (*place == 0)
 			++optind;
-	}
-	else {					/* need an argument */
-		if (*place)			/* no white space */
-			optarg = place;
-		else if (nargc <= ++optind) {	/* no arg */
+	} else {
+		/* Option-argument is either the rest of this argument or the
+		   entire next argument. */
+		if (*place)
+			optarg = __UNCONST(place);
+		else if (oli[2] == ':')
+			/*
+			 * GNU Extension, for optional arguments if the rest of
+			 * the argument is empty, we return NULL
+			 */
+			optarg = NULL;
+		else if (nargc > ++optind)
+			optarg = nargv[optind];
+		else {
+			/* option-argument absent */
 			place = EMSG;
 			if (*ostr == ':')
 				return (BADARG);
@@ -125,12 +136,10 @@ getopt(nargc, nargv, ostr)
 				    __progname, optopt);
 			return (BADCH);
 		}
-	 	else				/* white space */
-			optarg = nargv[optind];
 		place = EMSG;
 		++optind;
 	}
-	return (optopt);			/* dump back option letter */
+	return (optopt);			/* return option letter */
 }
 #endif

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***


More information about the svn-src-all mailing list