3
if [ $# -eq 3 -a "$2" = '-d' ]; then
5
elif [ $# -ne 1 ]; then
6
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
10
-patch) patch $pdir -f --no-backup-if-mismatch -p0 < $0;;
11
-unpatch) patch $pdir -f --no-backup-if-mismatch -R -p0 < $0;;
13
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
18
# DP: bash-4.0 upstream fix 007
26
Bug-Reported-by: AnMaster <anmaster@tele2.se>
27
Bug-Reference-ID: <49A41C18.80807@tele2.se>
28
Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2009-02/msg00188.html
32
Bash had a number of problems parsing associative array subscripts containing
33
special characters. The subscripts are supposed to be read as if they are
34
enclosed between double quotes.
38
*** ../bash-4.0/parse.y 2009-01-08 08:29:12.000000000 -0500
39
--- parse.y 2009-02-25 17:25:56.000000000 -0500
43
#define P_COMMAND 0x08 /* parsing a command, so look for comments */
44
#define P_BACKQUOTE 0x10 /* parsing a backquoted command substitution */
45
+ #define P_ARRAYSUB 0x20 /* parsing a [...] array subscript for assignment */
47
/* Lexical state while parsing a grouping construct or $(...). */
53
+ else if ((flags & P_ARRAYSUB) && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */
54
+ goto parse_dollar_word;
56
/* Parse an old-style command substitution within double quotes as a
60
/* check for $(), $[], or ${} inside quoted string. */
63
if (open == ch) /* undo previous increment */
67
(token_index == 0 && (parser_state&PST_COMPASSIGN))))
69
! ttok = parse_matched_pair (cd, '[', ']', &ttoklen, 0);
70
if (ttok == &matched_pair_error)
71
return -1; /* Bail immediately. */
73
(token_index == 0 && (parser_state&PST_COMPASSIGN))))
75
! ttok = parse_matched_pair (cd, '[', ']', &ttoklen, P_ARRAYSUB);
76
if (ttok == &matched_pair_error)
77
return -1; /* Bail immediately. */
78
*** ../bash-4.0/arrayfunc.c 2009-01-04 14:32:21.000000000 -0500
79
--- arrayfunc.c 2009-02-25 07:58:54.000000000 -0500
84
! /* This function assumes s[i] == '['; returns with s[ret] == ']' if
85
! an array subscript is correctly parsed. */
87
! skipsubscript (s, i)
92
! #if defined (HANDLE_MULTIBYTE)
93
! mbstate_t state, state_bak;
94
! size_t slength, mblength;
97
! #if defined (HANDLE_MULTIBYTE)
98
! memset (&state, '\0', sizeof (mbstate_t));
99
! slength = strlen (s + i);
105
! /* Advance one (possibly multibyte) character in S starting at I. */
106
! #if defined (HANDLE_MULTIBYTE)
107
! if (MB_CUR_MAX > 1)
110
! mblength = mbrlen (s + i, slength, &state);
112
! if (MB_INVALIDCH (mblength))
118
! else if (MB_NULLWCH (mblength))
123
! slength -= mblength;
143
/* This function is called with SUB pointing to just after the beginning
147
! /* skipsubscript moved to subst.c to use private functions. 2009/02/24. */
149
/* This function is called with SUB pointing to just after the beginning
150
*** ../bash-4.0/subst.c 2009-01-28 14:34:12.000000000 -0500
151
--- subst.c 2009-02-25 09:18:33.000000000 -0500
155
static char *extract_delimited_string __P((char *, int *, char *, char *, char *, int));
156
static char *extract_dollar_brace_string __P((char *, int *, int, int));
157
+ static int skip_matched_pair __P((const char *, int, int, int, int));
159
static char *pos_params __P((char *, int, int, int));
163
#define CQ_RETURN(x) do { no_longjmp_on_fatal_error = 0; return (x); } while (0)
165
+ /* This function assumes s[i] == open; returns with s[ret] == close; used to
166
+ parse array subscripts. FLAGS currently unused. */
168
+ skip_matched_pair (string, start, open, close, flags)
169
+ const char *string;
170
+ int start, open, close, flags;
172
+ int i, pass_next, backq, si, c, count;
177
+ slen = strlen (string + start) + start;
178
+ no_longjmp_on_fatal_error = 1;
180
+ i = start + 1; /* skip over leading bracket */
182
+ pass_next = backq = 0;
183
+ ss = (char *)string;
184
+ while (c = string[i])
191
+ ADVANCE_CHAR (string, slen, i);
194
+ else if (c == '\\')
204
+ ADVANCE_CHAR (string, slen, i);
213
+ else if (c == open)
219
+ else if (c == close)
227
+ else if (c == '\'' || c == '"')
229
+ i = (c == '\'') ? skip_single_quoted (ss, slen, ++i)
230
+ : skip_double_quoted (ss, slen, ++i);
231
+ /* no increment, the skip functions increment past the closing quote. */
233
+ else if (c == '$' && (string[i+1] == LPAREN || string[i+1] == LBRACE))
236
+ if (string[si] == '\0')
239
+ if (string[i+1] == LPAREN)
240
+ temp = extract_delimited_string (ss, &si, "$(", "(", ")", SX_NOALLOC|SX_COMMAND); /* ) */
242
+ temp = extract_dollar_brace_string (ss, &si, 0, SX_NOALLOC);
244
+ if (string[i] == '\0') /* don't increment i past EOS in loop */
250
+ ADVANCE_CHAR (string, slen, i);
256
+ #if defined (ARRAY_VARS)
258
+ skipsubscript (string, start)
259
+ const char *string;
262
+ return (skip_matched_pair (string, start, '[', ']', 0));
266
/* Skip characters in STRING until we find a character in DELIMS, and return
267
the index of that character. START is the index into string at which we
268
*** ../bash-4.0/patchlevel.h 2009-01-04 14:32:40.000000000 -0500
269
--- patchlevel.h 2009-02-22 16:11:31.000000000 -0500
272
looks for to find the patch level (for the sccs version string). */
274
! #define PATCHLEVEL 6
276
#endif /* _PATCHLEVEL_H_ */
278
looks for to find the patch level (for the sccs version string). */
280
! #define PATCHLEVEL 7
282
#endif /* _PATCHLEVEL_H_ */