Deleted Added
full compact
var.c (251422) var.c (253883)
1/* $NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $ */
1/* $NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $ */
2
3/*
4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor.
9 *

--- 54 unchanged lines hidden (view full) ---

64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE.
69 */
70
71#ifndef MAKE_NATIVE
2
3/*
4 * Copyright (c) 1988, 1989, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Adam de Boor.
9 *

--- 54 unchanged lines hidden (view full) ---

64 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * SUCH DAMAGE.
69 */
70
71#ifndef MAKE_NATIVE
72static char rcsid[] = "$NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $";
72static char rcsid[] = "$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $";
73#else
74#include <sys/cdefs.h>
75#ifndef lint
76#if 0
77static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
78#else
73#else
74#include <sys/cdefs.h>
75#ifndef lint
76#if 0
77static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
78#else
79__RCSID("$NetBSD: var.c,v 1.175 2013/05/29 00:23:31 sjg Exp $");
79__RCSID("$NetBSD: var.c,v 1.183 2013/07/16 20:00:56 sjg Exp $");
80#endif
81#endif /* not lint */
82#endif
83
84/*-
85 * var.c --
86 * Variable-handling functions
87 *

--- 46 unchanged lines hidden (view full) ---

134#include <limits.h>
135#include <time.h>
136
137#include "make.h"
138#include "buf.h"
139#include "dir.h"
140#include "job.h"
141
80#endif
81#endif /* not lint */
82#endif
83
84/*-
85 * var.c --
86 * Variable-handling functions
87 *

--- 46 unchanged lines hidden (view full) ---

134#include <limits.h>
135#include <time.h>
136
137#include "make.h"
138#include "buf.h"
139#include "dir.h"
140#include "job.h"
141
142extern int makelevel;
142/*
143 * XXX transition hack for FreeBSD ports.
144 * bsd.port.mk can set .MAKE.FreeBSD_UL=yes
145 * to cause us to treat :[LU] as aliases for :t[lu]
146 * To be reverted when ports converts to :t[lu] (when 8.3 is EOL)
147 */
148#define MAKE_FREEBSD_UL ".MAKE.FreeBSD_UL"
149#ifdef MAKE_FREEBSD_UL

--- 513 unchanged lines hidden (view full) ---

