source: patches/bash-4.0-branch_update-2.patch@ e963bf3

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since e963bf3 was 7a39f29, checked in by Jim Gifford <clfs@…>, 16 years ago

Updated Bash Branch Update Patch to -2

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

    Submitted By: Jim Gifford (jim at cross-lfs dot org)
    Date: 03-02-2009
    Initial Package Version: 4.0
    Origin: Upstream
    Upstream Status: Applied
    Description: Fixes from the Mailing List - Bash Bug 
                 http://lists.gnu.org/archive/html/bug-bash/2009-02/index.html
    
    diff -Naur bash-4.0.orig/arrayfunc.c bash-4.0/arrayfunc.c
    old new  
    604604    }
    605605}
    606606
    607 /* This function assumes s[i] == '['; returns with s[ret] == ']' if
    608    an array subscript is correctly parsed. */
    609 int
    610 skipsubscript (s, i)
    611      const char *s;
    612      int i;
    613 {
    614   int count, c;
    615 #if defined (HANDLE_MULTIBYTE)
    616   mbstate_t state, state_bak;
    617   size_t slength, mblength;
    618 #endif
    619 
    620 #if defined (HANDLE_MULTIBYTE)
    621   memset (&state, '\0', sizeof (mbstate_t));
    622   slength = strlen (s + i);
    623 #endif
    624  
    625   count = 1;
    626   while (count)
    627     {
    628       /* Advance one (possibly multibyte) character in S starting at I. */
    629 #if defined (HANDLE_MULTIBYTE)
    630       if (MB_CUR_MAX > 1)
    631         {
    632           state_bak = state;
    633           mblength = mbrlen (s + i, slength, &state);
    634 
    635           if (MB_INVALIDCH (mblength))
    636             {
    637               state = state_bak;
    638               i++;
    639               slength--;
    640             }
    641           else if (MB_NULLWCH (mblength))
    642             return i;
    643           else
    644             {
    645               i += mblength;
    646               slength -= mblength;
    647             }
    648         }
    649       else
    650 #endif
    651       ++i;
    652 
    653       c = s[i];
    654 
    655       if (c == 0)
    656         break;
    657       else if (c == '[')
    658         count++;
    659       else if (c == ']')
    660         count--;
    661     }
    662 
    663   return i;
    664 }
     607/* skipsubscript moved to subst.c to use private functions. 2009/02/24. */
    665608
    666609/* This function is called with SUB pointing to just after the beginning
    667610   `[' of an array subscript and removes the array element to which SUB
  • builtins/declare.def

    diff -Naur bash-4.0.orig/builtins/declare.def bash-4.0/builtins/declare.def
    old new  
    287287              name[offset - 1] = '\0';
    288288            }
    289289        }
     290      else if (legal_identifier (name) == 0)
     291        {
     292          sh_invalidid (name);
     293          assign_error++;
     294          NEXT_VARIABLE ();
     295        }
    290296      else
    291297        value = "";
    292298
     
    295301      subscript_start = (char *)NULL;
    296302      if (t = strchr (name, '['))       /* ] */
    297303        {
     304          /* If offset != 0 we have already validated any array reference */
     305          if (offset == 0 && valid_array_reference (name) == 0)
     306            {
     307              sh_invalidid (name);
     308              assign_error++;
     309              NEXT_VARIABLE ();
     310            }
    298311          subscript_start = t;
    299312          *t = '\0';
    300313          making_array_special = 1;
     
    484497            }
    485498          /* declare -a name[[n]] or declare name[n] makes name an indexed
    486499             array variable. */
    487           else if ((making_array_special || (flags_on & att_array)) && array_p (var) == 0)
     500          else if ((making_array_special || (flags_on & att_array)) && array_p (var) == 0 && assoc_p (var) == 0)
    488501            var = convert_var_to_array (var);
    489502#endif /* ARRAY_VARS */
    490503
  • builtins/exit.def

    diff -Naur bash-4.0.orig/builtins/exit.def bash-4.0/builtins/exit.def
    old new  
    113113      for (i = stopmsg = 0; i < js.j_jobslots; i++)
    114114        if (jobs[i] && STOPPED (i))
    115115          stopmsg = JSTOPPED;
    116         else if (check_jobs_at_exit && stopmsg == 0 && RUNNING (i))
     116        else if (check_jobs_at_exit && stopmsg == 0 && jobs[i] && RUNNING (i))
    117117          stopmsg = JRUNNING;
    118118
    119119      if (stopmsg == JSTOPPED)
  • builtins/read.def

    diff -Naur bash-4.0.orig/builtins/read.def bash-4.0/builtins/read.def
    old new  
    369369      code = setjmp (alrmbuf);
    370370      if (code)
    371371        {
    372 #if 0
     372          /* Tricky.  The top of the unwind-protect stack is the free of
     373             input_string.  We want to run all the rest and use input_string,
     374             so we have to remove it from the stack. */
     375          remove_unwind_protect ();
    373376          run_unwind_frame ("read_builtin");
    374           return (EXECUTION_FAILURE);
    375 #else
    376377          input_string[i] = '\0';       /* make sure it's terminated */
    377           retval = 128+SIGALRM;;
     378          retval = 128+SIGALRM;
    378379          goto assign_vars;
    379 #endif
    380380        }
    381381      old_alrm = set_signal_handler (SIGALRM, sigalrm);
    382382      add_unwind_protect (reset_alarm, (char *)NULL);
  • parse.y

    diff -Naur bash-4.0.orig/parse.y bash-4.0/parse.y
    old new  
    16151615{
    16161616  int *ret;
    16171617
    1618   ret = (int *)xmalloc (3 * sizeof (int));
     1618  ret = (int *)xmalloc (4 * sizeof (int));
    16191619  ret[0] = last_read_token;
    16201620  ret[1] = token_before_that;
    16211621  ret[2] = two_tokens_ago;
     1622  ret[3] = current_token;
    16221623  return ret;
    16231624}
    16241625
     
    16311632  last_read_token = ts[0];
    16321633  token_before_that = ts[1];
    16331634  two_tokens_ago = ts[2];
     1635  current_token = ts[3];
    16341636}
    16351637
    16361638/*
     
    26682670  FREE (word_desc_to_read);
    26692671  word_desc_to_read = (WORD_DESC *)NULL;
    26702672
     2673  current_token = '\n';         /* XXX */
    26712674  last_read_token = '\n';
    26722675  token_to_read = '\n';
    26732676}
     
    29152918#define P_DQUOTE        0x04
    29162919#define P_COMMAND       0x08    /* parsing a command, so look for comments */
    29172920#define P_BACKQUOTE     0x10    /* parsing a backquoted command substitution */
     2921#define P_ARRAYSUB      0x20    /* parsing a [...] array subscript for assignment */
    29182922
    29192923/* Lexical state while parsing a grouping construct or $(...). */
    29202924#define LEX_WASDOL      0x001
     
    31293133              APPEND_NESTRET ();
    31303134              FREE (nestret);
    31313135            }
     3136          else if ((flags & P_ARRAYSUB) && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '['))      /* ) } ] */
     3137            goto parse_dollar_word;
    31323138        }
    31333139      /* Parse an old-style command substitution within double quotes as a
    31343140         single word. */
     
    31453151      else if MBTEST(open != '`' && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '['))     /* ) } ] */
    31463152        /* check for $(), $[], or ${} inside quoted string. */
    31473153        {
     3154parse_dollar_word:
    31483155          if (open == ch)       /* undo previous increment */
    31493156            count--;
    31503157          if (ch == '(')                /* ) */
     
    33063313        }
    33073314
    33083315      /* Meta-characters that can introduce a reserved word.  Not perfect yet. */
    3309       if MBTEST((tflags & LEX_RESWDOK) == 0 && (tflags & LEX_CKCASE) && (tflags & LEX_INCOMMENT) == 0 && shellmeta(ch))
     3316      if MBTEST((tflags & LEX_PASSNEXT) == 0 && (tflags & LEX_RESWDOK) == 0 && (tflags & LEX_CKCASE) && (tflags & LEX_INCOMMENT) == 0 && shellmeta(ch))
    33103317        {
    33113318          /* Add this character. */
    33123319          RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
     
    33943401                }
    33953402              else
    33963403                shell_ungetc (peekc);
    3397               tflags |= LEX_HEREDELIM;
    3398               lex_firstind = -1;
     3404              if (peekc != '<')
     3405                {
     3406                  tflags |= LEX_HEREDELIM;
     3407                  lex_firstind = -1;
     3408                }
    33993409              continue;
    34003410            }
    34013411          else
     
    42484258                     ((token_index > 0 && assignment_acceptable (last_read_token) && token_is_ident (token, token_index)) ||
    42494259                      (token_index == 0 && (parser_state&PST_COMPASSIGN))))
    42504260        {
    4251           ttok = parse_matched_pair (cd, '[', ']', &ttoklen, 0);
     4261          ttok = parse_matched_pair (cd, '[', ']', &ttoklen, P_ARRAYSUB);
    42524262          if (ttok == &matched_pair_error)
    42534263            return -1;          /* Bail immediately. */
    42544264          RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
     
    44494459    case '}':           /* XXX */
    44504460    case AND_AND:
    44514461    case BANG:
     4462    case BAR_AND:
    44524463    case DO:
    44534464    case DONE:
    44544465    case ELIF:
  • pcomplete.c

    diff -Naur bash-4.0.orig/pcomplete.c bash-4.0/pcomplete.c
    old new  
    10321032  cmdlist = build_arg_list (funcname, text, lwords, cw);
    10331033
    10341034  pps = &ps;
     1035  save_parser_state (pps);
    10351036  begin_unwind_frame ("gen-shell-function-matches");
    10361037  add_unwind_protect (restore_parser_state, (char *)pps);
    10371038  add_unwind_protect (dispose_words, (char *)cmdlist);
  • subst.c

    diff -Naur bash-4.0.orig/subst.c bash-4.0/subst.c
    old new  
    222222static int skip_double_quoted __P((char *, size_t, int));
    223223static char *extract_delimited_string __P((char *, int *, char *, char *, char *, int));
    224224static char *extract_dollar_brace_string __P((char *, int *, int, int));
     225static int skip_matched_pair __P((const char *, int, int, int, int));
    225226
    226227static char *pos_params __P((char *, int, int, int));
    227228
     
    13741375
    13751376#define CQ_RETURN(x) do { no_longjmp_on_fatal_error = 0; return (x); } while (0)
    13761377
     1378/* This function assumes s[i] == open; returns with s[ret] == close; used to
     1379   parse array subscripts.  FLAGS currently unused. */
     1380static int
     1381skip_matched_pair (string, start, open, close, flags)
     1382     const char *string;
     1383     int start, open, close, flags;
     1384{
     1385  int i, pass_next, backq, si, c, count;
     1386  size_t slen;
     1387  char *temp, *ss;
     1388  DECLARE_MBSTATE;
     1389
     1390  slen = strlen (string + start) + start;
     1391  no_longjmp_on_fatal_error = 1;
     1392
     1393  i = start + 1;                /* skip over leading bracket */
     1394  count = 1;
     1395  pass_next = backq = 0;
     1396  ss = (char *)string;
     1397  while (c = string[i])
     1398    {
     1399      if (pass_next)
     1400        {
     1401          pass_next = 0;
     1402          if (c == 0)
     1403            CQ_RETURN(i);
     1404          ADVANCE_CHAR (string, slen, i);
     1405          continue;
     1406        }
     1407      else if (c == '\\')
     1408        {
     1409          pass_next = 1;
     1410          i++;
     1411          continue;
     1412        }
     1413      else if (backq)
     1414        {
     1415          if (c == '`')
     1416            backq = 0;
     1417          ADVANCE_CHAR (string, slen, i);
     1418          continue;
     1419        }
     1420      else if (c == '`')
     1421        {
     1422          backq = 1;
     1423          i++;
     1424          continue;
     1425        }
     1426      else if (c == open)
     1427        {
     1428          count++;
     1429          i++;
     1430          continue;
     1431        }
     1432      else if (c == close)
     1433        {
     1434          count--;
     1435          if (count == 0)
     1436            break;
     1437          i++;
     1438          continue;
     1439        }
     1440      else if (c == '\'' || c == '"')
     1441        {
     1442          i = (c == '\'') ? skip_single_quoted (ss, slen, ++i)
     1443                          : skip_double_quoted (ss, slen, ++i);
     1444          /* no increment, the skip functions increment past the closing quote. */
     1445        }
     1446      else if (c == '$' && (string[i+1] == LPAREN || string[i+1] == LBRACE))
     1447        {
     1448          si = i + 2;
     1449          if (string[si] == '\0')
     1450            CQ_RETURN(si);
     1451
     1452          if (string[i+1] == LPAREN)
     1453            temp = extract_delimited_string (ss, &si, "$(", "(", ")", SX_NOALLOC|SX_COMMAND); /* ) */
     1454          else
     1455            temp = extract_dollar_brace_string (ss, &si, 0, SX_NOALLOC);
     1456          i = si;
     1457          if (string[i] == '\0')        /* don't increment i past EOS in loop */
     1458            break;
     1459          i++;
     1460          continue;
     1461        }
     1462      else
     1463        ADVANCE_CHAR (string, slen, i);
     1464    }
     1465
     1466  CQ_RETURN(i);
     1467}
     1468
     1469#if defined (ARRAY_VARS)
     1470int
     1471skipsubscript (string, start)
     1472     const char *string;
     1473     int start;
     1474{
     1475  return (skip_matched_pair (string, start, '[', ']', 0));
     1476}
     1477#endif
     1478
    13771479/* Skip characters in STRING until we find a character in DELIMS, and return
    13781480   the index of that character.  START is the index into string at which we
    13791481   begin.  This is similar in spirit to strpbrk, but it returns an index into
Note: See TracBrowser for help on using the repository browser.