source: patches/bash-4.3-branch_update-3.patch@ 54ef248

clfs-3.0.0-sysvinit sysvinit
Last change on this file since 54ef248 was b7f8179, checked in by William Harrington <kb0iic@…>, 11 years ago

Replace bash 4.3 level 11 patch with level 18 patch.

  • Property mode set to 100644
File size: 59.6 KB
  • arrayfunc.c

    Submitted By: William Harrington (kb0iic at cross-lfs dot org)
    Date: 05-17-2014
    Initial Package Version: 4.3
    Origin: Upstream
    Upstream Status: Applied
    Description: Contains all upstream patches up to 4.3-018
    
    diff -Naur bash-4.3.orig/arrayfunc.c bash-4.3/arrayfunc.c
    old new  
    179179    array_insert (array_cell (entry), ind, newval);
    180180  FREE (newval);
    181181
     182  VUNSETATTR (entry, att_invisible);    /* no longer invisible */
    182183  return (entry);
    183184}
    184185
     
    597598      if (assoc_p (var))
    598599        {
    599600          val = expand_assignment_string_to_string (val, 0);
     601          if (val == 0)
     602            {
     603              val = (char *)xmalloc (1);
     604              val[0] = '\0';    /* like do_assignment_internal */
     605            }
    600606          free_val = 1;
    601607        }
    602608
  • bashline.c

    diff -Naur bash-4.3.orig/bashline.c bash-4.3/bashline.c
    old new  
    41674167  int qc;
    41684168
    41694169  qc = rl_dispatching ? rl_completion_quote_character : 0; 
    4170   dfn = bash_dequote_filename ((char *)text, qc);
     4170  /* If rl_completion_found_quote != 0, rl_completion_matches will call the
     4171     filename dequoting function, causing the directory name to be dequoted
     4172     twice. */
     4173  if (rl_dispatching && rl_completion_found_quote == 0)
     4174    dfn = bash_dequote_filename ((char *)text, qc);
     4175  else
     4176    dfn = (char *)text;
    41714177  m1 = rl_completion_matches (dfn, rl_filename_completion_function);
    4172   free (dfn);
     4178  if (dfn != text)
     4179    free (dfn);
    41734180
    41744181  if (m1 == 0 || m1[0] == 0)
    41754182    return m1;
  • externs.h

    diff -Naur bash-4.3.orig/externs.h bash-4.3/externs.h
    old new  
    324324extern char *sh_backslash_quote __P((char *, const char *, int));
    325325extern char *sh_backslash_quote_for_double_quotes __P((char *));
    326326extern int sh_contains_shell_metas __P((char *));
     327extern int sh_contains_quotes __P((char *));
    327328
    328329/* declarations for functions defined in lib/sh/spell.c */
    329330extern int spname __P((char *, char *));
  • bash-4.3

    diff -Naur bash-4.3.orig/jobs.c bash-4.3/jobs.c
    old new  
    35973597  unwind_protect_int (jobs_list_frozen);
    35983598  unwind_protect_pointer (the_pipeline);
    35993599  unwind_protect_pointer (subst_assign_varlist);
     3600  unwind_protect_pointer (this_shell_builtin);
    36003601
    36013602  /* We have to add the commands this way because they will be run
    36023603     in reverse order of adding.  We don't want maybe_set_sigchld_trap ()
     
    43744375void
    43754376end_job_control ()
    43764377{
    4377   if (interactive_shell)                /* XXX - should it be interactive? */
     4378  if (interactive_shell || job_control)         /* XXX - should it be just job_control? */
    43784379    {
    43794380      terminate_stopped_jobs ();
    43804381
  • lib/glob/glob.c

    diff -Naur bash-4.3.orig/lib/glob/glob.c bash-4.3/lib/glob/glob.c
    old new  
    123123extern char *glob_patscan __P((char *, char *, int));
    124124extern wchar_t *glob_patscan_wc __P((wchar_t *, wchar_t *, int));
    125125
     126extern char *glob_dirscan __P((char *, int));
     127
    126128/* Compile `glob_loop.c' for single-byte characters. */
    127129#define CHAR    unsigned char
    128130#define INT     int
     
    179181     char *pat, *dname;
    180182     int flags;
    181183{
    182   char *pp, *pe, *t;
    183   int n, r;
     184  char *pp, *pe, *t, *se;
     185  int n, r, negate;
    184186
     187  negate = *pat == '!';
    185188  pp = pat + 2;
    186   pe = pp + strlen (pp) - 1;    /*(*/
    187   if (*pe != ')')
     189  se = pp + strlen (pp) - 1;            /* end of string */
     190  pe = glob_patscan (pp, se, 0);        /* end of extglob pattern (( */
     191  /* we should check for invalid extglob pattern here */
     192  if (pe == 0)
    188193    return 0;
    189   if ((t = strchr (pp, '|')) == 0)      /* easy case first */
     194
     195  /* if pe != se we have more of the pattern at the end of the extglob
     196     pattern. Check the easy case first ( */
     197  if (pe == se && *pe == ')' && (t = strchr (pp, '|')) == 0)
    190198    {
    191199      *pe = '\0';
     200#if defined (HANDLE_MULTIBYTE)
     201      r = mbskipname (pp, dname, flags);
     202#else
    192203      r = skipname (pp, dname, flags);  /*(*/
     204#endif
    193205      *pe = ')';
    194206      return r;
    195207    }
     208
     209  /* check every subpattern */
    196210  while (t = glob_patscan (pp, pe, '|'))
    197211    {
    198212      n = t[-1];
    199213      t[-1] = '\0';
     214#if defined (HANDLE_MULTIBYTE)
     215      r = mbskipname (pp, dname, flags);
     216#else
    200217      r = skipname (pp, dname, flags);
     218#endif
    201219      t[-1] = n;
    202220      if (r == 0)       /* if any pattern says not skip, we don't skip */
    203221        return r;
    204222      pp = t;
    205223    }   /*(*/
    206224
    207   if (pp == pe)         /* glob_patscan might find end of pattern */
     225  /* glob_patscan might find end of pattern */
     226  if (pp == se)
    208227    return r;
    209228
    210   *pe = '\0';
    211 #  if defined (HANDLE_MULTIBYTE)
    212   r = mbskipname (pp, dname, flags);    /*(*/
    213 #  else
    214   r = skipname (pp, dname, flags);      /*(*/
    215 #  endif
    216   *pe = ')';
    217   return r;
     229  /* but if it doesn't then we didn't match a leading dot */
     230  return 0;
    218231}
    219232#endif
    220233
     
    277290     int flags;
    278291{
    279292#if EXTENDED_GLOB
    280   wchar_t *pp, *pe, *t, n;
    281   int r;
     293  wchar_t *pp, *pe, *t, n, *se;
     294  int r, negate;
    282295
     296  negate = *pat == L'!';
    283297  pp = pat + 2;
    284   pe = pp + wcslen (pp) - 1;    /*(*/
    285   if (*pe != L')')
    286     return 0;
    287   if ((t = wcschr (pp, L'|')) == 0)
     298  se = pp + wcslen (pp) - 1;    /*(*/
     299  pe = glob_patscan_wc (pp, se, 0);
     300
     301  if (pe == se && *pe == ')' && (t = wcschr (pp, L'|')) == 0)
    288302    {
    289303      *pe = L'\0';
    290304      r = wchkname (pp, dname); /*(*/
    291305      *pe = L')';
    292306      return r;
    293307    }
     308
     309  /* check every subpattern */
    294310  while (t = glob_patscan_wc (pp, pe, '|'))
    295311    {
    296312      n = t[-1];
     
    305321  if (pp == pe)         /* glob_patscan_wc might find end of pattern */
    306322    return r;
    307323
    308   *pe = L'\0';
    309   r = wchkname (pp, dname);     /*(*/
    310   *pe = L')';
    311   return r;
     324  /* but if it doesn't then we didn't match a leading dot */
     325  return 0;
    312326#else
    313327  return (wchkname (pat, dname));
    314328#endif
     
    10061020{
    10071021  char **result;
    10081022  unsigned int result_size;
    1009   char *directory_name, *filename, *dname;
     1023  char *directory_name, *filename, *dname, *fn;
    10101024  unsigned int directory_len;
    10111025  int free_dirname;                     /* flag */
    10121026  int dflags;
     
    10221036
    10231037  /* Find the filename.  */
    10241038  filename = strrchr (pathname, '/');
     1039#if defined (EXTENDED_GLOB)
     1040  if (filename && extended_glob)
     1041    {
     1042      fn = glob_dirscan (pathname, '/');
     1043#if DEBUG_MATCHING
     1044      if (fn != filename)
     1045        fprintf (stderr, "glob_filename: glob_dirscan: fn (%s) != filename (%s)\n", fn ? fn : "(null)", filename);
     1046#endif
     1047      filename = fn;
     1048    }
     1049#endif
     1050
    10251051  if (filename == NULL)
    10261052    {
    10271053      filename = pathname;
  • lib/glob/gmisc.c

    diff -Naur bash-4.3.orig/lib/glob/gmisc.c bash-4.3/lib/glob/gmisc.c
    old new  
    4242#define WLPAREN         L'('
    4343#define WRPAREN         L')'
    4444
     45extern char *glob_patscan __P((char *, char *, int));
     46
    4547/* Return 1 of the first character of WSTRING could match the first
    4648   character of pattern WPAT.  Wide character version. */
    4749int
     
    210212    case '+':
    211213    case '!':
    212214    case '@':
     215    case '?':
    213216      return (pat[1] == LPAREN);
    214217    default:
    215218      return 0;
     
    374377
    375378  return matlen;
    376379}
     380
     381/* Skip characters in PAT and return the final occurrence of DIRSEP.  This
     382   is only called when extended_glob is set, so we have to skip over extglob
     383   patterns x(...) */
     384char *
     385glob_dirscan (pat, dirsep)
     386     char *pat;
     387     int dirsep;
     388{
     389  char *p, *d, *pe, *se;
     390
     391  d = pe = se = 0;
     392  for (p = pat; p && *p; p++)
     393    {
     394      if (extglob_pattern_p (p))
     395        {
     396          if (se == 0)
     397            se = p + strlen (p) - 1;
     398          pe = glob_patscan (p + 2, se, 0);
     399          if (pe == 0)
     400            continue;
     401          else if (*pe == 0)
     402            break;
     403          p = pe - 1;   /* will do increment above */
     404          continue;
     405        }
     406      if (*p ==  dirsep)
     407        d = p;
     408    }
     409  return d;
     410}
  • lib/readline/display.c

    diff -Naur bash-4.3.orig/lib/readline/display.c bash-4.3/lib/readline/display.c
    old new  
    16371637  /* If we are changing the number of invisible characters in a line, and
    16381638     the spot of first difference is before the end of the invisible chars,
    16391639     lendiff needs to be adjusted. */
    1640   if (current_line == 0 && !_rl_horizontal_scroll_mode &&
     1640  if (current_line == 0 && /* !_rl_horizontal_scroll_mode && */
    16411641      current_invis_chars != visible_wrap_offset)
    16421642    {
    16431643      if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
     
    18251825              else
    18261826                _rl_last_c_pos += bytes_to_insert;
    18271827
     1828              /* XXX - we only want to do this if we are at the end of the line
     1829                 so we move there with _rl_move_cursor_relative */
    18281830              if (_rl_horizontal_scroll_mode && ((oe-old) > (ne-new)))
    1829                 goto clear_rest_of_line;
     1831                {
     1832                  _rl_move_cursor_relative (ne-new, new);
     1833                  goto clear_rest_of_line;
     1834                }
    18301835            }
    18311836        }
    18321837      /* Otherwise, print over the existing material. */
     
    26772682{
    26782683  if (_rl_echoing_p)
    26792684    {
    2680       _rl_move_vert (_rl_vis_botlin);
     2685      if (_rl_vis_botlin > 0)   /* minor optimization plus bug fix */
     2686        _rl_move_vert (_rl_vis_botlin);
    26812687      _rl_vis_botlin = 0;
    26822688      fflush (rl_outstream);
    26832689      rl_restart_output (1, 0);
  • lib/readline/readline.c

    diff -Naur bash-4.3.orig/lib/readline/readline.c bash-4.3/lib/readline/readline.c
    old new  
    744744    r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
    745745
    746746  RL_CHECK_SIGNALS ();
    747   if (r == 0)                   /* success! */
     747  /* We only treat values < 0 specially to simulate recursion. */
     748  if (r >= 0 || (r == -1 && (cxt->flags & KSEQ_SUBSEQ) == 0))   /* success! or failure! */
    748749    {
    749750      _rl_keyseq_chain_dispose ();
    750751      RL_UNSETSTATE (RL_STATE_MULTIKEY);
     
    964965#if defined (VI_MODE)
    965966  if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
    966967      key != ANYOTHERKEY &&
    967       rl_key_sequence_length == 1 &&    /* XXX */
     968      _rl_dispatching_keymap == vi_movement_keymap &&
    968969      _rl_vi_textmod_command (key))
    969970    _rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
    970971#endif
  • lib/readline/readline.c.orig

    diff -Naur bash-4.3.orig/lib/readline/readline.c.orig bash-4.3/lib/readline/readline.c.orig
    old new  
     1/* readline.c -- a general facility for reading lines of input
     2   with emacs style editing and completion. */
     3
     4/* Copyright (C) 1987-2013 Free Software Foundation, Inc.
     5
     6   This file is part of the GNU Readline Library (Readline), a library
     7   for reading lines of text with interactive input and history editing.     
     8
     9   Readline is free software: you can redistribute it and/or modify
     10   it under the terms of the GNU General Public License as published by
     11   the Free Software Foundation, either version 3 of the License, or
     12   (at your option) any later version.
     13
     14   Readline is distributed in the hope that it will be useful,
     15   but WITHOUT ANY WARRANTY; without even the implied warranty of
     16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     17   GNU General Public License for more details.
     18
     19   You should have received a copy of the GNU General Public License
     20   along with Readline.  If not, see <http://www.gnu.org/licenses/>.
     21*/
     22
     23#define READLINE_LIBRARY
     24
     25#if defined (HAVE_CONFIG_H)
     26#  include <config.h>
     27#endif
     28
     29#include <sys/types.h>
     30#include "posixstat.h"
     31#include <fcntl.h>
     32#if defined (HAVE_SYS_FILE_H)
     33#  include <sys/file.h>
     34#endif /* HAVE_SYS_FILE_H */
     35
     36#if defined (HAVE_UNISTD_H)
     37#  include <unistd.h>
     38#endif /* HAVE_UNISTD_H */
     39
     40#if defined (HAVE_STDLIB_H)
     41#  include <stdlib.h>
     42#else
     43#  include "ansi_stdlib.h"
     44#endif /* HAVE_STDLIB_H */
     45
     46#if defined (HAVE_LOCALE_H)
     47#  include <locale.h>
     48#endif
     49
     50#include <stdio.h>
     51#include "posixjmp.h"
     52#include <errno.h>
     53
     54#if !defined (errno)
     55extern int errno;
     56#endif /* !errno */
     57
     58/* System-specific feature definitions and include files. */
     59#include "rldefs.h"
     60#include "rlmbutil.h"
     61
     62#if defined (__EMX__)
     63#  define INCL_DOSPROCESS
     64#  include <os2.h>
     65#endif /* __EMX__ */
     66
     67/* Some standard library routines. */
     68#include "readline.h"
     69#include "history.h"
     70
     71#include "rlprivate.h"
     72#include "rlshell.h"
     73#include "xmalloc.h"
     74
     75#ifndef RL_LIBRARY_VERSION
     76#  define RL_LIBRARY_VERSION "5.1"
     77#endif
     78
     79#ifndef RL_READLINE_VERSION
     80#  define RL_READLINE_VERSION   0x0501
     81#endif
     82
     83extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
     84
     85#if defined (COLOR_SUPPORT)
     86extern void _rl_parse_colors PARAMS((void));            /* XXX */
     87#endif
     88
     89
     90/* Forward declarations used in this file. */
     91static char *readline_internal PARAMS((void));
     92static void readline_initialize_everything PARAMS((void));
     93
     94static void bind_arrow_keys_internal PARAMS((Keymap));
     95static void bind_arrow_keys PARAMS((void));
     96
     97static void readline_default_bindings PARAMS((void));
     98static void reset_default_bindings PARAMS((void));
     99
     100static int _rl_subseq_result PARAMS((int, Keymap, int, int));
     101static int _rl_subseq_getchar PARAMS((int));
     102
     103/* **************************************************************** */
     104/*                                                                  */
     105/*                      Line editing input utility                  */
     106/*                                                                  */
     107/* **************************************************************** */
     108
     109const char *rl_library_version = RL_LIBRARY_VERSION;
     110
     111int rl_readline_version = RL_READLINE_VERSION;
     112
     113/* True if this is `real' readline as opposed to some stub substitute. */
     114int rl_gnu_readline_p = 1;
     115
     116/* A pointer to the keymap that is currently in use.
     117   By default, it is the standard emacs keymap. */
     118Keymap _rl_keymap = emacs_standard_keymap;
     119
     120/* The current style of editing. */
     121int rl_editing_mode = emacs_mode;
     122
     123/* The current insert mode:  input (the default) or overwrite */
     124int rl_insert_mode = RL_IM_DEFAULT;
     125
     126/* Non-zero if we called this function from _rl_dispatch().  It's present
     127   so functions can find out whether they were called from a key binding
     128   or directly from an application. */
     129int rl_dispatching;
     130
     131/* Non-zero if the previous command was a kill command. */
     132int _rl_last_command_was_kill = 0;
     133
     134/* The current value of the numeric argument specified by the user. */
     135int rl_numeric_arg = 1;
     136
     137/* Non-zero if an argument was typed. */
     138int rl_explicit_arg = 0;
     139
     140/* Temporary value used while generating the argument. */
     141int rl_arg_sign = 1;
     142
     143/* Non-zero means we have been called at least once before. */
     144static int rl_initialized;
     145
     146#if 0
     147/* If non-zero, this program is running in an EMACS buffer. */
     148static int running_in_emacs;
     149#endif
     150
     151/* Flags word encapsulating the current readline state. */
     152int rl_readline_state = RL_STATE_NONE;
     153
     154/* The current offset in the current input line. */
     155int rl_point;
     156
     157/* Mark in the current input line. */
     158int rl_mark;
     159
     160/* Length of the current input line. */
     161int rl_end;
     162
     163/* Make this non-zero to return the current input_line. */
     164int rl_done;
     165
     166/* The last function executed by readline. */
     167rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL;
     168
     169/* Top level environment for readline_internal (). */
     170procenv_t _rl_top_level;
     171
     172/* The streams we interact with. */
     173FILE *_rl_in_stream, *_rl_out_stream;
     174
     175/* The names of the streams that we do input and output to. */
     176FILE *rl_instream = (FILE *)NULL;
     177FILE *rl_outstream = (FILE *)NULL;
     178
     179/* Non-zero means echo characters as they are read.  Defaults to no echo;
     180   set to 1 if there is a controlling terminal, we can get its attributes,
     181   and the attributes include `echo'.  Look at rltty.c:prepare_terminal_settings
     182   for the code that sets it. */
     183int _rl_echoing_p = 0;
     184
     185/* Current prompt. */
     186char *rl_prompt = (char *)NULL;
     187int rl_visible_prompt_length = 0;
     188
     189/* Set to non-zero by calling application if it has already printed rl_prompt
     190   and does not want readline to do it the first time. */
     191int rl_already_prompted = 0;
     192
     193/* The number of characters read in order to type this complete command. */
     194int rl_key_sequence_length = 0;
     195
     196/* If non-zero, then this is the address of a function to call just
     197   before readline_internal_setup () prints the first prompt. */
     198rl_hook_func_t *rl_startup_hook = (rl_hook_func_t *)NULL;
     199
     200/* If non-zero, this is the address of a function to call just before
     201   readline_internal_setup () returns and readline_internal starts
     202   reading input characters. */
     203rl_hook_func_t *rl_pre_input_hook = (rl_hook_func_t *)NULL;
     204
     205/* What we use internally.  You should always refer to RL_LINE_BUFFER. */
     206static char *the_line;
     207
     208/* The character that can generate an EOF.  Really read from
     209   the terminal driver... just defaulted here. */
     210int _rl_eof_char = CTRL ('D');
     211
     212/* Non-zero makes this the next keystroke to read. */
     213int rl_pending_input = 0;
     214
     215/* Pointer to a useful terminal name. */
     216const char *rl_terminal_name = (const char *)NULL;
     217
     218/* Non-zero means to always use horizontal scrolling in line display. */
     219int _rl_horizontal_scroll_mode = 0;
     220
     221/* Non-zero means to display an asterisk at the starts of history lines
     222   which have been modified. */
     223int _rl_mark_modified_lines = 0; 
     224
     225/* The style of `bell' notification preferred.  This can be set to NO_BELL,
     226   AUDIBLE_BELL, or VISIBLE_BELL. */
     227int _rl_bell_preference = AUDIBLE_BELL;
     228     
     229/* String inserted into the line by rl_insert_comment (). */
     230char *_rl_comment_begin;
     231
     232/* Keymap holding the function currently being executed. */
     233Keymap rl_executing_keymap;
     234
     235/* Keymap we're currently using to dispatch. */
     236Keymap _rl_dispatching_keymap;
     237
     238/* Non-zero means to erase entire line, including prompt, on empty input lines. */
     239int rl_erase_empty_line = 0;
     240
     241/* Non-zero means to read only this many characters rather than up to a
     242   character bound to accept-line. */
     243int rl_num_chars_to_read;
     244
     245/* Line buffer and maintenance. */
     246char *rl_line_buffer = (char *)NULL;
     247int rl_line_buffer_len = 0;
     248
     249/* Key sequence `contexts' */
     250_rl_keyseq_cxt *_rl_kscxt = 0;
     251
     252int rl_executing_key;
     253char *rl_executing_keyseq = 0;
     254int _rl_executing_keyseq_size = 0;
     255
     256/* Timeout (specified in milliseconds) when reading characters making up an
     257   ambiguous multiple-key sequence */
     258int _rl_keyseq_timeout = 500;
     259
     260#define RESIZE_KEYSEQ_BUFFER() \
     261  do \
     262    { \
     263      if (rl_key_sequence_length + 2 >= _rl_executing_keyseq_size) \
     264        { \
     265          _rl_executing_keyseq_size += 16; \
     266          rl_executing_keyseq = xrealloc (rl_executing_keyseq, _rl_executing_keyseq_size); \
     267        } \
     268    } \
     269  while (0);
     270       
     271/* Forward declarations used by the display, termcap, and history code. */
     272
     273/* **************************************************************** */
     274/*                                                                  */
     275/*                      `Forward' declarations                      */
     276/*                                                                  */
     277/* **************************************************************** */
     278
     279/* Non-zero means do not parse any lines other than comments and
     280   parser directives. */
     281unsigned char _rl_parsing_conditionalized_out = 0;
     282
     283/* Non-zero means to convert characters with the meta bit set to
     284   escape-prefixed characters so we can indirect through
     285   emacs_meta_keymap or vi_escape_keymap. */
     286int _rl_convert_meta_chars_to_ascii = 1;
     287
     288/* Non-zero means to output characters with the meta bit set directly
     289   rather than as a meta-prefixed escape sequence. */
     290int _rl_output_meta_chars = 0;
     291
     292/* Non-zero means to look at the termios special characters and bind
     293   them to equivalent readline functions at startup. */
     294int _rl_bind_stty_chars = 1;
     295
     296/* Non-zero means to go through the history list at every newline (or
     297   whenever rl_done is set and readline returns) and revert each line to
     298   its initial state. */
     299int _rl_revert_all_at_newline = 0;
     300
     301/* Non-zero means to honor the termios ECHOCTL bit and echo control
     302   characters corresponding to keyboard-generated signals. */
     303int _rl_echo_control_chars = 1;
     304
     305/* Non-zero means to prefix the displayed prompt with a character indicating
     306   the editing mode: @ for emacs, : for vi-command, + for vi-insert. */
     307int _rl_show_mode_in_prompt = 0;
     308
     309/* **************************************************************** */
     310/*                                                                  */
     311/*                      Top Level Functions                         */
     312/*                                                                  */
     313/* **************************************************************** */
     314
     315/* Non-zero means treat 0200 bit in terminal input as Meta bit. */
     316int _rl_meta_flag = 0;  /* Forward declaration */
     317
     318/* Set up the prompt and expand it.  Called from readline() and
     319   rl_callback_handler_install (). */
     320int
     321rl_set_prompt (prompt)
     322     const char *prompt;
     323{
     324  FREE (rl_prompt);
     325  rl_prompt = prompt ? savestring (prompt) : (char *)NULL;
     326  rl_display_prompt = rl_prompt ? rl_prompt : "";
     327
     328  rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
     329  return 0;
     330}
     331 
     332/* Read a line of input.  Prompt with PROMPT.  An empty PROMPT means
     333   none.  A return value of NULL means that EOF was encountered. */
     334char *
     335readline (prompt)
     336     const char *prompt;
     337{
     338  char *value;
     339#if 0
     340  int in_callback;
     341#endif
     342
     343  /* If we are at EOF return a NULL string. */
     344  if (rl_pending_input == EOF)
     345    {
     346      rl_clear_pending_input ();
     347      return ((char *)NULL);
     348    }
     349
     350#if 0
     351  /* If readline() is called after installing a callback handler, temporarily
     352     turn off the callback state to avoid ensuing messiness.  Patch supplied
     353     by the gdb folks.  XXX -- disabled.  This can be fooled and readline
     354     left in a strange state by a poorly-timed longjmp. */
     355  if (in_callback = RL_ISSTATE (RL_STATE_CALLBACK))
     356    RL_UNSETSTATE (RL_STATE_CALLBACK);
     357#endif
     358
     359  rl_set_prompt (prompt);
     360
     361  rl_initialize ();
     362  if (rl_prep_term_function)
     363    (*rl_prep_term_function) (_rl_meta_flag);
     364
     365#if defined (HANDLE_SIGNALS)
     366  rl_set_signals ();
     367#endif
     368
     369  value = readline_internal ();
     370  if (rl_deprep_term_function)
     371    (*rl_deprep_term_function) ();
     372
     373#if defined (HANDLE_SIGNALS)
     374  rl_clear_signals ();
     375#endif
     376
     377#if 0
     378  if (in_callback)
     379    RL_SETSTATE (RL_STATE_CALLBACK);
     380#endif
     381
     382#if HAVE_DECL_AUDIT_TTY && defined (ENABLE_TTY_AUDIT_SUPPORT)
     383  if (value)
     384    _rl_audit_tty (value);
     385#endif
     386
     387  return (value);
     388}
     389
     390#if defined (READLINE_CALLBACKS)
     391#  define STATIC_CALLBACK
     392#else
     393#  define STATIC_CALLBACK static
     394#endif
     395
     396STATIC_CALLBACK void
     397readline_internal_setup ()
     398{
     399  char *nprompt;
     400
     401  _rl_in_stream = rl_instream;
     402  _rl_out_stream = rl_outstream;
     403
     404  /* Enable the meta key only for the duration of readline(), if this
     405     terminal has one and the terminal has been initialized */
     406  if (_rl_enable_meta & RL_ISSTATE (RL_STATE_TERMPREPPED))
     407    _rl_enable_meta_key ();
     408
     409  if (rl_startup_hook)
     410    (*rl_startup_hook) ();
     411
     412#if defined (VI_MODE)
     413  if (rl_editing_mode == vi_mode)
     414    rl_vi_insertion_mode (1, 'i');      /* don't want to reset last */
     415#endif /* VI_MODE */
     416
     417  /* If we're not echoing, we still want to at least print a prompt, because
     418     rl_redisplay will not do it for us.  If the calling application has a
     419     custom redisplay function, though, let that function handle it. */
     420  if (_rl_echoing_p == 0 && rl_redisplay_function == rl_redisplay)
     421    {
     422      if (rl_prompt && rl_already_prompted == 0)
     423        {
     424          nprompt = _rl_strip_prompt (rl_prompt);
     425          fprintf (_rl_out_stream, "%s", nprompt);
     426          fflush (_rl_out_stream);
     427          xfree (nprompt);
     428        }
     429    }
     430  else
     431    {
     432      if (rl_prompt && rl_already_prompted)
     433        rl_on_new_line_with_prompt ();
     434      else
     435        rl_on_new_line ();
     436      (*rl_redisplay_function) ();
     437    }
     438
     439  if (rl_pre_input_hook)
     440    (*rl_pre_input_hook) ();
     441
     442  RL_CHECK_SIGNALS ();
     443}
     444
     445STATIC_CALLBACK char *
     446readline_internal_teardown (eof)
     447     int eof;
     448{
     449  char *temp;
     450  HIST_ENTRY *entry;
     451
     452  RL_CHECK_SIGNALS ();
     453
     454  /* Restore the original of this history line, iff the line that we
     455     are editing was originally in the history, AND the line has changed. */
     456  entry = current_history ();
     457
     458  if (entry && rl_undo_list)
     459    {
     460      temp = savestring (the_line);
     461      rl_revert_line (1, 0);
     462      entry = replace_history_entry (where_history (), the_line, (histdata_t)NULL);
     463      _rl_free_history_entry (entry);
     464
     465      strcpy (the_line, temp);
     466      xfree (temp);
     467    }
     468
     469  if (_rl_revert_all_at_newline)
     470    _rl_revert_all_lines ();
     471
     472  /* At any rate, it is highly likely that this line has an undo list.  Get
     473     rid of it now. */
     474  if (rl_undo_list)
     475    rl_free_undo_list ();
     476
     477  /* Disable the meta key, if this terminal has one and we were told to use it.
     478     The check whether or not we sent the enable string is in
     479     _rl_disable_meta_key(); the flag is set in _rl_enable_meta_key */
     480  _rl_disable_meta_key ();
     481
     482  /* Restore normal cursor, if available. */
     483  _rl_set_insert_mode (RL_IM_INSERT, 0);
     484
     485  return (eof ? (char *)NULL : savestring (the_line));
     486}
     487
     488void
     489_rl_internal_char_cleanup ()
     490{
     491#if defined (VI_MODE)
     492  /* In vi mode, when you exit insert mode, the cursor moves back
     493     over the previous character.  We explicitly check for that here. */
     494  if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
     495    rl_vi_check ();
     496#endif /* VI_MODE */
     497
     498  if (rl_num_chars_to_read && rl_end >= rl_num_chars_to_read)
     499    {
     500      (*rl_redisplay_function) ();
     501      _rl_want_redisplay = 0;
     502      rl_newline (1, '\n');
     503    }
     504
     505  if (rl_done == 0)
     506    {
     507      (*rl_redisplay_function) ();
     508      _rl_want_redisplay = 0;
     509    }
     510
     511  /* If the application writer has told us to erase the entire line if
     512     the only character typed was something bound to rl_newline, do so. */
     513  if (rl_erase_empty_line && rl_done && rl_last_func == rl_newline &&
     514      rl_point == 0 && rl_end == 0)
     515    _rl_erase_entire_line ();
     516}
     517
     518STATIC_CALLBACK int
     519#if defined (READLINE_CALLBACKS)
     520readline_internal_char ()
     521#else
     522readline_internal_charloop ()
     523#endif
     524{
     525  static int lastc, eof_found;
     526  int c, code, lk;
     527
     528  lastc = -1;
     529  eof_found = 0;
     530
     531#if !defined (READLINE_CALLBACKS)
     532  while (rl_done == 0)
     533    {
     534#endif
     535      lk = _rl_last_command_was_kill;
     536
     537#if defined (HAVE_POSIX_SIGSETJMP)
     538      code = sigsetjmp (_rl_top_level, 0);
     539#else
     540      code = setjmp (_rl_top_level);
     541#endif
     542
     543      if (code)
     544        {
     545          (*rl_redisplay_function) ();
     546          _rl_want_redisplay = 0;
     547          /* If we get here, we're not being called from something dispatched
     548             from _rl_callback_read_char(), which sets up its own value of
     549             _rl_top_level (saving and restoring the old, of course), so
     550             we can just return here. */
     551          if (RL_ISSTATE (RL_STATE_CALLBACK))
     552            return (0);
     553        }
     554
     555      if (rl_pending_input == 0)
     556        {
     557          /* Then initialize the argument and number of keys read. */
     558          _rl_reset_argument ();
     559          rl_key_sequence_length = 0;
     560          rl_executing_keyseq[0] = 0;
     561        }
     562
     563      RL_SETSTATE(RL_STATE_READCMD);
     564      c = rl_read_key ();
     565      RL_UNSETSTATE(RL_STATE_READCMD);
     566
     567      /* look at input.c:rl_getc() for the circumstances under which this will
     568         be returned; punt immediately on read error without converting it to
     569         a newline; assume that rl_read_key has already called the signal
     570         handler. */
     571      if (c == READERR)
     572        {
     573#if defined (READLINE_CALLBACKS)
     574          RL_SETSTATE(RL_STATE_DONE);
     575          return (rl_done = 1);
     576#else
     577          eof_found = 1;
     578          break;
     579#endif
     580        }
     581
     582      /* EOF typed to a non-blank line is a <NL>.  If we want to change this,
     583         to force any existing line to be ignored when read(2) reads EOF,
     584         for example, this is the place to change. */
     585      if (c == EOF && rl_end)
     586        c = NEWLINE;
     587
     588      /* The character _rl_eof_char typed to blank line, and not as the
     589         previous character is interpreted as EOF. */
     590      if (((c == _rl_eof_char && lastc != c) || c == EOF) && !rl_end)
     591        {
     592#if defined (READLINE_CALLBACKS)
     593          RL_SETSTATE(RL_STATE_DONE);
     594          return (rl_done = 1);
     595#else
     596          eof_found = 1;
     597          break;
     598#endif
     599        }
     600
     601      lastc = c;
     602      _rl_dispatch ((unsigned char)c, _rl_keymap);
     603      RL_CHECK_SIGNALS ();
     604
     605      /* If there was no change in _rl_last_command_was_kill, then no kill
     606         has taken place.  Note that if input is pending we are reading
     607         a prefix command, so nothing has changed yet. */
     608      if (rl_pending_input == 0 && lk == _rl_last_command_was_kill)
     609        _rl_last_command_was_kill = 0;
     610
     611      _rl_internal_char_cleanup ();
     612
     613#if defined (READLINE_CALLBACKS)
     614      return 0;
     615#else
     616    }
     617
     618  return (eof_found);
     619#endif
     620}
     621
     622#if defined (READLINE_CALLBACKS)
     623static int
     624readline_internal_charloop ()
     625{
     626  int eof = 1;
     627
     628  while (rl_done == 0)
     629    eof = readline_internal_char ();
     630  return (eof);
     631}
     632#endif /* READLINE_CALLBACKS */
     633
     634/* Read a line of input from the global rl_instream, doing output on
     635   the global rl_outstream.
     636   If rl_prompt is non-null, then that is our prompt. */
     637static char *
     638readline_internal ()
     639{
     640  int eof;
     641
     642  readline_internal_setup ();
     643  eof = readline_internal_charloop ();
     644  return (readline_internal_teardown (eof));
     645}
     646
     647void
     648_rl_init_line_state ()
     649{
     650  rl_point = rl_end = rl_mark = 0;
     651  the_line = rl_line_buffer;
     652  the_line[0] = 0;
     653}
     654
     655void
     656_rl_set_the_line ()
     657{
     658  the_line = rl_line_buffer;
     659}
     660
     661#if defined (READLINE_CALLBACKS)
     662_rl_keyseq_cxt *
     663_rl_keyseq_cxt_alloc ()
     664{
     665  _rl_keyseq_cxt *cxt;
     666
     667  cxt = (_rl_keyseq_cxt *)xmalloc (sizeof (_rl_keyseq_cxt));
     668
     669  cxt->flags = cxt->subseq_arg = cxt->subseq_retval = 0;
     670
     671  cxt->okey = 0;
     672  cxt->ocxt = _rl_kscxt;
     673  cxt->childval = 42;           /* sentinel value */
     674
     675  return cxt;
     676}
     677
     678void
     679_rl_keyseq_cxt_dispose (cxt)
     680    _rl_keyseq_cxt *cxt;
     681{
     682  xfree (cxt);
     683}
     684
     685void
     686_rl_keyseq_chain_dispose ()
     687{
     688  _rl_keyseq_cxt *cxt;
     689
     690  while (_rl_kscxt)
     691    {
     692      cxt = _rl_kscxt;
     693      _rl_kscxt = _rl_kscxt->ocxt;
     694      _rl_keyseq_cxt_dispose (cxt);
     695    }
     696}
     697#endif
     698
     699static int
     700_rl_subseq_getchar (key)
     701     int key;
     702{
     703  int k;
     704
     705  if (key == ESC)
     706    RL_SETSTATE(RL_STATE_METANEXT);
     707  RL_SETSTATE(RL_STATE_MOREINPUT);
     708  k = rl_read_key ();
     709  RL_UNSETSTATE(RL_STATE_MOREINPUT);
     710  if (key == ESC)
     711    RL_UNSETSTATE(RL_STATE_METANEXT);
     712
     713  return k;
     714}
     715
     716#if defined (READLINE_CALLBACKS)
     717int
     718_rl_dispatch_callback (cxt)
     719     _rl_keyseq_cxt *cxt;
     720{
     721  int nkey, r;
     722
     723  /* For now */
     724  /* The first time this context is used, we want to read input and dispatch
     725     on it.  When traversing the chain of contexts back `up', we want to use
     726     the value from the next context down.  We're simulating recursion using
     727     a chain of contexts. */
     728  if ((cxt->flags & KSEQ_DISPATCHED) == 0)
     729    {
     730      nkey = _rl_subseq_getchar (cxt->okey);
     731      if (nkey < 0)
     732        {
     733          _rl_abort_internal ();
     734          return -1;
     735        }
     736      r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
     737      cxt->flags |= KSEQ_DISPATCHED;
     738    }
     739  else
     740    r = cxt->childval;
     741
     742  /* For now */
     743  if (r != -3)  /* don't do this if we indicate there will be other matches */
     744    r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
     745
     746  RL_CHECK_SIGNALS ();
     747  /* We only treat values < 0 specially to simulate recursion. */
     748  if (r >= 0 || (r == -1 && (cxt->flags & KSEQ_SUBSEQ) == 0))   /* success! or failure! */
     749    {
     750      _rl_keyseq_chain_dispose ();
     751      RL_UNSETSTATE (RL_STATE_MULTIKEY);
     752      return r;
     753    }
     754
     755  if (r != -3)                  /* magic value that says we added to the chain */
     756    _rl_kscxt = cxt->ocxt;
     757  if (_rl_kscxt)
     758    _rl_kscxt->childval = r;
     759  if (r != -3)
     760    _rl_keyseq_cxt_dispose (cxt);
     761
     762  return r;
     763}
     764#endif /* READLINE_CALLBACKS */
     765 
     766/* Do the command associated with KEY in MAP.
     767   If the associated command is really a keymap, then read
     768   another key, and dispatch into that map. */
     769int
     770_rl_dispatch (key, map)
     771     register int key;
     772     Keymap map;
     773{
     774  _rl_dispatching_keymap = map;
     775  return _rl_dispatch_subseq (key, map, 0);
     776}
     777
     778int
     779_rl_dispatch_subseq (key, map, got_subseq)
     780     register int key;
     781     Keymap map;
     782     int got_subseq;
     783{
     784  int r, newkey;
     785  char *macro;
     786  rl_command_func_t *func;
     787#if defined (READLINE_CALLBACKS)
     788  _rl_keyseq_cxt *cxt;
     789#endif
     790
     791  if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
     792    {
     793      if (map[ESC].type == ISKMAP)
     794        {
     795          if (RL_ISSTATE (RL_STATE_MACRODEF))
     796            _rl_add_macro_char (ESC);
     797          RESIZE_KEYSEQ_BUFFER ();
     798          rl_executing_keyseq[rl_key_sequence_length++] = ESC;
     799          map = FUNCTION_TO_KEYMAP (map, ESC);
     800          key = UNMETA (key);
     801          return (_rl_dispatch (key, map));
     802        }
     803      else
     804        rl_ding ();
     805      return 0;
     806    }
     807
     808  if (RL_ISSTATE (RL_STATE_MACRODEF))
     809    _rl_add_macro_char (key);
     810
     811  r = 0;
     812  switch (map[key].type)
     813    {
     814    case ISFUNC:
     815      func = map[key].function;
     816      if (func)
     817        {
     818          /* Special case rl_do_lowercase_version (). */
     819          if (func == rl_do_lowercase_version)
     820            /* Should we do anything special if key == ANYOTHERKEY? */
     821            return (_rl_dispatch (_rl_to_lower (key), map));
     822
     823          rl_executing_keymap = map;
     824          rl_executing_key = key;
     825
     826          RESIZE_KEYSEQ_BUFFER();
     827          rl_executing_keyseq[rl_key_sequence_length++] = key;
     828          rl_executing_keyseq[rl_key_sequence_length] = '\0';
     829
     830          rl_dispatching = 1;
     831          RL_SETSTATE(RL_STATE_DISPATCHING);
     832          r = (*func) (rl_numeric_arg * rl_arg_sign, key);
     833          RL_UNSETSTATE(RL_STATE_DISPATCHING);
     834          rl_dispatching = 0;
     835
     836          /* If we have input pending, then the last command was a prefix
     837             command.  Don't change the state of rl_last_func.  Otherwise,
     838             remember the last command executed in this variable. */
     839          if (rl_pending_input == 0 && map[key].function != rl_digit_argument)
     840            rl_last_func = map[key].function;
     841
     842          RL_CHECK_SIGNALS ();
     843        }
     844      else if (map[ANYOTHERKEY].function)
     845        {
     846          /* OK, there's no function bound in this map, but there is a
     847             shadow function that was overridden when the current keymap
     848             was created.  Return -2 to note  that. */
     849          if (RL_ISSTATE (RL_STATE_MACROINPUT))
     850            _rl_prev_macro_key ();
     851          else
     852            _rl_unget_char  (key);
     853          return -2;
     854        }
     855      else if (got_subseq)
     856        {
     857          /* Return -1 to note that we're in a subsequence, but  we don't
     858             have a matching key, nor was one overridden.  This means
     859             we need to back up the recursion chain and find the last
     860             subsequence that is bound to a function. */
     861          if (RL_ISSTATE (RL_STATE_MACROINPUT))
     862            _rl_prev_macro_key ();
     863          else
     864            _rl_unget_char (key);
     865          return -1;
     866        }
     867      else
     868        {
     869#if defined (READLINE_CALLBACKS)
     870          RL_UNSETSTATE (RL_STATE_MULTIKEY);
     871          _rl_keyseq_chain_dispose ();
     872#endif
     873          _rl_abort_internal ();
     874          return -1;
     875        }
     876      break;
     877
     878    case ISKMAP:
     879      if (map[key].function != 0)
     880        {
     881#if defined (VI_MODE)
     882          /* The only way this test will be true is if a subsequence has been
     883             bound starting with ESC, generally the arrow keys.  What we do is
     884             check whether there's input in the queue, which there generally
     885             will be if an arrow key has been pressed, and, if there's not,
     886             just dispatch to (what we assume is) rl_vi_movement_mode right
     887             away.  This is essentially an input test with a zero timeout (by
     888             default) or a timeout determined by the value of `keyseq-timeout' */
     889          /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued
     890             takes microseconds, so multiply by 1000 */
     891          if (rl_editing_mode == vi_mode && key == ESC && map == vi_insertion_keymap
     892              && _rl_input_queued ((_rl_keyseq_timeout > 0) ? _rl_keyseq_timeout*1000 : 0) == 0)
     893            return (_rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key)));
     894#endif
     895
     896          RESIZE_KEYSEQ_BUFFER ();
     897          rl_executing_keyseq[rl_key_sequence_length++] = key;
     898          _rl_dispatching_keymap = FUNCTION_TO_KEYMAP (map, key);
     899
     900          /* Allocate new context here.  Use linked contexts (linked through
     901             cxt->ocxt) to simulate recursion */
     902#if defined (READLINE_CALLBACKS)
     903          if (RL_ISSTATE (RL_STATE_CALLBACK))
     904            {
     905              /* Return 0 only the first time, to indicate success to
     906                 _rl_callback_read_char.  The rest of the time, we're called
     907                 from _rl_dispatch_callback, so we return -3 to indicate
     908                 special handling is necessary. */
     909              r = RL_ISSTATE (RL_STATE_MULTIKEY) ? -3 : 0;
     910              cxt = _rl_keyseq_cxt_alloc ();
     911
     912              if (got_subseq)
     913                cxt->flags |= KSEQ_SUBSEQ;
     914              cxt->okey = key;
     915              cxt->oldmap = map;
     916              cxt->dmap = _rl_dispatching_keymap;
     917              cxt->subseq_arg = got_subseq || cxt->dmap[ANYOTHERKEY].function;
     918
     919              RL_SETSTATE (RL_STATE_MULTIKEY);
     920              _rl_kscxt = cxt;
     921
     922              return r;         /* don't indicate immediate success */
     923            }
     924#endif
     925
     926          /* Tentative inter-character timeout for potential multi-key
     927             sequences?  If no input within timeout, abort sequence and
     928             act as if we got non-matching input. */
     929          /* _rl_keyseq_timeout specified in milliseconds; _rl_input_queued
     930             takes microseconds, so multiply by 1000 */
     931          if (_rl_keyseq_timeout > 0 &&
     932                (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
     933                _rl_pushed_input_available () == 0 &&
     934                _rl_dispatching_keymap[ANYOTHERKEY].function &&
     935                _rl_input_queued (_rl_keyseq_timeout*1000) == 0)
     936            return (_rl_subseq_result (-2, map, key, got_subseq));
     937
     938          newkey = _rl_subseq_getchar (key);
     939          if (newkey < 0)
     940            {
     941              _rl_abort_internal ();
     942              return -1;
     943            }
     944
     945          r = _rl_dispatch_subseq (newkey, _rl_dispatching_keymap, got_subseq || map[ANYOTHERKEY].function);
     946          return _rl_subseq_result (r, map, key, got_subseq);
     947        }
     948      else
     949        {
     950          _rl_abort_internal ();
     951          return -1;
     952        }
     953      break;
     954
     955    case ISMACR:
     956      if (map[key].function != 0)
     957        {
     958          rl_executing_keyseq[rl_key_sequence_length] = '\0';
     959          macro = savestring ((char *)map[key].function);
     960          _rl_with_macro_input (macro);
     961          return 0;
     962        }
     963      break;
     964    }
     965#if defined (VI_MODE)
     966  if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
     967      key != ANYOTHERKEY &&
     968      rl_key_sequence_length == 1 &&    /* XXX */
     969      _rl_vi_textmod_command (key))
     970    _rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
     971#endif
     972
     973  return (r);
     974}
     975
     976static int
     977_rl_subseq_result (r, map, key, got_subseq)
     978     int r;
     979     Keymap map;
     980     int key, got_subseq;
     981{
     982  Keymap m;
     983  int type, nt;
     984  rl_command_func_t *func, *nf;
     985
     986  if (r == -2)
     987    /* We didn't match anything, and the keymap we're indexed into
     988       shadowed a function previously bound to that prefix.  Call
     989       the function.  The recursive call to _rl_dispatch_subseq has
     990       already taken care of pushing any necessary input back onto
     991       the input queue with _rl_unget_char. */
     992    {
     993      m = _rl_dispatching_keymap;
     994      type = m[ANYOTHERKEY].type;
     995      func = m[ANYOTHERKEY].function;
     996      if (type == ISFUNC && func == rl_do_lowercase_version)
     997        r = _rl_dispatch (_rl_to_lower (key), map);
     998      else if (type == ISFUNC && func == rl_insert)
     999        {
     1000          /* If the function that was shadowed was self-insert, we
     1001             somehow need a keymap with map[key].func == self-insert.
     1002             Let's use this one. */
     1003          nt = m[key].type;
     1004          nf = m[key].function;
     1005
     1006          m[key].type = type;
     1007          m[key].function = func;
     1008          r = _rl_dispatch (key, m);
     1009          m[key].type = nt;
     1010          m[key].function = nf;
     1011        }
     1012      else
     1013        r = _rl_dispatch (ANYOTHERKEY, m);
     1014    }
     1015  else if (r && map[ANYOTHERKEY].function)
     1016    {
     1017      /* We didn't match (r is probably -1), so return something to
     1018         tell the caller that it should try ANYOTHERKEY for an
     1019         overridden function. */
     1020      if (RL_ISSTATE (RL_STATE_MACROINPUT))
     1021        _rl_prev_macro_key ();
     1022      else
     1023        _rl_unget_char (key);
     1024      _rl_dispatching_keymap = map;
     1025      return -2;
     1026    }
     1027  else if (r && got_subseq)
     1028    {
     1029      /* OK, back up the chain. */
     1030      if (RL_ISSTATE (RL_STATE_MACROINPUT))
     1031        _rl_prev_macro_key ();
     1032      else
     1033        _rl_unget_char (key);
     1034      _rl_dispatching_keymap = map;
     1035      return -1;
     1036    }
     1037
     1038  return r;
     1039}
     1040
     1041/* **************************************************************** */
     1042/*                                                                  */
     1043/*                      Initializations                             */
     1044/*                                                                  */
     1045/* **************************************************************** */
     1046
     1047/* Initialize readline (and terminal if not already). */
     1048int
     1049rl_initialize ()
     1050{
     1051  /* If we have never been called before, initialize the
     1052     terminal and data structures. */
     1053  if (!rl_initialized)
     1054    {
     1055      RL_SETSTATE(RL_STATE_INITIALIZING);
     1056      readline_initialize_everything ();
     1057      RL_UNSETSTATE(RL_STATE_INITIALIZING);
     1058      rl_initialized++;
     1059      RL_SETSTATE(RL_STATE_INITIALIZED);
     1060    }
     1061
     1062  /* Initialize the current line information. */
     1063  _rl_init_line_state ();
     1064
     1065  /* We aren't done yet.  We haven't even gotten started yet! */
     1066  rl_done = 0;
     1067  RL_UNSETSTATE(RL_STATE_DONE);
     1068
     1069  /* Tell the history routines what is going on. */
     1070  _rl_start_using_history ();
     1071
     1072  /* Make the display buffer match the state of the line. */
     1073  rl_reset_line_state ();
     1074
     1075  /* No such function typed yet. */
     1076  rl_last_func = (rl_command_func_t *)NULL;
     1077
     1078  /* Parsing of key-bindings begins in an enabled state. */
     1079  _rl_parsing_conditionalized_out = 0;
     1080
     1081#if defined (VI_MODE)
     1082  if (rl_editing_mode == vi_mode)
     1083    _rl_vi_initialize_line ();
     1084#endif
     1085
     1086  /* Each line starts in insert mode (the default). */
     1087  _rl_set_insert_mode (RL_IM_DEFAULT, 1);
     1088
     1089  return 0;
     1090}
     1091
     1092#if 0
     1093#if defined (__EMX__)
     1094static void
     1095_emx_build_environ ()
     1096{
     1097  TIB *tibp;
     1098  PIB *pibp;
     1099  char *t, **tp;
     1100  int c;
     1101
     1102  DosGetInfoBlocks (&tibp, &pibp);
     1103  t = pibp->pib_pchenv;
     1104  for (c = 1; *t; c++)
     1105    t += strlen (t) + 1;
     1106  tp = environ = (char **)xmalloc ((c + 1) * sizeof (char *));
     1107  t = pibp->pib_pchenv;
     1108  while (*t)
     1109    {
     1110      *tp++ = t;
     1111      t += strlen (t) + 1;
     1112    }
     1113  *tp = 0;
     1114}
     1115#endif /* __EMX__ */
     1116#endif
     1117
     1118/* Initialize the entire state of the world. */
     1119static void
     1120readline_initialize_everything ()
     1121{
     1122#if 0
     1123#if defined (__EMX__)
     1124  if (environ == 0)
     1125    _emx_build_environ ();
     1126#endif
     1127#endif
     1128
     1129#if 0
     1130  /* Find out if we are running in Emacs -- UNUSED. */
     1131  running_in_emacs = sh_get_env_value ("EMACS") != (char *)0;
     1132#endif
     1133
     1134  /* Set up input and output if they are not already set up. */
     1135  if (!rl_instream)
     1136    rl_instream = stdin;
     1137
     1138  if (!rl_outstream)
     1139    rl_outstream = stdout;
     1140
     1141  /* Bind _rl_in_stream and _rl_out_stream immediately.  These values
     1142     may change, but they may also be used before readline_internal ()
     1143     is called. */
     1144  _rl_in_stream = rl_instream;
     1145  _rl_out_stream = rl_outstream;
     1146
     1147  /* Allocate data structures. */
     1148  if (rl_line_buffer == 0)
     1149    rl_line_buffer = (char *)xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);
     1150
     1151  /* Initialize the terminal interface. */
     1152  if (rl_terminal_name == 0)
     1153    rl_terminal_name = sh_get_env_value ("TERM");
     1154  _rl_init_terminal_io (rl_terminal_name);
     1155
     1156  /* Bind tty characters to readline functions. */
     1157  readline_default_bindings ();
     1158
     1159  /* Initialize the function names. */
     1160  rl_initialize_funmap ();
     1161
     1162  /* Decide whether we should automatically go into eight-bit mode. */
     1163  _rl_init_eightbit ();
     1164     
     1165  /* Read in the init file. */
     1166  rl_read_init_file ((char *)NULL);
     1167
     1168  /* XXX */
     1169  if (_rl_horizontal_scroll_mode && _rl_term_autowrap)
     1170    {
     1171      _rl_screenwidth--;
     1172      _rl_screenchars -= _rl_screenheight;
     1173    }
     1174
     1175  /* Override the effect of any `set keymap' assignments in the
     1176     inputrc file. */
     1177  rl_set_keymap_from_edit_mode ();
     1178
     1179  /* Try to bind a common arrow key prefix, if not already bound. */
     1180  bind_arrow_keys ();
     1181
     1182  /* If the completion parser's default word break characters haven't
     1183     been set yet, then do so now. */
     1184  if (rl_completer_word_break_characters == (char *)NULL)
     1185    rl_completer_word_break_characters = (char *)rl_basic_word_break_characters;
     1186
     1187#if defined (COLOR_SUPPORT)
     1188  if (_rl_colored_stats)
     1189    _rl_parse_colors ();
     1190#endif
     1191
     1192  rl_executing_keyseq = malloc (_rl_executing_keyseq_size = 16);
     1193  if (rl_executing_keyseq)
     1194    rl_executing_keyseq[0] = '\0';
     1195}
     1196
     1197/* If this system allows us to look at the values of the regular
     1198   input editing characters, then bind them to their readline
     1199   equivalents, iff the characters are not bound to keymaps. */
     1200static void
     1201readline_default_bindings ()
     1202{
     1203  if (_rl_bind_stty_chars)
     1204    rl_tty_set_default_bindings (_rl_keymap);
     1205}
     1206
     1207/* Reset the default bindings for the terminal special characters we're
     1208   interested in back to rl_insert and read the new ones. */
     1209static void
     1210reset_default_bindings ()
     1211{
     1212  if (_rl_bind_stty_chars)
     1213    {
     1214      rl_tty_unset_default_bindings (_rl_keymap);
     1215      rl_tty_set_default_bindings (_rl_keymap);
     1216    }
     1217}
     1218
     1219/* Bind some common arrow key sequences in MAP. */
     1220static void
     1221bind_arrow_keys_internal (map)
     1222     Keymap map;
     1223{
     1224  Keymap xkeymap;
     1225
     1226  xkeymap = _rl_keymap;
     1227  _rl_keymap = map;
     1228
     1229#if defined (__MSDOS__)
     1230  rl_bind_keyseq_if_unbound ("\033[0A", rl_get_previous_history);
     1231  rl_bind_keyseq_if_unbound ("\033[0B", rl_backward_char);
     1232  rl_bind_keyseq_if_unbound ("\033[0C", rl_forward_char);
     1233  rl_bind_keyseq_if_unbound ("\033[0D", rl_get_next_history);
     1234#endif
     1235
     1236  rl_bind_keyseq_if_unbound ("\033[A", rl_get_previous_history);
     1237  rl_bind_keyseq_if_unbound ("\033[B", rl_get_next_history);
     1238  rl_bind_keyseq_if_unbound ("\033[C", rl_forward_char);
     1239  rl_bind_keyseq_if_unbound ("\033[D", rl_backward_char);
     1240  rl_bind_keyseq_if_unbound ("\033[H", rl_beg_of_line);
     1241  rl_bind_keyseq_if_unbound ("\033[F", rl_end_of_line);
     1242
     1243  rl_bind_keyseq_if_unbound ("\033OA", rl_get_previous_history);
     1244  rl_bind_keyseq_if_unbound ("\033OB", rl_get_next_history);
     1245  rl_bind_keyseq_if_unbound ("\033OC", rl_forward_char);
     1246  rl_bind_keyseq_if_unbound ("\033OD", rl_backward_char);
     1247  rl_bind_keyseq_if_unbound ("\033OH", rl_beg_of_line);
     1248  rl_bind_keyseq_if_unbound ("\033OF", rl_end_of_line);
     1249
     1250#if defined (__MINGW32__)
     1251  rl_bind_keyseq_if_unbound ("\340H", rl_get_previous_history);
     1252  rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history);
     1253  rl_bind_keyseq_if_unbound ("\340M", rl_forward_char);
     1254  rl_bind_keyseq_if_unbound ("\340K", rl_backward_char);
     1255  rl_bind_keyseq_if_unbound ("\340G", rl_beg_of_line);
     1256  rl_bind_keyseq_if_unbound ("\340O", rl_end_of_line);
     1257  rl_bind_keyseq_if_unbound ("\340S", rl_delete);
     1258  rl_bind_keyseq_if_unbound ("\340R", rl_overwrite_mode);
     1259
     1260  /* These may or may not work because of the embedded NUL. */
     1261  rl_bind_keyseq_if_unbound ("\\000H", rl_get_previous_history);
     1262  rl_bind_keyseq_if_unbound ("\\000P", rl_get_next_history);
     1263  rl_bind_keyseq_if_unbound ("\\000M", rl_forward_char);
     1264  rl_bind_keyseq_if_unbound ("\\000K", rl_backward_char);
     1265  rl_bind_keyseq_if_unbound ("\\000G", rl_beg_of_line);
     1266  rl_bind_keyseq_if_unbound ("\\000O", rl_end_of_line);
     1267  rl_bind_keyseq_if_unbound ("\\000S", rl_delete);
     1268  rl_bind_keyseq_if_unbound ("\\000R", rl_overwrite_mode);
     1269#endif
     1270
     1271  _rl_keymap = xkeymap;
     1272}
     1273
     1274/* Try and bind the common arrow key prefixes after giving termcap and
     1275   the inputrc file a chance to bind them and create `real' keymaps
     1276   for the arrow key prefix. */
     1277static void
     1278bind_arrow_keys ()
     1279{
     1280  bind_arrow_keys_internal (emacs_standard_keymap);
     1281
     1282#if defined (VI_MODE)
     1283  bind_arrow_keys_internal (vi_movement_keymap);
     1284  /* Unbind vi_movement_keymap[ESC] to allow users to repeatedly hit ESC
     1285     in vi command mode while still allowing the arrow keys to work. */
     1286  if (vi_movement_keymap[ESC].type == ISKMAP)
     1287    rl_bind_keyseq_in_map ("\033", (rl_command_func_t *)NULL, vi_movement_keymap);
     1288  bind_arrow_keys_internal (vi_insertion_keymap);
     1289#endif
     1290}
     1291
     1292/* **************************************************************** */
     1293/*                                                                  */
     1294/*              Saving and Restoring Readline's state               */
     1295/*                                                                  */
     1296/* **************************************************************** */
     1297
     1298int
     1299rl_save_state (sp)
     1300     struct readline_state *sp;
     1301{
     1302  if (sp == 0)
     1303    return -1;
     1304
     1305  sp->point = rl_point;
     1306  sp->end = rl_end;
     1307  sp->mark = rl_mark;
     1308  sp->buffer = rl_line_buffer;
     1309  sp->buflen = rl_line_buffer_len;
     1310  sp->ul = rl_undo_list;
     1311  sp->prompt = rl_prompt;
     1312
     1313  sp->rlstate = rl_readline_state;
     1314  sp->done = rl_done;
     1315  sp->kmap = _rl_keymap;
     1316
     1317  sp->lastfunc = rl_last_func;
     1318  sp->insmode = rl_insert_mode;
     1319  sp->edmode = rl_editing_mode;
     1320  sp->kseqlen = rl_key_sequence_length;
     1321  sp->inf = rl_instream;
     1322  sp->outf = rl_outstream;
     1323  sp->pendingin = rl_pending_input;
     1324  sp->macro = rl_executing_macro;
     1325
     1326  sp->catchsigs = rl_catch_signals;
     1327  sp->catchsigwinch = rl_catch_sigwinch;
     1328
     1329  return (0);
     1330}
     1331
     1332int
     1333rl_restore_state (sp)
     1334     struct readline_state *sp;
     1335{
     1336  if (sp == 0)
     1337    return -1;
     1338
     1339  rl_point = sp->point;
     1340  rl_end = sp->end;
     1341  rl_mark = sp->mark;
     1342  the_line = rl_line_buffer = sp->buffer;
     1343  rl_line_buffer_len = sp->buflen;
     1344  rl_undo_list = sp->ul;
     1345  rl_prompt = sp->prompt;
     1346
     1347  rl_readline_state = sp->rlstate;
     1348  rl_done = sp->done;
     1349  _rl_keymap = sp->kmap;
     1350
     1351  rl_last_func = sp->lastfunc;
     1352  rl_insert_mode = sp->insmode;
     1353  rl_editing_mode = sp->edmode;
     1354  rl_key_sequence_length = sp->kseqlen;
     1355  rl_instream = sp->inf;
     1356  rl_outstream = sp->outf;
     1357  rl_pending_input = sp->pendingin;
     1358  rl_executing_macro = sp->macro;
     1359
     1360  rl_catch_signals = sp->catchsigs;
     1361  rl_catch_sigwinch = sp->catchsigwinch;
     1362
     1363  return (0);
     1364}
  • lib/sh/shquote.c

    diff -Naur bash-4.3.orig/lib/sh/shquote.c bash-4.3/lib/sh/shquote.c
    old new  
    311311
    312312  return (0);
    313313}
     314
     315int
     316sh_contains_quotes (string)
     317     char *string;
     318{
     319  char *s;
     320
     321  for (s = string; s && *s; s++)
     322    {
     323      if (*s == '\'' || *s == '"' || *s == '\\')
     324        return 1;
     325    }
     326  return 0;
     327}
  • parse.y

    diff -Naur bash-4.3.orig/parse.y bash-4.3/parse.y
    old new  
    24242424         not already end in an EOF character.  */
    24252425      if (shell_input_line_terminator != EOF)
    24262426        {
    2427           if (shell_input_line_size < SIZE_MAX && shell_input_line_len > shell_input_line_size - 3)
     2427          if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size))
    24282428            shell_input_line = (char *)xrealloc (shell_input_line,
    24292429                                        1 + (shell_input_line_size += 2));
    24302430
     
    33983398         within a double-quoted ${...} construct "an even number of
    33993399         unescaped double-quotes or single-quotes, if any, shall occur." */
    34003400      /* This was changed in Austin Group Interp 221 */
    3401       if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
     3401      if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && dolbrace_state != DOLBRACE_QUOTE2 && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
    34023402        continue;
    34033403
    34043404      /* Could also check open == '`' if we want to parse grouping constructs
  • patchlevel.h

    diff -Naur bash-4.3.orig/patchlevel.h bash-4.3/patchlevel.h
    old new  
    2525   regexp `^#define[    ]*PATCHLEVEL', since that's what support/mkversion.sh
    2626   looks for to find the patch level (for the sccs version string). */
    2727
    28 #define PATCHLEVEL 0
     28#define PATCHLEVEL 18
    2929
    3030#endif /* _PATCHLEVEL_H_ */
  • pcomplete.c

    diff -Naur bash-4.3.orig/pcomplete.c bash-4.3/pcomplete.c
    old new  
    183183
    184184COMPSPEC *pcomp_curcs;
    185185const char *pcomp_curcmd;
     186const char *pcomp_curtxt;
    186187
    187188#ifdef DEBUG
    188189/* Debugging code */
     
    753754             quoted strings. */
    754755          dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
    755756        }
     757      /* Intended to solve a mismatched assumption by bash-completion.  If
     758         the text to be completed is empty, but bash-completion turns it into
     759         a quoted string ('') assuming that this code will dequote it before
     760         calling readline, do the dequoting. */
     761      else if (iscompgen && iscompleting &&
     762               pcomp_curtxt && *pcomp_curtxt == 0 &&
     763               text && (*text == '\'' || *text == '"') && text[1] == text[0] && text[2] == 0 &&
     764               rl_filename_dequoting_function)
     765        dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
     766      /* Another mismatched assumption by bash-completion.  If compgen is being
     767         run as part of bash-completion, and the argument to compgen is not
     768         the same as the word originally passed to the programmable completion
     769         code, dequote the argument if it has quote characters.  It's an
     770         attempt to detect when bash-completion is quoting its filename
     771         argument before calling compgen. */
     772      /* We could check whether gen_shell_function_matches is in the call
     773         stack by checking whether the gen-shell-function-matches tag is in
     774         the unwind-protect stack, but there's no function to do that yet.
     775         We could simply check whether we're executing in a function by
     776         checking variable_context, and may end up doing that. */
     777      else if (iscompgen && iscompleting && rl_filename_dequoting_function &&
     778               pcomp_curtxt && text &&
     779               STREQ (pcomp_curtxt, text) == 0 &&
     780               variable_context &&
     781               sh_contains_quotes (text))       /* guess */
     782        dfn = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
    756783      else
    757784        dfn = savestring (text);
    758785    }
     
    15221549     COMPSPEC **lastcs;
    15231550{
    15241551  COMPSPEC *cs, *oldcs;
    1525   const char *oldcmd;
     1552  const char *oldcmd, *oldtxt;
    15261553  STRINGLIST *ret;
    15271554
    15281555  cs = progcomp_search (ocmd);
     
    15451572
    15461573  oldcs = pcomp_curcs;
    15471574  oldcmd = pcomp_curcmd;
     1575  oldtxt = pcomp_curtxt;
    15481576
    15491577  pcomp_curcs = cs;
    15501578  pcomp_curcmd = cmd;
     1579  pcomp_curtxt = word;
    15511580
    15521581  ret = gen_compspec_completions (cs, cmd, word, start, end, foundp);
    15531582
    15541583  pcomp_curcs = oldcs;
    15551584  pcomp_curcmd = oldcmd;
     1585  pcomp_curtxt = oldtxt;
    15561586
    15571587  /* We need to conditionally handle setting *retryp here */
    15581588  if (retryp)
  • subst.c

    diff -Naur bash-4.3.orig/subst.c bash-4.3/subst.c
    old new  
    32483248  if (w->word == 0 || w->word[0] == '\0')
    32493249    return ((char *)NULL);
    32503250
     3251  expand_no_split_dollar_star = 1;
    32513252  w->flags |= W_NOSPLIT2;
    32523253  l = call_expand_word_internal (w, 0, 0, (int *)0, (int *)0);
     3254  expand_no_split_dollar_star = 0;
    32533255  if (l)
    32543256    {
    32553257      if (special == 0)                 /* LHS */
     
    78477849         We also want to make sure that splitting is done no matter what --
    78487850         according to POSIX.2, this expands to a list of the positional
    78497851         parameters no matter what IFS is set to. */
     7852      /* XXX - what to do when in a context where word splitting is not
     7853         performed? Even when IFS is not the default, posix seems to imply
     7854         that we behave like unquoted $* ?  Maybe we should use PF_NOSPLIT2
     7855         here. */
    78507856      temp = string_list_dollar_at (list, (pflags & PF_ASSIGNRHS) ? (quoted|Q_DOUBLE_QUOTES) : quoted);
    78517857
    78527858      tflag |= W_DOLLARAT;
     
    88168822  else
    88178823    {
    88188824      char *ifs_chars;
     8825      char *tstring;
    88198826
    88208827      ifs_chars = (quoted_dollar_at || has_dollar_at) ? ifs_value : (char *)NULL;
    88218828
     
    88308837         regardless of what else has happened to IFS since the expansion. */
    88318838      if (split_on_spaces)
    88328839        list = list_string (istring, " ", 1);   /* XXX quoted == 1? */
     8840      /* If we have $@ (has_dollar_at != 0) and we are in a context where we
     8841         don't want to split the result (W_NOSPLIT2), and we are not quoted,
     8842         we have already separated the arguments with the first character of
     8843         $IFS.  In this case, we want to return a list with a single word
     8844         with the separator possibly replaced with a space (it's what other
     8845         shells seem to do).
     8846         quoted_dollar_at is internal to this function and is set if we are
     8847         passed an argument that is unquoted (quoted == 0) but we encounter a
     8848         double-quoted $@ while expanding it. */
     8849      else if (has_dollar_at && quoted_dollar_at == 0 && ifs_chars && quoted == 0 && (word->flags & W_NOSPLIT2))
     8850        {
     8851          /* Only split and rejoin if we have to */
     8852          if (*ifs_chars && *ifs_chars != ' ')
     8853            {
     8854              list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
     8855              tstring = string_list (list);
     8856            }
     8857          else
     8858            tstring = istring;
     8859          tword = make_bare_word (tstring);
     8860          if (tstring != istring)
     8861            free (tstring);
     8862          goto set_word_flags;
     8863        }
    88338864      else if (has_dollar_at && ifs_chars)
    88348865        list = list_string (istring, *ifs_chars ? ifs_chars : " ", 1);
    88358866      else
    88368867        {
    88378868          tword = make_bare_word (istring);
     8869set_word_flags:
    88388870          if ((quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) || (quoted_state == WHOLLY_QUOTED))
    88398871            tword->flags |= W_QUOTED;
    88408872          if (word->flags & W_ASSIGNMENT)
  • bash-4.3

    diff -Naur bash-4.3.orig/test.c bash-4.3/test.c
    old new  
    646646      return (v && invisible_p (v) == 0 && var_isset (v) ? TRUE : FALSE);
    647647
    648648    case 'R':
    649       v = find_variable (arg);
    650       return (v && invisible_p (v) == 0 && var_isset (v) && nameref_p (v) ? TRUE : FALSE);
     649      v = find_variable_noref (arg);
     650      return ((v && invisible_p (v) == 0 && var_isset (v) && nameref_p (v)) ? TRUE : FALSE);
    651651    }
    652652
    653653  /* We can't actually get here, but this shuts up gcc. */
     
    723723    case 'o': case 'p': case 'r': case 's': case 't':
    724724    case 'u': case 'v': case 'w': case 'x': case 'z':
    725725    case 'G': case 'L': case 'O': case 'S': case 'N':
     726    case 'R':
    726727      return (1);
    727728    }
    728729
  • bash-4.3

    diff -Naur bash-4.3.orig/trap.c bash-4.3/trap.c
    old new  
    920920      subst_assign_varlist = 0;
    921921
    922922#if defined (JOB_CONTROL)
    923       save_pipeline (1);        /* XXX only provides one save level */
     923      if (sig != DEBUG_TRAP)    /* run_debug_trap does this */
     924        save_pipeline (1);      /* XXX only provides one save level */
    924925#endif
    925926
    926927      /* If we're in a function, make sure return longjmps come here, too. */
     
    940941      trap_exit_value = last_command_exit_value;
    941942
    942943#if defined (JOB_CONTROL)
    943       restore_pipeline (1);
     944      if (sig != DEBUG_TRAP)    /* run_debug_trap does this */
     945        restore_pipeline (1);
    944946#endif
    945947
    946948      subst_assign_varlist = save_subst_varlist;
  • variables.c

    diff -Naur bash-4.3.orig/variables.c bash-4.3/variables.c
    old new  
    21972197  /* local foo; local foo;  is a no-op. */
    21982198  old_var = find_variable (name);
    21992199  if (old_var && local_p (old_var) && old_var->context == variable_context)
    2200     {
    2201       VUNSETATTR (old_var, att_invisible);      /* XXX */
    2202       return (old_var);
    2203     }
     2200    return (old_var);
    22042201
    22052202  was_tmpvar = old_var && tempvar_p (old_var);
    22062203  /* If we're making a local variable in a shell function, the temporary env
  • y.tab.c

    diff -Naur bash-4.3.orig/y.tab.c bash-4.3/y.tab.c
    old new  
    47364736         not already end in an EOF character.  */
    47374737      if (shell_input_line_terminator != EOF)
    47384738        {
    4739           if (shell_input_line_size < SIZE_MAX && shell_input_line_len > shell_input_line_size - 3)
     4739          if (shell_input_line_size < SIZE_MAX-3 && (shell_input_line_len+3 > shell_input_line_size))
    47404740            shell_input_line = (char *)xrealloc (shell_input_line,
    47414741                                        1 + (shell_input_line_size += 2));
    47424742
     
    57105710         within a double-quoted ${...} construct "an even number of
    57115711         unescaped double-quotes or single-quotes, if any, shall occur." */
    57125712      /* This was changed in Austin Group Interp 221 */
    5713       if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
     5713      if MBTEST(posixly_correct && shell_compatibility_level > 41 && dolbrace_state != DOLBRACE_QUOTE && dolbrace_state != DOLBRACE_QUOTE2 && (flags & P_DQUOTE) && (flags & P_DOLBRACE) && ch == '\'')
    57145714        continue;
    57155715
    57165716      /* Could also check open == '`' if we want to parse grouping constructs
Note: See TracBrowser for help on using the repository browser.