source: patches/bash-3.2-fixes-4.patch@ 277483d

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 277483d was 8d87eba, checked in by Jim Gifford <clfs@…>, 18 years ago

Update Bash Upstream Patch

  • Property mode set to 100644
File size: 11.4 KB
RevLine 
[9717098]1Submitted By: Jim Gifford (jim at linuxfromscratch dot org)
[8d87eba]2Date: 2006-12-12
[9717098]3Initial Package Version: 3.2
4Origin: ftp://ftp.cwru.edu/pub/bash/bash-3.2-patches/
5Upstream Status: From Upstream
[8d87eba]6Description: Contains patches 001-009 from upstream
[9717098]7
8diff -Naur bash-3.2.orig/builtins/printf.def bash-3.2/builtins/printf.def
9--- bash-3.2.orig/builtins/printf.def 2006-09-18 05:48:42.000000000 -0700
[8d87eba]10+++ bash-3.2/builtins/printf.def 2006-12-12 15:10:15.000000000 -0800
[9717098]11@@ -49,6 +49,12 @@
12 # define INT_MIN (-2147483647-1)
13 #endif
14
15+#if defined (PREFER_STDARG)
16+# include <stdarg.h>
17+#else
18+# include <varargs.h>
19+#endif
20+
21 #include <stdio.h>
22 #include <chartypes.h>
23
24@@ -151,6 +157,10 @@
25 #define SKIP1 "#'-+ 0"
26 #define LENMODS "hjlLtz"
27
28+#ifndef HAVE_ASPRINTF
29+extern int asprintf __P((char **, const char *, ...)) __attribute__((__format__ (printf, 2, 3)));
30+#endif
31+
32 static void printf_erange __P((char *));
33 static int printstr __P((char *, char *, int, int, int));
34 static int tescape __P((char *, char *, int *));
[8d87eba]35diff -Naur bash-3.2.orig/findcmd.c bash-3.2/findcmd.c
36--- bash-3.2.orig/findcmd.c 2005-08-17 13:49:54.000000000 -0700
37+++ bash-3.2/findcmd.c 2006-12-12 15:11:54.000000000 -0800
38@@ -308,7 +308,7 @@
39 if (hashed_file && (posixly_correct || check_hashed_filenames))
40 {
41 st = file_status (hashed_file);
42- if ((st ^ (FS_EXISTS | FS_EXECABLE)) != 0)
43+ if ((st & (FS_EXISTS|FS_EXECABLE)) != (FS_EXISTS|FS_EXECABLE))
44 {
45 phash_remove (pathname);
46 free (hashed_file);
47diff -Naur bash-3.2.orig/jobs.c bash-3.2/jobs.c
48--- bash-3.2.orig/jobs.c 2006-07-29 13:40:48.000000000 -0700
49+++ bash-3.2/jobs.c 2006-12-12 15:11:37.000000000 -0800
50@@ -984,8 +984,6 @@
51 temp = jobs[job_index];
52 if (temp == 0)
53 return;
54- if (job_index == js.j_current || job_index == js.j_previous)
55- reset_current ();
56
57 if ((dflags & DEL_NOBGPID) == 0)
58 {
59@@ -1028,6 +1026,9 @@
60 js.j_firstj = js.j_lastj = 0;
61 else if (jobs[js.j_firstj] == 0 || jobs[js.j_lastj] == 0)
62 reset_job_indices ();
63+
64+ if (job_index == js.j_current || job_index == js.j_previous)
65+ reset_current ();
66 }
67
68 /* Must be called with SIGCHLD blocked. */
69diff -Naur bash-3.2.orig/lib/readline/display.c bash-3.2/lib/readline/display.c
70--- bash-3.2.orig/lib/readline/display.c 2006-09-14 11:20:12.000000000 -0700
71+++ bash-3.2/lib/readline/display.c 2006-12-12 15:11:08.000000000 -0800
72@@ -2380,6 +2380,8 @@
73
74 if (end <= start)
75 return 0;
76+ if (MB_CUR_MAX == 1 || rl_byte_oriented)
77+ return (end - start);
78
79 memset (&ps, 0, sizeof (mbstate_t));
80
[9717098]81diff -Naur bash-3.2.orig/lib/sh/snprintf.c bash-3.2/lib/sh/snprintf.c
82--- bash-3.2.orig/lib/sh/snprintf.c 2006-04-06 06:48:40.000000000 -0700
[8d87eba]83+++ bash-3.2/lib/sh/snprintf.c 2006-12-12 15:10:15.000000000 -0800
[9717098]84@@ -471,6 +471,8 @@
85 10^x ~= r
86 * log_10(200) = 2;
87 * log_10(250) = 2;
88+ *
89+ * NOTE: do not call this with r == 0 -- an infinite loop results.
90 */
91 static int
92 log_10(r)
93@@ -576,8 +578,11 @@
94 {
95 integral_part[0] = '0';
96 integral_part[1] = '\0';
97- fraction_part[0] = '0';
98- fraction_part[1] = '\0';
99+ /* The fractional part has to take the precision into account */
100+ for (ch = 0; ch < precision-1; ch++)
101+ fraction_part[ch] = '0';
102+ fraction_part[ch] = '0';
103+ fraction_part[ch+1] = '\0';
104 if (fract)
105 *fract = fraction_part;
106 return integral_part;
107@@ -805,6 +810,7 @@
108 PUT_CHAR(*tmp, p);
109 tmp++;
110 }
111+
112 PAD_LEFT(p);
113 }
114
115@@ -972,11 +978,21 @@
116 if ((p->flags & PF_THOUSANDS) && grouping && (t = groupnum (tmp)))
117 tmp = t;
118
119+ if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
120+ {
121+ /* smash the trailing zeros unless altform */
122+ for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
123+ tmp2[i] = '\0';
124+ if (tmp2[0] == '\0')
125+ p->precision = 0;
126+ }
127+
128 /* calculate the padding. 1 for the dot */
129 p->width = p->width -
130 ((d > 0. && p->justify == RIGHT) ? 1:0) -
131 ((p->flags & PF_SPACE) ? 1:0) -
132- strlen(tmp) - p->precision - 1;
133+ strlen(tmp) - p->precision -
134+ ((p->precision != 0 || (p->flags & PF_ALTFORM)) ? 1 : 0); /* radix char */
135 PAD_RIGHT(p);
136 PUT_PLUS(d, p, 0.);
137 PUT_SPACE(d, p, 0.);
138@@ -991,11 +1007,6 @@
139 if (p->precision != 0 || (p->flags & PF_ALTFORM))
140 PUT_CHAR(decpoint, p); /* put the '.' */
141
142- if ((*p->pf == 'g' || *p->pf == 'G') && (p->flags & PF_ALTFORM) == 0)
143- /* smash the trailing zeros unless altform */
144- for (i = strlen(tmp2) - 1; i >= 0 && tmp2[i] == '0'; i--)
145- tmp2[i] = '\0';
146-
147 for (; *tmp2; tmp2++)
148 PUT_CHAR(*tmp2, p); /* the fraction */
149
150@@ -1011,14 +1022,19 @@
151 char *tmp, *tmp2;
152 int j, i;
153
154- if (chkinfnan(p, d, 1) || chkinfnan(p, d, 2))
155+ if (d != 0 && (chkinfnan(p, d, 1) || chkinfnan(p, d, 2)))
156 return; /* already printed nan or inf */
157
158 GETLOCALEDATA(decpoint, thoussep, grouping);
159 DEF_PREC(p);
160- j = log_10(d);
161- d = d / pow_10(j); /* get the Mantissa */
162- d = ROUND(d, p);
163+ if (d == 0.)
164+ j = 0;
165+ else
166+ {
167+ j = log_10(d);
168+ d = d / pow_10(j); /* get the Mantissa */
169+ d = ROUND(d, p);
170+ }
171 tmp = dtoa(d, p->precision, &tmp2);
172
173 /* 1 for unit, 1 for the '.', 1 for 'e|E',
174@@ -1076,6 +1092,7 @@
175 PUT_CHAR(*tmp, p);
176 tmp++;
177 }
178+
179 PAD_LEFT(p);
180 }
181 #endif
182@@ -1358,7 +1375,7 @@
183 STAR_ARGS(data);
184 DEF_PREC(data);
185 d = GETDOUBLE(data);
186- i = log_10(d);
187+ i = (d != 0.) ? log_10(d) : -1;
188 /*
189 * for '%g|%G' ANSI: use f if exponent
190 * is in the range or [-4,p] exclusively
191diff -Naur bash-3.2.orig/parse.y bash-3.2/parse.y
192--- bash-3.2.orig/parse.y 2006-09-19 13:37:21.000000000 -0700
[8d87eba]193+++ bash-3.2/parse.y 2006-12-12 15:10:15.000000000 -0800
[9717098]194@@ -1029,6 +1029,7 @@
195 #define PST_CMDTOKEN 0x1000 /* command token OK - unused */
196 #define PST_COMPASSIGN 0x2000 /* parsing x=(...) compound assignment */
197 #define PST_ASSIGNOK 0x4000 /* assignment statement ok in this context */
198+#define PST_REGEXP 0x8000 /* parsing an ERE/BRE as a single word */
199
200 /* Initial size to allocate for tokens, and the
201 amount to grow them by. */
202@@ -2591,6 +2592,9 @@
203 return (character);
204 }
205
206+ if (parser_state & PST_REGEXP)
207+ goto tokword;
208+
209 /* Shell meta-characters. */
210 if MBTEST(shellmeta (character) && ((parser_state & PST_DBLPAREN) == 0))
211 {
212@@ -2698,6 +2702,7 @@
213 if MBTEST(character == '-' && (last_read_token == LESS_AND || last_read_token == GREATER_AND))
214 return (character);
215
216+tokword:
217 /* Okay, if we got this far, we have to read a word. Read one,
218 and then check it against the known ones. */
219 result = read_token_word (character);
220@@ -2735,7 +2740,7 @@
221 /* itrace("parse_matched_pair: open = %c close = %c", open, close); */
222 count = 1;
223 pass_next_character = backq_backslash = was_dollar = in_comment = 0;
224- check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
225+ check_comment = (flags & P_COMMAND) && qc != '`' && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
226
227 /* RFLAGS is the set of flags we want to pass to recursive calls. */
228 rflags = (qc == '"') ? P_DQUOTE : (flags & P_DQUOTE);
229@@ -3202,8 +3207,11 @@
230 if (tok == WORD && test_binop (yylval.word->word))
231 op = yylval.word;
232 #if defined (COND_REGEXP)
233- else if (tok == WORD && STREQ (yylval.word->word,"=~"))
234- op = yylval.word;
235+ else if (tok == WORD && STREQ (yylval.word->word, "=~"))
236+ {
237+ op = yylval.word;
238+ parser_state |= PST_REGEXP;
239+ }
240 #endif
241 else if (tok == '<' || tok == '>')
242 op = make_word_from_token (tok); /* ( */
243@@ -3234,6 +3242,7 @@
244
245 /* rhs */
246 tok = read_token (READ);
247+ parser_state &= ~PST_REGEXP;
248 if (tok == WORD)
249 {
250 tright = make_cond_node (COND_TERM, yylval.word, (COND_COM *)NULL, (COND_COM *)NULL);
251@@ -3419,9 +3428,34 @@
252 goto next_character;
253 }
254
255+#ifdef COND_REGEXP
256+ /* When parsing a regexp as a single word inside a conditional command,
257+ we need to special-case characters special to both the shell and
258+ regular expressions. Right now, that is only '(' and '|'. */ /*)*/
259+ if MBTEST((parser_state & PST_REGEXP) && (character == '(' || character == '|')) /*)*/
260+ {
261+ if (character == '|')
262+ goto got_character;
263+
264+ push_delimiter (dstack, character);
265+ ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
266+ pop_delimiter (dstack);
267+ if (ttok == &matched_pair_error)
268+ return -1; /* Bail immediately. */
269+ RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
270+ token_buffer_size, TOKEN_DEFAULT_GROW_SIZE);
271+ token[token_index++] = character;
272+ strcpy (token + token_index, ttok);
273+ token_index += ttoklen;
274+ FREE (ttok);
275+ dollar_present = all_digit_token = 0;
276+ goto next_character;
277+ }
278+#endif /* COND_REGEXP */
279+
280 #ifdef EXTENDED_GLOB
281 /* Parse a ksh-style extended pattern matching specification. */
282- if (extended_glob && PATTERN_CHAR (character))
283+ if MBTEST(extended_glob && PATTERN_CHAR (character))
284 {
285 peek_char = shell_getc (1);
286 if MBTEST(peek_char == '(') /* ) */
287diff -Naur bash-3.2.orig/patchlevel.h bash-3.2/patchlevel.h
288--- bash-3.2.orig/patchlevel.h 2006-04-13 05:31:04.000000000 -0700
[8d87eba]289+++ bash-3.2/patchlevel.h 2006-12-12 15:11:54.000000000 -0800
[9717098]290@@ -25,6 +25,6 @@
291 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
292 looks for to find the patch level (for the sccs version string). */
293
294-#define PATCHLEVEL 0
[8d87eba]295+#define PATCHLEVEL 8
[9717098]296
297 #endif /* _PATCHLEVEL_H_ */
298diff -Naur bash-3.2.orig/po/ru.po bash-3.2/po/ru.po
299--- bash-3.2.orig/po/ru.po 2006-01-10 14:51:03.000000000 -0800
[8d87eba]300+++ bash-3.2/po/ru.po 2006-12-12 15:10:15.000000000 -0800
[9717098]301@@ -12,7 +12,7 @@
302 "Last-Translator: Evgeniy Dushistov <dushistov@mail.ru>\n"
303 "Language-Team: Russian <ru@li.org>\n"
304 "MIME-Version: 1.0\n"
305-"Content-Type: text/plain; charset=UTF-8\n"
306+"Content-Type: text/plain; charset=KOI8-R\n"
307 "Content-Transfer-Encoding: 8bit\n"
308 "Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
309
310diff -Naur bash-3.2.orig/subst.c bash-3.2/subst.c
311--- bash-3.2.orig/subst.c 2006-09-19 05:35:09.000000000 -0700
[8d87eba]312+++ bash-3.2/subst.c 2006-12-12 15:10:15.000000000 -0800
[9717098]313@@ -5707,6 +5707,11 @@
314 vtype &= ~VT_STARSUB;
315
316 mflags = 0;
317+ if (patsub && *patsub == '/')
318+ {
319+ mflags |= MATCH_GLOBREP;
320+ patsub++;
321+ }
322
323 /* Malloc this because expand_string_if_necessary or one of the expansion
324 functions in its call chain may free it on a substitution error. */
325@@ -5741,13 +5746,12 @@
326 }
327
328 /* ksh93 doesn't allow the match specifier to be a part of the expanded
329- pattern. This is an extension. */
330+ pattern. This is an extension. Make sure we don't anchor the pattern
331+ at the beginning or end of the string if we're doing global replacement,
332+ though. */
333 p = pat;
334- if (pat && pat[0] == '/')
335- {
336- mflags |= MATCH_GLOBREP|MATCH_ANY;
337- p++;
338- }
339+ if (mflags & MATCH_GLOBREP)
340+ mflags |= MATCH_ANY;
341 else if (pat && pat[0] == '#')
342 {
343 mflags |= MATCH_BEG;
344diff -Naur bash-3.2.orig/tests/new-exp.right bash-3.2/tests/new-exp.right
345--- bash-3.2.orig/tests/new-exp.right 2006-08-10 09:00:00.000000000 -0700
[8d87eba]346+++ bash-3.2/tests/new-exp.right 2006-12-12 15:10:15.000000000 -0800
[9717098]347@@ -430,7 +430,7 @@
348 Case06---1---A B C::---
349 Case07---3---A:B:C---
350 Case08---3---A:B:C---
351-./new-exp.tests: line 506: /${$(($#-1))}: bad substitution
352+./new-exp.tests: line 506: ${$(($#-1))}: bad substitution
353 argv[1] = <a>
354 argv[2] = <b>
355 argv[3] = <c>
Note: See TracBrowser for help on using the repository browser.