Author: bdubbs Date: Fri Apr 18 14:19:55 2014 New Revision: 2874 Log: Upstream fixes for bash/readline
Added: trunk/bash/bash-4.3-upstream_fixes-1.patch trunk/readline/readline-6.3-upstream_fixes-1.patch Added: trunk/bash/bash-4.3-upstream_fixes-1.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/bash/bash-4.3-upstream_fixes-1.patch Fri Apr 18 14:19:55 2014 (r2874) @@ -0,0 +1,393 @@ +Submitted By: Bruce Dubbs <bdubbs_at_linuxfromscratch_dot_org> +Date: 2014-04-18 +Initial Package Version: 4.3 +Upstream Status: Already in upstream patch repo +Origin: Upstream +Description: This patch contains upstream patch numbers 001 thru 011. + +diff -Naur bash-4.3/arrayfunc.c bash-4.3.patched/arrayfunc.c +--- bash-4.3/arrayfunc.c 2013-08-02 15:19:59.000000000 -0500 ++++ bash-4.3.patched/arrayfunc.c 2014-04-18 13:57:54.084650326 -0500 +@@ -597,6 +597,11 @@ + if (assoc_p (var)) + { + val = expand_assignment_string_to_string (val, 0); ++ if (val == 0) ++ { ++ val = (char *)xmalloc (1); ++ val[0] = '\0'; /* like do_assignment_internal */ ++ } + free_val = 1; + } + +diff -Naur bash-4.3/externs.h bash-4.3.patched/externs.h +--- bash-4.3/externs.h 2014-01-02 13:58:20.000000000 -0600 ++++ bash-4.3.patched/externs.h 2014-04-18 13:57:54.090650249 -0500 +@@ -324,6 +324,7 @@ + extern char *sh_backslash_quote __P((char *, const char *, int)); + extern char *sh_backslash_quote_for_double_quotes __P((char *)); + extern int sh_contains_shell_metas __P((char *)); ++extern int sh_contains_quotes __P((char *)); + + /* declarations for functions defined in lib/sh/spell.c */ + extern int spname __P((char *, char *)); +diff -Naur bash-4.3/jobs.c bash-4.3.patched/jobs.c +--- bash-4.3/jobs.c 2014-01-10 08:05:34.000000000 -0600 ++++ bash-4.3.patched/jobs.c 2014-04-18 13:57:54.083650339 -0500 +@@ -4374,7 +4374,7 @@ + void + end_job_control () + { +- if (interactive_shell) /* XXX - should it be interactive? */ ++ if (interactive_shell || job_control) /* XXX - should it be just job_control? */ + { + terminate_stopped_jobs (); + +diff -Naur bash-4.3/lib/glob/glob.c bash-4.3.patched/lib/glob/glob.c +--- bash-4.3/lib/glob/glob.c 2014-01-31 20:43:51.000000000 -0600 ++++ bash-4.3.patched/lib/glob/glob.c 2014-04-18 13:57:54.085650313 -0500 +@@ -179,42 +179,50 @@ + char *pat, *dname; + int flags; + { +- char *pp, *pe, *t; +- int n, r; ++ char *pp, *pe, *t, *se; ++ int n, r, negate; + ++ negate = *pat == '!'; + pp = pat + 2; +- pe = pp + strlen (pp) - 1; /*(*/ +- if (*pe != ')') +- return 0; +- if ((t = strchr (pp, '|')) == 0) /* easy case first */ ++ se = pp + strlen (pp) - 1; /* end of string */ ++ pe = glob_patscan (pp, se, 0); /* end of extglob pattern (( */ ++ /* we should check for invalid extglob pattern here */ ++ /* if pe != se we have more of the pattern at the end of the extglob ++ pattern. Check the easy case first ( */ ++ if (pe == se && *pe == ')' && (t = strchr (pp, '|')) == 0) + { + *pe = '\0'; ++#if defined (HANDLE_MULTIBYTE) ++ r = mbskipname (pp, dname, flags); ++#else + r = skipname (pp, dname, flags); /*(*/ ++#endif + *pe = ')'; + return r; + } ++ ++ /* check every subpattern */ + while (t = glob_patscan (pp, pe, '|')) + { + n = t[-1]; + t[-1] = '\0'; ++#if defined (HANDLE_MULTIBYTE) ++ r = mbskipname (pp, dname, flags); ++#else + r = skipname (pp, dname, flags); ++#endif + t[-1] = n; + if (r == 0) /* if any pattern says not skip, we don't skip */ + return r; + pp = t; + } /*(*/ + +- if (pp == pe) /* glob_patscan might find end of pattern */ ++ /* glob_patscan might find end of pattern */ ++ if (pp == se) + return r; + +- *pe = '\0'; +-# if defined (HANDLE_MULTIBYTE) +- r = mbskipname (pp, dname, flags); /*(*/ +-# else +- r = skipname (pp, dname, flags); /*(*/ +-# endif +- *pe = ')'; +- return r; ++ /* but if it doesn't then we didn't match a leading dot */ ++ return 0; + } + #endif + +@@ -277,20 +285,23 @@ + int flags; + { + #if EXTENDED_GLOB +- wchar_t *pp, *pe, *t, n; +- int r; ++ wchar_t *pp, *pe, *t, n, *se; ++ int r, negate; + ++ negate = *pat == L'!'; + pp = pat + 2; +- pe = pp + wcslen (pp) - 1; /*(*/ +- if (*pe != L')') +- return 0; +- if ((t = wcschr (pp, L'|')) == 0) ++ se = pp + wcslen (pp) - 1; /*(*/ ++ pe = glob_patscan_wc (pp, se, 0); ++ ++ if (pe == se && *pe == ')' && (t = wcschr (pp, L'|')) == 0) + { + *pe = L'\0'; + r = wchkname (pp, dname); /*(*/ + *pe = L')'; + return r; + } ++ ++ /* check every subpattern */ + while (t = glob_patscan_wc (pp, pe, '|')) + { + n = t[-1]; +@@ -305,10 +316,8 @@ + if (pp == pe) /* glob_patscan_wc might find end of pattern */ + return r; + +- *pe = L'\0'; +- r = wchkname (pp, dname); /*(*/ +- *pe = L')'; +- return r; ++ /* but if it doesn't then we didn't match a leading dot */ ++ return 0; + #else + return (wchkname (pat, dname)); + #endif +diff -Naur bash-4.3/lib/glob/gmisc.c bash-4.3.patched/lib/glob/gmisc.c +--- bash-4.3/lib/glob/gmisc.c 2013-10-28 13:45:25.000000000 -0500 ++++ bash-4.3.patched/lib/glob/gmisc.c 2014-04-18 13:57:54.085650313 -0500 +@@ -210,6 +210,7 @@ + case '+': + case '!': + case '@': ++ case '?': + return (pat[1] == LPAREN); + default: + return 0; +diff -Naur bash-4.3/lib/readline/display.c bash-4.3.patched/lib/readline/display.c +--- bash-4.3/lib/readline/display.c 2013-12-27 12:10:56.000000000 -0600 ++++ bash-4.3.patched/lib/readline/display.c 2014-04-18 13:57:54.092650223 -0500 +@@ -2677,7 +2677,8 @@ + { + if (_rl_echoing_p) + { +- _rl_move_vert (_rl_vis_botlin); ++ if (_rl_vis_botlin > 0) /* minor optimization plus bug fix */ ++ _rl_move_vert (_rl_vis_botlin); + _rl_vis_botlin = 0; + fflush (rl_outstream); + rl_restart_output (1, 0); +diff -Naur bash-4.3/lib/readline/readline.c bash-4.3.patched/lib/readline/readline.c +--- bash-4.3/lib/readline/readline.c 2013-10-28 13:58:06.000000000 -0500 ++++ bash-4.3.patched/lib/readline/readline.c 2014-04-18 13:57:54.078650404 -0500 +@@ -744,7 +744,8 @@ + r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ)); + + RL_CHECK_SIGNALS (); +- if (r == 0) /* success! */ ++ /* We only treat values < 0 specially to simulate recursion. */ ++ if (r >= 0 || (r == -1 && (cxt->flags & KSEQ_SUBSEQ) == 0)) /* success! or failure! */ + { + _rl_keyseq_chain_dispose (); + RL_UNSETSTATE (RL_STATE_MULTIKEY); +@@ -964,7 +965,7 @@ + #if defined (VI_MODE) + if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap && + key != ANYOTHERKEY && +- rl_key_sequence_length == 1 && /* XXX */ ++ _rl_dispatching_keymap == vi_movement_keymap && + _rl_vi_textmod_command (key)) + _rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign); + #endif +diff -Naur bash-4.3/lib/sh/shquote.c bash-4.3.patched/lib/sh/shquote.c +--- bash-4.3/lib/sh/shquote.c 2013-03-31 20:53:32.000000000 -0500 ++++ bash-4.3.patched/lib/sh/shquote.c 2014-04-18 13:57:54.090650249 -0500 +@@ -311,3 +311,17 @@ + + return (0); + } ++ ++int ++sh_contains_quotes (string) ++ char *string; ++{ ++ char *s; ++ ++ for (s = string; s && *s; s++) ++ { ++ if (*s == '\'' || *s == '"' || *s == '\\') ++ return 1; ++ } ++ return 0; ++} +diff -Naur bash-4.3/parse.y bash-4.3.patched/parse.y +--- bash-4.3/parse.y 2014-02-11 08:42:10.000000000 -0600 ++++ bash-4.3.patched/parse.y 2014-04-18 13:57:54.087650287 -0500 +@@ -2424,7 +2424,7 @@ + not already end in an EOF character. */ + if (shell_input_line_terminator != EOF) + { +- if (shell_input_line_size < SIZE_MAX && shell_input_line_len > shell_input_line_size - 3) ++ if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size)) + shell_input_line = (char *)xrealloc (shell_input_line, + 1 + (shell_input_line_size += 2)); + +@@ -3398,7 +3398,7 @@ + within a double-quoted ${...} construct "an even number of + unescaped double-quotes or single-quotes, if any, shall occur." */ + /* This was changed in Austin Group Interp 221 */ +- if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'') ++ if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && dolbrace_state != DOLBRACE_QUOTE2 && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'') + continue; + + /* Could also check open == '`' if we want to parse grouping constructs +diff -Naur bash-4.3/patchlevel.h bash-4.3.patched/patchlevel.h +--- bash-4.3/patchlevel.h 2012-12-29 09:47:57.000000000 -0600 ++++ bash-4.3.patched/patchlevel.h 2014-04-18 13:57:54.092650223 -0500 +@@ -25,6 +25,6 @@ + regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh + looks for to find the patch level (for the sccs version string). */ + +-#define PATCHLEVEL 0 ++#define PATCHLEVEL 11 + + #endif /* _PATCHLEVEL_H_ */ +diff -Naur bash-4.3/pcomplete.c bash-4.3.patched/pcomplete.c +--- bash-4.3/pcomplete.c 2013-08-26 14:23:45.000000000 -0500 ++++ bash-4.3.patched/pcomplete.c 2014-04-18 13:57:54.091650236 -0500 +@@ -183,6 +183,7 @@ + + COMPSPEC *pcomp_curcs; + const char *pcomp_curcmd; ++const char *pcomp_curtxt; + + #ifdef DEBUG + /* Debugging code */ +@@ -753,6 +754,32 @@ + quoted strings. */ + dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character); + } ++ /* Intended to solve a mismatched assumption by bash-completion. If ++ the text to be completed is empty, but bash-completion turns it into ++ a quoted string ('') assuming that this code will dequote it before ++ calling readline, do the dequoting. */ ++ else if (iscompgen && iscompleting && ++ pcomp_curtxt && *pcomp_curtxt == 0 && ++ text && (*text == '\'' || *text == '"') && text[1] == text[0] && text[2] == 0 && ++ rl_filename_dequoting_function) ++ dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character); ++ /* Another mismatched assumption by bash-completion. If compgen is being ++ run as part of bash-completion, and the argument to compgen is not ++ the same as the word originally passed to the programmable completion ++ code, dequote the argument if it has quote characters. It's an ++ attempt to detect when bash-completion is quoting its filename ++ argument before calling compgen. */ ++ /* We could check whether gen_shell_function_matches is in the call ++ stack by checking whether the gen-shell-function-matches tag is in ++ the unwind-protect stack, but there's no function to do that yet. ++ We could simply check whether we're executing in a function by ++ checking variable_context, and may end up doing that. */ ++ else if (iscompgen && iscompleting && rl_filename_dequoting_function && ++ pcomp_curtxt && text && ++ STREQ (pcomp_curtxt, text) == 0 && ++ variable_context && ++ sh_contains_quotes (text)) /* guess */ ++ dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character); + else + dfn = savestring (text); + } +@@ -1522,7 +1549,7 @@ + COMPSPEC **lastcs; + { + COMPSPEC *cs, *oldcs; +- const char *oldcmd; ++ const char *oldcmd, *oldtxt; + STRINGLIST *ret; + + cs = progcomp_search (ocmd); +@@ -1545,14 +1572,17 @@ + + oldcs = pcomp_curcs; + oldcmd = pcomp_curcmd; ++ oldtxt = pcomp_curtxt; + + pcomp_curcs = cs; + pcomp_curcmd = cmd; ++ pcomp_curtxt = word; + + ret = gen_compspec_completions (cs, cmd, word, start, end, foundp); + + pcomp_curcs = oldcs; + pcomp_curcmd = oldcmd; ++ pcomp_curtxt = oldtxt; + + /* We need to conditionally handle setting *retryp here */ + if (retryp) +diff -Naur bash-4.3/test.c bash-4.3.patched/test.c +--- bash-4.3/test.c 2014-02-04 15:52:58.000000000 -0600 ++++ bash-4.3.patched/test.c 2014-04-18 13:57:54.074650455 -0500 +@@ -646,8 +646,8 @@ + return (v && invisible_p (v) == 0 && var_isset (v) ? TRUE : FALSE); + + case 'R': +- v = find_variable (arg); +- return (v && invisible_p (v) == 0 && var_isset (v) && nameref_p (v) ? TRUE : FALSE); ++ v = find_variable_noref (arg); ++ return ((v && invisible_p (v) == 0 && var_isset (v) && nameref_p (v)) ? TRUE : FALSE); + } + + /* We can't actually get here, but this shuts up gcc. */ +@@ -723,6 +723,7 @@ + case 'o': case 'p': case 'r': case 's': case 't': + case 'u': case 'v': case 'w': case 'x': case 'z': + case 'G': case 'L': case 'O': case 'S': case 'N': ++ case 'R': + return (1); + } + +diff -Naur bash-4.3/trap.c bash-4.3.patched/trap.c +--- bash-4.3/trap.c 2014-02-05 09:03:21.000000000 -0600 ++++ bash-4.3.patched/trap.c 2014-04-18 13:57:54.075650442 -0500 +@@ -920,7 +920,8 @@ + subst_assign_varlist = 0; + + #if defined (JOB_CONTROL) +- save_pipeline (1); /* XXX only provides one save level */ ++ if (sig != DEBUG_TRAP) /* run_debug_trap does this */ ++ save_pipeline (1); /* XXX only provides one save level */ + #endif + + /* If we're in a function, make sure return longjmps come here, too. */ +@@ -940,7 +941,8 @@ + trap_exit_value = last_command_exit_value; + + #if defined (JOB_CONTROL) +- restore_pipeline (1); ++ if (sig != DEBUG_TRAP) /* run_debug_trap does this */ ++ restore_pipeline (1); + #endif + + subst_assign_varlist = save_subst_varlist; +diff -Naur bash-4.3/y.tab.c bash-4.3.patched/y.tab.c +--- bash-4.3/y.tab.c 2014-02-11 09:57:47.000000000 -0600 ++++ bash-4.3.patched/y.tab.c 2014-04-18 13:57:54.089650262 -0500 +@@ -4736,7 +4736,7 @@ + not already end in an EOF character. */ + if (shell_input_line_terminator != EOF) + { +- if (shell_input_line_size < SIZE_MAX && shell_input_line_len > shell_input_line_size - 3) ++ if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size)) + shell_input_line = (char *)xrealloc (shell_input_line, + 1 + (shell_input_line_size += 2)); + +@@ -5710,7 +5710,7 @@ + within a double-quoted ${...} construct "an even number of + unescaped double-quotes or single-quotes, if any, shall occur." */ + /* This was changed in Austin Group Interp 221 */ +- if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'') ++ if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && dolbrace_state != DOLBRACE_QUOTE2 && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'') + continue; + + /* Could also check open == '`' if we want to parse grouping constructs Added: trunk/readline/readline-6.3-upstream_fixes-1.patch ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/readline/readline-6.3-upstream_fixes-1.patch Fri Apr 18 14:19:55 2014 (r2874) @@ -0,0 +1,90 @@ +Submitted By: Bruce Dubbs <bdubbs_at_linuxfromscratch_dot_org> +Date: 2014-04-18 +Initial Package Version: 6.3 +Upstream Status: Already in upstream patch repo +Origin: Upstream +Description: This patch contains upstream patch numbers 001 through 005. + +diff -Naur readline-6.3/display.c readline-6.3.patched/display.c +--- readline-6.3/display.c 2013-12-27 12:10:56.000000000 -0600 ++++ readline-6.3.patched/display.c 2014-04-18 15:51:38.249945858 -0500 +@@ -2677,7 +2677,8 @@ + { + if (_rl_echoing_p) + { +- _rl_move_vert (_rl_vis_botlin); ++ if (_rl_vis_botlin > 0) /* minor optimization plus bug fix */ ++ _rl_move_vert (_rl_vis_botlin); + _rl_vis_botlin = 0; + fflush (rl_outstream); + rl_restart_output (1, 0); +diff -Naur readline-6.3/readline.c readline-6.3.patched/readline.c +--- readline-6.3/readline.c 2013-10-28 13:58:06.000000000 -0500 ++++ readline-6.3.patched/readline.c 2014-04-18 15:51:38.247945883 -0500 +@@ -744,7 +744,8 @@ + r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ)); + + RL_CHECK_SIGNALS (); +- if (r == 0) /* success! */ ++ /* We only treat values < 0 specially to simulate recursion. */ ++ if (r >= 0 || (r == -1 && (cxt->flags & KSEQ_SUBSEQ) == 0)) /* success! or failure! */ + { + _rl_keyseq_chain_dispose (); + RL_UNSETSTATE (RL_STATE_MULTIKEY); +@@ -964,7 +965,7 @@ + #if defined (VI_MODE) + if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap && + key != ANYOTHERKEY && +- rl_key_sequence_length == 1 && /* XXX */ ++ _rl_dispatching_keymap == vi_movement_keymap && + _rl_vi_textmod_command (key)) + _rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign); + #endif +diff -Naur readline-6.3/rltypedefs.h readline-6.3.patched/rltypedefs.h +--- readline-6.3/rltypedefs.h 2011-03-26 13:53:31.000000000 -0500 ++++ readline-6.3.patched/rltypedefs.h 2014-04-18 15:51:38.250945845 -0500 +@@ -26,6 +26,25 @@ + extern "C" { + #endif + ++/* Old-style, attempt to mark as deprecated in some way people will notice. */ ++ ++#if !defined (_FUNCTION_DEF) ++# define _FUNCTION_DEF ++ ++#if defined(__GNUC__) || defined(__clang__) ++typedef int Function () __attribute__ ((deprecated)); ++typedef void VFunction () __attribute__ ((deprecated)); ++typedef char *CPFunction () __attribute__ ((deprecated)); ++typedef char **CPPFunction () __attribute__ ((deprecated)); ++#else ++typedef int Function (); ++typedef void VFunction (); ++typedef char *CPFunction (); ++typedef char **CPPFunction (); ++#endif ++ ++#endif /* _FUNCTION_DEF */ ++ + /* New style. */ + + #if !defined (_RL_FUNCTION_TYPEDEF) +diff -Naur readline-6.3/util.c readline-6.3.patched/util.c +--- readline-6.3/util.c 2013-09-02 12:36:12.000000000 -0500 ++++ readline-6.3.patched/util.c 2014-04-18 15:51:38.248945871 -0500 +@@ -476,6 +476,7 @@ + return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s))); + } + ++#if defined (DEBUG) + #if defined (USE_VARARGS) + static FILE *_rl_tracefp; + +@@ -538,6 +539,7 @@ + _rl_tracefp = fp; + } + #endif ++#endif /* DEBUG */ + + + #if HAVE_DECL_AUDIT_USER_TTY && defined (ENABLE_TTY_AUDIT_SUPPORT) -- http://linuxfromscratch.org/mailman/listinfo/patches FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page