]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20041216 snapshot
authorChet Ramey <chet.ramey@case.edu>
Sat, 3 Dec 2011 18:41:18 +0000 (13:41 -0500)
committerChet Ramey <chet.ramey@case.edu>
Sat, 3 Dec 2011 18:41:18 +0000 (13:41 -0500)
15 files changed:
CWRU/CWRU.chlog
CWRU/CWRU.chlog~
builtins/set.def
builtins/set.def~
subst.c
subst.c~
tests/RUN-ONE-TEST
tests/RUN-ONE-TEST.gprof [new file with mode: 0755]
tests/RUN-ONE-TEST.gprof~ [new file with mode: 0755]
tests/array.tests
tests/array.tests~
tests/gmon.out [new file with mode: 0644]
tests/intl.tests
tests/intl.tests~
tests/shopt.right

index 19a093f7fa54e44bbddfc764e9d664367044cfc0..95620aa3caf0b8ddfa0cbf884f372140ee1e8ff5 100644 (file)
@@ -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
index 94290735abc7be15fef7299795d3d9c869f016c9..3d499d2cee2a938b636ac61f0b38e2e84da24689 100644 (file)
@@ -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)
+
index 87a58d7782da2c58de48194d39a9a2f481961bc8..3bb327040f99abd48224ce6cd3a5489411dfccfa 100644 (file)
@@ -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.
index a6046d979f8ceffe7fcd1e259d21f87b01dcb546..87a58d7782da2c58de48194d39a9a2f481961bc8 100644 (file)
@@ -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 513939e13b39e2a1ce18d093b64a5e521f5a0e5c..73778459fb9a00cb7797dba6e314eef94785525f 100644 (file)
--- 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;
index 879649c84c659856318c137ba7b777875b748934..796049e0b784ab750202f1376a53d79b922a19aa 100644 (file)
--- 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;
            }
index 3efcf32d68e9722024b6ca9d67f9e81b2aa5ac04..72ec06a2c1fd8dde92acea5e8ac773e35f1d061b 100755 (executable)
@@ -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 (executable)
index 0000000..b29a64f
--- /dev/null
@@ -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 (executable)
index 0000000..72ec06a
--- /dev/null
@@ -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 "$@"
index 5aca26510c20a8ba90f70f57c43fc545684b3219..4a735d8cd4c54f3b0d2d215140f207da1c5b6626 100644 (file)
@@ -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}
-
index 0d638784ec638c7dbf960adfab57e10f8850540d..5aca26510c20a8ba90f70f57c43fc545684b3219 100644 (file)
@@ -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 (file)
index 0000000..c50ffc5
Binary files /dev/null and b/tests/gmon.out differ
index 3a9111a46db56ee644bd6eb9b3a95b64fe35f566..0dc33cbb0912b1e601955b1ae33cbf732a706154 100644 (file)
@@ -1,4 +1,4 @@
-LANG=en_US.UTF-8
+export LANG=en_US.UTF-8
 
 a=$'\303\251'
 
index 7e3cb37d0965f9e6cdeab52434c5c5c29a084800..3a9111a46db56ee644bd6eb9b3a95b64fe35f566 100644 (file)
@@ -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
index 605a8f01b56ad4a37526dc429f133b3a555ac7c6..ca9a2c3445e4efa4ffddb227db57d594c50bde25 100644 (file)
@@ -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