source:
patches/bash-4.0-branch_update-1.patch@
82c4aa0
Last change on this file since 82c4aa0 was c822ddc, checked in by , 16 years ago | |
---|---|
|
|
File size: 9.9 KB |
-
arrayfunc.c
Submitted By: Jim Gifford (jim at cross-lfs dot org) Date: 01-08-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 604 604 } 605 605 } 606 606 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. */ 665 608 666 609 /* This function is called with SUB pointing to just after the beginning 667 610 `[' 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 287 287 name[offset - 1] = '\0'; 288 288 } 289 289 } 290 else if (legal_identifier (name) == 0) 291 { 292 sh_invalidid (name); 293 assign_error++; 294 NEXT_VARIABLE (); 295 } 290 296 else 291 297 value = ""; 292 298 … … 295 301 subscript_start = (char *)NULL; 296 302 if (t = strchr (name, '[')) /* ] */ 297 303 { 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 } 298 311 subscript_start = t; 299 312 *t = '\0'; 300 313 making_array_special = 1; … … 484 497 } 485 498 /* declare -a name[[n]] or declare name[n] makes name an indexed 486 499 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) 488 501 var = convert_var_to_array (var); 489 502 #endif /* ARRAY_VARS */ 490 503 -
builtins/exit.def
diff -Naur bash-4.0.orig/builtins/exit.def bash-4.0/builtins/exit.def
old new 113 113 for (i = stopmsg = 0; i < js.j_jobslots; i++) 114 114 if (jobs[i] && STOPPED (i)) 115 115 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)) 117 117 stopmsg = JRUNNING; 118 118 119 119 if (stopmsg == JSTOPPED) -
parse.y
diff -Naur bash-4.0.orig/parse.y bash-4.0/parse.y
old new 1615 1615 { 1616 1616 int *ret; 1617 1617 1618 ret = (int *)xmalloc ( 3* sizeof (int));1618 ret = (int *)xmalloc (4 * sizeof (int)); 1619 1619 ret[0] = last_read_token; 1620 1620 ret[1] = token_before_that; 1621 1621 ret[2] = two_tokens_ago; 1622 ret[3] = current_token; 1622 1623 return ret; 1623 1624 } 1624 1625 … … 1631 1632 last_read_token = ts[0]; 1632 1633 token_before_that = ts[1]; 1633 1634 two_tokens_ago = ts[2]; 1635 current_token = ts[3]; 1634 1636 } 1635 1637 1636 1638 /* … … 2668 2670 FREE (word_desc_to_read); 2669 2671 word_desc_to_read = (WORD_DESC *)NULL; 2670 2672 2673 current_token = '\n'; /* XXX */ 2671 2674 last_read_token = '\n'; 2672 2675 token_to_read = '\n'; 2673 2676 } … … 2915 2918 #define P_DQUOTE 0x04 2916 2919 #define P_COMMAND 0x08 /* parsing a command, so look for comments */ 2917 2920 #define P_BACKQUOTE 0x10 /* parsing a backquoted command substitution */ 2921 #define P_ARRAYSUB 0x20 /* parsing a [...] array subscript for assignment */ 2918 2922 2919 2923 /* Lexical state while parsing a grouping construct or $(...). */ 2920 2924 #define LEX_WASDOL 0x001 … … 3129 3133 APPEND_NESTRET (); 3130 3134 FREE (nestret); 3131 3135 } 3136 else if ((flags & P_ARRAYSUB) && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ 3137 goto parse_dollar_word; 3132 3138 } 3133 3139 /* Parse an old-style command substitution within double quotes as a 3134 3140 single word. */ … … 3145 3151 else if MBTEST(open != '`' && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ 3146 3152 /* check for $(), $[], or ${} inside quoted string. */ 3147 3153 { 3154 parse_dollar_word: 3148 3155 if (open == ch) /* undo previous increment */ 3149 3156 count--; 3150 3157 if (ch == '(') /* ) */ … … 3306 3313 } 3307 3314 3308 3315 /* 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)) 3310 3317 { 3311 3318 /* Add this character. */ 3312 3319 RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64); … … 3394 3401 } 3395 3402 else 3396 3403 shell_ungetc (peekc); 3397 tflags |= LEX_HEREDELIM; 3398 lex_firstind = -1; 3404 if (peekc != '<') 3405 { 3406 tflags |= LEX_HEREDELIM; 3407 lex_firstind = -1; 3408 } 3399 3409 continue; 3400 3410 } 3401 3411 else … … 4248 4258 ((token_index > 0 && assignment_acceptable (last_read_token) && token_is_ident (token, token_index)) || 4249 4259 (token_index == 0 && (parser_state&PST_COMPASSIGN)))) 4250 4260 { 4251 ttok = parse_matched_pair (cd, '[', ']', &ttoklen, 0);4261 ttok = parse_matched_pair (cd, '[', ']', &ttoklen, P_ARRAYSUB); 4252 4262 if (ttok == &matched_pair_error) 4253 4263 return -1; /* Bail immediately. */ 4254 4264 RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2, … … 4449 4459 case '}': /* XXX */ 4450 4460 case AND_AND: 4451 4461 case BANG: 4462 case BAR_AND: 4452 4463 case DO: 4453 4464 case DONE: 4454 4465 case ELIF: -
pcomplete.c
diff -Naur bash-4.0.orig/pcomplete.c bash-4.0/pcomplete.c
old new 1032 1032 cmdlist = build_arg_list (funcname, text, lwords, cw); 1033 1033 1034 1034 pps = &ps; 1035 save_parser_state (pps); 1035 1036 begin_unwind_frame ("gen-shell-function-matches"); 1036 1037 add_unwind_protect (restore_parser_state, (char *)pps); 1037 1038 add_unwind_protect (dispose_words, (char *)cmdlist); -
subst.c
diff -Naur bash-4.0.orig/subst.c bash-4.0/subst.c
old new 222 222 static int skip_double_quoted __P((char *, size_t, int)); 223 223 static char *extract_delimited_string __P((char *, int *, char *, char *, char *, int)); 224 224 static char *extract_dollar_brace_string __P((char *, int *, int, int)); 225 static int skip_matched_pair __P((const char *, int, int, int, int)); 225 226 226 227 static char *pos_params __P((char *, int, int, int)); 227 228 … … 1374 1375 1375 1376 #define CQ_RETURN(x) do { no_longjmp_on_fatal_error = 0; return (x); } while (0) 1376 1377 1378 /* This function assumes s[i] == open; returns with s[ret] == close; used to 1379 parse array subscripts. FLAGS currently unused. */ 1380 static int 1381 skip_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) 1470 int 1471 skipsubscript (string, start) 1472 const char *string; 1473 int start; 1474 { 1475 return (skip_matched_pair (string, start, '[', ']', 0)); 1476 } 1477 #endif 1478 1377 1479 /* Skip characters in STRING until we find a character in DELIMS, and return 1378 1480 the index of that character. START is the index into string at which we 1379 1481 begin. This is similar in spirit to strpbrk, but it returns an index into
Note:
See TracBrowser
for help on using the repository browser.