commit bash-20120831 snapshot

This commit is contained in:
Chet Ramey
2012-09-13 11:55:04 -04:00
parent df0e4bfe75
commit a7ad477fe7
58 changed files with 67921 additions and 22187 deletions
+117 -11050
View File
File diff suppressed because it is too large Load Diff
+171 -11050
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -52,7 +52,7 @@ README f
RBASH f
AUTHORS f
Y2K f
configure.in f
configure.ac f
configure f 755
Makefile.in f
config-top.h f
@@ -792,6 +792,7 @@ tests/array10.sub f
tests/array11.sub f
tests/array12.sub f
tests/array13.sub f
tests/array14.sub f
tests/array-at-star f
tests/array2.right f
tests/assoc.tests f
+3 -3
View File
@@ -1,6 +1,6 @@
# Makefile for bash-4.2, version 4.7
# Makefile for bash-4.2, version 4.8
#
# Copyright (C) 1996-2011 Free Software Foundation, Inc.
# Copyright (C) 1996-2012 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
@@ -717,7 +717,7 @@ pathnames.h: Makefile $(srcdir)/pathnames.h.in
@${RM} pathnames.tmp
# comment out for distribution
$(srcdir)/configure: $(srcdir)/configure.in $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
$(srcdir)/configure: $(srcdir)/configure.ac $(srcdir)/aclocal.m4 $(srcdir)/config.h.in
cd $(srcdir) && autoconf
# for chet
+9
View File
@@ -305,6 +305,9 @@ assign_array_element_internal (entry, name, vname, sub, sublen, value, flags)
else
{
ind = array_expand_index (entry, sub, sublen);
/* negative subscripts to indexed arrays count back from end */
if (ind < 0)
ind = array_max_index (array_cell (entry)) + 1 + ind;
if (ind < 0)
{
err_badarraysub (name);
@@ -542,6 +545,9 @@ assign_compound_array_list (var, nlist, flags)
if (array_p (var))
{
ind = array_expand_index (var, w + 1, len);
/* negative subscripts to indexed arrays count back from end */
if (ind < 0)
ind = array_max_index (array_cell (var)) + 1 + ind;
if (ind < 0)
{
err_badarraysub (w);
@@ -742,6 +748,9 @@ unbind_array_element (var, sub)
else
{
ind = array_expand_index (var, sub, len+1);
/* negative subscripts to indexed arrays count back from end */
if (ind < 0)
ind = array_max_index (array_cell (var)) + 1 + ind;
if (ind < 0)
{
builtin_error ("[%s]: %s", sub, _(bash_badsub_errmsg));
File diff suppressed because it is too large Load Diff
+69
View File
@@ -249,6 +249,75 @@
'AC_HEADER_DIRENT' => 1,
'AC_CHECK_FUNCS' => 1
}
], 'Autom4te::Request' ),
bless( [
'3',
1,
[
'/sw/share/autoconf'
],
[
'/sw/share/autoconf/autoconf/autoconf.m4f',
'aclocal.m4',
'configure.ac'
],
{
'AM_PROG_F77_C_O' => 1,
'_LT_AC_TAGCONFIG' => 1,
'm4_pattern_forbid' => 1,
'AC_INIT' => 1,
'AC_CANONICAL_TARGET' => 1,
'_AM_COND_IF' => 1,
'AC_CONFIG_LIBOBJ_DIR' => 1,
'AC_SUBST' => 1,
'AC_CANONICAL_HOST' => 1,
'AC_FC_SRCEXT' => 1,
'AC_PROG_LIBTOOL' => 1,
'AM_INIT_AUTOMAKE' => 1,
'AC_CONFIG_SUBDIRS' => 1,
'AM_PATH_GUILE' => 1,
'AM_AUTOMAKE_VERSION' => 1,
'LT_CONFIG_LTDL_DIR' => 1,
'AC_CONFIG_LINKS' => 1,
'AC_REQUIRE_AUX_FILE' => 1,
'LT_SUPPORTED_TAG' => 1,
'm4_sinclude' => 1,
'AM_MAINTAINER_MODE' => 1,
'AM_NLS' => 1,
'AM_GNU_GETTEXT_INTL_SUBDIR' => 1,
'_m4_warn' => 1,
'AM_MAKEFILE_INCLUDE' => 1,
'AM_PROG_CXX_C_O' => 1,
'_AM_MAKEFILE_INCLUDE' => 1,
'_AM_COND_ENDIF' => 1,
'AM_ENABLE_MULTILIB' => 1,
'AM_SILENT_RULES' => 1,
'AM_PROG_MOC' => 1,
'AC_CONFIG_FILES' => 1,
'LT_INIT' => 1,
'include' => 1,
'AM_GNU_GETTEXT' => 1,
'AM_PROG_AR' => 1,
'AC_LIBSOURCE' => 1,
'AC_CANONICAL_BUILD' => 1,
'AM_PROG_FC_C_O' => 1,
'AC_FC_FREEFORM' => 1,
'AH_OUTPUT' => 1,
'AC_CONFIG_AUX_DIR' => 1,
'_AM_SUBST_NOTMAKE' => 1,
'm4_pattern_allow' => 1,
'AM_PROG_CC_C_O' => 1,
'sinclude' => 1,
'AM_CONDITIONAL' => 1,
'AC_CANONICAL_SYSTEM' => 1,
'AM_XGETTEXT_OPTION' => 1,
'AC_CONFIG_HEADERS' => 1,
'AC_DEFINE_TRACE_LITERAL' => 1,
'AM_POT_TOOLS' => 1,
'm4_include' => 1,
'_AM_COND_ELSE' => 1,
'AC_SUBST_TRACE' => 1
}
], 'Autom4te::Request' )
);
File diff suppressed because it is too large Load Diff
Vendored
+1 -1
View File
@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in for Bash 4.2, version 4.049.
# From configure.ac for Bash 4.2, version 4.050.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for bash 4.2-maint.
#
+1188
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,3 +1,3 @@
# Make sure the first target in the makefile is the right one
configure: configure.in aclocal.m4 config.h.in
configure: configure.ac aclocal.m4 config.h.in
autoconf
+31 -5
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Fri Aug 24 11:50:05 EDT 2012
.\" Last Change: Tue Aug 28 17:20:54 EDT 2012
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2012 August 24" "GNU Bash 4.2"
.TH BASH 1 "2012 August 28" "GNU Bash 4.2"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -1910,6 +1910,13 @@ A sample value is
.if t \f(CW".:~:/usr"\fP.
.if n ".:~:/usr".
.TP
.B CHILD_MAX
Set the number of exited child status values for the shell to remember.
Bash will not allow this value to be decreased below a Posix-mandated
minimum, and there is a maximum value (currently 8192) that this may
not exceed.
The minimum value is system-dependent.
.TP
.B COLUMNS
Used by the \fBselect\fP compound command to determine the terminal width
when printing selection lists. Automatically set in an interactive shell
@@ -2457,6 +2464,12 @@ This syntax is also accepted by the
.B declare
builtin. Individual array elements may be assigned to using the
\fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
When assigning to an indexed array, if
.I name
is subscripted by a negative number, that number is
interpreted as relative to one greater than the maximum index of
\fIname\fP, so negative indices count back from the end of the
array, and an index of \-1 references the last element.
.PP
Any element of an array may be referenced using
${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
@@ -2487,9 +2500,10 @@ referencing the array with a subscript of 0.
If the
.I subscript
used to reference an element of an indexed array
evaluates to a number less than zero, it is used as
an offset from one greater than the array's maximum index (so a subcript
of -1 refers to the last element of the array).
evaluates to a number less than zero, it is
interpreted as relative to one greater than the maximum index of the array,
so negative indices count back from the end of the
array, and an index of \-1 references the last element.
.PP
An array variable is considered set if a subscript has been assigned a
value. The null string is a valid value.
@@ -2498,6 +2512,7 @@ The
.B unset
builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
destroys the array element at index \fIsubscript\fP.
Negative subscripts to indexed arrays are interpreted as described above.
Care must be taken to avoid unwanted side effects caused by pathname
expansion.
\fBunset\fP \fIname\fP, where \fIname\fP is an array, or
@@ -2898,6 +2913,12 @@ is an array name subscripted by
or
.BR @ ,
the value substituted is the number of elements in the array.
If
.I parameter
is an indexed array name subscripted by a negative number, that number is
interpreted as relative to one greater than the maximum index of
\fIparameter\fP, so negative indices count back from the end of the
array, and an index of \-1 references the last element.
.TP
${\fIparameter\fP\fB#\fP\fIword\fP}
.PD 0
@@ -5416,6 +5437,11 @@ possible partial completion (the possible completions don't share
a common prefix) cause the matches to be listed immediately instead
of ringing the bell.
.TP
.B show\-mode\-in\-prompt (Off)
If set to \fBOn\fP, add a character to the beginning of the prompt
indicating the editing mode: emacs (@), vi command (:) or vi
insertion (+).
.TP
.B skip\-completed\-text (Off)
If set to \fBOn\fP, this alters the default completion behavior when
inserting a single match into the line. It's only active when
+34 -6
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Sat Jul 14 14:31:31 EDT 2012
.\" Last Change: Tue Aug 28 17:20:54 EDT 2012
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2012 July 14" "GNU Bash 4.2"
.TH BASH 1 "2012 August 28" "GNU Bash 4.2"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -705,6 +705,7 @@ lexicographically using the current locale.
When the \fB==\fP and \fB!=\fP operators are used, the string to the
right of the operator is considered a pattern and matched according
to the rules described below under \fBPattern Matching\fP.
The \fB=\fP operator is equivalent to \fB==\fP.
If the shell option
.B nocasematch
is enabled, the match is performed without regard to the case
@@ -1909,6 +1910,12 @@ A sample value is
.if t \f(CW".:~:/usr"\fP.
.if n ".:~:/usr".
.TP
.B CHILD_MAX
Set the number of exited child status values for the shell to remember.
Bash will not allow this value to be decreased below a Posix-mandated
minimum, and there is a maximum value (currently 8192) that this may
not exceed.
.TP
.B COLUMNS
Used by the \fBselect\fP compound command to determine the terminal width
when printing selection lists. Automatically set in an interactive shell
@@ -2331,7 +2338,7 @@ The value of \fIp\fP determines whether or not the fraction is
included.
.IP
If this variable is not set, \fBbash\fP acts as if it had the
value \fB$\(aq\enreal\et%3lR\enuser\et%3lU\ensys\t%3lS\(aq\fP.
value \fB$\(aq\enreal\et%3lR\enuser\et%3lU\ensys\e\t%3lS\(aq\fP.
If the value is null, no timing information is displayed.
A trailing newline is added when the format string is displayed.
.PD 0
@@ -2456,6 +2463,12 @@ This syntax is also accepted by the
.B declare
builtin. Individual array elements may be assigned to using the
\fIname\fP[\fIsubscript\fP]=\fIvalue\fP syntax introduced above.
When assigning to an indexed array, if
.I name
is subscripted by a negative number, that number is
interpreted as relative to one greater than the maximum index of
\fIname\fP, so negative indices count back from the end of the
array, and an index of \-1 references the last element.
.PP
Any element of an array may be referenced using
${\fIname\fP[\fIsubscript\fP]}. The braces are required to avoid
@@ -2486,9 +2499,10 @@ referencing the array with a subscript of 0.
If the
.I subscript
used to reference an element of an indexed array
evaluates to a number less than zero, it is used as
an offset from one greater than the array's maximum index (so a subcript
of -1 refers to the last element of the array).
evaluates to a number less than zero, it is
interpreted as relative to one greater than the maximum index of the array,
so negative indices count back from the end of the
array, and an index of \-1 references the last element.
.PP
An array variable is considered set if a subscript has been assigned a
value. The null string is a valid value.
@@ -2497,6 +2511,7 @@ The
.B unset
builtin is used to destroy arrays. \fBunset\fP \fIname\fP[\fIsubscript\fP]
destroys the array element at index \fIsubscript\fP.
Negative subscripts to indexed arrays are interpreted as described above.
Care must be taken to avoid unwanted side effects caused by pathname
expansion.
\fBunset\fP \fIname\fP, where \fIname\fP is an array, or
@@ -2897,6 +2912,12 @@ is an array name subscripted by
or
.BR @ ,
the value substituted is the number of elements in the array.
If
.I parameter
is an indexed array name subscripted by a negative number, that number is
interpreted as relative to one greater than the maximum index of
\fIparameter\fP, so negative indices count back from the end of the
array, and an index of \-1 references the last element.
.TP
${\fIparameter\fP\fB#\fP\fIword\fP}
.PD 0
@@ -4232,6 +4253,8 @@ is non-zero.
.PD
True if the strings are equal. \fB=\fP should be used
with the \fBtest\fP command for POSIX conformance.
When used with the \fB[[\fP command, this performs pattern matching as
described above (\fBCompound Commands\fP).
.TP
\fIstring1\fP \fB!=\fP \fIstring2\fP
True if the strings are not equal.
@@ -5413,6 +5436,11 @@ possible partial completion (the possible completions don't share
a common prefix) cause the matches to be listed immediately instead
of ringing the bell.
.TP
.B show\-mode\-in\-prompt (Off)
If set to \fBOn\fP, add a character to the beginning of the prompt
indicating the editing mode: emacs (@), vi command (:) or vi
insertion (+).
.TP
.B skip\-completed\-text (Off)
If set to \fBOn\fP, this alters the default completion behavior when
inserting a single match into the line. It's only active when
+25 -5
View File
@@ -2034,6 +2034,11 @@ If @var{parameter} is @samp{*} or @samp{@@}, the value substituted
is the number of positional parameters.
If @var{parameter} is an array name subscripted by @samp{*} or @samp{@@},
the value substituted is the number of elements in the array.
If @var{parameter}
is an indexed array name subscripted by a negative number, that number is
interpreted as relative to one greater than the maximum index of
@var{parameter}, so negative indices count back from the end of the
array, and an index of -1 references the last element.
@item $@{@var{parameter}#@var{word}@}
@itemx $@{@var{parameter}##@var{word}@}
@@ -5365,6 +5370,13 @@ Note that setting @code{BASH_XTRACEFD} to 2 (the standard error file
descriptor) and then unsetting it will result in the standard error
being closed.
@item CHILD_MAX
Set the number of exited child status values for the shell to remember.
Bash will not allow this value to be decreased below a @sc{posix}-mandated
minimum, and there is a maximum value (currently 8192) that this may
not exceed.
The minimum value is system-dependent.
@item COLUMNS
Used by the @code{select} command to determine the terminal width
when printing selection lists. Automatically set by an interactive shell
@@ -6677,6 +6689,12 @@ This syntax is also accepted by the @code{declare}
builtin. Individual array elements may be assigned to using the
@code{@var{name}[@var{subscript}]=@var{value}} syntax introduced above.
When assigning to an indexed array, if @var{name}
is subscripted by a negative number, that number is
interpreted as relative to one greater than the maximum index of
@var{name}, so negative indices count back from the end of the
array, and an index of -1 references the last element.
Any element of an array may be referenced using
@code{$@{@var{name}[@var{subscript}]@}}.
The braces are required to avoid
@@ -6704,9 +6722,10 @@ Referencing an array variable without a subscript is equivalent to
referencing with a subscript of 0.
If the @var{subscript}
used to reference an element of an indexed array
evaluates to a number less than zero, it is used as
an offset from one greater than the array's maximum index (so a subcript
of -1 refers to the last element of the array).
evaluates to a number less than zero, it is
interpreted as relative to one greater than the maximum index of the array,
so negative indices count back from the end of the array,
and an index of -1 refers to the last element.
An array variable is considered set if a subscript has been assigned a
value. The null string is a valid value.
@@ -6714,6 +6733,7 @@ value. The null string is a valid value.
The @code{unset} builtin is used to destroy arrays.
@code{unset @var{name}[@var{subscript}]}
destroys the array element at index @var{subscript}.
Negative subscripts to indexed arrays are interpreted as described above.
Care must be taken to avoid unwanted side effects caused by filename
expansion.
@code{unset @var{name}}, where @var{name} is an array, removes the
@@ -7644,9 +7664,9 @@ to do them, and mail diffs or instructions to
@email{bash-maintainers@@gnu.org} so they can be
considered for the next release.
The file @file{configure.in} is used to create @code{configure}
The file @file{configure.ac} is used to create @code{configure}
by a program called Autoconf. You only need
@file{configure.in} if you want to change it or regenerate
@file{configure.ac} if you want to change it or regenerate
@code{configure} using a newer version of Autoconf. If
you do this, make sure you are using Autoconf version 2.50 or
newer.
+8603
View File
File diff suppressed because it is too large Load Diff
+2 -3
View File
@@ -2,11 +2,11 @@
Copyright (C) 1988-2012 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Fri Aug 24 11:49:45 EDT 2012
@set LASTCHANGE Tue Aug 28 17:19:20 EDT 2012
@set EDITION 4.2
@set VERSION 4.2
@set UPDATED 24 August 2012
@set UPDATED 28 August 2012
@set UPDATED-MONTH August 2012
@@ -14,4 +14,3 @@ Copyright (C) 1988-2012 Free Software Foundation, Inc.
+29 -1
View File
@@ -83,7 +83,14 @@ extern int errno;
extern int killpg __P((pid_t, int));
#endif
#define DEFAULT_CHILD_MAX 32
#if !DEFAULT_CHILD_MAX
# define DEFAULT_CHILD_MAX 32
#endif
#if !MAX_CHILD_MAX
# define MAX_CHILD_MAX 8192
#endif
#if !defined (DEBUG)
#define MAX_JOBS_IN_ARRAY 4096 /* production */
#else
@@ -4241,6 +4248,27 @@ restart_job_control ()
initialize_job_control (0);
}
void
set_maxchild (nchild)
int nchild;
{
static int lmaxchild = -1;
if (lmaxchild < 0)
lmaxchild = getmaxchild ();
if (lmaxchild < 0)
lmaxchild = DEFAULT_CHILD_MAX;
/* Clamp value we set. Minimum is what Posix requires, maximum is defined
above as MAX_CHILD_MAX. */
if (nchild < lmaxchild)
nchild = lmaxchild;
else if (nchild > MAX_CHILD_MAX)
nchild = MAX_CHILD_MAX;
js.c_childmax = nchild;
}
/* Set the handler to run when the shell receives a SIGCHLD signal. */
void
set_sigchld_handler ()
+4302
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -243,6 +243,8 @@ extern void close_pgrp_pipe __P((void));
extern void save_pgrp_pipe __P((int *, int));
extern void restore_pgrp_pipe __P((int *));
extern void set_maxchild __P((int));
extern int job_control; /* set to 0 in nojobs.c */
#endif /* _JOBS_H_ */
+248
View File
@@ -0,0 +1,248 @@
/* jobs.h -- structures and definitions used by the jobs.c file. */
/* Copyright (C) 1993-2009 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined (_JOBS_H_)
# define _JOBS_H_
#include "quit.h"
#include "siglist.h"
#include "stdc.h"
#include "posixwait.h"
/* Defines controlling the fashion in which jobs are listed. */
#define JLIST_STANDARD 0
#define JLIST_LONG 1
#define JLIST_PID_ONLY 2
#define JLIST_CHANGED_ONLY 3
#define JLIST_NONINTERACTIVE 4
/* I looked it up. For pretty_print_job (). The real answer is 24. */
#define LONGEST_SIGNAL_DESC 24
/* The max time to sleep while retrying fork() on EAGAIN failure */
#define FORKSLEEP_MAX 16
/* We keep an array of jobs. Each entry in the array is a linked list
of processes that are piped together. The first process encountered is
the group leader. */
/* Values for the `running' field of a struct process. */
#define PS_DONE 0
#define PS_RUNNING 1
#define PS_STOPPED 2
#define PS_RECYCLED 4
/* Each child of the shell is remembered in a STRUCT PROCESS. A circular
chain of such structures is a pipeline. */
typedef struct process {
struct process *next; /* Next process in the pipeline. A circular chain. */
pid_t pid; /* Process ID. */
WAIT status; /* The status of this command as returned by wait. */
int running; /* Non-zero if this process is running. */
char *command; /* The particular program that is running. */
} PROCESS;
/* PALIVE really means `not exited' */
#define PSTOPPED(p) (WIFSTOPPED((p)->status))
#define PRUNNING(p) ((p)->running == PS_RUNNING)
#define PALIVE(p) (PRUNNING(p) || PSTOPPED(p))
#define PEXITED(p) ((p)->running == PS_DONE)
#if defined (RECYCLES_PIDS)
# define PRECYCLED(p) ((p)->running == PS_RECYCLED)
#else
# define PRECYCLED(p) (0)
#endif
#define PDEADPROC(p) (PEXITED(p) || PRECYCLED(p))
#define get_job_by_jid(ind) (jobs[(ind)])
/* A description of a pipeline's state. */
typedef enum { JNONE = -1, JRUNNING = 1, JSTOPPED = 2, JDEAD = 4, JMIXED = 8 } JOB_STATE;
#define JOBSTATE(job) (jobs[(job)]->state)
#define J_JOBSTATE(j) ((j)->state)
#define STOPPED(j) (jobs[(j)]->state == JSTOPPED)
#define RUNNING(j) (jobs[(j)]->state == JRUNNING)
#define DEADJOB(j) (jobs[(j)]->state == JDEAD)
#define INVALID_JOB(j) ((j) < 0 || (j) >= js.j_jobslots || get_job_by_jid(j) == 0)
/* Values for the FLAGS field in the JOB struct below. */
#define J_FOREGROUND 0x01 /* Non-zero if this is running in the foreground. */
#define J_NOTIFIED 0x02 /* Non-zero if already notified about job state. */
#define J_JOBCONTROL 0x04 /* Non-zero if this job started under job control. */
#define J_NOHUP 0x08 /* Don't send SIGHUP to job if shell gets SIGHUP. */
#define J_STATSAVED 0x10 /* A process in this job had had status saved via $! */
#define J_ASYNC 0x20 /* Job was started asynchronously */
#define IS_FOREGROUND(j) ((jobs[j]->flags & J_FOREGROUND) != 0)
#define IS_NOTIFIED(j) ((jobs[j]->flags & J_NOTIFIED) != 0)
#define IS_JOBCONTROL(j) ((jobs[j]->flags & J_JOBCONTROL) != 0)
#define IS_ASYNC(j) ((jobs[j]->flags & J_ASYNC) != 0)
typedef struct job {
char *wd; /* The working directory at time of invocation. */
PROCESS *pipe; /* The pipeline of processes that make up this job. */
pid_t pgrp; /* The process ID of the process group (necessary). */
JOB_STATE state; /* The state that this job is in. */
int flags; /* Flags word: J_NOTIFIED, J_FOREGROUND, or J_JOBCONTROL. */
#if defined (JOB_CONTROL)
COMMAND *deferred; /* Commands that will execute when this job is done. */
sh_vptrfunc_t *j_cleanup; /* Cleanup function to call when job marked JDEAD */
PTR_T cleanarg; /* Argument passed to (*j_cleanup)() */
#endif /* JOB_CONTROL */
} JOB;
struct jobstats {
/* limits */
long c_childmax;
/* child process statistics */
int c_living; /* running or stopped child processes */
int c_reaped; /* exited child processes still in jobs list */
int c_injobs; /* total number of child processes in jobs list */
/* child process totals */
int c_totforked; /* total number of children this shell has forked */
int c_totreaped; /* total number of children this shell has reaped */
/* job counters and indices */
int j_jobslots; /* total size of jobs array */
int j_lastj; /* last (newest) job allocated */
int j_firstj; /* first (oldest) job allocated */
int j_njobs; /* number of non-NULL jobs in jobs array */
int j_ndead; /* number of JDEAD jobs in jobs array */
/* */
int j_current; /* current job */
int j_previous; /* previous job */
/* */
JOB *j_lastmade; /* last job allocated by stop_pipeline */
JOB *j_lastasync; /* last async job allocated by stop_pipeline */
};
struct pidstat {
struct pidstat *next;
pid_t pid;
int status;
};
struct bgpids {
struct pidstat *list;
struct pidstat *end;
int npid;
};
#define NO_JOB -1 /* An impossible job array index. */
#define DUP_JOB -2 /* A possible return value for get_job_spec (). */
#define BAD_JOBSPEC -3 /* Bad syntax for job spec. */
/* A value which cannot be a process ID. */
#define NO_PID (pid_t)-1
/* System calls. */
#if !defined (HAVE_UNISTD_H)
extern pid_t fork (), getpid (), getpgrp ();
#endif /* !HAVE_UNISTD_H */
/* Stuff from the jobs.c file. */
extern struct jobstats js;
extern pid_t original_pgrp, shell_pgrp, pipeline_pgrp;
extern pid_t last_made_pid, last_asynchronous_pid;
extern int asynchronous_notification;
extern JOB **jobs;
extern void making_children __P((void));
extern void stop_making_children __P((void));
extern void cleanup_the_pipeline __P((void));
extern void save_pipeline __P((int));
extern void restore_pipeline __P((int));
extern void start_pipeline __P((void));
extern int stop_pipeline __P((int, COMMAND *));
extern void append_process __P((char *, pid_t, int, int));
extern void delete_job __P((int, int));
extern void nohup_job __P((int));
extern void delete_all_jobs __P((int));
extern void nohup_all_jobs __P((int));
extern int count_all_jobs __P((void));
extern void terminate_current_pipeline __P((void));
extern void terminate_stopped_jobs __P((void));
extern void hangup_all_jobs __P((void));
extern void kill_current_pipeline __P((void));
#if defined (__STDC__) && defined (pid_t)
extern int get_job_by_pid __P((int, int));
extern void describe_pid __P((int));
#else
extern int get_job_by_pid __P((pid_t, int));
extern void describe_pid __P((pid_t));
#endif
extern void list_one_job __P((JOB *, int, int, int));
extern void list_all_jobs __P((int));
extern void list_stopped_jobs __P((int));
extern void list_running_jobs __P((int));
extern pid_t make_child __P((char *, int));
extern int get_tty_state __P((void));
extern int set_tty_state __P((void));
extern int job_exit_status __P((int));
extern int job_exit_signal __P((int));
extern int wait_for_single_pid __P((pid_t));
extern void wait_for_background_pids __P((void));
extern int wait_for __P((pid_t));
extern int wait_for_job __P((int));
extern void notify_and_cleanup __P((void));
extern void reap_dead_jobs __P((void));
extern int start_job __P((int, int));
extern int kill_pid __P((pid_t, int, int));
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 run_sigchld_trap __P((int));
extern void freeze_jobs_list __P((void));
extern void unfreeze_jobs_list __P((void));
extern int set_job_control __P((int));
extern void without_job_control __P((void));
extern void end_job_control __P((void));
extern void restart_job_control __P((void));
extern void set_sigchld_handler __P((void));
extern void ignore_tty_job_signals __P((void));
extern void default_tty_job_signals __P((void));
extern void init_job_stats __P((void));
extern void close_pgrp_pipe __P((void));
extern void save_pgrp_pipe __P((int *, int));
extern void restore_pgrp_pipe __P((int *));
extern int job_control; /* set to 0 in nojobs.c */
#endif /* _JOBS_H_ */
+3
View File
@@ -1504,6 +1504,7 @@ static const struct {
{ "revert-all-at-newline", &_rl_revert_all_at_newline, 0 },
{ "show-all-if-ambiguous", &_rl_complete_show_all, 0 },
{ "show-all-if-unmodified", &_rl_complete_show_unmodified, 0 },
{ "show-mode-in-prompt", &_rl_show_mode_in_prompt, 0 },
{ "skip-completed-text", &_rl_skip_completed_text, 0 },
#if defined (VISIBLE_STATS)
{ "visible-stats", &rl_visible_stats, 0 },
@@ -1543,6 +1544,8 @@ hack_special_boolean_var (i)
else
_rl_bell_preference = AUDIBLE_BELL;
}
else if (_rl_stricmp (name, "show-mode-in-prompt") == 0)
_rl_reset_prompt ();
}
typedef int _rl_sv_func_t PARAMS((const char *));
+2476
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -198,7 +198,7 @@ rl_callback_read_char ()
{
/* This allows functions that simply need to read an additional
character (like quoted-insert) to register a function to be
called when input is available. _rl_callback_data is simply a
called when input is available. _rl_callback_data is a
pointer to a struct that has the argument count originally
passed to the registering function and space for any additional
parameters. */
+293
View File
@@ -0,0 +1,293 @@
/* callback.c -- functions to use readline as an X `callback' mechanism. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
Readline 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 3 of the License, or
(at your option) any later version.
Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
*/
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include "rlconf.h"
#if defined (READLINE_CALLBACKS)
#include <sys/types.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif
#include <stdio.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "readline.h"
#include "rlprivate.h"
#include "xmalloc.h"
/* Private data for callback registration functions. See comments in
rl_callback_read_char for more details. */
_rl_callback_func_t *_rl_callback_func = 0;
_rl_callback_generic_arg *_rl_callback_data = 0;
/* **************************************************************** */
/* */
/* Callback Readline Functions */
/* */
/* **************************************************************** */
/* Allow using readline in situations where a program may have multiple
things to handle at once, and dispatches them via select(). Call
rl_callback_handler_install() with the prompt and a function to call
whenever a complete line of input is ready. The user must then
call rl_callback_read_char() every time some input is available, and
rl_callback_read_char() will call the user's function with the complete
text read in at each end of line. The terminal is kept prepped
all the time, except during calls to the user's function. Signal
handlers are only installed when the application calls back into
readline, so readline doesn't `steal' signals from the application. */
rl_vcpfunc_t *rl_linefunc; /* user callback function */
static int in_handler; /* terminal_prepped and signals set? */
/* Make sure the terminal is set up, initialize readline, and prompt. */
static void
_rl_callback_newline ()
{
rl_initialize ();
if (in_handler == 0)
{
in_handler = 1;
if (rl_prep_term_function)
(*rl_prep_term_function) (_rl_meta_flag);
}
readline_internal_setup ();
RL_CHECK_SIGNALS ();
}
/* Install a readline handler, set up the terminal, and issue the prompt. */
void
rl_callback_handler_install (prompt, linefunc)
const char *prompt;
rl_vcpfunc_t *linefunc;
{
rl_set_prompt (prompt);
RL_SETSTATE (RL_STATE_CALLBACK);
rl_linefunc = linefunc;
_rl_callback_newline ();
}
#if defined (HANDLE_SIGNALS)
#define CALLBACK_READ_RETURN() \
do { \
rl_clear_signals (); \
return; \
} while (0)
#else
#define CALLBACK_READ_RETURN() return
#endif
/* Read one character, and dispatch to the handler if it ends the line. */
void
rl_callback_read_char ()
{
char *line;
int eof, jcode;
static procenv_t olevel;
if (rl_linefunc == NULL)
{
_rl_errmsg ("readline_callback_read_char() called with no handler!");
abort ();
}
memcpy ((void *)olevel, (void *)_rl_top_level, sizeof (procenv_t));
#if defined (HAVE_POSIX_SIGSETJMP)
jcode = sigsetjmp (_rl_top_level, 0);
#else
jcode = setjmp (_rl_top_level);
#endif
if (jcode)
{
(*rl_redisplay_function) ();
_rl_want_redisplay = 0;
memcpy ((void *)_rl_top_level, (void *)olevel, sizeof (procenv_t));
CALLBACK_READ_RETURN ();
}
#if defined (HANDLE_SIGNALS)
/* Install signal handlers only when readline has control. */
rl_set_signals ();
#endif
do
{
RL_CHECK_SIGNALS ();
if (RL_ISSTATE (RL_STATE_ISEARCH))
{
eof = _rl_isearch_callback (_rl_iscxt);
if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
rl_callback_read_char ();
CALLBACK_READ_RETURN ();
}
else if (RL_ISSTATE (RL_STATE_NSEARCH))
{
eof = _rl_nsearch_callback (_rl_nscxt);
CALLBACK_READ_RETURN ();
}
#if defined (VI_MODE)
else if (RL_ISSTATE (RL_STATE_VIMOTION))
{
eof = _rl_vi_domove_callback (_rl_vimvcxt);
/* Should handle everything, including cleanup, numeric arguments,
and turning off RL_STATE_VIMOTION */
if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
_rl_internal_char_cleanup ();
CALLBACK_READ_RETURN ();
}
#endif
else if (RL_ISSTATE (RL_STATE_NUMERICARG))
{
eof = _rl_arg_callback (_rl_argcxt);
if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
rl_callback_read_char ();
/* XXX - this should handle _rl_last_command_was_kill better */
else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
_rl_internal_char_cleanup ();
CALLBACK_READ_RETURN ();
}
else if (RL_ISSTATE (RL_STATE_MULTIKEY))
{
eof = _rl_dispatch_callback (_rl_kscxt); /* For now */
while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED))
eof = _rl_dispatch_callback (_rl_kscxt);
if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0)
{
_rl_internal_char_cleanup ();
_rl_want_redisplay = 1;
}
}
else if (_rl_callback_func)
{
/* This allows functions that simply need to read an additional
character (like quoted-insert) to register a function to be
called when input is available. _rl_callback_data is simply a
pointer to a struct that has the argument count originally
passed to the registering function and space for any additional
parameters. */
eof = (*_rl_callback_func) (_rl_callback_data);
/* If the function `deregisters' itself, make sure the data is
cleaned up. */
if (_rl_callback_func == 0)
{
if (_rl_callback_data)
{
_rl_callback_data_dispose (_rl_callback_data);
_rl_callback_data = 0;
}
_rl_internal_char_cleanup ();
}
}
else
eof = readline_internal_char ();
RL_CHECK_SIGNALS ();
if (rl_done == 0 && _rl_want_redisplay)
{
(*rl_redisplay_function) ();
_rl_want_redisplay = 0;
}
if (rl_done)
{
line = readline_internal_teardown (eof);
if (rl_deprep_term_function)
(*rl_deprep_term_function) ();
#if defined (HANDLE_SIGNALS)
rl_clear_signals ();
#endif
in_handler = 0;
(*rl_linefunc) (line);
/* If the user did not clear out the line, do it for him. */
if (rl_line_buffer[0])
_rl_init_line_state ();
/* Redisplay the prompt if readline_handler_{install,remove}
not called. */
if (in_handler == 0 && rl_linefunc)
_rl_callback_newline ();
}
}
while (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT));
CALLBACK_READ_RETURN ();
}
/* Remove the handler, and make sure the terminal is in its normal state. */
void
rl_callback_handler_remove ()
{
rl_linefunc = NULL;
RL_UNSETSTATE (RL_STATE_CALLBACK);
RL_CHECK_SIGNALS ();
if (in_handler)
{
in_handler = 0;
if (rl_deprep_term_function)
(*rl_deprep_term_function) ();
#if defined (HANDLE_SIGNALS)
rl_clear_signals ();
#endif
}
}
_rl_callback_generic_arg *
_rl_callback_data_alloc (count)
int count;
{
_rl_callback_generic_arg *arg;
arg = (_rl_callback_generic_arg *)xmalloc (sizeof (_rl_callback_generic_arg));
arg->count = count;
arg->i1 = arg->i2 = 0;
return arg;
}
void _rl_callback_data_dispose (arg)
_rl_callback_generic_arg *arg;
{
xfree (arg);
}
#endif
+40 -6
View File
@@ -1,6 +1,6 @@
/* display.c -- readline redisplay facility. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -237,6 +237,18 @@ static int saved_local_length;
static int saved_invis_chars_first_line;
static int saved_physical_chars;
/* Return a character indicating the editing mode, for use in the prompt. */
static int
prompt_modechar ()
{
if (rl_editing_mode == emacs_mode)
return '@';
else if (_rl_keymap == vi_insertion_keymap)
return '+'; /* vi insert mode */
else
return ':'; /* vi command mode */
}
/* Expand the prompt string S and return the number of visible
characters in *LP, if LP is not null. This is currently more-or-less
a placeholder for expansion. LIP, if non-null is a place to store the
@@ -263,7 +275,16 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
/* Short-circuit if we can. */
if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (pmt, RL_PROMPT_START_IGNORE) == 0)
{
r = savestring (pmt);
if (pmt == rl_prompt && _rl_show_mode_in_prompt)
{
l = strlen (pmt);
r = (char *)xmalloc (l + 2);
r[0] = prompt_modechar ();
strcpy (r + 1, pmt);
}
else
r = savestring (pmt);
if (lp)
*lp = strlen (r);
if (lip)
@@ -276,13 +297,20 @@ expand_prompt (pmt, lp, lip, niflp, vlp)
}
l = strlen (pmt);
r = ret = (char *)xmalloc (l + 1);
r = ret = (char *)xmalloc (l + 2);
rl = physchars = 0; /* move up here so mode show can set them */
if (pmt == rl_prompt && _rl_show_mode_in_prompt)
{
*r++ = prompt_modechar ();
rl = physchars = 1;
}
invfl = 0; /* invisible chars in first line of prompt */
invflset = 0; /* we only want to set invfl once */
igstart = 0;
for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++)
for (ignoring = last = ninvis = 0, p = pmt; p && *p; p++)
{
/* This code strips the invisible character string markers
RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */
@@ -371,6 +399,12 @@ _rl_strip_prompt (pmt)
return ret;
}
void
_rl_reset_prompt ()
{
rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
}
/*
* Expand the prompt string into the various display components, if
* necessary.
@@ -1772,7 +1806,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
_rl_last_c_pos += _rl_col_width (nfd, 0, temp, 1);
if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
if (current_line == 0 && wrap_offset && _rl_last_c_pos > wrap_offset && ((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
cpos_adjusted = 1;
@@ -1795,7 +1829,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
_rl_last_c_pos += col_temp; /* XXX */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
if (current_line == 0 && wrap_offset && ((nfd - new) <= prompt_last_invisible))
if (current_line == 0 && wrap_offset && _rl_last_c_pos > wrap_offset && ((nfd - new) <= prompt_last_invisible))
{
_rl_last_c_pos -= wrap_offset;
cpos_adjusted = 1;
File diff suppressed because it is too large Load Diff
+2 -12
View File
@@ -2,10 +2,10 @@
@c %**start of header (This is for running Texinfo on a region.)
@setfilename history.info
@settitle GNU History Library
@c %**end of header (This is for running Texinfo on a region.)
@include version.texi
@c %**end of header (This is for running Texinfo on a region.)
@copying
This document describes the GNU History library
(version @value{VERSION}, @value{UPDATED}),
@@ -14,10 +14,6 @@ recalling lines of previously typed input.
Copyright @copyright{} 1988--2012 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -46,12 +42,6 @@ A copy of the license is included in the section entitled
@vskip 0pt plus 1filll
@insertcopying
@sp 1
Published by the Free Software Foundation @*
59 Temple Place, Suite 330, @*
Boston, MA 02111-1307 @*
USA @*
@end titlepage
@contents
+1 -1
View File
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
Copyright (C) 1988-2011 Free Software Foundation, Inc.
Copyright (C) 1988-2012 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
+1 -1
View File
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
Copyright (C) 1988--2011 Free Software Foundation, Inc.
Copyright (C) 1988--2012 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
+5
View File
@@ -552,6 +552,11 @@ possible partial completion (the possible completions don't share
a common prefix) cause the matches to be listed immediately instead
of ringing the bell.
.TP
.B show\-mode\-in\-prompt (Off)
If set to \fBOn\fP, add a character to the beginning of the prompt
indicating the editing mode: emacs (@), vi command (:) or vi
insertion (+).
.TP
.B skip\-completed\-text (Off)
If set to \fBOn\fP, this alters the default completion behavior when
inserting a single match into the line. It's only active when
File diff suppressed because it is too large Load Diff
+3 -12
View File
@@ -2,11 +2,11 @@
@comment %**start of header (This is for running Texinfo on a region.)
@setfilename readline.info
@settitle GNU Readline Library
@include version.texi
@comment %**end of header (This is for running Texinfo on a region.)
@synindex vr fn
@include version.texi
@copying
This manual describes the GNU Readline Library
(version @value{VERSION}, @value{UPDATED}), a library which aids in the
@@ -15,10 +15,6 @@ a command line interface.
Copyright @copyright{} 1988--2012 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -46,12 +42,6 @@ A copy of the license is included in the section entitled
@vskip 0pt plus 1filll
@insertcopying
@sp 1
Published by the Free Software Foundation @*
59 Temple Place, Suite 330, @*
Boston, MA 02111-1307 @*
USA @*
@end titlepage
@contents
@@ -63,6 +53,7 @@ USA @*
This document describes the GNU Readline Library, a utility which aids
in the consistency of user interface across discrete programs which
provide a command line interface.
The Readline home page is @url{http://www.gnu.org/software/readline/}.
@menu
* Command Line Editing:: GNU Readline User's Manual.
+8 -1
View File
@@ -9,7 +9,7 @@ use these features. There is a document entitled "readline.texinfo"
which contains both end-user and programmer documentation for the
GNU Readline Library.
Copyright (C) 1988--2011 Free Software Foundation, Inc.
Copyright (C) 1988--2012 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
@@ -664,6 +664,13 @@ a common prefix) cause the matches to be listed immediately instead
of ringing the bell.
The default value is @samp{off}.
@item show-mode-in-prompt
@vindex show-mode-in-prompt
If set to @samp{on}, add a character to the beginning of the prompt
indicating the editing mode: emacs (@samp{@@}), vi command (@samp{:}),
or vi insertion (@samp{+}).
The default value is @samp{off}.
@item skip-completed-text
@vindex skip-completed-text
If set to @samp{on}, this alters the default completion behavior when
File diff suppressed because it is too large Load Diff
+3 -12
View File
@@ -2,10 +2,10 @@
@comment %**start of header (This is for running Texinfo on a region.)
@setfilename rluserman.info
@settitle GNU Readline Library
@comment %**end of header (This is for running Texinfo on a region.)
@include version.texi
@comment %**end of header (This is for running Texinfo on a region.)
@copying
This manual describes the end user interface of the GNU Readline Library
(version @value{VERSION}, @value{UPDATED}), a library which aids in the
@@ -14,10 +14,6 @@ a command line interface.
Copyright @copyright{} 1988--2012 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.
@quotation
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -45,12 +41,6 @@ A copy of the license is included in the section entitled
@vskip 0pt plus 1filll
@insertcopying
@sp 1
Published by the Free Software Foundation @*
59 Temple Place, Suite 330, @*
Boston, MA 02111-1307 @*
USA @*
@end titlepage
@contents
@@ -62,6 +52,7 @@ USA @*
This document describes the end user interface of the GNU Readline Library,
a utility which aids in the consistency of user interface across discrete
programs which provide a command line interface.
The Readline home page is @url{http://www.gnu.org/software/readline/}.
@menu
* Command Line Editing:: GNU Readline User's Manual.
+3 -3
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2012 Free Software Foundation, Inc.
@set EDITION 6.2
@set VERSION 6.2
@set UPDATED 4 February 2012
@set UPDATED-MONTH February 2012
@set UPDATED 27 August 2012
@set UPDATED-MONTH August 2012
@set LASTCHANGE Sat Feb 4 16:31:10 EST 2012
@set LASTCHANGE Mon Aug 27 09:54:01 EDT 2012
+4
View File
@@ -656,6 +656,10 @@ rl_emacs_editing_mode (count, key)
rl_editing_mode = emacs_mode;
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
_rl_keymap = emacs_standard_keymap;
if (_rl_show_mode_in_prompt)
_rl_reset_prompt ();
return 0;
}
+688
View File
@@ -0,0 +1,688 @@
/* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
Readline 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 3 of the License, or
(at your option) any later version.
Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
*/
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_LOCALE_H)
# include <locale.h>
#endif
#include <stdio.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
#include "rlshell.h"
#include "xmalloc.h"
static int rl_digit_loop PARAMS((void));
static void _rl_history_set_point PARAMS((void));
extern int history_offset;
/* Forward declarations used in this file */
void _rl_free_history_entry PARAMS((HIST_ENTRY *));
/* If non-zero, rl_get_previous_history and rl_get_next_history attempt
to preserve the value of rl_point from line to line. */
int _rl_history_preserve_point = 0;
_rl_arg_cxt _rl_argcxt;
/* Saved target point for when _rl_history_preserve_point is set. Special
value of -1 means that point is at the end of the line. */
int _rl_history_saved_point = -1;
/* **************************************************************** */
/* */
/* Numeric Arguments */
/* */
/* **************************************************************** */
int
_rl_arg_overflow ()
{
if (rl_numeric_arg > 1000000)
{
_rl_argcxt = 0;
rl_explicit_arg = rl_numeric_arg = 0;
rl_ding ();
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return 1;
}
return 0;
}
void
_rl_arg_init ()
{
rl_save_prompt ();
_rl_argcxt = 0;
RL_SETSTATE(RL_STATE_NUMERICARG);
}
int
_rl_arg_getchar ()
{
int c;
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
return c;
}
/* Process C as part of the current numeric argument. Return -1 if the
argument should be aborted, 0 if we should not read any more chars, and
1 if we should continue to read chars. */
int
_rl_arg_dispatch (cxt, c)
_rl_arg_cxt cxt;
int c;
{
int key, r;
key = c;
/* If we see a key bound to `universal-argument' after seeing digits,
it ends the argument but is otherwise ignored. */
if (_rl_keymap[c].type == ISFUNC && _rl_keymap[c].function == rl_universal_argument)
{
if ((cxt & NUM_SAWDIGITS) == 0)
{
rl_numeric_arg *= 4;
return 1;
}
else if (RL_ISSTATE (RL_STATE_CALLBACK))
{
_rl_argcxt |= NUM_READONE;
return 0; /* XXX */
}
else
{
RL_SETSTATE(RL_STATE_MOREINPUT);
key = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
if (key < 0)
return -1;
return (_rl_dispatch (key, _rl_keymap));
}
}
c = UNMETA (c);
if (_rl_digit_p (c))
{
r = _rl_digit_value (c);
rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + r : r;
rl_explicit_arg = 1;
_rl_argcxt |= NUM_SAWDIGITS;
}
else if (c == '-' && rl_explicit_arg == 0)
{
rl_numeric_arg = 1;
_rl_argcxt |= NUM_SAWMINUS;
rl_arg_sign = -1;
}
else
{
/* Make M-- command equivalent to M--1 command. */
if ((_rl_argcxt & NUM_SAWMINUS) && rl_numeric_arg == 1 && rl_explicit_arg == 0)
rl_explicit_arg = 1;
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
r = _rl_dispatch (key, _rl_keymap);
if (RL_ISSTATE (RL_STATE_CALLBACK))
{
/* At worst, this will cause an extra redisplay. Otherwise,
we have to wait until the next character comes in. */
if (rl_done == 0)
(*rl_redisplay_function) ();
r = 0;
}
return r;
}
return 1;
}
/* Handle C-u style numeric args, as well as M--, and M-digits. */
static int
rl_digit_loop ()
{
int c, r;
while (1)
{
if (_rl_arg_overflow ())
return 1;
c = _rl_arg_getchar ();
if (c < 0)
{
_rl_abort_internal ();
return -1;
}
r = _rl_arg_dispatch (_rl_argcxt, c);
if (r <= 0 || (RL_ISSTATE (RL_STATE_NUMERICARG) == 0))
break;
}
return r;
}
/* Create a default argument. */
void
_rl_reset_argument ()
{
rl_numeric_arg = rl_arg_sign = 1;
rl_explicit_arg = 0;
_rl_argcxt = 0;
}
/* Start a numeric argument with initial value KEY */
int
rl_digit_argument (ignore, key)
int ignore, key;
{
_rl_arg_init ();
if (RL_ISSTATE (RL_STATE_CALLBACK))
{
_rl_arg_dispatch (_rl_argcxt, key);
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
return 0;
}
else
{
rl_execute_next (key);
return (rl_digit_loop ());
}
}
/* C-u, universal argument. Multiply the current argument by 4.
Read a key. If the key has nothing to do with arguments, then
dispatch on it. If the key is the abort character then abort. */
int
rl_universal_argument (count, key)
int count, key;
{
_rl_arg_init ();
rl_numeric_arg *= 4;
return (RL_ISSTATE (RL_STATE_CALLBACK) ? 0 : rl_digit_loop ());
}
int
_rl_arg_callback (cxt)
_rl_arg_cxt cxt;
{
int c, r;
c = _rl_arg_getchar ();
if (_rl_argcxt & NUM_READONE)
{
_rl_argcxt &= ~NUM_READONE;
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
rl_execute_next (c);
return 0;
}
r = _rl_arg_dispatch (cxt, c);
return (r != 1);
}
/* What to do when you abort reading an argument. */
int
rl_discard_argument ()
{
rl_ding ();
rl_clear_message ();
_rl_reset_argument ();
return 0;
}
/* **************************************************************** */
/* */
/* History Utilities */
/* */
/* **************************************************************** */
/* We already have a history library, and that is what we use to control
the history features of readline. This is our local interface to
the history mechanism. */
/* While we are editing the history, this is the saved
version of the original line. */
HIST_ENTRY *_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
/* Set the history pointer back to the last entry in the history. */
void
_rl_start_using_history ()
{
using_history ();
if (_rl_saved_line_for_history)
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
/* Free the contents (and containing structure) of a HIST_ENTRY. */
void
_rl_free_history_entry (entry)
HIST_ENTRY *entry;
{
if (entry == 0)
return;
FREE (entry->line);
FREE (entry->timestamp);
xfree (entry);
}
/* Perhaps put back the current line if it has changed. */
int
rl_maybe_replace_line ()
{
HIST_ENTRY *temp;
temp = current_history ();
/* If the current line has changed, save the changes. */
if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
{
temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
xfree (temp->line);
FREE (temp->timestamp);
xfree (temp);
}
return 0;
}
/* Restore the _rl_saved_line_for_history if there is one. */
int
rl_maybe_unsave_line ()
{
if (_rl_saved_line_for_history)
{
/* Can't call with `1' because rl_undo_list might point to an undo
list from a history entry, as in rl_replace_from_history() below. */
rl_replace_line (_rl_saved_line_for_history->line, 0);
rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
rl_point = rl_end; /* rl_replace_line sets rl_end */
}
else
rl_ding ();
return 0;
}
/* Save the current line in _rl_saved_line_for_history. */
int
rl_maybe_save_line ()
{
if (_rl_saved_line_for_history == 0)
{
_rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
_rl_saved_line_for_history->line = savestring (rl_line_buffer);
_rl_saved_line_for_history->timestamp = (char *)NULL;
_rl_saved_line_for_history->data = (char *)rl_undo_list;
}
return 0;
}
int
_rl_free_saved_history_line ()
{
if (_rl_saved_line_for_history)
{
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
return 0;
}
static void
_rl_history_set_point ()
{
rl_point = (_rl_history_preserve_point && _rl_history_saved_point != -1)
? _rl_history_saved_point
: rl_end;
if (rl_point > rl_end)
rl_point = rl_end;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode && _rl_keymap != vi_insertion_keymap)
rl_point = 0;
#endif /* VI_MODE */
if (rl_editing_mode == emacs_mode)
rl_mark = (rl_point == rl_end ? 0 : rl_end);
}
void
rl_replace_from_history (entry, flags)
HIST_ENTRY *entry;
int flags; /* currently unused */
{
/* Can't call with `1' because rl_undo_list might point to an undo list
from a history entry, just like we're setting up here. */
rl_replace_line (entry->line, 0);
rl_undo_list = (UNDO_LIST *)entry->data;
rl_point = rl_end;
rl_mark = 0;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
{
rl_point = 0;
rl_mark = rl_end;
}
#endif
}
/* Process and free undo lists attached to each history entry prior to the
current entry, inclusive, reverting each line to its saved state. This
is destructive, and state about the current line is lost. This is not
intended to be called while actively editing, and the current line is
not assumed to have been added to the history list. */
void
_rl_revert_all_lines ()
{
int hpos;
HIST_ENTRY *entry;
UNDO_LIST *ul, *saved_undo_list;
char *lbuf;
lbuf = savestring (rl_line_buffer);
saved_undo_list = rl_undo_list;
hpos = where_history ();
entry = (hpos == history_length) ? previous_history () : current_history ();
while (entry)
{
if (ul = (UNDO_LIST *)entry->data)
{
if (ul == saved_undo_list)
saved_undo_list = 0;
/* Set up rl_line_buffer and other variables from history entry */
rl_replace_from_history (entry, 0); /* entry->line is now current */
/* Undo all changes to this history entry */
while (rl_undo_list)
rl_do_undo ();
/* And copy the reverted line back to the history entry, preserving
the timestamp. */
FREE (entry->line);
entry->line = savestring (rl_line_buffer);
entry->data = 0;
}
entry = previous_history ();
}
/* Restore history state */
rl_undo_list = saved_undo_list; /* may have been set to null */
history_set_pos (hpos);
/* reset the line buffer */
rl_replace_line (lbuf, 0);
_rl_set_the_line ();
/* and clean up */
xfree (lbuf);
}
/* Free the history list, including private readline data and take care
of pointer aliases to history data. Resets rl_undo_list if it points
to an UNDO_LIST * saved as some history entry's data member. This
should not be called while editing is active. */
void
rl_clear_history ()
{
HIST_ENTRY **hlist, *hent;
register int i;
UNDO_LIST *ul, *saved_undo_list;
saved_undo_list = rl_undo_list;
hlist = history_list (); /* direct pointer, not copy */
for (i = 0; i < history_length; i++)
{
hent = hlist[i];
if (ul = (UNDO_LIST *)hent->data)
{
if (ul == saved_undo_list)
saved_undo_list = 0;
_rl_free_undo_list (ul);
hent->data = 0;
}
_rl_free_history_entry (hent);
}
history_offset = history_length = 0;
rl_undo_list = saved_undo_list; /* should be NULL */
}
/* **************************************************************** */
/* */
/* History Commands */
/* */
/* **************************************************************** */
/* Meta-< goes to the start of the history. */
int
rl_beginning_of_history (count, key)
int count, key;
{
return (rl_get_previous_history (1 + where_history (), key));
}
/* Meta-> goes to the end of the history. (The current line). */
int
rl_end_of_history (count, key)
int count, key;
{
rl_maybe_replace_line ();
using_history ();
rl_maybe_unsave_line ();
return 0;
}
/* Move down to the next history line. */
int
rl_get_next_history (count, key)
int count, key;
{
HIST_ENTRY *temp;
if (count < 0)
return (rl_get_previous_history (-count, key));
if (count == 0)
return 0;
rl_maybe_replace_line ();
/* either not saved by rl_newline or at end of line, so set appropriately. */
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
temp = (HIST_ENTRY *)NULL;
while (count)
{
temp = next_history ();
if (!temp)
break;
--count;
}
if (temp == 0)
rl_maybe_unsave_line ();
else
{
rl_replace_from_history (temp, 0);
_rl_history_set_point ();
}
return 0;
}
/* Get the previous item out of our interactive history, making it the current
line. If there is no previous history, just ding. */
int
rl_get_previous_history (count, key)
int count, key;
{
HIST_ENTRY *old_temp, *temp;
if (count < 0)
return (rl_get_next_history (-count, key));
if (count == 0)
return 0;
/* either not saved by rl_newline or at end of line, so set appropriately. */
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
/* If we don't have a line saved, then save this one. */
rl_maybe_save_line ();
/* If the current line has changed, save the changes. */
rl_maybe_replace_line ();
temp = old_temp = (HIST_ENTRY *)NULL;
while (count)
{
temp = previous_history ();
if (temp == 0)
break;
old_temp = temp;
--count;
}
/* If there was a large argument, and we moved back to the start of the
history, that is not an error. So use the last value found. */
if (!temp && old_temp)
temp = old_temp;
if (temp == 0)
rl_ding ();
else
{
rl_replace_from_history (temp, 0);
_rl_history_set_point ();
}
return 0;
}
/* **************************************************************** */
/* */
/* Editing Modes */
/* */
/* **************************************************************** */
/* How to toggle back and forth between editing modes. */
int
rl_vi_editing_mode (count, key)
int count, key;
{
#if defined (VI_MODE)
_rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
rl_editing_mode = vi_mode;
rl_vi_insert_mode (1, key);
#endif /* VI_MODE */
return 0;
}
int
rl_emacs_editing_mode (count, key)
int count, key;
{
rl_editing_mode = emacs_mode;
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
_rl_keymap = emacs_standard_keymap;
return 0;
}
/* Function for the rest of the library to use to set insert/overwrite mode. */
void
_rl_set_insert_mode (im, force)
int im, force;
{
#ifdef CURSOR_MODE
_rl_set_cursor (im, force);
#endif
rl_insert_mode = im;
}
/* Toggle overwrite mode. A positive explicit argument selects overwrite
mode. A negative or zero explicit argument selects insert mode. */
int
rl_overwrite_mode (count, key)
int count, key;
{
if (rl_explicit_arg == 0)
_rl_set_insert_mode (rl_insert_mode ^ 1, 0);
else if (count > 0)
_rl_set_insert_mode (RL_IM_OVERWRITE, 0);
else
_rl_set_insert_mode (RL_IM_INSERT, 0);
return 0;
}
+9 -5
View File
@@ -297,6 +297,10 @@ int _rl_revert_all_at_newline = 0;
characters corresponding to keyboard-generated signals. */
int _rl_echo_control_chars = 1;
/* Non-zero means to prefix the displayed prompt with a character indicating
the editing mode: @ for emacs, : for vi-command, + for vi-insert. */
int _rl_show_mode_in_prompt = 0;
/* **************************************************************** */
/* */
/* Top Level Functions */
@@ -400,6 +404,11 @@ readline_internal_setup ()
if (rl_startup_hook)
(*rl_startup_hook) ();
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
rl_vi_insert_mode (1, 'i');
#endif /* VI_MODE */
/* If we're not echoing, we still want to at least print a prompt, because
rl_redisplay will not do it for us. If the calling application has a
custom redisplay function, though, let that function handle it. */
@@ -422,11 +431,6 @@ readline_internal_setup ()
(*rl_redisplay_function) ();
}
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
rl_vi_insert_mode (1, 'i');
#endif /* VI_MODE */
if (rl_pre_input_hook)
(*rl_pre_input_hook) ();
File diff suppressed because it is too large Load Diff
+2
View File
@@ -258,6 +258,7 @@ extern void _rl_free_match_list PARAMS((char **));
/* display.c */
extern char *_rl_strip_prompt PARAMS((char *));
extern void _rl_reset_prompt PARAMS((void));
extern void _rl_move_cursor_relative PARAMS((int, const char *));
extern void _rl_move_vert PARAMS((int));
extern void _rl_save_prompt PARAMS((void));
@@ -470,6 +471,7 @@ extern int _rl_output_meta_chars;
extern int _rl_bind_stty_chars;
extern int _rl_revert_all_at_newline;
extern int _rl_echo_control_chars;
extern int _rl_show_mode_in_prompt;
extern char *_rl_comment_begin;
extern unsigned char _rl_parsing_conditionalized_out;
extern Keymap _rl_keymap;
+532
View File
@@ -0,0 +1,532 @@
/* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */
/* Copyright (C) 1999-2012 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
Readline 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 3 of the License, or
(at your option) any later version.
Readline 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 Readline. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined (_RL_PRIVATE_H_)
#define _RL_PRIVATE_H_
#include "rlconf.h" /* for VISIBLE_STATS */
#include "rlstdc.h"
#include "posixjmp.h" /* defines procenv_t */
/*************************************************************************
* *
* Convenience definitions *
* *
*************************************************************************/
#define EMACS_MODE() (rl_editing_mode == emacs_mode)
#define VI_COMMAND_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
#define VI_INSERT_MODE() (rl_editing_mode == vi_mode && _rl_keymap == vi_insertion_keymap)
#define RL_CHECK_SIGNALS() \
do { \
if (_rl_caught_signal) _rl_signal_handler (_rl_caught_signal); \
} while (0)
#define RL_SIG_RECEIVED() (_rl_caught_signal != 0)
#define RL_SIGINT_RECEIVED() (_rl_caught_signal == SIGINT)
/*************************************************************************
* *
* Global structs undocumented in texinfo manual and not in readline.h *
* *
*************************************************************************/
/* search types */
#define RL_SEARCH_ISEARCH 0x01 /* incremental search */
#define RL_SEARCH_NSEARCH 0x02 /* non-incremental search */
#define RL_SEARCH_CSEARCH 0x04 /* intra-line char search */
/* search flags */
#define SF_REVERSE 0x01
#define SF_FOUND 0x02
#define SF_FAILED 0x04
#define SF_CHGKMAP 0x08
typedef struct __rl_search_context
{
int type;
int sflags;
char *search_string;
int search_string_index;
int search_string_size;
char **lines;
char *allocated_line;
int hlen;
int hindex;
int save_point;
int save_mark;
int save_line;
int last_found_line;
char *prev_line_found;
UNDO_LIST *save_undo_list;
Keymap keymap; /* used when dispatching commands in search string */
Keymap okeymap; /* original keymap */
int history_pos;
int direction;
int prevc;
int lastc;
#if defined (HANDLE_MULTIBYTE)
char mb[MB_LEN_MAX];
char pmb[MB_LEN_MAX];
#endif
char *sline;
int sline_len;
int sline_index;
char *search_terminators;
} _rl_search_cxt;
/* Callback data for reading numeric arguments */
#define NUM_SAWMINUS 0x01
#define NUM_SAWDIGITS 0x02
#define NUM_READONE 0x04
typedef int _rl_arg_cxt;
/* A context for reading key sequences longer than a single character when
using the callback interface. */
#define KSEQ_DISPATCHED 0x01
#define KSEQ_SUBSEQ 0x02
#define KSEQ_RECURSIVE 0x04
typedef struct __rl_keyseq_context
{
int flags;
int subseq_arg;
int subseq_retval; /* XXX */
Keymap dmap;
Keymap oldmap;
int okey;
struct __rl_keyseq_context *ocxt;
int childval;
} _rl_keyseq_cxt;
/* vi-mode commands that use result of motion command to define boundaries */
#define VIM_DELETE 0x01
#define VIM_CHANGE 0x02
#define VIM_YANK 0x04
/* various states for vi-mode commands that use motion commands. reflects
RL_READLINE_STATE */
#define VMSTATE_READ 0x01
#define VMSTATE_NUMARG 0x02
typedef struct __rl_vimotion_context
{
int op;
int state;
int flags; /* reserved */
_rl_arg_cxt ncxt;
int numeric_arg;
int start, end; /* rl_point, rl_end */
int key, motion; /* initial key, motion command */
} _rl_vimotion_cxt;
/* fill in more as needed */
/* `Generic' callback data and functions */
typedef struct __rl_callback_generic_arg
{
int count;
int i1, i2;
/* add here as needed */
} _rl_callback_generic_arg;
typedef int _rl_callback_func_t PARAMS((_rl_callback_generic_arg *));
typedef void _rl_sigcleanup_func_t PARAMS((int, void *));
/*************************************************************************
* *
* Global functions undocumented in texinfo manual and not in readline.h *
* *
*************************************************************************/
/*************************************************************************
* *
* Global variables undocumented in texinfo manual and not in readline.h *
* *
*************************************************************************/
/* complete.c */
extern int rl_complete_with_tilde_expansion;
#if defined (VISIBLE_STATS)
extern int rl_visible_stats;
#endif /* VISIBLE_STATS */
#if defined (COLOR_SUPPORT)
extern int _rl_colored_stats;
#endif
/* readline.c */
extern int rl_line_buffer_len;
extern int rl_arg_sign;
extern int rl_visible_prompt_length;
extern int rl_byte_oriented;
/* display.c */
extern int rl_display_fixed;
/* parens.c */
extern int rl_blink_matching_paren;
/*************************************************************************
* *
* Global functions and variables unused and undocumented *
* *
*************************************************************************/
/* kill.c */
extern int rl_set_retained_kills PARAMS((int));
/* terminal.c */
extern void _rl_set_screen_size PARAMS((int, int));
/* undo.c */
extern int _rl_fix_last_undo_of_type PARAMS((int, int, int));
/* util.c */
extern char *_rl_savestring PARAMS((const char *));
/*************************************************************************
* *
* Functions and variables private to the readline library *
* *
*************************************************************************/
/* NOTE: Functions and variables prefixed with `_rl_' are
pseudo-global: they are global so they can be shared
between files in the readline library, but are not intended
to be visible to readline callers. */
/*************************************************************************
* Undocumented private functions *
*************************************************************************/
#if defined(READLINE_CALLBACKS)
/* readline.c */
extern void readline_internal_setup PARAMS((void));
extern char *readline_internal_teardown PARAMS((int));
extern int readline_internal_char PARAMS((void));
extern _rl_keyseq_cxt *_rl_keyseq_cxt_alloc PARAMS((void));
extern void _rl_keyseq_cxt_dispose PARAMS((_rl_keyseq_cxt *));
extern void _rl_keyseq_chain_dispose PARAMS((void));
extern int _rl_dispatch_callback PARAMS((_rl_keyseq_cxt *));
/* callback.c */
extern _rl_callback_generic_arg *_rl_callback_data_alloc PARAMS((int));
extern void _rl_callback_data_dispose PARAMS((_rl_callback_generic_arg *));
#endif /* READLINE_CALLBACKS */
/* bind.c */
extern char *_rl_untranslate_macro_value PARAMS((char *, int));
/* complete.c */
extern void _rl_reset_completion_state PARAMS((void));
extern char _rl_find_completion_word PARAMS((int *, int *));
extern void _rl_free_match_list PARAMS((char **));
/* display.c */
extern char *_rl_strip_prompt PARAMS((char *));
extern int _rl_reset_prompt PARAMS((void));
extern void _rl_move_cursor_relative PARAMS((int, const char *));
extern void _rl_move_vert PARAMS((int));
extern void _rl_save_prompt PARAMS((void));
extern void _rl_restore_prompt PARAMS((void));
extern char *_rl_make_prompt_for_search PARAMS((int));
extern void _rl_erase_at_end_of_line PARAMS((int));
extern void _rl_clear_to_eol PARAMS((int));
extern void _rl_clear_screen PARAMS((void));
extern void _rl_update_final PARAMS((void));
extern void _rl_redisplay_after_sigwinch PARAMS((void));
extern void _rl_clean_up_for_exit PARAMS((void));
extern void _rl_erase_entire_line PARAMS((void));
extern int _rl_current_display_line PARAMS((void));
/* input.c */
extern int _rl_any_typein PARAMS((void));
extern int _rl_input_available PARAMS((void));
extern int _rl_input_queued PARAMS((int));
extern void _rl_insert_typein PARAMS((int));
extern int _rl_unget_char PARAMS((int));
extern int _rl_pushed_input_available PARAMS((void));
/* isearch.c */
extern _rl_search_cxt *_rl_scxt_alloc PARAMS((int, int));
extern void _rl_scxt_dispose PARAMS((_rl_search_cxt *, int));
extern int _rl_isearch_dispatch PARAMS((_rl_search_cxt *, int));
extern int _rl_isearch_callback PARAMS((_rl_search_cxt *));
extern int _rl_search_getchar PARAMS((_rl_search_cxt *));
/* macro.c */
extern void _rl_with_macro_input PARAMS((char *));
extern int _rl_next_macro_key PARAMS((void));
extern int _rl_prev_macro_key PARAMS((void));
extern void _rl_push_executing_macro PARAMS((void));
extern void _rl_pop_executing_macro PARAMS((void));
extern void _rl_add_macro_char PARAMS((int));
extern void _rl_kill_kbd_macro PARAMS((void));
/* misc.c */
extern int _rl_arg_overflow PARAMS((void));
extern void _rl_arg_init PARAMS((void));
extern int _rl_arg_getchar PARAMS((void));
extern int _rl_arg_callback PARAMS((_rl_arg_cxt));
extern void _rl_reset_argument PARAMS((void));
extern void _rl_start_using_history PARAMS((void));
extern int _rl_free_saved_history_line PARAMS((void));
extern void _rl_set_insert_mode PARAMS((int, int));
extern void _rl_revert_all_lines PARAMS((void));
/* nls.c */
extern int _rl_init_eightbit PARAMS((void));
/* parens.c */
extern void _rl_enable_paren_matching PARAMS((int));
/* readline.c */
extern void _rl_init_line_state PARAMS((void));
extern void _rl_set_the_line PARAMS((void));
extern int _rl_dispatch PARAMS((int, Keymap));
extern int _rl_dispatch_subseq PARAMS((int, Keymap, int));
extern void _rl_internal_char_cleanup PARAMS((void));
/* rltty.c */
extern int _rl_disable_tty_signals PARAMS((void));
extern int _rl_restore_tty_signals PARAMS((void));
/* search.c */
extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *));
/* signals.c */
extern void _rl_signal_handler PARAMS((int));
extern void _rl_block_sigint PARAMS((void));
extern void _rl_release_sigint PARAMS((void));
extern void _rl_block_sigwinch PARAMS((void));
extern void _rl_release_sigwinch PARAMS((void));
/* terminal.c */
extern void _rl_get_screen_size PARAMS((int, int));
extern void _rl_sigwinch_resize_terminal PARAMS((void));
extern int _rl_init_terminal_io PARAMS((const char *));
#ifdef _MINIX
extern void _rl_output_character_function PARAMS((int));
#else
extern int _rl_output_character_function PARAMS((int));
#endif
extern void _rl_output_some_chars PARAMS((const char *, int));
extern int _rl_backspace PARAMS((int));
extern void _rl_enable_meta_key PARAMS((void));
extern void _rl_disable_meta_key PARAMS((void));
extern void _rl_control_keypad PARAMS((int));
extern void _rl_set_cursor PARAMS((int, int));
/* text.c */
extern void _rl_fix_point PARAMS((int));
extern int _rl_replace_text PARAMS((const char *, int, int));
extern int _rl_forward_char_internal PARAMS((int));
extern int _rl_insert_char PARAMS((int, int));
extern int _rl_overwrite_char PARAMS((int, int));
extern int _rl_overwrite_rubout PARAMS((int, int));
extern int _rl_rubout_char PARAMS((int, int));
#if defined (HANDLE_MULTIBYTE)
extern int _rl_char_search_internal PARAMS((int, int, char *, int));
#else
extern int _rl_char_search_internal PARAMS((int, int, int));
#endif
extern int _rl_set_mark_at_pos PARAMS((int));
/* undo.c */
extern UNDO_LIST *_rl_copy_undo_entry PARAMS((UNDO_LIST *));
extern UNDO_LIST *_rl_copy_undo_list PARAMS((UNDO_LIST *));
extern void _rl_free_undo_list PARAMS((UNDO_LIST *));
/* util.c */
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
extern void _rl_ttymsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
extern void _rl_errmsg (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
extern void _rl_trace (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
#else
extern void _rl_ttymsg ();
extern void _rl_errmsg ();
extern void _rl_trace ();
#endif
extern void _rl_audit_tty PARAMS((char *));
extern int _rl_tropen PARAMS((void));
extern int _rl_abort_internal PARAMS((void));
extern int _rl_null_function PARAMS((int, int));
extern char *_rl_strindex PARAMS((const char *, const char *));
extern int _rl_qsort_string_compare PARAMS((char **, char **));
extern int (_rl_uppercase_p) PARAMS((int));
extern int (_rl_lowercase_p) PARAMS((int));
extern int (_rl_pure_alphabetic) PARAMS((int));
extern int (_rl_digit_p) PARAMS((int));
extern int (_rl_to_lower) PARAMS((int));
extern int (_rl_to_upper) PARAMS((int));
extern int (_rl_digit_value) PARAMS((int));
/* vi_mode.c */
extern void _rl_vi_initialize_line PARAMS((void));
extern void _rl_vi_reset_last PARAMS((void));
extern void _rl_vi_set_last PARAMS((int, int, int));
extern int _rl_vi_textmod_command PARAMS((int));
extern void _rl_vi_done_inserting PARAMS((void));
extern int _rl_vi_domove_callback PARAMS((_rl_vimotion_cxt *));
/*************************************************************************
* Undocumented private variables *
*************************************************************************/
/* bind.c */
extern const char * const _rl_possible_control_prefixes[];
extern const char * const _rl_possible_meta_prefixes[];
/* callback.c */
extern _rl_callback_func_t *_rl_callback_func;
extern _rl_callback_generic_arg *_rl_callback_data;
/* complete.c */
extern int _rl_complete_show_all;
extern int _rl_complete_show_unmodified;
extern int _rl_complete_mark_directories;
extern int _rl_complete_mark_symlink_dirs;
extern int _rl_completion_prefix_display_length;
extern int _rl_completion_columns;
extern int _rl_print_completions_horizontally;
extern int _rl_completion_case_fold;
extern int _rl_completion_case_map;
extern int _rl_match_hidden_files;
extern int _rl_page_completions;
extern int _rl_skip_completed_text;
extern int _rl_menu_complete_prefix_first;
/* display.c */
extern int _rl_vis_botlin;
extern int _rl_last_c_pos;
extern int _rl_suppress_redisplay;
extern int _rl_want_redisplay;
/* isearch.c */
extern char *_rl_isearch_terminators;
extern _rl_search_cxt *_rl_iscxt;
/* macro.c */
extern char *_rl_executing_macro;
/* misc.c */
extern int _rl_history_preserve_point;
extern int _rl_history_saved_point;
extern _rl_arg_cxt _rl_argcxt;
/* nls.c */
extern int _rl_utf8locale;
/* readline.c */
extern int _rl_echoing_p;
extern int _rl_horizontal_scroll_mode;
extern int _rl_mark_modified_lines;
extern int _rl_bell_preference;
extern int _rl_meta_flag;
extern int _rl_convert_meta_chars_to_ascii;
extern int _rl_output_meta_chars;
extern int _rl_bind_stty_chars;
extern int _rl_revert_all_at_newline;
extern int _rl_echo_control_chars;
extern int _rl_show_mode_in_prompt;
extern char *_rl_comment_begin;
extern unsigned char _rl_parsing_conditionalized_out;
extern Keymap _rl_keymap;
extern FILE *_rl_in_stream;
extern FILE *_rl_out_stream;
extern int _rl_last_command_was_kill;
extern int _rl_eof_char;
extern procenv_t _rl_top_level;
extern _rl_keyseq_cxt *_rl_kscxt;
extern int _rl_keyseq_timeout;
extern int _rl_executing_keyseq_size;
/* search.c */
extern _rl_search_cxt *_rl_nscxt;
/* signals.c */
extern int _rl_interrupt_immediately;
extern int volatile _rl_caught_signal;
extern _rl_sigcleanup_func_t *_rl_sigcleanup;
extern void *_rl_sigcleanarg;
extern int _rl_echoctl;
extern int _rl_intr_char;
extern int _rl_quit_char;
extern int _rl_susp_char;
/* terminal.c */
extern int _rl_enable_keypad;
extern int _rl_enable_meta;
extern char *_rl_term_clreol;
extern char *_rl_term_clrpag;
extern char *_rl_term_im;
extern char *_rl_term_ic;
extern char *_rl_term_ei;
extern char *_rl_term_DC;
extern char *_rl_term_up;
extern char *_rl_term_dc;
extern char *_rl_term_cr;
extern char *_rl_term_IC;
extern char *_rl_term_forward_char;
extern int _rl_screenheight;
extern int _rl_screenwidth;
extern int _rl_screenchars;
extern int _rl_terminal_can_insert;
extern int _rl_term_autowrap;
/* undo.c */
extern int _rl_doing_an_undo;
extern int _rl_undo_group_level;
/* vi_mode.c */
extern int _rl_vi_last_command;
extern _rl_vimotion_cxt *_rl_vimvcxt;
#endif /* _RL_PRIVATE_H_ */
+6 -1
View File
@@ -1,7 +1,7 @@
/* vi_mode.c -- A vi emulation mode for Bash.
Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -706,6 +706,8 @@ rl_vi_insertion_mode (count, key)
{
_rl_keymap = vi_insertion_keymap;
_rl_vi_last_key_before_insert = key;
if (_rl_show_mode_in_prompt)
_rl_reset_prompt ();
return (0);
}
@@ -824,6 +826,9 @@ rl_vi_movement_mode (count, key)
if (RL_ISSTATE (RL_STATE_VICMDONCE) == 0)
rl_free_undo_list ();
if (_rl_show_mode_in_prompt)
_rl_reset_prompt ();
RL_SETSTATE (RL_STATE_VICMDONCE);
return (0);
}
File diff suppressed because it is too large Load Diff
+4
View File
@@ -4747,7 +4747,11 @@ got_token:
{
/* can use token; already copied to the_word */
token[token_index-1] = '\0';
#if defined (ARRAY_VARS)
if (legal_identifier (token+1) || valid_array_reference (token+1))
#else
if (legal_identifier (token+1))
#endif
{
strcpy (the_word->word, token+1);
/*itrace("read_token_word: returning REDIR_WORD for %s", the_word->word);*/
+6090
View File
File diff suppressed because it is too large Load Diff
+21 -4
View File
@@ -1282,8 +1282,7 @@ stdin_redirects (redirs)
n += stdin_redirection (rp->instruction, rp->redirector.dest);
return n;
}
/* These don't yet handle array references */
/* bind_var_to_int handles array references */
static int
redir_varassign (redir, fd)
REDIRECT *redir;
@@ -1300,20 +1299,38 @@ redir_varassign (redir, fd)
return 0;
}
/* Handles {array[ind]} for redirection words */
static int
redir_varvalue (redir)
REDIRECT *redir;
{
SHELL_VAR *v;
char *val;
char *val, *w;
intmax_t vmax;
int i;
#if defined (ARRAY_VARS)
char *sub;
int len, vr;
#endif
w = redir->redirector.filename->word; /* shorthand */
/* XXX - handle set -u here? */
v = find_variable (redir->redirector.filename->word);
#if defined (ARRAY_VARS)
if (vr = valid_array_reference (w))
v = array_variable_part (w, &sub, &len);
else
#endif
v = find_variable (w);
if (v == 0 || invisible_p (v))
return -1;
#if defined (ARRAY_VARS)
/* get_variable_value handles references to array variables without
subscripts */
if (vr && (array_p (v) || assoc_p (v)))
val = get_array_value (w, 0, (int *)NULL, (arrayind_t *)0);
else
#endif
val = get_variable_value (v);
if (val == 0 || *val == 0)
return -1;
+1343
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1830,7 +1830,7 @@ show_shell_usage (fp, extra)
fprintf (fp, "\t--%s\n", long_args[i].name);
fputs (_("Shell options:\n"), fp);
fputs (_("\t-irsD or -c command or -O shopt_option\t\t(invocation only)\n"), fp);
fputs (_("\t-ilrsD or -c command or -O shopt_option\t\t(invocation only)\n"), fp);
for (i = 0, set_opts = 0; shell_builtins[i].name; i++)
if (STREQ (shell_builtins[i].name, "set"))
+3
View File
@@ -5541,6 +5541,9 @@ array_length_reference (s)
else
{
ind = array_expand_index (var, t, len);
/* negative subscripts to indexed arrays count back from end */
if (var && array_p (var) && ind < 0)
ind = array_max_index (array_cell (var)) + 1 + ind;
if (ind < 0)
{
err_badarraysub (t);
+1 -1
View File
@@ -1,7 +1,7 @@
#! /bin/sh
#
# mkconffiles - create _distribution and _patchlevel files in preparation
# for recreating `configure' from `configure.in'
# for recreating `configure' from `configure.ac'
#
# options:
# -s srcdir directory where `configure' resides (defaults to `.')
+11
View File
@@ -364,3 +364,14 @@ bar
main main
function function
function function
declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")'
declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")'
declare -a x='([0]="0" [1]="1" [2]="2" [4]="4")'
./array14.sub: line 11: [-10]: bad array subscript
declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4")'
declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="five")'
declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")'
declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5foo")'
declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4" [5]="5")'
declare -a x='([0]="0" [1]="1" [2]="2" [3]="3" [4]="4four" [5]="5")'
strlen(4four) = 5
+2
View File
@@ -394,3 +394,5 @@ ${THIS_SH} ./array11.sub
${THIS_SH} ./array12.sub
${THIS_SH} ./array13.sub
${THIS_SH} ./array14.sub
+30
View File
@@ -0,0 +1,30 @@
# start at a test suite for negative indexed array subscripts -- post bash-4.2
x=( 0 1 2 3 4 5)
declare -p x
unset 'x[-1]'
declare -p x
unset 'x[-2]'
declare -p x
unset 'x[-10]'
x[-2]=3
declare -p x
x+=( five )
declare -p x
x[-1]=5
declare -p x
x+=( [-1]=foo )
declare -p x
x[-1]=5
declare -p x
x[-2]+=four
declare -p x
echo "strlen(${x[-2]})" = ${#x[-2]}
+18
View File
@@ -4497,6 +4497,10 @@ struct name_and_function {
static struct name_and_function special_vars[] = {
{ "BASH_XTRACEFD", sv_xtracefd },
#if defined (JOB_CONTROL)
{ "CHILD_MAX", sv_childmax },
#endif
#if defined (READLINE)
# if defined (STRICT_POSIX)
{ "COLUMNS", sv_winsize },
@@ -5148,3 +5152,17 @@ sv_xtracefd (name)
internal_error (_("%s: %s: invalid value for trace file descriptor"), name, value_cell (v));
}
}
#if defined (JOB_CONTROL)
void
sv_childmax (name)
char *name;
{
char *tt;
int s;
tt = get_string_value (name);
s = (tt && *tt) ? atoi (tt) : 0;
set_maxchild (s);
}
#endif
+4
View File
@@ -403,4 +403,8 @@ extern void sv_histtimefmt __P((char *));
extern void sv_tz __P((char *));
#endif
#if defined (JOB_CONTROL)
extern void sv_childmax __P((char *));
#endif
#endif /* !_VARIABLES_H_ */
+410
View File
@@ -0,0 +1,410 @@
/* variables.h -- data structures for shell variables. */
/* Copyright (C) 1987-2012 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined (_VARIABLES_H_)
#define _VARIABLES_H_
#include "stdc.h"
#include "array.h"
#include "assoc.h"
/* Shell variables and functions are stored in hash tables. */
#include "hashlib.h"
#include "conftypes.h"
/* A variable context. */
typedef struct var_context {
char *name; /* empty or NULL means global context */
int scope; /* 0 means global context */
int flags;
struct var_context *up; /* previous function calls */
struct var_context *down; /* down towards global context */
HASH_TABLE *table; /* variables at this scope */
} VAR_CONTEXT;
/* Flags for var_context->flags */
#define VC_HASLOCAL 0x01
#define VC_HASTMPVAR 0x02
#define VC_FUNCENV 0x04 /* also function if name != NULL */
#define VC_BLTNENV 0x08 /* builtin_env */
#define VC_TEMPENV 0x10 /* temporary_env */
#define VC_TEMPFLAGS (VC_FUNCENV|VC_BLTNENV|VC_TEMPENV)
/* Accessing macros */
#define vc_isfuncenv(vc) (((vc)->flags & VC_FUNCENV) != 0)
#define vc_isbltnenv(vc) (((vc)->flags & VC_BLTNENV) != 0)
#define vc_istempenv(vc) (((vc)->flags & (VC_TEMPFLAGS)) == VC_TEMPENV)
#define vc_istempscope(vc) (((vc)->flags & (VC_TEMPENV|VC_BLTNENV)) != 0)
#define vc_haslocals(vc) (((vc)->flags & VC_HASLOCAL) != 0)
#define vc_hastmpvars(vc) (((vc)->flags & VC_HASTMPVAR) != 0)
/* What a shell variable looks like. */
typedef struct variable *sh_var_value_func_t __P((struct variable *));
typedef struct variable *sh_var_assign_func_t __P((struct variable *, char *, arrayind_t, char *));
/* For the future */
union _value {
char *s; /* string value */
intmax_t i; /* int value */
COMMAND *f; /* function */
ARRAY *a; /* array */
HASH_TABLE *h; /* associative array */
double d; /* floating point number */
#if defined (HAVE_LONG_DOUBLE)
long double ld; /* long double */
#endif
struct variable *v; /* possible indirect variable use */
void *opaque; /* opaque data for future use */
};
typedef struct variable {
char *name; /* Symbol that the user types. */
char *value; /* Value that is returned. */
char *exportstr; /* String for the environment. */
sh_var_value_func_t *dynamic_value; /* Function called to return a `dynamic'
value for a variable, like $SECONDS
or $RANDOM. */
sh_var_assign_func_t *assign_func; /* Function called when this `special
variable' is assigned a value in
bind_variable. */
int attributes; /* export, readonly, array, invisible... */
int context; /* Which context this variable belongs to. */
} SHELL_VAR;
typedef struct _vlist {
SHELL_VAR **list;
int list_size; /* allocated size */
int list_len; /* current number of entries */
} VARLIST;
/* The various attributes that a given variable can have. */
/* First, the user-visible attributes */
#define att_exported 0x0000001 /* export to environment */
#define att_readonly 0x0000002 /* cannot change */
#define att_array 0x0000004 /* value is an array */
#define att_function 0x0000008 /* value is a function */
#define att_integer 0x0000010 /* internal representation is int */
#define att_local 0x0000020 /* variable is local to a function */
#define att_assoc 0x0000040 /* variable is an associative array */
#define att_trace 0x0000080 /* function is traced with DEBUG trap */
#define att_uppercase 0x0000100 /* word converted to uppercase on assignment */
#define att_lowercase 0x0000200 /* word converted to lowercase on assignment */
#define att_capcase 0x0000400 /* word capitalized on assignment */
#define att_nameref 0x0000800 /* word is a name reference */
#define user_attrs (att_exported|att_readonly|att_integer|att_local|att_trace|att_uppercase|att_lowercase|att_capcase|att_nameref)
#define attmask_user 0x0000fff
/* Internal attributes used for bookkeeping */
#define att_invisible 0x0001000 /* cannot see */
#define att_nounset 0x0002000 /* cannot unset */
#define att_noassign 0x0004000 /* assignment not allowed */
#define att_imported 0x0008000 /* came from environment */
#define att_special 0x0010000 /* requires special handling */
#define att_nofree 0x0020000 /* do not free value on unset */
#define attmask_int 0x00ff000
/* Internal attributes used for variable scoping. */
#define att_tempvar 0x0100000 /* variable came from the temp environment */
#define att_propagate 0x0200000 /* propagate to previous scope */
#define attmask_scope 0x0f00000
#define exported_p(var) ((((var)->attributes) & (att_exported)))
#define readonly_p(var) ((((var)->attributes) & (att_readonly)))
#define array_p(var) ((((var)->attributes) & (att_array)))
#define function_p(var) ((((var)->attributes) & (att_function)))
#define integer_p(var) ((((var)->attributes) & (att_integer)))
#define local_p(var) ((((var)->attributes) & (att_local)))
#define assoc_p(var) ((((var)->attributes) & (att_assoc)))
#define trace_p(var) ((((var)->attributes) & (att_trace)))
#define uppercase_p(var) ((((var)->attributes) & (att_uppercase)))
#define lowercase_p(var) ((((var)->attributes) & (att_lowercase)))
#define capcase_p(var) ((((var)->attributes) & (att_capcase)))
#define nameref_p(var) ((((var)->attributes) & (att_nameref)))
#define invisible_p(var) ((((var)->attributes) & (att_invisible)))
#define non_unsettable_p(var) ((((var)->attributes) & (att_nounset)))
#define noassign_p(var) ((((var)->attributes) & (att_noassign)))
#define imported_p(var) ((((var)->attributes) & (att_imported)))
#define specialvar_p(var) ((((var)->attributes) & (att_special)))
#define nofree_p(var) ((((var)->attributes) & (att_nofree)))
#define tempvar_p(var) ((((var)->attributes) & (att_tempvar)))
/* Acessing variable values: rvalues */
#define value_cell(var) ((var)->value)
#define function_cell(var) (COMMAND *)((var)->value)
#define array_cell(var) (ARRAY *)((var)->value)
#define assoc_cell(var) (HASH_TABLE *)((var)->value)
#define nameref_cell(var) ((var)->value) /* so it can change later */
#define NAMEREF_MAX 8 /* only 8 levels of nameref indirection */
#define var_isnull(var) ((var)->value == 0)
#define var_isset(var) ((var)->value != 0)
/* Assigning variable values: lvalues */
#define var_setvalue(var, str) ((var)->value = (str))
#define var_setfunc(var, func) ((var)->value = (char *)(func))
#define var_setarray(var, arr) ((var)->value = (char *)(arr))
#define var_setassoc(var, arr) ((var)->value = (char *)(arr))
#define var_setref(var, str) ((var)->value = (str))
/* Make VAR be auto-exported. */
#define set_auto_export(var) \
do { (var)->attributes |= att_exported; array_needs_making = 1; } while (0)
#define SETVARATTR(var, attr, undo) \
((undo == 0) ? ((var)->attributes |= (attr)) \
: ((var)->attributes &= ~(attr)))
#define VSETATTR(var, attr) ((var)->attributes |= (attr))
#define VUNSETATTR(var, attr) ((var)->attributes &= ~(attr))
#define VGETFLAGS(var) ((var)->attributes)
#define VSETFLAGS(var, flags) ((var)->attributes = (flags))
#define VCLRFLAGS(var) ((var)->attributes = 0)
/* Macros to perform various operations on `exportstr' member of a SHELL_VAR. */
#define CLEAR_EXPORTSTR(var) (var)->exportstr = (char *)NULL
#define COPY_EXPORTSTR(var) ((var)->exportstr) ? savestring ((var)->exportstr) : (char *)NULL
#define SET_EXPORTSTR(var, value) (var)->exportstr = (value)
#define SAVE_EXPORTSTR(var, value) (var)->exportstr = (value) ? savestring (value) : (char *)NULL
#define FREE_EXPORTSTR(var) \
do { if ((var)->exportstr) free ((var)->exportstr); } while (0)
#define CACHE_IMPORTSTR(var, value) \
(var)->exportstr = savestring (value)
#define INVALIDATE_EXPORTSTR(var) \
do { \
if ((var)->exportstr) \
{ \
free ((var)->exportstr); \
(var)->exportstr = (char *)NULL; \
} \
} while (0)
/* Stuff for hacking variables. */
typedef int sh_var_map_func_t __P((SHELL_VAR *));
/* Where we keep the variables and functions */
extern VAR_CONTEXT *global_variables;
extern VAR_CONTEXT *shell_variables;
extern HASH_TABLE *shell_functions;
extern HASH_TABLE *temporary_env;
extern int variable_context;
extern char *dollar_vars[];
extern char **export_env;
extern void initialize_shell_variables __P((char **, int));
extern SHELL_VAR *set_if_not __P((char *, char *));
extern void sh_set_lines_and_columns __P((int, int));
extern void set_pwd __P((void));
extern void set_ppid __P((void));
extern void make_funcname_visible __P((int));
extern SHELL_VAR *var_lookup __P((const char *, VAR_CONTEXT *));
extern SHELL_VAR *find_function __P((const char *));
extern FUNCTION_DEF *find_function_def __P((const char *));
extern SHELL_VAR *find_variable __P((const char *));
extern SHELL_VAR *find_variable_noref __P((const char *));
extern SHELL_VAR *find_variable_last_nameref __P((const char *));
extern SHELL_VAR *find_global_variable_last_nameref __P((const char *));
extern SHELL_VAR *find_variable_nameref __P((SHELL_VAR *));
extern SHELL_VAR *find_variable_internal __P((const char *, int));
extern SHELL_VAR *find_variable_tempenv __P((const char *));
extern SHELL_VAR *find_variable_notempenv __P((const char *));
extern SHELL_VAR *find_global_variable __P((const char *));
extern SHELL_VAR *find_global_variable_noref __P((const char *));
extern SHELL_VAR *find_shell_variable __P((const char *));
extern SHELL_VAR *find_tempenv_variable __P((const char *));
extern SHELL_VAR *copy_variable __P((SHELL_VAR *));
extern SHELL_VAR *make_local_variable __P((const char *));
extern SHELL_VAR *bind_variable __P((const char *, char *, int));
extern SHELL_VAR *bind_function __P((const char *, COMMAND *));
extern void bind_function_def __P((const char *, FUNCTION_DEF *));
extern SHELL_VAR **map_over __P((sh_var_map_func_t *, VAR_CONTEXT *));
SHELL_VAR **map_over_funcs __P((sh_var_map_func_t *));
extern SHELL_VAR **all_shell_variables __P((void));
extern SHELL_VAR **all_shell_functions __P((void));
extern SHELL_VAR **all_visible_variables __P((void));
extern SHELL_VAR **all_visible_functions __P((void));
extern SHELL_VAR **all_exported_variables __P((void));
extern SHELL_VAR **local_exported_variables __P((void));
extern SHELL_VAR **all_local_variables __P((void));
#if defined (ARRAY_VARS)
extern SHELL_VAR **all_array_variables __P((void));
#endif
extern char **all_variables_matching_prefix __P((const char *));
extern char **make_var_array __P((HASH_TABLE *));
extern char **add_or_supercede_exported_var __P((char *, int));
extern char *get_variable_value __P((SHELL_VAR *));
extern char *get_string_value __P((const char *));
extern char *sh_get_env_value __P((const char *));
extern char *make_variable_value __P((SHELL_VAR *, char *, int));
extern SHELL_VAR *bind_variable_value __P((SHELL_VAR *, char *, int));
extern SHELL_VAR *bind_int_variable __P((char *, char *));
extern SHELL_VAR *bind_var_to_int __P((char *, intmax_t));
extern int assign_in_env __P((WORD_DESC *, int));
extern int unbind_variable __P((const char *));
extern int unbind_nameref __P((const char *));
extern int unbind_func __P((const char *));
extern int unbind_function_def __P((const char *));
extern int makunbound __P((const char *, VAR_CONTEXT *));
extern int kill_local_variable __P((const char *));
extern void delete_all_variables __P((HASH_TABLE *));
extern void delete_all_contexts __P((VAR_CONTEXT *));
extern VAR_CONTEXT *new_var_context __P((char *, int));
extern void dispose_var_context __P((VAR_CONTEXT *));
extern VAR_CONTEXT *push_var_context __P((char *, int, HASH_TABLE *));
extern void pop_var_context __P((void));
extern VAR_CONTEXT *push_scope __P((int, HASH_TABLE *));
extern void pop_scope __P((int));
extern void push_context __P((char *, int, HASH_TABLE *));
extern void pop_context __P((void));
extern void push_dollar_vars __P((void));
extern void pop_dollar_vars __P((void));
extern void dispose_saved_dollar_vars __P((void));
extern void push_args __P((WORD_LIST *));
extern void pop_args __P((void));
extern void adjust_shell_level __P((int));
extern void non_unsettable __P((char *));
extern void dispose_variable __P((SHELL_VAR *));
extern void dispose_used_env_vars __P((void));
extern void dispose_function_env __P((void));
extern void dispose_builtin_env __P((void));
extern void merge_temporary_env __P((void));
extern void merge_builtin_env __P((void));
extern void kill_all_local_variables __P((void));
extern void set_var_read_only __P((char *));
extern void set_func_read_only __P((const char *));
extern void set_var_auto_export __P((char *));
extern void set_func_auto_export __P((const char *));
extern void sort_variables __P((SHELL_VAR **));
extern int chkexport __P((char *));
extern void maybe_make_export_env __P((void));
extern void update_export_env_inplace __P((char *, int, char *));
extern void put_command_name_into_env __P((char *));
extern void put_gnu_argv_flags_into_env __P((intmax_t, char *));
extern void print_var_list __P((SHELL_VAR **));
extern void print_func_list __P((SHELL_VAR **));
extern void print_assignment __P((SHELL_VAR *));
extern void print_var_value __P((SHELL_VAR *, int));
extern void print_var_function __P((SHELL_VAR *));
#if defined (ARRAY_VARS)
extern SHELL_VAR *make_new_array_variable __P((char *));
extern SHELL_VAR *make_local_array_variable __P((char *, int));
extern SHELL_VAR *make_new_assoc_variable __P((char *));
extern SHELL_VAR *make_local_assoc_variable __P((char *));
extern void set_pipestatus_array __P((int *, int));
extern ARRAY *save_pipestatus_array __P((void));
extern void restore_pipestatus_array __P((ARRAY *));
#endif
extern void set_pipestatus_from_exit __P((int));
/* The variable in NAME has just had its state changed. Check to see if it
is one of the special ones where something special happens. */
extern void stupidly_hack_special_variables __P((char *));
/* Reinitialize some special variables that have external effects upon unset
when the shell reinitializes itself. */
extern void reinit_special_variables __P((void));
extern int get_random_number __P((void));
/* The `special variable' functions that get called when a particular
variable is set. */
extern void sv_ifs __P((char *));
extern void sv_path __P((char *));
extern void sv_mail __P((char *));
extern void sv_funcnest __P((char *));
extern void sv_globignore __P((char *));
extern void sv_ignoreeof __P((char *));
extern void sv_strict_posix __P((char *));
extern void sv_optind __P((char *));
extern void sv_opterr __P((char *));
extern void sv_locale __P((char *));
extern void sv_xtracefd __P((char *));
#if defined (READLINE)
extern void sv_comp_wordbreaks __P((char *));
extern void sv_terminal __P((char *));
extern void sv_hostfile __P((char *));
extern void sv_winsize __P((char *));
#endif
#if defined (__CYGWIN__)
extern void sv_home __P((char *));
#endif
#if defined (HISTORY)
extern void sv_histsize __P((char *));
extern void sv_histignore __P((char *));
extern void sv_history_control __P((char *));
# if defined (BANG_HISTORY)
extern void sv_histchars __P((char *));
# endif
extern void sv_histtimefmt __P((char *));
#endif /* HISTORY */
#if defined (HAVE_TZSET)
extern void sv_tz __P((char *));
#endif
#if defined (JOB_CONTROL)
extern void sv_maxchild __P((char *));
#endif
#endif /* !_VARIABLES_H_ */