663{
664 char tmp[BUFSIZ];
665 Hash_Entry *var;
666 Hash_Search state;
667 Var *v;
668 char *val;
669 int n;
670
143/*
144 * XXX transition hack for FreeBSD ports.
145 * bsd.port.mk can set .MAKE.FreeBSD_UL=yes
146 * to cause us to treat :[LU] as aliases for :t[lu]
147 * To be reverted when ports converts to :t[lu] (when 8.3 is EOL)
148 */
149#define MAKE_FREEBSD_UL ".MAKE.FreeBSD_UL"
150#ifdef MAKE_FREEBSD_UL

--- 513 unchanged lines hidden (view full) ---

664{
665 char tmp[BUFSIZ];
666 Hash_Entry *var;
667 Hash_Search state;
668 Var *v;
669 char *val;
670 int n;
671
672 /*
673 * Several make's support this sort of mechanism for tracking
674 * recursion - but each uses a different name.
675 * We allow the makefiles to update MAKELEVEL and ensure
676 * children see a correctly incremented value.
677 */
678 snprintf(tmp, sizeof(tmp), "%d", makelevel + 1);
679 setenv(MAKE_LEVEL_ENV, tmp, 1);
680
671 if (VAR_EXPORTED_NONE == var_exportedVars)
672 return;
673
674 if (VAR_EXPORTED_ALL == var_exportedVars) {
675 /*
676 * Ouch! This is crazy...
677 */
678 for (var = Hash_EnumFirst(&VAR_GLOBAL->context, &state);

--- 105 unchanged lines hidden (view full) ---

784
785 vlist = NULL;
786
787 str += 8;
788 unexport_env = (strncmp(str, "-env", 4) == 0);
789 if (unexport_env) {
790 char **newenv;
791
681 if (VAR_EXPORTED_NONE == var_exportedVars)
682 return;
683
684 if (VAR_EXPORTED_ALL == var_exportedVars) {
685 /*
686 * Ouch! This is crazy...
687 */
688 for (var = Hash_EnumFirst(&VAR_GLOBAL->context, &state);

--- 105 unchanged lines hidden (view full) ---

794
795 vlist = NULL;
796
797 str += 8;
798 unexport_env = (strncmp(str, "-env", 4) == 0);
799 if (unexport_env) {
800 char **newenv;
801
792 cp = getenv(MAKE_LEVEL); /* we should preserve this */
802 cp = getenv(MAKE_LEVEL_ENV); /* we should preserve this */
793 if (environ == savedEnv) {
794 /* we have been here before! */
795 newenv = bmake_realloc(environ, 2 * sizeof(char *));
796 } else {
797 if (savedEnv) {
798 free(savedEnv);
799 savedEnv = NULL;
800 }
801 newenv = bmake_malloc(2 * sizeof(char *));
802 }
803 if (!newenv)
804 return;
805 /* Note: we cannot safely free() the original environ. */
806 environ = savedEnv = newenv;
807 newenv[0] = NULL;
808 newenv[1] = NULL;
803 if (environ == savedEnv) {
804 /* we have been here before! */
805 newenv = bmake_realloc(environ, 2 * sizeof(char *));
806 } else {
807 if (savedEnv) {
808 free(savedEnv);
809 savedEnv = NULL;
810 }
811 newenv = bmake_malloc(2 * sizeof(char *));
812 }
813 if (!newenv)
814 return;
815 /* Note: we cannot safely free() the original environ. */
816 environ = savedEnv = newenv;
817 newenv[0] = NULL;
818 newenv[1] = NULL;
809 setenv(MAKE_LEVEL, cp, 1);
810#ifdef MAKE_LEVEL_SAFE
811 setenv(MAKE_LEVEL_SAFE, cp, 1);
812#endif
819 setenv(MAKE_LEVEL_ENV, cp, 1);
813 } else {
814 for (; *str != '\n' && isspace((unsigned char) *str); str++)
815 continue;
816 if (str[0] && str[0] != '\n') {
817 vlist = str;
818 }
819 }
820

--- 107 unchanged lines hidden (view full) ---

928 }
929 goto out;
930 }
931 VarFreeEnv(v, TRUE);
932 }
933 }
934 v = VarFind(name, ctxt, 0);
935 if (v == NULL) {
820 } else {
821 for (; *str != '\n' && isspace((unsigned char) *str); str++)
822 continue;
823 if (str[0] && str[0] != '\n') {
824 vlist = str;
825 }
826 }
827

--- 107 unchanged lines hidden (view full) ---

935 }
936 goto out;
937 }
938 VarFreeEnv(v, TRUE);
939 }
940 }
941 v = VarFind(name, ctxt, 0);
942 if (v == NULL) {
943 if (ctxt == VAR_CMD && (flags & VAR_NO_EXPORT) == 0) {
944 /*
945 * This var would normally prevent the same name being added
946 * to VAR_GLOBAL, so delete it from there if needed.
947 * Otherwise -V name may show the wrong value.
948 */
949 Var_Delete(name, VAR_GLOBAL);
950 }
936 VarAdd(name, val, ctxt);
937 } else {
938 Buf_Empty(&v->val);
939 Buf_AddBytes(&v->val, strlen(val), val);
940
941 if (DEBUG(VAR)) {
942 fprintf(debug_file, "%s:%s = %s\n", ctxt->name, name, val);
943 }

--- 18 unchanged lines hidden (view full) ---

962 * that the command-line settings continue to override
963 * Makefile settings.
964 */
965 if (varNoExportEnv != TRUE)
966 setenv(name, val, 1);
967
968 Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
969 }
951 VarAdd(name, val, ctxt);
952 } else {
953 Buf_Empty(&v->val);
954 Buf_AddBytes(&v->val, strlen(val), val);
955
956 if (DEBUG(VAR)) {
957 fprintf(debug_file, "%s:%s = %s\n", ctxt->name, name, val);
958 }

--- 18 unchanged lines hidden (view full) ---

977 * that the command-line settings continue to override
978 * Makefile settings.
979 */
980 if (varNoExportEnv != TRUE)
981 setenv(name, val, 1);
982
983 Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
984 }
970 /*
971 * Another special case.
972 * Several make's support this sort of mechanism for tracking
973 * recursion - but each uses a different name.
974 * We allow the makefiles to update .MAKE.LEVEL and ensure
975 * children see a correctly incremented value.
976 */
977 if (ctxt == VAR_GLOBAL && strcmp(MAKE_LEVEL, name) == 0) {
978 char tmp[64];
979 int level;
980
985
981 level = atoi(val);
982 snprintf(tmp, sizeof(tmp), "%u", level + 1);
983 setenv(MAKE_LEVEL, tmp, 1);
984#ifdef MAKE_LEVEL_SAFE
985 setenv(MAKE_LEVEL_SAFE, tmp, 1);
986#endif
987 }
988#ifdef MAKE_FREEBSD_UL
989 if (strcmp(MAKE_FREEBSD_UL, name) == 0) {
990 FreeBSD_UL = getBoolean(MAKE_FREEBSD_UL, FALSE);
991 }
992#endif
986#ifdef MAKE_FREEBSD_UL
987 if (strcmp(MAKE_FREEBSD_UL, name) == 0) {
988 FreeBSD_UL = getBoolean(MAKE_FREEBSD_UL, FALSE);
989 }
990#endif
993
994
991
992
995 out:
996 if (expanded_name != NULL)
997 free(expanded_name);
998 if (v != NULL)
999 VarFreeEnv(v, TRUE);
1000}
1001
1002/*-

--- 3222 unchanged lines hidden ---
993 out:
994 if (expanded_name != NULL)
995 free(expanded_name);
996 if (v != NULL)
997 VarFreeEnv(v, TRUE);
998}
999
1000/*-

--- 3222 unchanged lines hidden ---