From: Chet Ramey Date: Sat, 3 Dec 2011 18:41:18 +0000 (-0500) Subject: commit bash-20041216 snapshot X-Git-Tag: bash-3.1-alpha~28 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=da713c2366636f46b719afddcf7e4af46da4c641;p=thirdparty%2Fbash.git commit bash-20041216 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 19a093f7f..95620aa3c 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -10696,3 +10696,26 @@ builtins/set.def builtins/shopt.def - fix bug that caused `gnu_errfmt' to not be compiled in unless READLINE is defined + + 12/16 + ----- +subst.c + - fixed a typo in string_extract_verbatim in first call to MBLEN + (used `slen - 1' instead of `slen - i') + + 12/17 + ----- +subst.c + - avoid some calls to strlen if the value is only being used for + ADVANCE_CHAR and MB_CUR_MAX == 1 (since ADVANCE_CHAR doesn't need + it unless multibyte characters are possible) + - change string_extract_verbatim so it takes the length of the string + as a parameter, so we don't have to recompute the length of the same + string over and over again when doing word splitting (that kills if + it's a long string) + + 12/18 + ----- +subst.c + - in string_list_dollar_star, make sure to null-terminate the + separator if the character is longer than one byte diff --git a/CWRU/CWRU.chlog~ b/CWRU/CWRU.chlog~ index 94290735a..3d499d2ce 100644 --- a/CWRU/CWRU.chlog~ +++ b/CWRU/CWRU.chlog~ @@ -10687,3 +10687,30 @@ subst.c lib/readline/bind.c - make new-style "\M-x" keybindings obey `convert-meta' settings (bug reported by twaugh@redhat.com) + + 12/14 + ----- +builtins/set.def + - added description of `-' option to help text + +builtins/shopt.def + - fix bug that caused `gnu_errfmt' to not be compiled in unless + READLINE is defined + + 12/16 + ----- +subst.c + - fixed a typo in string_extract_verbatim in first call to MBLEN + (used `slen - 1' instead of `slen - i') + + 12/17 + ----- +subst.c + - avoid some calls to strlen if the value is only being used for + ADVANCE_CHAR and MB_CUR_MAX == 1 (since ADVANCE_CHAR doesn't need + it unless multibyte characters are possible) + - change string_extract_verbatim so it takes the length of the string + as a parameter, so we don't have to recompute the length of the same + string over and over again when doing word splitting (that kills if + it's a long string) + diff --git a/builtins/set.def b/builtins/set.def index 87a58d778..3bb327040 100644 --- a/builtins/set.def +++ b/builtins/set.def @@ -128,7 +128,7 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...] -E If set, the ERR trap is inherited by shell functions. #if defined (BANG_HISTORY) -H Enable ! style history substitution. This flag is on - by default. + by default when the shell is interactive. #endif /* BANG_HISTORY */ -P If set, do not follow symbolic links when executing commands such as cd which change the current directory. diff --git a/builtins/set.def~ b/builtins/set.def~ index a6046d979..87a58d778 100644 --- a/builtins/set.def~ +++ b/builtins/set.def~ @@ -133,6 +133,8 @@ $SHORT_DOC set [--abefhkmnptuvxBCHP] [-o option] [arg ...] -P If set, do not follow symbolic links when executing commands such as cd which change the current directory. -T If set, the DEBUG trap is inherited by shell functions. + - Assign any remaining arguments to the positional parameters. + The -x and -v options are turned off. Using + rather than - causes these flags to be turned off. The flags can also be used upon invocation of the shell. The current diff --git a/subst.c b/subst.c index 513939e13..73778459f 100644 --- a/subst.c +++ b/subst.c @@ -209,7 +209,7 @@ static SHELL_VAR *do_compound_assignment __P((char *, char *, int)); #endif static int do_assignment_internal __P((const WORD_DESC *, int)); -static char *string_extract_verbatim __P((char *, int *, char *)); +static char *string_extract_verbatim __P((char *, size_t, int *, char *)); static char *string_extract __P((char *, int *, char *, int)); static char *string_extract_double_quoted __P((char *, int *, int)); static inline char *string_extract_single_quoted __P((char *, int *)); @@ -555,7 +555,7 @@ string_extract (string, sindex, charlist, flags) char *temp; DECLARE_MBSTATE; - slen = strlen (string + *sindex) + *sindex; + slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0; i = *sindex; while (c = string[i]) { @@ -830,7 +830,8 @@ string_extract_single_quoted (string, sindex) char *t; DECLARE_MBSTATE; - slen = strlen (string + *sindex) + *sindex; + /* Don't need slen for ADVANCE_CHAR unless multibyte chars possible. */ + slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0; i = *sindex; while (string[i] && string[i] != '\'') ADVANCE_CHAR (string, slen, i); @@ -865,13 +866,13 @@ skip_single_quoted (string, slen, sind) /* Just like string_extract, but doesn't hack backslashes or any of that other stuff. Obeys CTLESC quoting. Used to do splitting on $IFS. */ static char * -string_extract_verbatim (string, sindex, charlist) +string_extract_verbatim (string, slen, sindex, charlist) char *string; + size_t slen; int *sindex; char *charlist; { register int i = *sindex; - size_t slen; #if defined (HANDLE_MULTIBYTE) size_t clen; wchar_t *wcharlist; @@ -887,8 +888,12 @@ string_extract_verbatim (string, sindex, charlist) return temp; } - slen = strlen (string + *sindex) + *sindex; i = *sindex; +#if 0 + /* See how the MBLEN and ADVANCE_CHAR macros work to understand why we need + this only if MB_CUR_MAX > 1. */ + slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 1; +#endif #if defined (HANDLE_MULTIBYTE) clen = strlen (charlist); wcharlist = 0; @@ -905,7 +910,7 @@ string_extract_verbatim (string, sindex, charlist) } #if defined (HANDLE_MULTIBYTE) - mblength = MBLEN (string + i, slen - 1); + mblength = MBLEN (string + i, slen - i); if (mblength > 1) { wchar_t wc; @@ -1768,7 +1773,10 @@ string_list_dollar_star (list) sep[1] = '\0'; } else - memcpy (sep, ifs_firstc, ifs_firstc_len); + { + memcpy (sep, ifs_firstc, ifs_firstc_len); + sep[ifs_firstc_len] = '\0'; + } #else sep[0] = ifs_firstc; sep[1] = '\0'; @@ -1906,9 +1914,12 @@ list_string (string, separators, quoted) extract a word, stopping at a separator skip sequences of spc, tab, or nl as long as they are separators This obeys the field splitting rules in Posix.2. */ + slen = (MB_CUR_MAX > 1) ? strlen (string) : 1; for (result = (WORD_LIST *)NULL, sindex = 0; string[sindex]; ) { - current_word = string_extract_verbatim (string, &sindex, separators); + /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim + unless multibyte chars are possible. */ + current_word = string_extract_verbatim (string, slen, &sindex, separators); if (current_word == 0) break; @@ -1954,8 +1965,6 @@ list_string (string, separators, quoted) if (string[sindex]) { DECLARE_MBSTATE; - if (slen == 0) - slen = strlen (string); ADVANCE_CHAR (string, slen, sindex); } @@ -2025,7 +2034,10 @@ get_word_from_string (stringp, separators, endptr) This obeys the field splitting rules in Posix.2. */ sindex = 0; - current_word = string_extract_verbatim (s, &sindex, separators); + /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim + unless multibyte chars are possible. */ + slen = (MB_CUR_MAX > 1) ? strlen (s) : 1; + current_word = string_extract_verbatim (s, slen, &sindex, separators); /* Set ENDPTR to the first character after the end of the word. */ if (endptr) @@ -2038,8 +2050,6 @@ get_word_from_string (stringp, separators, endptr) if (s[sindex]) { DECLARE_MBSTATE; - if (slen == 0) - slen = strlen (s); ADVANCE_CHAR (s, slen, sindex); } @@ -2464,7 +2474,8 @@ expand_string_if_necessary (string, quoted, func) char *ret; DECLARE_MBSTATE; - slen = strlen (string); + /* Don't need string length for ADVANCE_CHAR unless multibyte chars possible. */ + slen = (MB_CUR_MAX > 1) ? strlen (string) : 0; i = saw_quote = 0; while (string[i]) { @@ -5295,7 +5306,8 @@ mb_substring (string, s, e) DECLARE_MBSTATE; start = 0; - slen = STRLEN (string); + /* Don't need string length in ADVANCE_CHAR unless multibyte chars possible. */ + slen = (MB_CUR_MAX > 1) ? STRLEN (string) : 0; i = s; while (string[start] && i--) @@ -6435,7 +6447,9 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin string = word->word; if (string == 0) goto finished_with_string; - string_size = strlen (string); + /* Don't need the string length for the SADD... and COPY_ macros unless + multibyte characters are possible. */ + string_size = (MB_CUR_MAX > 1) ? strlen (string) : 1; if (contains_dollar_at) *contains_dollar_at = 0; diff --git a/subst.c~ b/subst.c~ index 879649c84..796049e0b 100644 --- a/subst.c~ +++ b/subst.c~ @@ -209,7 +209,7 @@ static SHELL_VAR *do_compound_assignment __P((char *, char *, int)); #endif static int do_assignment_internal __P((const WORD_DESC *, int)); -static char *string_extract_verbatim __P((char *, int *, char *)); +static char *string_extract_verbatim __P((char *, size_t, int *, char *)); static char *string_extract __P((char *, int *, char *, int)); static char *string_extract_double_quoted __P((char *, int *, int)); static inline char *string_extract_single_quoted __P((char *, int *)); @@ -555,7 +555,7 @@ string_extract (string, sindex, charlist, flags) char *temp; DECLARE_MBSTATE; - slen = strlen (string + *sindex) + *sindex; + slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0; i = *sindex; while (c = string[i]) { @@ -830,7 +830,8 @@ string_extract_single_quoted (string, sindex) char *t; DECLARE_MBSTATE; - slen = strlen (string + *sindex) + *sindex; + /* Don't need slen for ADVANCE_CHAR unless multibyte chars possible. */ + slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0; i = *sindex; while (string[i] && string[i] != '\'') ADVANCE_CHAR (string, slen, i); @@ -865,13 +866,13 @@ skip_single_quoted (string, slen, sind) /* Just like string_extract, but doesn't hack backslashes or any of that other stuff. Obeys CTLESC quoting. Used to do splitting on $IFS. */ static char * -string_extract_verbatim (string, sindex, charlist) +string_extract_verbatim (string, slen, sindex, charlist) char *string; + size_t slen; int *sindex; char *charlist; { register int i = *sindex; - size_t slen; #if defined (HANDLE_MULTIBYTE) size_t clen; wchar_t *wcharlist; @@ -887,8 +888,12 @@ string_extract_verbatim (string, sindex, charlist) return temp; } - slen = strlen (string + *sindex) + *sindex; i = *sindex; +#if 0 + /* See how the MBLEN and ADVANCE_CHAR macros work to understand why we need + this only if MB_CUR_MAX > 1. */ + slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 1; +#endif #if defined (HANDLE_MULTIBYTE) clen = strlen (charlist); wcharlist = 0; @@ -905,7 +910,7 @@ string_extract_verbatim (string, sindex, charlist) } #if defined (HANDLE_MULTIBYTE) - mblength = MBLEN (string + i, slen - 1); + mblength = MBLEN (string + i, slen - i); if (mblength > 1) { wchar_t wc; @@ -1768,7 +1773,10 @@ string_list_dollar_star (list) sep[1] = '\0'; } else - memcpy (sep, ifs_firstc, ifs_firstc_len); + { + memcpy (sep, ifs_firstc, ifs_firstc_len); + sep[ifs_firstc_len] = '\0'; + } #else sep[0] = ifs_firstc; sep[1] = '\0'; @@ -1906,9 +1914,12 @@ list_string (string, separators, quoted) extract a word, stopping at a separator skip sequences of spc, tab, or nl as long as they are separators This obeys the field splitting rules in Posix.2. */ + slen = (MB_CUR_MAX > 1) ? strlen (string) : 1; for (result = (WORD_LIST *)NULL, sindex = 0; string[sindex]; ) { - current_word = string_extract_verbatim (string, &sindex, separators); + /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim + unless multibyte chars are possible. */ + current_word = string_extract_verbatim (string, slen, &sindex, separators); if (current_word == 0) break; @@ -1954,8 +1965,6 @@ list_string (string, separators, quoted) if (string[sindex]) { DECLARE_MBSTATE; - if (slen == 0) - slen = strlen (string); ADVANCE_CHAR (string, slen, sindex); } @@ -2025,7 +2034,10 @@ get_word_from_string (stringp, separators, endptr) This obeys the field splitting rules in Posix.2. */ sindex = 0; - current_word = string_extract_verbatim (s, &sindex, separators); + /* Don't need string length in ADVANCE_CHAR or string_extract_verbatim + unless multibyte chars are possible. */ + slen = (MB_CUR_MAX > 1) ? strlen (s) : 1; + current_word = string_extract_verbatim (s, slen, &sindex, separators); /* Set ENDPTR to the first character after the end of the word. */ if (endptr) @@ -2038,8 +2050,6 @@ get_word_from_string (stringp, separators, endptr) if (s[sindex]) { DECLARE_MBSTATE; - if (slen == 0) - slen = strlen (s); ADVANCE_CHAR (s, slen, sindex); } @@ -2201,7 +2211,7 @@ do_assignment_internal (word, expand) if (name[offset - 1] == '+') { appendop = 1; - name[offset - 1] = 0; + name[offset - 1] = '\0'; } name[offset] = 0; /* might need this set later */ @@ -2239,7 +2249,7 @@ do_assignment_internal (word, expand) name[offset - 1] = '+'; xtrace_print_assignment (name, value, assign_list, 1); if (appendop) - name[offset - 1] = '+'; + name[offset - 1] = '\0'; } #define ASSIGN_RETURN(r) do { FREE (value); free (name); return (r); } while (0) @@ -2464,7 +2474,8 @@ expand_string_if_necessary (string, quoted, func) char *ret; DECLARE_MBSTATE; - slen = strlen (string); + /* Don't need string length for ADVANCE_CHAR unless multibyte chars possible. */ + slen = (MB_CUR_MAX > 1) ? strlen (string) : 0; i = saw_quote = 0; while (string[i]) { @@ -5235,6 +5246,15 @@ get_var_and_type (varname, value, quoted, varp, valp) } *varp = v; } + else if (v && (ALL_ELEMENT_SUB (temp[0]) && temp[1] == ']')) + { + vtype = VT_VARIABLE; + *varp = v; + if (quoted & (Q_DOUBLE_QUOTES|Q_HERE_DOCUMENT)) + *valp = dequote_string (value); + else + *valp = dequote_escapes (value); + } else return -1; } @@ -5286,7 +5306,8 @@ mb_substring (string, s, e) DECLARE_MBSTATE; start = 0; - slen = STRLEN (string); + /* Don't need string length in ADVANCE_CHAR unless multibyte chars possible. */ + slen = (MB_CUR_MAX > 1) ? STRLEN (string) : 0; i = s; while (string[start] && i--) @@ -6426,7 +6447,9 @@ expand_word_internal (word, quoted, isexp, contains_dollar_at, expanded_somethin string = word->word; if (string == 0) goto finished_with_string; - string_size = strlen (string); + /* Don't need the string length for the SADD... and COPY_ macros unless + multibyte characters are possible. */ + string_size = (MB_CUR_MAX > 1) ? strlen (string) : 1; if (contains_dollar_at) *contains_dollar_at = 0; @@ -6574,7 +6597,7 @@ add_string: goto add_string; } else - { +b { FREE (temp); goto add_character; } diff --git a/tests/RUN-ONE-TEST b/tests/RUN-ONE-TEST index 3efcf32d6..72ec06a2c 100755 --- a/tests/RUN-ONE-TEST +++ b/tests/RUN-ONE-TEST @@ -1,4 +1,4 @@ -BUILD_DIR=/usr/local/build/chet/bash/bash-current +BUILD_DIR=/usr/local/build/bash/bash-current THIS_SH=$BUILD_DIR/bash PATH=$PATH:$BUILD_DIR diff --git a/tests/RUN-ONE-TEST.gprof b/tests/RUN-ONE-TEST.gprof new file mode 100755 index 000000000..b29a64fd4 --- /dev/null +++ b/tests/RUN-ONE-TEST.gprof @@ -0,0 +1,9 @@ +BUILD_DIR=/usr/local/build/bash/bash-20041216-gprof +THIS_SH=$BUILD_DIR/bash +PATH=$PATH:$BUILD_DIR + +export THIS_SH PATH + +rm -f /tmp/xx + +/bin/sh "$@" diff --git a/tests/RUN-ONE-TEST.gprof~ b/tests/RUN-ONE-TEST.gprof~ new file mode 100755 index 000000000..72ec06a2c --- /dev/null +++ b/tests/RUN-ONE-TEST.gprof~ @@ -0,0 +1,9 @@ +BUILD_DIR=/usr/local/build/bash/bash-current +THIS_SH=$BUILD_DIR/bash +PATH=$PATH:$BUILD_DIR + +export THIS_SH PATH + +rm -f /tmp/xx + +/bin/sh "$@" diff --git a/tests/array.tests b/tests/array.tests index 5aca26510..4a735d8cd 100644 --- a/tests/array.tests +++ b/tests/array.tests @@ -374,7 +374,7 @@ echo "${x[@]}" mkdir $TMPDIR/bash-test-$$ cd $TMPDIR/bash-test-$$ -trap "cd / ; rm -rf $TMPDIR/bash-test/$$" 0 1 2 3 6 15 +trap "cd / ; rm -rf $TMPDIR/bash-test-$$" 0 1 2 3 6 15 touch '[3]=abcde' @@ -396,4 +396,3 @@ unset x[2] x[9]='9' echo ${x[*]: -1} - diff --git a/tests/array.tests~ b/tests/array.tests~ index 0d638784e..5aca26510 100644 --- a/tests/array.tests~ +++ b/tests/array.tests~ @@ -236,7 +236,12 @@ echo "value = ${barray[*]}" set -u ( echo ${#narray[4]} ) +${THIS_SH} ./array1.sub +${THIS_SH} ./array2.sub + # some old bugs and ksh93 compatibility tests +${THIS_SH} ./array3.sub + set +u cd /tmp @@ -392,5 +397,3 @@ x[9]='9' echo ${x[*]: -1} -${THIS_SH} ./array1.sub -${THIS_SH} ./array2.sub diff --git a/tests/gmon.out b/tests/gmon.out new file mode 100644 index 000000000..c50ffc5a1 Binary files /dev/null and b/tests/gmon.out differ diff --git a/tests/intl.tests b/tests/intl.tests index 3a9111a46..0dc33cbb0 100644 --- a/tests/intl.tests +++ b/tests/intl.tests @@ -1,4 +1,4 @@ -LANG=en_US.UTF-8 +export LANG=en_US.UTF-8 a=$'\303\251' diff --git a/tests/intl.tests~ b/tests/intl.tests~ index 7e3cb37d0..3a9111a46 100644 --- a/tests/intl.tests~ +++ b/tests/intl.tests~ @@ -21,8 +21,8 @@ a=$(printf '%b' 'A\303\251B') IFS=$(printf '%b' '\303\251') case "$a" in -"A${IFS}B") echo yes ;; -*) echo no ;; +"A${IFS}B") echo ok 1 ;; +*) echo bad 1 ;; esac set $a diff --git a/tests/shopt.right b/tests/shopt.right index 605a8f01b..ca9a2c344 100644 --- a/tests/shopt.right +++ b/tests/shopt.right @@ -15,8 +15,8 @@ shopt -s extquote shopt -u failglob shopt -s force_fignore shopt -u gnu_errfmt -shopt -u histreedit shopt -u histappend +shopt -u histreedit shopt -u histverify shopt -s hostcomplete shopt -u huponexit @@ -58,8 +58,8 @@ shopt -u extdebug shopt -u extglob shopt -u failglob shopt -u gnu_errfmt -shopt -u histreedit shopt -u histappend +shopt -u histreedit shopt -u histverify shopt -u huponexit shopt -u lithist @@ -81,8 +81,8 @@ extdebug off extglob off failglob off gnu_errfmt off -histreedit off histappend off +histreedit off histverify off huponexit off lithist off