source: patches/make-3.82-fixes-1.patch@ 34649df

clfs-3.0.0-sysvinit sysvinit
Last change on this file since 34649df was d87123b, checked in by William Harrington <kb0iic@…>, 11 years ago

Add make 3.82 fixes patch for upstream changes.

  • Property mode set to 100644
File size: 9.4 KB
RevLine 
[d87123b]1Submitted By: William Harrington at <kb0iic at cross-lfs dot org>
2Date: 2013-08-01
3Initial Package Version: 3.82
4Upstream Status: Fixed Upstream
5Origin: Upstream
6Description: Several bug fixes from upstream git
7
8diff -Naur make-3.82.orig/expand.c make-3.82/expand.c
9--- make-3.82.orig/expand.c 2010-07-13 01:20:39.000000000 +0000
10+++ make-3.82/expand.c 2013-08-01 20:44:22.773645293 +0000
11@@ -197,7 +197,7 @@
12 {
13 struct variable *v;
14 const char *p, *p1;
15- char *abuf = NULL;
16+ char *save;
17 char *o;
18 unsigned int line_offset;
19
20@@ -212,16 +212,11 @@
21 return (variable_buffer);
22 }
23
24- /* If we want a subset of the string, allocate a temporary buffer for it.
25- Most of the functions we use here don't work with length limits. */
26- if (length > 0 && string[length] != '\0')
27- {
28- abuf = xmalloc(length+1);
29- memcpy(abuf, string, length);
30- abuf[length] = '\0';
31- string = abuf;
32- }
33- p = string;
34+ /* We need a copy of STRING: due to eval, it's possible that it will get
35+ freed as we process it (it might be the value of a variable that's reset
36+ for example). Also having a nil-terminated string is handy. */
37+ save = length < 0 ? xstrdup (string) : xstrndup (string, length);
38+ p = save;
39
40 while (1)
41 {
42@@ -411,8 +406,7 @@
43 ++p;
44 }
45
46- if (abuf)
47- free (abuf);
48+ free (save);
49
50 variable_buffer_output (o, "", 1);
51 return (variable_buffer + line_offset);
52diff -Naur make-3.82.orig/function.c make-3.82/function.c
53--- make-3.82.orig/function.c 2010-07-13 01:20:39.000000000 +0000
54+++ make-3.82/function.c 2013-08-01 20:45:09.100176320 +0000
55@@ -706,7 +706,7 @@
56 const char *word_iterator = argv[0];
57 char buf[20];
58
59- while (find_next_token (&word_iterator, (unsigned int *) 0) != 0)
60+ while (find_next_token (&word_iterator, NULL) != 0)
61 ++i;
62
63 sprintf (buf, "%d", i);
64@@ -1133,21 +1133,14 @@
65
66 /* Find the maximum number of words we'll have. */
67 t = argv[0];
68- wordi = 1;
69- while (*t != '\0')
70+ wordi = 0;
71+ while ((p = find_next_token (&t, NULL)) != 0)
72 {
73- char c = *(t++);
74-
75- if (! isspace ((unsigned char)c))
76- continue;
77-
78+ ++t;
79 ++wordi;
80-
81- while (isspace ((unsigned char)*t))
82- ++t;
83 }
84
85- words = xmalloc (wordi * sizeof (char *));
86+ words = xmalloc ((wordi == 0 ? 1 : wordi) * sizeof (char *));
87
88 /* Now assign pointers to each string in the array. */
89 t = argv[0];
90diff -Naur make-3.82.orig/job.c make-3.82/job.c
91--- make-3.82.orig/job.c 2010-07-24 08:27:50.000000000 +0000
92+++ make-3.82/job.c 2013-08-01 20:44:54.400222908 +0000
93@@ -29,6 +29,15 @@
94
95 #include <string.h>
96
97+#if defined(__linux__) /* defined (HAVE_LINUX_BINFMTS_H) && defined (HAVE_SYS_USER_H) */
98+#include <sys/user.h>
99+#include <unistd.h>
100+#ifndef PAGE_SIZE
101+#define PAGE_SIZE sysconf(_SC_PAGE_SIZE)
102+#endif
103+#include <linux/binfmts.h>
104+#endif
105+
106 /* Default shell to use. */
107 #ifdef WINDOWS32
108 #include <windows.h>
109@@ -2791,6 +2800,15 @@
110 argument list. */
111
112 unsigned int shell_len = strlen (shell);
113+#ifdef MAX_ARG_STRLEN
114+ static char eval_line[] = "eval\\ \\\"set\\ x\\;\\ shift\\;\\ ";
115+#define ARG_NUMBER_DIGITS 5
116+#define EVAL_LEN (sizeof(eval_line)-1 + shell_len + 4 \
117+ + (7 + ARG_NUMBER_DIGITS) * 2 * line_len / (MAX_ARG_STRLEN - 2))
118+#else
119+#define EVAL_LEN 0
120+#endif
121+ char *args_ptr;
122 unsigned int line_len = strlen (line);
123 unsigned int sflags_len = strlen (shellflags);
124 char *command_ptr = NULL; /* used for batch_mode_shell mode */
125@@ -2866,7 +2884,7 @@
126 }
127
128 new_line = alloca (shell_len + 1 + sflags_len + 1
129- + (line_len*2) + 1);
130+ + (line_len*2) + 1 + EVAL_LEN);
131 ap = new_line;
132 memcpy (ap, shell, shell_len);
133 ap += shell_len;
134@@ -2875,6 +2893,30 @@
135 ap += sflags_len;
136 *(ap++) = ' ';
137 command_ptr = ap;
138+
139+#if !defined (WINDOWS32) && defined (MAX_ARG_STRLEN)
140+ if (unixy_shell && line_len > MAX_ARG_STRLEN)
141+ {
142+ unsigned j;
143+ memcpy (ap, eval_line, sizeof (eval_line) - 1);
144+ ap += sizeof (eval_line) - 1;
145+ for (j = 1; j <= 2 * line_len / (MAX_ARG_STRLEN - 2); j++)
146+ ap += sprintf (ap, "\\$\\{%u\\}", j);
147+ *ap++ = '\\';
148+ *ap++ = '"';
149+ *ap++ = ' ';
150+ /* Copy only the first word of SHELL to $0. */
151+ for (p = shell; *p != '\0'; ++p)
152+ {
153+ if (isspace ((unsigned char)*p))
154+ break;
155+ *ap++ = *p;
156+ }
157+ *ap++ = ' ';
158+ }
159+#endif
160+ args_ptr = ap;
161+
162 for (p = line; *p != '\0'; ++p)
163 {
164 if (restp != NULL && *p == '\n')
165@@ -2922,6 +2964,14 @@
166 }
167 #endif
168 *ap++ = *p;
169+
170+#if !defined (WINDOWS32) && defined (MAX_ARG_STRLEN)
171+ if (unixy_shell && line_len > MAX_ARG_STRLEN && (ap - args_ptr > MAX_ARG_STRLEN - 2))
172+ {
173+ *ap++ = ' ';
174+ args_ptr = ap;
175+ }
176+#endif
177 }
178 if (ap == new_line + shell_len + sflags_len + 2)
179 /* Line was empty. */
180diff -Naur make-3.82.orig/main.c make-3.82/main.c
181--- make-3.82.orig/main.c 2010-07-19 07:10:53.000000000 +0000
182+++ make-3.82/main.c 2013-08-01 20:45:20.540147980 +0000
183@@ -1138,7 +1138,7 @@
184 a macro and some compilers (MSVC) don't like conditionals in macros. */
185 {
186 const char *features = "target-specific order-only second-expansion"
187- " else-if shortest-stem undefine"
188+ " else-if shortest-stem undefine oneshell"
189 #ifndef NO_ARCHIVES
190 " archives"
191 #endif
192@@ -2093,7 +2093,7 @@
193 const char *pv = define_makeflags (1, 1);
194 char *p = alloca (sizeof ("MAKEFLAGS=") + strlen (pv) + 1);
195 sprintf (p, "MAKEFLAGS=%s", pv);
196- putenv (p);
197+ putenv (allocated_variable_expand (p));
198 }
199
200 if (ISDB (DB_BASIC))
201diff -Naur make-3.82.orig/read.c make-3.82/read.c
202--- make-3.82.orig/read.c 2010-07-13 01:20:42.000000000 +0000
203+++ make-3.82/read.c 2013-08-01 20:44:39.690263962 +0000
204@@ -2904,6 +2904,7 @@
205 const char *name;
206 const char **nlist = 0;
207 char *tildep = 0;
208+ int globme = 1;
209 #ifndef NO_ARCHIVES
210 char *arname = 0;
211 char *memname = 0;
212@@ -3028,7 +3029,7 @@
213 {
214 /* This looks like the first element in an open archive group.
215 A valid group MUST have ')' as the last character. */
216- const char *e = p + nlen;
217+ const char *e = p;
218 do
219 {
220 e = next_token (e);
221@@ -3084,19 +3085,19 @@
222 Go to the next item in the string. */
223 if (flags & PARSEFS_NOGLOB)
224 {
225- NEWELT (concat (2, prefix, tp));
226+ NEWELT (concat (2, prefix, tmpbuf));
227 continue;
228 }
229
230 /* If we get here we know we're doing glob expansion.
231 TP is a string in tmpbuf. NLEN is no longer used.
232 We may need to do more work: after this NAME will be set. */
233- name = tp;
234+ name = tmpbuf;
235
236 /* Expand tilde if applicable. */
237- if (tp[0] == '~')
238+ if (tmpbuf[0] == '~')
239 {
240- tildep = tilde_expand (tp);
241+ tildep = tilde_expand (tmpbuf);
242 if (tildep != 0)
243 name = tildep;
244 }
245@@ -3112,32 +3113,40 @@
246 }
247 #endif /* !NO_ARCHIVES */
248
249- switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl))
250- {
251- case GLOB_NOSPACE:
252- fatal (NILF, _("virtual memory exhausted"));
253-
254- case 0:
255- /* Success. */
256- i = gl.gl_pathc;
257- nlist = (const char **)gl.gl_pathv;
258- break;
259-
260- case GLOB_NOMATCH:
261- /* If we want only existing items, skip this one. */
262- if (flags & PARSEFS_EXISTS)
263- {
264- i = 0;
265- break;
266- }
267- /* FALLTHROUGH */
268-
269- default:
270- /* By default keep this name. */
271+ /* glob() is expensive: don't call it unless we need to. */
272+ if (!(flags & PARSEFS_EXISTS) && strpbrk (name, "?*[") == NULL)
273+ {
274+ globme = 0;
275 i = 1;
276 nlist = &name;
277- break;
278- }
279+ }
280+ else
281+ switch (glob (name, GLOB_NOSORT|GLOB_ALTDIRFUNC, NULL, &gl))
282+ {
283+ case GLOB_NOSPACE:
284+ fatal (NILF, _("virtual memory exhausted"));
285+
286+ case 0:
287+ /* Success. */
288+ i = gl.gl_pathc;
289+ nlist = (const char **)gl.gl_pathv;
290+ break;
291+
292+ case GLOB_NOMATCH:
293+ /* If we want only existing items, skip this one. */
294+ if (flags & PARSEFS_EXISTS)
295+ {
296+ i = 0;
297+ break;
298+ }
299+ /* FALLTHROUGH */
300+
301+ default:
302+ /* By default keep this name. */
303+ i = 1;
304+ nlist = &name;
305+ break;
306+ }
307
308 /* For each matched element, add it to the list. */
309 while (i-- > 0)
310@@ -3152,7 +3161,10 @@
311 else
312 {
313 /* We got a chain of items. Attach them. */
314- (*newp)->next = found;
315+ if (*newp)
316+ (*newp)->next = found;
317+ else
318+ *newp = found;
319
320 /* Find and set the new end. Massage names if necessary. */
321 while (1)
322@@ -3174,7 +3186,8 @@
323 #endif /* !NO_ARCHIVES */
324 NEWELT (concat (2, prefix, nlist[i]));
325
326- globfree (&gl);
327+ if (globme)
328+ globfree (&gl);
329
330 #ifndef NO_ARCHIVES
331 if (arname)
Note: See TracBrowser for help on using the repository browser.