7 Bug-Reported-by: Stephane Chazelas <stephane_chazelas@yahoo.fr>
8 Bug-Reference-ID: <20040902131957.GC1860@frhdtmp102861.morse.corp.wan>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2004-07/msg00291.html
13 Calculation of lengths and offsets for parameter string length and substring
14 expansion does not correctly account for multibyte characters.
18 *** ../bash-3.0/subst.c Sun Jul 4 13:56:13 2004
19 --- subst.c Thu Aug 12 13:36:17 2004
25 + #if defined (HANDLE_MULTIBYTE)
34 + memset (&mbs, 0, sizeof (mbs));
35 + while ((clen = mbrlen(s, MB_CUR_MAX, &mbs)) != 0 && (MB_INVALIDCH(clen) == 0))
45 /* Handle the parameter brace expansion that requires us to return the
46 length of a parameter. */
50 t = get_dollar_var_value (arg_index);
51 ! number = STRLEN (t);
54 #if defined (ARRAY_VARS)
55 ! else if ((var = find_variable (name + 1)) && array_p (var))
57 t = array_reference (array_cell (var), 0);
58 ! number = STRLEN (t);
63 t = get_dollar_var_value (arg_index);
64 ! number = MB_STRLEN (t);
67 #if defined (ARRAY_VARS)
68 ! else if ((var = find_variable (name + 1)) && (invisible_p (var) == 0) && array_p (var))
70 t = array_reference (array_cell (var), 0);
71 ! number = MB_STRLEN (t);
78 ! number = STRLEN (t);
84 ! number = MB_STRLEN (t);
91 ! len = strlen (value);
97 ! len = MB_STRLEN (value);
100 *** ../bash-3.0/include/shmbutil.h Mon Apr 19 09:59:42 2004
101 --- include/shmbutil.h Thu Sep 2 15:20:47 2004
105 extern size_t xdupmbstowcs __P((wchar_t **, char ***, const char *));
107 + extern size_t mbstrlen __P((const char *));
109 extern char *xstrchr __P((const char *, int));
116 + #define MBSLEN(s) (((s) && (s)[0]) ? ((s)[1] ? mbstrlen (s) : 1) : 0)
117 + #define MB_STRLEN(s) ((MB_CUR_MAX > 1) ? MBSLEN (s) : STRLEN (s))
119 #else /* !HANDLE_MULTIBYTE */
124 #define MB_NULLWCH(x) (0)
127 + #define MB_STRLEN(s) (STRLEN(s))
129 #endif /* !HANDLE_MULTIBYTE */
131 *** ../bash-3.0/patchlevel.h Wed Aug 22 08:05:39 2001
132 --- patchlevel.h Thu Sep 2 15:04:32 2004
135 looks for to find the patch level (for the sccs version string). */
137 ! #define PATCHLEVEL 3
139 #endif /* _PATCHLEVEL_H_ */
141 looks for to find the patch level (for the sccs version string). */
143 ! #define PATCHLEVEL 4
145 #endif /* _PATCHLEVEL_H_ */