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
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)
+
-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.
-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
#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 *));
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])
{
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);
/* 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;
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;
}
#if defined (HANDLE_MULTIBYTE)
- mblength = MBLEN (string + i, slen - 1);
+ mblength = MBLEN (string + i, slen - i);
if (mblength > 1)
{
wchar_t wc;
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';
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;
if (string[sindex])
{
DECLARE_MBSTATE;
- if (slen == 0)
- slen = strlen (string);
ADVANCE_CHAR (string, slen, sindex);
}
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)
if (s[sindex])
{
DECLARE_MBSTATE;
- if (slen == 0)
- slen = strlen (s);
ADVANCE_CHAR (s, slen, sindex);
}
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])
{
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--)
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;
#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 *));
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])
{
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);
/* 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;
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;
}
#if defined (HANDLE_MULTIBYTE)
- mblength = MBLEN (string + i, slen - 1);
+ mblength = MBLEN (string + i, slen - i);
if (mblength > 1)
{
wchar_t wc;
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';
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;
if (string[sindex])
{
DECLARE_MBSTATE;
- if (slen == 0)
- slen = strlen (string);
ADVANCE_CHAR (string, slen, sindex);
}
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)
if (s[sindex])
{
DECLARE_MBSTATE;
- if (slen == 0)
- slen = strlen (s);
ADVANCE_CHAR (s, slen, sindex);
}
if (name[offset - 1] == '+')
{
appendop = 1;
- name[offset - 1] = 0;
+ name[offset - 1] = '\0';
}
name[offset] = 0; /* might need this set later */
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)
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])
{
}
*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;
}
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--)
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;
goto add_string;
}
else
- {
+b {
FREE (temp);
goto add_character;
}
-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
--- /dev/null
+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 "$@"
--- /dev/null
+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 "$@"
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'
x[9]='9'
echo ${x[*]: -1}
-
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
echo ${x[*]: -1}
-${THIS_SH} ./array1.sub
-${THIS_SH} ./array2.sub
-LANG=en_US.UTF-8
+export LANG=en_US.UTF-8
a=$'\303\251'
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
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
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
extglob off
failglob off
gnu_errfmt off
-histreedit off
histappend off
+histreedit off
histverify off
huponexit off
lithist off