commit bash-20050922 snapshot

This commit is contained in:
Chet Ramey
2011-12-03 13:51:24 -05:00
parent 66e6d7cffd
commit f6410766e1
29 changed files with 6005 additions and 122 deletions
+11
View File
@@ -63,6 +63,14 @@ t. Fixed a bug that caused the expanded value of a $'...' string to be
incorrectly re-quoted if it occurred within a double-quoted ${...}
parameter expansion.
u. Restored default emacs-mode key binding of M-TAB to dynamic-complete-history.
v. Fixed a bug that caused core dumps when interrupting loops running builtins
on some systems.
w. Make sure that some of the functions bash provides replacements for are
not cpp defines.
2. Changes to Readline
a. The `change-case' command now correctly changes the case of multibyte
@@ -87,6 +95,9 @@ a. A new configuration option, `--enable-strict-posix-default', which will
4. New Features in Readline
a. If the rl_completion_query_items is set to a value < 0, readline never
asks the user whether or not to view the possible completions.
------------------------------------------------------------------------------
This document details the changes between this version, bash-3.1-alpha1,
and the previous version, bash-3.0-release.
+34
View File
@@ -12118,3 +12118,37 @@ eval.c
lib/sh/strto[iu]max.c
- make sure the function being declared is not a cpp define before
defining it -- should fix problems on HP-UX
9/19
----
Makefile.in
- make sure the binaries for the tests are at the front of $PATH
9/22
----
parse.y
- new flag for parse_matched_pair: P_COMMAND, indicating that the
text being parsed is a command (`...`, $(...))
- change calls to parse_matched_pair to include P_COMMAND where
appropriate
- if P_COMMAND flag is set and the text is unquoted, check for comments
and don't try to parse embedded quoted strings if in a comment (still
not exactly right yet)
9/24
----
builtins/history.def
- if running history -n, don't count these new lines as history lines
for the current session if the `histappend' shell option is set.
If we're just appending to the history file, the issue that caused
history_lines_this_session to be recalculated doesn't apply -- the
history file won't be missing any entries
lib/readline/isearch.c
- fix C-w handler for isearch string reader to handle multibyte chars
lib/readline/rlmbutil.h
- new defines for _rl_to_wupper and _rl_to_wlower
lib/readline/text.c
- use _rl_to_wupper and _rl_to_wlower as appropriate
+34
View File
@@ -12112,3 +12112,37 @@ eval.c
longjmp might restore the value of current_command after we've
disposed it, and the subsequent call to dispose_command from the
DISCARD case will free memory twice
9/16
----
lib/sh/strto[iu]max.c
- make sure the function being declared is not a cpp define before
defining it -- should fix problems on HP-UX
9/19
----
Makefile.in
- make sure the binaries for the tests are at the front of $PATH
9/22
----
parse.y
- new flag for parse_matched_pair: P_COMMAND, indicating that the
text being parsed is a command (`...`, $(...))
- change calls to parse_matched_pair to include P_COMMAND where
appropriate
- if P_COMMAND flag is set and the text is unquoted, check for comments
and don't try to parse embedded quoted strings if in a comment (still
not exactly right yet)
9/24
----
builtins/history.def
- if running history -n, don't count these new lines as history lines
for the current session if the `histappend' shell option is set.
If we're just appending to the history file, the issue that caused
history_lines_this_session to be recalculated doesn't apply -- the
history file won't be missing any entries
lib/readline/isearch.c
- fix C-w handler for isearch string reader to handle multibyte chars
+1
View File
@@ -526,6 +526,7 @@ support/xenix-link.sh f 755
support/shobj-conf f 755
support/rlvers.sh f 755
examples/bashdb/PERMISSION f
examples/bashdb/README f
examples/bashdb/bashdb f
examples/bashdb/bashdb.el f
examples/obashdb/PERMISSION f
+4
View File
@@ -714,6 +714,7 @@ tests/dollar-at-star f
tests/dollar-at1.sub f
tests/dollar-at2.sub f
tests/dollar-star1.sub f
tests/dollar-star2.sub f
tests/dollar.right f
tests/dstack.tests f
tests/dstack.right f
@@ -766,6 +767,8 @@ tests/history.right f
tests/history.list f 444
tests/ifs.tests f
tests/ifs.right f
tests/ifs-posix.tests f
tests/ifs-posix.right f
tests/input-line.sh f
tests/input-line.sub f
tests/input.right f
@@ -863,6 +866,7 @@ tests/run-herestr f
tests/run-histexpand f
tests/run-history f
tests/run-ifs f
tests/run-ifs-posix f
tests/run-input-test f
tests/run-intl f
tests/run-iquote f
+1 -1
View File
@@ -794,7 +794,7 @@ test tests check: force $(Program) $(TESTS_SUPPORT)
@-test -d tests || mkdir tests
@cp $(TESTS_SUPPORT) tests
@( cd $(srcdir)/tests && \
PATH=$$PATH:$(BUILD_DIR)/tests THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
PATH=$(BUILD_DIR)/tests:$$PATH THIS_SH=$(THIS_SH) $(SHELL) ${TESTSCRIPT} )
symlinks:
$(SHELL) $(SUPPORT_SRC)fixlinks -s $(srcdir)
+17 -17
View File
@@ -17,19 +17,19 @@
{
'm4_pattern_forbid' => 1,
'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_C_VOLATILE' => 1,
'AC_TYPE_OFF_T' => 1,
'AC_FUNC_CLOSEDIR_VOID' => 1,
'AC_REPLACE_FNMATCH' => 1,
'AC_PROG_LIBTOOL' => 1,
'AC_FUNC_STAT' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_HEADER_TIME' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_STRUCT_TM' => 1,
'AC_FUNC_WAIT3' => 1,
'AC_FUNC_LSTAT' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_STRUCT_TM' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'AC_TYPE_MODE_T' => 1,
'AC_FUNC_GETMNTENT' => 1,
'AC_FUNC_STRTOD' => 1,
'AC_CHECK_HEADERS' => 1,
'AC_FUNC_STRNLEN' => 1,
@@ -48,17 +48,17 @@
'AC_STRUCT_ST_BLOCKS' => 1,
'AC_TYPE_SIGNAL' => 1,
'AC_TYPE_UID_T' => 1,
'AC_PROG_MAKE_SET' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'm4_pattern_allow' => 1,
'AC_PROG_MAKE_SET' => 1,
'sinclude' => 1,
'm4_pattern_allow' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AC_FUNC_STRERROR_R' => 1,
'AC_PROG_CC' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_FUNC_FORK' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_DECL_SYS_SIGLIST' => 1,
'AC_FUNC_VPRINTF' => 1,
'AC_FUNC_STRCOLL' => 1,
'AC_PROG_YACC' => 1,
'AC_INIT' => 1,
'AC_STRUCT_TIMEZONE' => 1,
@@ -80,33 +80,33 @@
'AM_MAINTAINER_MODE' => 1,
'AC_FUNC_UTIME_NULL' => 1,
'AC_FUNC_SELECT_ARGTYPES' => 1,
'AC_HEADER_STAT' => 1,
'AC_FUNC_STRFTIME' => 1,
'AC_C_INLINE' => 1,
'AC_HEADER_STAT' => 1,
'AC_PROG_CPP' => 1,
'AC_C_CONST' => 1,
'AC_PROG_LEX' => 1,
'AC_C_INLINE' => 1,
'AC_TYPE_PID_T' => 1,
'AC_PROG_LEX' => 1,
'AC_C_CONST' => 1,
'AC_CONFIG_FILES' => 1,
'include' => 1,
'AC_FUNC_SETVBUF_REVERSED' => 1,
'AC_PROG_INSTALL' => 1,
'AM_GNU_GETTEXT' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_CHECK_LIB' => 1,
'AC_FUNC_OBSTACK' => 1,
'AC_FUNC_MALLOC' => 1,
'AC_FUNC_GETGROUPS' => 1,
'AC_FUNC_GETLOADAVG' => 1,
'AH_OUTPUT' => 1,
'AC_FUNC_FSEEKO' => 1,
'AM_PROG_CC_C_O' => 1,
'AM_CONDITIONAL' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AC_FUNC_MKTIME' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AM_CONDITIONAL' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_HEADER_SYS_WAIT' => 1,
'AC_PROG_LN_S' => 1,
'AC_FUNC_MEMCMP' => 1,
'AC_PROG_LN_S' => 1,
'm4_include' => 1,
'AC_HEADER_DIRENT' => 1,
'AC_CHECK_FUNCS' => 1
+10 -5
View File
@@ -77,6 +77,7 @@ extern int errno;
#endif
extern int current_command_line_count;
extern int force_append_history; /* shopt -s histappend */
int delete_last_history __P((void));
@@ -215,15 +216,19 @@ history_builtin (list)
using_history ();
history_lines_in_file = where_history ();
/* The question is whether we reset history_lines_this_session to 0,
losing any history entries we had before we read the new entries
from the history file, or whether we count the new entries we just
read from the file as history lines added during this session.
/* If we're rewriting the history file at shell exit rather than just
appending the lines from this session to it, the question is whether
we reset history_lines_this_session to 0, losing any history entries
we had before we read the new entries from the history file, or
whether we count the new entries we just read from the file as
history lines added during this session.
Right now, we do the latter. This will cause these history entries
to be written to the history file along with any intermediate entries
we add when we do a `history -a', but the alternative is losing
them altogether. */
history_lines_this_session += history_lines_in_file - old_history_lines +
if (force_append_history == 0)
history_lines_this_session += history_lines_in_file - old_history_lines +
history_base - obase;
}
+13 -10
View File
@@ -78,10 +78,11 @@ extern int errno;
extern int current_command_line_count;
int delete_last_history __P((void));
static char *histtime __P((HIST_ENTRY *, const char *));
static void display_history __P((WORD_LIST *));
static int delete_histent __P((int));
static int delete_last_history __P((void));
static void push_history __P((WORD_LIST *));
static int expand_and_print_history __P((WORD_LIST *));
@@ -214,15 +215,19 @@ history_builtin (list)
using_history ();
history_lines_in_file = where_history ();
/* The question is whether we reset history_lines_this_session to 0,
losing any history entries we had before we read the new entries
from the history file, or whether we count the new entries we just
read from the file as history lines added during this session.
/* If we're rewriting the history file at shell exit rather than just
appending the lines from this session to it, the question is whether
we reset history_lines_this_session to 0, losing any history entries
we had before we read the new entries from the history file, or
whether we count the new entries we just read from the file as
history lines added during this session.
Right now, we do the latter. This will cause these history entries
to be written to the history file along with any intermediate entries
we add when we do a `history -a', but the alternative is losing
them altogether. */
history_lines_this_session += history_lines_in_file - old_history_lines +
if (force_append_history == 0)
history_lines_this_session += history_lines_in_file - old_history_lines +
history_base - obase;
}
@@ -310,7 +315,7 @@ delete_histent (i)
return 1;
}
static int
int
delete_last_history ()
{
register int i;
@@ -346,8 +351,6 @@ push_history (list)
{
char *s;
if (current_command_line_count == 0)
itrace("push_history: current_command_line_count == 0");
/* Delete the last history entry if it was a single entry added to the
history list (generally the `history -s' itself), or if `history -s'
is being used in a compound command and the compound command was
@@ -385,7 +388,7 @@ expand_and_print_history (list)
char *s;
int r, result;
if (hist_last_line_added && delete_last_history () == 0)
if (hist_last_line_pushed == 0 && hist_last_line_added && delete_last_history () == 0)
return EXECUTION_FAILURE;
result = EXECUTION_SUCCESS;
while (list)
Vendored
-1
View File
@@ -28319,4 +28319,3 @@ if test "$no_create" != yes; then
# would make configure fail if this is the last instruction.
$ac_cs_success || { (exit 1); exit 1; }
fi
+1 -1
View File
@@ -11,7 +11,7 @@
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2005 Aug 27" "GNU Bash-3.1-alpha1"
.TH BASH 1 "2005 Aug 27" "GNU Bash-3.1-beta1"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
+2 -2
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2005 Free Software Foundation, Inc.
@set LASTCHANGE Mon Sep 5 11:47:04 EDT 2005
@set EDITION 3.1-alpha1
@set VERSION 3.1-alpha1
@set EDITION 3.1-beta1
@set VERSION 3.1-beta1
@set UPDATED 5 September 2005
@set UPDATED-MONTH September 2005
+3
View File
@@ -0,0 +1,3 @@
This is a sample implementation of a bash debugger. It is not the same
as the project available from http://bashdb.sourceforge.net, and has been
deprecated in favor of that implementation.
+4 -4
View File
@@ -509,11 +509,11 @@ function _showline
fi
if (( $line < 100 )); then
_msg "$_guineapig:$line $bp $cl${_lines[$line]}"
_msg "${_guineapig/*\//}:$line $bp $cl${_lines[$line]}"
elif (( $line < 10 )); then
_msg "$_guineapig:$line $bp $cl${_lines[$line]}"
_msg "${_guineapig/*\//}:$line $bp $cl${_lines[$line]}"
elif (( $line > 0 )); then
_msg "$_guineapig:$line $bp $cl${_lines[$line]}"
_msg "${_guineapig/*\//}:$line $bp $cl${_lines[$line]}"
fi
}
@@ -564,7 +564,7 @@ let _trace=0
let _i=1
# Be careful about quoted newlines
_potbelliedpig=${TMPDIR-/tmp}/$_guineapig.$$
_potbelliedpig=${TMPDIR-/tmp}/${_guineapig/*\//}.$$
sed 's,\\$,\\\\,' $_guineapig > $_potbelliedpig
_msg "Reading source from file: $_guineapig"
+581
View File
@@ -0,0 +1,581 @@
#! /bin/bash
# bashdb - Bash shell debugger
#
# Adapted from an idea in O'Reilly's `Learning the Korn Shell'
# Copyright (C) 1993-1994 O'Reilly and Associates, Inc.
# Copyright (C) 1998, 1999, 2001 Gary V. Vaughan <gvv@techie.com>>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# NOTE:
#
# This program requires bash 2.x.
# If bash 2.x is installed as "bash2", you can invoke bashdb like this:
#
# DEBUG_SHELL=/bin/bash2 /bin/bash2 bashdb script.sh
# TODO:
#
# break [regexp]
# cond [break] [condition]
# tbreak [regexp|+lines]
# restart
# Variable watchpoints
# Instrument `source' and `.' files in $_potbelliedpig
# be cleverer about lines we allow breakpoints to be set on
# break [function_name]
echo 'Bash Debugger version 1.2.4'
export _dbname=${0##*/}
if test $# -lt 1; then
echo "$_dbname: Usage: $_dbname filename" >&2
exit 1
fi
_guineapig=$1
if test ! -r $1; then
echo "$_dbname: Cannot read file '$_guineapig'." >&2
exit 1
fi
shift
__debug=${TMPDIR-/tmp}/bashdb.$$
sed -e '/^# bashdb - Bash shell debugger/,/^# -- DO NOT DELETE THIS LINE -- /d' "$0" > $__debug
cat $_guineapig >> $__debug
exec ${DEBUG_SHELL-bash} $__debug $_guineapig "$@"
exit 1
# -- DO NOT DELETE THIS LINE -- The program depends on it
#bashdb preamble
# $1 name of the original guinea pig script
__debug=$0
_guineapig=$1
__steptrap_calls=0
shift
shopt -s extglob # turn on extglob so we can parse the debugger funcs
function _steptrap
{
local i=0
_curline=$1
if (( ++__steptrap_calls > 1 && $_curline == 1 )); then
return
fi
if [ -n "$_disps" ]; then
while (( $i < ${#_disps[@]} ))
do
if [ -n "${_disps[$i]}" ]; then
_msg "${_disps[$i]}: \c"
eval _msg ${_disps[$i]}
fi
let i=$i+1
done
fi
if (( $_trace )); then
_showline $_curline
fi
if (( $_steps >= 0 )); then
let _steps="$_steps - 1"
fi
if _at_linenumbp ; then
_msg "Reached breakpoint at line $_curline"
_showline $_curline
_cmdloop
elif [ -n "$_brcond" ] && eval $_brcond; then
_msg "Break condition $_brcond true at line $_curline"
_showline $_curline
_cmdloop
elif (( $_steps == 0 )); then
# Assuming a real script will have the "#! /bin/sh" at line 1,
# assume that when $_curline == 1 we are inside backticks.
if (( ! $_trace )); then
_msg "Stopped at line $_curline"
_showline $_curline
fi
_cmdloop
fi
}
function _setbp
{
local i f line _x
if [ -z "$1" ]; then
_listbp
return
fi
eval "$_seteglob"
if [[ $1 == *(\+)[1-9]*([0-9]) ]]; then
case $1 in
+*)
# normalize argument, then double it (+2 -> +2 + 2 = 4)
_x=${1##*([!1-9])} # cut off non-numeric prefix
_x=${x%%*([!0-9])} # cut off non-numeric suffix
f=$(( $1 + $_x ))
;;
*)
f=$(( $1 ))
;;
esac
# find the next valid line
line="${_lines[$f]}"
while _invalidbreakp $f
do
(( f++ ))
line="${_lines[$f]}"
done
if (( $f != $1 ))
then
_msg "Line $1 is not a valid breakpoint"
fi
if [ -n "${_lines[$f]}" ]; then
_linebp[$1]=$1;
_msg "Breakpoint set at line $f"
else
_msg "Breakpoints can only be set on executable lines"
fi
else
_msg "Please specify a numeric line number"
fi
eval "$_resteglob"
}
function _listbp
{
local i
if [ -n "$_linebp" ]; then
_msg "Breakpoints:"
for i in ${_linebp[*]}; do
_showline $i
done
else
_msg "No breakpoints have been set"
fi
}
function _clearbp
{
local i
if [ -z "$1" ]; then
read -e -p "Delete all breakpoints? "
case $REPLY in
[yY]*)
unset _linebp[*]
_msg "All breakpoints have been cleared"
;;
esac
return 0
fi
eval "$_seteglob"
if [[ $1 == [1-9]*([0-9]) ]]; then
unset _linebp[$1]
_msg "Breakpoint cleared at line $1"
else
_msg "Please specify a numeric line number"
fi
eval "$_resteglob"
}
function _setbc
{
if (( $# > 0 )); then
_brcond=$@
_msg "Break when true: $_brcond"
else
_brcond=
_msg "Break condition cleared"
fi
}
function _setdisp
{
if [ -z "$1" ]; then
_listdisp
else
_disps[${#_disps[@]}]="$1"
if (( ${#_disps[@]} < 10 ))
then
_msg " ${#_disps[@]}: $1"
else
_msg "${#_disps[@]}: $1"
fi
fi
}
function _listdisp
{
local i=0 j
if [ -n "$_disps" ]; then
while (( $i < ${#_disps[@]} ))
do
let j=$i+1
if (( ${#_disps[@]} < 10 ))
then
_msg " $j: ${_disps[$i]}"
else
_msg "$j: ${_disps[$i]}"
fi
let i=$j
done
else
_msg "No displays have been set"
fi
}
function _cleardisp
{
if (( $# < 1 )) ; then
read -e -p "Delete all display expressions? "
case $REPLY in
[Yy]*)
unset _disps[*]
_msg "All breakpoints have been cleared"
;;
esac
return 0
fi
eval "$_seteglob"
if [[ $1 == [1-9]*([0-9]) ]]; then
unset _disps[$1]
_msg "Display $i has been cleared"
else
_listdisp
_msg "Please specify a numeric display number"
fi
eval "$_resteglob"
}
# usage _ftrace -u funcname [funcname...]
function _ftrace
{
local _opt=-t _tmsg="enabled" _func
if [[ $1 == -u ]]; then
_opt=+t
_tmsg="disabled"
shift
fi
for _func; do
declare -f $_opt $_func
_msg "Tracing $_tmsg for function $_func"
done
}
function _cmdloop
{
local cmd args
while read -e -p "bashdb> " cmd args; do
test -n "$cmd" && history -s "$cmd $args" # save on history list
test -n "$cmd" || { set $_lastcmd; cmd=$1; shift; args=$*; }
if [ -n "$cmd" ]
then
case $cmd in
b|br|bre|brea|break)
_setbp $args
_lastcmd="break $args"
;;
co|con)
_msg "ambiguous command: '$cmd', condition, continue?"
;;
cond|condi|condit|conditi|conditio|condition)
_setbc $args
_lastcmd="condition $args"
;;
c|cont|conti|contin|continu|continue)
_lastcmd="continue"
return
;;
d)
_msg "ambiguous command: '$cmd', delete, display?"
;;
de|del|dele|delet|delete)
_clearbp $args
_lastcmd="delete $args"
;;
di|dis|disp|displ|displa|display)
_setdisp $args
_lastcmd="display $args"
;;
f|ft|ftr|ftra|ftrace)
_ftrace $args
_lastcmd="ftrace $args"
;;
\?|h|he|hel|help)
_menu
_lastcmd="help"
;;
l|li|lis|list)
_displayscript $args
# _lastcmd is set in the _displayscript function
;;
p|pr|pri|prin|print)
_examine $args
_lastcmd="print $args"
;;
q|qu|qui|quit)
exit
;;
s|st|ste|step|n|ne|nex|next)
let _steps=${args:-1}
_lastcmd="next $args"
return
;;
t|tr|tra|trac|trace)
_xtrace
;;
u|un|und|undi|undis|undisp|undispl|undispla|undisplay)
_cleardisp $args
_lastcmd="undisplay $args"
;;
!*)
eval ${cmd#!} $args
_lastcmd="$cmd $args"
;;
*)
_msg "Invalid command: '$cmd'"
;;
esac
fi
done
}
function _at_linenumbp
{
[[ -n ${_linebp[$_curline]} ]]
}
function _invalidbreakp
{
local line=${_lines[$1]}
# XXX - should use shell patterns
if test -z "$line" \
|| expr "$line" : '[ \t]*#.*' > /dev/null \
|| expr "$line" : '[ \t]*;;[ \t]*$' > /dev/null \
|| expr "$line" : '[ \t]*[^)]*)[ \t]*$' > /dev/null \
|| expr "$line" : '[ \t]*;;[ \t]*#.**$' > /dev/null \
|| expr "$line" : '[ \t]*[^)]*)[ \t]*;;[ \t]*$' > /dev/null \
|| expr "$line" : '[ \t]*[^)]*)[ \t]*;;*[ \t]*#.*$' > /dev/null
then
return 0
fi
return 1
}
function _examine
{
if [ -n "$*" ]; then
_msg "$args: \c"
eval _msg $args
else
_msg "Nothing to print"
fi
}
function _displayscript
{
local i j start end bp cl
if (( $# == 1 )); then # list 5 lines on either side of $1
if [ $1 = "%" ]; then
let start=1
let end=${#_lines[@]}
else
let start=$1-5
let end=$1+5
fi
elif (( $# > 1 )); then # list between start and end
if [ $1 = "^" ]; then
let start=1
else
let start=$1
fi
if [ $2 = "\$" ]; then
let end=${#_lines[@]}
else
let end=$2
fi
else # list 5 lines on either side of current line
let start=$_curline-5
let end=$_curline+5
fi
# normalize start and end
if (( $start < 1 )); then
start=1
fi
if (( $end > ${#_lines[@]} )); then
end=${#_lines[@]}
fi
cl=$(( $end - $start ))
if (( $cl > ${LINES-24} )); then
pager=${PAGER-more}
else
pager=cat
fi
i=$start
( while (( $i <= $end )); do
_showline $i
let i=$i+1
done ) 2>&1 | $pager
# calculate the next block of lines
start=$(( $end + 1 ))
end=$(( $start + 11 ))
if (( $end > ${#_lines[@]} ))
then
end=${#_lines[@]}
fi
_lastcmd="list $start $end"
}
function _xtrace
{
let _trace="! $_trace"
if (( $_trace )); then
_msg "Execution trace on"
else
_msg "Execution trace off"
fi
}
function _msg
{
echo -e "$@" >&2
}
function _showline
{
local i=0 bp=' ' line=$1 cl=' '
if [[ -n ${_linebp[$line]} ]]; then
bp='*'
fi
if (( $_curline == $line )); then
cl=">"
fi
if (( $line < 100 )); then
_msg "$_guineapig:$line $bp $cl${_lines[$line]}"
elif (( $line < 10 )); then
_msg "$_guineapig:$line $bp $cl${_lines[$line]}"
elif (( $line > 0 )); then
_msg "$_guineapig:$line $bp $cl${_lines[$line]}"
fi
}
function _cleanup
{
rm -f $__debug $_potbelliedpig 2> /dev/null
}
function _menu
{
_msg 'bashdb commands:
break N set breakpoint at line N
break list breakpoints & break condition
condition foo set break condition to foo
condition clear break condition
delete N clear breakpoint at line N
delete clear all breakpoints
display EXP evaluate and display EXP for each debug step
display show a list of display expressions
undisplay N remove display expression N
list N M display all lines of script between N and M
list N display 5 lines of script either side of line N
list display 5 lines if script either side of current line
continue continue execution upto next breakpoint
next [N] execute [N] statements (default 1)
print expr prints the value of an expression
trace toggle execution trace on/off
ftrace [-u] func make the debugger step into function FUNC
(-u turns off tracing FUNC)
help print this menu
! string passes string to a shell
quit quit'
}
shopt -u extglob
HISTFILE=~/.bashdb_history
set -o history
set +H
# strings to save and restore the setting of `extglob' in debugger functions
# that need it
_seteglob='local __eopt=-u ; shopt -q extglob && __eopt=-s ; shopt -s extglob'
_resteglob='shopt $__eopt extglob'
_linebp=()
let _trace=0
let _i=1
# Be careful about quoted newlines
_potbelliedpig=${TMPDIR-/tmp}/$_guineapig.$$
sed 's,\\$,\\\\,' $_guineapig > $_potbelliedpig
_msg "Reading source from file: $_guineapig"
while read; do
_lines[$_i]=$REPLY
let _i=$_i+1
done < $_potbelliedpig
trap _cleanup EXIT
# Assuming a real script will have the "#! /bin/sh" at line 1,
# don't stop at line 1 on the first run
let _steps=1
LINENO=-1
trap '_steptrap $LINENO' DEBUG
+1
View File
@@ -115,6 +115,7 @@ malloc.o: $(BUILD_DIR)/config.h $(topdir)/bashtypes.h getpagesize.h
xmalloc.o: $(BUILD_DIR)/config.h $(BASHINCDIR)/ansi_stdlib.h
trace.o: ${BUILD_DIR}/config.h
table.o: ${BUILD_DIR}/config.h
watch.o: ${BUILD_DIR}/config.h
malloc.o: ${srcdir}/imalloc.h ${srcdir}/mstats.h
malloc.o: ${srcdir}/table.h ${srcdir}/watch.h
+2
View File
@@ -86,6 +86,8 @@
/* Some systems define these; we want our definitions. */
#undef ISPRINT
/* Beware: these only work with single-byte ASCII characters. */
#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
+163
View File
@@ -0,0 +1,163 @@
/* chardefs.h -- Character definitions for readline. */
/* Copyright (C) 1994 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _CHARDEFS_H_
#define _CHARDEFS_H_
#include <ctype.h>
#if defined (HAVE_CONFIG_H)
# if defined (HAVE_STRING_H)
# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
# include <memory.h>
# endif
# include <string.h>
# endif /* HAVE_STRING_H */
# if defined (HAVE_STRINGS_H)
# include <strings.h>
# endif /* HAVE_STRINGS_H */
#else
# include <string.h>
#endif /* !HAVE_CONFIG_H */
#ifndef whitespace
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
#endif
#ifdef CTRL
# undef CTRL
#endif
#ifdef UNCTRL
# undef UNCTRL
#endif
/* Some character stuff. */
#define control_character_threshold 0x020 /* Smaller than this is control. */
#define control_character_mask 0x1f /* 0x20 - 1 */
#define meta_character_threshold 0x07f /* Larger than this is Meta. */
#define control_character_bit 0x40 /* 0x000000, must be off. */
#define meta_character_bit 0x080 /* x0000000, must be on. */
#define largest_char 255 /* Largest character value. */
#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
#define CTRL(c) ((c) & control_character_mask)
#define META(c) ((c) | meta_character_bit)
#define UNMETA(c) ((c) & (~meta_character_bit))
#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII))
# define IN_CTYPE_DOMAIN(c) 1
#else
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
#endif
#if defined (CTYPE_NON_ASCII)
# define NON_NEGATIVE(c) 1
#else
# define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
#endif
/* Some systems define these; we want our definitions. */
#undef ISPRINT
#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
#define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c))
#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c))
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c))
#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c))
#ifndef _rl_to_upper
# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c))
# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c))
#endif
#ifndef _rl_digit_value
# define _rl_digit_value(x) ((x) - '0')
#endif
#ifndef _rl_isident
# define _rl_isident(c) (ISALNUM(c) || (c) == '_')
#endif
#ifndef ISOCTAL
# define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
#endif
#define OCTVALUE(c) ((c) - '0')
#define HEXVALUE(c) \
(((c) >= 'a' && (c) <= 'f') \
? (c)-'a'+10 \
: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
#ifndef NEWLINE
#define NEWLINE '\n'
#endif
#ifndef RETURN
#define RETURN CTRL('M')
#endif
#ifndef RUBOUT
#define RUBOUT 0x7f
#endif
#ifndef TAB
#define TAB '\t'
#endif
#ifdef ABORT_CHAR
#undef ABORT_CHAR
#endif
#define ABORT_CHAR CTRL('G')
#ifdef PAGE
#undef PAGE
#endif
#define PAGE CTRL('L')
#ifdef SPACE
#undef SPACE
#endif
#define SPACE ' ' /* XXX - was 0x20 */
#ifdef ESC
#undef ESC
#endif
#define ESC CTRL('[')
#endif /* _CHARDEFS_H_ */
+1 -1
View File
@@ -8,7 +8,7 @@
.\"
.\" Last Change: Tue Sep 13 12:07:26 EDT 2005
.\"
.TH READLINE 3 "2005 Sep 13" "GNU Readline 5.1-alpha1"
.TH READLINE 3 "2005 Sep 13" "GNU Readline 5.1-beta1"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
+2 -2
View File
@@ -2,8 +2,8 @@
Copyright (C) 1988-2005 Free Software Foundation, Inc.
@end ignore
@set EDITION 5.1-alpha1
@set VERSION 5.1-alpha1
@set EDITION 5.1-beta1
@set VERSION 5.1-beta1
@set UPDATED 13 September 2005
@set UPDATED-MONTH September 2005
+11 -5
View File
@@ -323,7 +323,7 @@ _rl_isearch_dispatch (cxt, c)
_rl_search_cxt *cxt;
int c;
{
int n, wstart, wlen, limit;
int n, wstart, wlen, limit, cval;
rl_command_func_t *f;
f = (rl_command_func_t *)NULL;
@@ -456,14 +456,20 @@ _rl_isearch_dispatch (cxt, c)
}
/* if not in a word, move to one. */
if (rl_alphabetic(rl_line_buffer[wstart]) == 0)
cval = _rl_char_value (rl_line_buffer, wstart);
if (_rl_walphabetic (cval) == 0)
{
rl_ding ();
break;
}
n = wstart;
while (n < rl_end && rl_alphabetic(rl_line_buffer[n]))
n++;
n = MB_NEXTCHAR (rl_line_buffer, wstart, 1, MB_FIND_NONZERO);;
while (n < rl_end)
{
cval = _rl_char_value (rl_line_buffer, n);
if (_rl_walphabetic (cval) == 0)
break;
n = MB_NEXTCHAR (rl_line_buffer, n, 1, MB_FIND_NONZERO);;
}
wlen = n - wstart + 1;
if (cxt->search_string_index + wlen + 1 >= cxt->search_string_size)
{
+13 -5
View File
@@ -101,6 +101,8 @@ _rl_scxt_alloc (type, flags)
cxt->last_found_line = cxt->save_line;
cxt->prev_line_found = 0;
cxt->save_undo_list = 0;
cxt->history_pos = 0;
cxt->direction = 0;
@@ -321,7 +323,7 @@ _rl_isearch_dispatch (cxt, c)
_rl_search_cxt *cxt;
int c;
{
int n, wstart, wlen, limit;
int n, wstart, wlen, limit, cval;
rl_command_func_t *f;
f = (rl_command_func_t *)NULL;
@@ -454,14 +456,20 @@ _rl_isearch_dispatch (cxt, c)
}
/* if not in a word, move to one. */
if (rl_alphabetic(rl_line_buffer[wstart]) == 0)
cval = _rl_char_value (rl_line_buffer, wstart);
if (rl_walphabetic (cval) == 0)
{
rl_ding ();
break;
}
n = wstart;
while (n < rl_end && rl_alphabetic(rl_line_buffer[n]))
n++;
n = MB_NEXTCHAR (rl_line_buffer, wstart, 1, MB_FIND_NONZERO);;
while (n < rl_end)
{
cval = _rl_char_value (rl_line_buffer, n);
if (rl_walphabetic (cval) == 0)
break;
n = MB_NEXTCHAR (rl_line_buffer, n, 1, MB_FIND_NONZERO);;
}
wlen = n - wstart + 1;
if (cxt->search_string_index + wlen + 1 >= cxt->search_string_size)
{
+6
View File
@@ -100,6 +100,9 @@ extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int));
extern wchar_t _rl_char_value PARAMS((char *, int));
extern int _rl_walphabetic PARAMS((wchar_t));
#define _rl_to_wupper(wc) (iswlower (wc) ? towupper (wc) : (wc))
#define _rl_to_wlower(wc) (iswupper (wc) ? towlower (wc) : (wc))
#define MB_NEXTCHAR(b,s,c,f) \
((MB_CUR_MAX > 1 && rl_byte_oriented == 0) \
? _rl_find_next_mbchar ((b), (s), (c), (f)) \
@@ -127,6 +130,9 @@ extern int _rl_walphabetic PARAMS((wchar_t));
#define _rl_walphabetic(c) (rl_alphabetic (c))
#define _rl_to_wupper(c) (_rl_to_upper (c))
#define _rl_to_wlower(c) (_rl_to_lower (c))
#define MB_NEXTCHAR(b,s,c,f) ((s) + (c))
#define MB_PREVCHAR(b,s,f) ((s) - 1)
+5 -5
View File
@@ -97,14 +97,14 @@ extern int _rl_read_mbstring PARAMS((int, char *, int));
extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int));
extern int _rl_char_value PARAMS((char *, int));
extern wchar_t _rl_char_value PARAMS((char *, int));
extern int _rl_walphabetic PARAMS((wchar_t));
#define NEXT_MBCHAR(b,s,c,f) \
#define MB_NEXTCHAR(b,s,c,f) \
((MB_CUR_MAX > 1 && rl_byte_oriented == 0) \
? _rl_find_next_mbchar ((b), (s), (c), (f)) \
: ((s) + (c)))
#define PREV_MBCHAR(b,s,f) \
#define MB_PREVCHAR(b,s,f) \
((MB_CUR_MAX > 1 && rl_byte_oriented == 0) \
? _rl_find_prev_mbchar ((b), (s), (f)) \
: ((s) - 1))
@@ -127,8 +127,8 @@ extern int _rl_walphabetic PARAMS((wchar_t));
#define _rl_walphabetic(c) (rl_alphabetic (c))
#define NEXT_MBCHAR(b,s,c,f) ((s) + (c))
#define PREV_MBCHAR(b,s,f) ((s) - 1)
#define MB_NEXTCHAR(b,s,c,f) ((s) + (c))
#define MB_PREVCHAR(b,s,f) ((s) - 1)
#define MB_INVALIDCH(x) (0)
#define MB_NULLWCH(x) (0)
+1 -2
View File
@@ -1293,8 +1293,7 @@ rl_change_case (count, op)
else
{
mbrtowc (&wc, rl_line_buffer + start, end - start, &ps);
nwc = (nop == UpCase) ? (iswlower (wc) ? towupper (wc) : wc)
: (iswupper (wc) ? towlower (wc) : wc);
nwc = (nop == UpCase) ? _rl_to_wupper (wc) : _rl_to_wlower (wc);
if (nwc != wc) /* just skip unchanged characters */
{
mblen = wcrtomb (mb, nwc, &ps);
+151 -52
View File
@@ -1,6 +1,6 @@
/* text.c -- text handling commands for readline. */
/* Copyright (C) 1987-2004 Free Software Foundation, Inc.
/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
@@ -62,6 +62,11 @@
static int rl_change_case PARAMS((int, int));
static int _rl_char_search PARAMS((int, int, int));
#if defined (READLINE_CALLBACKS)
static int _rl_insert_next_callback PARAMS((_rl_callback_generic_arg *));
static int _rl_char_search_callback PARAMS((_rl_callback_generic_arg *));
#endif
/* **************************************************************** */
/* */
/* Insert and Delete */
@@ -767,10 +772,8 @@ _rl_insert_char (count, c)
return 0;
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX == 1 || rl_byte_oriented)
{
#endif
/* We are inserting a single character.
If there is pending input, then make a string of all of the
pending characters that are bound to rl_insert, and insert
@@ -786,8 +789,8 @@ _rl_insert_char (count, c)
str[0] = c;
rl_insert_text (str);
}
#if defined (HANDLE_MULTIBYTE)
}
#if defined (HANDLE_MULTIBYTE)
else
{
rl_insert_text (incoming);
@@ -844,27 +847,63 @@ rl_insert (count, c)
}
/* Insert the next typed character verbatim. */
int
rl_quoted_insert (count, key)
int count, key;
static int
_rl_insert_next (count)
int count;
{
int c;
#if defined (HANDLE_SIGNALS)
_rl_disable_tty_signals ();
#endif
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
#if defined (HANDLE_SIGNALS)
_rl_restore_tty_signals ();
if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
_rl_restore_tty_signals ();
#endif
return (_rl_insert_char (count, c));
}
#if defined (READLINE_CALLBACKS)
static int
_rl_insert_next_callback (data)
_rl_callback_generic_arg *data;
{
int count;
count = data->count;
/* Deregister function, let rl_callback_read_char deallocate data */
_rl_callback_func = 0;
_rl_want_redisplay = 1;
return _rl_insert_next (count);
}
#endif
int
rl_quoted_insert (count, key)
int count, key;
{
/* Let's see...should the callback interface futz with signal handling? */
#if defined (HANDLE_SIGNALS)
if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
_rl_disable_tty_signals ();
#endif
#if defined (READLINE_CALLBACKS)
if (RL_ISSTATE (RL_STATE_CALLBACK))
{
_rl_callback_data = _rl_callback_data_alloc (count);
_rl_callback_func = _rl_insert_next_callback;
return (0);
}
#endif
return _rl_insert_next (count);
}
/* Insert a tab character. */
int
rl_tab_insert (count, key)
@@ -1046,11 +1085,9 @@ rl_delete (count, key)
if (count > 1 || rl_explicit_arg)
{
int orig_point = rl_point;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
rl_forward_char (count, key);
else
#endif
rl_forward_byte (count, key);
r = rl_kill_text (orig_point, rl_point);
@@ -1060,11 +1097,8 @@ rl_delete (count, key)
else
{
int new_point;
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
new_point = _rl_find_next_mbchar (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
else
new_point = rl_point + 1;
new_point = MB_NEXTCHAR (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
return (rl_delete_text (rl_point, new_point));
}
}
@@ -1200,42 +1234,81 @@ static int
rl_change_case (count, op)
int count, op;
{
register int start, end;
int inword, c;
int start, next, end;
int inword, c, nc, nop;
#if defined (HANDLE_MULTIBYTE)
wchar_t wc, nwc;
char mb[MB_LEN_MAX+1];
int mblen, p;
mbstate_t ps;
#endif
start = rl_point;
rl_forward_word (count, 0);
end = rl_point;
if (op != UpCase && op != DownCase && op != CapCase)
{
rl_ding ();
return -1;
}
if (count < 0)
SWAP (start, end);
#if defined (HANDLE_MULTIBYTE)
memset (&ps, 0, sizeof (mbstate_t));
#endif
/* We are going to modify some text, so let's prepare to undo it. */
rl_modifying (start, end);
for (inword = 0; start < end; start++)
inword = 0;
while (start < end)
{
c = rl_line_buffer[start];
switch (op)
c = _rl_char_value (rl_line_buffer, start);
/* This assumes that the upper and lower case versions are the same width. */
next = MB_NEXTCHAR (rl_line_buffer, start, 1, MB_FIND_NONZERO);
if (_rl_walphabetic (c) == 0)
{
case UpCase:
rl_line_buffer[start] = _rl_to_upper (c);
break;
case DownCase:
rl_line_buffer[start] = _rl_to_lower (c);
break;
case CapCase:
rl_line_buffer[start] = (inword == 0) ? _rl_to_upper (c) : _rl_to_lower (c);
inword = rl_alphabetic (rl_line_buffer[start]);
break;
default:
rl_ding ();
return -1;
inword = 0;
start = next;
continue;
}
if (op == CapCase)
{
nop = inword ? DownCase : UpCase;
inword = 1;
}
else
nop = op;
if (MB_CUR_MAX == 1 || rl_byte_oriented || isascii (c))
{
nc = (nop == UpCase) ? _rl_to_upper (c) : _rl_to_lower (c);
rl_line_buffer[start] = nc;
}
#if defined (HANDLE_MULTIBYTE)
else
{
mbrtowc (&wc, rl_line_buffer + start, end - start, &ps);
nwc = (nop == UpCase) ? (iswlower (wc) ? towupper (wc) : wc)
: (iswupper (wc) ? towlower (wc) : wc);
if (nwc != wc) /* just skip unchanged characters */
{
mblen = wcrtomb (mb, nwc, &ps);
if (mblen > 0)
mb[mblen] = '\0';
/* Assume the same width */
strncpy (rl_line_buffer + start, mb, mblen);
}
}
#endif
start = next;
}
rl_point = end;
return 0;
}
@@ -1315,11 +1388,11 @@ rl_transpose_chars (count, key)
{
#if defined (HANDLE_MULTIBYTE)
char *dummy;
int i, prev_point;
int i;
#else
char dummy[2];
#endif
int char_length;
int char_length, prev_point;
if (count == 0)
return 0;
@@ -1334,20 +1407,12 @@ rl_transpose_chars (count, key)
if (rl_point == rl_end)
{
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
else
--rl_point;
rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_NONZERO);
count = 1;
}
#if defined (HANDLE_MULTIBYTE)
prev_point = rl_point;
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
else
#endif
rl_point--;
rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_NONZERO);
#if defined (HANDLE_MULTIBYTE)
char_length = prev_point - rl_point;
@@ -1481,10 +1546,33 @@ _rl_char_search (count, fdir, bdir)
}
#endif /* !HANDLE_MULTIBYTE */
#if defined (READLINE_CALLBACKS)
static int
_rl_char_search_callback (data)
_rl_callback_generic_arg *data;
{
_rl_callback_func = 0;
_rl_want_redisplay = 1;
return (_rl_char_search (data->count, data->i1, data->i2));
}
#endif
int
rl_char_search (count, key)
int count, key;
{
#if defined (READLINE_CALLBACKS)
if (RL_ISSTATE (RL_STATE_CALLBACK))
{
_rl_callback_data = _rl_callback_data_alloc (count);
_rl_callback_data->i1 = FFIND;
_rl_callback_data->i2 = BFIND;
_rl_callback_func = _rl_char_search_callback;
return (0);
}
#endif
return (_rl_char_search (count, FFIND, BFIND));
}
@@ -1492,6 +1580,17 @@ int
rl_backward_char_search (count, key)
int count, key;
{
#if defined (READLINE_CALLBACKS)
if (RL_ISSTATE (RL_STATE_CALLBACK))
{
_rl_callback_data = _rl_callback_data_alloc (count);
_rl_callback_data->i1 = BFIND;
_rl_callback_data->i2 = FFIND;
_rl_callback_func = _rl_char_search_callback;
return (0);
}
#endif
return (_rl_char_search (count, BFIND, FFIND));
}
+22 -5
View File
@@ -2709,6 +2709,7 @@ read_token (command)
#define P_FIRSTCLOSE 0x01
#define P_ALLOWESC 0x02
#define P_DQUOTE 0x04
#define P_COMMAND 0x08 /* parsing a command, so look for comments */
static char matched_pair_error;
static char *
@@ -2717,13 +2718,14 @@ parse_matched_pair (qc, open, close, lenp, flags)
int open, close;
int *lenp, flags;
{
int count, ch, was_dollar;
int count, ch, was_dollar, in_comment, check_comment;
int pass_next_character, nestlen, ttranslen, start_lineno;
char *ret, *nestret, *ttrans;
int retind, retsize, rflags;
count = 1;
pass_next_character = was_dollar = 0;
pass_next_character = was_dollar = in_comment = 0;
check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
/* RFLAGS is the set of flags we want to pass to recursive calls. */
rflags = (qc == '"') ? P_DQUOTE : (flags & P_DQUOTE);
@@ -2751,6 +2753,21 @@ parse_matched_pair (qc, open, close, lenp, flags)
if (ch == '\n' && SHOULD_PROMPT ())
prompt_again ();
if (in_comment)
{
/* Add this character. */
RESIZE_MALLOCED_BUFFER (ret, retind, 1, retsize, 64);
ret[retind++] = ch;
if (ch == '\n')
in_comment = 0;
continue;
}
/* Not exactly right yet */
else if (check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind -1])))
in_comment = 1;
if (pass_next_character) /* last char was backslash */
{
pass_next_character = 0;
@@ -2873,7 +2890,7 @@ add_nestret:
}
FREE (nestret);
}
else if MBTEST(qc == '`' && (ch == '"' || ch == '\''))
else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0)
{
nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags);
goto add_nestret;
@@ -3363,7 +3380,7 @@ read_token_word (character)
if MBTEST(shellquote (character))
{
push_delimiter (dstack, character);
ttok = parse_matched_pair (character, character, character, &ttoklen, 0);
ttok = parse_matched_pair (character, character, character, &ttoklen, (character == '`') ? P_COMMAND : 0);
pop_delimiter (dstack);
if (ttok == &matched_pair_error)
return -1; /* Bail immediately. */
@@ -3426,7 +3443,7 @@ read_token_word (character)
history literally rather than causing a possibly-
incorrect `;' to be added. ) */
push_delimiter (dstack, peek_char);
ttok = parse_matched_pair (cd, '(', ')', &ttoklen, 0);
ttok = parse_matched_pair (cd, '(', ')', &ttoklen, P_COMMAND);
pop_delimiter (dstack);
}
else
+4911
View File
File diff suppressed because it is too large Load Diff
-4
View File
@@ -1000,9 +1000,6 @@ extract_array_assignment_list (string, sindex)
char *string;
int *sindex;
{
#if 0
return (extract_delimited_string (string, sindex, "(", (char *)NULL, ")", 0));
#else
int slen;
char *ret;
@@ -1013,7 +1010,6 @@ extract_array_assignment_list (string, sindex)
*sindex = slen - 1;
return ret;
}
#endif
}
#endif