source: patches/bash-3.2-fixes-3.patch@ a68510b6

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

Updated Bash Patch with Upstream Fixes

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