source: clfs-sysroot/patches/bash-4.0-branch_update-3.patch@ 5a30b49

Last change on this file since 5a30b49 was f91445c, checked in by Joe Ciccone <jciccone@…>, 16 years ago

Updated Bash to 4.0.

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

    Submitted By: Jim Gifford (jim at cross-lfs dot org)
    Date: 03-09-2009
    Initial Package Version: 4.0
    Origin: Upstream
    Upstream Status: Applied
    Description: Contains all upstream patches up to 4.0-010
    
    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  
    295295      subscript_start = (char *)NULL;
    296296      if (t = strchr (name, '['))       /* ] */
    297297        {
     298          /* If offset != 0 we have already validated any array reference */
     299          if (offset == 0 && valid_array_reference (name) == 0)
     300            {
     301              sh_invalidid (name);
     302              assign_error++;
     303              NEXT_VARIABLE ();
     304            }
    298305          subscript_start = t;
    299306          *t = '\0';
    300307          making_array_special = 1;
     
    484491            }
    485492          /* declare -a name[[n]] or declare name[n] makes name an indexed
    486493             array variable. */
    487           else if ((making_array_special || (flags_on & att_array)) && array_p (var) == 0)
     494          else if ((making_array_special || (flags_on & att_array)) && array_p (var) == 0 && assoc_p (var) == 0)
    488495            var = convert_var_to_array (var);
    489496#endif /* ARRAY_VARS */
    490497
  • 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
     
    29272931#define LEX_INHEREDOC   0x080
    29282932#define LEX_HEREDELIM   0x100           /* reading here-doc delimiter */
    29292933#define LEX_STRIPDOC    0x200           /* <<- strip tabs from here doc delim */
     2934#define LEX_INWORD      0x400
    29302935
    29312936#define COMSUB_META(ch)         ((ch) == ';' || (ch) == '&' || (ch) == '|')
    29322937
     
    31293134              APPEND_NESTRET ();
    31303135              FREE (nestret);
    31313136            }
     3137          else if ((flags & P_ARRAYSUB) && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '['))      /* ) } ] */
     3138            goto parse_dollar_word;
    31323139        }
    31333140      /* Parse an old-style command substitution within double quotes as a
    31343141         single word. */
     
    31453152      else if MBTEST(open != '`' && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '['))     /* ) } ] */
    31463153        /* check for $(), $[], or ${} inside quoted string. */
    31473154        {
     3155parse_dollar_word:
    31483156          if (open == ch)       /* undo previous increment */
    31493157            count--;
    31503158          if (ch == '(')                /* ) */
     
    31793187     int open, close;
    31803188     int *lenp, flags;
    31813189{
    3182   int count, ch, peekc, tflags, lex_rwlen, lex_firstind;
     3190  int count, ch, peekc, tflags, lex_rwlen, lex_wlen, lex_firstind;
    31833191  int nestlen, ttranslen, start_lineno;
    31843192  char *ret, *nestret, *ttrans, *heredelim;
    31853193  int retind, retsize, rflags, hdlen;
     
    32003208  retind = 0;
    32013209
    32023210  start_lineno = line_number;
    3203   lex_rwlen = 0;
     3211  lex_rwlen = lex_wlen = 0;
    32043212
    32053213  heredelim = 0;
    32063214  lex_firstind = -1;
     
    32673275          continue;
    32683276        }
    32693277
     3278      if (tflags & LEX_PASSNEXT)                /* last char was backslash */
     3279        {
     3280/*itrace("parse_comsub:%d: lex_passnext -> 0 ch = `%c' (%d)", line_number, ch, __LINE__);*/
     3281          tflags &= ~LEX_PASSNEXT;
     3282          if (qc != '\'' && ch == '\n') /* double-quoted \<newline> disappears. */
     3283            {
     3284              if (retind > 0)
     3285                retind--;       /* swallow previously-added backslash */
     3286              continue;
     3287            }
     3288
     3289          RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64);
     3290          if MBTEST(ch == CTLESC || ch == CTLNUL)
     3291            ret[retind++] = CTLESC;
     3292          ret[retind++] = ch;
     3293          continue;
     3294        }
     3295
     3296      /* If this is a shell break character, we are not in a word.  If not,
     3297         we either start or continue a word. */
     3298      if MBTEST(shellbreak (ch))
     3299        {
     3300          tflags &= ~LEX_INWORD;
     3301/*itrace("parse_comsub:%d: lex_inword -> 0 ch = `%c' (%d)", line_number, ch, __LINE__);*/
     3302        }
     3303      else
     3304        {
     3305          if (tflags & LEX_INWORD)
     3306            {
     3307              lex_wlen++;
     3308/*itrace("parse_comsub:%d: lex_inword == 1 ch = `%c' lex_wlen = %d (%d)", line_number, ch, lex_wlen, __LINE__);*/
     3309            }         
     3310          else
     3311            {
     3312/*itrace("parse_comsub:%d: lex_inword -> 1 ch = `%c' (%d)", line_number, ch, __LINE__);*/
     3313              tflags |= LEX_INWORD;
     3314              lex_wlen = 0;
     3315            }
     3316        }
     3317
    32703318      /* Skip whitespace */
    32713319      if MBTEST(shellblank (ch) && lex_rwlen == 0)
    32723320        {
     
    33643412}               
    33653413              tflags &= ~LEX_RESWDOK;
    33663414            }
    3367           else if (shellbreak (ch) == 0)
     3415          else if MBTEST((tflags & LEX_CKCOMMENT) && ch == '#' && (lex_rwlen == 0 || ((tflags & LEX_INWORD) && lex_wlen == 0)))
     3416            ;   /* don't modify LEX_RESWDOK if we're starting a comment */
     3417          else if MBTEST((tflags & LEX_INCASE) && ch != '\n')
     3418            /* If we can read a reserved word and we're in case, we're at the
     3419               point where we can read a new pattern list or an esac.  We
     3420               handle the esac case above.  If we read a newline, we want to
     3421               leave LEX_RESWDOK alone.  If we read anything else, we want to
     3422               turn off LEX_RESWDOK, since we're going to read a pattern list. */
    33683423{
    3369               tflags &= ~LEX_RESWDOK;
     3424            tflags &= ~LEX_RESWDOK;
     3425/*itrace("parse_comsub:%d: lex_incase == 1 found `%c', lex_reswordok -> 0", line_number, ch);*/
     3426}
     3427          else if MBTEST(shellbreak (ch) == 0)
     3428{
     3429            tflags &= ~LEX_RESWDOK;
    33703430/*itrace("parse_comsub:%d: found `%c', lex_reswordok -> 0", line_number, ch);*/
    33713431}
    33723432        }
     
    33943454                }
    33953455              else
    33963456                shell_ungetc (peekc);
    3397               tflags |= LEX_HEREDELIM;
    3398               lex_firstind = -1;
     3457              if (peekc != '<')
     3458                {
     3459                  tflags |= LEX_HEREDELIM;
     3460                  lex_firstind = -1;
     3461                }
    33993462              continue;
    34003463            }
    34013464          else
    3402             ch = peekc;         /* fall through and continue XXX - this skips comments if peekc == '#' */
     3465            ch = peekc;         /* fall through and continue XXX */
    34033466        }
    3404       /* Not exactly right yet, should handle shell metacharacters, too.  If
    3405          any changes are made to this test, make analogous changes to subst.c:
    3406          extract_delimited_string(). */
    3407       else if MBTEST((tflags & LEX_CKCOMMENT) && (tflags & LEX_INCOMMENT) == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || shellblank (ret[retind - 1])))
     3467      else if MBTEST((tflags & LEX_CKCOMMENT) && (tflags & LEX_INCOMMENT) == 0 && ch == '#' && (((tflags & LEX_RESWDOK) && lex_rwlen == 0) || ((tflags & LEX_INWORD) && lex_wlen == 0)))
     3468{
     3469/*itrace("parse_comsub:%d: lex_incomment -> 1 (%d)", line_number, __LINE__);*/
    34083470        tflags |= LEX_INCOMMENT;
     3471}
    34093472
    3410       if (tflags & LEX_PASSNEXT)                /* last char was backslash */
    3411         {
    3412           tflags &= ~LEX_PASSNEXT;
    3413           if (qc != '\'' && ch == '\n') /* double-quoted \<newline> disappears. */
    3414             {
    3415               if (retind > 0)
    3416                 retind--;       /* swallow previously-added backslash */
    3417               continue;
    3418             }
    3419 
    3420           RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64);
    3421           if MBTEST(ch == CTLESC || ch == CTLNUL)
    3422             ret[retind++] = CTLESC;
    3423           ret[retind++] = ch;
    3424           continue;
    3425         }
    3426       else if MBTEST(ch == CTLESC || ch == CTLNUL)      /* special shell escapes */
     3473      if MBTEST(ch == CTLESC || ch == CTLNUL)   /* special shell escapes */
    34273474        {
    34283475          RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64);
    34293476          ret[retind++] = CTLESC;
     
    42484295                     ((token_index > 0 && assignment_acceptable (last_read_token) && token_is_ident (token, token_index)) ||
    42494296                      (token_index == 0 && (parser_state&PST_COMPASSIGN))))
    42504297        {
    4251           ttok = parse_matched_pair (cd, '[', ']', &ttoklen, 0);
     4298          ttok = parse_matched_pair (cd, '[', ']', &ttoklen, P_ARRAYSUB);
    42524299          if (ttok == &matched_pair_error)
    42534300            return -1;          /* Bail immediately. */
    42544301          RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2,
     
    44494496    case '}':           /* XXX */
    44504497    case AND_AND:
    44514498    case BANG:
     4499    case BAR_AND:
    44524500    case DO:
    44534501    case DONE:
    44544502    case ELIF:
  • patchlevel.h

    diff -Naur bash-4.0.orig/patchlevel.h bash-4.0/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 10
    2929
    3030#endif /* _PATCHLEVEL_H_ */
  • 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.