View | Details | Raw Unified | Return to bug 59695
Collapse All | Expand All

(-)/usr/ports/devel/gmake/Makefile (-1 / +2 lines)
Lines 7-13 Link Here
7
7
8
PORTNAME=	gmake
8
PORTNAME=	gmake
9
PORTVERSION=	3.80
9
PORTVERSION=	3.80
10
PORTREVISION=	1
10
PORTREVISION=	2
11
CATEGORIES=	devel
11
CATEGORIES=	devel
12
MASTER_SITES=	${MASTER_SITE_GNU}
12
MASTER_SITES=	${MASTER_SITE_GNU}
13
MASTER_SITE_SUBDIR=	make
13
MASTER_SITE_SUBDIR=	make
Lines 35-40 Link Here
35
CONFIGURE_ENV+=	MAKEINFO="/usr/bin/makeinfo --no-split"
35
CONFIGURE_ENV+=	MAKEINFO="/usr/bin/makeinfo --no-split"
36
36
37
MAN1=		gmake.1
37
MAN1=		gmake.1
38
INFO=		make
38
39
39
.ifdef USE_GMAKE
40
.ifdef USE_GMAKE
40
.error You have `USE_GMAKE' variable defined either in environment or in make(1) arguments. Please undefine and try again.
41
.error You have `USE_GMAKE' variable defined either in environment or in make(1) arguments. Please undefine and try again.
(-)/usr/ports/devel/gmake/files/patch-eval_conditional (+150 lines)
Line 0 Link Here
1
Index: read.c
2
===================================================================
3
RCS file: /cvsroot/make/make/read.c,v
4
retrieving revision 1.124
5
diff -u -B -b -r1.124 read.c
6
--- read.c	14 Oct 2002 21:54:04 -0000	1.124
7
+++ read.c	25 Oct 2002 21:17:42 -0000
8
@@ -272,6 +272,34 @@
9
   return read_makefiles;
10
 }
11
 
12
+/* Install a new conditional and return the previous one.  */
13
+
14
+static struct conditionals *
15
+install_conditionals (struct conditionals *new)
16
+{
17
+  struct conditionals *save = conditionals;
18
+
19
+  bzero ((char *) new, sizeof (*new));
20
+  conditionals = new;
21
+
22
+  return save;
23
+}
24
+
25
+/* Free the current conditionals and reinstate a saved one.  */
26
+
27
+static void
28
+restore_conditionals (struct conditionals *saved)
29
+{
30
+  /* Free any space allocated by conditional_line.  */
31
+  if (conditionals->ignoring)
32
+    free (conditionals->ignoring);
33
+  if (conditionals->seen_else)
34
+    free (conditionals->seen_else);
35
+
36
+  /* Restore state.  */
37
+  conditionals = saved;
38
+}
39
+
40
 static int
41
 eval_makefile (char *filename, int flags)
42
 {
43
@@ -388,6 +416,8 @@
44
 eval_buffer (char *buffer)
45
 {
46
   struct ebuffer ebuf;
47
+  struct conditionals *saved;
48
+  struct conditionals new;
49
   const struct floc *curfile;
50
   int r;
51
 
52
@@ -402,8 +432,12 @@
53
   curfile = reading_file;
54
   reading_file = &ebuf.floc;
55
 
56
+  saved = install_conditionals (&new);
57
+
58
   r = eval (&ebuf, 1);
59
 
60
+  restore_conditionals (saved);
61
+
62
   reading_file = curfile;
63
 
64
   return r;
65
@@ -412,13 +446,8 @@
66
 
67
 /* Read file FILENAME as a makefile and add its contents to the data base.
68
 
69
-   SET_DEFAULT is true if we are allowed to set the default goal.
70
-
71
-   FILENAME is added to the `read_makefiles' chain.
72
+   SET_DEFAULT is true if we are allowed to set the default goal.  */
73
 
74
-   Returns 0 if a file was not found or not read.
75
-   Returns 1 if FILENAME was found and read.
76
-   Returns 2 if FILENAME was read, and we kept a reference (don't free it).  */
77
 
78
 static int
79
 eval (struct ebuffer *ebuf, int set_default)
80
@@ -782,9 +811,7 @@
81
 
82
 	  /* Save the state of conditionals and start
83
 	     the included makefile with a clean slate.  */
84
-	  save = conditionals;
85
-	  bzero ((char *) &new_conditionals, sizeof new_conditionals);
86
-	  conditionals = &new_conditionals;
87
+	  save = install_conditionals (&new_conditionals);
88
 
89
 	  /* Record the rules that are waiting so they will determine
90
 	     the default goal before those in the included makefile.  */
91
@@ -810,14 +837,8 @@
92
                 }
93
 	    }
94
 
95
-	  /* Free any space allocated by conditional_line.  */
96
-	  if (conditionals->ignoring)
97
-	    free (conditionals->ignoring);
98
-	  if (conditionals->seen_else)
99
-	    free (conditionals->seen_else);
100
-
101
-	  /* Restore state.  */
102
-	  conditionals = save;
103
+	  /* Restore conditional state.  */
104
+	  restore_conditionals (save);
105
 
106
           goto rule_complete;
107
 	}
