source:
clfs-sysroot/patches/bash-4.0-branch_update-3.patch@
bad66e0
Last change on this file since bad66e0 was f91445c, checked in by , 16 years ago | |
---|---|
|
|
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 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 295 295 subscript_start = (char *)NULL; 296 296 if (t = strchr (name, '[')) /* ] */ 297 297 { 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 } 298 305 subscript_start = t; 299 306 *t = '\0'; 300 307 making_array_special = 1; … … 484 491 } 485 492 /* declare -a name[[n]] or declare name[n] makes name an indexed 486 493 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) 488 495 var = convert_var_to_array (var); 489 496 #endif /* ARRAY_VARS */ 490 497 -
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) -
builtins/read.def
diff -Naur bash-4.0.orig/builtins/read.def bash-4.0/builtins/read.def
old new 369 369 code = setjmp (alrmbuf); 370 370 if (code) 371 371 { 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 (); 373 376 run_unwind_frame ("read_builtin"); 374 return (EXECUTION_FAILURE);375 #else376 377 input_string[i] = '\0'; /* make sure it's terminated */ 377 retval = 128+SIGALRM; ;378 retval = 128+SIGALRM; 378 379 goto assign_vars; 379 #endif380 380 } 381 381 old_alrm = set_signal_handler (SIGALRM, sigalrm); 382 382 add_unwind_protect (reset_alarm, (char *)NULL); -
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 … … 2927 2931 #define LEX_INHEREDOC 0x080 2928 2932 #define LEX_HEREDELIM 0x100 /* reading here-doc delimiter */ 2929 2933 #define LEX_STRIPDOC 0x200 /* <<- strip tabs from here doc delim */ 2934 #define LEX_INWORD 0x400 2930 2935 2931 2936 #define COMSUB_META(ch) ((ch) == ';' || (ch) == '&' || (ch) == '|') 2932 2937 … … 3129 3134 APPEND_NESTRET (); 3130 3135 FREE (nestret); 3131 3136 } 3137 else if ((flags & P_ARRAYSUB) && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ 3138 goto parse_dollar_word; 3132 3139 } 3133 3140 /* Parse an old-style command substitution within double quotes as a 3134 3141 single word. */ … … 3145 3152 else if MBTEST(open != '`' && (tflags & LEX_WASDOL) && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */ 3146 3153 /* check for $(), $[], or ${} inside quoted string. */ 3147 3154 { 3155 parse_dollar_word: 3148 3156 if (open == ch) /* undo previous increment */ 3149 3157 count--; 3150 3158 if (ch == '(') /* ) */ … … 3179 3187 int open, close; 3180 3188 int *lenp, flags; 3181 3189 { 3182 int count, ch, peekc, tflags, lex_rwlen, lex_ firstind;3190 int count, ch, peekc, tflags, lex_rwlen, lex_wlen, lex_firstind; 3183 3191 int nestlen, ttranslen, start_lineno; 3184 3192 char *ret, *nestret, *ttrans, *heredelim; 3185 3193 int retind, retsize, rflags, hdlen; … … 3200 3208 retind = 0; 3201 3209 3202 3210 start_lineno = line_number; 3203 lex_rwlen = 0;3211 lex_rwlen = lex_wlen = 0; 3204 3212 3205 3213 heredelim = 0; 3206 3214 lex_firstind = -1; … … 3267 3275 continue; 3268 3276 } 3269 3277 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 3270 3318 /* Skip whitespace */ 3271 3319 if MBTEST(shellblank (ch) && lex_rwlen == 0) 3272 3320 { … … 3364 3412 } 3365 3413 tflags &= ~LEX_RESWDOK; 3366 3414 } 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. */ 3368 3423 { 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; 3370 3430 /*itrace("parse_comsub:%d: found `%c', lex_reswordok -> 0", line_number, ch);*/ 3371 3431 } 3372 3432 } … … 3394 3454 } 3395 3455 else 3396 3456 shell_ungetc (peekc); 3397 tflags |= LEX_HEREDELIM; 3398 lex_firstind = -1; 3457 if (peekc != '<') 3458 { 3459 tflags |= LEX_HEREDELIM; 3460 lex_firstind = -1; 3461 } 3399 3462 continue; 3400 3463 } 3401 3464 else 3402 ch = peekc; /* fall through and continue XXX - this skips comments if peekc == '#'*/3465 ch = peekc; /* fall through and continue XXX */ 3403 3466 } 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__);*/ 3408 3470 tflags |= LEX_INCOMMENT; 3471 } 3409 3472 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 */ 3427 3474 { 3428 3475 RESIZE_MALLOCED_BUFFER (ret, retind, 2, retsize, 64); 3429 3476 ret[retind++] = CTLESC; … … 4248 4295 ((token_index > 0 && assignment_acceptable (last_read_token) && token_is_ident (token, token_index)) || 4249 4296 (token_index == 0 && (parser_state&PST_COMPASSIGN)))) 4250 4297 { 4251 ttok = parse_matched_pair (cd, '[', ']', &ttoklen, 0);4298 ttok = parse_matched_pair (cd, '[', ']', &ttoklen, P_ARRAYSUB); 4252 4299 if (ttok == &matched_pair_error) 4253 4300 return -1; /* Bail immediately. */ 4254 4301 RESIZE_MALLOCED_BUFFER (token, token_index, ttoklen + 2, … … 4449 4496 case '}': /* XXX */ 4450 4497 case AND_AND: 4451 4498 case BANG: 4499 case BAR_AND: 4452 4500 case DO: 4453 4501 case DONE: 4454 4502 case ELIF: -
patchlevel.h
diff -Naur bash-4.0.orig/patchlevel.h bash-4.0/patchlevel.h
old new 25 25 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh 26 26 looks for to find the patch level (for the sccs version string). */ 27 27 28 #define PATCHLEVEL 028 #define PATCHLEVEL 10 29 29 30 30 #endif /* _PATCHLEVEL_H_ */ -
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.