mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

726 lines
24 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/base/bash/bash3/to_patchlevel16.patch
  9. # ROCK Linux is Copyright (C) 1998 - 2005 Clifford Wolf
  10. #
  11. # This patch file is dual-licensed. It is available under the license the
  12. # patched project is licensed under, as long as it is an OpenSource license
  13. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  14. # of the GNU General Public License as published by the Free Software
  15. # Foundation; either version 2 of the License, or (at your option) any later
  16. # version.
  17. #
  18. # --- ROCK-COPYRIGHT-NOTE-END ---
  19. fixes a lot of bugs, please see:
  20. Patchlevel 1: http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00009.html
  21. Patchlevel 2: http://lists.gnu.org/archive/html/bug-bash/2004-07/msg00262.html
  22. Patchlevel 3: http://lists.gnu.org/archive/html/bug-bash/2004-07/msg00279.html
  23. Patchlevel 4: http://lists.gnu.org/archive/html/bug-bash/2004-07/msg00291.html
  24. Patchlevel 5: http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00004.html
  25. Patchlevel 6: http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00006.html
  26. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=257540
  27. Patchlevel 7: http://lists.gnu.org/archive/html/bug-bash/2004-07/msg00313.html
  28. http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00056.html
  29. Patchlevel 8: http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00144.html
  30. Patchlevel 9: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=129526b
  31. http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00116.html
  32. Patchlevel 10: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=261142
  33. Patchlevel 11: http://lists.gnu.org/archive/html/bug-bash/2004-07/msg00277.html
  34. Patchlevel 12: http://lists.gnu.org/archive/html/bug-bash/2004-08/msg00215.html
  35. Patchlevel 13: vi-mode filename completion/glob expansion should understand and perform tilde expansion.
  36. Patchlevel 14: http://lists.gnu.org/archive/html/bug-bash/2004-09/msg00250.html
  37. Patchlevel 15: http://lists.gnu.org/archive/html/bug-bash/2004-10/msg00297.html
  38. Patchlevel 16: http://lists.gnu.org/archive/html/bug-bash/2004-11/msg00017.html
  39. Parts taken from official patchlevel patches from bash developer team.
  40. Possible parts of the patch are integrated in the next release!
  41. --- bash-3.0-orig/array.c 2005-01-04 12:23:11.337526704 +0100
  42. +++ bash-3.0/array.c 2005-01-04 12:31:30.845589936 +0100
  43. @@ -451,7 +451,7 @@
  44. */
  45. array_dispose_element(new);
  46. free(element_value(ae));
  47. - ae->value = savestring(v);
  48. + ae->value = v ? savestring(v) : (char *)NULL;
  49. return(0);
  50. } else if (element_index(ae) > i) {
  51. ADD_BEFORE(ae, new);
  52. --- bash-3.0-orig/arrayfunc.c 2005-01-04 12:23:11.337526704 +0100
  53. +++ bash-3.0/arrayfunc.c 2005-01-04 12:25:24.082346424 +0100
  54. @@ -611,7 +611,7 @@
  55. var = find_variable (t);
  56. free (t);
  57. - return var;
  58. + return (var == 0 || invisible_p (var)) ? (SHELL_VAR *)0 : var;
  59. }
  60. /* Return a string containing the elements in the array and subscript
  61. --- bash-3.0-orig/bashline.c 2005-01-04 12:23:11.357523664 +0100
  62. +++ bash-3.0/bashline.c 2005-01-04 13:25:54.246477592 +0100
  63. @@ -100,6 +100,7 @@
  64. #endif
  65. /* Helper functions for Readline. */
  66. +static int bash_directory_expansion __P((char **));
  67. static int bash_directory_completion_hook __P((char **));
  68. static int filename_completion_ignore __P((char **));
  69. static int bash_push_line __P((void));
  70. @@ -292,7 +293,7 @@
  71. /* See if we have anything to do. */
  72. at = strchr (rl_completer_word_break_characters, '@');
  73. if ((at == 0 && on_or_off == 0) || (at != 0 && on_or_off != 0))
  74. - return;
  75. + return old_value;
  76. /* We have something to do. Do it. */
  77. nval = (char *)xmalloc (strlen (rl_completer_word_break_characters) + 1 + on_or_off);
  78. @@ -1406,10 +1407,19 @@
  79. filename. */
  80. if (*hint_text == '~')
  81. {
  82. - int l, tl, vl;
  83. + int l, tl, vl, dl;
  84. + char *rd;
  85. vl = strlen (val);
  86. tl = strlen (hint_text);
  87. +#if 0
  88. l = vl - hint_len; /* # of chars added */
  89. +#else
  90. + rd = savestring (filename_hint);
  91. + bash_directory_expansion (&rd);
  92. + dl = strlen (rd);
  93. + l = vl - dl; /* # of chars added */
  94. + free (rd);
  95. +#endif
  96. temp = (char *)xmalloc (l + 2 + tl);
  97. strcpy (temp, hint_text);
  98. strcpy (temp + tl, val + vl - l);
  99. @@ -2187,6 +2197,27 @@
  100. return 0;
  101. }
  102. +/* Simulate the expansions that will be performed by
  103. + rl_filename_completion_function. This must be called with the address of
  104. + a pointer to malloc'd memory. */
  105. +static int
  106. +bash_directory_expansion (dirname)
  107. + char **dirname;
  108. +{
  109. + char *d;
  110. +
  111. + d = savestring (*dirname);
  112. +
  113. + if (rl_directory_rewrite_hook)
  114. + (*rl_directory_rewrite_hook) (&d);
  115. +
  116. + if (rl_directory_completion_hook && (*rl_directory_completion_hook) (&d))
  117. + {
  118. + free (*dirname);
  119. + *dirname = d;
  120. + }
  121. +}
  122. +
  123. /* Handle symbolic link references and other directory name
  124. expansions while hacking completion. */
  125. static int
  126. @@ -2513,7 +2544,7 @@
  127. static char **matches = (char **)NULL;
  128. static int ind;
  129. int glen;
  130. - char *ret;
  131. + char *ret, *ttext;
  132. if (state == 0)
  133. {
  134. @@ -2523,18 +2554,23 @@
  135. FREE (globorig);
  136. FREE (globtext);
  137. + ttext = bash_tilde_expand (text, 0);
  138. +
  139. if (rl_explicit_arg)
  140. {
  141. - globorig = savestring (text);
  142. - glen = strlen (text);
  143. + globorig = savestring (ttext);
  144. + glen = strlen (ttext);
  145. globtext = (char *)xmalloc (glen + 2);
  146. - strcpy (globtext, text);
  147. + strcpy (globtext, ttext);
  148. globtext[glen] = '*';
  149. globtext[glen+1] = '\0';
  150. }
  151. else
  152. - globtext = globorig = savestring (text);
  153. + globtext = globorig = savestring (ttext);
  154. + if (ttext != text)
  155. + free (ttext);
  156. +
  157. matches = shell_glob_filename (globtext);
  158. if (GLOB_FAILED (matches))
  159. matches = (char **)NULL;
  160. --- bash-3.0-orig/braces.c 2005-01-04 12:23:11.358523512 +0100
  161. +++ bash-3.0/braces.c 2005-01-04 13:27:10.720851720 +0100
  162. @@ -340,8 +340,8 @@
  163. if (lhs_t == ST_CHAR)
  164. {
  165. - lhs_v = lhs[0];
  166. - rhs_v = rhs[0];
  167. + lhs_v = (unsigned char)lhs[0];
  168. + rhs_v = (unsigned char)rhs[0];
  169. }
  170. else
  171. {
  172. @@ -402,6 +402,8 @@
  173. {
  174. pass_next = 1;
  175. i++;
  176. + if (quoted == 0)
  177. + level++;
  178. continue;
  179. }
  180. #endif
  181. --- bash-3.0-orig/builtins/trap.def 2005-01-04 12:23:10.276687976 +0100
  182. +++ bash-3.0/builtins/trap.def 2005-01-04 12:38:46.960290424 +0100
  183. @@ -23,7 +23,7 @@
  184. $BUILTIN trap
  185. $FUNCTION trap_builtin
  186. -$SHORT_DOC trap [-lp] [[arg] signal_spec ...]
  187. +$SHORT_DOC trap [-lp] [arg signal_spec ...]
  188. The command ARG is to be read and executed when the shell receives
  189. signal(s) SIGNAL_SPEC. If ARG is absent (and a single SIGNAL_SPEC
  190. is supplied) or `-', each specified signal is reset to its original
  191. @@ -87,7 +87,7 @@
  192. trap_builtin (list)
  193. WORD_LIST *list;
  194. {
  195. - int list_signal_names, display, result, opt;
  196. + int list_signal_names, display, result, opt, first_signal;
  197. list_signal_names = display = 0;
  198. result = EXECUTION_SUCCESS;
  199. @@ -118,14 +118,19 @@
  200. else
  201. {
  202. char *first_arg;
  203. - int operation, sig;
  204. + int operation, sig, first_signal;
  205. operation = SET;
  206. first_arg = list->word->word;
  207. + first_signal = first_arg && *first_arg && all_digits (first_arg) && signal_object_p (first_arg, opt);
  208. +
  209. + /* Backwards compatibility */
  210. + if (first_signal)
  211. + operation = REVERT;
  212. /* When in posix mode, the historical behavior of looking for a
  213. missing first argument is disabled. To revert to the original
  214. signal handling disposition, use `-' as the first argument. */
  215. - if (posixly_correct == 0 && first_arg && *first_arg &&
  216. + else if (posixly_correct == 0 && first_arg && *first_arg &&
  217. (*first_arg != '-' || first_arg[1]) &&
  218. signal_object_p (first_arg, opt) && list->next == 0)
  219. operation = REVERT;
  220. --- bash-3.0-orig/doc/bashref.texi 2005-01-04 12:23:10.290685848 +0100
  221. +++ bash-3.0/doc/bashref.texi 2005-01-04 12:39:46.931173464 +0100
  222. @@ -5953,7 +5953,8 @@
  223. @item
  224. The @code{trap} builtin doesn't check the first argument for a possible
  225. signal specification and revert the signal handling to the original
  226. -disposition if it is. If users want to reset the handler for a given
  227. +disposition if it is, unless that argument consists solely of digits and
  228. +is a valid signal number. If users want to reset the handler for a given
  229. signal to the original disposition, they should use @samp{-} as the
  230. first argument.
  231. --- bash-3.0-orig/general.c 2005-01-04 12:23:11.338526552 +0100
  232. +++ bash-3.0/general.c 2005-01-04 13:28:15.205048632 +0100
  233. @@ -267,7 +267,7 @@
  234. c = string[indx = 0];
  235. #if defined (ARRAY_VARS)
  236. - if ((legal_variable_starter (c) == 0) && (flags && c != '[')) /* ] */
  237. + if ((legal_variable_starter (c) == 0) && (flags == 0 || c != '[')) /* ] */
  238. #else
  239. if (legal_variable_starter (c) == 0)
  240. #endif
  241. --- bash-3.0-orig/include/shmbutil.h 2005-01-04 12:23:10.605637968 +0100
  242. +++ bash-3.0/include/shmbutil.h 2005-01-04 12:48:35.821769872 +0100
  243. @@ -31,6 +31,8 @@
  244. extern size_t xmbsrtowcs __P((wchar_t *, const char **, size_t, mbstate_t *));
  245. extern size_t xdupmbstowcs __P((wchar_t **, char ***, const char *));
  246. +extern size_t mbstrlen __P((const char *));
  247. +
  248. extern char *xstrchr __P((const char *, int));
  249. #ifndef MB_INVALIDCH
  250. @@ -38,6 +40,9 @@
  251. #define MB_NULLWCH(x) ((x) == 0)
  252. #endif
  253. +#define MBSLEN(s) (((s) && (s)[0]) ? ((s)[1] ? mbstrlen (s) : 1) : 0)
  254. +#define MB_STRLEN(s) ((MB_CUR_MAX > 1) ? MBSLEN (s) : STRLEN (s))
  255. +
  256. #else /* !HANDLE_MULTIBYTE */
  257. #undef MB_LEN_MAX
  258. @@ -54,6 +59,8 @@
  259. #define MB_NULLWCH(x) (0)
  260. #endif
  261. +#define MB_STRLEN(s) (STRLEN(s))
  262. +
  263. #endif /* !HANDLE_MULTIBYTE */
  264. /* Declare and initialize a multibyte state. Call must be terminated
  265. --- bash-3.0-orig/jobs.c 2005-01-04 12:23:11.351524576 +0100
  266. +++ bash-3.0/jobs.c 2005-01-04 13:22:45.479174584 +0100
  267. @@ -1778,8 +1778,13 @@
  268. if (pipefail_opt)
  269. {
  270. fail = 0;
  271. - for (p = jobs[job]->pipe; p->next != jobs[job]->pipe; p = p->next)
  272. + p = jobs[job]->pipe;
  273. + do
  274. + {
  275. if (p->status != EXECUTION_SUCCESS) fail = p->status;
  276. + p = p->next;
  277. + }
  278. + while (p != jobs[job]->pipe);
  279. return fail;
  280. }
  281. --- bash-3.0-orig/lib/readline/display.c 2005-01-04 12:23:10.820605288 +0100
  282. +++ bash-3.0/lib/readline/display.c 2005-01-04 13:00:03.103287200 +0100
  283. @@ -201,7 +201,7 @@
  284. int *lp, *lip, *niflp, *vlp;
  285. {
  286. char *r, *ret, *p;
  287. - int l, rl, last, ignoring, ninvis, invfl, ind, pind, physchars;
  288. + int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars;
  289. /* Short-circuit if we can. */
  290. if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (pmt, RL_PROMPT_START_IGNORE) == 0)
  291. @@ -222,7 +222,8 @@
  292. r = ret = (char *)xmalloc (l + 1);
  293. invfl = 0; /* invisible chars in first line of prompt */
  294. -
  295. + invflset = 0; /* we only want to set invfl once */
  296. +
  297. for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++)
  298. {
  299. /* This code strips the invisible character string markers
  300. @@ -249,7 +250,10 @@
  301. while (l--)
  302. *r++ = *p++;
  303. if (!ignoring)
  304. - rl += ind - pind;
  305. + {
  306. + rl += ind - pind;
  307. + physchars += _rl_col_width (pmt, pind, ind);
  308. + }
  309. else
  310. ninvis += ind - pind;
  311. p--; /* compensate for later increment */
  312. @@ -259,16 +263,18 @@
  313. {
  314. *r++ = *p;
  315. if (!ignoring)
  316. - rl++; /* visible length byte counter */
  317. + {
  318. + rl++; /* visible length byte counter */
  319. + physchars++;
  320. + }
  321. else
  322. ninvis++; /* invisible chars byte counter */
  323. }
  324. -
  325. - if (rl >= _rl_screenwidth)
  326. - invfl = ninvis;
  327. -
  328. - if (ignoring == 0)
  329. - physchars++;
  330. + if (invflset == 0 && rl >= _rl_screenwidth)
  331. + {
  332. + invfl = ninvis;
  333. + invflset = 1;
  334. + }
  335. }
  336. }
  337. @@ -351,14 +357,14 @@
  338. local_prompt = expand_prompt (p, &prompt_visible_length,
  339. &prompt_last_invisible,
  340. (int *)NULL,
  341. - (int *)NULL);
  342. + &prompt_physical_chars);
  343. c = *t; *t = '\0';
  344. /* The portion of the prompt string up to and including the
  345. final newline is now null-terminated. */
  346. local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
  347. (int *)NULL,
  348. &prompt_invis_chars_first_line,
  349. - &prompt_physical_chars);
  350. + (int *)NULL);
  351. *t = c;
  352. return (prompt_prefix_length);
  353. }
  354. @@ -417,7 +423,7 @@
  355. register int in, out, c, linenum, cursor_linenum;
  356. register char *line;
  357. int c_pos, inv_botlin, lb_botlin, lb_linenum;
  358. - int newlines, lpos, temp, modmark;
  359. + int newlines, lpos, temp, modmark, n0, num;
  360. char *prompt_this_line;
  361. #if defined (HANDLE_MULTIBYTE)
  362. wchar_t wc;
  363. @@ -573,6 +579,7 @@
  364. #if defined (HANDLE_MULTIBYTE)
  365. memset (_rl_wrapped_line, 0, vis_lbsize);
  366. + num = 0;
  367. #endif
  368. /* prompt_invis_chars_first_line is the number of invisible characters in
  369. @@ -591,13 +598,32 @@
  370. probably too much work for the benefit gained. How many people have
  371. prompts that exceed two physical lines?
  372. Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
  373. +#if defined (HANDLE_MULTIBYTE)
  374. + n0 = num;
  375. + temp = local_prompt ? strlen (local_prompt) : 0;
  376. + while (num < temp)
  377. + {
  378. + if (_rl_col_width (local_prompt, n0, num) > _rl_screenwidth)
  379. + {
  380. + num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
  381. + break;
  382. + }
  383. + num++;
  384. + }
  385. + temp = num +
  386. +#else
  387. temp = ((newlines + 1) * _rl_screenwidth) +
  388. +#endif /* !HANDLE_MULTIBYTE */
  389. ((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line
  390. : ((newlines == 1) ? wrap_offset : 0))
  391. : ((newlines == 0) ? wrap_offset :0));
  392. inv_lbreaks[++newlines] = temp;
  393. +#if defined (HANDLE_MULTIBYTE)
  394. + lpos -= _rl_col_width (local_prompt, n0, num);
  395. +#else
  396. lpos -= _rl_screenwidth;
  397. +#endif
  398. }
  399. prompt_last_screen_line = newlines;
  400. --- bash-3.0-orig/lib/readline/mbutil.c 2005-01-04 12:23:10.823604832 +0100
  401. +++ bash-3.0/lib/readline/mbutil.c 2005-01-04 13:21:07.436079400 +0100
  402. @@ -126,11 +126,11 @@
  403. if (find_non_zero)
  404. {
  405. tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
  406. - while (wcwidth (wc) == 0)
  407. + while (tmp > 0 && wcwidth (wc) == 0)
  408. {
  409. point += tmp;
  410. tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
  411. - if (tmp == (size_t)(0) || tmp == (size_t)(-1) || tmp == (size_t)(-2))
  412. + if (MB_NULLWCH (tmp) || MB_INVALIDCH (tmp))
  413. break;
  414. }
  415. }
  416. --- bash-3.0-orig/lib/readline/misc.c 2005-01-04 12:23:10.825604528 +0100
  417. +++ bash-3.0/lib/readline/misc.c 2005-01-04 12:50:07.070897896 +0100
  418. @@ -276,12 +276,6 @@
  419. _rl_saved_line_for_history->line = savestring (rl_line_buffer);
  420. _rl_saved_line_for_history->data = (char *)rl_undo_list;
  421. }
  422. - else if (STREQ (rl_line_buffer, _rl_saved_line_for_history->line) == 0)
  423. - {
  424. - free (_rl_saved_line_for_history->line);
  425. - _rl_saved_line_for_history->line = savestring (rl_line_buffer);
  426. - _rl_saved_line_for_history->data = (char *)rl_undo_list; /* XXX possible memleak */
  427. - }
  428. return 0;
  429. }
  430. --- bash-3.0-orig/lib/readline/vi_mode.c 2005-01-04 12:23:10.813606352 +0100
  431. +++ bash-3.0/lib/readline/vi_mode.c 2005-01-04 13:14:17.382417032 +0100
  432. @@ -272,10 +272,12 @@
  433. switch (key)
  434. {
  435. case '?':
  436. + _rl_free_saved_history_line ();
  437. rl_noninc_forward_search (count, key);
  438. break;
  439. case '/':
  440. + _rl_free_saved_history_line ();
  441. rl_noninc_reverse_search (count, key);
  442. break;
  443. @@ -690,7 +692,7 @@
  444. {
  445. wchar_t wc;
  446. char mb[MB_LEN_MAX+1];
  447. - int mblen;
  448. + int mblen, p;
  449. mbstate_t ps;
  450. memset (&ps, 0, sizeof (mbstate_t));
  451. @@ -713,11 +715,14 @@
  452. /* Vi is kind of strange here. */
  453. if (wc)
  454. {
  455. + p = rl_point;
  456. mblen = wcrtomb (mb, wc, &ps);
  457. if (mblen >= 0)
  458. mb[mblen] = '\0';
  459. rl_begin_undo_group ();
  460. - rl_delete (1, 0);
  461. + rl_vi_delete (1, 0);
  462. + if (rl_point < p) /* Did we retreat at EOL? */
  463. + rl_point++; /* XXX - should we advance more than 1 for mbchar? */
  464. rl_insert_text (mb);
  465. rl_end_undo_group ();
  466. rl_vi_check ();
  467. @@ -1310,12 +1315,16 @@
  468. rl_vi_delete (1, c);
  469. #if defined (HANDLE_MULTIBYTE)
  470. if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
  471. - while (_rl_insert_char (1, c))
  472. - {
  473. - RL_SETSTATE (RL_STATE_MOREINPUT);
  474. - c = rl_read_key ();
  475. - RL_UNSETSTATE (RL_STATE_MOREINPUT);
  476. - }
  477. + {
  478. + if (rl_point < p) /* Did we retreat at EOL? */
  479. + rl_point++;
  480. + while (_rl_insert_char (1, c))
  481. + {
  482. + RL_SETSTATE (RL_STATE_MOREINPUT);
  483. + c = rl_read_key ();
  484. + RL_UNSETSTATE (RL_STATE_MOREINPUT);
  485. + }
  486. + }
  487. else
  488. #endif
  489. {
  490. --- bash-3.0-orig/patchlevel.h 2005-01-04 12:23:11.361523056 +0100
  491. +++ bash-3.0/patchlevel.h 2005-01-04 13:31:32.114113904 +0100
  492. @@ -25,6 +25,6 @@
  493. regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
  494. looks for to find the patch level (for the sccs version string). */
  495. -#define PATCHLEVEL 0
  496. +#define PATCHLEVEL 16
  497. #endif /* _PATCHLEVEL_H_ */
  498. --- bash-3.0-orig/pcomplete.c 2005-01-04 12:23:11.360523208 +0100
  499. +++ bash-3.0/pcomplete.c 2005-01-04 12:30:21.767091464 +0100
  500. @@ -863,6 +863,8 @@
  501. if (array_p (v) == 0)
  502. v = convert_var_to_array (v);
  503. v = assign_array_var_from_word_list (v, lwords);
  504. +
  505. + VUNSETATTR (v, att_invisible);
  506. return v;
  507. }
  508. #endif /* ARRAY_VARS */
  509. @@ -1022,6 +1024,7 @@
  510. if (array_p (v) == 0)
  511. v = convert_var_to_array (v);
  512. + VUNSETATTR (v, att_invisible);
  513. a = array_cell (v);
  514. if (a == 0 || array_empty (a))
  515. sl = (STRINGLIST *)NULL;
  516. --- bash-3.0-orig/subst.c 2005-01-04 12:23:11.348525032 +0100
  517. +++ bash-3.0/subst.c 2005-01-04 13:29:51.064475784 +0100
  518. @@ -4691,6 +4691,26 @@
  519. legal_identifier (name + 1)); /* ${#PS1} */
  520. }
  521. +#if defined (HANDLE_MULTIBYTE)
  522. +size_t
  523. +mbstrlen (s)
  524. + const char *s;
  525. +{
  526. + size_t clen, nc;
  527. + mbstate_t mbs;
  528. +
  529. + nc = 0;
  530. + memset (&mbs, 0, sizeof (mbs));
  531. + while ((clen = mbrlen(s, MB_CUR_MAX, &mbs)) != 0 && (MB_INVALIDCH(clen) == 0))
  532. + {
  533. + s += clen;
  534. + nc++;
  535. + }
  536. + return nc;
  537. +}
  538. +#endif
  539. +
  540. +
  541. /* Handle the parameter brace expansion that requires us to return the
  542. length of a parameter. */
  543. static intmax_t
  544. @@ -4746,14 +4766,14 @@
  545. if (legal_number (name + 1, &arg_index)) /* ${#1} */
  546. {
  547. t = get_dollar_var_value (arg_index);
  548. - number = STRLEN (t);
  549. + number = MB_STRLEN (t);
  550. FREE (t);
  551. }
  552. #if defined (ARRAY_VARS)
  553. - else if ((var = find_variable (name + 1)) && array_p (var))
  554. + else if ((var = find_variable (name + 1)) && (invisible_p (var) == 0) && array_p (var))
  555. {
  556. t = array_reference (array_cell (var), 0);
  557. - number = STRLEN (t);
  558. + number = MB_STRLEN (t);
  559. }
  560. #endif
  561. else /* ${#PS1} */
  562. @@ -4766,7 +4786,7 @@
  563. if (list)
  564. dispose_words (list);
  565. - number = STRLEN (t);
  566. + number = MB_STRLEN (t);
  567. FREE (t);
  568. }
  569. }
  570. @@ -4871,7 +4891,7 @@
  571. {
  572. case VT_VARIABLE:
  573. case VT_ARRAYMEMBER:
  574. - len = strlen (value);
  575. + len = MB_STRLEN (value);
  576. break;
  577. case VT_POSPARMS:
  578. len = number_of_args () + 1;
  579. @@ -4879,8 +4899,9 @@
  580. #if defined (ARRAY_VARS)
  581. case VT_ARRAYVAR:
  582. a = (ARRAY *)value;
  583. - /* For arrays, the first value deals with array indices. */
  584. - len = array_max_index (a); /* arrays index from 0 to n - 1 */
  585. + /* For arrays, the first value deals with array indices. Negative
  586. + offsets count from one past the array's maximum index. */
  587. + len = array_max_index (a) + (*e1p < 0); /* arrays index from 0 to n - 1 */
  588. break;
  589. #endif
  590. }
  591. @@ -4891,7 +4912,7 @@
  592. if (*e1p < 0) /* negative offsets count from end */
  593. *e1p += len;
  594. - if (*e1p >= len || *e1p < 0)
  595. + if (*e1p > len || *e1p < 0)
  596. return (-1);
  597. #if defined (ARRAY_VARS)
  598. @@ -4982,7 +5003,7 @@
  599. else
  600. return -1;
  601. }
  602. - else if ((v = find_variable (varname)) && array_p (v))
  603. + else if ((v = find_variable (varname)) && (invisible_p (v) == 0) && array_p (v))
  604. {
  605. vtype = VT_ARRAYMEMBER;
  606. *varp = v;
  607. --- bash-3.0-orig/tests/array.right 2005-01-04 12:23:11.026573976 +0100
  608. +++ bash-3.0/tests/array.right 2005-01-04 13:31:27.167865848 +0100
  609. @@ -170,8 +170,8 @@
  610. three five seven
  611. positive offset - expect five seven
  612. five seven
  613. -negative offset - expect five seven
  614. -five seven
  615. +negative offset to unset element - expect seven
  616. +seven
  617. positive offset 2 - expect seven
  618. seven
  619. negative offset 2 - expect seven
  620. --- bash-3.0-orig/tests/array.tests 2005-01-04 12:23:11.025574128 +0100
  621. +++ bash-3.0/tests/array.tests 2005-01-04 13:30:51.267323560 +0100
  622. @@ -322,7 +322,7 @@
  623. echo positive offset - expect five seven
  624. echo ${av[@]:5:2}
  625. -echo negative offset - expect five seven
  626. +echo negative offset to unset element - expect seven
  627. echo ${av[@]: -2:2}
  628. echo positive offset 2 - expect seven
  629. --- bash-3.0-orig/tests/dbg-support.tests 2005-01-04 12:23:11.031573216 +0100
  630. +++ bash-3.0/tests/dbg-support.tests 2005-01-04 12:32:39.778110600 +0100
  631. @@ -62,8 +62,8 @@
  632. trap 'print_debug_trap $LINENO' DEBUG
  633. trap 'print_return_trap $LINENO' RETURN
  634. -# Funcname is now an array. Vanilla Bash 2.05 doesn't have FUNCNAME array.
  635. -echo "FUNCNAME" ${FUNCNAME[0]}
  636. +# Funcname is now an array, but you still can't see it outside a function
  637. +echo "FUNCNAME" ${FUNCNAME[0]:-main}
  638. # We should trace into the below.
  639. # Start easy with a simple function.
  640. --- bash-3.0-orig/tests/errors.right 2005-01-04 12:23:11.035572608 +0100
  641. +++ bash-3.0/tests/errors.right 2005-01-04 12:40:37.086548688 +0100
  642. @@ -85,7 +85,7 @@
  643. ./errors.tests: line 213: /bin/sh + 0: syntax error: operand expected (error token is "/bin/sh + 0")
  644. ./errors.tests: line 216: trap: NOSIG: invalid signal specification
  645. ./errors.tests: line 219: trap: -s: invalid option
  646. -trap: usage: trap [-lp] [[arg] signal_spec ...]
  647. +trap: usage: trap [-lp] [arg signal_spec ...]
  648. ./errors.tests: line 225: return: can only `return' from a function or sourced script
  649. ./errors.tests: line 229: break: 0: loop count out of range
  650. ./errors.tests: line 233: continue: 0: loop count out of range
  651. --- bash-3.0-orig/variables.c 2005-01-04 12:23:11.341526096 +0100
  652. +++ bash-3.0/variables.c 2005-01-04 12:28:38.607774064 +0100
  653. @@ -1419,11 +1419,11 @@
  654. v = init_dynamic_array_var ("GROUPS", get_groupset, null_array_assign, att_noassign);
  655. # if defined (DEBUGGER)
  656. - v = init_dynamic_array_var ("BASH_ARGC", get_self, null_array_assign, (att_invisible|att_noassign));
  657. - v = init_dynamic_array_var ("BASH_ARGV", get_self, null_array_assign, (att_invisible|att_noassign));
  658. + v = init_dynamic_array_var ("BASH_ARGC", get_self, null_array_assign, att_noassign);
  659. + v = init_dynamic_array_var ("BASH_ARGV", get_self, null_array_assign, att_noassign);
  660. # endif /* DEBUGGER */
  661. - v = init_dynamic_array_var ("BASH_SOURCE", get_self, null_array_assign, (att_invisible|att_noassign));
  662. - v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, (att_invisible|att_noassign));
  663. + v = init_dynamic_array_var ("BASH_SOURCE", get_self, null_array_assign, att_noassign);
  664. + v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, att_noassign);
  665. #endif
  666. v = init_funcname_var ();
  667. @@ -1599,7 +1599,10 @@
  668. /* local foo; local foo; is a no-op. */
  669. old_var = find_variable (name);
  670. if (old_var && local_p (old_var) && old_var->context == variable_context)
  671. - return (old_var);
  672. + {
  673. + VUNSETATTR (old_var, att_invisible);
  674. + return (old_var);
  675. + }
  676. was_tmpvar = old_var && tempvar_p (old_var);
  677. if (was_tmpvar)