108
Index: tests/scripts/functions/eval
109
===================================================================
110
RCS file: /cvsroot/make/make/tests/scripts/functions/eval,v
111
retrieving revision 1.1
112
diff -u -B -b -r1.1 eval
113
--- tests/scripts/functions/eval	8 Jul 2002 02:26:48 -0000	1.1
114
+++ tests/scripts/functions/eval	25 Oct 2002 21:17:42 -0000
115
@@ -57,4 +57,35 @@
116
 
117
 &compare_output($answer,&get_logfile(1));
118
 
119
+# Test to make sure eval'ing inside conditionals works properly
120
+
121
+$makefile3 = &get_tmpfile;
122
+
123
+open(MAKEFILE,"> $makefile3");
124
+
125
+print MAKEFILE <<'EOF';
126
+FOO = foo
127
+
128
+all:: ; @echo it
129
+
130
+define Y
131
+  all:: ; @echo worked
132
+endef
133
+
134
+ifdef BAR
135
+$(eval $(Y))
136
+endif
137
+
138
+EOF
139
+
140
+close(MAKEFILE);
141
+
142
+&run_make_with_options($makefile3, "", &get_logfile);
143
+$answer = "it\n";
144
+&compare_output($answer,&get_logfile(1));
145
+
146
+&run_make_with_options($makefile3, "BAR=1", &get_logfile);
147
+$answer = "it\nworked\n";
148
+&compare_output($answer,&get_logfile(1));
149
+
150
 1;
(-)/usr/ports/devel/gmake/files/patch-eval_crash (+77 lines)
Line 0 Link Here
1
Index: variable.h
2
===================================================================
3
RCS file: /cvsroot/make/make/variable.h,v
4
retrieving revision 1.24
5
diff -u -B -b -r1.24 variable.h
6
--- variable.h	8 Aug 2002 00:11:19 -0000	1.24
7
+++ variable.h	25 Oct 2002 21:37:32 -0000
8
@@ -107,6 +107,8 @@
9
 extern char *expand_argument PARAMS ((char *str, char *end));
10
 extern char *variable_expand_string PARAMS ((char *line, char *string,
11
                                              long length));
12
+extern void install_variable_buffer PARAMS ((char **bufp, unsigned int *lenp));
13
+extern void restore_variable_buffer PARAMS ((char *buf, unsigned int len));
14
 
15
 /* function.c */
16
 extern int handle_function PARAMS ((char **op, char **stringp));
17
Index: expand.c
18
===================================================================
19
RCS file: /cvsroot/make/make/expand.c,v
20
retrieving revision 1.33
21
diff -u -B -b -r1.33 expand.c
22
--- expand.c	14 Oct 2002 21:54:04 -0000	1.33
23
+++ expand.c	25 Oct 2002 21:37:32 -0000
24
@@ -545,3 +545,28 @@
25
 
26
   return value;
27
 }
28
+
29
+/* Install a new variable_buffer context, returning the current one for
30
+   safe-keeping.  */
31
+
32
+void
33
+install_variable_buffer (char **bufp, unsigned int *lenp)
34
+{
35
+  *bufp = variable_buffer;
36
+  *lenp = variable_buffer_length;
37
+
38
+  variable_buffer = 0;
39
+  initialize_variable_output ();
40
+}
41
+
42
+/* Restore a previously-saved variable_buffer setting (free the current one).
43
+ */
44
+
45
+void
46
+restore_variable_buffer (char *buf, unsigned int len)
47
+{
48
+  free (variable_buffer);
49
+
50
+  variable_buffer = buf;
51
+  variable_buffer_length = len;
52
+}
53
Index: function.c
54
===================================================================
55
RCS file: /cvsroot/make/make/function.c,v
56
retrieving revision 1.71
57
diff -u -B -b -r1.71 function.c
58
--- function.c	14 Oct 2002 21:54:04 -0000	1.71
59
+++ function.c	25 Oct 2002 21:37:32 -0000
60
@@ -1196,7 +1196,17 @@
61
 static char *
62
 func_eval (char *o, char **argv, const char *funcname)
63
 {
64
+  char *buf;
65
+  unsigned int len;
66
+
67
+  /* Eval the buffer.  Pop the current variable buffer setting so that the
68
+     eval'd code can use its own without conflicting.  */
69
+
70
+  install_variable_buffer (&buf, &len);
71
+
72
   eval_buffer (argv[0]);
73
+
74
+  restore_variable_buffer (buf, len);
75
 
76
   return o;
77
 }
(-)/usr/ports/devel/gmake/pkg-plist (-3 lines)
Lines 1-7 Link Here
1
bin/gmake
1
bin/gmake
2
@unexec install-info --delete %D/info/make.info %D/info/dir
3
info/make.info
4
@exec install-info %D/info/make.info %D/info/dir
5
%%NLS%%share/locale/da/LC_MESSAGES/make.mo
2
%%NLS%%share/locale/da/LC_MESSAGES/make.mo
6
%%NLS%%share/locale/de/LC_MESSAGES/make.mo
3
%%NLS%%share/locale/de/LC_MESSAGES/make.mo
7
%%NLS%%share/locale/es/LC_MESSAGES/make.mo
4
%%NLS%%share/locale/es/LC_MESSAGES/make.mo

Return to bug 59695