mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-27 07:43:07 +02:00
commit bash-20051019 snapshot
This commit is contained in:
@@ -12264,3 +12264,50 @@ lib/readline/bind.c
|
||||
-----
|
||||
lib/glob/sm_loop.c
|
||||
- fix patscan() to correctly scan backslash-escaped characters
|
||||
|
||||
10/18
|
||||
-----
|
||||
lib/sh/{winsize.c,Makefile.in},{jobs,nojobs}.c,Makefile.in,externs.h
|
||||
- moved get_new_window_size from jobs.c/nojobs.c to new file,
|
||||
lib/sh/winsize.c, made function global
|
||||
|
||||
{jobs,nojobs,sig}.c,{jobs,sig}.h
|
||||
- moved SIGWINCH handling code to sig.c rather than duplicate it in
|
||||
jobs.c and nojobs.c
|
||||
- call set_sigwinch_handler from sig.c code rather than job control
|
||||
signal initialization
|
||||
|
||||
sig.[ch]
|
||||
- new variable, sigwinch_received, acts like interrupt_state for
|
||||
SIGWINCH, set by sigwinch_sighandler. sigwinch_sighandler no longer
|
||||
calls get_new_window_size
|
||||
|
||||
parse.y
|
||||
- add call to get_new_window_size if sigwinch_received at top of
|
||||
shell_getc
|
||||
|
||||
10/19
|
||||
-----
|
||||
lib/malloc/malloc.c
|
||||
- to avoid orphaning memory on free if the right bucket is busy, use a
|
||||
new function xplit(mem, bucket) to split the block into two or more
|
||||
smaller ones and add those to the right bucket (appropriately marking
|
||||
it as busy)
|
||||
- audit bsplit(), bcoalesce(), and xsplit() for proper use of busy[],
|
||||
since they're dealing with two separate buckets
|
||||
|
||||
10/22
|
||||
-----
|
||||
subst.c
|
||||
- new flag for string_extract: EX_REQMATCH, means to return an error
|
||||
if a matching/closing character is not found before EOS
|
||||
- new static flag variables: extract_string_error and extract_string_fatal
|
||||
- change expand_word_internal to check for new error returns from
|
||||
string_extract and return errors if appropriate
|
||||
|
||||
10/23
|
||||
-----
|
||||
builtins/cd.def
|
||||
- make sure we free TDIR in change_to_directory after calling
|
||||
set_working_directory (which allocates new memory) and other places
|
||||
we short-circuit and return
|
||||
|
||||
@@ -12259,3 +12259,54 @@ lib/readline/bind.c
|
||||
- change rl_parse_and_bind so only `set' commands involving boolean
|
||||
readline variables have trailing whitespace stripped from the value
|
||||
string
|
||||
|
||||
10/16
|
||||
-----
|
||||
lib/glob/sm_loop.c
|
||||
- fix patscan() to correctly scan backslash-escaped characters
|
||||
|
||||
10/18
|
||||
-----
|
||||
lib/sh/{winsize.c,Makefile.in},{jobs,nojobs}.c,Makefile.in,externs.h
|
||||
- moved get_new_window_size from jobs.c/nojobs.c to new file,
|
||||
lib/sh/winsize.c, made function global
|
||||
|
||||
{jobs,nojobs,sig}.c,{jobs,sig}.h
|
||||
- moved SIGWINCH handling code to sig.c rather than duplicate it in
|
||||
jobs.c and nojobs.c
|
||||
- call set_sigwinch_handler from sig.c code rather than job control
|
||||
signal initialization
|
||||
|
||||
sig.[ch]
|
||||
- new variable, sigwinch_received, acts like interrupt_state for
|
||||
SIGWINCH, set by sigwinch_sighandler. sigwinch_sighandler no longer
|
||||
calls get_new_window_size
|
||||
|
||||
parse.y
|
||||
- add call to get_new_window_size if sigwinch_received at top of
|
||||
shell_getc
|
||||
|
||||
10/19
|
||||
-----
|
||||
lib/malloc/malloc.c
|
||||
- to avoid orphaning memory on free if the right bucket is busy, use a
|
||||
new function xplit(mem, bucket) to split the block into two or more
|
||||
smaller ones and add those to the right bucket (appropriately marking
|
||||
it as busy)
|
||||
- audit bsplit(), bcoalesce(), and xsplit() for proper use of busy[],
|
||||
since they're dealing with two separate buckets
|
||||
|
||||
10/22
|
||||
-----
|
||||
subst.c
|
||||
- new flag for string_extract: EX_REQMATCH, means to return an error
|
||||
if a matching/closing character is not found before EOS
|
||||
- new static flag variables: extract_string_error and extract_string_fatal
|
||||
- change expand_word_internal to check for new error returns from
|
||||
string_extract and return errors if appropriate
|
||||
|
||||
10/23
|
||||
-----
|
||||
builtins/cd.def
|
||||
- make sure we free TDIR in change_to_directory after calling
|
||||
set_working_directory (which allocates new memory)
|
||||
|
||||
@@ -191,13 +191,14 @@ the Bash `configure' recognizes.
|
||||
Define if you are using the Andrew File System from Transarc.
|
||||
|
||||
`--with-bash-malloc'
|
||||
Use the Bash version of `malloc' in `lib/malloc/malloc.c'. This
|
||||
is not the same `malloc' that appears in GNU libc, but an older
|
||||
version derived from the 4.2 BSD `malloc'. This `malloc' is very
|
||||
fast, but wastes some space on each allocation. This option is
|
||||
enabled by default. The `NOTES' file contains a list of systems
|
||||
for which this should be turned off, and `configure' disables this
|
||||
option automatically for a number of systems.
|
||||
Use the Bash version of `malloc' in the directory `lib/malloc'.
|
||||
This is not the same `malloc' that appears in GNU libc, but an
|
||||
older version originally derived from the 4.2 BSD `malloc'. This
|
||||
`malloc' is very fast, but wastes some space on each allocation.
|
||||
This option is enabled by default. The `NOTES' file contains a
|
||||
list of systems for which this should be turned off, and
|
||||
`configure' disables this option automatically for a number of
|
||||
systems.
|
||||
|
||||
`--with-curses'
|
||||
Use the curses library instead of the termcap library. This should
|
||||
@@ -210,7 +211,7 @@ the Bash `configure' recognizes.
|
||||
`--with-installed-readline[=PREFIX]'
|
||||
Define this to make Bash link with a locally-installed version of
|
||||
Readline rather than the version in `lib/readline'. This works
|
||||
only with Readline 4.3 and later versions. If PREFIX is `yes' or
|
||||
only with Readline 5.0 and later versions. If PREFIX is `yes' or
|
||||
not supplied, `configure' uses the values of the make variables
|
||||
`includedir' and `libdir', which are subdirectories of `prefix' by
|
||||
default, to find the installed version of Readline if it is not in
|
||||
@@ -291,6 +292,9 @@ does not provide the necessary support.
|
||||
`=~' binary operator in the `[[' conditional command. (*note
|
||||
Conditional Constructs::).
|
||||
|
||||
`--enable-debugger'
|
||||
Include support for the bash debugger (distributed separately).
|
||||
|
||||
`--enable-directory-stack'
|
||||
Include support for a `csh'-like directory stack and the `pushd',
|
||||
`popd', and `dirs' builtins (*note The Directory Stack::).
|
||||
@@ -334,17 +338,17 @@ does not provide the necessary support.
|
||||
This enables process substitution (*note Process Substitution::) if
|
||||
the operating system provides the necessary support.
|
||||
|
||||
`--enable-progcomp'
|
||||
Enable the programmable completion facilities (*note Programmable
|
||||
Completion::). If Readline is not enabled, this option has no
|
||||
effect.
|
||||
|
||||
`--enable-prompt-string-decoding'
|
||||
Turn on the interpretation of a number of backslash-escaped
|
||||
characters in the `$PS1', `$PS2', `$PS3', and `$PS4' prompt
|
||||
strings. See *Note Printing a Prompt::, for a complete list of
|
||||
prompt string escape sequences.
|
||||
|
||||
`--enable-progcomp'
|
||||
Enable the programmable completion facilities (*note Programmable
|
||||
Completion::). If Readline is not enabled, this option has no
|
||||
effect.
|
||||
|
||||
`--enable-readline'
|
||||
Include support for command-line editing and history with the Bash
|
||||
version of the Readline library (*note Command Line Editing::).
|
||||
@@ -358,6 +362,19 @@ does not provide the necessary support.
|
||||
Include the `select' builtin, which allows the generation of simple
|
||||
menus (*note Conditional Constructs::).
|
||||
|
||||
`--enable-separate-helpfiles'
|
||||
Use external files for the documentation displayed by the `help'
|
||||
builtin instead of storing the text internally.
|
||||
|
||||
`--enable-single-help-strings'
|
||||
Store the text displayed by the `help' builtin as a single string
|
||||
for each help topic. This aids in translating the text to
|
||||
different languages. You may need to disable this if your
|
||||
compiler cannot handle very long string literals.
|
||||
|
||||
`--enable-strict-posix-default'
|
||||
Make Bash POSIX-conformant by default (*note Bash POSIX Mode::).
|
||||
|
||||
`--enable-usg-echo-default'
|
||||
A synonym for `--enable-xpg-echo-default'.
|
||||
|
||||
@@ -366,7 +383,7 @@ does not provide the necessary support.
|
||||
default, without requiring the `-e' option. This sets the default
|
||||
value of the `xpg_echo' shell option to `on', which makes the Bash
|
||||
`echo' behave more like the version specified in the Single Unix
|
||||
Specification, version 2. *Note Bash Builtins::, for a
|
||||
Specification, version 3. *Note Bash Builtins::, for a
|
||||
description of the escape sequences that `echo' recognizes.
|
||||
|
||||
The file `config-top.h' contains C Preprocessor `#define' statements
|
||||
|
||||
@@ -423,6 +423,7 @@ lib/sh/times.c f
|
||||
lib/sh/timeval.c f
|
||||
lib/sh/tmpfile.c f
|
||||
lib/sh/vprint.c f
|
||||
lib/sh/winsize.c f
|
||||
lib/sh/xstrchr.c f
|
||||
lib/sh/zcatfd.c f
|
||||
lib/sh/zread.c f
|
||||
|
||||
+1
-1
@@ -198,7 +198,7 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
|
||||
${SH_LIBSRC}/mktime.c ${SH_LIBSRC}/strftime.c \
|
||||
${SH_LIBSRC}/memset.c ${SH_LIBSRC}/xstrchr.c \
|
||||
${SH_LIBSRC}/zcatfd.c ${SH_LIBSRC}/shmatch.c \
|
||||
${SH_LIBSRC}/strnlen.c
|
||||
${SH_LIBSRC}/strnlen.c ${SH_LIBSRC}/winsize.c
|
||||
|
||||
SHLIB_LIB = -lsh
|
||||
SHLIB_LIBNAME = libsh.a
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
Bash POSIX Mode
|
||||
===============
|
||||
6.11 Bash POSIX Mode
|
||||
====================
|
||||
|
||||
Starting Bash with the `--posix' command-line option or executing `set
|
||||
-o posix' while Bash is running will cause Bash to conform more closely
|
||||
@@ -22,58 +22,59 @@ The following list is what's changed when `POSIX mode' is in effect:
|
||||
is stopped is `Stopped(SIGNAME)', where SIGNAME is, for example,
|
||||
`SIGTSTP'.
|
||||
|
||||
4. Reserved words may not be aliased.
|
||||
4. The `bg' builtin uses the required format to describe each job
|
||||
placed in the background, which does not include an indication of
|
||||
whether the job is the current or previous job.
|
||||
|
||||
5. The POSIX 1003.2 `PS1' and `PS2' expansions of `!' to the history
|
||||
5. Reserved words appearing in a context where reserved words are
|
||||
recognized do not undergo alias expansion.
|
||||
|
||||
6. The POSIX 1003.2 `PS1' and `PS2' expansions of `!' to the history
|
||||
number and `!!' to `!' are enabled, and parameter expansion is
|
||||
performed on the values of `PS1' and `PS2' regardless of the
|
||||
setting of the `promptvars' option.
|
||||
|
||||
6. The POSIX 1003.2 startup files are executed (`$ENV') rather than
|
||||
7. The POSIX 1003.2 startup files are executed (`$ENV') rather than
|
||||
the normal Bash files.
|
||||
|
||||
7. Tilde expansion is only performed on assignments preceding a
|
||||
8. Tilde expansion is only performed on assignments preceding a
|
||||
command name, rather than on all assignment statements on the line.
|
||||
|
||||
8. The default history file is `~/.sh_history' (this is the default
|
||||
9. The default history file is `~/.sh_history' (this is the default
|
||||
value of `$HISTFILE').
|
||||
|
||||
9. The output of `kill -l' prints all the signal names on a single
|
||||
10. The output of `kill -l' prints all the signal names on a single
|
||||
line, separated by spaces, without the `SIG' prefix.
|
||||
|
||||
10. The `kill' builtin does not accept signal names with a `SIG'
|
||||
11. The `kill' builtin does not accept signal names with a `SIG'
|
||||
prefix.
|
||||
|
||||
11. Non-interactive shells exit if FILENAME in `.' FILENAME is not
|
||||
12. Non-interactive shells exit if FILENAME in `.' FILENAME is not
|
||||
found.
|
||||
|
||||
12. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
13. Non-interactive shells exit if a syntax error in an arithmetic
|
||||
expansion results in an invalid expression.
|
||||
|
||||
13. Redirection operators do not perform filename expansion on the word
|
||||
14. Redirection operators do not perform filename expansion on the word
|
||||
in the redirection unless the shell is interactive.
|
||||
|
||||
14. Redirection operators do not perform word splitting on the word in
|
||||
15. Redirection operators do not perform word splitting on the word in
|
||||
the redirection.
|
||||
|
||||
15. Function names must be valid shell `name's. That is, they may not
|
||||
16. Function names must be valid shell `name's. That is, they may not
|
||||
contain characters other than letters, digits, and underscores, and
|
||||
may not start with a digit. Declaring a function with an invalid
|
||||
name causes a fatal syntax error in non-interactive shells.
|
||||
|
||||
16. POSIX 1003.2 `special' builtins are found before shell functions
|
||||
17. POSIX 1003.2 special builtins are found before shell functions
|
||||
during command lookup.
|
||||
|
||||
17. If a POSIX 1003.2 special builtin returns an error status, a
|
||||
18. If a POSIX 1003.2 special builtin returns an error status, a
|
||||
non-interactive shell exits. The fatal errors are those listed in
|
||||
the POSIX.2 standard, and include things like passing incorrect
|
||||
options, redirection errors, variable assignment errors for
|
||||
assignments preceding the command name, and so on.
|
||||
|
||||
18. If the `cd' builtin finds a directory to change to using
|
||||
`$CDPATH', the value it assigns to the `PWD' variable does not
|
||||
contain any symbolic links, as if `cd -P' had been executed.
|
||||
|
||||
19. If `CDPATH' is set, the `cd' builtin will not implicitly append
|
||||
the current directory to it. This means that `cd' will fail if no
|
||||
valid directory name can be constructed from any of the entries in
|
||||
@@ -105,9 +106,10 @@ The following list is what's changed when `POSIX mode' is in effect:
|
||||
|
||||
27. The `trap' builtin doesn't check the first argument for a possible
|
||||
signal specification and revert the signal handling to the original
|
||||
disposition if it is. If users want to reset the handler for a
|
||||
given signal to the original disposition, they should use `-' as
|
||||
the first argument.
|
||||
disposition if it is, unless that argument consists solely of
|
||||
digits and is a valid signal number. If users want to reset the
|
||||
handler for a given signal to the original disposition, they
|
||||
should use `-' as the first argument.
|
||||
|
||||
28. The `.' and `source' builtins do not search the current directory
|
||||
for the filename argument if it is not found by searching `PATH'.
|
||||
@@ -134,19 +136,44 @@ The following list is what's changed when `POSIX mode' is in effect:
|
||||
argument does not refer to an existing directory, `cd' will fail
|
||||
instead of falling back to PHYSICAL mode.
|
||||
|
||||
There is other POSIX 1003.2 behavior that Bash does not implement.
|
||||
Specifically:
|
||||
35. When the `pwd' builtin is supplied the `-P' option, it resets
|
||||
`$PWD' to a pathname containing no symlinks.
|
||||
|
||||
1. Assignment statements affect the execution environment of all
|
||||
builtins, not just special ones.
|
||||
36. The `pwd' builtin verifies that the value it prints is the same as
|
||||
the current directory, even if it is not asked to check the file
|
||||
system with the `-P' option.
|
||||
|
||||
2. When a subshell is created to execute a shell script with execute
|
||||
permission, but without a leading `#!', Bash sets `$0' to the full
|
||||
pathname of the script as found by searching `$PATH', rather than
|
||||
the command as typed by the user.
|
||||
37. When listing the history, the `fc' builtin does not include an
|
||||
indication of whether or not a history entry has been modified.
|
||||
|
||||
3. When using `.' to source a shell script found in `$PATH', bash
|
||||
checks execute permission bits rather than read permission bits,
|
||||
just as if it were searching for a command.
|
||||
38. The default editor used by `fc' is `ed'.
|
||||
|
||||
39. The `type' and `command' builtins will not report a non-executable
|
||||
file as having been found, though the shell will attempt to
|
||||
execute such a file if it is the only so-named file found in
|
||||
`$PATH'.
|
||||
|
||||
40. The `vi' editing mode will invoke the `vi' editor directly when
|
||||
the `v' command is run, instead of checking `$FCEDIT' and
|
||||
`$EDITOR'.
|
||||
|
||||
41. When the `xpg_echo' option is enabled, Bash does not attempt to
|
||||
interpret any arguments to `echo' as options. Each argument is
|
||||
displayed, after escape characters are converted.
|
||||
|
||||
|
||||
There is other POSIX 1003.2 behavior that Bash does not implement by
|
||||
default even when in POSIX mode. Specifically:
|
||||
|
||||
1. The `fc' builtin checks `$EDITOR' as a program to edit history
|
||||
entries if `FCEDIT' is unset, rather than defaulting directly to
|
||||
`ed'. `fc' uses `ed' if `EDITOR' is unset.
|
||||
|
||||
2. As noted above, Bash requires the `xpg_echo' option to be enabled
|
||||
for the `echo' builtin to be fully conformant.
|
||||
|
||||
|
||||
Bash can be configured to be POSIX-conformant by default, by specifying
|
||||
the `--enable-strict-posix-default' to `configure' when building (*note
|
||||
Optional Features::).
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
The Restricted Shell
|
||||
====================
|
||||
6.10 The Restricted Shell
|
||||
=========================
|
||||
|
||||
If Bash is started with the name `rbash', or the `--restricted' or `-r'
|
||||
option is supplied at invocation, the shell becomes restricted. A
|
||||
|
||||
+6
-1
@@ -444,6 +444,7 @@ change_to_directory (newdir, nolinks)
|
||||
if (errno != ENOENT)
|
||||
#endif
|
||||
errno = ENOTDIR;
|
||||
free (tdir);
|
||||
return (0);
|
||||
}
|
||||
|
||||
@@ -461,13 +462,17 @@ change_to_directory (newdir, nolinks)
|
||||
else
|
||||
set_working_directory (tdir);
|
||||
|
||||
free (tdir);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* We failed to change to the appropriate directory name. If we tried
|
||||
what the user passed (nolinks != 0), punt now. */
|
||||
if (nolinks)
|
||||
return (0);
|
||||
{
|
||||
free (tdir);
|
||||
return (0);
|
||||
}
|
||||
|
||||
err = errno;
|
||||
|
||||
|
||||
+8
-3
@@ -360,7 +360,8 @@ pwd_builtin (list)
|
||||
|
||||
/* Try again using getcwd() if canonicalization fails (for instance, if
|
||||
the file system has changed state underneath bash). */
|
||||
if ((tcwd && directory == 0) || (posixly_correct && file_isdir (tcwd) == 0))
|
||||
if ((tcwd && directory == 0) ||
|
||||
(posixly_correct && same_file (".", tcwd, (struct stat *)0, (struct stat *)0) == 0))
|
||||
directory = resetpwd ("pwd");
|
||||
|
||||
#undef tcwd
|
||||
@@ -399,7 +400,7 @@ change_to_directory (newdir, nolinks)
|
||||
int nolinks;
|
||||
{
|
||||
char *t, *tdir;
|
||||
int err, canon_failed, r;
|
||||
int err, canon_failed, r, ndlen, dlen;
|
||||
|
||||
tdir = (char *)NULL;
|
||||
|
||||
@@ -417,6 +418,9 @@ change_to_directory (newdir, nolinks)
|
||||
tdir = nolinks ? sh_physpath (t, 0)
|
||||
: sh_canonpath (t, PATH_CHECKDOTDOT|PATH_CHECKEXISTS);
|
||||
|
||||
ndlen = strlen (newdir);
|
||||
dlen = strlen (t);
|
||||
|
||||
/* Use the canonicalized version of NEWDIR, or, if canonicalization
|
||||
failed, use the non-canonical form. */
|
||||
canon_failed = 0;
|
||||
@@ -432,7 +436,7 @@ change_to_directory (newdir, nolinks)
|
||||
/* In POSIX mode, if we're resolving symlinks logically and sh_canonpath
|
||||
returns NULL (because it checks the path, it will return NULL if the
|
||||
resolved path doesn't exist), fail immediately. */
|
||||
if (posixly_correct && nolinks == 0 && canon_failed)
|
||||
if (posixly_correct && nolinks == 0 && canon_failed && (errno != ENAMETOOLONG || ndlen > PATH_MAX))
|
||||
{
|
||||
#if defined ENAMETOOLONG
|
||||
if (errno != ENOENT && errno != ENAMETOOLONG)
|
||||
@@ -457,6 +461,7 @@ change_to_directory (newdir, nolinks)
|
||||
else
|
||||
set_working_directory (tdir);
|
||||
|
||||
free (tdir);
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
+4113
-3957
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -16,7 +16,7 @@ trap 'rm -f $TMPOUT $TMPINFO $OUT; trap '' 0; exit 1' 1 2 3 6 15
|
||||
trap 'rm -f $TMPOUT $TMPINFO' 0
|
||||
|
||||
# create an info file without paragraph indentation
|
||||
makeinfo --no-split -I../lib/readline/doc --paragraph-indent 0 -o $TMPINFO $TEXI
|
||||
makeinfo --no-split --no-number-sections -I../lib/readline/doc --paragraph-indent 0 -o $TMPINFO $TEXI
|
||||
|
||||
# write out the text from the `Installing Bash' node to INSTALL.tmp
|
||||
info --file $TMPINFO --node "$NODE" --subnodes --output $TMPOUT
|
||||
|
||||
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# mkinstall - make the INSTALL file from the `Installing Bash' node of the
|
||||
# texinfo manual
|
||||
#
|
||||
|
||||
NODE="Installing Bash"
|
||||
SUBNODE="Basic Installation"
|
||||
TEXI=bashref.texi
|
||||
TMPINFO=temp.info
|
||||
TMPOUT=INSTALL.tmp
|
||||
|
||||
OUT=${1:-INSTALL}
|
||||
|
||||
trap 'rm -f $TMPOUT $TMPINFO $OUT; trap '' 0; exit 1' 1 2 3 6 15
|
||||
trap 'rm -f $TMPOUT $TMPINFO' 0
|
||||
|
||||
# create an info file without paragraph indentation
|
||||
makeinfo --no-split -I../lib/readline/doc --paragraph-indent 0 -o $TMPINFO $TEXI
|
||||
|
||||
# write out the text from the `Installing Bash' node to INSTALL.tmp
|
||||
info --file $TMPINFO --node "$NODE" --subnodes --output $TMPOUT
|
||||
|
||||
# remove the info traversal information and the initial menu, and squeeze
|
||||
# out multiple consecutive blank lines like `cat -s'
|
||||
awk 'BEGIN { printline = 0; newlines = 0; }
|
||||
|
||||
/^File: '$TMPINFO'/ { next; }
|
||||
|
||||
/^'"$SUBNODE"'/ { printline = 1; }
|
||||
|
||||
/^$/ { if (printline) newlines = 1; next; }
|
||||
|
||||
/$/ { if (printline) {
|
||||
if (newlines) {
|
||||
printf "\n";
|
||||
newlines = 0;
|
||||
}
|
||||
print $0;
|
||||
}
|
||||
}' < $TMPOUT > $OUT
|
||||
|
||||
exit 0
|
||||
@@ -1,7 +1,7 @@
|
||||
/* externs.h -- extern function declarations which do not appear in their
|
||||
own header file. */
|
||||
|
||||
/* Copyright (C) 1993-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1993-2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -369,6 +369,9 @@ extern char *sh_mktmpname __P((char *, int));
|
||||
extern int sh_mktmpfd __P((char *, int, char **));
|
||||
/* extern FILE *sh_mktmpfp __P((char *, int, char **)); */
|
||||
|
||||
/* declarations for functions defined in lib/sh/winsize.c */
|
||||
extern void get_new_window_size __P((int));
|
||||
|
||||
/* declarations for functions defined in lib/sh/xstrchr.c */
|
||||
#undef xstrchr
|
||||
extern char *xstrchr __P((const char *, int));
|
||||
|
||||
+14
@@ -235,6 +235,7 @@ extern int sh_regmatch __P((const char *, const char *, int));
|
||||
/* declarations for functions defined in lib/sh/shquote.c */
|
||||
extern char *sh_single_quote __P((char *));
|
||||
extern char *sh_double_quote __P((char *));
|
||||
extern char *sh_mkdoublequoted __P((const char *, int, int));
|
||||
extern char *sh_un_double_quote __P((char *));
|
||||
extern char *sh_backslash_quote __P((char *));
|
||||
extern char *sh_backslash_quote_for_double_quotes __P((char *));
|
||||
@@ -302,6 +303,16 @@ extern void strvec_sort __P((char **));
|
||||
extern char **strvec_from_word_list __P((WORD_LIST *, int, int, int *));
|
||||
extern WORD_LIST *strvec_to_word_list __P((char **, int, int));
|
||||
|
||||
/* declarations for functions defined in lib/sh/strnlen.c */
|
||||
#if !defined (HAVE_STRNLEN)
|
||||
extern size_t strnlen __P((const char *, size_t));
|
||||
#endif
|
||||
|
||||
/* declarations for functions defined in lib/sh/strpbrk.c */
|
||||
#if !defined (HAVE_STRPBRK)
|
||||
extern char *strpbrk __P((const char *, const char *));
|
||||
#endif
|
||||
|
||||
/* declarations for functions defined in lib/sh/strtod.c */
|
||||
#if !defined (HAVE_STRTOD)
|
||||
extern double strtod __P((const char *, char **));
|
||||
@@ -358,6 +369,9 @@ extern char *sh_mktmpname __P((char *, int));
|
||||
extern int sh_mktmpfd __P((char *, int, char **));
|
||||
/* extern FILE *sh_mktmpfp __P((char *, int, char **)); */
|
||||
|
||||
/* declarations for functions defined in lib/sh/winsize.c */
|
||||
extern void get_new_window_size __P((int));
|
||||
|
||||
/* declarations for functions defined in lib/sh/xstrchr.c */
|
||||
#undef xstrchr
|
||||
extern char *xstrchr __P((const char *, int));
|
||||
|
||||
@@ -63,17 +63,6 @@
|
||||
# include <bsdtty.h>
|
||||
#endif /* hpux && !TERMIOS_TTY_DRIVER */
|
||||
|
||||
#if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
|
||||
/* For struct winsize on SCO */
|
||||
/* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */
|
||||
# if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH)
|
||||
# if defined (HAVE_SYS_STREAM_H)
|
||||
# include <sys/stream.h>
|
||||
# endif
|
||||
# include <sys/ptem.h>
|
||||
# endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
|
||||
#endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
|
||||
|
||||
#include "bashansi.h"
|
||||
#include "bashintl.h"
|
||||
#include "shell.h"
|
||||
@@ -142,10 +131,6 @@ extern int errno;
|
||||
|
||||
typedef int sh_job_map_func_t __P((JOB *, int, int, int));
|
||||
|
||||
#if defined (READLINE)
|
||||
extern void rl_set_screen_size __P((int, int));
|
||||
#endif
|
||||
|
||||
/* Variables used here but defined in other files. */
|
||||
extern int subshell_environment, line_number;
|
||||
extern int posixly_correct, shell_level;
|
||||
@@ -224,13 +209,10 @@ int check_window_size;
|
||||
|
||||
/* Functions local to this file. */
|
||||
|
||||
static void get_new_window_size __P((int));
|
||||
|
||||
static void run_sigchld_trap __P((int));
|
||||
|
||||
static sighandler wait_sigint_handler __P((int));
|
||||
static sighandler sigchld_handler __P((int));
|
||||
static sighandler sigwinch_sighandler __P((int));
|
||||
static sighandler sigcont_sighandler __P((int));
|
||||
static sighandler sigstop_sighandler __P((int));
|
||||
|
||||
@@ -313,10 +295,6 @@ static int queue_sigchld;
|
||||
static SigHandler *old_tstp, *old_ttou, *old_ttin;
|
||||
static SigHandler *old_cont = (SigHandler *)SIG_DFL;
|
||||
|
||||
#if defined (TIOCGWINSZ) && defined (SIGWINCH)
|
||||
static SigHandler *old_winch = (SigHandler *)SIG_DFL;
|
||||
#endif
|
||||
|
||||
/* A place to temporarily save the current pipeline. */
|
||||
static PROCESS *saved_pipeline;
|
||||
static int saved_already_making_children;
|
||||
@@ -3546,60 +3524,6 @@ set_new_line_discipline (tty)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (TIOCGWINSZ) && defined (SIGWINCH)
|
||||
static void
|
||||
get_new_window_size (from_sig)
|
||||
int from_sig;
|
||||
{
|
||||
struct winsize win;
|
||||
|
||||
if ((ioctl (shell_tty, TIOCGWINSZ, &win) == 0) &&
|
||||
win.ws_row > 0 && win.ws_col > 0)
|
||||
{
|
||||
#if defined (aixpc)
|
||||
shell_tty_info.c_winsize = win; /* structure copying */
|
||||
#endif
|
||||
sh_set_lines_and_columns (win.ws_row, win.ws_col);
|
||||
#if defined (READLINE)
|
||||
rl_set_screen_size (win.ws_row, win.ws_col);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static sighandler
|
||||
sigwinch_sighandler (sig)
|
||||
int sig;
|
||||
{
|
||||
#if defined (MUST_REINSTALL_SIGHANDLERS)
|
||||
set_signal_handler (SIGWINCH, sigwinch_sighandler);
|
||||
#endif /* MUST_REINSTALL_SIGHANDLERS */
|
||||
get_new_window_size (1);
|
||||
SIGRETURN (0);
|
||||
}
|
||||
#else
|
||||
static void
|
||||
get_new_window_size (from_sig)
|
||||
int from_sig;
|
||||
{
|
||||
}
|
||||
#endif /* TIOCGWINSZ && SIGWINCH */
|
||||
|
||||
void
|
||||
set_sigwinch_handler ()
|
||||
{
|
||||
#if defined (TIOCGWINSZ) && defined (SIGWINCH)
|
||||
old_winch = set_signal_handler (SIGWINCH, sigwinch_sighandler);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
unset_sigwinch_handler ()
|
||||
{
|
||||
#if defined (TIOCGWINSZ) && defined (SIGWINCH)
|
||||
set_signal_handler (SIGWINCH, old_winch);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Setup this shell to handle C-C, etc. */
|
||||
void
|
||||
initialize_job_signals ()
|
||||
@@ -3610,7 +3534,6 @@ initialize_job_signals ()
|
||||
set_signal_handler (SIGTSTP, SIG_IGN);
|
||||
set_signal_handler (SIGTTOU, SIG_IGN);
|
||||
set_signal_handler (SIGTTIN, SIG_IGN);
|
||||
set_sigwinch_handler ();
|
||||
}
|
||||
else if (job_control)
|
||||
{
|
||||
|
||||
@@ -218,9 +218,6 @@ extern int initialize_job_control __P((int));
|
||||
extern void initialize_job_signals __P((void));
|
||||
extern int give_terminal_to __P((pid_t, int));
|
||||
|
||||
extern void set_sigwinch_handler __P((void));
|
||||
extern void unset_sigwinch_handler __P((void));
|
||||
|
||||
extern void unfreeze_jobs_list __P((void));
|
||||
extern int set_job_control __P((int));
|
||||
extern void without_job_control __P((void));
|
||||
|
||||
+86
-25
@@ -1,6 +1,6 @@
|
||||
/* malloc.c - dynamic memory allocation for bash. */
|
||||
|
||||
/* Copyright (C) 1985-2003 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1985-2005 Free Software Foundation, Inc.
|
||||
|
||||
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
|
||||
@@ -221,7 +221,7 @@ typedef union _malloc_guard {
|
||||
|
||||
static union mhead *nextf[NBUCKETS];
|
||||
|
||||
/* busy[i] is nonzero while allocation of block size i is in progress. */
|
||||
/* busy[i] is nonzero while allocation or free of block size i is in progress. */
|
||||
|
||||
static char busy[NBUCKETS];
|
||||
|
||||
@@ -323,7 +323,8 @@ xbotch (mem, e, s, file, line)
|
||||
|
||||
/* Coalesce two adjacent free blocks off the free list for size NU - 1,
|
||||
as long as we can find two adjacent free blocks. nextf[NU -1] is
|
||||
assumed to not be busy; the caller (morecore()) checks for this. */
|
||||
assumed to not be busy; the caller (morecore()) checks for this.
|
||||
BUSY[NU] must be set to 1. */
|
||||
static void
|
||||
bcoalesce (nu)
|
||||
register int nu;
|
||||
@@ -333,9 +334,10 @@ bcoalesce (nu)
|
||||
unsigned long siz;
|
||||
|
||||
nbuck = nu - 1;
|
||||
if (nextf[nbuck] == 0)
|
||||
if (nextf[nbuck] == 0 || busy[nbuck])
|
||||
return;
|
||||
|
||||
busy[nbuck] = 1;
|
||||
siz = binsize (nbuck);
|
||||
|
||||
mp2 = mp1 = nextf[nbuck];
|
||||
@@ -346,22 +348,27 @@ bcoalesce (nu)
|
||||
mp1 = mp;
|
||||
mp = CHAIN (mp);
|
||||
}
|
||||
|
||||
if (mp == 0)
|
||||
return;
|
||||
{
|
||||
busy[nbuck] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* OK, now we have mp1 pointing to the block we want to add to nextf[NU].
|
||||
CHAIN(mp2) must equal mp1. Check that mp1 and mp are adjacent. */
|
||||
if (mp2 != mp1 && CHAIN(mp2) != mp1)
|
||||
xbotch ((PTR_T)0, 0, "bcoalesce: CHAIN(mp2) != mp1", (char *)NULL, 0);
|
||||
{
|
||||
busy[nbuck] = 0;
|
||||
xbotch ((PTR_T)0, 0, "bcoalesce: CHAIN(mp2) != mp1", (char *)NULL, 0);
|
||||
}
|
||||
|
||||
#ifdef MALLOC_DEBUG
|
||||
if (CHAIN (mp1) != (union mhead *)((char *)mp1 + siz))
|
||||
return; /* not adjacent */
|
||||
#endif
|
||||
|
||||
#ifdef MALLOC_STATS
|
||||
_mstats.tbcoalesce++;
|
||||
_mstats.ncoalesce[nbuck]++;
|
||||
{
|
||||
busy[nbuck] = 0;
|
||||
return; /* not adjacent */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Since they are adjacent, remove them from the free list */
|
||||
@@ -369,6 +376,12 @@ bcoalesce (nu)
|
||||
nextf[nbuck] = CHAIN (mp);
|
||||
else
|
||||
CHAIN (mp2) = CHAIN (mp);
|
||||
busy[nbuck] = 0;
|
||||
|
||||
#ifdef MALLOC_STATS
|
||||
_mstats.tbcoalesce++;
|
||||
_mstats.ncoalesce[nbuck]++;
|
||||
#endif
|
||||
|
||||
/* And add the combined two blocks to nextf[NU]. */
|
||||
mp1->mh_alloc = ISFREE;
|
||||
@@ -380,7 +393,7 @@ bcoalesce (nu)
|
||||
/* Split a block at index > NU (but less than SPLIT_MAX) into a set of
|
||||
blocks of the correct size, and attach them to nextf[NU]. nextf[NU]
|
||||
is assumed to be empty. Must be called with signals blocked (e.g.,
|
||||
by morecore()). */
|
||||
by morecore()). BUSY[NU] must be set to 1. */
|
||||
static void
|
||||
bsplit (nu)
|
||||
register int nu;
|
||||
@@ -416,6 +429,12 @@ bsplit (nu)
|
||||
/* XXX might want to split only if nextf[nbuck] has >= 2 blocks free
|
||||
and nbuck is below some threshold. */
|
||||
|
||||
/* Remove the block from the chain of larger blocks. */
|
||||
busy[nbuck] = 1;
|
||||
mp = nextf[nbuck];
|
||||
nextf[nbuck] = CHAIN (mp);
|
||||
busy[nbuck] = 0;
|
||||
|
||||
#ifdef MALLOC_STATS
|
||||
_mstats.tbsplit++;
|
||||
_mstats.nsplit[nbuck]++;
|
||||
@@ -425,10 +444,6 @@ bsplit (nu)
|
||||
siz = binsize (nu);
|
||||
nblks = binsize (nbuck) / siz;
|
||||
|
||||
/* Remove the block from the chain of larger blocks. */
|
||||
mp = nextf[nbuck];
|
||||
nextf[nbuck] = CHAIN (mp);
|
||||
|
||||
/* Split the block and put it on the requested chain. */
|
||||
nextf[nu] = mp;
|
||||
while (1)
|
||||
@@ -442,6 +457,49 @@ bsplit (nu)
|
||||
CHAIN (mp) = 0;
|
||||
}
|
||||
|
||||
/* Take the memory block MP and add it to a chain < NU. NU is the right bucket,
|
||||
but is busy. This avoids memory orphaning. */
|
||||
static void
|
||||
xsplit (mp, nu)
|
||||
union mhead *mp;
|
||||
int nu;
|
||||
{
|
||||
union mhead *nh;
|
||||
int nbuck, nblks, split_max;
|
||||
unsigned long siz;
|
||||
|
||||
nbuck = nu - 1;
|
||||
while (nbuck >= SPLIT_MIN && busy[nbuck])
|
||||
nbuck--;
|
||||
if (nbuck < SPLIT_MIN)
|
||||
return;
|
||||
|
||||
#ifdef MALLOC_STATS
|
||||
_mstats.tbsplit++;
|
||||
_mstats.nsplit[nu]++;
|
||||
#endif
|
||||
|
||||
/* Figure out how many blocks we'll get. */
|
||||
siz = binsize (nu); /* original block size */
|
||||
nblks = siz / binsize (nbuck); /* should be 2 most of the time */
|
||||
|
||||
/* And add it to nextf[nbuck] */
|
||||
siz = binsize (nbuck); /* XXX - resetting here */
|
||||
nh = mp;
|
||||
while (1)
|
||||
{
|
||||
mp->mh_alloc = ISFREE;
|
||||
mp->mh_index = nbuck;
|
||||
if (--nblks <= 0) break;
|
||||
CHAIN (mp) = (union mhead *)((char *)mp + siz);
|
||||
mp = (union mhead *)((char *)mp + siz);
|
||||
}
|
||||
busy[nbuck] = 1;
|
||||
CHAIN (mp) = nextf[nbuck];
|
||||
nextf[nbuck] = nh;
|
||||
busy[nbuck] = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
block_signals (setp, osetp)
|
||||
sigset_t *setp, *osetp;
|
||||
@@ -490,9 +548,10 @@ lesscore (nu) /* give system back some memory */
|
||||
_mstats.nlesscore[nu]++;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Ask system for more memory; add to NEXTF[NU]. BUSY[NU] must be set to 1. */
|
||||
static void
|
||||
morecore (nu) /* ask system for more memory */
|
||||
morecore (nu)
|
||||
register int nu; /* size index to get more of */
|
||||
{
|
||||
register union mhead *mp;
|
||||
@@ -531,7 +590,7 @@ morecore (nu) /* ask system for more memory */
|
||||
}
|
||||
|
||||
/* Try to coalesce two adjacent blocks from the free list on nextf[nu - 1],
|
||||
if we can, and we're withing the range of the block coalescing limits. */
|
||||
if we can, and we're within the range of the block coalescing limits. */
|
||||
if (nu >= COMBINE_MIN && nu < COMBINE_MAX && busy[nu - 1] == 0 && nextf[nu - 1])
|
||||
{
|
||||
bcoalesce (nu);
|
||||
@@ -852,9 +911,8 @@ internal_free (mem, file, line, flags)
|
||||
{
|
||||
/* If above LESSCORE_FRC, give back unconditionally. This should be set
|
||||
high enough to be infrequently encountered. If between LESSCORE_MIN
|
||||
and LESSCORE_FRC, call lesscore if the bucket is marked as busy (in
|
||||
which case we would punt below and leak memory) or if there's already
|
||||
a block on the free list. */
|
||||
and LESSCORE_FRC, call lesscore if the bucket is marked as busy or if
|
||||
there's already a block on the free list. */
|
||||
if ((nunits >= LESSCORE_FRC) || busy[nunits] || nextf[nunits] != 0)
|
||||
{
|
||||
lesscore (nunits);
|
||||
@@ -869,11 +927,14 @@ internal_free (mem, file, line, flags)
|
||||
#endif
|
||||
|
||||
ASSERT (nunits < NBUCKETS);
|
||||
p->mh_alloc = ISFREE;
|
||||
|
||||
if (busy[nunits] == 1)
|
||||
return; /* this is bogus, but at least it won't corrupt the chains */
|
||||
{
|
||||
xsplit (p, nunits); /* split block and add to different chain */
|
||||
goto free_return;
|
||||
}
|
||||
|
||||
p->mh_alloc = ISFREE;
|
||||
/* Protect against signal handlers calling malloc. */
|
||||
busy[nunits] = 1;
|
||||
/* Put this block on the free list. */
|
||||
|
||||
+89
-28
@@ -221,7 +221,7 @@ typedef union _malloc_guard {
|
||||
|
||||
static union mhead *nextf[NBUCKETS];
|
||||
|
||||
/* busy[i] is nonzero while allocation of block size i is in progress. */
|
||||
/* busy[i] is nonzero while allocation or free of block size i is in progress. */
|
||||
|
||||
static char busy[NBUCKETS];
|
||||
|
||||
@@ -246,7 +246,7 @@ static unsigned long binsizes[NBUCKETS] = {
|
||||
static PTR_T internal_malloc __P((size_t, const char *, int, int));
|
||||
static PTR_T internal_realloc __P((PTR_T, size_t, const char *, int, int));
|
||||
static void internal_free __P((PTR_T, const char *, int, int));
|
||||
static PTR_T internal_memalign __P((unsigned int, size_t, const char *, int, int));
|
||||
static PTR_T internal_memalign __P((size_t, size_t, const char *, int, int));
|
||||
#ifndef NO_CALLOC
|
||||
static PTR_T internal_calloc __P((size_t, size_t, const char *, int, int));
|
||||
static void internal_cfree __P((PTR_T, const char *, int, int));
|
||||
@@ -323,7 +323,8 @@ xbotch (mem, e, s, file, line)
|
||||
|
||||
/* Coalesce two adjacent free blocks off the free list for size NU - 1,
|
||||
as long as we can find two adjacent free blocks. nextf[NU -1] is
|
||||
assumed to not be busy; the caller (morecore()) checks for this. */
|
||||
assumed to not be busy; the caller (morecore()) checks for this.
|
||||
BUSY[NU] must be set to 1. */
|
||||
static void
|
||||
bcoalesce (nu)
|
||||
register int nu;
|
||||
@@ -333,9 +334,10 @@ bcoalesce (nu)
|
||||
unsigned long siz;
|
||||
|
||||
nbuck = nu - 1;
|
||||
if (nextf[nbuck] == 0)
|
||||
if (nextf[nbuck] == 0 || busy[nbuck])
|
||||
return;
|
||||
|
||||
busy[nbuck] = 1;
|
||||
siz = binsize (nbuck);
|
||||
|
||||
mp2 = mp1 = nextf[nbuck];
|
||||
@@ -346,22 +348,27 @@ bcoalesce (nu)
|
||||
mp1 = mp;
|
||||
mp = CHAIN (mp);
|
||||
}
|
||||
|
||||
if (mp == 0)
|
||||
return;
|
||||
{
|
||||
busy[nbuck] = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/* OK, now we have mp1 pointing to the block we want to add to nextf[NU].
|
||||
CHAIN(mp2) must equal mp1. Check that mp1 and mp are adjacent. */
|
||||
if (mp2 != mp1 && CHAIN(mp2) != mp1)
|
||||
xbotch ((PTR_T)0, 0, "bcoalesce: CHAIN(mp2) != mp1", (char *)NULL, 0);
|
||||
{
|
||||
busy[nbuck] = 0;
|
||||
xbotch ((PTR_T)0, 0, "bcoalesce: CHAIN(mp2) != mp1", (char *)NULL, 0);
|
||||
}
|
||||
|
||||
#ifdef MALLOC_DEBUG
|
||||
if (CHAIN (mp1) != (union mhead *)((char *)mp1 + siz))
|
||||
return; /* not adjacent */
|
||||
#endif
|
||||
|
||||
#ifdef MALLOC_STATS
|
||||
_mstats.tbcoalesce++;
|
||||
_mstats.ncoalesce[nbuck]++;
|
||||
{
|
||||
busy[nbuck] = 0;
|
||||
return; /* not adjacent */
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Since they are adjacent, remove them from the free list */
|
||||
@@ -369,6 +376,12 @@ bcoalesce (nu)
|
||||
nextf[nbuck] = CHAIN (mp);
|
||||
else
|
||||
CHAIN (mp2) = CHAIN (mp);
|
||||
busy[nbuck] = 0;
|
||||
|
||||
#ifdef MALLOC_STATS
|
||||
_mstats.tbcoalesce++;
|
||||
_mstats.ncoalesce[nbuck]++;
|
||||
#endif
|
||||
|
||||
/* And add the combined two blocks to nextf[NU]. */
|
||||
mp1->mh_alloc = ISFREE;
|
||||
@@ -380,7 +393,7 @@ bcoalesce (nu)
|
||||
/* Split a block at index > NU (but less than SPLIT_MAX) into a set of
|
||||
blocks of the correct size, and attach them to nextf[NU]. nextf[NU]
|
||||
is assumed to be empty. Must be called with signals blocked (e.g.,
|
||||
by morecore()). */
|
||||
by morecore()). BUSY[NU] must be set to 1. */
|
||||
static void
|
||||
bsplit (nu)
|
||||
register int nu;
|
||||
@@ -416,6 +429,12 @@ bsplit (nu)
|
||||
/* XXX might want to split only if nextf[nbuck] has >= 2 blocks free
|
||||
and nbuck is below some threshold. */
|
||||
|
||||
/* Remove the block from the chain of larger blocks. */
|
||||
busy[nbuck] = 1;
|
||||
mp = nextf[nbuck];
|
||||
nextf[nbuck] = CHAIN (mp);
|
||||
busy[nbuck] = 0;
|
||||
|
||||
#ifdef MALLOC_STATS
|
||||
_mstats.tbsplit++;
|
||||
_mstats.nsplit[nbuck]++;
|
||||
@@ -425,10 +444,6 @@ bsplit (nu)
|
||||
siz = binsize (nu);
|
||||
nblks = binsize (nbuck) / siz;
|
||||
|
||||
/* Remove the block from the chain of larger blocks. */
|
||||
mp = nextf[nbuck];
|
||||
nextf[nbuck] = CHAIN (mp);
|
||||
|
||||
/* Split the block and put it on the requested chain. */
|
||||
nextf[nu] = mp;
|
||||
while (1)
|
||||
@@ -442,6 +457,49 @@ bsplit (nu)
|
||||
CHAIN (mp) = 0;
|
||||
}
|
||||
|
||||
/* Take the memory block MP and add it to a chain < NU. NU is the right bucket,
|
||||
but is busy. This avoids memory orphaning. */
|
||||
static void
|
||||
xsplit (mp, nu)
|
||||
union mhead *mp;
|
||||
int nu;
|
||||
{
|
||||
union mhead *nh;
|
||||
int nbuck, nblks, split_max;
|
||||
unsigned long siz;
|
||||
|
||||
nbuck = nu - 1;
|
||||
while (nbuck >= SPLIT_MIN && busy[nbuck])
|
||||
nbuck--;
|
||||
if (nbuck < SPLIT_MIN)
|
||||
return;
|
||||
|
||||
#ifdef MALLOC_STATS
|
||||
_mstats.tbsplit++;
|
||||
_mstats.nsplit[nu]++;
|
||||
#endif
|
||||
|
||||
/* Figure out how many blocks we'll get. */
|
||||
siz = binsize (nu); /* original block size */
|
||||
nblks = siz / binsize (nbuck); /* should be 2 most of the time */
|
||||
|
||||
/* And add it to nextf[nbuck] */
|
||||
siz = binsize (nbuck); /* XXX - resetting here */
|
||||
nh = mp;
|
||||
while (1)
|
||||
{
|
||||
mp->mh_alloc = ISFREE;
|
||||
mp->mh_index = nbuck;
|
||||
if (--nblks <= 0) break;
|
||||
CHAIN (mp) = (union mhead *)((char *)mp + siz);
|
||||
mp = (union mhead *)((char *)mp + siz);
|
||||
}
|
||||
busy[nbuck] = 1;
|
||||
CHAIN (mp) = nextf[nbuck];
|
||||
nextf[nbuck] = nh;
|
||||
busy[nbuck] = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
block_signals (setp, osetp)
|
||||
sigset_t *setp, *osetp;
|
||||
@@ -490,9 +548,10 @@ lesscore (nu) /* give system back some memory */
|
||||
_mstats.nlesscore[nu]++;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Ask system for more memory; add to NEXTF[NU]. BUSY[NU] must be set to 1. */
|
||||
static void
|
||||
morecore (nu) /* ask system for more memory */
|
||||
morecore (nu)
|
||||
register int nu; /* size index to get more of */
|
||||
{
|
||||
register union mhead *mp;
|
||||
@@ -531,7 +590,7 @@ morecore (nu) /* ask system for more memory */
|
||||
}
|
||||
|
||||
/* Try to coalesce two adjacent blocks from the free list on nextf[nu - 1],
|
||||
if we can, and we're withing the range of the block coalescing limits. */
|
||||
if we can, and we're within the range of the block coalescing limits. */
|
||||
if (nu >= COMBINE_MIN && nu < COMBINE_MAX && busy[nu - 1] == 0 && nextf[nu - 1])
|
||||
{
|
||||
bcoalesce (nu);
|
||||
@@ -852,9 +911,8 @@ internal_free (mem, file, line, flags)
|
||||
{
|
||||
/* If above LESSCORE_FRC, give back unconditionally. This should be set
|
||||
high enough to be infrequently encountered. If between LESSCORE_MIN
|
||||
and LESSCORE_FRC, call lesscore if the bucket is marked as busy (in
|
||||
which case we would punt below and leak memory) or if there's already
|
||||
a block on the free list. */
|
||||
and LESSCORE_FRC, call lesscore if the bucket is marked as busy or if
|
||||
there's already a block on the free list. */
|
||||
if ((nunits >= LESSCORE_FRC) || busy[nunits] || nextf[nunits] != 0)
|
||||
{
|
||||
lesscore (nunits);
|
||||
@@ -869,11 +927,14 @@ internal_free (mem, file, line, flags)
|
||||
#endif
|
||||
|
||||
ASSERT (nunits < NBUCKETS);
|
||||
p->mh_alloc = ISFREE;
|
||||
|
||||
if (busy[nunits] == 1)
|
||||
return; /* this is bogus, but at least it won't corrupt the chains */
|
||||
{
|
||||
xsplit (p, nunits); /* split block and add to different chain */
|
||||
goto free_return;
|
||||
}
|
||||
|
||||
p->mh_alloc = ISFREE;
|
||||
/* Protect against signal handlers calling malloc. */
|
||||
busy[nunits] = 1;
|
||||
/* Put this block on the free list. */
|
||||
@@ -1026,7 +1087,7 @@ internal_realloc (mem, n, file, line, flags)
|
||||
|
||||
static PTR_T
|
||||
internal_memalign (alignment, size, file, line, flags)
|
||||
unsigned int alignment;
|
||||
size_t alignment;
|
||||
size_t size;
|
||||
const char *file;
|
||||
int line, flags;
|
||||
@@ -1145,7 +1206,7 @@ sh_free (mem, file, line)
|
||||
|
||||
PTR_T
|
||||
sh_memalign (alignment, size, file, line)
|
||||
unsigned int alignment;
|
||||
size_t alignment;
|
||||
size_t size;
|
||||
const char *file;
|
||||
int line;
|
||||
@@ -1212,7 +1273,7 @@ free (mem)
|
||||
|
||||
PTR_T
|
||||
memalign (alignment, size)
|
||||
unsigned int alignment;
|
||||
size_t alignment;
|
||||
size_t size;
|
||||
{
|
||||
return internal_memalign (alignment, size, (char *)NULL, 0, 0);
|
||||
|
||||
+2
-2
@@ -88,7 +88,7 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
|
||||
shquote.c strtrans.c strindex.c snprintf.c mailstat.c \
|
||||
fmtulong.c fmtullong.c fmtumax.c shmatch.c strnlen.c \
|
||||
strtoll.c strtoull.c strtoimax.c strtoumax.c memset.c strstr.c \
|
||||
mktime.c strftime.c xstrchr.c zcatfd.c
|
||||
mktime.c strftime.c xstrchr.c zcatfd.c winsize.c
|
||||
|
||||
# The header files for this library.
|
||||
HSOURCES =
|
||||
@@ -100,7 +100,7 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \
|
||||
netconn.o netopen.o timeval.o makepath.o pathcanon.o \
|
||||
pathphys.o tmpfile.o stringlist.o stringvec.o spell.o shquote.o \
|
||||
strtrans.o strindex.o snprintf.o mailstat.o fmtulong.o \
|
||||
fmtullong.o fmtumax.o xstrchr.o zcatfd.o ${LIBOBJS}
|
||||
fmtullong.o fmtumax.o xstrchr.o zcatfd.o winsize.o ${LIBOBJS}
|
||||
|
||||
SUPPORT = Makefile
|
||||
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
/* Handle window size changes and information. */
|
||||
|
||||
/* Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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.
|
||||
|
||||
Bash 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 Bash; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdc.h>
|
||||
|
||||
#include "bashtypes.h"
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
|
||||
/* For struct winsize on SCO */
|
||||
/* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */
|
||||
# if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH)
|
||||
# if defined (HAVE_SYS_STREAM_H)
|
||||
# include <sys/stream.h>
|
||||
# endif
|
||||
# include <sys/ptem.h>
|
||||
# endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
|
||||
#endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Return the fd from which we are actually getting input. */
|
||||
#define input_tty() (shell_tty != -1) ? shell_tty : fileno (stderr)
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
extern int shell_tty;
|
||||
|
||||
#if defined (READLINE)
|
||||
extern void rl_set_screen_size __P((int, int));
|
||||
#endif
|
||||
|
||||
void
|
||||
get_new_window_size (from_sig)
|
||||
int from_sig;
|
||||
{
|
||||
#if defined (TIOCGWINSZ)
|
||||
struct winsize win;
|
||||
int tty;
|
||||
|
||||
tty = input_tty ();
|
||||
if (tty >= 0 && (ioctl (tty, TIOCGWINSZ, &win) == 0) &&
|
||||
win.ws_row > 0 && win.ws_col > 0)
|
||||
{
|
||||
sh_set_lines_and_columns (win.ws_row, win.ws_col);
|
||||
#if defined (READLINE)
|
||||
rl_set_screen_size (win.ws_row, win.ws_col);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
/* Handle window size changes and information. */
|
||||
|
||||
/* Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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.
|
||||
|
||||
Bash 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 Bash; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "bashtypes.h"
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
|
||||
/* For struct winsize on SCO */
|
||||
/* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */
|
||||
# if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH)
|
||||
# if defined (HAVE_SYS_STREAM_H)
|
||||
# include <sys/stream.h>
|
||||
# endif
|
||||
# include <sys/ptem.h>
|
||||
# endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
|
||||
#endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* Return the fd from which we are actually getting input. */
|
||||
#define input_tty() (shell_tty != -1) ? shell_tty : fileno (stderr)
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
extern int shell_tty;
|
||||
|
||||
#if defined (READLINE)
|
||||
extern void rl_set_screen_size __P((int, int));
|
||||
#endif
|
||||
|
||||
void
|
||||
get_new_window_size (from_sig)
|
||||
int from_sig;
|
||||
{
|
||||
#if defined (TIOCGWINSZ)
|
||||
struct winsize win;
|
||||
int tty;
|
||||
|
||||
tty = input_tty ();
|
||||
if (tty >= 0 && (ioctl (tty, TIOCGWINSZ, &win) == 0) &&
|
||||
win.ws_row > 0 && win.ws_col > 0)
|
||||
{
|
||||
sh_set_lines_and_columns (win.ws_row, win.ws_col);
|
||||
#if defined (READLINE)
|
||||
rl_set_screen_size (win.ws_row, win.ws_col);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
/* This file works under BSD, System V, minix, and Posix systems. It does
|
||||
not implement job control. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -41,17 +41,6 @@
|
||||
/* Need to include this up here for *_TTY_DRIVER definitions. */
|
||||
#include "shtty.h"
|
||||
|
||||
#if !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
|
||||
/* For struct winsize on SCO */
|
||||
/* sys/ptem.h has winsize but needs mblk_t from sys/stream.h */
|
||||
# if defined (HAVE_SYS_PTEM_H) && defined (TIOCGWINSZ) && defined (SIGWINCH)
|
||||
# if defined (HAVE_SYS_STREAM_H)
|
||||
# include <sys/stream.h>
|
||||
# endif
|
||||
# include <sys/ptem.h>
|
||||
# endif /* HAVE_SYS_PTEM_H && TIOCGWINSZ && SIGWINCH */
|
||||
#endif /* !STRUCT_WINSIZE_IN_SYS_IOCTL */
|
||||
|
||||
#include "bashintl.h"
|
||||
|
||||
#include "shell.h"
|
||||
@@ -82,10 +71,6 @@
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
#if defined (READLINE)
|
||||
extern void rl_set_screen_size __P((int, int));
|
||||
#endif
|
||||
|
||||
extern int interactive, interactive_shell, login_shell;
|
||||
extern int subshell_environment;
|
||||
extern int last_command_exit_value, last_command_exit_signal;
|
||||
@@ -148,8 +133,6 @@ static int get_pid_flags __P((pid_t));
|
||||
static void add_pid __P((pid_t, int));
|
||||
static void mark_dead_jobs_as_notified __P((int));
|
||||
|
||||
static void get_new_window_size __P((int));
|
||||
static sighandler sigwinch_sighandler __P((int));
|
||||
static sighandler wait_sigint_handler __P((int));
|
||||
static char *j_strsignal __P((int));
|
||||
|
||||
@@ -424,69 +407,11 @@ initialize_job_control (force)
|
||||
get_tty_state ();
|
||||
}
|
||||
|
||||
#if defined (TIOCGWINSZ) && defined (SIGWINCH)
|
||||
static SigHandler *old_winch = (SigHandler *)SIG_DFL;
|
||||
|
||||
static void
|
||||
get_new_window_size (from_sig)
|
||||
int from_sig;
|
||||
{
|
||||
struct winsize win;
|
||||
int tty;
|
||||
|
||||
tty = input_tty ();
|
||||
if (tty >= 0 && (ioctl (tty, TIOCGWINSZ, &win) == 0) &&
|
||||
win.ws_row > 0 && win.ws_col > 0)
|
||||
{
|
||||
#if defined (aixpc)
|
||||
shell_tty_info.c_winsize = win; /* structure copying */
|
||||
#endif
|
||||
sh_set_lines_and_columns (win.ws_row, win.ws_col);
|
||||
#if defined (READLINE)
|
||||
rl_set_screen_size (win.ws_row, win.ws_col);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
static sighandler
|
||||
sigwinch_sighandler (sig)
|
||||
int sig;
|
||||
{
|
||||
#if defined (MUST_REINSTALL_SIGHANDLERS)
|
||||
set_signal_handler (SIGWINCH, sigwinch_sighandler);
|
||||
#endif /* MUST_REINSTALL_SIGHANDLERS */
|
||||
get_new_window_size (1);
|
||||
}
|
||||
#else
|
||||
static void
|
||||
get_new_window_size (from_sig)
|
||||
int from_sig;
|
||||
{
|
||||
}
|
||||
#endif /* TIOCGWINSZ && SIGWINCH */
|
||||
|
||||
void
|
||||
set_sigwinch_handler ()
|
||||
{
|
||||
#if defined (TIOCGWINSZ) && defined (SIGWINCH)
|
||||
old_winch = set_signal_handler (SIGWINCH, sigwinch_sighandler);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
unset_sigwinch_handler ()
|
||||
{
|
||||
#if defined (TIOCGWINSZ) && defined (SIGWINCH)
|
||||
set_signal_handler (SIGWINCH, old_winch);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Setup this shell to handle C-C, etc. */
|
||||
void
|
||||
initialize_job_signals ()
|
||||
{
|
||||
set_signal_handler (SIGINT, sigint_sighandler);
|
||||
set_sigwinch_handler ();
|
||||
|
||||
/* If this is a login shell we don't wish to be disturbed by
|
||||
stop signals. */
|
||||
|
||||
@@ -1873,6 +1873,12 @@ shell_getc (remove_quoted_newline)
|
||||
|
||||
QUIT;
|
||||
|
||||
if (sigwinch_received)
|
||||
{
|
||||
sigwinch_received = 0;
|
||||
get_new_window_size (0);
|
||||
}
|
||||
|
||||
if (eol_ungetc_lookahead)
|
||||
{
|
||||
c = eol_ungetc_lookahead;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* sig.c - interface for shell signal handlers and signal initialization. */
|
||||
|
||||
/* Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1994-2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -61,6 +61,9 @@ extern int parse_and_execute_level, shell_initialized;
|
||||
/* Non-zero after SIGINT. */
|
||||
int interrupt_state;
|
||||
|
||||
/* Non-zero after SIGWINCH */
|
||||
volatile int sigwinch_received = 0;
|
||||
|
||||
/* The environment at the top-level R-E loop. We use this in
|
||||
the case of error return. */
|
||||
procenv_t top_level;
|
||||
@@ -73,6 +76,10 @@ sigset_t top_level_mask;
|
||||
/* When non-zero, we throw_to_top_level (). */
|
||||
int interrupt_immediately = 0;
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
static SigHandler *old_winch = (SigHandler *)SIG_DFL;
|
||||
#endif
|
||||
|
||||
static void initialize_shell_signals __P((void));
|
||||
|
||||
void
|
||||
@@ -295,6 +302,7 @@ initialize_shell_signals ()
|
||||
{
|
||||
set_signal_handler (SIGINT, sigint_sighandler);
|
||||
set_signal_handler (SIGTERM, SIG_IGN);
|
||||
set_sigwinch_handler ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,6 +473,35 @@ sigint_sighandler (sig)
|
||||
SIGRETURN (0);
|
||||
}
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
sighandler
|
||||
sigwinch_sighandler (sig)
|
||||
int sig;
|
||||
{
|
||||
#if defined (MUST_REINSTALL_SIGHANDLERS)
|
||||
set_signal_handler (SIGWINCH, sigwinch_sighandler);
|
||||
#endif /* MUST_REINSTALL_SIGHANDLERS */
|
||||
sigwinch_received = 1;
|
||||
SIGRETURN (0);
|
||||
}
|
||||
#endif /* SIGWINCH */
|
||||
|
||||
void
|
||||
set_sigwinch_handler ()
|
||||
{
|
||||
#if defined (SIGWINCH)
|
||||
old_winch = set_signal_handler (SIGWINCH, sigwinch_sighandler);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
unset_sigwinch_handler ()
|
||||
{
|
||||
#if defined (SIGWINCH)
|
||||
set_signal_handler (SIGWINCH, old_winch);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Signal functions used by the rest of the code. */
|
||||
#if !defined (HAVE_POSIX_SIGNALS)
|
||||
|
||||
|
||||
@@ -61,6 +61,9 @@ extern int parse_and_execute_level, shell_initialized;
|
||||
/* Non-zero after SIGINT. */
|
||||
int interrupt_state;
|
||||
|
||||
/* Non-zero after SIGWINCH */
|
||||
volatile int sigwinch_received = 0;
|
||||
|
||||
/* The environment at the top-level R-E loop. We use this in
|
||||
the case of error return. */
|
||||
procenv_t top_level;
|
||||
@@ -73,6 +76,10 @@ sigset_t top_level_mask;
|
||||
/* When non-zero, we throw_to_top_level (). */
|
||||
int interrupt_immediately = 0;
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
static SigHandler *old_winch = (SigHandler *)SIG_DFL;
|
||||
#endif
|
||||
|
||||
static void initialize_shell_signals __P((void));
|
||||
|
||||
void
|
||||
@@ -230,6 +237,7 @@ initialize_terminating_signals ()
|
||||
|
||||
sigaction (XSIG (i), &act, &oact);
|
||||
XHANDLER(i) = oact.sa_handler;
|
||||
XSAFLAGS(i) = oact.sa_flags;
|
||||
/* Don't do anything with signals that are ignored at shell entry
|
||||
if the shell is not interactive. */
|
||||
if (!interactive_shell && XHANDLER (i) == SIG_IGN)
|
||||
@@ -252,6 +260,7 @@ initialize_terminating_signals ()
|
||||
continue;
|
||||
|
||||
XHANDLER(i) = signal (XSIG (i), termination_unwind_protect);
|
||||
XSAFLAGS(i) = 0;
|
||||
/* Don't do anything with signals that are ignored at shell entry
|
||||
if the shell is not interactive. */
|
||||
if (!interactive_shell && XHANDLER (i) == SIG_IGN)
|
||||
@@ -293,6 +302,7 @@ initialize_shell_signals ()
|
||||
{
|
||||
set_signal_handler (SIGINT, sigint_sighandler);
|
||||
set_signal_handler (SIGTERM, SIG_IGN);
|
||||
set_sigwinch_handler ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,6 +328,7 @@ reset_terminating_signals ()
|
||||
continue;
|
||||
|
||||
act.sa_handler = XHANDLER (i);
|
||||
act.sa_flags = XSAFLAGS (i);
|
||||
sigaction (XSIG (i), &act, (struct sigaction *) NULL);
|
||||
}
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
@@ -410,10 +421,14 @@ sighandler
|
||||
termination_unwind_protect (sig)
|
||||
int sig;
|
||||
{
|
||||
/* I don't believe this condition ever tests true. */
|
||||
if (sig == SIGINT && signal_is_trapped (SIGINT))
|
||||
run_interrupt_trap ();
|
||||
|
||||
#if defined (HISTORY)
|
||||
/* This might be unsafe, since it eventually calls functions POSIX says
|
||||
not to call from signal handlers. If it's a problem, take this code
|
||||
out. */
|
||||
if (interactive_shell && sig != SIGABRT)
|
||||
maybe_save_shell_history ();
|
||||
#endif /* HISTORY */
|
||||
@@ -458,6 +473,35 @@ sigint_sighandler (sig)
|
||||
SIGRETURN (0);
|
||||
}
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
sighandler
|
||||
sigwinch_sighandler (sig)
|
||||
int sig;
|
||||
{
|
||||
#if defined (MUST_REINSTALL_SIGHANDLERS)
|
||||
set_signal_handler (SIGWINCH, sigwinch_sighandler);
|
||||
#endif /* MUST_REINSTALL_SIGHANDLERS */
|
||||
sigwinch_received = 1;
|
||||
SIGRETURN (0);
|
||||
}
|
||||
#endif /* SIGWINCH */
|
||||
|
||||
void
|
||||
set_sigwinch_handler ()
|
||||
{
|
||||
#if defined (SIGWINCH)
|
||||
old_winch = set_signal_handler (SIGWINCH, sigwinch_sighandler);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
unset_sigwinch_handler ()
|
||||
{
|
||||
#if defined (SIGWINCH)
|
||||
set_signal_handler (SIGWINCH, old_winch);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Signal functions used by the rest of the code. */
|
||||
#if !defined (HAVE_POSIX_SIGNALS)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* sig.h -- header file for signal handler definitions. */
|
||||
|
||||
/* Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1994-2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -108,6 +108,9 @@ do { \
|
||||
|
||||
#endif /* JOB_CONTROL */
|
||||
|
||||
/* Extern variables */
|
||||
extern volatile int sigwinch_received;
|
||||
|
||||
/* Functions from sig.c. */
|
||||
extern sighandler termination_unwind_protect __P((int));
|
||||
extern sighandler sigint_sighandler __P((int));
|
||||
@@ -117,6 +120,10 @@ extern void reset_terminating_signals __P((void));
|
||||
extern void throw_to_top_level __P((void));
|
||||
extern void jump_to_top_level __P((int)) __attribute__((__noreturn__));
|
||||
|
||||
extern sighandler sigwinch_sighandler __P((int));
|
||||
extern void set_sigwinch_handler __P((void));
|
||||
extern void unset_sigwinch_handler __P((void));
|
||||
|
||||
/* Functions defined in trap.c. */
|
||||
extern SigHandler *set_sigint_handler __P((void));
|
||||
extern SigHandler *trap_to_sighandler __P((int));
|
||||
|
||||
@@ -81,6 +81,7 @@ extern int errno;
|
||||
/* Flags for the string extraction functions. */
|
||||
#define EX_NOALLOC 0x01 /* just skip; don't return substring */
|
||||
#define EX_VARNAME 0x02 /* variable name; for string_extract () */
|
||||
#define EX_REQMATCH 0x04 /* closing/matching delimiter required */
|
||||
|
||||
/* Flags for the `pflags' argument to param_expand() */
|
||||
#define PF_NOCOMSUB 0x01 /* Do not perform command substitution */
|
||||
@@ -165,6 +166,7 @@ static int glob_argv_flags_size;
|
||||
static WORD_LIST expand_word_error, expand_word_fatal;
|
||||
static WORD_DESC expand_wdesc_error, expand_wdesc_fatal;
|
||||
static char expand_param_error, expand_param_fatal;
|
||||
static char extract_string_error, extract_string_fatal;
|
||||
|
||||
/* Tell the expansion functions to not longjmp back to top_level on fatal
|
||||
errors. Enabled when doing completion and prompt string expansion. */
|
||||
@@ -543,7 +545,8 @@ sub_append_number (number, target, indx, size)
|
||||
is non-zero, and array variables have been compiled into the shell,
|
||||
everything between a `[' and a corresponding `]' is skipped over.
|
||||
If (flags & EX_NOALLOC) is non-zero, don't return the substring, just
|
||||
update SINDEX. */
|
||||
update SINDEX. If (flags & EX_REQMATCH) is non-zero, the string must
|
||||
contain a closing character from CHARLIST. */
|
||||
static char *
|
||||
string_extract (string, sindex, charlist, flags)
|
||||
char *string;
|
||||
@@ -552,12 +555,14 @@ string_extract (string, sindex, charlist, flags)
|
||||
int flags;
|
||||
{
|
||||
register int c, i;
|
||||
int found;
|
||||
size_t slen;
|
||||
char *temp;
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0;
|
||||
i = *sindex;
|
||||
found = 0;
|
||||
while (c = string[i])
|
||||
{
|
||||
if (c == '\\')
|
||||
@@ -578,13 +583,25 @@ string_extract (string, sindex, charlist, flags)
|
||||
}
|
||||
#endif
|
||||
else if (MEMBER (c, charlist))
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
ADVANCE_CHAR (string, slen, i);
|
||||
}
|
||||
|
||||
/* If we had to have a matching delimiter and didn't find one, return an
|
||||
error and let the caller deal with it. */
|
||||
if ((flags & EX_REQMATCH) && found == 0)
|
||||
{
|
||||
*sindex = i;
|
||||
return (&extract_string_error);
|
||||
}
|
||||
|
||||
temp = (flags & EX_NOALLOC) ? (char *)NULL : substring (string, *sindex, i);
|
||||
*sindex = i;
|
||||
|
||||
return (temp);
|
||||
}
|
||||
|
||||
@@ -6825,7 +6842,16 @@ add_string:
|
||||
if (expanded_something)
|
||||
*expanded_something = 1;
|
||||
|
||||
temp = string_extract (string, &sindex, "`", 0);
|
||||
temp = string_extract (string, &sindex, "`", EX_REQMATCH);
|
||||
if (temp == &extract_string_error || temp == &extract_string_fatal)
|
||||
{
|
||||
report_error ("bad substitution: no closing \"`\" in %s", string+t_index);
|
||||
free (string);
|
||||
free (istring);
|
||||
return ((temp == &extract_string_error) ? &expand_word_error
|
||||
: &expand_word_fatal);
|
||||
}
|
||||
|
||||
if (word->flags & W_NOCOMSUB)
|
||||
/* sindex + 1 because string[sindex] == '`' */
|
||||
temp1 = substring (string, t_index, sindex + 1);
|
||||
|
||||
@@ -81,6 +81,7 @@ extern int errno;
|
||||
/* Flags for the string extraction functions. */
|
||||
#define EX_NOALLOC 0x01 /* just skip; don't return substring */
|
||||
#define EX_VARNAME 0x02 /* variable name; for string_extract () */
|
||||
#define EX_REQMATCH 0x04 /* closing/matching delimiter required */
|
||||
|
||||
/* Flags for the `pflags' argument to param_expand() */
|
||||
#define PF_NOCOMSUB 0x01 /* Do not perform command substitution */
|
||||
@@ -165,6 +166,7 @@ static int glob_argv_flags_size;
|
||||
static WORD_LIST expand_word_error, expand_word_fatal;
|
||||
static WORD_DESC expand_wdesc_error, expand_wdesc_fatal;
|
||||
static char expand_param_error, expand_param_fatal;
|
||||
static char extract_string_error, extract_string_fatal;
|
||||
|
||||
/* Tell the expansion functions to not longjmp back to top_level on fatal
|
||||
errors. Enabled when doing completion and prompt string expansion. */
|
||||
@@ -543,7 +545,8 @@ sub_append_number (number, target, indx, size)
|
||||
is non-zero, and array variables have been compiled into the shell,
|
||||
everything between a `[' and a corresponding `]' is skipped over.
|
||||
If (flags & EX_NOALLOC) is non-zero, don't return the substring, just
|
||||
update SINDEX. */
|
||||
update SINDEX. If (flags & EX_REQMATCH) is non-zero, the string must
|
||||
contain a closing character from CHARLIST. */
|
||||
static char *
|
||||
string_extract (string, sindex, charlist, flags)
|
||||
char *string;
|
||||
@@ -552,12 +555,14 @@ string_extract (string, sindex, charlist, flags)
|
||||
int flags;
|
||||
{
|
||||
register int c, i;
|
||||
int found;
|
||||
size_t slen;
|
||||
char *temp;
|
||||
DECLARE_MBSTATE;
|
||||
|
||||
slen = (MB_CUR_MAX > 1) ? strlen (string + *sindex) + *sindex : 0;
|
||||
i = *sindex;
|
||||
found = 0;
|
||||
while (c = string[i])
|
||||
{
|
||||
if (c == '\\')
|
||||
@@ -578,13 +583,25 @@ string_extract (string, sindex, charlist, flags)
|
||||
}
|
||||
#endif
|
||||
else if (MEMBER (c, charlist))
|
||||
{
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
ADVANCE_CHAR (string, slen, i);
|
||||
}
|
||||
|
||||
/* If we had to have a matching delimiter and didn't find one, return an
|
||||
error and let the caller deal with it. */
|
||||
if ((flags & EX_REQMATCH) && found == 0)
|
||||
{
|
||||
*sindex = i;
|
||||
return (&extract_string_error);
|
||||
}
|
||||
|
||||
temp = (flags & EX_NOALLOC) ? (char *)NULL : substring (string, *sindex, i);
|
||||
*sindex = i;
|
||||
|
||||
return (temp);
|
||||
}
|
||||
|
||||
@@ -1000,9 +1017,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 +1027,7 @@ extract_array_assignment_list (string, sindex)
|
||||
*sindex = slen - 1;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2329,7 +2343,7 @@ do_assignment_no_expand (string)
|
||||
td.flags = W_ASSIGNMENT;
|
||||
td.word = string;
|
||||
|
||||
do_assignment_internal (&td, 0);
|
||||
return (do_assignment_internal (&td, 0));
|
||||
}
|
||||
|
||||
/***************************************************
|
||||
@@ -6828,7 +6842,16 @@ add_string:
|
||||
if (expanded_something)
|
||||
*expanded_something = 1;
|
||||
|
||||
temp = string_extract (string, &sindex, "`", 0);
|
||||
temp = string_extract (string, &sindex, "`", EX_REQMATCH);
|
||||
if (temp == &extract_string_error || temp == &extract_string_fatal)
|
||||
{
|
||||
free (string);
|
||||
free (istring);
|
||||
report_error ("bad substitution: no closing \"`\" in %s", string+t_index);
|
||||
return ((temp == &extract_string_error) ? &expand_word_error
|
||||
: &expand_word_fatal);
|
||||
}
|
||||
|
||||
if (word->flags & W_NOCOMSUB)
|
||||
/* sindex + 1 because string[sindex] == '`' */
|
||||
temp1 = substring (string, t_index, sindex + 1);
|
||||
@@ -7364,9 +7387,7 @@ setifs (v)
|
||||
#if 0
|
||||
ifs_value = v ? value_cell (v) : " \t\n";
|
||||
#else
|
||||
ifs_value = v ? value_cell (v) : (char *)0;
|
||||
if (ifs_value == 0)
|
||||
ifs_value = " \t\n";
|
||||
ifs_value = (v && value_cell (v)) ? value_cell (v) : " \t\n";
|
||||
#endif
|
||||
|
||||
/* Should really merge ifs_cmap with sh_syntaxtab. XXX - doesn't yet
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
|
||||
@@ -33,8 +33,6 @@ x3y
|
||||
x10y x9y x8y x7y x6y x5y x4y x3y x2y x1y
|
||||
a b c d e f
|
||||
f e d c b a
|
||||
a _ ^ ] [ Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
|
||||
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ ] ^ _ a
|
||||
f
|
||||
{1..f}
|
||||
{f..1}
|
||||
|
||||
+2
-2
@@ -54,8 +54,8 @@ echo x{10..1}y
|
||||
echo {a..f}
|
||||
echo {f..a}
|
||||
|
||||
echo {a..A}
|
||||
echo {A..a}
|
||||
#echo {a..A}
|
||||
#echo {A..a}
|
||||
|
||||
echo {f..f}
|
||||
|
||||
|
||||
@@ -24,6 +24,9 @@ echo `zecho foo {1,2} bar`
|
||||
echo $(zecho foo {1,2} bar)
|
||||
|
||||
var=baz
|
||||
varx=vx
|
||||
vary=vy
|
||||
|
||||
echo foo{bar,${var}.}
|
||||
echo foo{bar,${var}}
|
||||
|
||||
@@ -31,6 +34,8 @@ echo "${var}"{x,y}
|
||||
echo $var{x,y}
|
||||
echo ${var}{x,y}
|
||||
|
||||
unset var varx vary
|
||||
|
||||
# new sequence brace operators
|
||||
echo {1..10}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user