aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJari Aalto <jari.aalto@cante.net>2000-03-17 21:46:59 +0000
committerJari Aalto <jari.aalto@cante.net>2009-09-12 16:46:53 +0000
commitbb70624e964126b7ac4ff085ba163a9c35ffa18f (patch)
treeba2dd4add13ada94b1899c6d4aca80195b80b74b /lib
parentb72432fdcc59300c6fe7c9d6c8a31ad3447933f5 (diff)
downloadandroid_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.tar.gz
android_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.tar.bz2
android_external_bash-bb70624e964126b7ac4ff085ba163a9c35ffa18f.zip
Imported from ../bash-2.04.tar.gz.
Diffstat (limited to 'lib')
-rw-r--r--lib/glob/Makefile.in24
-rw-r--r--lib/glob/collsyms.h2
-rw-r--r--lib/glob/fnmatch.c56
-rw-r--r--lib/glob/fnmatch.h4
-rw-r--r--lib/glob/glob.c6
-rw-r--r--lib/glob/glob.h4
-rw-r--r--lib/malloc/Makefile.in22
-rw-r--r--lib/malloc/getpagesize.h2
-rw-r--r--lib/malloc/gmalloc.c6
-rw-r--r--lib/malloc/malloc.c164
-rw-r--r--lib/malloc/ogmalloc.c26
-rw-r--r--lib/malloc/omalloc.c4
-rw-r--r--lib/malloc/xmalloc.c4
-rw-r--r--lib/posixheaders/ansi_stdlib.h41
-rw-r--r--lib/posixheaders/filecntl.h45
-rw-r--r--lib/posixheaders/memalloc.h58
-rw-r--r--lib/posixheaders/posixdir.h49
-rw-r--r--lib/posixheaders/posixjmp.h22
-rw-r--r--lib/posixheaders/posixstat.h142
-rw-r--r--lib/posixheaders/stdc.h79
-rw-r--r--lib/readline/COPYING2
-rw-r--r--lib/readline/Makefile.in71
-rw-r--r--lib/readline/ansi_stdlib.h2
-rw-r--r--lib/readline/bind.c427
-rw-r--r--lib/readline/callback.c14
-rw-r--r--lib/readline/chardefs.h4
-rw-r--r--lib/readline/complete.c135
-rw-r--r--lib/readline/display.c358
-rw-r--r--lib/readline/doc/Makefile91
-rw-r--r--lib/readline/doc/hist.texinfo4
-rw-r--r--lib/readline/doc/hstech.texinfo9
-rw-r--r--lib/readline/doc/hsuser.texinfo109
-rw-r--r--lib/readline/doc/manvers.texinfo10
-rw-r--r--lib/readline/doc/rlman.texinfo4
-rw-r--r--lib/readline/doc/rltech.texinfo51
-rw-r--r--lib/readline/doc/rluser.texinfo448
-rw-r--r--lib/readline/doc/rluserman.texinfo94
-rw-r--r--lib/readline/emacs_keymap.c16
-rw-r--r--lib/readline/examples/Makefile18
-rw-r--r--lib/readline/examples/excallback.c186
-rw-r--r--lib/readline/examples/fileman.c26
-rw-r--r--lib/readline/examples/rl.c39
-rw-r--r--lib/readline/examples/rltest.c16
-rw-r--r--lib/readline/funmap.c16
-rw-r--r--lib/readline/histexpand.c18
-rw-r--r--lib/readline/histfile.c54
-rw-r--r--lib/readline/histlib.h12
-rw-r--r--lib/readline/history.c6
-rw-r--r--lib/readline/history.h10
-rw-r--r--lib/readline/histsearch.c7
-rw-r--r--lib/readline/input.c92
-rw-r--r--lib/readline/isearch.c21
-rw-r--r--lib/readline/keymaps.c14
-rw-r--r--lib/readline/keymaps.h12
-rw-r--r--lib/readline/kill.c39
-rw-r--r--lib/readline/macro.c19
-rw-r--r--lib/readline/nls.c21
-rw-r--r--lib/readline/parens.c41
-rw-r--r--lib/readline/posixdir.h4
-rw-r--r--lib/readline/posixjmp.h18
-rw-r--r--lib/readline/posixstat.h4
-rw-r--r--lib/readline/readline.c205
-rw-r--r--lib/readline/readline.h23
-rw-r--r--lib/readline/rlconf.h8
-rw-r--r--lib/readline/rldefs.h7
-rw-r--r--lib/readline/rlprivate.h271
-rw-r--r--lib/readline/rlshell.h34
-rw-r--r--lib/readline/rlstdc.h58
-rw-r--r--lib/readline/rltty.c202
-rw-r--r--lib/readline/rltty.h25
-rw-r--r--lib/readline/rlwinsize.h5
-rw-r--r--lib/readline/savestring.c4
-rw-r--r--lib/readline/search.c182
-rw-r--r--lib/readline/shell.c50
-rw-r--r--lib/readline/signals.c54
-rw-r--r--lib/readline/tcap.h4
-rw-r--r--lib/readline/terminal.c210
-rw-r--r--lib/readline/tilde.c55
-rw-r--r--lib/readline/tilde.h28
-rw-r--r--lib/readline/undo.c6
-rw-r--r--lib/readline/util.c24
-rw-r--r--lib/readline/vi_keymap.c4
-rw-r--r--lib/readline/vi_mode.c33
-rw-r--r--lib/readline/xmalloc.c27
-rw-r--r--lib/readline/xmalloc.h46
-rw-r--r--lib/sh/Makefile.in109
-rw-r--r--lib/sh/clock.c78
-rw-r--r--lib/sh/getcwd.c16
-rw-r--r--lib/sh/getenv.c2
-rw-r--r--lib/sh/inet_aton.c205
-rw-r--r--lib/sh/itos.c2
-rw-r--r--lib/sh/makepath.c116
-rw-r--r--lib/sh/netopen.c228
-rw-r--r--lib/sh/rename.c18
-rw-r--r--lib/sh/setlinebuf.c38
-rw-r--r--lib/sh/shquote.c217
-rw-r--r--lib/sh/shtty.c284
-rw-r--r--lib/sh/strpbrk.c44
-rw-r--r--lib/sh/times.c77
-rw-r--r--lib/sh/timeval.c144
-rw-r--r--lib/sh/vprint.c4
-rw-r--r--lib/sh/zread.c127
-rw-r--r--lib/sh/zwrite.c61
-rw-r--r--lib/termcap/Makefile.in23
-rw-r--r--lib/termcap/grot/COPYING12
-rw-r--r--lib/termcap/grot/Makefile.in2
-rw-r--r--lib/termcap/grot/termcap.texi3
-rw-r--r--lib/termcap/ltcap.h29
-rw-r--r--lib/termcap/termcap.c30
-rw-r--r--lib/termcap/termcap.h2
-rw-r--r--lib/termcap/tparam.c20
-rw-r--r--lib/termcap/version.c2
-rw-r--r--lib/tilde/Makefile.in22
-rw-r--r--lib/tilde/shell.c4
-rw-r--r--lib/tilde/tilde.c55
-rw-r--r--lib/tilde/tilde.h28
116 files changed, 4949 insertions, 1920 deletions
diff --git a/lib/glob/Makefile.in b/lib/glob/Makefile.in
index 0a596d1..234e8e1 100644
--- a/lib/glob/Makefile.in
+++ b/lib/glob/Makefile.in
@@ -3,6 +3,22 @@
# Makefile for the GNU Glob Library. #
# #
####################################################################
+#
+# Copyright (C) 1996 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
srcdir = @srcdir@
VPATH = .:@srcdir@
@@ -31,7 +47,9 @@ LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
-INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib
+BASHINCDIR = ${topdir}/include
+
+INCLUDES = -I. -I../.. -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
@@ -107,8 +125,8 @@ fnmatch.o: fnmatch.h
fnmatch.o: $(BUILD_DIR)/config.h
glob.o: $(BUILD_DIR)/config.h
-glob.o: $(topdir)/bashtypes.h $(topdir)/ansi_stdlib.h $(topdir)/bashansi.h
-glob.o: $(topdir)/posixstat.h $(topdir)/memalloc.h
+glob.o: $(topdir)/bashtypes.h $(BASHINCDIR)/ansi_stdlib.h $(topdir)/bashansi.h
+glob.o: $(BASHINCDIR)/posixstat.h $(BASHINCDIR)/memalloc.h
glob.o: fnmatch.h
# Rules for deficient makes, like SunOS and Solaris
diff --git a/lib/glob/collsyms.h b/lib/glob/collsyms.h
index 4f90083..7ef0906 100644
--- a/lib/glob/collsyms.h
+++ b/lib/glob/collsyms.h
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _COLLSYMS_H_
# define _COLLSYSMS_H_
diff --git a/lib/glob/fnmatch.c b/lib/glob/fnmatch.c
index b032a69..823ebf0 100644
--- a/lib/glob/fnmatch.c
+++ b/lib/glob/fnmatch.c
@@ -17,9 +17,11 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
+
+#include <stdio.h> /* for debugging */
#include "fnmatch.h"
#include "collsyms.h"
@@ -66,8 +68,18 @@ static char *patscan ();
#define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
#endif
+/* We don't use strcoll(3) for range comparisons in bracket expressions,
+ even if we have it, since it can have unwanted side effects in locales
+ other than POSIX or US. For instance, in the de locale, [A-Z] matches
+ all characters. So, for ranges we use ASCII collation, and for
+ collating symbol equivalence we use strcoll(). The casts to int are
+ to handle tests that use unsigned chars. */
+
+#define rangecmp(c1, c2) ((int)(c1) - (int)(c2))
+
#if defined (HAVE_STRCOLL)
-static int rangecmp (c1, c2)
+/* Helper function for collating symbol equivalence. */
+static int rangecmp2 (c1, c2)
int c1, c2;
{
static char s1[2] = { ' ', '\0' };
@@ -89,14 +101,14 @@ static int rangecmp (c1, c2)
return (c1 - c2);
}
#else /* !HAVE_STRCOLL */
-# define rangecmp(c1, c2) ((c1) - (c2))
+# define rangecmp2(c1, c2) ((int)(c1) - (int)(c2))
#endif /* !HAVE_STRCOLL */
#if defined (HAVE_STRCOLL)
static int collequiv (c1, c2)
int c1, c2;
{
- return (rangecmp (c1, c2) == 0);
+ return (rangecmp2 (c1, c2) == 0);
}
#else
# define collequiv(c1, c2) ((c1) == (c2))
@@ -253,7 +265,7 @@ gmatch (string, se, pattern, pe, flags)
that's OK, since we can match 0 or more occurrences.
We need to skip the glob pattern and see if we
match the rest of the string. */
- newn = patscan (p, pe, 0);
+ newn = patscan (p + 1, pe, 0);
p = newn;
}
#endif
@@ -587,6 +599,8 @@ patscan (string, end, delim)
pnest = bnest = 0;
for (s = string; c = *s; s++)
{
+ if (s >= end)
+ return (s);
switch (c)
{
case '\0':
@@ -603,10 +617,15 @@ patscan (string, end, delim)
pnest++;
break;
case ')':
+#if 0
if (bnest == 0)
pnest--;
if (pnest <= 0)
return ++s;
+#else
+ if (bnest == 0 && pnest-- <= 0)
+ return ++s;
+#endif
break;
case '|':
if (bnest == 0 && pnest == 0 && delim == '|')
@@ -614,6 +633,7 @@ patscan (string, end, delim)
break;
}
}
+
return (char *)0;
}
@@ -658,16 +678,22 @@ extmatch (xc, s, se, p, pe, flags)
char *srest; /* pointer to rest of string */
int m1, m2;
+#if 0
+fprintf(stderr, "extmatch: xc = %c\n", xc);
+fprintf(stderr, "extmatch: s = %s; se = %s\n", s, se);
+fprintf(stderr, "extmatch: p = %s; pe = %s\n", p, pe);
+#endif
+
+ prest = patscan (p + (*p == '('), pe, 0); /* ) */
+ if (prest == 0)
+ /* If PREST is 0, we failed to scan a valid pattern. In this
+ case, we just want to compare the two as strings. */
+ return (strcompare (p - 1, pe, s, se));
+
switch (xc)
{
case '+': /* match one or more occurrences */
case '*': /* match zero or more occurrences */
- prest = patscan (p, pe, 0);
- if (prest == 0)
- /* If PREST is 0, we failed to scan a valid pattern. In this
- case, we just want to compare the two as strings. */
- return (strcompare (p - 1, pe, s, se));
-
/* If we can get away with no matches, don't even bother. Just
call gmatch on the rest of the pattern and return success if
it succeeds. */
@@ -701,10 +727,6 @@ extmatch (xc, s, se, p, pe, flags)
case '?': /* match zero or one of the patterns */
case '@': /* match exactly one of the patterns */
- prest = patscan (p, pe, 0);
- if (prest == 0)
- return (strcompare (p - 1, pe, s, se));
-
/* If we can get away with no matches, don't even bother. Just
call gmatch on the rest of the pattern and return success if
it succeeds. */
@@ -730,10 +752,6 @@ extmatch (xc, s, se, p, pe, flags)
return (FNM_NOMATCH);
case '!': /* match anything *except* one of the patterns */
- prest = patscan (p, pe, 0);
- if (prest == 0)
- return (strcompare (p - 1, pe, s, se));
-
for (srest = s; srest <= se; srest++)
{
m1 = 0;
diff --git a/lib/glob/fnmatch.h b/lib/glob/fnmatch.h
index 5e2cfb1..c690891 100644
--- a/lib/glob/fnmatch.h
+++ b/lib/glob/fnmatch.h
@@ -13,8 +13,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _FNMATCH_H
#define _FNMATCH_H 1
diff --git a/lib/glob/glob.c b/lib/glob/glob.c
index be4e9dc..c272274 100644
--- a/lib/glob/glob.c
+++ b/lib/glob/glob.c
@@ -3,7 +3,7 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* To whomever it may concern: I have never seen the code which most
Unix programs use to perform this function. I wrote this from scratch
@@ -67,7 +67,7 @@
# endif
#endif /* !HAVE_DIRENT_H */
-#if defined (_POSIX_SOURCE)
+#if defined (_POSIX_SOURCE) && !defined (STRUCT_DIRENT_HAS_D_INO)
/* Posix does not require that the d_ino field be present, and some
systems do not provide it. */
# define REAL_DIR_ENTRY(dp) 1
diff --git a/lib/glob/glob.h b/lib/glob/glob.h
index ac83f1e..41ad726 100644
--- a/lib/glob/glob.h
+++ b/lib/glob/glob.h
@@ -3,7 +3,7 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _GLOB_H_
#define _GLOB_H_
diff --git a/lib/malloc/Makefile.in b/lib/malloc/Makefile.in
index 0778b33..9e8f022 100644
--- a/lib/malloc/Makefile.in
+++ b/lib/malloc/Makefile.in
@@ -1,5 +1,21 @@
# Skeleton Makefile for the GNU malloc code
#
+#
+# Copyright (C) 1996 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
srcdir = @srcdir@
VPATH = .:@srcdir@
@@ -30,7 +46,9 @@ LDFLAGS = @LDFLAGS@
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
-INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib
+BASHINCDIR = ${topdir}/include
+
+INCLUDES = -I. -I../.. -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib
CCFLAGS = ${PROFILE_FLAGS} ${INCLUDES} $(DEFS) $(LOCAL_DEFS) $(LOCAL_CFLAGS) \
$(CFLAGS) $(MALLOC_CFLAGS) $(CPPFLAGS)
@@ -110,7 +128,7 @@ alloca.o: $(BUILD_DIR)/config.h
malloc.o: $(BUILD_DIR)/config.h $(topdir)/bashtypes.h getpagesize.h
nmalloc.o: $(BUILD_DIR)/config.h $(topdir)/bashtypes.h getpagesize.h
nmalloc2.o: $(BUILD_DIR)/config.h $(topdir)/bashtypes.h getpagesize.h
-xmalloc.o: $(BUILD_DIR)/config.h $(topdir)/ansi_stdlib.h
+xmalloc.o: $(BUILD_DIR)/config.h $(BASHINCDIR)/ansi_stdlib.h
gmalloc.o: $(BUILD_DIR)/config.h
# Rules for deficient makes, like SunOS and Solaris
diff --git a/lib/malloc/getpagesize.h b/lib/malloc/getpagesize.h
index 6085a5c..0bc5ef9 100644
--- a/lib/malloc/getpagesize.h
+++ b/lib/malloc/getpagesize.h
@@ -13,7 +13,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
diff --git a/lib/malloc/gmalloc.c b/lib/malloc/gmalloc.c
index dd24146..8441b0f 100644
--- a/lib/malloc/gmalloc.c
+++ b/lib/malloc/gmalloc.c
@@ -16,8 +16,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-ot, write to the Free Software Foundation, Inc., 59 Temple Place -
-Suite 330, Boston, MA 02111-1307, USA.
+ot, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -141,7 +141,7 @@ struct mstats
struct hdr
{
size_t size; /* Exact size requested by user. */
- u_int32_t magic; /* Magic number to check header integrity. */
+ u_bits32_t magic; /* Magic number to check header integrity. */
};
#endif /* RCHECK */
diff --git a/lib/malloc/malloc.c b/lib/malloc/malloc.c
index e96dd27..daa1371 100644
--- a/lib/malloc/malloc.c
+++ b/lib/malloc/malloc.c
@@ -4,7 +4,7 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
@@ -107,6 +107,15 @@ what you give them. Help stamp out software-hoarding! */
# endif /* HAVE_BCOPY */
#endif /* !__GNUC__ */
+/* Generic pointer type. */
+#ifndef PTR_T
+# if defined (__STDC__)
+# define PTR_T void *
+# else
+# define PTR_T char *
+# endif
+#endif
+
#if !defined (NULL)
# define NULL 0
#endif
@@ -139,9 +148,10 @@ extern char *sbrk ();
* (whether by morecore() or for alignment); TSBRK is the total number of
* bytes requested from the kernel with sbrk(). BYTESUSED is the total
* number of bytes consumed by blocks currently in use; BYTESFREE is the
- * total number of bytes currently on all of the free lists. NBSPLIT is
+ * total number of bytes currently on all of the free lists. TBSPLIT is
* the number of times a larger block was split to satisfy a smaller request.
- * NBCOALESCE is the number of times two adjacent smaller blocks off the free
+ * NSPLIT[i] is the number of times a block of size I was split.
+ * TBCOALESCE is the number of times two adjacent smaller blocks off the free
* list were combined to satisfy a larger request.
*/
struct _malstats {
@@ -154,11 +164,12 @@ struct _malstats {
int nrcopy;
int nrecurse;
int nsbrk;
- int32_t tsbrk;
- int32_t bytesused;
- int32_t bytesfree;
- int nbsplit;
- int nbcoalesce;
+ bits32_t tsbrk;
+ bits32_t bytesused;
+ bits32_t bytesfree;
+ int tbsplit;
+ int nsplit[NBUCKETS];
+ int tbcoalesce;
};
static struct _malstats _mstats;
@@ -167,13 +178,16 @@ static struct _malstats _mstats;
NFREE is the number of free blocks for this allocation size. NUSED
is the number of blocks in use. NMAL is the number of requests for
blocks of size BLOCKSIZE. NMORECORE is the number of times we had
- to call MORECORE to repopulate the free list for this bucket. */
+ to call MORECORE to repopulate the free list for this bucket. NSPLIT
+ is the number of times a block of this size was split to satisfy a
+ smaller request. */
struct bucket_stats {
- u_int32_t blocksize;
+ u_bits32_t blocksize;
int nfree;
int nused;
int nmal;
int nmorecore;
+ int nsplit;
};
#endif /* MALLOC_STATS */
@@ -189,8 +203,8 @@ union mhead {
char mi_alloc; /* ISALLOC or ISFREE */ /* 1 */
char mi_index; /* index in nextf[] */ /* 1 */
/* Remainder are valid only when block is allocated */
- u_int32_t mi_nbytes; /* # of bytes allocated */ /* 4 */
- unsigned short mi_magic2;/* should be == MAGIC2 */ /* 2 */
+ u_bits32_t mi_nbytes; /* # of bytes allocated */ /* 4 */
+ u_bits16_t mi_magic2;/* should be == MAGIC2 */ /* 2 */
} minfo;
};
#define mh_alloc minfo.mi_alloc
@@ -243,8 +257,8 @@ botch (s)
/* Minimum and maximum bucket indices for block splitting (and to bound
the search for a block to split). */
#define SPLIT_MIN 3
-#define SPLIT_MID 9
-#define SPLIT_MAX 12
+#define SPLIT_MID 11 /* XXX - was 9 */
+#define SPLIT_MAX 14 /* XXX - was 12 */
/* Minimum and maximum bucket indices for block coalescing. */
#define COMBINE_MIN 6
@@ -262,6 +276,7 @@ static char busy[NBUCKETS];
static int pagesz; /* system page size. */
static int pagebucket; /* bucket for requests a page in size */
+static int maxbuck; /* highest bucket receiving allocation request. */
#if 0
/* Coalesce two adjacent free blocks off the free list for size NU - 1,
@@ -305,7 +320,7 @@ bcoalesce (nu)
return; /* not adjacent */
#ifdef MALLOC_STATS
- _mstats.nbcoalesce++;
+ _mstats.tbcoalesce++;
#endif
/* Since they are adjacent, remove them from the free list */
@@ -328,12 +343,14 @@ bsplit (nu)
register int nu;
{
register union mhead *mp;
- int nbuck, nblks;
+ int nbuck, nblks, split_max;
unsigned long siz;
+ split_max = (maxbuck > SPLIT_MAX) ? maxbuck : SPLIT_MAX;
+
if (nu >= SPLIT_MID)
{
- for (nbuck = SPLIT_MAX; nbuck > nu; nbuck--)
+ for (nbuck = split_max; nbuck > nu; nbuck--)
{
if (busy[nbuck] || nextf[nbuck] == 0)
continue;
@@ -342,7 +359,7 @@ bsplit (nu)
}
else
{
- for (nbuck = nu + 1; nbuck <= SPLIT_MAX; nbuck++)
+ for (nbuck = nu + 1; nbuck <= split_max; nbuck++)
{
if (busy[nbuck] || nextf[nbuck] == 0)
continue;
@@ -350,14 +367,15 @@ bsplit (nu)
}
}
- if (nbuck > SPLIT_MAX || nbuck <= nu)
+ if (nbuck > split_max || nbuck <= nu)
return;
/* XXX might want to split only if nextf[nbuck] has >= 2 blocks free
and nbuck is below some threshold. */
#ifdef MALLOC_STATS
- _mstats.nbsplit++;
+ _mstats.tbsplit++;
+ _mstats.nsplit[nbuck]++;
#endif
/* Figure out how many blocks we'll get. */
@@ -406,7 +424,7 @@ morecore (nu) /* ask system for more memory */
siz = 1 << (nu + 3); /* size of desired block for nextf[nu] */
if (siz < 0)
- return; /* oops */
+ goto morecore_done; /* oops */
#ifdef MALLOC_STATS
_mstats.nmorecore[nu]++;
@@ -414,7 +432,11 @@ morecore (nu) /* ask system for more memory */
/* Try to split a larger block here, if we're within the range of sizes
to split. */
+#if 0
if (nu >= SPLIT_MIN && nu < SPLIT_MAX)
+#else
+ if (nu >= SPLIT_MIN)
+#endif
{
bsplit (nu);
if (nextf[nu] != 0)
@@ -463,7 +485,7 @@ morecore (nu) /* ask system for more memory */
/* Totally out of memory. */
if ((long)mp == -1)
- return;
+ goto morecore_done;
/* shouldn't happen, but just in case -- require 8-byte alignment */
if ((long)mp & 7)
@@ -515,10 +537,10 @@ zmemset (s, c, n)
static void
malloc_debug_dummy ()
{
- ;
+ write (1, "malloc_debug_dummy\n", 19);
}
-char *
+PTR_T
malloc (n) /* get a block */
size_t n;
{
@@ -578,7 +600,7 @@ malloc (n) /* get a block */
}
else
{
- register u_int32_t amt;
+ register u_bits32_t amt;
nunits = pagebucket;
amt = pagesz;
@@ -599,6 +621,9 @@ malloc (n) /* get a block */
while (busy[nunits]) nunits++;
busy[nunits] = 1;
+ if (nunits > maxbuck)
+ maxbuck = nunits;
+
/* If there are no blocks of the appropriate size, go get some */
if (nextf[nunits] == 0)
morecore (nunits);
@@ -636,18 +661,18 @@ malloc (n) /* get a block */
_mstats.tmalloc[nunits]++;
_mstats.nmal++;
#endif /* MALLOC_STATS */
- return (char *) (p + 1);
+ return (char *) (p + 1); /* XXX - should be cast to PTR_T? */
}
void
free (mem)
- char *mem;
+ PTR_T mem;
{
register union mhead *p;
register char *ap;
register int nunits;
- if ((ap = mem) == 0)
+ if ((ap = (char *)mem) == 0)
return;
p = (union mhead *) ap - 1;
@@ -680,6 +705,11 @@ free (mem)
ASSERT (nunits < NBUCKETS);
p->mh_alloc = ISFREE;
+#if 0
+ if (busy[nunits] == 1)
+ botch ("calling free %d while in malloc for %d", nunits, nunits);
+#endif
+
/* Protect against signal handlers calling malloc. */
busy[nunits] = 1;
/* Put this block on the free list. */
@@ -693,13 +723,13 @@ free (mem)
#endif /* MALLOC_STATS */
}
-char *
+PTR_T
realloc (mem, n)
- char *mem;
+ PTR_T mem;
register size_t n;
{
register union mhead *p;
- register u_int32_t tocopy;
+ register u_bits32_t tocopy;
register unsigned int nbytes;
register int nunits;
register char *m;
@@ -720,7 +750,7 @@ realloc (mem, n)
ASSERT (p->mh_alloc == ISALLOC);
ASSERT (p->mh_magic2 == MAGIC2);
- m = mem + (tocopy = p->mh_nbytes);
+ m = (char *)mem + (tocopy = p->mh_nbytes);
ASSERT (*m++ == MAGIC1); ASSERT (*m++ == MAGIC1);
ASSERT (*m++ == MAGIC1); ASSERT (*m == MAGIC1);
@@ -730,10 +760,10 @@ realloc (mem, n)
/* If ok, use the same block, just marking its size as changed. */
if (nbytes > (4 << nunits) && nbytes <= (8 << nunits))
{
- m = mem + tocopy;
+ m = (char *)mem + tocopy;
*m++ = 0; *m++ = 0; *m++ = 0; *m++ = 0;
p->mh_nbytes = n;
- m = mem + n;
+ m = (char *)mem + n;
*m++ = MAGIC1; *m++ = MAGIC1; *m++ = MAGIC1; *m++ = MAGIC1;
return mem;
}
@@ -752,7 +782,7 @@ realloc (mem, n)
return m;
}
-char *
+PTR_T
memalign (alignment, size)
unsigned int alignment;
size_t size;
@@ -782,11 +812,7 @@ memalign (alignment, size)
#if !defined (HPUX)
/* This runs into trouble with getpagesize on HPUX, and Multimax machines.
Patching out seems cleaner than the ugly fix needed. */
-#if defined (__STDC__)
-void *
-#else
-char *
-#endif
+PTR_T
valloc (size)
size_t size;
{
@@ -795,7 +821,7 @@ valloc (size)
#endif /* !HPUX */
#ifndef NO_CALLOC
-char *
+PTR_T
calloc (n, s)
size_t n, s;
{
@@ -811,7 +837,7 @@ calloc (n, s)
void
cfree (p)
- char *p;
+ PTR_T p;
{
free (p);
}
@@ -831,7 +857,7 @@ malloc_bucket_stats (size)
if (size < 0 || size >= NBUCKETS)
{
v.blocksize = 0;
- v.nused = v.nmal = 0;
+ v.nused = v.nmal = v.nmorecore = v.nsplit = 0;
return v;
}
@@ -839,6 +865,7 @@ malloc_bucket_stats (size)
v.nused = _mstats.nmalloc[size];
v.nmal = _mstats.tmalloc[size];
v.nmorecore = _mstats.nmorecore[size];
+ v.nsplit = _mstats.nsplit[size];
for (p = nextf[size]; p; p = CHAIN (p))
v.nfree++;
@@ -868,29 +895,60 @@ malloc_stats ()
return (result);
}
-void
-print_malloc_stats (s)
+static void
+_print_malloc_stats (s, fp)
char *s;
+ FILE *fp;
{
register int i;
int totused, totfree;
struct bucket_stats v;
- fprintf (stderr, "Memory allocation statistics: %s\n\tsize\tfree\tin use\ttotal\tmorecore\n", s ? s : "");
+ fprintf (fp, "Memory allocation statistics: %s\n\tsize\tfree\tin use\ttotal\tmorecore\tsplit\n", s ? s : "");
for (i = totused = totfree = 0; i < NBUCKETS; i++)
{
v = malloc_bucket_stats (i);
- fprintf (stderr, "%12lu\t%4d\t%6d\t%5d\t%8d\n", v.blocksize, v.nfree, v.nused, v.nmal, v.nmorecore);
+ fprintf (fp, "%12lu\t%4d\t%6d\t%5d\t%8d\t%5d\n", v.blocksize, v.nfree, v.nused, v.nmal, v.nmorecore, v.nsplit);
totfree += v.nfree * v.blocksize;
totused += v.nused * v.blocksize;
}
- fprintf (stderr, "\nTotal bytes in use: %d, total bytes free: %d\n",
+ fprintf (fp, "\nTotal bytes in use: %d, total bytes free: %d\n",
totused, totfree);
- fprintf (stderr, "Total mallocs: %d, total frees: %d, total reallocs: %d (%d copies)\n",
+ fprintf (fp, "Total mallocs: %d, total frees: %d, total reallocs: %d (%d copies)\n",
_mstats.nmal, _mstats.nfre, _mstats.nrealloc, _mstats.nrcopy);
- fprintf (stderr, "Total sbrks: %d, total bytes via sbrk: %d\n",
+ fprintf (fp, "Total sbrks: %d, total bytes via sbrk: %d\n",
_mstats.nsbrk, _mstats.tsbrk);
- fprintf (stderr, "Total blocks split: %d, total block coalesces: %d\n",
- _mstats.nbsplit, _mstats.nbcoalesce);
+ fprintf (fp, "Total blocks split: %d, total block coalesces: %d\n",
+ _mstats.tbsplit, _mstats.tbcoalesce);
+}
+
+void
+print_malloc_stats (s)
+{
+ _print_malloc_stats (s, stderr);
+}
+
+#define TRACEROOT "/var/tmp/maltrace/trace."
+extern char *inttostr ();
+
+void
+trace_malloc_stats (s)
+{
+ char ibuf[32], *ip;
+ char fname[64];
+ int p;
+ FILE *fp;
+
+ p = (int)getpid();
+ ip = inttostr(p, ibuf, sizeof(ibuf));
+ strcpy (fname, TRACEROOT);
+ strcat (fname, ip);
+ fp = fopen(fname, "w");
+ if (fp)
+ {
+ _print_malloc_stats (s, fp);
+ fflush(fp);
+ fclose(fp);
+ }
}
#endif /* MALLOC_STATS */
diff --git a/lib/malloc/ogmalloc.c b/lib/malloc/ogmalloc.c
index 8690b12..6b3600a 100644
--- a/lib/malloc/ogmalloc.c
+++ b/lib/malloc/ogmalloc.c
@@ -20,8 +20,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -328,8 +328,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -854,8 +854,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -1163,8 +1163,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -1404,8 +1404,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA.
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA.
The author may be reached (Email) at the address mike@ai.mit.edu,
or (US mail) as Mike Haertel c/o Free Software Foundation. */
@@ -1444,7 +1444,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with the GNU C Library; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+the Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _MALLOC_INTERNAL
#define _MALLOC_INTERNAL
@@ -1493,8 +1493,8 @@ Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+not, write to the Free Software Foundation, Inc.,
+59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _MALLOC_INTERNAL
#define _MALLOC_INTERNAL
diff --git a/lib/malloc/omalloc.c b/lib/malloc/omalloc.c
index a8b232a..413faeb 100644
--- a/lib/malloc/omalloc.c
+++ b/lib/malloc/omalloc.c
@@ -4,7 +4,7 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
@@ -14,7 +14,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
In other words, you are welcome to use, share and improve this program.
You are forbidden to forbid anyone else to use, share and improve
diff --git a/lib/malloc/xmalloc.c b/lib/malloc/xmalloc.c
index 4160651..a495d77 100644
--- a/lib/malloc/xmalloc.c
+++ b/lib/malloc/xmalloc.c
@@ -7,7 +7,7 @@
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 1, or (at your option) any
+ Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
#include <config.h>
diff --git a/lib/posixheaders/ansi_stdlib.h b/lib/posixheaders/ansi_stdlib.h
deleted file mode 100644
index 52339da..0000000
--- a/lib/posixheaders/ansi_stdlib.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/* ansi_stdlib.h -- An ANSI Standard stdlib.h. */
-/* A minimal stdlib.h containing extern declarations for those functions
- that bash uses. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_STDLIB_H_)
-#define _STDLIB_H_ 1
-
-/* String conversion functions. */
-extern int atoi ();
-extern long int atol ();
-
-/* Memory allocation functions. */
-extern char *malloc ();
-extern char *realloc ();
-extern void free ();
-
-/* Other miscellaneous functions. */
-extern void abort ();
-extern void exit ();
-extern char *getenv ();
-extern void qsort ();
-
-#endif /* _STDLIB_H */
diff --git a/lib/posixheaders/filecntl.h b/lib/posixheaders/filecntl.h
deleted file mode 100644
index cf5054d..0000000
--- a/lib/posixheaders/filecntl.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/* filecntl.h - Definitions to set file descriptors to close-on-exec. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_FILECNTL_H_)
-#define _FILECNTL_H_
-
-#include <fcntl.h>
-
-/* Definitions to set file descriptors to close-on-exec, the Posix way. */
-#if !defined (FD_CLOEXEC)
-#define FD_CLOEXEC 1
-#endif
-
-#define FD_NCLOEXEC 0
-
-#define SET_CLOSE_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_CLOEXEC))
-#define SET_OPEN_ON_EXEC(fd) (fcntl ((fd), F_SETFD, FD_NCLOEXEC))
-
-/* How to open a file in non-blocking mode, the Posix.1 way. */
-#if !defined (O_NONBLOCK)
-# if defined (O_NDELAY)
-# define O_NONBLOCK O_NDELAY
-# else
-# define O_NONBLOCK 0
-# endif
-#endif
-
-#endif /* ! _FILECNTL_H_ */
diff --git a/lib/posixheaders/memalloc.h b/lib/posixheaders/memalloc.h
deleted file mode 100644
index c68961f..0000000
--- a/lib/posixheaders/memalloc.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/* memalloc.h -- consolidate code for including alloca.h or malloc.h and
- defining alloca. */
-
-/* Copyright (C) 1993 Free Software Foundation, Inc.
-
- This file is part of GNU Bash, the Bourne Again SHell.
-
- Bash is free software; you can redistribute it and/or modify it under
- the terms of the GNU General Public License as published by the Free
- Software Foundation; either version 2, or (at your option) any later
- version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License along
- with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_MEMALLOC_H_)
-# define _MEMALLOC_H_
-
-#if defined (sparc) && defined (sun) && !defined (HAVE_ALLOCA_H)
-# define HAVE_ALLOCA_H
-#endif
-
-#if defined (__GNUC__) && !defined (HAVE_ALLOCA)
-# define HAVE_ALLOCA
-#endif
-
-#if defined (HAVE_ALLOCA_H) && !defined (HAVE_ALLOCA)
-# define HAVE_ALLOCA
-#endif /* HAVE_ALLOCA_H && !HAVE_ALLOCA */
-
-#if defined (__GNUC__) && !defined (C_ALLOCA)
-# undef alloca
-# define alloca __builtin_alloca
-#else /* !__GNUC__ || C_ALLOCA */
-# if defined (HAVE_ALLOCA_H) && !defined (C_ALLOCA)
-# if defined (IBMESA)
-# include <malloc.h>
-# else /* !IBMESA */
-# include <alloca.h>
-# endif /* !IBMESA */
-# else /* !HAVE_ALLOCA_H || C_ALLOCA */
-# if defined (__hpux) && defined (__STDC__) && !defined (alloca)
-extern void *alloca ();
-# else
-# if !defined (alloca)
-extern char *alloca ();
-# endif /* !alloca */
-# endif /* !__hpux || !__STDC__ && !alloca */
-# endif /* !HAVE_ALLOCA_H || C_ALLOCA */
-#endif /* !__GNUC__ || C_ALLOCA */
-
-#endif /* _MEMALLOC_H_ */
diff --git a/lib/posixheaders/posixdir.h b/lib/posixheaders/posixdir.h
deleted file mode 100644
index 7480a93..0000000
--- a/lib/posixheaders/posixdir.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* posixdir.h -- Posix directory reading includes and defines. */
-
-/* Copyright (C) 1987,1991 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 1, or (at your option)
- any later version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
-
-#if !defined (_POSIXDIR_H_)
-#define _POSIXDIR_H_
-
-#if defined (HAVE_DIRENT_H)
-# include <dirent.h>
-# define D_NAMLEN(d) (strlen ((d)->d_name))
-#else
-# if defined (HAVE_SYS_NDIR_H)
-# include <sys/ndir.h>
-# endif
-# if defined (HAVE_SYS_DIR_H)
-# include <sys/dir.h>
-# endif
-# if defined (HAVE_NDIR_H)
-# include <ndir.h>
-# endif
-# if !defined (dirent)
-# define dirent direct
-# endif /* !dirent */
-# define D_NAMLEN(d) ((d)->d_namlen)
-#endif /* !HAVE_DIRENT_H */
-
-#if defined (STRUCT_DIRENT_HAS_D_INO) && !defined (STRUCT_DIRENT_HAS_D_FILENO)
-# define d_fileno d_ino
-#endif
-
-#endif /* !_POSIXDIR_H_ */
diff --git a/lib/posixheaders/posixjmp.h b/lib/posixheaders/posixjmp.h
deleted file mode 100644
index 1347cc0..0000000
--- a/lib/posixheaders/posixjmp.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
-
-#ifndef _POSIXJMP_H_
-#define _POSIXJMP_H_
-
-#include <setjmp.h>
-
-/* This *must* be included *after* config.h */
-
-#if defined (HAVE_POSIX_SIGSETJMP)
-# define procenv_t sigjmp_buf
-# if !defined (__OPENNT)
-# undef setjmp
-# define setjmp(x) sigsetjmp((x), 1)
-# undef longjmp
-# define longjmp(x, n) siglongjmp((x), (n))
-# endif /* !__OPENNT */
-#else
-# define procenv_t jmp_buf
-#endif
-
-#endif /* _POSIXJMP_H_ */
diff --git a/lib/posixheaders/posixstat.h b/lib/posixheaders/posixstat.h
deleted file mode 100644
index bfce8c0..0000000
--- a/lib/posixheaders/posixstat.h
+++ /dev/null
@@ -1,142 +0,0 @@
-/* posixstat.h -- Posix stat(2) definitions for systems that
- don't have them. */
-
-/* Copyright (C) 1987,1991 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 1, or (at your option)
- any later version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* This file should be included instead of <sys/stat.h>.
- It relies on the local sys/stat.h to work though. */
-#if !defined (_POSIXSTAT_H_)
-#define _POSIXSTAT_H_
-
-#include <sys/stat.h>
-
-#if defined (STAT_MACROS_BROKEN)
-# undef S_ISBLK
-# undef S_ISCHR
-# undef S_ISDIR
-# undef S_ISFIFO
-# undef S_ISREG
-# undef S_ISLNK
-#endif /* STAT_MACROS_BROKEN */
-
-/* These are guaranteed to work only on isc386 */
-#if !defined (S_IFDIR) && !defined (S_ISDIR)
-# define S_IFDIR 0040000
-#endif /* !S_IFDIR && !S_ISDIR */
-#if !defined (S_IFMT)
-# define S_IFMT 0170000
-#endif /* !S_IFMT */
-
-/* Posix 1003.1 5.6.1.1 <sys/stat.h> file types */
-
-/* Some Posix-wannabe systems define _S_IF* macros instead of S_IF*, but
- do not provide the S_IS* macros that Posix requires. */
-
-#if defined (_S_IFMT) && !defined (S_IFMT)
-#define S_IFMT _S_IFMT
-#endif
-#if defined (_S_IFIFO) && !defined (S_IFIFO)
-#define S_IFIFO _S_IFIFO
-#endif
-#if defined (_S_IFCHR) && !defined (S_IFCHR)
-#define S_IFCHR _S_IFCHR
-#endif
-#if defined (_S_IFDIR) && !defined (S_IFDIR)
-#define S_IFDIR _S_IFDIR
-#endif
-#if defined (_S_IFBLK) && !defined (S_IFBLK)
-#define S_IFBLK _S_IFBLK
-#endif
-#if defined (_S_IFREG) && !defined (S_IFREG)
-#define S_IFREG _S_IFREG
-#endif
-#if defined (_S_IFLNK) && !defined (S_IFLNK)
-#define S_IFLNK _S_IFLNK
-#endif
-#if defined (_S_IFSOCK) && !defined (S_IFSOCK)
-#define S_IFSOCK _S_IFSOCK
-#endif
-
-/* Test for each symbol individually and define the ones necessary (some
- systems claiming Posix compatibility define some but not all). */
-
-#if defined (S_IFBLK) && !defined (S_ISBLK)
-#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */
-#endif
-
-#if defined (S_IFCHR) && !defined (S_ISCHR)
-#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */
-#endif
-
-#if defined (S_IFDIR) && !defined (S_ISDIR)
-#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */
-#endif
-
-#if defined (S_IFREG) && !defined (S_ISREG)
-#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */
-#endif
-
-#if defined (S_IFIFO) && !defined (S_ISFIFO)
-#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */
-#endif
-
-#if defined (S_IFLNK) && !defined (S_ISLNK)
-#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */
-#endif
-
-#if defined (S_IFSOCK) && !defined (S_ISSOCK)
-#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */
-#endif
-
-/*
- * POSIX 1003.1 5.6.1.2 <sys/stat.h> File Modes
- */
-
-#if !defined (S_IRWXU)
-# if !defined (S_IREAD)
-# define S_IREAD 00400
-# define S_IWRITE 00200
-# define S_IEXEC 00100
-# endif /* S_IREAD */
-
-# if !defined (S_IRUSR)
-# define S_IRUSR S_IREAD /* read, owner */
-# define S_IWUSR S_IWRITE /* write, owner */
-# define S_IXUSR S_IEXEC /* execute, owner */
-
-# define S_IRGRP (S_IREAD >> 3) /* read, group */
-# define S_IWGRP (S_IWRITE >> 3) /* write, group */
-# define S_IXGRP (S_IEXEC >> 3) /* execute, group */
-
-# define S_IROTH (S_IREAD >> 6) /* read, other */
-# define S_IWOTH (S_IWRITE >> 6) /* write, other */
-# define S_IXOTH (S_IEXEC >> 6) /* execute, other */
-# endif /* !S_IRUSR */
-
-# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
-# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
-# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
-#endif /* !S_IRWXU */
-
-/* These are non-standard, but are used in builtins.c$symbolic_umask() */
-#define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
-#define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
-#define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
-
-#endif /* _POSIXSTAT_H_ */
diff --git a/lib/posixheaders/stdc.h b/lib/posixheaders/stdc.h
deleted file mode 100644
index f1590c6..0000000
--- a/lib/posixheaders/stdc.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* stdc.h -- macros to make source compile on both ANSI C and K&R C
- compilers. */
-
-/* Copyright (C) 1993 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 1, or (at your option)
- any later version.
-
- Bash is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
- License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-#if !defined (_STDC_H_)
-#define _STDC_H_
-
-/* Adapted from BSD /usr/include/sys/cdefs.h. */
-
-/* A function can be defined using prototypes and compile on both ANSI C
- and traditional C compilers with something like this:
- extern char *func __P((char *, char *, int)); */
-
-#if defined (__STDC__)
-
-# if !defined (__P)
-# define __P(protos) protos
-# endif
-# define __STRING(x) #x
-
-# if !defined (__GNUC__)
-# define inline
-# endif
-
-#else /* !__STDC__ */
-
-# if !defined (__P)
-# define __P(protos) ()
-# endif
-# define __STRING(x) "x"
-
-#if defined (__GNUC__) /* gcc with -traditional */
-# if !defined (const)
-# define const __const
-# endif
-# if !defined (inline)
-# define inline __inline
-# endif
-# if !defined (signed)
-# define signed __signed
-# endif
-# if !defined (volatile)
-# define volatile __volatile
-# endif
-#else /* !__GNUC__ */
-# if !defined (const)
-# define const
-# endif
-# if !defined (inline)
-# define inline
-# endif
-# if !defined (signed)
-# define signed
-# endif
-# if !defined (volatile)
-# define volatile
-# endif
-#endif /* !__GNUC__ */
-
-#endif /* !__STDC__ */
-
-#endif /* !_STDC_H_ */
diff --git a/lib/readline/COPYING b/lib/readline/COPYING
index a43ea21..a414399 100644
--- a/lib/readline/COPYING
+++ b/lib/readline/COPYING
@@ -2,7 +2,7 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
diff --git a/lib/readline/Makefile.in b/lib/readline/Makefile.in
index c0439ae..082410e 100644
--- a/lib/readline/Makefile.in
+++ b/lib/readline/Makefile.in
@@ -4,6 +4,22 @@
# #
#############################################################################
+# Copyright (C) 1994 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
@@ -61,7 +77,7 @@ CSOURCES = $(srcdir)/readline.c $(srcdir)/funmap.c $(srcdir)/keymaps.c \
# The header files for this library.
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
posixstat.h posixdir.h posixjmp.h tilde.h rlconf.h rltty.h \
- ansi_stdlib.h rlstdc.h tcap.h
+ ansi_stdlib.h rlstdc.h tcap.h rlprivate.h rlshell.h
HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o savestring.o
TILDEOBJ = tilde.o
@@ -179,6 +195,8 @@ macro.o: readline.h keymaps.h chardefs.h tilde.h
macro.o: history.h rlstdc.h
nls.o: ansi_stdlib.h
nls.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
+nls.o: readline.h keymaps.h chardefs.h tilde.h
+nls.o: history.h rlstdc.h
parens.o: rlconf.h
parens.o: ${BUILD_DIR}/config.h
parens.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
@@ -213,8 +231,55 @@ util.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
vi_mode.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
vi_mode.o: readline.h keymaps.h chardefs.h tilde.h
vi_mode.o: history.h ansi_stdlib.h rlstdc.h
-xmalloc.o: ${BUILD_DIR}/config.h
-xmalloc.o: ansi_stdlib.h
+xmalloc.o: ${BUILD_DIR}/config.h ansi_stdlib.h
+
+bind.o: rlshell.h
+histfile.o: rlshell.h
+nls.o: rlshell.h
+readline.o: rlshell.h
+shell.o: rlshell.h
+terminal.o: rlshell.h
+histexpand.o: rlshell.h
+
+bind.o: rlprivate.h
+callback.o: rlprivate.h
+complete.o: rlprivate.h
+display.o: rlprivate.h
+input.o: rlprivate.h
+isearch.o: rlprivate.h
+kill.o: rlprivate.h
+macro.o: rlprivate.h
+nls.o: rlprivate.h
+parens.o: rlprivate.h
+readline.o: rlprivate.h
+rltty.o: rlprivate.h
+search.o: rlprivate.h
+signals.o: rlprivate.h
+terminal.o: rlprivate.h
+undo.o: rlprivate.h
+util.o: rlprivate.h
+vi_mode.o: rlprivate.h
+
+bind.o: xmalloc.h
+complete.o: xmalloc.h
+display.o: xmalloc.h
+funmap.o: xmalloc.h
+histexpand.o: xmalloc.h
+histfile.o: xmalloc.h
+history.o: xmalloc.h
+input.o: xmalloc.h
+isearch.o: xmalloc.h
+keymaps.o: xmalloc.h
+kill.o: xmalloc.h
+macro.o: xmalloc.h
+readline.o: xmalloc.h
+savestring.o: xmalloc.h
+search.o: xmalloc.h
+shell.o: xmalloc.h
+tilde.o: xmalloc.h
+tilde.o: xmalloc.h
+util.o: xmalloc.h
+vi_mode.o: xmalloc.h
# Rules for deficient makes, like SunOS and Solaris
bind.o: bind.c
diff --git a/lib/readline/ansi_stdlib.h b/lib/readline/ansi_stdlib.h
index 52339da..a720cb9 100644
--- a/lib/readline/ansi_stdlib.h
+++ b/lib/readline/ansi_stdlib.h
@@ -18,7 +18,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_STDLIB_H_)
#define _STDLIB_H_ 1
diff --git a/lib/readline/bind.c b/lib/readline/bind.c
index f446dc8..6a6424e 100644
--- a/lib/readline/bind.c
+++ b/lib/readline/bind.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -42,7 +42,6 @@
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
-#include <signal.h>
#include <errno.h>
#if !defined (errno)
@@ -58,61 +57,25 @@ extern int errno;
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
#if !defined (strchr) && !defined (__STDC__)
extern char *strchr (), *strrchr ();
#endif /* !strchr && !__STDC__ */
-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_complete_show_all;
-extern int _rl_complete_mark_directories;
-extern int _rl_print_completions_horizontally;
-extern int _rl_completion_case_fold;
-extern int _rl_enable_keypad;
-#if defined (PAREN_MATCHING)
-extern int rl_blink_matching_paren;
-#endif /* PAREN_MATCHING */
-#if defined (VISIBLE_STATS)
-extern int rl_visible_stats;
-#endif /* VISIBLE_STATS */
-extern int rl_complete_with_tilde_expansion;
-extern int rl_completion_query_items;
-extern int rl_inhibit_completion;
-extern char *_rl_comment_begin;
-extern unsigned char *_rl_isearch_terminators;
-
-extern int rl_explicit_arg;
-extern int rl_editing_mode;
-extern unsigned char _rl_parsing_conditionalized_out;
-extern Keymap _rl_keymap;
-
-extern char *possible_control_prefixes[], *possible_meta_prefixes[];
-
-/* Functions imported from funmap.c */
-extern char **rl_funmap_names ();
-extern int rl_add_funmap_entry ();
-
-/* Functions imported from util.c */
-extern char *_rl_strindex ();
-
-/* Functions imported from shell.c */
-extern char *get_env_value ();
-
/* Variables exported by this file. */
Keymap rl_binding_keymap;
-/* Forward declarations */
-void rl_set_keymap_from_edit_mode ();
+static int _rl_read_init_file __P((char *, int));
+static int glean_key_from_name __P((char *));
+static int substring_member_of_array __P((char *, char **));
-static int _rl_read_init_file ();
-static int glean_key_from_name ();
-static int substring_member_of_array ();
+static int currently_reading_init_file;
-extern char *xmalloc (), *xrealloc ();
+/* used only in this file */
+static int _rl_prefer_visible_bell = 1;
/* **************************************************************** */
/* */
@@ -677,9 +640,16 @@ _rl_read_file (filename, sizep)
return ((char *)NULL);
}
+#if 0
buffer[file_size] = '\0';
if (sizep)
*sizep = file_size;
+#else
+ buffer[i] = '\0';
+ if (sizep)
+ *sizep = i;
+#endif
+
return (buffer);
}
@@ -718,6 +688,11 @@ rl_read_init_file (filename)
if (*filename == 0)
filename = DEFAULT_INPUTRC;
+#if defined (__MSDOS__)
+ if (_rl_read_init_file (filename, 0) == 0)
+ return 0;
+ filename = "~/_inputrc";
+#endif
return (_rl_read_init_file (filename, 0));
}
@@ -746,6 +721,8 @@ _rl_read_init_file (filename, include_level)
last_readline_init_file = savestring (filename);
}
+ currently_reading_init_file = 1;
+
/* Loop over the lines in the file. Lines that start with `#' are
comments; all other lines are commands for readline initialization. */
current_readline_init_lineno = 1;
@@ -756,6 +733,12 @@ _rl_read_init_file (filename, include_level)
/* Find the end of this line. */
for (i = 0; line + i != end && line[i] != '\n'; i++);
+#if defined (__CYGWIN32__)
+ /* ``Be liberal in what you accept.'' */
+ if (line[i] == '\n' && line[i-1] == '\r')
+ line[i - 1] = '\0';
+#endif
+
/* Mark end of line. */
line[i] = '\0';
@@ -776,6 +759,7 @@ _rl_read_init_file (filename, include_level)
}
free (buffer);
+ currently_reading_init_file = 0;
return (0);
}
@@ -783,9 +767,11 @@ static void
_rl_init_file_error (msg)
char *msg;
{
- fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file,
- current_readline_init_lineno,
- msg);
+ if (currently_reading_init_file)
+ fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file,
+ current_readline_init_lineno, msg);
+ else
+ fprintf (stderr, "readline: %s\n", msg);
}
/* **************************************************************** */
@@ -1232,154 +1218,273 @@ rl_parse_and_bind (string)
have one of two values; either "On" or 1 for truth, or "Off" or 0 for
false. */
+#define V_SPECIAL 0x1
+
static struct {
char *name;
int *value;
+ int flags;
} boolean_varlist [] = {
-#if defined (PAREN_MATCHING)
- { "blink-matching-paren", &rl_blink_matching_paren },
-#endif
- { "completion-ignore-case", &_rl_completion_case_fold },
- { "convert-meta", &_rl_convert_meta_chars_to_ascii },
- { "disable-completion", &rl_inhibit_completion },
- { "enable-keypad", &_rl_enable_keypad },
- { "expand-tilde", &rl_complete_with_tilde_expansion },
- { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode },
- { "input-meta", &_rl_meta_flag },
- { "mark-directories", &_rl_complete_mark_directories },
- { "mark-modified-lines", &_rl_mark_modified_lines },
- { "meta-flag", &_rl_meta_flag },
- { "output-meta", &_rl_output_meta_chars },
- { "print-completions-horizontally", &_rl_print_completions_horizontally },
- { "show-all-if-ambiguous", &_rl_complete_show_all },
+ { "blink-matching-paren", &rl_blink_matching_paren, V_SPECIAL },
+ { "completion-ignore-case", &_rl_completion_case_fold, 0 },
+ { "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 },
+ { "disable-completion", &rl_inhibit_completion, 0 },
+ { "enable-keypad", &_rl_enable_keypad, 0 },
+ { "expand-tilde", &rl_complete_with_tilde_expansion, 0 },
+ { "horizontal-scroll-mode", &_rl_horizontal_scroll_mode, 0 },
+ { "input-meta", &_rl_meta_flag, 0 },
+ { "mark-directories", &_rl_complete_mark_directories, 0 },
+ { "mark-modified-lines", &_rl_mark_modified_lines, 0 },
+ { "meta-flag", &_rl_meta_flag, 0 },
+ { "output-meta", &_rl_output_meta_chars, 0 },
+ { "prefer-visible-bell", &_rl_prefer_visible_bell, V_SPECIAL },
+ { "print-completions-horizontally", &_rl_print_completions_horizontally, 0 },
+ { "show-all-if-ambiguous", &_rl_complete_show_all, 0 },
#if defined (VISIBLE_STATS)
- { "visible-stats", &rl_visible_stats },
+ { "visible-stats", &rl_visible_stats, 0 },
#endif /* VISIBLE_STATS */
{ (char *)NULL, (int *)NULL }
};
+static int
+find_boolean_var (name)
+ char *name;
+{
+ register int i;
+
+ for (i = 0; boolean_varlist[i].name; i++)
+ if (_rl_stricmp (name, boolean_varlist[i].name) == 0)
+ return i;
+ return -1;
+}
+
+/* Hooks for handling special boolean variables, where a
+ function needs to be called or another variable needs
+ to be changed when they're changed. */
+static void
+hack_special_boolean_var (i)
+ int i;
+{
+ char *name;
+
+ name = boolean_varlist[i].name;
+
+ if (_rl_stricmp (name, "blink-matching-paren") == 0)
+ _rl_enable_paren_matching (rl_blink_matching_paren);
+ else if (_rl_stricmp (name, "prefer-visible-bell") == 0)
+ {
+ if (_rl_prefer_visible_bell)
+ _rl_bell_preference = VISIBLE_BELL;
+ else
+ _rl_bell_preference = AUDIBLE_BELL;
+ }
+}
+
+/* These *must* correspond to the array indices for the appropriate
+ string variable. (Though they're not used right now.) */
+#define V_BELLSTYLE 0
+#define V_COMBEGIN 1
+#define V_EDITMODE 2
+#define V_ISRCHTERM 3
+#define V_KEYMAP 4
+
+#define V_STRING 1
+#define V_INT 2
+
+/* Forward declarations */
+static int sv_bell_style __P((char *));
+static int sv_combegin __P((char *));
+static int sv_compquery __P((char *));
+static int sv_editmode __P((char *));
+static int sv_isrchterm __P((char *));
+static int sv_keymap __P((char *));
+
+static struct {
+ char *name;
+ int flags;
+ Function *set_func;
+} string_varlist[] = {
+ { "bell-style", V_STRING, sv_bell_style },
+ { "comment-begin", V_STRING, sv_combegin },
+ { "completion-query-items", V_INT, sv_compquery },
+ { "editing-mode", V_STRING, sv_editmode },
+ { "isearch-terminators", V_STRING, sv_isrchterm },
+ { "keymap", V_STRING, sv_keymap },
+ { (char *)NULL, 0 }
+};
+
+static int
+find_string_var (name)
+ char *name;
+{
+ register int i;
+
+ for (i = 0; string_varlist[i].name; i++)
+ if (_rl_stricmp (name, string_varlist[i].name) == 0)
+ return i;
+ return -1;
+}
+
+/* A boolean value that can appear in a `set variable' command is true if
+ the value is null or empty, `on' (case-insenstive), or "1". Any other
+ values result in 0 (false). */
+static int
+bool_to_int (value)
+ char *value;
+{
+ return (value == 0 || *value == '\0' ||
+ (_rl_stricmp (value, "on") == 0) ||
+ (value[0] == '1' && value[1] == '\0'));
+}
+
int
rl_variable_bind (name, value)
char *name, *value;
{
register int i;
+ int v;
/* Check for simple variables first. */
- for (i = 0; boolean_varlist[i].name; i++)
+ i = find_boolean_var (name);
+ if (i >= 0)
{
- if (_rl_stricmp (name, boolean_varlist[i].name) == 0)
- {
- /* A variable is TRUE if the "value" is "on", "1" or "". */
- *boolean_varlist[i].value = *value == 0 ||
- _rl_stricmp (value, "on") == 0 ||
- (value[0] == '1' && value[1] == '\0');
- return 0;
- }
+ *boolean_varlist[i].value = bool_to_int (value);
+ if (boolean_varlist[i].flags & V_SPECIAL)
+ hack_special_boolean_var (i);
+ return 0;
}
- /* Not a boolean variable, so check for specials. */
+ i = find_string_var (name);
- /* Editing mode change? */
- if (_rl_stricmp (name, "editing-mode") == 0)
+ /* For the time being, unknown variable names or string names without a
+ handler function are simply ignored. */
+ if (i < 0 || string_varlist[i].set_func == 0)
+ return 0;
+
+ v = (*string_varlist[i].set_func) (value);
+ return v;
+}
+
+static int
+sv_editmode (value)
+ char *value;
+{
+ if (_rl_strnicmp (value, "vi", 2) == 0)
{
- if (_rl_strnicmp (value, "vi", 2) == 0)
- {
#if defined (VI_MODE)
- _rl_keymap = vi_insertion_keymap;
- rl_editing_mode = vi_mode;
+ _rl_keymap = vi_insertion_keymap;
+ rl_editing_mode = vi_mode;
#endif /* VI_MODE */
- }
- else if (_rl_strnicmp (value, "emacs", 5) == 0)
- {
- _rl_keymap = emacs_standard_keymap;
- rl_editing_mode = emacs_mode;
- }
+ return 0;
}
-
- /* Comment string change? */
- else if (_rl_stricmp (name, "comment-begin") == 0)
+ else if (_rl_strnicmp (value, "emacs", 5) == 0)
{
- if (*value)
- {
- if (_rl_comment_begin)
- free (_rl_comment_begin);
-
- _rl_comment_begin = savestring (value);
- }
+ _rl_keymap = emacs_standard_keymap;
+ rl_editing_mode = emacs_mode;
+ return 0;
}
- else if (_rl_stricmp (name, "completion-query-items") == 0)
+ return 1;
+}
+
+static int
+sv_combegin (value)
+ char *value;
+{
+ if (value && *value)
{
- int nval = 100;
- if (*value)
- {
- nval = atoi (value);
- if (nval < 0)
- nval = 0;
- }
- rl_completion_query_items = nval;
+ FREE (_rl_comment_begin);
+ _rl_comment_begin = savestring (value);
+ return 0;
}
- else if (_rl_stricmp (name, "keymap") == 0)
+ return 1;
+}
+
+static int
+sv_compquery (value)
+ char *value;
+{
+ int nval = 100;
+
+ if (value && *value)
{
- Keymap kmap;
- kmap = rl_get_keymap_by_name (value);
- if (kmap)
- rl_set_keymap (kmap);
+ nval = atoi (value);
+ if (nval < 0)
+ nval = 0;
}
- else if (_rl_stricmp (name, "bell-style") == 0)
+ rl_completion_query_items = nval;
+ return 0;
+}
+
+static int
+sv_keymap (value)
+ char *value;
+{
+ Keymap kmap;
+
+ kmap = rl_get_keymap_by_name (value);
+ if (kmap)
{
- if (!*value)
- _rl_bell_preference = AUDIBLE_BELL;
- else
- {
- if (_rl_stricmp (value, "none") == 0 || _rl_stricmp (value, "off") == 0)
- _rl_bell_preference = NO_BELL;
- else if (_rl_stricmp (value, "audible") == 0 || _rl_stricmp (value, "on") == 0)
- _rl_bell_preference = AUDIBLE_BELL;
- else if (_rl_stricmp (value, "visible") == 0)
- _rl_bell_preference = VISIBLE_BELL;
- }
+ rl_set_keymap (kmap);
+ return 0;
}
- else if (_rl_stricmp (name, "prefer-visible-bell") == 0)
+ return 1;
+}
+
+#define _SET_BELL(v) do { _rl_bell_preference = v; return 0; } while (0)
+
+static int
+sv_bell_style (value)
+ char *value;
+{
+ if (value == 0 || *value == '\0')
+ _SET_BELL (AUDIBLE_BELL);
+ else if (_rl_stricmp (value, "none") == 0 || _rl_stricmp (value, "off") == 0)
+ _SET_BELL (NO_BELL);
+ else if (_rl_stricmp (value, "audible") == 0 || _rl_stricmp (value, "on") == 0)
+ _SET_BELL (AUDIBLE_BELL);
+ else if (_rl_stricmp (value, "visible") == 0)
+ _SET_BELL (VISIBLE_BELL);
+ else
+ return 1;
+}
+#undef _SET_BELL
+
+static int
+sv_isrchterm (value)
+ char *value;
+{
+ int beg, end, delim;
+ char *v;
+
+ if (value == 0)
+ return 1;
+
+ /* Isolate the value and translate it into a character string. */
+ v = savestring (value);
+ FREE (_rl_isearch_terminators);
+ if (v[0] == '"' || v[0] == '\'')
{
- /* Backwards compatibility. */
- if (*value && (_rl_stricmp (value, "on") == 0 ||
- (*value == '1' && !value[1])))
- _rl_bell_preference = VISIBLE_BELL;
- else
- _rl_bell_preference = AUDIBLE_BELL;
+ delim = v[0];
+ for (beg = end = 1; v[end] && v[end] != delim; end++)
+ ;
}
- else if (_rl_stricmp (name, "isearch-terminators") == 0)
+ else
{
- /* Isolate the value and translate it into a character string. */
- int beg, end;
- char *v;
+ for (beg = end = 0; whitespace (v[end]) == 0; end++)
+ ;
+ }
- v = savestring (value);
- FREE (_rl_isearch_terminators);
- if (v[0] == '"' || v[0] == '\'')
- {
- int delim = v[0];
- for (beg = end = 1; v[end] && v[end] != delim; end++)
- ;
- }
- else
- {
- for (beg = end = 0; whitespace (v[end]) == 0; end++)
- ;
- }
+ v[end] = '\0';
- v[end] = '\0';
- /* The value starts at v + beg. Translate it into a character string. */
- _rl_isearch_terminators = (unsigned char *)xmalloc (2 * strlen (v) + 1);
- rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
- _rl_isearch_terminators[end] = '\0';
- free (v);
- }
-
- /* For the time being, unknown variable names are simply ignored. */
+ /* The value starts at v + beg. Translate it into a character string. */
+ _rl_isearch_terminators = (unsigned char *)xmalloc (2 * strlen (v) + 1);
+ rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
+ _rl_isearch_terminators[end] = '\0';
+
+ free (v);
return 0;
}
-
+
/* Return the character which matches NAME.
For example, `Space' returns ' '. */
diff --git a/lib/readline/callback.c b/lib/readline/callback.c
index 6915be4..1172356 100644
--- a/lib/readline/callback.c
+++ b/lib/readline/callback.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -35,15 +35,7 @@
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "readline.h"
-
-extern void readline_internal_setup ();
-extern char *readline_internal_teardown ();
-extern int readline_internal_char ();
-extern void _rl_init_line_state ();
-
-extern int _rl_meta_flag;
-extern char *rl_prompt;
-extern int rl_visible_prompt_length;
+#include "rlprivate.h"
/* **************************************************************** */
/* */
diff --git a/lib/readline/chardefs.h b/lib/readline/chardefs.h
index 3e9e273..664c1e4 100644
--- a/lib/readline/chardefs.h
+++ b/lib/readline/chardefs.h
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _CHARDEFS_H_
#define _CHARDEFS_H_
diff --git a/lib/readline/complete.c b/lib/readline/complete.c
index 714a2bf..fb48712 100644
--- a/lib/readline/complete.c
+++ b/lib/readline/complete.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -70,20 +70,14 @@ extern struct passwd *getpwent ();
/* Some standard library routines. */
#include "readline.h"
+#include "xmalloc.h"
+#include "rlprivate.h"
-extern char *tilde_expand ();
-extern char *rl_copy_text ();
-extern void _rl_abort_internal ();
-extern int _rl_qsort_string_compare ();
-extern void _rl_replace_text ();
-
-extern Function *rl_last_func;
-extern int rl_editing_mode;
-extern int screenwidth;
-
-extern void _rl_move_vert ();
-extern int _rl_vis_botlin;
-extern int rl_display_fixed;
+#ifdef __STDC__
+typedef int QSFUNC (const void *, const void *);
+#else
+typedef int QSFUNC ();
+#endif
/* If non-zero, then this is the address of a function to call when
completing a word would normally display the list of possible matches.
@@ -95,27 +89,25 @@ extern int rl_display_fixed;
VFunction *rl_completion_display_matches_hook = (VFunction *)NULL;
/* Forward declarations for functions defined and used in this file. */
-char *filename_completion_function ();
-char **completion_matches ();
+char *filename_completion_function __P((char *, int));
+char **completion_matches __P((char *, CPFunction *));
#if defined (VISIBLE_STATS)
# if !defined (X_OK)
# define X_OK 1
# endif
-static int stat_char ();
+static int stat_char __P((char *));
#endif
-static char *rl_quote_filename ();
-static char *rl_strpbrk ();
-
-static char **remove_duplicate_matches ();
-static void insert_match ();
-static int append_to_match ();
-static void insert_all_matches ();
-static void display_matches ();
-static int compute_lcd_of_matches ();
+static char *rl_quote_filename __P((char *, int, char *));
+static char *rl_strpbrk __P((char *, char *));
-extern char *xmalloc (), *xrealloc ();
+static char **remove_duplicate_matches __P((char **));
+static void insert_match __P((char *, int, int, char *));
+static int append_to_match __P((char *, int, int));
+static void insert_all_matches __P((char **, int, char *));
+static void display_matches __P((char **));
+static int compute_lcd_of_matches __P((char **, int, char *));
/* **************************************************************** */
/* */
@@ -136,7 +128,11 @@ int _rl_complete_mark_directories = 1;
int _rl_print_completions_horizontally;
/* Non-zero means that case is not significant in filename completion. */
+#if defined (__MSDOS__) && !defined (__DJGPP__)
+int _rl_completion_case_fold = 1;
+#else
int _rl_completion_case_fold;
+#endif
/* Global variables available to applications using readline. */
@@ -417,6 +413,10 @@ printable_part (pathname)
char *temp;
temp = rl_filename_completion_desired ? strrchr (pathname, '/') : (char *)NULL;
+#if defined (__MSDOS__)
+ if (rl_filename_completion_desired && temp == 0 && isalpha (pathname[0]) && pathname[1] == ':')
+ temp = pathname + 1;
+#endif
return (temp ? ++temp : pathname);
}
@@ -477,7 +477,12 @@ print_filename (to_print, full_pathname)
c = to_print[-1];
to_print[-1] = '\0';
- s = tilde_expand (full_pathname);
+ /* If setting the last slash in full_pathname to a NUL results in
+ full_pathname being the empty string, we are trying to complete
+ files in the root directory. If we pass a null string to the
+ bash directory completion hook, for example, it will expand it
+ to the current directory. We just want the `/'. */
+ s = tilde_expand (full_pathname && *full_pathname ? full_pathname : "/");
if (rl_directory_completion_hook)
(*rl_directory_completion_hook) (&s);
@@ -627,25 +632,31 @@ find_completion_word (fp, dp)
/* If there is an application-specific function to say whether or not
a character is quoted and we found a quote character, let that
function decide whether or not a character is a word break, even
- if it is found in rl_completer_word_break_characters. */
- if (rl_char_is_quoted_p)
- isbrk = (found_quote == 0 ||
- (*rl_char_is_quoted_p) (rl_line_buffer, rl_point) == 0) &&
- strchr (rl_completer_word_break_characters, scan) != 0;
- else
- isbrk = strchr (rl_completer_word_break_characters, scan) != 0;
-
- if (isbrk)
+ if it is found in rl_completer_word_break_characters. Don't bother
+ if we're at the end of the line, though. */
+ if (scan)
{
- /* If the character that caused the word break was a quoting
- character, then remember it as the delimiter. */
- if (rl_basic_quote_characters && strchr (rl_basic_quote_characters, scan) && (end - rl_point) > 1)
- delimiter = scan;
-
- /* If the character isn't needed to determine something special
- about what kind of completion to perform, then advance past it. */
- if (rl_special_prefixes == 0 || strchr (rl_special_prefixes, scan) == 0)
- rl_point++;
+ if (rl_char_is_quoted_p)
+ isbrk = (found_quote == 0 ||
+ (*rl_char_is_quoted_p) (rl_line_buffer, rl_point) == 0) &&
+ strchr (rl_completer_word_break_characters, scan) != 0;
+ else
+ isbrk = strchr (rl_completer_word_break_characters, scan) != 0;
+
+ if (isbrk)
+ {
+ /* If the character that caused the word break was a quoting
+ character, then remember it as the delimiter. */
+ if (rl_basic_quote_characters &&
+ strchr (rl_basic_quote_characters, scan) &&
+ (end - rl_point) > 1)
+ delimiter = scan;
+
+ /* If the character isn't needed to determine something special
+ about what kind of completion to perform, then advance past it. */
+ if (rl_special_prefixes == 0 || strchr (rl_special_prefixes, scan) == 0)
+ rl_point++;
+ }
}
if (fp)
@@ -715,7 +726,7 @@ remove_duplicate_matches (matches)
/* Sort the array without matches[0], since we need it to
stay in place no matter what. */
if (i)
- qsort (matches+1, i-1, sizeof (char *), _rl_qsort_string_compare);
+ qsort (matches+1, i-1, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
/* Remember the lowest common denominator for it may be unique. */
lowest_common = savestring (matches[0]);
@@ -908,7 +919,7 @@ rl_display_match_list (matches, len, max)
/* Sort the items if they are not already sorted. */
if (rl_ignore_completion_duplicates == 0)
- qsort (matches + 1, len, sizeof (char *), _rl_qsort_string_compare);
+ qsort (matches + 1, len, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
crlf ();
@@ -1407,9 +1418,9 @@ username_completion_function (text, state)
char *text;
int state;
{
-#if defined (__GO32__) || defined (__WIN32__) || defined (__OPENNT)
+#if defined (__WIN32__) || defined (__OPENNT)
return (char *)NULL;
-#else /* !__GO32__ */
+#else /* !__WIN32__ && !__OPENNT) */
static char *username = (char *)NULL;
static struct passwd *entry;
static int namelen, first_char, first_char_loc;
@@ -1452,7 +1463,7 @@ username_completion_function (text, state)
return (value);
}
-#endif /* !__GO32__ */
+#endif /* !__WIN32__ && !__OPENNT */
}
/* Okay, now we write the entry_function for filename completion. In the
@@ -1494,11 +1505,25 @@ filename_completion_function (text, state)
temp = strrchr (dirname, '/');
+#if defined (__MSDOS__)
+ /* special hack for //X/... */
+ if (dirname[0] == '/' && dirname[1] == '/' && isalpha (dirname[2]) && dirname[3] == '/')
+ temp = strrchr (dirname + 3, '/');
+#endif
+
if (temp)
{
strcpy (filename, ++temp);
*temp = '\0';
}
+#if defined (__MSDOS__)
+ /* searches from current directory on the drive */
+ else if (isalpha (dirname[0]) && dirname[1] == ':')
+ {
+ strcpy (filename, dirname + 2);
+ dirname[2] = '\0';
+ }
+#endif
else
{
dirname[0] = '.';
@@ -1660,11 +1685,7 @@ rl_menu_complete (count, ignore)
/* Clean up from previous call, if any. */
FREE (orig_text);
if (matches)
- {
- for (match_list_index = 0; matches[match_list_index]; match_list_index++)
- free (matches[match_list_index]);
- free (matches);
- }
+ free_match_list (matches);
match_list_index = match_list_size = 0;
matches = (char **)NULL;
diff --git a/lib/readline/display.c b/lib/readline/display.c
index 25aba64..4487004 100644
--- a/lib/readline/display.c
+++ b/lib/readline/display.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -41,11 +41,6 @@
#include <stdio.h>
-#if defined (__GO32__)
-# include <go32.h>
-# include <pc.h>
-#endif /* __GO32__ */
-
/* System-specific feature definitions and include files. */
#include "rldefs.h"
@@ -56,48 +51,25 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "xmalloc.h"
+
#if !defined (strchr) && !defined (__STDC__)
extern char *strchr (), *strrchr ();
#endif /* !strchr && !__STDC__ */
-/* Global and pseudo-global variables and functions
- imported from readline.c. */
-extern char *rl_prompt;
-extern int readline_echoing_p;
-
-extern int _rl_output_meta_chars;
-extern int _rl_horizontal_scroll_mode;
-extern int _rl_mark_modified_lines;
-extern int _rl_prefer_visible_bell;
-
-/* Variables and functions imported from terminal.c */
-extern void _rl_output_some_chars ();
-#ifdef _MINIX
-extern void _rl_output_character_function ();
-#else
-extern int _rl_output_character_function ();
+#if defined (HACK_TERMCAP_MOTION)
+extern char *term_forward_char;
#endif
-extern int _rl_backspace ();
-
-extern char *term_clreol, *term_clrpag;
-extern char *term_im, *term_ic, *term_ei, *term_DC;
-extern char *term_up, *term_dc, *term_cr, *term_IC;
-extern int screenheight, screenwidth, screenchars;
-extern int terminal_can_insert, _rl_term_autowrap;
-
-/* Pseudo-global functions (local to the readline library) exported
- by this file. */
-void _rl_move_cursor_relative (), _rl_output_some_chars ();
-void _rl_move_vert ();
-void _rl_clear_to_eol (), _rl_clear_screen ();
-static void update_line (), space_to_eol ();
-static void delete_chars (), insert_some_chars ();
-static void cr ();
+static void update_line __P((char *, char *, int, int, int, int));
+static void space_to_eol __P((int));
+static void delete_chars __P((int));
+static void insert_some_chars __P((char *, int));
+static void cr __P((void));
static int *inv_lbreaks, *vis_lbreaks;
-
-extern char *xmalloc (), *xrealloc ();
+static int inv_lbsize, vis_lbsize;
/* Heuristic used to decide whether it is faster to move from CUR to NEW
by backing up or outputting a carriage return and moving forward. */
@@ -190,7 +162,7 @@ static int visible_first_line_len;
/* 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
- index of the last invisible character in ther eturned string. */
+ index of the last invisible character in the returned string. */
/* Current implementation:
\001 (^A) start non-visible characters
@@ -250,6 +222,18 @@ expand_prompt (pmt, lp, lip)
return ret;
}
+/* Just strip out RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE from
+ PMT and return the rest of PMT. */
+char *
+_rl_strip_prompt (pmt)
+ char *pmt;
+{
+ char *ret;
+
+ ret = expand_prompt (pmt, (int *)NULL, (int *)NULL);
+ return ret;
+}
+
/*
* Expand the prompt string into the various display components, if
* necessary.
@@ -307,6 +291,49 @@ rl_expand_prompt (prompt)
}
}
+/* Initialize the VISIBLE_LINE and INVISIBLE_LINE arrays, and their associated
+ arrays of line break markers. MINSIZE is the minimum size of VISIBLE_LINE
+ and INVISIBLE_LINE; if it is greater than LINE_SIZE, LINE_SIZE is
+ increased. If the lines have already been allocated, this ensures that
+ they can hold at least MINSIZE characters. */
+static void
+init_line_structures (minsize)
+ int minsize;
+{
+ register int n;
+
+ if (invisible_line == 0) /* initialize it */
+ {
+ if (line_size < minsize)
+ line_size = minsize;
+ visible_line = xmalloc (line_size);
+ invisible_line = xmalloc (line_size);
+ }
+ else if (line_size < minsize) /* ensure it can hold MINSIZE chars */
+ {
+ line_size *= 2;
+ if (line_size < minsize)
+ line_size = minsize;
+ visible_line = xrealloc (visible_line, line_size);
+ invisible_line = xrealloc (invisible_line, line_size);
+ }
+
+ for (n = minsize; n < line_size; n++)
+ {
+ visible_line[n] = 0;
+ invisible_line[n] = 1;
+ }
+
+ if (vis_lbreaks == 0)
+ {
+ /* should be enough. */
+ inv_lbsize = vis_lbsize = 256;
+ inv_lbreaks = (int *)xmalloc (inv_lbsize * sizeof (int));
+ vis_lbreaks = (int *)xmalloc (vis_lbsize * sizeof (int));
+ inv_lbreaks[0] = vis_lbreaks[0] = 0;
+ }
+}
+
/* Basic redisplay algorithm. */
void
rl_redisplay ()
@@ -325,19 +352,7 @@ rl_redisplay ()
if (invisible_line == 0)
{
- visible_line = xmalloc (line_size);
- invisible_line = xmalloc (line_size);
- for (in = 0; in < line_size; in++)
- {
- visible_line[in] = 0;
- invisible_line[in] = 1;
- }
-
- /* should be enough, but then again, this is just for testing. */
- inv_lbreaks = (int *)malloc (256 * sizeof (int));
- vis_lbreaks = (int *)malloc (256 * sizeof (int));
- inv_lbreaks[0] = vis_lbreaks[0] = 0;
-
+ init_line_structures (0);
rl_on_new_line ();
}
@@ -395,12 +410,13 @@ rl_redisplay ()
else
{
prompt_this_line++;
+ pmtlen = prompt_this_line - rl_display_prompt; /* temp var */
if (forced_display)
{
- _rl_output_some_chars (rl_display_prompt, prompt_this_line - rl_display_prompt);
+ _rl_output_some_chars (rl_display_prompt, pmtlen);
/* Make sure we are at column zero even after a newline,
regardless of the state of terminal output processing. */
- if (prompt_this_line[-2] != '\r')
+ if (pmtlen < 2 || prompt_this_line[-2] != '\r')
cr ();
}
}
@@ -419,11 +435,25 @@ rl_redisplay ()
wrap_offset = 0;
}
+#define CHECK_INV_LBREAKS() \
+ do { \
+ if (newlines >= (inv_lbsize - 2)) \
+ { \
+ inv_lbsize *= 2; \
+ inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
+ } \
+ } while (0)
+
#define CHECK_LPOS() \
do { \
lpos++; \
if (lpos >= screenwidth) \
{ \
+ if (newlines >= (inv_lbsize - 2)) \
+ { \
+ inv_lbsize *= 2; \
+ inv_lbreaks = (int *)xrealloc (inv_lbreaks, inv_lbsize * sizeof (int)); \
+ } \
inv_lbreaks[++newlines] = out; \
lpos = 0; \
} \
@@ -437,14 +467,13 @@ rl_redisplay ()
contents of the command line? */
while (lpos >= screenwidth)
{
-#if 0
- temp = ((newlines + 1) * screenwidth) - ((newlines == 0) ? wrap_offset : 0);
-#else
/* XXX - possible fix from Darin Johnson <darin@acuson.com> for prompt
string with invisible characters that is longer than the screen
- width. */
+ width. XXX - this doesn't work right if invisible characters have
+ to be put on the second screen line -- it adds too much (the number
+ of invisible chars after the screenwidth). */
temp = ((newlines + 1) * screenwidth) + ((newlines == 0) ? wrap_offset : 0);
-#endif
+
inv_lbreaks[++newlines] = temp;
lpos -= screenwidth;
}
@@ -477,6 +506,7 @@ rl_redisplay ()
if (lpos + 4 >= screenwidth)
{
temp = screenwidth - lpos;
+ CHECK_INV_LBREAKS ();
inv_lbreaks[++newlines] = out + temp;
lpos = 4 - temp;
}
@@ -506,6 +536,7 @@ rl_redisplay ()
{
register int temp2;
temp2 = screenwidth - lpos;
+ CHECK_INV_LBREAKS ();
inv_lbreaks[++newlines] = out + temp2;
lpos = temp - temp2;
while (out < newout)
@@ -522,6 +553,7 @@ rl_redisplay ()
else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && term_up && *term_up)
{
line[out++] = '\0'; /* XXX - sentinel */
+ CHECK_INV_LBREAKS ();
inv_lbreaks[++newlines] = out;
lpos = 0;
}
@@ -546,6 +578,7 @@ rl_redisplay ()
}
inv_botlin = lb_botlin = newlines;
+ CHECK_INV_LBREAKS ();
inv_lbreaks[newlines+1] = out;
cursor_linenum = lb_linenum;
@@ -651,8 +684,12 @@ rl_redisplay ()
if (cursor_linenum == 0 && wrap_offset > 0 && _rl_last_c_pos > 0 &&
_rl_last_c_pos <= last_invisible && local_prompt)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
if (term_cr)
tputs (term_cr, 1, _rl_output_character_function);
+#endif
_rl_output_some_chars (local_prompt, nleft);
_rl_last_c_pos = nleft;
}
@@ -772,11 +809,17 @@ rl_redisplay ()
/* Swap visible and non-visible lines. */
{
char *temp = visible_line;
- int *itemp = vis_lbreaks;
+ int *itemp = vis_lbreaks, ntemp = vis_lbsize;
+
visible_line = invisible_line;
invisible_line = temp;
+
vis_lbreaks = inv_lbreaks;
inv_lbreaks = itemp;
+
+ vis_lbsize = inv_lbsize;
+ inv_lbsize = ntemp;
+
rl_display_fixed = 0;
/* If we are displaying on a single line, and last_lmargin is > 0, we
are not displaying any invisible characters, so set visible_wrap_offset
@@ -899,7 +942,11 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
term_cr && lendiff > visible_length && _rl_last_c_pos > 0 &&
od > lendiff && _rl_last_c_pos < last_invisible)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
tputs (term_cr, 1, _rl_output_character_function);
+#endif
_rl_output_some_chars (local_prompt, lendiff);
_rl_last_c_pos = lendiff;
}
@@ -1029,6 +1076,58 @@ rl_on_new_line ()
return 0;
}
+/* Tell the update routines that we have moved onto a new line with the
+ prompt already displayed. Code originally from the version of readline
+ distributed with CLISP. */
+int
+rl_on_new_line_with_prompt ()
+{
+ int prompt_size, i, l, real_screenwidth, newlines;
+ char *prompt_last_line;
+
+ /* Initialize visible_line and invisible_line to ensure that they can hold
+ the already-displayed prompt. */
+ prompt_size = strlen (rl_prompt) + 1;
+ init_line_structures (prompt_size);
+
+ /* Make sure the line structures hold the already-displayed prompt for
+ redisplay. */
+ strcpy (visible_line, rl_prompt);
+ strcpy (invisible_line, rl_prompt);
+
+ /* If the prompt contains newlines, take the last tail. */
+ prompt_last_line = strrchr (rl_prompt, '\n');
+ if (!prompt_last_line)
+ prompt_last_line = rl_prompt;
+
+ l = strlen (prompt_last_line);
+ _rl_last_c_pos = l;
+
+ /* Dissect prompt_last_line into screen lines. Note that here we have
+ to use the real screenwidth. Readline's notion of screenwidth might be
+ one less, see terminal.c. */
+ real_screenwidth = screenwidth + (_rl_term_autowrap ? 0 : 1);
+ _rl_last_v_pos = l / real_screenwidth;
+ /* If the prompt length is a multiple of real_screenwidth, we don't know
+ whether the cursor is at the end of the last line, or already at the
+ beginning of the next line. Output a newline just to be safe. */
+ if (l > 0 && (l % real_screenwidth) == 0)
+ _rl_output_some_chars ("\n", 1);
+ last_lmargin = 0;
+
+ newlines = 0; i = 0;
+ while (i <= l)
+ {
+ _rl_vis_botlin = newlines;
+ vis_lbreaks[newlines++] = i;
+ i += real_screenwidth;
+ }
+ vis_lbreaks[newlines] = l;
+ visible_wrap_offset = 0;
+
+ return 0;
+}
+
/* Actually update the display, period. */
int
rl_forced_update_display ()
@@ -1086,8 +1185,6 @@ _rl_move_cursor_relative (new, data)
That kind of control is for people who don't know what the
data is underneath the cursor. */
#if defined (HACK_TERMCAP_MOTION)
- extern char *term_forward_char;
-
if (term_forward_char)
for (i = _rl_last_c_pos; i < new; i++)
tputs (term_forward_char, 1, _rl_output_character_function);
@@ -1114,20 +1211,15 @@ _rl_move_vert (to)
if (_rl_last_v_pos == to || to > screenheight)
return;
-#if defined (__GO32__)
- {
- int row, col;
-
- ScreenGetCursor (&row, &col);
- ScreenSetCursor ((row + to - _rl_last_v_pos), col);
- }
-#else /* !__GO32__ */
-
if ((delta = to - _rl_last_v_pos) > 0)
{
for (i = 0; i < delta; i++)
putc ('\n', rl_outstream);
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
tputs (term_cr, 1, _rl_output_character_function);
+#endif
_rl_last_c_pos = 0;
}
else
@@ -1136,7 +1228,7 @@ _rl_move_vert (to)
for (i = 0; i < -delta; i++)
tputs (term_up, 1, _rl_output_character_function);
}
-#endif /* !__GO32__ */
+
_rl_last_v_pos = to; /* Now TO is here */
}
@@ -1344,11 +1436,9 @@ void
_rl_clear_to_eol (count)
int count;
{
-#if !defined (__GO32__)
if (term_clreol)
tputs (term_clreol, 1, _rl_output_character_function);
else if (count)
-#endif /* !__GO32__ */
space_to_eol (count);
}
@@ -1369,11 +1459,9 @@ space_to_eol (count)
void
_rl_clear_screen ()
{
-#if !defined (__GO32__)
if (term_clrpag)
tputs (term_clrpag, 1, _rl_output_character_function);
else
-#endif /* !__GO32__ */
crlf ();
}
@@ -1383,20 +1471,6 @@ insert_some_chars (string, count)
char *string;
int count;
{
-#if defined (__GO32__)
- int row, col, width;
- char *row_start;
-
- ScreenGetCursor (&row, &col);
- width = ScreenCols ();
- row_start = ScreenPrimary + (row * width);
-
- memcpy (row_start + col + count, row_start + col, width - col - count);
-
- /* Place the text on the screen. */
- _rl_output_some_chars (string, count);
-#else /* !_GO32 */
-
/* If IC is defined, then we do not have to "enter" insert mode. */
if (term_IC)
{
@@ -1429,7 +1503,6 @@ insert_some_chars (string, count)
if (term_ei && *term_ei)
tputs (term_ei, 1, _rl_output_character_function);
}
-#endif /* !__GO32__ */
}
/* Delete COUNT characters from the display line. */
@@ -1437,18 +1510,6 @@ static void
delete_chars (count)
int count;
{
-#if defined (__GO32__)
- int row, col, width;
- char *row_start;
-
- ScreenGetCursor (&row, &col);
- width = ScreenCols ();
- row_start = ScreenPrimary + (row * width);
-
- memcpy (row_start + col, row_start + col + count, width - col - count);
- memset (row_start + width - count, 0, count * 2);
-#else /* !_GO32 */
-
if (count > screenwidth) /* XXX */
return;
@@ -1464,7 +1525,6 @@ delete_chars (count)
while (count--)
tputs (term_dc, 1, _rl_output_character_function);
}
-#endif /* !__GO32__ */
}
void
@@ -1486,7 +1546,11 @@ _rl_update_final ()
if (full_lines && _rl_term_autowrap && (VIS_LLEN(_rl_vis_botlin) == screenwidth))
{
char *last_line;
+#if 0
last_line = &visible_line[inv_lbreaks[_rl_vis_botlin]];
+#else
+ last_line = &visible_line[vis_lbreaks[_rl_vis_botlin]];
+#endif
_rl_move_cursor_relative (screenwidth - 1, last_line);
_rl_clear_to_eol (0);
putc (last_line[screenwidth - 1], rl_outstream);
@@ -1503,23 +1567,66 @@ cr ()
{
if (term_cr)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
tputs (term_cr, 1, _rl_output_character_function);
+#endif
_rl_last_c_pos = 0;
}
}
+/* Redraw the last line of a multi-line prompt that may possibly contain
+ terminal escape sequences. Called with the cursor at column 0 of the
+ line to draw the prompt on. */
+static void
+redraw_prompt (t)
+ char *t;
+{
+ char *oldp, *oldl, *oldlprefix;
+ int oldlen, oldlast, oldplen;
+
+ /* Geez, I should make this a struct. */
+ oldp = rl_display_prompt;
+ oldl = local_prompt;
+ oldlprefix = local_prompt_prefix;
+ oldlen = visible_length;
+ oldplen = prefix_length;
+ oldlast = last_invisible;
+
+ rl_display_prompt = t;
+ local_prompt = expand_prompt (t, &visible_length, &last_invisible);
+ local_prompt_prefix = (char *)NULL;
+ rl_forced_update_display ();
+
+ rl_display_prompt = oldp;
+ local_prompt = oldl;
+ local_prompt_prefix = oldlprefix;
+ visible_length = oldlen;
+ prefix_length = oldplen;
+ last_invisible = oldlast;
+}
+
/* Redisplay the current line after a SIGWINCH is received. */
void
_rl_redisplay_after_sigwinch ()
{
- char *t, *oldp, *oldl, *oldlprefix;
+ char *t;
/* Clear the current line and put the cursor at column 0. Make sure
the right thing happens if we have wrapped to a new screen line. */
if (term_cr)
{
+#if defined (__MSDOS__)
+ putc ('\r', rl_outstream);
+#else
tputs (term_cr, 1, _rl_output_character_function);
+#endif
_rl_last_c_pos = 0;
+#if defined (__MSDOS__)
+ space_to_eol (screenwidth);
+ putc ('\r', rl_outstream);
+#else
if (term_clreol)
tputs (term_clreol, 1, _rl_output_character_function);
else
@@ -1527,6 +1634,7 @@ _rl_redisplay_after_sigwinch ()
space_to_eol (screenwidth);
tputs (term_cr, 1, _rl_output_character_function);
}
+#endif
if (_rl_last_v_pos > 0)
_rl_move_vert (0);
}
@@ -1536,17 +1644,7 @@ _rl_redisplay_after_sigwinch ()
/* Redraw only the last line of a multi-line prompt. */
t = strrchr (rl_display_prompt, '\n');
if (t)
- {
- oldp = rl_display_prompt;
- oldl = local_prompt;
- oldlprefix = local_prompt_prefix;
- rl_display_prompt = ++t;
- local_prompt = local_prompt_prefix = (char *)NULL;
- rl_forced_update_display ();
- rl_display_prompt = oldp;
- local_prompt = oldl;
- local_prompt_prefix = oldlprefix;
- }
+ redraw_prompt (++t);
else
rl_forced_update_display ();
}
@@ -1571,3 +1669,25 @@ _rl_erase_entire_line ()
cr ();
fflush (rl_outstream);
}
+
+/* return the `current display line' of the cursor -- the number of lines to
+ move up to get to the first screen line of the current readline line. */
+int
+_rl_current_display_line ()
+{
+ int ret, nleft;
+
+ /* Find out whether or not there might be invisible characters in the
+ editing buffer. */
+ if (rl_display_prompt == rl_prompt)
+ nleft = _rl_last_c_pos - screenwidth - rl_visible_prompt_length;
+ else
+ nleft = _rl_last_c_pos - screenwidth;
+
+ if (nleft > 0)
+ ret = 1 + nleft / screenwidth;
+ else
+ ret = 0;
+
+ return ret;
+}
diff --git a/lib/readline/doc/Makefile b/lib/readline/doc/Makefile
index b58ab56..42b578e 100644
--- a/lib/readline/doc/Makefile
+++ b/lib/readline/doc/Makefile
@@ -1,7 +1,7 @@
-# Generated automatically from Makefile.in by configure.
+# Derived by hand from the generated readline-src/doc/Makefile
# This makefile for Readline library documentation is in -*- text -*- mode.
# Emacs likes it that way.
-top_srcdir = .
+topdir = .
srcdir = .
VPATH = .
@@ -9,25 +9,32 @@ prefix = /usr/local
infodir = ${prefix}/info
mandir = ${prefix}/man
-man3dir = $(mandir)/man3
+manpfx = man
+
+man1ext = 1
+man1dir = $(mandir)/$(manpfx)$(man1ext)
+man3ext = 3
+man3dir = $(mandir)/$(manpfx)$(man3ext)
SHELL = /bin/sh
RM = rm -f
+INSTALL = /usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+
+BUILD_DIR = .
TEXINPUTDIR = $(srcdir)
-MAKEINFO = makeinfo
+MAKEINFO = LANGUAGE= makeinfo
TEXI2DVI = $(srcdir)/texi2dvi
TEXI2HTML = $(srcdir)/texi2html
QUIETPS = #set this to -q to shut up dvips
-DVIPS = dvips -D 300 $(QUIETPS) -o $@ # tricky
-
-INSTALL = /usr/bin/install -c
-INSTALL_PROGRAM = ${INSTALL}
-INSTALL_DATA = ${INSTALL} -m 644
+PSDPI = 300 # I don't have any 600-dpi printers
+DVIPS = dvips -D ${PSDPI} $(QUIETPS) -o $@ # tricky
RLSRC = $(srcdir)/rlman.texinfo $(srcdir)/rluser.texinfo \
- $(srcdir)/rltech.texinfo $(srcdir)/manvers.texinfo
+ $(srcdir)/rltech.texinfo $(srcdir)/manvers.texinfo \
+ $(srcdir)/rluserman.texinfo
HISTSRC = $(srcdir)/hist.texinfo $(srcdir)/hsuser.texinfo \
$(srcdir)/hstech.texinfo $(srcdir)/manvers.texinfo
@@ -37,25 +44,19 @@ NROFF = groff -Tascii
# This should be a program that converts troff to postscript
GROFF = groff
-DVIOBJ = readline.dvi history.dvi
-INFOOBJ = readline.info history.info
-PSOBJ = readline.ps history.ps
-HTMLOBJ = readline.html history.html
-HTMLTOC = readline_toc.html history_toc.html
-TEXTOBJ = readline.0
+DVIOBJ = readline.dvi history.dvi rluserman.dvi
+INFOOBJ = readline.info history.info rluserman.info
+PSOBJ = readline.ps history.ps rluserman.ps
+HTMLOBJ = readline.html history.html rluserman.html
-INTERMEDIATE_OBJ = rlman.dvi hist.dvi
+INTERMEDIATE_OBJ = rlman.dvi hist.dvi rluserman.dvi
-CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ) $(HTMLTOC) $(TEXTOBJ)
+CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ)
-.SUFFIXES: .0 .3 .ps .txt .dvi
+.SUFFIXES: .ps .txt .dvi
-.3.0:
- $(RM) $@
- -${NROFF} -man $< > $@
-
-all: info dvi html ps #text
-nodvi: info html #text
+all: info dvi html ps
+nodvi: info html
readline.dvi: $(RLSRC)
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rlman.texinfo
@@ -64,6 +65,12 @@ readline.dvi: $(RLSRC)
readline.info: $(RLSRC)
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rlman.texinfo
+rluserman.dvi: $(RLSRC)
+ TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rluserman.texinfo
+
+rluserman.info: $(RLSRC)
+ $(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rluserman.texinfo
+
history.dvi: ${HISTSRC}
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/hist.texinfo
mv hist.dvi history.dvi
@@ -75,6 +82,10 @@ readline.ps: readline.dvi
$(RM) $@
$(DVIPS) readline.dvi
+rluserman.ps: rluserman.dvi
+ $(RM) $@
+ $(DVIPS) rluserman.dvi
+
history.ps: history.dvi
$(RM) $@
$(DVIPS) history.dvi
@@ -84,6 +95,9 @@ readline.html: ${RLSRC}
sed -e 's:rlman.html:readline.html:' rlman.html > readline.html
$(RM) rlman.html
+rluserman.html: ${RLSRC}
+ $(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rluserman.texinfo
+
history.html: ${HISTSRC}
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/hist.texinfo
sed -e 's:hist.html:history.html:' hist.html > history.html
@@ -93,9 +107,6 @@ info: $(INFOOBJ)
dvi: $(DVIOBJ)
ps: $(PSOBJ)
html: $(HTMLOBJ)
-text: $(TEXTOBJ)
-
-readline.0: readline.3
clean:
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
@@ -113,27 +124,7 @@ maintainer-clean: clean
$(RM) $(INTERMEDIATE_OBJ)
$(RM) Makefile
-installdirs: $(top_srcdir)/support/mkdirs
- -$(SHELL) $(top_srcdir)/support/mkdirs $(infodir) $(man3dir)
-
-install: installdirs
- if test -f readline.info; then \
- ${INSTALL_DATA} readline.info $(infodir)/readline.info; \
- else \
- ${INSTALL_DATA} $(srcdir)/readline.info $(infodir)/readline.info; \
- fi
- if test -f history.info; then \
- ${INSTALL_DATA} history.info $(infodir)/history.info; \
- else \
- ${INSTALL_DATA} $(srcdir)/history.info $(infodir)/history.info; \
- fi
- if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
- install-info --dir-file=$(infodir)/dir $(infodir)/readline.info ; \
- install-info --dir-file=$(infodir)/dir $(infodir)/history.info ; \
- else true; fi
- -${INSTALL_DATA} $(srcdir)/readline.3 $(man3dir)/readline.3
+install:
+ @echo "This documentation should not be installed."
uninstall:
- $(RM) $(infodir)/readline.info
- $(RM) $(infodir)/history.info
- $(RM) $(man3dir)/readline.3
diff --git a/lib/readline/doc/hist.texinfo b/lib/readline/doc/hist.texinfo
index 31a0ba0..8a9c941 100644
--- a/lib/readline/doc/hist.texinfo
+++ b/lib/readline/doc/hist.texinfo
@@ -55,8 +55,8 @@ provides a consistent user interface for recalling lines of previously
typed input.
Published by the Free Software Foundation @*
-675 Massachusetts Avenue, @*
-Cambridge, MA 02139 USA
+59 Temple Place, Suite 330, @*
+Boston, MA 02111 USA
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
diff --git a/lib/readline/doc/hstech.texinfo b/lib/readline/doc/hstech.texinfo
index 5410090..12fff2c 100644
--- a/lib/readline/doc/hstech.texinfo
+++ b/lib/readline/doc/hstech.texinfo
@@ -66,6 +66,13 @@ If the programmer desires, he can use the Readline library, which
includes some history manipulation by default, and has the added
advantage of command line editing.
+Before declaring any functions using any functionality the History
+library provides in other code, an application writer should include
+the file @code{<readline/history.h>} in any file that uses the
+History library's features. It supplies extern declarations for all
+of the library's public functions and variables, and declares all of
+the public data structures.
+
@node History Storage
@section History Storage
@@ -334,7 +341,7 @@ if expansions did take place;
@item -1
if there was an error in expansion;
@item 2
-if the returned line should only be displayed, but not executed,
+if the returned line should be displayed, but not executed,
as with the @code{:p} modifier (@pxref{Modifiers}).
@end table
diff --git a/lib/readline/doc/hsuser.texinfo b/lib/readline/doc/hsuser.texinfo
index 76cb63b..5f75f5d 100644
--- a/lib/readline/doc/hsuser.texinfo
+++ b/lib/readline/doc/hsuser.texinfo
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
-Copyright (C) 1988, 1991, 1996 Free Software Foundation, Inc.
+Copyright (C) 1988-1999 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
@@ -26,11 +26,16 @@ into another language, under the above conditions for modified versions.
@node Using History Interactively
@chapter Using History Interactively
+@ifclear BashFeatures
+@defcodeindex bt
+@end ifclear
+
@ifset BashFeatures
-This chapter describes how to use the GNU History Library interactively,
-from a user's standpoint. It should be considered a user's guide. For
-information on using the GNU History Library in other programs,
-see the GNU Readline Library Manual.
+This chapter describes how to use the @sc{gnu} History Library
+interactively, from a user's standpoint.
+It should be considered a user's guide.
+For information on using the @sc{gnu} History Library in other programs,
+see the @sc{gnu} Readline Library Manual.
@end ifset
@ifclear BashFeatures
This chapter describes how to use the GNU History Library interactively,
@@ -63,20 +68,25 @@ information on using the GNU History Library in your own programs,
When the @samp{-o history} option to the @code{set} builtin
is enabled (@pxref{The Set Builtin}),
the shell provides access to the @var{command history},
-the list of commands previously typed. The text of the last
-@code{HISTSIZE}
-commands (default 500) is saved in a history list. The shell
-stores each command in the history list prior to parameter and
-variable expansion
+the list of commands previously typed.
+The value of the @code{HISTSIZE} shell variable is used as the
+number of commands to save in a history list.
+The text of the last @code{$HISTSIZE}
+commands (default 500) is saved.
+The shell stores each command in the history list prior to
+parameter and variable expansion
but after history expansion is performed, subject to the
values of the shell variables
@code{HISTIGNORE} and @code{HISTCONTROL}.
+
When the shell starts up, the history is initialized from the
file named by the @code{HISTFILE} variable (default @file{~/.bash_history}).
-@code{HISTFILE} is truncated, if necessary, to contain no more than
-the number of lines specified by the value of the @code{HISTFILESIZE}
-variable. When an interactive shell exits, the last
-@code{HISTSIZE} lines are copied from the history list to @code{HISTFILE}.
+The file named by the value of @code{HISTFILE} is truncated, if
+necessary, to contain no more than the number of lines specified by
+the value of the @code{HISTFILESIZE} variable.
+When an interactive shell exits, the last
+@code{$HISTSIZE} lines are copied from the history list to the file
+named by @code{$HISTFILE}.
If the @code{histappend} shell option is set (@pxref{Bash Builtins}),
the lines are appended to the history file,
otherwise the history file is overwritten.
@@ -88,11 +98,11 @@ lines. If @code{HISTFILESIZE} is not set, no truncation is performed.
The builtin command @code{fc} may be used to list or edit and re-execute
a portion of the history list.
-The @code{history} builtin can be used to display or modify the history
+The @code{history} builtin may be used to display or modify the history
list and manipulate the history file.
-When using the command-line editing, search commands
+When using command-line editing, search commands
are available in each editing mode that provide access to the
-history list.
+history list (@pxref{Commands For History}).
The shell allows control over which commands are saved on the history
list. The @code{HISTCONTROL} and @code{HISTIGNORE}
@@ -105,13 +115,14 @@ semicolons where necessary to preserve syntactic correctness.
The @code{lithist}
shell option causes the shell to save the command with embedded newlines
instead of semicolons.
+The @code{shopt} builtin is used to set these options.
@xref{Bash Builtins}, for a description of @code{shopt}.
@node Bash History Builtins
@section Bash History Builtins
@cindex history builtins
-Bash provides two builtin commands that allow you to manipulate the
+Bash provides two builtin commands which manipulate the
history list and history file.
@table @code
@@ -151,23 +162,27 @@ and typing @samp{r} re-executes the last command (@pxref{Aliases}).
@item history
@btindex history
@example
-history [-c] [@var{n}]
+history [@var{n}]
+history -c
+history -d @var{offset}
history [-anrw] [@var{filename}]
history -ps @var{arg}
@end example
-Display the history list with line numbers. Lines prefixed with
-with a @samp{*} have been modified. An argument of @var{n} says
-to list only the last @var{n} lines. Options, if supplied, have
-the following meanings:
+With no options, display the history list with line numbers.
+Lines prefixed with with a @samp{*} have been modified.
+An argument of @var{n} lists only the last @var{n} lines.
+Options, if supplied, have the following meanings:
@table @code
-@item -w
-Write out the current history to the history file.
+@item -c
+Clear the history list. This may be combined
+with the other options to replace the history list completely.
-@item -r
-Read the current history file and append its contents to
-the history list.
+@item -d @var{offset}
+Delete the history entry at position @var{offset}.
+@var{offset} should be specified as it appears when the history is
+displayed.
@item -a
Append the new
@@ -179,20 +194,24 @@ Append the history lines not already read from the history file
to the current history list. These are lines appended to the history
file since the beginning of the current Bash session.
-@item -c
-Clear the history list. This may be combined
-with the other options to replace the history list completely.
+@item -r
+Read the current history file and append its contents to
+the history list.
-@item -s
-The @var{arg}s are added to the end of
-the history list as a single entry.
+@item -w
+Write out the current history to the history file.
@item -p
Perform history substitution on the @var{arg}s and display the result
on the standard output, without storing the results in the history list.
+
+@item -s
+The @var{arg}s are added to the end of
+the history list as a single entry.
+
@end table
-When the @samp{-w}, @samp{-r}, @samp{-a}, or @samp{-n} option is
+When any of the @samp{-w}, @samp{-r}, @samp{-a}, or @samp{-n} options is
used, if @var{filename}
is given, then it is used as the history file. If not, then
the value of the @code{HISTFILE} variable is used.
@@ -309,6 +328,26 @@ may be omitted if the word designator begins with a @samp{^}, @samp{$},
of the line, with the first word being denoted by 0 (zero). Words are
inserted into the current line separated by single spaces.
+@need 0.75
+For example,
+
+@table @code
+@item !!
+designates the preceding command. When you type this, the preceding
+command is repeated in toto.
+
+@item !!:$
+designates the last argument of the preceding command. This may be
+shortened to @code{!$}.
+
+@item !fi:2
+designates the second argument of the most recent command starting with
+the letters @code{fi}.
+@end table
+
+@need 0.75
+Here are the word designators:
+
@table @code
@item 0 (zero)
diff --git a/lib/readline/doc/manvers.texinfo b/lib/readline/doc/manvers.texinfo
index 63924e3..3122b6c 100644
--- a/lib/readline/doc/manvers.texinfo
+++ b/lib/readline/doc/manvers.texinfo
@@ -1,6 +1,6 @@
-@set EDITION 4.0
-@set VERSION 4.0
-@set UPDATED 31 December 1998
-@set UPDATE-MONTH December 1998
+@set EDITION 4.1
+@set VERSION 4.1
+@set UPDATED 2000 January 19
+@set UPDATE-MONTH January 2000
-@set LASTCHANGE Thu Dec 31 10:17:05 EST 1998
+@set LASTCHANGE Wed Jan 19 12:16:30 EST 2000
diff --git a/lib/readline/doc/rlman.texinfo b/lib/readline/doc/rlman.texinfo
index 41bafbf..759f0eb 100644
--- a/lib/readline/doc/rlman.texinfo
+++ b/lib/readline/doc/rlman.texinfo
@@ -55,8 +55,8 @@ in the consistency of user interface across discrete programs that need
to provide a command line interface.
Published by the Free Software Foundation @*
-675 Massachusetts Avenue, @*
-Cambridge, MA 02139 USA
+59 Temple Place, Suite 330, @*
+Boston, MA 02111 USA
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
diff --git a/lib/readline/doc/rltech.texinfo b/lib/readline/doc/rltech.texinfo
index ea8d7f8..51c340a 100644
--- a/lib/readline/doc/rltech.texinfo
+++ b/lib/readline/doc/rltech.texinfo
@@ -167,6 +167,13 @@ programs. This section describes the various functions and variables
defined within the Readline library which allow a user program to add
customized functionality to Readline.
+Before declaring any functions that customize Readline's behavior, or
+using any functionality Readline provides in other code, an
+application writer should include the file @code{<readline/readline.h>}
+in any file that uses Readline's features. Since some of the definitions
+in @code{readline.h} use the @code{stdio} library, the file
+@code{<stdio.h>} should be included before @code{readline.h}.
+
@menu
* The Function Type:: C declarations to make code readable.
* Function Writing:: Variables and calling conventions.
@@ -241,7 +248,9 @@ These variables are available to function writers.
@deftypevar {char *} rl_line_buffer
This is the line gathered so far. You are welcome to modify the
-contents of the line, but see @ref{Allowing Undoing}.
+contents of the line, but see @ref{Allowing Undoing}. The
+function @code{rl_extend_line_buffer} is available to increase
+the memory allocated to @code{rl_line_buffer}.
@end deftypevar
@deftypevar int rl_point
@@ -282,6 +291,16 @@ The prompt Readline uses. This is set from the argument to
@code{readline ()}, and should not be assigned to directly.
@end deftypevar
+@deftypevar int rl_already_prompted
+If an application wishes to display the prompt itself, rather than have
+Readline do it the first time @code{readline()} is called, it should set
+this variable to a non-zero value after displaying the prompt.
+The prompt must also be passed as the argument to @code{readline()} so
+the redisplay functions can update the display properly.
+The calling application is responsible for managing the value; Readline
+never sets it.
+@end deftypevar
+
@deftypevar {char *} rl_library_version
The version number of this revision of the library.
@end deftypevar
@@ -447,6 +466,13 @@ several internal keymaps: @code{emacs_standard_keymap},
@code{emacs_standard_keymap} is the default, and the examples in
this manual assume that.
+Since @code{readline} installs a set of default key bindings the first
+time it is called, there is always the danger that a custom binding
+installed before the first call to @code{readline} will be overridden.
+An alternate mechanism is to install custom key bindings in an
+initialization function assigned to the @code{rl_startup_hook} variable
+(@pxref{Readline Variables}).
+
These functions manage key bindings.
@deftypefun int rl_bind_key (int key, Function *function)
@@ -534,6 +560,12 @@ the list is formatted in such a way that it can be made part of an
Print the names of all bindable Readline functions to @code{rl_outstream}.
@end deftypefun
+@deftypefun {char **} rl_funmap_names ()
+Return a NULL terminated array of known function names. The array is
+sorted. The array itself is allocated, but not the strings inside. You
+should free () the array when you done, but not the pointrs.
+@end deftypefun
+
@node Allowing Undoing
@subsection Allowing Undoing
@@ -615,10 +647,19 @@ Readline thinks the screen display is correct.
@end deftypefun
@deftypefun int rl_on_new_line ()
-Tell the update routines that we have moved onto a new (empty) line,
+Tell the update functions that we have moved onto a new (empty) line,
usually after ouputting a newline.
@end deftypefun
+@deftypefun int rl_on_new_line_with_prompt ()
+Tell the update functions that we have moved onto a new line, with
+@var{rl_prompt} already displayed.
+This could be used by applications that want to output the prompt string
+themselves, but still need Readline to know the prompt string length for
+redisplay.
+It should be used after setting @var{rl_already_prompted}.
+@end deftypefun
+
@deftypefun int rl_reset_line_state ()
Reset the display state to a clean state and redisplay the current line
starting on a new line.
@@ -688,7 +729,7 @@ before Readline attempts to read characters from the terminal with
@code{rl_read_key ()}.
@end deftypefun
-@deftypefun rl_extend_line_buffer (int len)
+@deftypefun int rl_extend_line_buffer (int len)
Ensure that @code{rl_line_buffer} has enough space to hold @var{len}
characters, possibly reallocating it if necessary.
@end deftypefun
@@ -700,6 +741,8 @@ Initialize or re-initialize Readline's internal state.
@deftypefun int rl_reset_terminal (char *terminal_name)
Reinitialize Readline's idea of the terminal settings using
@var{terminal_name} as the terminal type (e.g., @code{vt100}).
+If @var{terminal_name} is NULL, the value of the @code{TERM}
+environment variable is used.
@end deftypefun
@deftypefun int alphabetic (int c)
@@ -1106,7 +1149,7 @@ for subsequent calls.
@deftypevar {Function *} rl_completion_entry_function
A pointer to the generator function for @code{completion_matches ()}.
-@code{NULL} means to use @code{filename_entry_function ()}, the default
+@code{NULL} means to use @code{filename_completion_function ()}, the default
filename completer.
@end deftypevar
diff --git a/lib/readline/doc/rluser.texinfo b/lib/readline/doc/rluser.texinfo
index 755f7ca..9f088ff 100644
--- a/lib/readline/doc/rluser.texinfo
+++ b/lib/readline/doc/rluser.texinfo
@@ -7,10 +7,10 @@
This file documents the end user interface to the GNU command line
editing features. It is to be an appendix to manuals for programs which
use these features. There is a document entitled "readline.texinfo"
-which contains both end-user and programmer documentation for the GNU
-Readline Library.
+which contains both end-user and programmer documentation for the
+GNU Readline Library.
-Copyright (C) 1988, 1991, 1993, 1996 Free Software Foundation, Inc.
+Copyright (C) 1988-1999 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
@@ -36,11 +36,19 @@ into another language, under the above conditions for modified versions.
@comment If you are including this manual as an appendix, then set the
@comment variable readline-appendix.
+@ifclear BashFeatures
+@defcodeindex bt
+@end ifclear
+
@node Command Line Editing
@chapter Command Line Editing
-This chapter describes the basic features of the @sc{GNU}
+This chapter describes the basic features of the @sc{gnu}
command line editing interface.
+@ifset BashFeatures
+Command line editing is provided by the Readline library, which is
+used by several different programs, including Bash.
+@end ifset
@menu
* Introduction and Notation:: Notation used in this text.
@@ -50,6 +58,12 @@ command line editing interface.
available for binding
* Readline vi Mode:: A short description of how to make Readline
behave like the vi editor.
+@ifset BashFeatures
+* Programmable Completion:: How to specify the possible completions for
+ a specific command.
+* Programmable Completion Builtins:: Builtin commands to specify how to
+ complete arguments for a particular command.
+@end ifset
@end menu
@node Introduction and Notation
@@ -63,9 +77,19 @@ produced when the @key{k} key is pressed while the Control key
is depressed.
The text @key{M-k} is read as `Meta-K' and describes the character
-produced when the meta key (if you have one) is depressed, and the @key{k}
-key is pressed. If you do not have a meta key, the identical keystroke
-can be generated by typing @key{ESC} @i{first}, and then typing @key{k}.
+produced when the Meta key (if you have one) is depressed, and the @key{k}
+key is pressed.
+The Meta key is labeled @key{ALT} on many keyboards.
+On keyboards with two keys labeled @key{ALT} (usually to either side of
+the space bar), the @key{ALT} on the left side is generally set to
+work as a Meta key.
+The @key{ALT} key on the right may also be configured to work as a
+Meta key or may be configured as some other modifier, such as a
+Compose key for typing accented characters.
+
+If you do not have a Meta or @key{ALT} key, or another key working as
+a Meta key, the identical keystroke can be generated by typing @key{ESC}
+@i{first}, and then typing @key{k}.
Either process is known as @dfn{metafying} the @key{k} key.
The text @key{M-C-k} is read as `Meta-Control-k' and describes the
@@ -75,6 +99,10 @@ In addition, several keys have their own names. Specifically,
@key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all
stand for themselves when seen in this text, or in an init file
(@pxref{Readline Init File}).
+If your keyboard lacks a @key{LFD} key, typing @key{C-j} will
+produce the desired character.
+The @key{RET} key may be labeled @key{Return} or @key{Enter} on
+some keyboards.
@node Readline Interaction
@section Readline Interaction
@@ -110,8 +138,8 @@ character appears where the cursor was, and then the cursor moves one
space to the right. If you mistype a character, you can use your
erase character to back up and delete the mistyped character.
-Sometimes you may miss typing a character that you wanted to type, and
-not notice your error until you have typed several other characters. In
+Sometimes you may mistype a character, and
+not notice the error until you have typed several other characters. In
that case, you can type @key{C-b} to move the cursor to the left, and then
correct your mistake. Afterwards, you can move the cursor to the right
with @key{C-f}.
@@ -120,7 +148,7 @@ When you add text in the middle of a line, you will notice that characters
to the right of the cursor are `pushed over' to make room for the text
that you have inserted. Likewise, when you delete text behind the cursor,
characters to the right of the cursor are `pulled back' to fill in the
-blank space created by the removal of the text. A list of the basic bare
+blank space created by the removal of the text. A list of the bare
essentials for editing the text of an input line follows.
@table @asis
@@ -128,22 +156,28 @@ essentials for editing the text of an input line follows.
Move back one character.
@item @key{C-f}
Move forward one character.
-@item @key{DEL}
+@item @key{DEL} or @key{Backspace}
Delete the character to the left of the cursor.
@item @key{C-d}
Delete the character underneath the cursor.
@item @w{Printing characters}
Insert the character into the line at the cursor.
-@item @key{C-_}
+@item @key{C-_} or @key{C-x C-u}
Undo the last editing command. You can undo all the way back to an
empty line.
@end table
+@noindent
+(Depending on your configuration, the @key{Backspace} key be set to
+delete the character to the left of the cursor and the @key{DEL} key set
+to delete the character underneath the cursor, like @key{C-d}, rather
+than the character to the left of the cursor.)
+
@node Readline Movement Commands
@subsection Readline Movement Commands
-The above table describes the most basic possible keystrokes that you need
+The above table describes the most basic keystrokes that you need
in order to do editing of the input line. For your convenience, many
other commands have been added in addition to @key{C-b}, @key{C-f},
@key{C-d}, and @key{DEL}. Here are some commands for moving more rapidly
@@ -175,6 +209,8 @@ operate on characters while meta keystrokes operate on words.
@dfn{Killing} text means to delete the text from the line, but to save
it away for later use, usually by @dfn{yanking} (re-inserting)
it back into the line.
+(`Cut' and `paste' are more recent jargon for `kill' and `yank'.)
+
If the description for a command says that it `kills' text, then you can
be sure that you can get the text back in a different (or the same)
place later.
@@ -194,12 +230,14 @@ Here is the list of commands for killing text.
Kill the text from the current cursor position to the end of the line.
@item M-d
-Kill from the cursor to the end of the current word, or if between
+Kill from the cursor to the end of the current word, or, if between
words, to the end of the next word.
+Word boundaries are the same as those used by @key{M-f}.
@item M-DEL
-Kill from the cursor the start of the previous word, or if between
+Kill from the cursor the start of the previous word, or, if between
words, to the start of the previous word.
+Word boundaries are the same as those used by @key{M-b}.
@item C-w
Kill from the cursor to the previous whitespace. This is different than
@@ -231,7 +269,7 @@ start of the line, you might type @samp{M-- C-k}.
The general way to pass numeric arguments to a command is to type meta
digits before the command. If the first `digit' typed is a minus
-sign (@key{-}), then the sign of the argument will be negative. Once
+sign (@samp{-}), then the sign of the argument will be negative. Once
you have typed one meta digit to get the argument started, you can type
the remainder of the digits, and then the command. For example, to give
the @key{C-d} command an argument of 10, you could type @samp{M-1 0 C-d}.
@@ -252,15 +290,18 @@ As each character of the search string is typed, Readline displays
the next entry from the history matching the string typed so far.
An incremental search requires only as many characters as needed to
find the desired history entry.
-The characters present in the value of the @var{isearch-terminators} variable
+To search backward in the history for a particular string, type
+@key{C-r}. Typing @key{C-s} searches forward through the history.
+The characters present in the value of the @code{isearch-terminators} variable
are used to terminate an incremental search.
If that variable has not been assigned a value, the @key{ESC} and
@key{C-J} characters will terminate an incremental search.
@key{C-g} will abort an incremental search and restore the original line.
When the search is terminated, the history entry containing the
search string becomes the current line.
-To find other matching entries in the history list, type @key{C-s} or
-@key{C-r} as appropriate.
+
+To find other matching entries in the history list, type @key{C-r} or
+@key{C-s} as appropriate.
This will search backward or forward in the history for the next
entry matching the search string typed so far.
Any other key sequence bound to a Readline command will terminate
@@ -276,11 +317,11 @@ typed by the user or be part of the contents of the current line.
@section Readline Init File
@cindex initialization file, readline
-Although the Readline library comes with a set of @code{emacs}-like
+Although the Readline library comes with a set of Emacs-like
keybindings installed by default, it is possible to use a different set
of keybindings.
Any user can customize programs that use Readline by putting
-commands in an @dfn{inputrc} file in his home directory.
+commands in an @dfn{inputrc} file, conventionally in his home directory.
The name of this
@ifset BashFeatures
file is taken from the value of the shell variable @code{INPUTRC}. If
@@ -326,6 +367,11 @@ change from the default Emacs-like key binding to use
set editing-mode vi
@end example
+@ifset BashFeatures
+The @w{@code{bind -V}} command lists the current Readline variable names
+and values. @xref{Bash Builtins}.
+@end ifset
+
A great deal of run-time behavior is changeable with the following
variables.
@@ -363,7 +409,7 @@ them; otherwise, they are simply listed. The default limit is
@vindex convert-meta
If set to @samp{on}, Readline will convert characters with the
eighth bit set to an ASCII key sequence by stripping the eighth
-bit and prepending an @key{ESC} character, converting them to a
+bit and prefixing an @key{ESC} character, converting them to a
meta-prefixed key sequence. The default value is @samp{on}.
@item disable-completion
@@ -469,7 +515,7 @@ completions. The default is @samp{off}.
@item Key Bindings
The syntax for controlling key bindings in the init file is
-simple. First you have to know the name of the command that you
+simple. First you need to find the name of the command that you
want to change. The following sections contain tables of the command
name, the default keybinding, if any, and a short description of what
the command does.
@@ -480,6 +526,12 @@ command on a line in the init file. The name of the key
can be expressed in different ways, depending on which is most
comfortable for you.
+@ifset BashFeatures
+The @w{@code{bind -p}} command displays Readline function names and
+bindings in a format that can put directly into an initialization file.
+@xref{Bash Builtins}.
+@end ifset
+
@table @asis
@item @w{@var{keyname}: @var{function-name} or @var{macro}}
@var{keyname} is the name of a key spelled out in English. For example:
@@ -497,7 +549,7 @@ expressed on the right hand side (that is, to insert the text
@item @w{"@var{keyseq}": @var{function-name} or @var{macro}}
@var{keyseq} differs from @var{keyname} above in that strings
denoting an entire key sequence can be specified, by placing
-the key sequence in double quotes. Some GNU Emacs style key
+the key sequence in double quotes. Some @sc{gnu} Emacs style key
escapes can be used, as in the following example, but the
special character names are not recognized.
@@ -515,7 +567,7 @@ the text @samp{Function Key 1}.
@end table
-The following GNU Emacs style escape sequences are available when
+The following @sc{gnu} Emacs style escape sequences are available when
specifying key sequences:
@table @code
@@ -528,12 +580,12 @@ an escape character
@item @kbd{\\}
backslash
@item @kbd{\"}
-@key{"}
+@key{"}, a double quotation mark
@item @kbd{\'}
-@key{'}
+@key{'}, a single quote or apostrophe
@end table
-In addition to the GNU Emacs style escape sequences, a second
+In addition to the @sc{gnu} Emacs style escape sequences, a second
set of backslash escapes is available:
@table @code
@@ -554,10 +606,10 @@ horizontal tab
@item \v
vertical tab
@item \@var{nnn}
-the character whose ASCII code is the octal value @var{nnn}
+the character whose @code{ASCII} code is the octal value @var{nnn}
(one to three digits)
@item \x@var{nnn}
-the character whose ASCII code is the hexadecimal value @var{nnn}
+the character whose @code{ASCII} code is the hexadecimal value @var{nnn}
(one to three digits)
@end table
@@ -762,6 +814,17 @@ $endif
This section describes Readline commands that may be bound to key
sequences.
+@ifset BashFeatures
+You can list your key bindings by executing
+@w{@code{bind -P}} or, for a more terse format, suitable for an
+@var{inputrc} file, @w{@code{bind -p}}. (@xref{Bash Builtins}.)
+@end ifset
+
+Command names without an accompanying key sequence are unbound by default.
+In the following descriptions, @var{point} refers to the current cursor
+position, and @var{mark} refers to a cursor position saved by the
+@code{set-mark} command.
+The text between the point and mark is referred to as the @var{region}.
@node Commands For Moving
@subsection Commands For Moving
@@ -783,7 +846,7 @@ Move forward to the end of the next word. Words are composed of
letters and digits.
@item backward-word (M-b)
-Move back to the start of this, or the previous, word. Words are
+Move back to the start of the current or previous word. Words are
composed of letters and digits.
@item clear-screen (C-l)
@@ -846,9 +909,9 @@ for a string supplied by the user.
@item history-search-forward ()
Search forward through the history for the string of characters
-between the start of the current line and the current cursor
-position (the @var{point}). This is a non-incremental search. By
-default, this command is unbound.
+between the start of the current line and the point.
+This is a non-incremental search.
+By default, this command is unbound.
@item history-search-backward ()
Search backward through the history for the string of characters
@@ -908,11 +971,11 @@ the character at the cursor, moving the
cursor forward as well. If the insertion point
is at the end of the line, then this
transposes the last two characters of the line.
-Negative arguments don't work.
+Negative arguments have no effect.
@item transpose-words (M-t)
-Drag the word behind the cursor past the word in front of the cursor
-moving the cursor over that word as well.
+Drag the word before point past the word after point,
+moving point past that word as well.
@item upcase-word (M-u)
Uppercase the current (or following) word. With a negative argument,
@@ -934,38 +997,36 @@ capitalize the previous word, but do not move the cursor.
@ftable @code
@item kill-line (C-k)
-Kill the text from the current cursor position to the end of the line.
+Kill the text from point to the end of the line.
@item backward-kill-line (C-x Rubout)
Kill backward to the beginning of the line.
@item unix-line-discard (C-u)
Kill backward from the cursor to the beginning of the current line.
-The killed text is saved on the kill-ring.
@item kill-whole-line ()
-Kill all characters on the current line, no matter where the
-cursor is. By default, this is unbound.
+Kill all characters on the current line, no matter point is.
+By default, this is unbound.
@item kill-word (M-d)
-Kill from the cursor to the end of the current word, or if between
-words, to the end of the next word. Word boundaries are the same
-as @code{forward-word}.
+Kill from point to the end of the current word, or if between
+words, to the end of the next word.
+Word boundaries are the same as @code{forward-word}.
@item backward-kill-word (M-DEL)
-Kill the word behind the cursor. Word boundaries are the same
-as @code{backward-word}.
+Kill the word behind point.
+Word boundaries are the same as @code{backward-word}.
@item unix-word-rubout (C-w)
-Kill the word behind the cursor, using white space as a word
-boundary. The killed text is saved on the kill-ring.
+Kill the word behind point, using white space as a word boundary.
+The killed text is saved on the kill-ring.
@item delete-horizontal-space ()
Delete all spaces and tabs around point. By default, this is unbound.
@item kill-region ()
-Kill the text between the point and the @emph{mark} (saved
-cursor position). This text is referred to as the @var{region}.
+Kill the text in the current region.
By default, this command is unbound.
@item copy-region-as-kill ()
@@ -1109,7 +1170,7 @@ the text against lines from the history list for possible
completion matches.
@item complete-into-braces (M-@{)
-Perform filename completion and return the list of possible completions
+Perform filename completion and insert the list of possible completions
enclosed within braces so the list is available to the shell
(@pxref{Brace Expansion}).
@@ -1138,7 +1199,7 @@ in the macro appear as if typed at the keyboard.
@ftable @code
@item re-read-init-file (C-x C-r)
-Read in the contents of the inputrc file, and incorporate
+Read in the contents of the @var{inputrc} file, and incorporate
any bindings or variable assignments found there.
@item abort (C-g)
@@ -1192,7 +1253,8 @@ The value of the @code{comment-begin}
variable is inserted at the beginning of the current line,
and the line is accepted as if a newline had been typed.
@ifset BashFeatures
-This makes the current line a shell comment.
+The default value of @code{comment-begin} causes this command
+to make the current line a shell comment.
@end ifset
@item dump-functions ()
@@ -1285,3 +1347,283 @@ switches you into `command' mode, where you can edit the text of the
line with the standard @code{vi} movement keys, move to previous
history lines with @samp{k} and subsequent lines with @samp{j}, and
so forth.
+
+@ifset BashFeatures
+@node Programmable Completion
+@section Programmable Completion
+@cindex programmable completion
+
+When word completion is attempted for an argument to a command for
+which a completion specification (a @var{compspec}) has been defined
+using the @code{complete} builtin (@pxref{Programmable Completion Builtins}),
+the programmable completion facilities are invoked.
+
+First, the command name is identified.
+If a compspec has been defined for that command, the
+compspec is used to generate the list of possible completions for the word.
+If the command word is a full pathname, a compspec for the full
+pathname is searched for first.
+If no compspec is found for the full pathname, an attempt is made to
+find a compspec for the portion following the final slash.
+
+Once a compspec has been found, it is used to generate the list of
+matching words.
+If a compspec is not found, the default Bash completion
+described above (@pxref{Commands For Completion}) is performed.
+
+First, the actions specified by the compspec are used.
+Only matches which are prefixed by the word being completed are
+returned.
+When the @samp{-f} or @samp{-d} option is used for filename or
+directory name completion, the shell variable @code{FIGNORE} is
+used to filter the matches.
+@xref{Bash Variables}, for a description of @code{FIGNORE}.
+
+Any completions specified by a filename expansion pattern to the
+@samp{-G} option are generated next.
+The words generated by the pattern need not match the word being completed.
+The @code{GLOBIGNORE} shell variable is not used to filter the matches,
+but the @code{FIGNORE} shell variable is used.
+
+Next, the string specified as the argument to the @samp{-W} option
+is considered.
+The string is first split using the characters in the @code{IFS}
+special variable as delimiters.
+Shell quoting is honored.
+Each word is then expanded using
+brace expansion, tilde expansion, parameter and variable expansion,
+command substitution, arithmetic expansion, and pathname expansion,
+as described above (@pxref{Shell Expansions}).
+The results are split using the rules described above
+(@pxref{Word Splitting}).
+The results of the expansion are prefix-matched against the word being
+completed, and the matching words become the possible completions.
+
+After these matches have been generated, any shell function or command
+specified with the @samp{-F} and @samp{-C} options is invoked.
+When the command or function is invoked, the @code{COMP_LINE} and
+@code{COMP_POINT} variables are assigned values as described above
+(@pxref{Bash Variables}).
+If a shell function is being invoked, the @code{COMP_WORDS} and
+@code{COMP_CWORD} variables are also set.
+When the function or command is invoked, the first argument is the
+name of the command whose arguments are being completed, the
+second argument is the word being completed, and the third argument
+is the word preceding the word being completed on the current command line.
+No filtering of the generated completions against the word being completed
+is performed; the function or command has complete freedom in generating
+the matches.
+
+Any function specified with @samp{-F} is invoked first.
+The function may use any of the shell facilities, including the
+@code{compgen} builtin described below
+(@pxref{Programmable Completion Builtins}), to generate the matches.
+It must put the possible completions in the @code{COMPREPLY} array
+variable.
+
+Next, any command specified with the @samp{-C} option is invoked
+in an environment equivalent to command substitution.
+It should print a list of completions, one per line, to
+the standard output.
+Backslash may be used to escape a newline, if necessary.
+
+After all of the possible completions are generated, any filter
+specified with the @samp{-X} option is applied to the list.
+The filter is a pattern as used for pathname expansion; a @samp{&}
+in the pattern is replaced with the text of the word being completed.
+A literal @samp{&} may be escaped with a backslash; the backslash
+is removed before attempting a match.
+Any completion that matches the pattern will be removed from the list.
+A leading @samp{!} negates the pattern; in this case any completion
+not matching the pattern will be removed.
+
+Finally, any prefix and suffix specified with the @samp{-P} and @samp{-S}
+options are added to each member of the completion list, and the result is
+returned to the Readline completion code as the list of possible
+completions.
+
+If a compspec is found, whatever it generates is returned to the completion
+code as the full set of possible completions.
+The default Bash completions are not attempted, and the Readline
+default of filename completion is disabled.
+
+@node Programmable Completion Builtins
+@section Programmable Completion Builtins
+@cindex completion builtins
+
+Two builtin commands are available to manipulate the programmable completion
+facilities.
+
+@table @code
+@item compgen
+@btindex compgen
+@example
+@code{compgen [@var{option}] [@var{word}]}
+@end example
+
+Generate possible completion matches for @var{word} according to
+the @var{option}s, which may be any option accepted by the
+@code{complete}
+builtin with the exception of @samp{-p} and @samp{-r}, and write
+the matches to the standard output.
+When using the @samp{-F} or @samp{-C} options, the various shell variables
+set by the programmable completion facilities, while available, will not
+have useful values.
+
+The matches will be generated in the same way as if the programmable
+completion code had generated them directly from a completion specification
+with the same flags.
+If @var{word} is specified, only those completions matching @var{word}
+will be displayed.
+
+The return value is true unless an invalid option is supplied, or no
+matches were generated.
+
+@item complete
+@btindex complete
+@example
+@code{complete [-abcdefjkvu] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
+[-P @var{prefix}] [-S @var{suffix}] [-X @var{filterpat}] [-F @var{function}]
+[-C @var{command}] @var{name} [@var{name} @dots{}]}
+@code{complete -pr [@var{name} @dots{}]}
+@end example
+
+Specify how arguments to each @var{name} should be completed.
+If the @samp{-p} option is supplied, or if no options are supplied, existing
+completion specifications are printed in a way that allows them to be
+reused as input.
+The @samp{-r} option removes a completion specification for
+each @var{name}, or, if no @var{name}s are supplied, all
+completion specifications.
+
+The process of applying these completion specifications when word completion
+is attempted is described above (@pxref{Programmable Completion}).
+
+Other options, if specified, have the following meanings.
+The arguments to the @samp{-G}, @samp{-W}, and @samp{-X} options
+(and, if necessary, the @samp{-P} and @samp{-S} options)
+should be quoted to protect them from expansion before the
+@code{complete} builtin is invoked.
+
+@table @code
+@item -A @var{action}
+The @var{action} may be one of the following to generate a list of possible
+completions:
+
+@table @code
+@item alias
+Alias names. May also be specified as @samp{-a}.
+
+@item arrayvar
+Array variable names.
+
+@item binding
+Readline key binding names (@pxref{Bindable Readline Commands}).
+
+@item builtin
+Names of shell builtin commands. May also be specified as @samp{-b}.
+
+@item command
+Command names. May also be specified as @samp{-c}.
+
+@item directory
+Directory names. May also be specified as @samp{-d}.
+
+@item disabled
+Names of disabled shell builtins.
+
+@item enabled
+Names of enabled shell builtins.
+
+@item export
+Names of exported shell variables. May also be specified as @samp{-e}.
+
+@item file
+File names. May also be specified as @samp{-f}.
+
+@item function
+Names of shell functions.
+
+@item helptopic
+Help topics as accepted by the @code{help} builtin (@pxref{Bash Builtins}).
+
+@item hostname
+Hostnames, as taken from the file specified by the
+@code{HOSTFILE} shell variable (@pxref{Bash Variables}).
+
+@item job
+Job names, if job control is active. May also be specified as @samp{-j}.
+
+@item keyword
+Shell reserved words. May also be specified as @samp{-k}.
+
+@item running
+Names of running jobs, if job control is active.
+
+@item setopt
+Valid arguments for the @samp{-o} option to the @code{set} builtin
+(@pxref{The Set Builtin}).
+
+@item shopt
+Shell option names as accepted by the @code{shopt} builtin
+(@pxref{Bash Builtins}).
+
+@item signal
+Signal names.
+
+@item stopped
+Names of stopped jobs, if job control is active.
+
+@item user
+User names. May also be specified as @samp{-u}.
+
+@item variable
+Names of all shell variables. May also be specified as @samp{-v}.
+@end table
+
+@item -G @var{globpat}
+The filename expansion pattern @var{globpat} is expanded to generate
+the possible completions.
+
+@item -W @var{wordlist}
+The @var{wordlist} is split using the characters in the
+@code{IFS} special variable as delimiters, and each resultant word
+is expanded.
+The possible completions are the members of the resultant list which
+match the word being completed.
+
+@item -C @var{command}
+@var{command} is executed in a subshell environment, and its output is
+used as the possible completions.
+
+@item -F @var{function}
+The shell function @var{function} is executed in the current shell
+environment.
+When it finishes, the possible completions are retrieved from the value
+of the @code{COMPREPLY} array variable.
+
+@item -X @var{filterpat}
+@var{filterpat} is a pattern as used for filename expansion.
+It is applied to the list of possible completions generated by the
+preceding options and arguments, and each completion matching
+@var{filterpat} is removed from the list.
+A leading @samp{!} in @var{filterpat} negates the pattern; in this
+case, any completion not matching @var{filterpat} is removed.
+
+@item -P @var{prefix}
+@var{prefix} is added at the beginning of each possible completion
+after all other options have been applied.
+
+@item -S @var{suffix}
+@var{suffix} is appended to each possible completion
+after all other options have been applied.
+@end table
+
+The return value is true unless an invalid option is supplied, an option
+other than @samp{-p} or @samp{-r} is supplied without a @var{name}
+argument, an attempt is made to remove a completion specification for
+a @var{name} for which no specification exists, or
+an error occurs adding a completion specification.
+
+@end table
+@end ifset
diff --git a/lib/readline/doc/rluserman.texinfo b/lib/readline/doc/rluserman.texinfo
new file mode 100644
index 0000000..e6a3dcd
--- /dev/null
+++ b/lib/readline/doc/rluserman.texinfo
@@ -0,0 +1,94 @@
+\input texinfo @c -*-texinfo-*-
+@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.)
+@setchapternewpage odd
+
+@include manvers.texinfo
+
+@ifinfo
+@dircategory Libraries
+@direntry
+* Readline: (readline). The GNU readline library API
+@end direntry
+
+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 that need to provide a command line interface.
+
+Copyright (C) 1988-1999 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+pare preserved on all copies.
+
+@ignore
+Permission is granted to process this file through TeX and print the
+results, provided the printed document carries copying permission
+notice identical to this one except for the removal of this paragraph
+(this paragraph not being relevant to the printed manual).
+@end ignore
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the entire
+resulting derived work is distributed under the terms of a permission
+notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions,
+except that this permission notice may be stated in a translation approved
+by the Free Software Foundation.
+@end ifinfo
+
+@titlepage
+@title GNU Readline Library User Interface
+@subtitle Edition @value{EDITION}, for @code{Readline Library} Version @value{VERSION}.
+@subtitle @value{UPDATE-MONTH}
+@author Brian Fox, Free Software Foundation
+@author Chet Ramey, Case Western Reserve University
+
+@page
+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 that need to provide a command line interface.
+
+Published by the Free Software Foundation @*
+59 Temple Place, Suite 330, @*
+Boston, MA 02111 USA
+
+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.
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the entire
+resulting derived work is distributed under the terms of a permission
+notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions,
+except that this permission notice may be stated in a translation approved
+by the Free Software Foundation.
+
+@vskip 0pt plus 1filll
+Copyright @copyright{} 1988-1999 Free Software Foundation, Inc.
+@end titlepage
+
+@ifinfo
+@node Top
+@top GNU Readline Library
+
+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 that need to provide a command line interface.
+
+@menu
+* Command Line Editing:: GNU Readline User's Manual.
+@end menu
+@end ifinfo
+
+@include rluser.texinfo
+
+@contents
+@bye
diff --git a/lib/readline/emacs_keymap.c b/lib/readline/emacs_keymap.c
index 4ba3858..daba213 100644
--- a/lib/readline/emacs_keymap.c
+++ b/lib/readline/emacs_keymap.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (BUFSIZ)
#include <stdio.h>
@@ -76,11 +76,7 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
{ ISFUNC, rl_insert }, /* & */
{ ISFUNC, rl_insert }, /* ' */
{ ISFUNC, rl_insert }, /* ( */
-#if defined (PAREN_MATCHING)
- { ISFUNC, rl_insert_close }, /* ) */
-#else
{ ISFUNC, rl_insert }, /* ) */
-#endif /* !PAREN_MATCHING */
{ ISFUNC, rl_insert }, /* * */
{ ISFUNC, rl_insert }, /* + */
{ ISFUNC, rl_insert }, /* , */
@@ -140,11 +136,7 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
/* Some more punctuation. */
{ ISFUNC, rl_insert }, /* [ */
{ ISFUNC, rl_insert }, /* \ */
-#if defined (PAREN_MATCHING)
- { ISFUNC, rl_insert_close }, /* ] */
-#else
{ ISFUNC, rl_insert }, /* ] */
-#endif /* !PAREN_MATCHING */
{ ISFUNC, rl_insert }, /* ^ */
{ ISFUNC, rl_insert }, /* _ */
{ ISFUNC, rl_insert }, /* ` */
@@ -180,11 +172,7 @@ KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
/* Final punctuation. */
{ ISFUNC, rl_insert }, /* { */
{ ISFUNC, rl_insert }, /* | */
-#if defined (PAREN_MATCHING)
- { ISFUNC, rl_insert_close }, /* } */
-#else
{ ISFUNC, rl_insert }, /* } */
-#endif /* !PAREN_MATCHING */
{ ISFUNC, rl_insert }, /* ~ */
{ ISFUNC, rl_rubout }, /* RUBOUT */
diff --git a/lib/readline/examples/Makefile b/lib/readline/examples/Makefile
index d72a15d..d8df38c 100644
--- a/lib/readline/examples/Makefile
+++ b/lib/readline/examples/Makefile
@@ -1,7 +1,23 @@
# This is the Makefile for the examples subdirectory of readline. -*- text -*-
#
+# Copyright (C) 1994 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
EXECUTABLES = fileman rltest rl
-CFLAGS = -g -I../.. -I..
+CFLAGS = -g -I../.. -I.. -DREADLINE_LIBRARY
LDFLAGS = -g -L..
.c.o:
diff --git a/lib/readline/examples/excallback.c b/lib/readline/examples/excallback.c
new file mode 100644
index 0000000..ca03fc3
--- /dev/null
+++ b/lib/readline/examples/excallback.c
@@ -0,0 +1,186 @@
+/*
+From: Jeff Solomon <jsolomon@stanford.edu>
+Date: Fri, 9 Apr 1999 10:13:27 -0700 (PDT)
+To: chet@po.cwru.edu
+Subject: new readline example
+Message-ID: <14094.12094.527305.199695@mrclean.Stanford.EDU>
+
+Chet,
+
+I've been using readline 4.0. Specifically, I've been using the perl
+version Term::ReadLine::Gnu. It works great.
+
+Anyway, I've been playing around the alternate interface and I wanted
+to contribute a little C program, callback.c, to you that you could
+use as an example of the alternate interface in the /examples
+directory of the readline distribution.
+
+My example shows how, using the alternate interface, you can
+interactively change the prompt (which is very nice imo). Also, I
+point out that you must roll your own terminal setting when using the
+alternate interface because readline depreps (using your parlance) the
+terminal while in the user callback. I try to demostrate what I mean
+with an example. I've included the program below.
+
+To compile, I just put the program in the examples directory and made
+the appropriate changes to the EXECUTABLES and OBJECTS line and added
+an additional target 'callback'.
+
+I compiled on my Sun Solaris2.6 box using Sun's cc.
+
+Let me know what you think.
+
+Jeff
+*/
+
+#if defined (HAVE_CONFIG_H)
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <termios.h> /* xxx - should make this more general */
+
+#ifdef READLINE_LIBRARY
+# include "readline.h"
+#else
+# include <readline/readline.h>
+#endif
+
+/* This little examples demonstrates the alternate interface to using readline.
+ * In the alternate interface, the user maintains control over program flow and
+ * only calls readline when STDIN is readable. Using the alternate interface,
+ * you can do anything else while still using readline (like talking to a
+ * network or another program) without blocking.
+ *
+ * Specifically, this program highlights two importants features of the
+ * alternate interface. The first is the ability to interactively change the
+ * prompt, which can't be done using the regular interface since rl_prompt is
+ * read-only.
+ *
+ * The second feature really highlights a subtle point when using the alternate
+ * interface. That is, readline will not alter the terminal when inside your
+ * callback handler. So let's so, your callback executes a user command that
+ * takes a non-trivial amount of time to complete (seconds). While your
+ * executing the command, the user continues to type keystrokes and expects them
+ * to be re-echoed on the new prompt when it returns. Unfortunately, the default
+ * terminal configuration doesn't do this. After the prompt returns, the user
+ * must hit one additional keystroke and then will see all of his previous
+ * keystrokes. To illustrate this, compile and run this program. Type "sleep" at
+ * the prompt and then type "bar" before the prompt returns (you have 3
+ * seconds). Notice how "bar" is re-echoed on the prompt after the prompt
+ * returns? This is what you expect to happen. Now comment out the 4 lines below
+ * the line that says COMMENT LINE BELOW. Recompile and rerun the program and do
+ * the same thing. When the prompt returns, you should not see "bar". Now type
+ * "f", see how "barf" magically appears? This behavior is un-expected and not
+ * desired.
+ */
+
+void process_line(char *line);
+int change_prompt(void);
+char *get_prompt(void);
+
+int prompt = 1;
+char prompt_buf[40], line_buf[256];
+tcflag_t old_lflag;
+cc_t old_vtime;
+struct termios term;
+
+int
+main()
+{
+ fd_set fds;
+
+ /* Adjust the terminal slightly before the handler is installed. Disable
+ * canonical mode processing and set the input character time flag to be
+ * non-blocking.
+ */
+ if( tcgetattr(STDIN_FILENO, &term) < 0 ) {
+ perror("tcgetattr");
+ exit(1);
+ }
+ old_lflag = term.c_lflag;
+ old_vtime = term.c_cc[VTIME];
+ term.c_lflag &= ~ICANON;
+ term.c_cc[VTIME] = 1;
+ /* COMMENT LINE BELOW - see above */
+ if( tcsetattr(STDIN_FILENO, TCSANOW, &term) < 0 ) {
+ perror("tcsetattr");
+ exit(1);
+ }
+
+ rl_add_defun("change-prompt", change_prompt, CTRL('t'));
+ rl_callback_handler_install(get_prompt(), process_line);
+
+ while(1) {
+ FD_ZERO(&fds);
+ FD_SET(fileno(stdin), &fds);
+
+ if( select(FD_SETSIZE, &fds, NULL, NULL, NULL) < 0) {
+ perror("select");
+ exit(1);
+ }
+
+ if( FD_ISSET(fileno(stdin), &fds) ) {
+ rl_callback_read_char();
+ }
+ }
+}
+
+void
+process_line(char *line)
+{
+ if( line == NULL ) {
+ fprintf(stderr, "\n", line);
+
+ /* reset the old terminal setting before exiting */
+ term.c_lflag = old_lflag;
+ term.c_cc[VTIME] = old_vtime;
+ if( tcsetattr(STDIN_FILENO, TCSANOW, &term) < 0 ) {
+ perror("tcsetattr");
+ exit(1);
+ }
+ exit(0);
+ }
+
+ if( strcmp(line, "sleep") == 0 ) {
+ sleep(3);
+ } else {
+ fprintf(stderr, "|%s|\n", line);
+ }
+}
+
+int
+change_prompt(void)
+{
+ /* toggle the prompt variable */
+ prompt = !prompt;
+
+ /* save away the current contents of the line */
+ strcpy(line_buf, rl_line_buffer);
+
+ /* install a new handler which will change the prompt and erase the current line */
+ rl_callback_handler_install(get_prompt(), process_line);
+
+ /* insert the old text on the new line */
+ rl_insert_text(line_buf);
+
+ /* redraw the current line - this is an undocumented function. It invokes the
+ * redraw-current-line command.
+ */
+ rl_refresh_line(0, 0);
+}
+
+char *
+get_prompt(void)
+{
+ /* The prompts can even be different lengths! */
+ sprintf(prompt_buf, "%s",
+ prompt ? "Hit ctrl-t to toggle prompt> " : "Pretty cool huh?> ");
+ return prompt_buf;
+}
diff --git a/lib/readline/examples/fileman.c b/lib/readline/examples/fileman.c
index 0702a5b..dc29a40 100644
--- a/lib/readline/examples/fileman.c
+++ b/lib/readline/examples/fileman.c
@@ -1,22 +1,22 @@
/* fileman.c -- A tiny application which demonstrates how to use the
GNU Readline library. This application interactively allows users
to manipulate files and their modes. */
-/*
- * Remove the next line if you're compiling this against an installed
- * libreadline.a
- */
-#define READLINE_LIBRARY
#ifdef HAVE_CONFIG_H
-#include <config.h>
+# include <config.h>
#endif
#include <sys/types.h>
#ifdef HAVE_SYS_FILE_H
-#include <sys/file.h>
+# include <sys/file.h>
#endif
#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
@@ -26,6 +26,10 @@
# include <strings.h>
#endif /* !HAVE_STRING_H */
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
#ifdef READLINE_LIBRARY
# include "readline.h"
# include "history.h"
@@ -34,7 +38,6 @@
# include <readline/history.h>
#endif
-extern char *getwd ();
extern char *xmalloc ();
/* The names of functions that actually do the manipulation. */
@@ -300,7 +303,12 @@ com_view (arg)
if (!valid_argument ("view", arg))
return 1;
+#if defined (__MSDOS__)
+ /* more.com doesn't grok slashes in pathnames */
+ sprintf (syscom, "less %s", arg);
+#else
sprintf (syscom, "more %s", arg);
+#endif
return (system (syscom));
}
@@ -406,7 +414,7 @@ com_pwd (ignore)
{
char dir[1024], *s;
- s = getwd (dir);
+ s = getcwd (dir, sizeof(dir) - 1);
if (s == 0)
{
printf ("Error getting pwd: %s\n", dir);
diff --git a/lib/readline/examples/rl.c b/lib/readline/examples/rl.c
index 17a6343..2d1d17e 100644
--- a/lib/readline/examples/rl.c
+++ b/lib/readline/examples/rl.c
@@ -2,15 +2,9 @@
* rl - command-line interface to read a line from the standard input
* (or another fd) using readline.
*
- * usage: rl [-p prompt] [-u unit] [-d default]
+ * usage: rl [-p prompt] [-u unit] [-d default] [-n nchars]
*/
-/*
- * Remove the next line if you're compiling this against an installed
- * libreadline.a
- */
-#define READLINE_LIBRARY
-
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
@@ -18,8 +12,14 @@
#include <stdio.h>
#include <sys/types.h>
#include "posixstat.h"
-#include "readline.h"
-#include "history.h"
+
+#if defined (READLINE_LIBRARY)
+# include "readline.h"
+# include "history.h"
+#else
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif
extern int optind;
extern char *optarg;
@@ -40,22 +40,24 @@ set_deftext ()
deftext = (char *)NULL;
rl_startup_hook = (Function *)NULL;
}
+ return 0;
}
static void
usage()
{
- fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default]\n",
+ fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default] [-n nchars]\n",
progname, progname);
}
+int
main (argc, argv)
int argc;
char **argv;
{
char *temp, *prompt;
struct stat sb;
- int opt, fd;
+ int opt, fd, nch;
FILE *ifp;
progname = strrchr(argv[0], '/');
@@ -66,10 +68,10 @@ main (argc, argv)
/* defaults */
prompt = "readline$ ";
- fd = 0;
+ fd = nch = 0;
deftext = (char *)0;
- while ((opt = getopt(argc, argv, "p:u:d:")) != EOF)
+ while ((opt = getopt(argc, argv, "p:u:d:n:")) != EOF)
{
switch (opt)
{
@@ -87,6 +89,14 @@ main (argc, argv)
case 'd':
deftext = optarg;
break;
+ case 'n':
+ nch = atoi(optarg);
+ if (nch < 0)
+ {
+ fprintf (stderr, "%s: bad value for -n: `%s'\n", progname, optarg);
+ exit (2);
+ }
+ break;
default:
usage ();
exit (2);
@@ -107,6 +117,9 @@ main (argc, argv)
if (deftext && *deftext)
rl_startup_hook = set_deftext;
+ if (nch > 0)
+ rl_num_chars_to_read = nch;
+
temp = readline (prompt);
/* Test for EOF. */
diff --git a/lib/readline/examples/rltest.c b/lib/readline/examples/rltest.c
index 453f8ec..6250f90 100644
--- a/lib/readline/examples/rltest.c
+++ b/lib/readline/examples/rltest.c
@@ -4,20 +4,20 @@
/* */
/* **************************************************************** */
-/*
- * Remove the next line if you're compiling this against an installed
- * libreadline.a
- */
-#define READLINE_LIBRARY
-
#if defined (HAVE_CONFIG_H)
#include <config.h>
#endif
#include <stdio.h>
#include <sys/types.h>
-#include "readline.h"
-#include "history.h"
+
+#ifdef READLINE_LIBRARY
+# include "readline.h"
+# include "history.h"
+#else
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif
extern HIST_ENTRY **history_list ();
diff --git a/lib/readline/funmap.c b/lib/readline/funmap.c
index f6b8628..1f7ba87 100644
--- a/lib/readline/funmap.c
+++ b/lib/readline/funmap.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,15 +18,13 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
-extern char *xmalloc (), *xrealloc ();
-
#if !defined (BUFSIZ)
#include <stdio.h>
#endif /* BUFSIZ */
@@ -40,6 +38,14 @@ extern char *xmalloc (), *xrealloc ();
#include "rlconf.h"
#include "readline.h"
+#include "xmalloc.h"
+
+#ifdef __STDC__
+typedef int QSFUNC (const void *, const void *);
+#else
+typedef int QSFUNC ();
+#endif
+
extern int _rl_qsort_string_compare ();
FUNMAP **funmap;
@@ -240,7 +246,7 @@ rl_funmap_names ()
result[result_index + 1] = (char *)NULL;
}
- qsort (result, result_index, sizeof (char *), _rl_qsort_string_compare);
+ qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
return (result);
}
diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c
index 392e6d3..78da3e5 100644
--- a/lib/readline/histexpand.c
+++ b/lib/readline/histexpand.c
@@ -7,7 +7,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
@@ -50,6 +50,9 @@
#include "history.h"
#include "histlib.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
#define HISTORY_WORD_DELIMITERS " \t\n;&()|<>"
#define HISTORY_QUOTE_CHARACTERS "\"'`"
@@ -60,15 +63,10 @@ static char *subst_rhs;
static int subst_lhs_len;
static int subst_rhs_len;
-static char *get_history_word_specifier ();
-static char *history_find_word ();
-
-extern int history_offset;
-
-extern char *single_quote ();
-static char *quote_breaks ();
+static char *get_history_word_specifier __P((char *, char *, int *));
+static char *history_find_word __P((char *, int));
-extern char *xmalloc (), *xrealloc ();
+static char *quote_breaks __P((char *));
/* Variables exported by this file. */
/* The character that represents the start of a history expansion
diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c
index 3325b7f..b908e22 100644
--- a/lib/readline/histfile.c
+++ b/lib/readline/histfile.c
@@ -7,7 +7,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* The goal is to make the implementation transparent, so that you
don't have to know what data types are used, just what functions
@@ -35,7 +35,7 @@
#ifndef _MINIX
# include <sys/file.h>
#endif
-#include <sys/stat.h>
+#include "posixstat.h"
#include <fcntl.h>
#if defined (HAVE_STDLIB_H)
@@ -54,15 +54,19 @@
# include <strings.h>
#endif /* !HAVE_STRING_H */
-#if defined (__EMX__)
+
+/* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment
+ on win 95/98/nt), we want to open files with O_BINARY mode so that there
+ is no \n -> \r\n conversion performed. On other systems, we don't want to
+ mess around with O_BINARY at all, so we ensure that it's defined to 0. */
+#if defined (__EMX__) || defined (__CYGWIN__)
# ifndef O_BINARY
# define O_BINARY 0
# endif
-#else /* !__EMX__ */
- /* If we're not compiling for __EMX__, we don't want this at all. Ever. */
+#else /* !__EMX__ && !__CYGWIN__ */
# undef O_BINARY
# define O_BINARY 0
-#endif /* !__EMX__ */
+#endif /* !__EMX__ && !__CYGWIN__ */
#include <errno.h>
#if !defined (errno)
@@ -72,10 +76,8 @@ extern int errno;
#include "history.h"
#include "histlib.h"
-/* Functions imported from shell.c */
-extern char *get_env_value ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "rlshell.h"
+#include "xmalloc.h"
/* Return the string that should be used in the place of this
filename. This only matters when you don't specify the
@@ -105,7 +107,11 @@ history_filename (filename)
return_val = xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
strcpy (return_val, home);
return_val[home_len] = '/';
+#if defined (__MSDOS__)
+ strcpy (return_val + home_len + 1, "_history");
+#else
strcpy (return_val + home_len + 1, ".history");
+#endif
return (return_val);
}
@@ -132,7 +138,7 @@ read_history_range (filename, from, to)
{
register int line_start, line_end;
char *input, *buffer;
- int file, current_line;
+ int file, current_line, chars_read;
struct stat finfo;
size_t file_size;
@@ -155,11 +161,9 @@ read_history_range (filename, from, to)
}
buffer = xmalloc (file_size + 1);
-#if 0
- if (read (file, buffer, file_size) != file_size)
-#else
- if (read (file, buffer, file_size) < 0)
-#endif
+
+ chars_read = read (file, buffer, file_size);
+ if (chars_read < 0)
{
error_and_exit:
if (file >= 0)
@@ -175,15 +179,15 @@ read_history_range (filename, from, to)
/* Set TO to larger than end of file if negative. */
if (to < 0)
- to = file_size;
+ to = chars_read;
/* Start at beginning of file, work to end. */
line_start = line_end = current_line = 0;
/* Skip lines until we are at FROM. */
- while (line_start < file_size && current_line < from)
+ while (line_start < chars_read && current_line < from)
{
- for (line_end = line_start; line_end < file_size; line_end++)
+ for (line_end = line_start; line_end < chars_read; line_end++)
if (buffer[line_end] == '\n')
{
current_line++;
@@ -194,7 +198,7 @@ read_history_range (filename, from, to)
}
/* If there are lines left to gobble, then gobble them now. */
- for (line_end = line_start; line_end < file_size; line_end++)
+ for (line_end = line_start; line_end < chars_read; line_end++)
if (buffer[line_end] == '\n')
{
buffer[line_end] = '\0';
@@ -236,6 +240,10 @@ history_truncate_file (fname, lines)
if (file == -1 || fstat (file, &finfo) == -1)
goto truncate_exit;
+ /* Don't try to truncate non-regular files. */
+ if (S_ISREG(finfo.st_mode) == 0)
+ goto truncate_exit;
+
file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */
@@ -279,11 +287,11 @@ history_truncate_file (fname, lines)
truncate to. */
if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
{
- write (file, buffer + i, file_size - i);
+ write (file, buffer + i, chars_read - i);
#if defined (__BEOS__)
/* BeOS ignores O_TRUNC. */
- ftruncate (file, file_size - i);
+ ftruncate (file, chars_read - i);
#endif
close (file);
diff --git a/lib/readline/histlib.h b/lib/readline/histlib.h
index 422cf59..88a34d1 100644
--- a/lib/readline/histlib.h
+++ b/lib/readline/histlib.h
@@ -6,7 +6,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_HISTLIB_H_)
#define _HISTLIB_H_
@@ -31,8 +31,11 @@ typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif /* _FUNCTION_DEF */
+#if !defined (STREQ)
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
-#define STREQN(a, b, n) (((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
+#define STREQN(a, b, n) (((n) == 0) ? (1) \
+ : ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
+#endif
#ifndef savestring
# ifndef strcpy
@@ -79,4 +82,7 @@ extern char *strchr ();
#define HISTORY_APPEND 0
#define HISTORY_OVERWRITE 1
+/* Some variable definitions shared across history source files. */
+extern int history_offset;
+
#endif /* !_HISTLIB_H_ */
diff --git a/lib/readline/history.c b/lib/readline/history.c
index d56ffac..400f18b 100644
--- a/lib/readline/history.c
+++ b/lib/readline/history.c
@@ -7,7 +7,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* The goal is to make the implementation transparent, so that you
don't have to know what data types are used, just what functions
@@ -53,7 +53,7 @@
#include "history.h"
#include "histlib.h"
-extern char *xmalloc (), *xrealloc ();
+#include "xmalloc.h"
/* The number of slots to increase the_history by. */
#define DEFAULT_HISTORY_GROW_SIZE 50
diff --git a/lib/readline/history.h b/lib/readline/history.h
index 8ecce72..5210deb 100644
--- a/lib/readline/history.h
+++ b/lib/readline/history.h
@@ -6,7 +6,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _HISTORY_H_
#define _HISTORY_H_
@@ -119,7 +119,7 @@ extern int where_history __P((void));
/* Return the history entry at the current position, as determined by
history_offset. If there is no entry there, return a NULL pointer. */
-HIST_ENTRY *current_history __P((void));
+extern HIST_ENTRY *current_history __P((void));
/* Return the history entry which is logically at OFFSET in the history
array. OFFSET is relative to history_base. */
@@ -132,7 +132,7 @@ extern int history_total_bytes __P((void));
/* Moving around the history list. */
/* Set the position in the history list to POS. */
-int history_set_pos __P((int));
+extern int history_set_pos __P((int));
/* Back up history_offset to the previous history entry, and return
a pointer to that entry. If there is no previous entry, return
@@ -187,7 +187,7 @@ extern int write_history __P((char *));
/* Append NELEMENT entries to FILENAME. The entries appended are from
the end of the list minus NELEMENTs up to the end of the list. */
-int append_history __P((int, char *));
+extern int append_history __P((int, char *));
/* Truncate the history file, leaving only the last NLINES lines. */
extern int history_truncate_file __P((char *, int));
diff --git a/lib/readline/histsearch.c b/lib/readline/histsearch.c
index 7e98e95..8d153b6 100644
--- a/lib/readline/histsearch.c
+++ b/lib/readline/histsearch.c
@@ -7,7 +7,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
@@ -47,9 +47,6 @@
#include "history.h"
#include "histlib.h"
-/* Variables imported from other history library files. */
-extern int history_offset;
-
/* The list of alternate characters that can delimit a history search
string. */
char *history_search_delimiter_chars = (char *)NULL;
diff --git a/lib/readline/input.c b/lib/readline/input.c
index 3b48483..64a55c6 100644
--- a/lib/readline/input.c
+++ b/lib/readline/input.c
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -67,39 +67,15 @@ extern int errno;
/* Some standard library routines. */
#include "readline.h"
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
/* What kind of non-blocking I/O do we have? */
#if !defined (O_NDELAY) && defined (O_NONBLOCK)
# define O_NDELAY O_NONBLOCK /* Posix style */
#endif
-/* Functions imported from other files in the library. */
-extern char *xmalloc (), *xrealloc ();
-
-/* Variables and functions from macro.c. */
-extern void _rl_add_macro_char ();
-extern void _rl_with_macro_input ();
-extern int _rl_next_macro_key ();
-extern int _rl_defining_kbd_macro;
-
-#if defined (VI_MODE)
-extern void _rl_vi_set_last ();
-extern int _rl_vi_textmod_command ();
-#endif /* VI_MODE */
-
-extern FILE *rl_instream, *rl_outstream;
-extern Function *rl_last_func;
-extern int rl_key_sequence_length;
-extern int rl_pending_input;
-extern int rl_editing_mode;
-
-extern Keymap _rl_keymap;
-
-extern int _rl_convert_meta_chars_to_ascii;
-
-#if defined (__GO32__)
-# include <pc.h>
-#endif /* __GO32__ */
-
/* Non-null means it is a pointer to a function to run while waiting for
character input. */
Function *rl_event_hook = (Function *)NULL;
@@ -176,17 +152,6 @@ rl_unget_char (key)
static void
rl_gather_tyi ()
{
-#if defined (__GO32__)
- char input;
-
- if (isatty (0) && kbhit () && ibuffer_space ())
- {
- int i;
- i = (*rl_getc_function) (rl_instream);
- rl_stuff_char (i);
- }
-#else /* !__GO32__ */
-
int tty;
register int tem, result;
int chars_avail;
@@ -255,7 +220,6 @@ rl_gather_tyi ()
if (chars_avail)
rl_stuff_char (input);
}
-#endif /* !__GO32__ */
}
/* Is there input available to be read on the readline input file
@@ -394,14 +358,9 @@ int
rl_getc (stream)
FILE *stream;
{
- int result, flags;
+ int result;
unsigned char c;
-#if defined (__GO32__)
- if (isatty (0))
- return (getkey () & 0x7F);
-#endif /* __GO32__ */
-
while (1)
{
result = read (fileno (stream), &c, sizeof (unsigned char));
@@ -420,40 +379,31 @@ rl_getc (stream)
#endif
#if defined (EWOULDBLOCK)
- if (errno == EWOULDBLOCK)
+# define X_EWOULDBLOCK EWOULDBLOCK
+#else
+# define X_EWOULDBLOCK -99
+#endif
+
+#if defined (EAGAIN)
+# define X_EAGAIN EAGAIN
+#else
+# define X_EAGAIN -99
+#endif
+
+ if (errno == X_EWOULDBLOCK || errno == X_EAGAIN)
{
- if ((flags = fcntl (fileno (stream), F_GETFL, 0)) < 0)
+ if (unset_nodelay_mode (fileno (stream)) < 0)
return (EOF);
- if (flags & O_NDELAY)
- {
- flags &= ~O_NDELAY;
- fcntl (fileno (stream), F_SETFL, flags);
- continue;
- }
continue;
}
-#endif /* EWOULDBLOCK */
-#if defined (_POSIX_VERSION) && defined (EAGAIN) && defined (O_NONBLOCK)
- if (errno == EAGAIN)
- {
- if ((flags = fcntl (fileno (stream), F_GETFL, 0)) < 0)
- return (EOF);
- if (flags & O_NONBLOCK)
- {
- flags &= ~O_NONBLOCK;
- fcntl (fileno (stream), F_SETFL, flags);
- continue;
- }
- }
-#endif /* _POSIX_VERSION && EAGAIN && O_NONBLOCK */
+#undef X_EWOULDBLOCK
+#undef X_EAGAIN
-#if !defined (__GO32__)
/* If the error that we received was SIGINT, then try again,
this is simply an interrupted system call to read ().
Otherwise, some error ocurred, also signifying EOF. */
if (errno != EINTR)
return (EOF);
-#endif /* !__GO32__ */
}
}
diff --git a/lib/readline/isearch.c b/lib/readline/isearch.c
index 67279e1..952c10d 100644
--- a/lib/readline/isearch.c
+++ b/lib/readline/isearch.c
@@ -12,7 +12,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -23,7 +23,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -48,24 +48,17 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "xmalloc.h"
+
/* Variables exported to other files in the readline library. */
unsigned char *_rl_isearch_terminators = (unsigned char *)NULL;
/* Variables imported from other files in the readline library. */
-extern Keymap _rl_keymap;
extern HIST_ENTRY *saved_line_for_history;
-extern int rl_line_buffer_len;
-extern int rl_point, rl_end;
-extern char *rl_line_buffer;
-
-extern int rl_execute_next ();
-extern void rl_extend_line_buffer ();
-
-extern int _rl_input_available ();
-
-extern char *xmalloc (), *xrealloc ();
-static int rl_search_history ();
+/* Forward declarations */
+static int rl_search_history __P((int, int));
/* Last line found by the current incremental search, so we don't `find'
identical lines many times in a row. */
diff --git a/lib/readline/keymaps.c b/lib/readline/keymaps.c
index c73666b..8fb7de3 100644
--- a/lib/readline/keymaps.c
+++ b/lib/readline/keymaps.c
@@ -7,7 +7,7 @@
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 1, or (at your option) any
+ Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -30,18 +30,18 @@
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
+#include <stdio.h> /* for FILE * definition for readline.h */
+
+#include "readline.h"
#include "rlconf.h"
-#include "keymaps.h"
+
#include "emacs_keymap.c"
#if defined (VI_MODE)
#include "vi_keymap.c"
#endif
-extern int rl_do_lowercase_version ();
-extern int rl_rubout (), rl_insert ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "xmalloc.h"
/* **************************************************************** */
/* */
diff --git a/lib/readline/keymaps.h b/lib/readline/keymaps.h
index 5dff46f..3a504fb 100644
--- a/lib/readline/keymaps.h
+++ b/lib/readline/keymaps.h
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,11 +18,15 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _KEYMAPS_H_
#define _KEYMAPS_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if defined (READLINE_LIBRARY)
# include "rlstdc.h"
# include "chardefs.h"
@@ -97,4 +101,8 @@ extern Keymap rl_get_keymap __P((void));
/* Set the current keymap to MAP. */
extern void rl_set_keymap __P((Keymap));
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _KEYMAPS_H_ */
diff --git a/lib/readline/kill.c b/lib/readline/kill.c
index 0b4714f..c3241bd 100644
--- a/lib/readline/kill.c
+++ b/lib/readline/kill.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -46,17 +46,8 @@
#include "readline.h"
#include "history.h"
-extern int _rl_last_command_was_kill;
-extern int rl_editing_mode;
-extern int rl_explicit_arg;
-extern Function *rl_last_func;
-
-extern void _rl_init_argument ();
-extern int _rl_set_mark_at_pos ();
-extern void _rl_fix_point ();
-extern void _rl_abort_internal ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "rlprivate.h"
+#include "xmalloc.h"
/* **************************************************************** */
/* */
@@ -385,10 +376,12 @@ int
rl_kill_region (count, ignore)
int count, ignore;
{
- int r;
+ int r, npoint;
+ npoint = (rl_point < rl_mark) ? rl_point : rl_mark;
r = region_kill_internal (1);
_rl_fix_point (1);
+ rl_point = npoint;
return r;
}
@@ -503,7 +496,9 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
{
register HIST_ENTRY *entry;
char *arg;
- int i;
+ int i, pos;
+
+ pos = where_history ();
if (history_skip)
{
@@ -512,16 +507,10 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
}
entry = previous_history ();
- if (entry)
- {
- if (history_skip)
- {
- for (i = 0; i < history_skip; i++)
- next_history ();
- }
- next_history ();
- }
- else
+
+ history_set_pos (pos);
+
+ if (entry == 0)
{
ding ();
return -1;
diff --git a/lib/readline/macro.c b/lib/readline/macro.c
index f3c442b..5a44852 100644
--- a/lib/readline/macro.c
+++ b/lib/readline/macro.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -46,19 +46,10 @@
#include "readline.h"
#include "history.h"
-#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
-
-/* Forward definitions. */
-void _rl_push_executing_macro (), _rl_pop_executing_macro ();
-void _rl_add_macro_char ();
-
-/* Extern declarations. */
-extern int rl_explicit_arg;
-extern int rl_key_sequence_length;
+#include "rlprivate.h"
+#include "xmalloc.h"
-extern void _rl_abort_internal ();
-
-extern char *xmalloc (), *xrealloc ();
+#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
/* **************************************************************** */
/* */
diff --git a/lib/readline/nls.c b/lib/readline/nls.c
index f2d413d..67bed8a 100644
--- a/lib/readline/nls.c
+++ b/lib/readline/nls.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -27,6 +27,8 @@
#include <sys/types.h>
+#include <stdio.h>
+
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
@@ -44,13 +46,9 @@
#include <ctype.h>
#include "rldefs.h"
-
-extern int _rl_convert_meta_chars_to_ascii;
-extern int _rl_output_meta_chars;
-extern int _rl_meta_flag;
-
-/* Functions imported from shell.c */
-extern char *get_env_value ();
+#include "readline.h"
+#include "rlshell.h"
+#include "rlprivate.h"
#if !defined (HAVE_SETLOCALE)
/* A list of legal values for the LANG or LC_CTYPE environment variables.
@@ -70,12 +68,11 @@ static char *legal_lang_values[] =
"iso88599",
"iso885910",
"koi8r",
- "koi8-r",
0
};
-static char *normalize_codeset ();
-static char *find_codeset ();
+static char *normalize_codeset __P((char *));
+static char *find_codeset __P((char *, size_t *));
#endif /* !HAVE_SETLOCALE */
/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value
diff --git a/lib/readline/parens.c b/lib/readline/parens.c
index a500c0a..b6de529 100644
--- a/lib/readline/parens.c
+++ b/lib/readline/parens.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,23 +18,11 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#include "rlconf.h"
-#if !defined (PAREN_MATCHING)
-extern int rl_insert ();
-
-int
-rl_insert_close (count, invoking_key)
- int count, invoking_key;
-{
- return (rl_insert (count, invoking_key));
-}
-
-#else /* PAREN_MATCHING */
-
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
@@ -64,8 +52,9 @@ extern char *strchr (), *strrchr ();
#endif /* !strchr && !__STDC__ */
#include "readline.h"
+#include "rlprivate.h"
-extern int rl_explicit_arg;
+static int find_matching_open __P((char *, int, int));
/* Non-zero means try to blink the matching open parenthesis when the
close parenthesis is inserted. */
@@ -75,7 +64,25 @@ int rl_blink_matching_paren = 1;
int rl_blink_matching_paren = 0;
#endif /* !HAVE_SELECT */
-static int find_matching_open ();
+/* Change emacs_standard_keymap to have bindings for paren matching when
+ ON_OR_OFF is 1, change them back to self_insert when ON_OR_OFF == 0. */
+void
+_rl_enable_paren_matching (on_or_off)
+ int on_or_off;
+{
+ if (on_or_off)
+ { /* ([{ */
+ rl_bind_key_in_map (')', rl_insert_close, emacs_standard_keymap);
+ rl_bind_key_in_map (']', rl_insert_close, emacs_standard_keymap);
+ rl_bind_key_in_map ('}', rl_insert_close, emacs_standard_keymap);
+ }
+ else
+ { /* ([{ */
+ rl_bind_key_in_map (')', rl_insert, emacs_standard_keymap);
+ rl_bind_key_in_map (']', rl_insert, emacs_standard_keymap);
+ rl_bind_key_in_map ('}', rl_insert, emacs_standard_keymap);
+ }
+}
int
rl_insert_close (count, invoking_key)
@@ -152,5 +159,3 @@ find_matching_open (string, from, closer)
}
return (i);
}
-
-#endif /* PAREN_MATCHING */
diff --git a/lib/readline/posixdir.h b/lib/readline/posixdir.h
index 7480a93..98ced75 100644
--- a/lib/readline/posixdir.h
+++ b/lib/readline/posixdir.h
@@ -6,7 +6,7 @@
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 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
diff --git a/lib/readline/posixjmp.h b/lib/readline/posixjmp.h
index 1347cc0..b52aa00 100644
--- a/lib/readline/posixjmp.h
+++ b/lib/readline/posixjmp.h
@@ -1,5 +1,23 @@
/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
+/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
#ifndef _POSIXJMP_H_
#define _POSIXJMP_H_
diff --git a/lib/readline/posixstat.h b/lib/readline/posixstat.h
index bfce8c0..c93b528 100644
--- a/lib/readline/posixstat.h
+++ b/lib/readline/posixstat.h
@@ -7,7 +7,7 @@
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 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* This file should be included instead of <sys/stat.h>.
It relies on the local sys/stat.h to work though. */
diff --git a/lib/readline/readline.c b/lib/readline/readline.c
index 622811f..2c6aef6 100644
--- a/lib/readline/readline.c
+++ b/lib/readline/readline.c
@@ -8,7 +8,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -47,7 +47,6 @@
# include <locale.h>
#endif
-#include <signal.h>
#include <stdio.h>
#include "posixjmp.h"
@@ -63,117 +62,27 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "rlshell.h"
+#include "xmalloc.h"
+
#ifndef RL_LIBRARY_VERSION
-# define RL_LIBRARY_VERSION "4.0"
+# define RL_LIBRARY_VERSION "4.1"
#endif
/* Evaluates its arguments multiple times. */
#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
-/* 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. */
-
-/* Variables and functions imported from terminal.c */
-extern int _rl_init_terminal_io ();
-extern void _rl_enable_meta_key ();
-#ifdef _MINIX
-extern void _rl_output_character_function ();
-#else
-extern int _rl_output_character_function ();
-#endif
-
-extern int _rl_enable_meta;
-extern int _rl_term_autowrap;
-extern int screenwidth, screenheight, screenchars;
-
-/* Variables and functions imported from rltty.c. */
-extern void rl_prep_terminal (), rl_deprep_terminal ();
-extern void rltty_set_default_bindings ();
-
-/* Functions imported from util.c. */
-extern void _rl_abort_internal ();
-extern void rl_extend_line_buffer ();
-extern int alphabetic ();
-
-/* Functions imported from bind.c. */
-extern void _rl_bind_if_unbound ();
-
-/* Functions imported from input.c. */
-extern int _rl_any_typein ();
-extern void _rl_insert_typein ();
-extern int rl_read_key ();
-
-/* Functions imported from nls.c */
-extern int _rl_init_eightbit ();
-
-/* Functions imported from shell.c */
-extern char *get_env_value ();
-
-/* External redisplay functions and variables from display.c */
-extern void _rl_move_vert ();
-extern void _rl_update_final ();
-extern void _rl_clear_to_eol ();
-extern void _rl_clear_screen ();
-extern void _rl_erase_entire_line ();
-
-extern void _rl_erase_at_end_of_line ();
-extern void _rl_move_cursor_relative ();
-
-extern int _rl_vis_botlin;
-extern int _rl_last_c_pos;
-extern int _rl_horizontal_scroll_mode;
-extern int rl_display_fixed;
-extern int _rl_suppress_redisplay;
-extern char *rl_display_prompt;
-
-/* Variables imported from complete.c. */
-extern char *rl_completer_word_break_characters;
-extern char *rl_basic_word_break_characters;
-extern int rl_completion_query_items;
-extern int rl_complete_with_tilde_expansion;
-
-/* Variables and functions from macro.c. */
-extern void _rl_add_macro_char ();
-extern void _rl_with_macro_input ();
-extern int _rl_next_macro_key ();
-extern int _rl_defining_kbd_macro;
-
-#if defined (VI_MODE)
-/* Functions imported from vi_mode.c. */
-extern void _rl_vi_set_last ();
-extern void _rl_vi_reset_last ();
-extern void _rl_vi_done_inserting ();
-extern int _rl_vi_textmod_command ();
-extern void _rl_vi_initialize_line ();
-#endif /* VI_MODE */
-
-extern UNDO_LIST *rl_undo_list;
-extern int _rl_doing_an_undo;
-
/* Forward declarations used in this file. */
-void _rl_free_history_entry ();
+void _rl_free_history_entry __P((HIST_ENTRY *));
-int _rl_dispatch ();
-int _rl_init_argument ();
+static char *readline_internal __P((void));
+static void readline_initialize_everything __P((void));
+static void start_using_history __P((void));
+static void bind_arrow_keys __P((void));
+static int rl_change_case __P((int, int));
-static char *readline_internal ();
-static void readline_initialize_everything ();
-static void start_using_history ();
-static void bind_arrow_keys ();
-
-#if !defined (__GO32__)
-static void readline_default_bindings ();
-#endif /* !__GO32__ */
-
-#if defined (__GO32__)
-# include <go32.h>
-# include <pc.h>
-# undef HANDLE_SIGNALS
-#endif /* __GO32__ */
-
-extern char *xmalloc (), *xrealloc ();
+static void readline_default_bindings __P((void));
/* **************************************************************** */
/* */
@@ -183,6 +92,8 @@ extern char *xmalloc (), *xrealloc ();
char *rl_library_version = RL_LIBRARY_VERSION;
+int rl_gnu_readline_p = 1;
+
/* A pointer to the keymap that is currently in use.
By default, it is the standard emacs keymap. */
Keymap _rl_keymap = emacs_standard_keymap;
@@ -245,6 +156,10 @@ int readline_echoing_p = 1;
char *rl_prompt;
int rl_visible_prompt_length = 0;
+/* Set to non-zero by calling application if it has already printed rl_prompt
+ and does not want readline to do it the first time. */
+int rl_already_prompted = 0;
+
/* The number of characters read in order to type this complete command. */
int rl_key_sequence_length = 0;
@@ -290,6 +205,10 @@ Keymap rl_executing_keymap;
/* Non-zero means to erase entire line, including prompt, on empty input lines. */
int rl_erase_empty_line = 0;
+/* Non-zero means to read only this many characters rather than up to a
+ character bound to accept-line. */
+int rl_num_chars_to_read;
+
/* Line buffer and maintenence. */
char *rl_line_buffer = (char *)NULL;
int rl_line_buffer_len = 0;
@@ -369,6 +288,8 @@ readline (prompt)
STATIC_CALLBACK void
readline_internal_setup ()
{
+ char *nprompt;
+
_rl_in_stream = rl_instream;
_rl_out_stream = rl_outstream;
@@ -377,15 +298,20 @@ readline_internal_setup ()
if (readline_echoing_p == 0)
{
- if (rl_prompt)
+ if (rl_prompt && rl_already_prompted == 0)
{
- fprintf (_rl_out_stream, "%s", rl_prompt);
+ nprompt = _rl_strip_prompt (rl_prompt);
+ fprintf (_rl_out_stream, "%s", nprompt);
fflush (_rl_out_stream);
+ free (nprompt);
}
}
else
{
- rl_on_new_line ();
+ if (rl_prompt && rl_already_prompted)
+ rl_on_new_line_with_prompt ();
+ else
+ rl_on_new_line ();
(*rl_redisplay_function) ();
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
@@ -477,7 +403,7 @@ readline_internal_charloop ()
}
lastc = c;
- _rl_dispatch (c, _rl_keymap);
+ _rl_dispatch ((unsigned char)c, _rl_keymap);
/* If there was no change in _rl_last_command_was_kill, then no kill
has taken place. Note that if input is pending we are reading
@@ -492,6 +418,12 @@ readline_internal_charloop ()
rl_vi_check ();
#endif /* VI_MODE */
+ if (rl_num_chars_to_read && rl_end >= rl_num_chars_to_read)
+ {
+ (*rl_redisplay_function) ();
+ rl_newline (1, '\n');
+ }
+
if (rl_done == 0)
(*rl_redisplay_function) ();
@@ -689,6 +621,7 @@ rl_initialize ()
return 0;
}
+#if 0
#if defined (__EMX__)
static void
_emx_build_environ ()
@@ -712,15 +645,18 @@ _emx_build_environ ()
*tp = 0;
}
#endif /* __EMX__ */
+#endif
/* Initialize the entire state of the world. */
static void
readline_initialize_everything ()
{
+#if 0
#if defined (__EMX__)
if (environ == 0)
_emx_build_environ ();
#endif
+#endif
/* Find out if we are running in Emacs. */
running_in_emacs = get_env_value ("EMACS") != (char *)0;
@@ -745,10 +681,8 @@ readline_initialize_everything ()
/* Initialize the terminal interface. */
_rl_init_terminal_io ((char *)NULL);
-#if !defined (__GO32__)
/* Bind tty characters to readline functions. */
readline_default_bindings ();
-#endif /* !__GO32__ */
/* Initialize the function names. */
rl_initialize_funmap ();
@@ -797,6 +731,17 @@ bind_arrow_keys_internal ()
{
Function *f;
+#if defined (__MSDOS__)
+ f = rl_function_of_keyseq ("\033[0A", _rl_keymap, (int *)NULL);
+ if (!f || f == rl_do_lowercase_version)
+ {
+ _rl_bind_if_unbound ("\033[0A", rl_get_previous_history);
+ _rl_bind_if_unbound ("\033[0B", rl_backward);
+ _rl_bind_if_unbound ("\033[0C", rl_forward);
+ _rl_bind_if_unbound ("\033[0D", rl_get_next_history);
+ }
+#endif
+
f = rl_function_of_keyseq ("\033[A", _rl_keymap, (int *)NULL);
if (!f || f == rl_do_lowercase_version)
{
@@ -1121,6 +1066,10 @@ rl_forward (count, key)
else
rl_point = end;
}
+
+ if (rl_end < 0)
+ rl_end = 0;
+
return 0;
}
@@ -1255,35 +1204,14 @@ int
rl_refresh_line (ignore1, ignore2)
int ignore1, ignore2;
{
- int curr_line, nleft;
+ int curr_line;
- /* Find out whether or not there might be invisible characters in the
- editing buffer. */
- if (rl_display_prompt == rl_prompt)
- nleft = _rl_last_c_pos - screenwidth - rl_visible_prompt_length;
- else
- nleft = _rl_last_c_pos - screenwidth;
-
- if (nleft > 0)
- curr_line = 1 + nleft / screenwidth;
- else
- curr_line = 0;
+ curr_line = _rl_current_display_line ();
_rl_move_vert (curr_line);
_rl_move_cursor_relative (0, the_line); /* XXX is this right */
-#if defined (__GO32__)
- {
- int row, col, width, row_start;
-
- ScreenGetCursor (&row, &col);
- width = ScreenCols ();
- row_start = ScreenPrimary + (row * width);
- memset (row_start + col, 0, (width - col) * 2);
- }
-#else /* !__GO32__ */
_rl_clear_to_eol (0); /* arg of 0 means to not use spaces */
-#endif /* !__GO32__ */
rl_forced_update_display ();
rl_display_fixed = 1;
@@ -1421,7 +1349,14 @@ rl_quoted_insert (count, key)
{
int c;
+#if defined (HANDLE_SIGNALS)
+ _rl_disable_tty_signals ();
+#endif
c = rl_read_key ();
+#if defined (HANDLE_SIGNALS)
+ _rl_restore_tty_signals ();
+#endif
+
return (rl_insert (count, c));
}
@@ -1615,8 +1550,6 @@ rl_insert_comment (count, key)
#define DownCase 2
#define CapCase 3
-static int rl_change_case ();
-
/* Uppercase the word at point. */
int
rl_upcase_word (count, key)
diff --git a/lib/readline/readline.h b/lib/readline/readline.h
index dba1a0f..97c62fd 100644
--- a/lib/readline/readline.h
+++ b/lib/readline/readline.h
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_READLINE_H_)
#define _READLINE_H_
@@ -192,7 +192,7 @@ extern int rl_noninc_reverse_search __P((int, int));
extern int rl_noninc_forward_search_again __P((int, int));
extern int rl_noninc_reverse_search_again __P((int, int));
-/* Not available unless readline is compiled -DPAREN_MATCHING. */
+/* Bindable command used when inserting a matching close character. */
extern int rl_insert_close __P((int, int));
/* Not available unless READLINE_CALLBACKS is defined. */
@@ -331,11 +331,12 @@ extern int rl_modifying __P((int, int));
/* Functions for redisplay. */
extern void rl_redisplay __P((void));
extern int rl_on_new_line __P((void));
+extern int rl_on_new_line_with_prompt __P((void));
extern int rl_forced_update_display __P((void));
extern int rl_clear_message __P((void));
extern int rl_reset_line_state __P((void));
-#if defined (__STDC__) && defined (USE_VARARGS) && defined (PREFER_STDARG)
+#if (defined (__STDC__) || defined (__cplusplus)) && defined (USE_VARARGS) && defined (PREFER_STDARG)
extern int rl_message (const char *, ...);
#else
extern int rl_message ();
@@ -405,6 +406,9 @@ extern char *filename_completion_function __P((char *, int));
/* The version of this incarnation of the readline library. */
extern char *rl_library_version;
+/* True if this is real GNU readline. */
+extern int rl_gnu_readline_p;
+
/* The name of the calling program. You should initialize this to
whatever was in argv[0]. It is used when parsing conditionals. */
extern char *rl_readline_name;
@@ -468,6 +472,15 @@ extern Keymap rl_binding_keymap;
rl_newline. */
extern int rl_erase_empty_line;
+/* If non-zero, the application has already printed the prompt (rl_prompt)
+ before calling readline, so readline should not output it the first time
+ redisplay is done. */
+extern int rl_already_prompted;
+
+/* A non-zero value means to read only this many characters rather than
+ up to a character bound to accept-line. */
+extern int rl_num_chars_to_read;
+
/* Variables to control readline signal handling. */
/* If non-zero, readline will install its own signal handlers for
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
@@ -611,7 +624,7 @@ extern int rl_inhibit_completion;
#define MULT_MATCH 2
#if !defined (savestring)
-extern char *savestring (); /* XXX backwards compatibility */
+extern char *savestring __P((char *)); /* XXX backwards compatibility */
#endif
#ifdef __cplusplus
diff --git a/lib/readline/rlconf.h b/lib/readline/rlconf.h
index 1356fd8..d2ab704 100644
--- a/lib/readline/rlconf.h
+++ b/lib/readline/rlconf.h
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLCONF_H_)
#define _RLCONF_H_
@@ -30,10 +30,6 @@
/* Define this to get an indication of file type when listing completions. */
#define VISIBLE_STATS
-/* If defined, readline shows opening parens and braces when closing
- paren or brace entered. */
-/* #define PAREN_MATCHING */
-
/* This definition is needed by readline.c, rltty.c, and signals.c. */
/* If on, then readline handles signals in a way that doesn't screw. */
#define HANDLE_SIGNALS
diff --git a/lib/readline/rldefs.h b/lib/readline/rldefs.h
index d4aced4..e504d9b 100644
--- a/lib/readline/rldefs.h
+++ b/lib/readline/rldefs.h
@@ -10,7 +10,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -21,7 +21,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLDEFS_H_)
#define _RLDEFS_H_
@@ -122,7 +122,8 @@ extern char *xmalloc ();
#if !defined (STREQ)
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
-#define STREQN(a, b, n) (((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
+#define STREQN(a, b, n) (((n) == 0) ? (1) \
+ : ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
#endif
#if !defined (FREE)
diff --git a/lib/readline/rlprivate.h b/lib/readline/rlprivate.h
new file mode 100644
index 0000000..c05230e
--- /dev/null
+++ b/lib/readline/rlprivate.h
@@ -0,0 +1,271 @@
+/* rlprivate.h -- functions and variables global to the readline library,
+ but not intended for use by applications. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library, a library for
+ reading lines of text with interactive input and history editing.
+
+ The GNU Readline Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2, or
+ (at your option) any later version.
+
+ The GNU Readline Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ The GNU General Public License is often shipped with GNU software, and
+ is generally kept in a file called COPYING or LICENSE. If you do not
+ have a copy of the license, write to the Free Software Foundation,
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_RL_PRIVATE_H_)
+#define _RL_PRIVATE_H_
+
+#include "rlconf.h" /* for VISIBLE_STATS */
+#include "rlstdc.h"
+#include "posixjmp.h" /* defines procenv_t */
+
+/*************************************************************************
+ * *
+ * Global functions undocumented in texinfo manual and not in readline.h *
+ * *
+ *************************************************************************/
+
+/* terminal.c */
+extern char *rl_get_termcap __P((char *));
+
+/*************************************************************************
+ * *
+ * 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 */
+
+/* readline.c */
+extern int rl_line_buffer_len;
+extern int rl_numeric_arg;
+extern int rl_arg_sign;
+extern int rl_explicit_arg;
+extern int rl_editing_mode;
+extern int rl_visible_prompt_length;
+extern Function *rl_last_func;
+extern int readline_echoing_p;
+extern int rl_key_sequence_length;
+
+/* display.c */
+extern int rl_display_fixed;
+
+/* parens.c */
+extern int rl_blink_matching_paren;
+
+/*************************************************************************
+ * *
+ * Global functions and variables unsed and undocumented *
+ * *
+ *************************************************************************/
+
+/* bind.c */
+extern char *rl_untranslate_keyseq __P((int));
+
+/* kill.c */
+extern int rl_set_retained_kills __P((int));
+
+/* readline.c */
+extern int rl_discard_argument __P((void));
+
+/* rltty.c */
+extern int rl_stop_output __P((int, int));
+
+/* terminal.c */
+extern void _rl_set_screen_size __P((int, int));
+
+/* undo.c */
+extern int _rl_fix_last_undo_of_type __P((int, int, int));
+
+/* util.c */
+extern char *_rl_savestring __P((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 __P((void));
+extern char *readline_internal_teardown __P((int));
+extern int readline_internal_char __P((void));
+
+#endif /* READLINE_CALLBACKS */
+
+/* bind.c */
+extern void _rl_bind_if_unbound __P((char *, Function *));
+
+/* display.c */
+extern char *_rl_strip_prompt __P((char *));
+extern void _rl_move_cursor_relative __P((int, char *));
+extern void _rl_move_vert __P((int));
+extern void _rl_save_prompt __P((void));
+extern void _rl_restore_prompt __P((void));
+extern char *_rl_make_prompt_for_search __P((int));
+extern void _rl_erase_at_end_of_line __P((int));
+extern void _rl_clear_to_eol __P((int));
+extern void _rl_clear_screen __P((void));
+extern void _rl_update_final __P((void));
+extern void _rl_redisplay_after_sigwinch __P((void));
+extern void _rl_clean_up_for_exit __P((void));
+extern void _rl_erase_entire_line __P((void));
+extern int _rl_currentb_display_line __P((void));
+
+/* input.c */
+extern int _rl_any_typein __P((void));
+extern int _rl_input_available __P((void));
+extern void _rl_insert_typein __P((int));
+
+/* macro.c */
+extern void _rl_with_macro_input __P((char *));
+extern int _rl_next_macro_key __P((void));
+extern void _rl_push_executing_macro __P((void));
+extern void _rl_pop_executing_macro __P((void));
+extern void _rl_add_macro_char __P((int));
+extern void _rl_kill_kbd_macro __P((void));
+
+/* nls.c */
+extern int _rl_init_eightbit __P((void));
+
+/* parens.c */
+extern void _rl_enable_paren_matching __P((int));
+
+/* readline.c */
+extern void _rl_init_line_state __P((void));
+extern void _rl_set_the_line __P((void));
+extern int _rl_dispatch __P((int, Keymap));
+extern int _rl_init_argument __P((void));
+extern void _rl_fix_point __P((int));
+extern void _rl_replace_text __P((char *, int, int));
+extern int _rl_char_search_internal __P((int, int, int));
+extern int _rl_set_mark_at_pos __P((int));
+
+/* rltty.c */
+extern int _rl_disable_tty_signals __P((void));
+extern int _rl_restore_tty_signals __P((void));
+
+/* terminal.c */
+extern void _rl_get_screen_size __P((int, int));
+extern int _rl_init_terminal_io __P((char *));
+#ifdef _MINIX
+extern void _rl_output_character_function __P((int));
+#else
+extern int _rl_output_character_function __P((int));
+#endif
+extern void _rl_output_some_chars __P((char *, int));
+extern int _rl_backspace __P((int));
+extern void _rl_enable_meta_key __P((void));
+extern void _rl_control_keypad __P((int));
+
+/* util.c */
+extern int alphabetic __P((int));
+extern int _rl_abort_internal __P((void));
+extern char *_rl_strindex __P((char *, char *));
+extern int _rl_qsort_string_compare __P((char **, char **));
+extern int (_rl_uppercase_p) __P((int));
+extern int (_rl_lowercase_p) __P((int));
+extern int (_rl_pure_alphabetic) __P((int));
+extern int (_rl_digit_p) __P((int));
+extern int (_rl_to_lower) __P((int));
+extern int (_rl_to_upper) __P((int));
+extern int (_rl_digit_value) __P((int));
+
+/* vi_mode.c */
+extern void _rl_vi_initialize_line __P((void));
+extern void _rl_vi_reset_last __P((void));
+extern void _rl_vi_set_last __P((int, int, int));
+extern int _rl_vi_textmod_command __P((int));
+extern void _rl_vi_done_inserting __P((void));
+
+/*************************************************************************
+ * Undocumented private variables *
+ *************************************************************************/
+
+/* complete.c */
+extern int _rl_complete_show_all;
+extern int _rl_complete_mark_directories;
+extern int _rl_print_completions_horizontally;
+extern int _rl_completion_case_fold;
+
+/* display.c */
+extern int _rl_vis_botlin;
+extern int _rl_last_c_pos;
+extern int _rl_suppress_redisplay;
+extern char *rl_display_prompt;
+
+/* funmap.c */
+extern char *possible_control_prefixes[];
+extern char *possible_meta_prefixes[];
+
+/* isearch.c */
+extern unsigned char *_rl_isearch_terminators;
+
+/* macro.c */
+extern int _rl_defining_kbd_macro;
+extern char *_rl_executing_macro;
+
+/* readline.c */
+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 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 readline_top_level;
+
+/* terminal.c */
+extern int _rl_enable_keypad;
+extern int _rl_enable_meta;
+extern char *term_clreol;
+extern char *term_clrpag;
+extern char *term_im;
+extern char *term_ic;
+extern char *term_ei;
+extern char *term_DC;
+extern char *term_up;
+extern char *term_dc;
+extern char *term_cr;
+extern char *term_IC;
+extern int screenheight;
+extern int screenwidth;
+extern int screenchars;
+extern int terminal_can_insert;
+extern int _rl_term_autowrap;
+
+/* undo.c */
+extern int _rl_doing_an_undo;
+extern int _rl_undo_group_level;
+
+#endif /* _RL_PRIVATE_H_ */
diff --git a/lib/readline/rlshell.h b/lib/readline/rlshell.h
new file mode 100644
index 0000000..7a4e699
--- /dev/null
+++ b/lib/readline/rlshell.h
@@ -0,0 +1,34 @@
+/* rlshell.h -- utility functions normally provided by bash. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library, a library for
+ reading lines of text with interactive input and history editing.
+
+ The GNU Readline Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2, or
+ (at your option) any later version.
+
+ The GNU Readline Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ The GNU General Public License is often shipped with GNU software, and
+ is generally kept in a file called COPYING or LICENSE. If you do not
+ have a copy of the license, write to the Free Software Foundation,
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_RL_SHELL_H_)
+#define _RL_SHELL_H_
+
+#include "rlstdc.h"
+
+extern char *single_quote __P((char *));
+extern void set_lines_and_columns __P((int, int));
+extern char *get_env_value __P((char *));
+extern char *get_home_dir __P((void));
+extern int unset_nodelay_mode __P((int));
+
+#endif /* _RL_SHELL_H_ */
diff --git a/lib/readline/rlstdc.h b/lib/readline/rlstdc.h
index f1590c6..dac8e98 100644
--- a/lib/readline/rlstdc.h
+++ b/lib/readline/rlstdc.h
@@ -7,7 +7,7 @@
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 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
Bash is distributed in the hope that it will be useful, but WITHOUT
@@ -17,10 +17,10 @@
You should have received a copy of the GNU General Public License
along with Bash; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
-#if !defined (_STDC_H_)
-#define _STDC_H_
+#if !defined (_RL_STDC_H_)
+#define _RL_STDC_H_
/* Adapted from BSD /usr/include/sys/cdefs.h. */
@@ -28,52 +28,12 @@
and traditional C compilers with something like this:
extern char *func __P((char *, char *, int)); */
-#if defined (__STDC__)
-
-# if !defined (__P)
+#if !defined (__P)
+# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
# define __P(protos) protos
-# endif
-# define __STRING(x) #x
-
-# if !defined (__GNUC__)
-# define inline
-# endif
-
-#else /* !__STDC__ */
-
-# if !defined (__P)
+# else
# define __P(protos) ()
# endif
-# define __STRING(x) "x"
-
-#if defined (__GNUC__) /* gcc with -traditional */
-# if !defined (const)
-# define const __const
-# endif
-# if !defined (inline)
-# define inline __inline
-# endif
-# if !defined (signed)
-# define signed __signed
-# endif
-# if !defined (volatile)
-# define volatile __volatile
-# endif
-#else /* !__GNUC__ */
-# if !defined (const)
-# define const
-# endif
-# if !defined (inline)
-# define inline
-# endif
-# if !defined (signed)
-# define signed
-# endif
-# if !defined (volatile)
-# define volatile
-# endif
-#endif /* !__GNUC__ */
-
-#endif /* !__STDC__ */
+#endif
-#endif /* !_STDC_H_ */
+#endif /* !_RL_STDC_H_ */
diff --git a/lib/readline/rltty.c b/lib/readline/rltty.c
index a5ef938..b868b69 100644
--- a/lib/readline/rltty.c
+++ b/lib/readline/rltty.c
@@ -8,7 +8,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -43,26 +43,12 @@
#include "rltty.h"
#include "readline.h"
+#include "rlprivate.h"
#if !defined (errno)
extern int errno;
#endif /* !errno */
-extern int readline_echoing_p;
-extern int _rl_eof_char;
-
-extern int _rl_enable_keypad, _rl_enable_meta;
-
-extern void _rl_control_keypad ();
-
-#if defined (__GO32__)
-# include <pc.h>
-# undef HANDLE_SIGNALS
-#endif /* __GO32__ */
-
-/* Indirect functions to allow apps control over terminal management. */
-extern void rl_prep_terminal (), rl_deprep_terminal ();
-
VFunction *rl_prep_term_function = rl_prep_terminal;
VFunction *rl_deprep_term_function = rl_deprep_terminal;
@@ -104,6 +90,7 @@ block_sigint ()
# endif /* HAVE_USG_SIGHOLD */
# endif /* !HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
+
sigint_blocked = 1;
}
@@ -111,7 +98,7 @@ block_sigint ()
static void
release_sigint ()
{
- if (!sigint_blocked)
+ if (sigint_blocked == 0)
return;
#if defined (HAVE_POSIX_SIGNALS)
@@ -138,25 +125,27 @@ release_sigint ()
/* Non-zero means that the terminal is in a prepped state. */
static int terminal_prepped;
+static _RL_TTY_CHARS _rl_tty_chars, _rl_last_tty_chars;
+
/* If non-zero, means that this process has called tcflow(fd, TCOOFF)
and output is suspended. */
#if defined (__ksr1__)
static int ksrflow;
#endif
-#if defined (TIOCGWINSZ)
/* Dummy call to force a backgrounded readline to stop before it tries
to get the tty settings. */
static void
set_winsize (tty)
int tty;
{
+#if defined (TIOCGWINSZ)
struct winsize w;
if (ioctl (tty, TIOCGWINSZ, &w) == 0)
(void) ioctl (tty, TIOCSWINSZ, &w);
-}
#endif /* TIOCGWINSZ */
+}
#if defined (NEW_TTY_DRIVER)
@@ -184,6 +173,42 @@ struct bsdtty {
static TIOTYPE otio;
+static void
+save_tty_chars (tiop)
+ TIOTYPE *tiop;
+{
+ _rl_last_tty_chars = _rl_tty_chars;
+
+ if (tiop->flags & SGTTY_SET)
+ {
+ _rl_tty_chars.t_erase = tiop->sgttyb.sg_erase;
+ _rl_tty_chars.t_kill = tiop->sgttyb.sg_kill;
+ }
+
+ if (tiop->flags & TCHARS_SET)
+ {
+ _rl_tty_chars.t_intr = tiop->tchars.t_intrc;
+ _rl_tty_chars.t_quit = tiop->tchars.t_quitc;
+ _rl_tty_chars.t_start = tiop->tchars.t_startc;
+ _rl_tty_chars.t_stop = tiop->tchars.t_stopc
+ _rl_tty_chars.t_eof = tiop->tchars.t_eofc;
+ _rl_tty_chars.t_eol = '\n';
+ _rl_tty_chars.t_eol2 = tiop->tchars.t_brkc;
+ }
+
+ if (tiop->flags & LTCHARS_SET)
+ {
+ _rl_tty_chars.t_susp = tiop->ltchars.t_suspc;
+ _rl_tty_chars.t_dsusp = tiop->ltchars.t_dsuspc;
+ _rl_tty_chars.t_reprint = tiop->ltchars.t_rprntc;
+ _rl_tty_chars.t_flush = tiop->ltchars.t_flushc;
+ _rl_tty_chars.t_werase = tiop->ltchars.t_werasc;
+ _rl_tty_chars.t_lnext = tiop->ltchars.t_lnextc;
+ }
+
+ _rl_tty_chars.t_status = -1;
+}
+
static int
get_tty_settings (tty, tiop)
int tty;
@@ -258,7 +283,6 @@ prepare_terminal_settings (meta_flag, otio, tiop)
int meta_flag;
TIOTYPE otio, *tiop;
{
-#if !defined (__GO32__)
readline_echoing_p = (otio.sgttyb.sg_flags & ECHO);
/* Copy the original settings to the structure we're going to use for
@@ -324,7 +348,6 @@ prepare_terminal_settings (meta_flag, otio, tiop)
tiop->ltchars.t_dsuspc = -1; /* C-y */
tiop->ltchars.t_lnextc = -1; /* C-v */
#endif /* TIOCGLTC */
-#endif /* !__GO32__ */
}
#else /* !defined (NEW_TTY_DRIVER) */
@@ -362,11 +385,58 @@ static TIOTYPE otio;
#endif
static void
+save_tty_chars (tiop)
+ TIOTYPE *tiop;
+{
+ _rl_last_tty_chars = _rl_tty_chars;
+
+ _rl_tty_chars.t_eof = tiop->c_cc[VEOF];
+ _rl_tty_chars.t_eol = tiop->c_cc[VEOL];
+#ifdef VEOL2
+ _rl_tty_chars.t_eol2 = tiop->c_cc[VEOL2];
+#endif
+ _rl_tty_chars.t_erase = tiop->c_cc[VERASE];
+#ifdef VWERASE
+ _rl_tty_chars.t_werase = tiop->c_cc[VWERASE];
+#endif
+ _rl_tty_chars.t_kill = tiop->c_cc[VKILL];
+#ifdef VREPRINT
+ _rl_tty_chars.t_reprint = tiop->c_cc[VREPRINT];
+#endif
+ _rl_tty_chars.t_intr = tiop->c_cc[VINTR];
+ _rl_tty_chars.t_quit = tiop->c_cc[VQUIT];
+#ifdef VSUSP
+ _rl_tty_chars.t_susp = tiop->c_cc[VSUSP];
+#endif
+#ifdef VDSUSP
+ _rl_tty_chars.t_dsusp = tiop->c_cc[VDSUSP];
+#endif
+#ifdef VSTART
+ _rl_tty_chars.t_start = tiop->c_cc[VSTART];
+#endif
+#ifdef VSTOP
+ _rl_tty_chars.t_stop = tiop->c_cc[VSTOP];
+#endif
+#ifdef VLNEXT
+ _rl_tty_chars.t_lnext = tiop->c_cc[VLNEXT];
+#endif
+#ifdef VDISCARD
+ _rl_tty_chars.t_flush = tiop->c_cc[VDISCARD];
+#endif
+#ifdef VSTATUS
+ _rl_tty_chars.t_status = tiop->c_cc[VSTATUS];
+#endif
+}
+
+#if defined (_AIX) || defined (_AIX41)
+/* Currently this is only used on AIX */
+static void
rltty_warning (msg)
char *msg;
{
fprintf (stderr, "readline: warning: %s\n", msg);
}
+#endif
#if defined (_AIX)
void
@@ -382,14 +452,12 @@ TIOTYPE *tp;
#endif
static int
-get_tty_settings (tty, tiop)
+_get_tty_settings (tty, tiop)
int tty;
TIOTYPE *tiop;
{
int ioctl_ret;
- set_winsize (tty);
-
while (1)
{
ioctl_ret = GETATTR (tty, tiop);
@@ -413,6 +481,19 @@ get_tty_settings (tty, tiop)
break;
}
+ return 0;
+}
+
+static int
+get_tty_settings (tty, tiop)
+ int tty;
+ TIOTYPE *tiop;
+{
+ set_winsize (tty);
+
+ if (_get_tty_settings (tty, tiop) < 0)
+ return -1;
+
#if defined (_AIX)
setopost(tiop);
#endif
@@ -421,7 +502,7 @@ get_tty_settings (tty, tiop)
}
static int
-set_tty_settings (tty, tiop)
+_set_tty_settings (tty, tiop)
int tty;
TIOTYPE *tiop;
{
@@ -431,7 +512,17 @@ set_tty_settings (tty, tiop)
return -1;
errno = 0;
}
+ return 0;
+}
+static int
+set_tty_settings (tty, tiop)
+ int tty;
+ TIOTYPE *tiop;
+{
+ if (_set_tty_settings (tty, tiop) < 0)
+ return -1;
+
#if 0
#if defined (TERMIOS_TTY_DRIVER)
@@ -448,7 +539,7 @@ set_tty_settings (tty, tiop)
ioctl (tty, TCXONC, 1); /* Simulate a ^Q. */
#endif /* !TERMIOS_TTY_DRIVER */
-#endif
+#endif /* 0 */
return 0;
}
@@ -520,7 +611,6 @@ void
rl_prep_terminal (meta_flag)
int meta_flag;
{
-#if !defined (__GO32__)
int tty;
TIOTYPE tio;
@@ -540,6 +630,8 @@ rl_prep_terminal (meta_flag)
otio = tio;
+ save_tty_chars (&otio);
+
prepare_terminal_settings (meta_flag, otio, &tio);
if (set_tty_settings (tty, &tio) < 0)
@@ -555,14 +647,12 @@ rl_prep_terminal (meta_flag)
terminal_prepped = 1;
release_sigint ();
-#endif /* !__GO32__ */
}
/* Restore the terminal's normal settings and modes. */
void
rl_deprep_terminal ()
{
-#if !defined (__GO32__)
int tty;
if (!terminal_prepped)
@@ -587,7 +677,6 @@ rl_deprep_terminal ()
terminal_prepped = 0;
release_sigint ();
-#endif /* !__GO32__ */
}
/* **************************************************************** */
@@ -725,3 +814,54 @@ rltty_set_default_bindings (kmap)
}
#endif /* !NEW_TTY_DRIVER */
}
+
+#if defined (HANDLE_SIGNALS)
+
+#if defined (NEW_TTY_DRIVER)
+int
+_rl_disable_tty_signals ()
+{
+ return 0;
+}
+
+int
+_rl_restore_tty_signals ()
+{
+ return 0;
+}
+#else
+
+static TIOTYPE sigstty, nosigstty;
+static int tty_sigs_disabled = 0;
+
+int
+_rl_disable_tty_signals ()
+{
+ if (tty_sigs_disabled)
+ return 0;
+
+ if (_get_tty_settings (fileno (rl_instream), &sigstty) < 0)
+ return -1;
+
+ nosigstty = sigstty;
+
+ nosigstty.c_lflag &= ~ISIG;
+
+ if (_set_tty_settings (fileno (rl_instream), &nosigstty) < 0)
+ return (_set_tty_settings (fileno (rl_instream), &sigstty));
+
+ tty_sigs_disabled = 1;
+ return 0;
+}
+
+int
+_rl_restore_tty_signals ()
+{
+ if (tty_sigs_disabled == 0)
+ return 0;
+
+ return (_set_tty_settings (fileno (rl_instream), &sigstty));
+}
+#endif /* !NEW_TTY_DRIVER */
+
+#endif /* HANDLE_SIGNALS */
diff --git a/lib/readline/rltty.h b/lib/readline/rltty.h
index fe78346..029a3fb 100644
--- a/lib/readline/rltty.h
+++ b/lib/readline/rltty.h
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,10 +19,10 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLTTY_H_)
-#define _RLTTY_H
+#define _RLTTY_H_
/* Posix systems use termios and the Posix signal functions. */
#if defined (TERMIOS_TTY_DRIVER)
@@ -60,4 +60,23 @@
# endif /* !_SVR4_DISABLE */
#endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
+typedef struct _rl_tty_chars {
+ char t_eof;
+ char t_eol;
+ char t_eol2;
+ char t_erase;
+ char t_werase;
+ char t_kill;
+ char t_reprint;
+ char t_intr;
+ char t_quit;
+ char t_susp;
+ char t_dsusp;
+ char t_start;
+ char t_stop;
+ char t_lnext;
+ char t_flush;
+ char t_status;
+} _RL_TTY_CHARS;
+
#endif /* _RLTTY_H_ */
diff --git a/lib/readline/rlwinsize.h b/lib/readline/rlwinsize.h
index 92b3de1..7838154 100644
--- a/lib/readline/rlwinsize.h
+++ b/lib/readline/rlwinsize.h
@@ -9,7 +9,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -20,7 +20,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLWINSIZE_H_)
#define _RLWINSIZE_H_
@@ -55,4 +55,3 @@
#endif /* _RL_WINSIZE_H */
-
diff --git a/lib/readline/savestring.c b/lib/readline/savestring.c
index 3f53a87..485890e 100644
--- a/lib/readline/savestring.c
+++ b/lib/readline/savestring.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
extern char *strcpy ();
extern char *xmalloc ();
diff --git a/lib/readline/search.c b/lib/readline/search.c
index 6c76e1a..112f807 100644
--- a/lib/readline/search.c
+++ b/lib/readline/search.c
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -43,30 +43,51 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "xmalloc.h"
+
#ifdef abs
# undef abs
#endif
#define abs(x) (((x) >= 0) ? (x) : -(x))
-extern char *xmalloc (), *xrealloc ();
-
-/* Variables imported from readline.c */
-extern int rl_point, rl_end, rl_line_buffer_len;
-extern int rl_editing_mode;
-extern char *rl_prompt;
-extern char *rl_line_buffer;
extern HIST_ENTRY *saved_line_for_history;
-extern Function *rl_last_func;
/* Functions imported from the rest of the library. */
-extern int _rl_free_history_entry ();
-extern char *_rl_make_prompt_for_search ();
-extern void rl_extend_line_buffer ();
+extern int _rl_free_history_entry __P((HIST_ENTRY *));
static char *noninc_search_string = (char *) NULL;
static int noninc_history_pos;
+
static char *prev_line_found = (char *) NULL;
+static int rl_history_search_len;
+static int rl_history_search_pos;
+static char *history_search_string;
+static int history_string_size;
+
+/* Make the data from the history entry ENTRY be the contents of the
+ current line. This doesn't do anything with rl_point; the caller
+ must set it. */
+static void
+make_history_line_current (entry)
+ HIST_ENTRY *entry;
+{
+ int line_len;
+
+ line_len = strlen (entry->line);
+ if (line_len >= rl_line_buffer_len)
+ rl_extend_line_buffer (line_len);
+ strcpy (rl_line_buffer, entry->line);
+
+ rl_undo_list = (UNDO_LIST *)entry->data;
+ rl_end = line_len;
+
+ if (saved_line_for_history)
+ _rl_free_history_entry (saved_line_for_history);
+ saved_line_for_history = (HIST_ENTRY *)NULL;
+}
+
/* Search the history list for STRING starting at absolute history position
POS. If STRING begins with `^', the search must match STRING at the
beginning of a history line, otherwise a full substring match is performed
@@ -102,7 +123,7 @@ noninc_dosearch (string, dir)
char *string;
int dir;
{
- int oldpos, pos, line_len;
+ int oldpos, pos;
HIST_ENTRY *entry;
if (string == 0 || *string == '\0' || noninc_history_pos < 0)
@@ -132,19 +153,10 @@ noninc_dosearch (string, dir)
#endif
history_set_pos (oldpos);
- line_len = strlen (entry->line);
- if (line_len >= rl_line_buffer_len)
- rl_extend_line_buffer (line_len);
- strcpy (rl_line_buffer, entry->line);
+ make_history_line_current (entry);
- rl_undo_list = (UNDO_LIST *)entry->data;
- rl_end = strlen (rl_line_buffer);
rl_point = 0;
rl_clear_message ();
-
- if (saved_line_for_history)
- _rl_free_history_entry (saved_line_for_history);
- saved_line_for_history = (HIST_ENTRY *)NULL;
}
/* Search non-interactively through the history list. DIR < 0 means to
@@ -235,8 +247,7 @@ noninc_search (dir, pchar)
{
/* We want to start the search from the current history position. */
noninc_history_pos = where_history ();
- if (noninc_search_string)
- free (noninc_search_string);
+ FREE (noninc_search_string);
noninc_search_string = savestring (rl_line_buffer);
}
@@ -295,59 +306,84 @@ rl_noninc_reverse_search_again (count, key)
}
static int
-rl_history_search_internal (count, direction)
- int count, direction;
+rl_history_search_internal (count, dir)
+ int count, dir;
{
- HIST_ENTRY *temp, *old_temp;
- int line_len;
+ HIST_ENTRY *temp;
+ int ret, oldpos;
maybe_save_line ();
+ temp = (HIST_ENTRY *)NULL;
- temp = old_temp = (HIST_ENTRY *)NULL;
+ /* Search COUNT times through the history for a line whose prefix
+ matches history_search_string. When this loop finishes, TEMP,
+ if non-null, is the history line to copy into the line buffer. */
while (count)
{
- temp = (direction < 0) ? previous_history () : next_history ();
- if (temp == 0)
- break;
- /* On an empty prefix, make this the same as previous-history. */
- if (rl_point == 0)
- {
- count--;
- continue;
- }
- if (STREQN (rl_line_buffer, temp->line, rl_point))
- {
- /* Don't find multiple instances of the same line. */
- if (prev_line_found && STREQ (prev_line_found, temp->line))
- continue;
- if (direction < 0)
- old_temp = temp;
- prev_line_found = temp->line;
- count--;
- }
+ ret = noninc_search_from_pos (history_search_string, rl_history_search_pos + dir, dir);
+ if (ret == -1)
+ break;
+
+ /* Get the history entry we found. */
+ rl_history_search_pos = ret;
+ oldpos = where_history ();
+ history_set_pos (rl_history_search_pos);
+ temp = current_history ();
+ history_set_pos (oldpos);
+
+ /* Don't find multiple instances of the same line. */
+ if (prev_line_found && STREQ (prev_line_found, temp->line))
+ continue;
+ prev_line_found = temp->line;
+ count--;
}
+ /* If we didn't find anything at all, return. */
if (temp == 0)
{
- if (direction < 0 && old_temp)
- temp = old_temp;
- else
- {
- maybe_unsave_line ();
- ding ();
- return 1;
- }
+ maybe_unsave_line ();
+ ding ();
+ /* If you don't want the saved history line (last match) to show up
+ in the line buffer after the search fails, change the #if 0 to
+ #if 1 */
+#if 0
+ if (rl_point > rl_history_search_len)
+ {
+ rl_point = rl_end = rl_history_search_len;
+ rl_line_buffer[rl_end] = '\0';
+ }
+#else
+ rl_point = rl_history_search_len; /* maybe_unsave_line changes it */
+#endif
+ return 1;
}
- line_len = strlen (temp->line);
- if (line_len >= rl_line_buffer_len)
- rl_extend_line_buffer (line_len);
- strcpy (rl_line_buffer, temp->line);
- rl_undo_list = (UNDO_LIST *)temp->data;
- rl_end = line_len;
+ /* Copy the line we found into the current line buffer. */
+ make_history_line_current (temp);
+
+ rl_point = rl_history_search_len;
return 0;
}
+static void
+rl_history_search_reinit ()
+{
+ rl_history_search_pos = where_history ();
+ rl_history_search_len = rl_point;
+ prev_line_found = (char *)NULL;
+ if (rl_point)
+ {
+ if (rl_history_search_len >= history_string_size - 2)
+ {
+ history_string_size = rl_history_search_len + 2;
+ history_search_string = xrealloc (history_search_string, history_string_size);
+ }
+ history_search_string[0] = '^';
+ strncpy (history_search_string + 1, rl_line_buffer, rl_point);
+ history_search_string[rl_point + 1] = '\0';
+ }
+}
+
/* Search forward in the history for the string of characters
from the start of the line to rl_point. This is a non-incremental
search. */
@@ -357,8 +393,13 @@ rl_history_search_forward (count, ignore)
{
if (count == 0)
return (0);
- if (rl_last_func != rl_history_search_forward)
- prev_line_found = (char *)NULL;
+
+ if (rl_last_func != rl_history_search_forward &&
+ rl_last_func != rl_history_search_backward)
+ rl_history_search_reinit ();
+
+ if (rl_history_search_len == 0)
+ return (rl_get_next_history (count, ignore));
return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
}
@@ -371,7 +412,12 @@ rl_history_search_backward (count, ignore)
{
if (count == 0)
return (0);
- if (rl_last_func != rl_history_search_backward)
- prev_line_found = (char *)NULL;
+
+ if (rl_last_func != rl_history_search_forward &&
+ rl_last_func != rl_history_search_backward)
+ rl_history_search_reinit ();
+
+ if (rl_history_search_len == 0)
+ return (rl_get_previous_history (count, ignore));
return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1));
}
diff --git a/lib/readline/shell.c b/lib/readline/shell.c
index 091ec08..3daef69 100644
--- a/lib/readline/shell.c
+++ b/lib/readline/shell.c
@@ -8,7 +8,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -44,13 +44,21 @@
# include <strings.h>
#endif /* !HAVE_STRING_H */
+#include <fcntl.h>
#include <pwd.h>
+#include <stdio.h>
+
+#include "rlshell.h"
+#include "xmalloc.h"
+
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid ();
#endif /* !HAVE_GETPW_DECLS */
-extern char *xmalloc ();
+#ifndef NULL
+# define NULL 0
+#endif
/* All of these functions are resolved from bash if we are linking readline
as part of bash. */
@@ -63,7 +71,7 @@ single_quote (string)
register int c;
char *result, *r, *s;
- result = (char *)xmalloc (3 + (3 * strlen (string)));
+ result = (char *)xmalloc (3 + (4 * strlen (string)));
r = result;
*r++ = '\'';
@@ -131,3 +139,37 @@ get_home_dir ()
home_dir = entry->pw_dir;
return (home_dir);
}
+
+#if !defined (O_NDELAY)
+# if defined (FNDELAY)
+# define O_NDELAY FNDELAY
+# endif
+#endif
+
+int
+unset_nodelay_mode (fd)
+ int fd;
+{
+ int flags, bflags;
+
+ if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
+ return -1;
+
+ bflags = 0;
+
+#ifdef O_NONBLOCK
+ bflags |= O_NONBLOCK;
+#endif
+
+#ifdef O_NDELAY
+ bflags |= O_NDELAY;
+#endif
+
+ if (flags & bflags)
+ {
+ flags &= ~bflags;
+ return (fcntl (fd, F_SETFL, flags));
+ }
+
+ return 0;
+}
diff --git a/lib/readline/signals.c b/lib/readline/signals.c
index 3a34432..861019d 100644
--- a/lib/readline/signals.c
+++ b/lib/readline/signals.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -40,15 +40,13 @@
# include <sys/ioctl.h>
#endif /* GWINSZ_IN_SYS_IOCTL */
-#if defined (__GO32__)
-# undef HANDLE_SIGNALS
-#endif /* __GO32__ */
-
#if defined (HANDLE_SIGNALS)
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+
#if !defined (RETSIGTYPE)
# if defined (VOID_SIGHANDLER)
# define RETSIGTYPE void
@@ -67,19 +65,15 @@
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
typedef RETSIGTYPE SigHandler ();
-extern int readline_echoing_p;
-extern int rl_pending_input;
-extern int _rl_meta_flag;
-
-extern void free_undo_list ();
-extern void _rl_get_screen_size ();
-extern void _rl_redisplay_after_sigwinch ();
-extern void _rl_clean_up_for_exit ();
-extern void _rl_kill_kbd_macro ();
-extern void _rl_init_argument ();
-extern void rl_deprep_terminal (), rl_prep_terminal ();
+#if defined (HAVE_POSIX_SIGNALS)
+typedef struct sigaction sighandler_cxt;
+# define rl_sigaction(s, nh, oh) sigaction(s, nh, oh)
+#else
+typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt;
+# define sigemptyset(m)
+#endif /* !HAVE_POSIX_SIGNALS */
-static SigHandler *rl_set_sighandler ();
+static SigHandler *rl_set_sighandler __P((int, SigHandler *, sighandler_cxt *));
/* Exported variables for use by applications. */
@@ -101,14 +95,6 @@ static int sigwinch_set_flag;
/* */
/* **************************************************************** */
-#if defined (HAVE_POSIX_SIGNALS)
-typedef struct sigaction sighandler_cxt;
-# define rl_sigaction(s, nh, oh) sigaction(s, nh, oh)
-#else
-typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt;
-# define sigemptyset(m)
-#endif /* !HAVE_POSIX_SIGNALS */
-
static sighandler_cxt old_int, old_term, old_alrm, old_quit;
#if defined (SIGTSTP)
static sighandler_cxt old_tstp, old_ttou, old_ttin;
@@ -165,6 +151,10 @@ rl_signal_handler (sig)
# endif /* HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
+#if defined (__EMX__)
+ signal (sig, SIG_ACK);
+#endif
+
kill (getpid (), sig);
/* Let the signal that we just sent through. */
@@ -232,6 +222,7 @@ rl_set_sighandler (sig, handler, ohandler)
SigHandler *handler;
sighandler_cxt *ohandler;
{
+ sighandler_cxt old_handler;
#if defined (HAVE_POSIX_SIGNALS)
struct sigaction act;
@@ -239,10 +230,17 @@ rl_set_sighandler (sig, handler, ohandler)
act.sa_flags = 0;
sigemptyset (&act.sa_mask);
sigemptyset (&ohandler->sa_mask);
- sigaction (sig, &act, ohandler);
+ sigaction (sig, &act, &old_handler);
#else
- ohandler->sa_handler = (SigHandler *)signal (sig, handler);
+ old_handler.sa_handler = (SigHandler *)signal (sig, handler);
#endif /* !HAVE_POSIX_SIGNALS */
+
+ /* XXX -- assume we have memcpy */
+ /* If rl_set_signals is called twice in a row, don't set the old handler to
+ rl_signal_handler, because that would cause infinite recursion. */
+ if (handler != rl_signal_handler || old_handler.sa_handler != rl_signal_handler)
+ memcpy (ohandler, &old_handler, sizeof (sighandler_cxt));
+
return (ohandler->sa_handler);
}
diff --git a/lib/readline/tcap.h b/lib/readline/tcap.h
index acb2d76..58ab894 100644
--- a/lib/readline/tcap.h
+++ b/lib/readline/tcap.h
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RLTCAP_H_)
#define _RLTCAP_H_
diff --git a/lib/readline/terminal.c b/lib/readline/terminal.c
index c22ec51..20ad126 100644
--- a/lib/readline/terminal.c
+++ b/lib/readline/terminal.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -46,9 +46,7 @@
# include <locale.h>
#endif
-#include <signal.h>
#include <stdio.h>
-#include <setjmp.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
@@ -64,18 +62,8 @@
#include "readline.h"
#include "history.h"
-/* Variables and functions imported from readline.c */
-extern FILE *_rl_in_stream, *_rl_out_stream;
-extern int readline_echoing_p;
-extern int _rl_bell_preference;
-extern Keymap _rl_keymap;
-
-/* Functions imported from bind.c */
-extern void _rl_bind_if_unbound ();
-
-/* Functions imported from shell.c */
-extern void set_lines_and_columns ();
-extern char *get_env_value ();
+#include "rlprivate.h"
+#include "rlshell.h"
/* **************************************************************** */
/* */
@@ -149,6 +137,22 @@ int _rl_enable_keypad;
/* Non-zero means the user wants to enable a meta key. */
int _rl_enable_meta = 1;
+#if defined (__EMX__)
+static void
+_emx_get_screensize (swp, shp)
+ int *swp, *shp;
+{
+ int sz[2];
+
+ _scrsize (sz);
+
+ if (swp)
+ *swp = sz[0];
+ if (shp)
+ *shp = sz[1];
+}
+#endif
+
/* Get readline's idea of the screen size. TTY is a file descriptor open
to the terminal. If IGNORE_ENV is true, we do not pay attention to the
values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being
@@ -161,9 +165,6 @@ _rl_get_screen_size (tty, ignore_env)
#if defined (TIOCGWINSZ)
struct winsize window_size;
#endif /* TIOCGWINSZ */
-#if defined (__EMX__)
- int sz[2];
-#endif
#if defined (TIOCGWINSZ)
if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
@@ -174,9 +175,7 @@ _rl_get_screen_size (tty, ignore_env)
#endif /* TIOCGWINSZ */
#if defined (__EMX__)
- _scrsize (sz);
- screenwidth = sz[0];
- screenheight = sz[1];
+ _emx_get_screensize (&screenwidth, &screenheight);
#endif
/* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
@@ -186,8 +185,10 @@ _rl_get_screen_size (tty, ignore_env)
if (ignore_env == 0 && (ss = get_env_value ("COLUMNS")))
screenwidth = atoi (ss);
+#if !defined (__DJGPP__)
if (screenwidth <= 0 && term_string_buffer)
screenwidth = tgetnum ("co");
+#endif
}
/* Environment variable LINES overrides setting of "li" if IGNORE_ENV
@@ -197,8 +198,10 @@ _rl_get_screen_size (tty, ignore_env)
if (ignore_env == 0 && (ss = get_env_value ("LINES")))
screenheight = atoi (ss);
+#if !defined (__DJGPP__)
if (screenheight <= 0 && term_string_buffer)
screenheight = tgetnum ("li");
+#endif
}
/* If all else fails, default to 80x24 terminal. */
@@ -213,7 +216,7 @@ _rl_get_screen_size (tty, ignore_env)
do a pair of putenv () or setenv () calls. */
set_lines_and_columns (screenheight, screenwidth);
- if (!_rl_term_autowrap)
+ if (_rl_term_autowrap == 0)
screenwidth--;
screenchars = screenwidth * screenheight;
@@ -251,32 +254,32 @@ struct _tc_string {
search algorithm to something smarter. */
static struct _tc_string tc_strings[] =
{
- "DC", &term_DC,
- "IC", &term_IC,
- "ce", &term_clreol,
- "cl", &term_clrpag,
- "cr", &term_cr,
- "dc", &term_dc,
- "ei", &term_ei,
- "ic", &term_ic,
- "im", &term_im,
- "kd", &term_kd,
- "kh", &term_kh, /* home */
- "kH", &term_kH, /* end */
- "kl", &term_kl,
- "kr", &term_kr,
- "ku", &term_ku,
- "ks", &term_ks,
- "ke", &term_ke,
- "le", &term_backspace,
- "mm", &term_mm,
- "mo", &term_mo,
+ { "DC", &term_DC },
+ { "IC", &term_IC },
+ { "ce", &term_clreol },
+ { "cl", &term_clrpag },
+ { "cr", &term_cr },
+ { "dc", &term_dc },
+ { "ei", &term_ei },
+ { "ic", &term_ic },
+ { "im", &term_im },
+ { "kd", &term_kd },
+ { "kh", &term_kh }, /* home */
+ { "kH", &term_kH }, /* end */
+ { "kl", &term_kl },
+ { "kr", &term_kr },
+ { "ku", &term_ku },
+ { "ks", &term_ks },
+ { "ke", &term_ke },
+ { "le", &term_backspace },
+ { "mm", &term_mm },
+ { "mo", &term_mo },
#if defined (HACK_TERMCAP_MOTION)
- "nd", &term_forward_char,
+ { "nd", &term_forward_char },
#endif
- "pc", &term_pc,
- "up", &term_up,
- "vb", &visible_bell,
+ { "pc", &term_pc },
+ { "up", &term_up },
+ { "vb", &visible_bell },
};
#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
@@ -287,72 +290,96 @@ static void
get_term_capabilities (bp)
char **bp;
{
+#if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */
register int i;
for (i = 0; i < NUM_TC_STRINGS; i++)
*(tc_strings[i].tc_value) = tgetstr (tc_strings[i].tc_var, bp);
+#endif
tcap_initialized = 1;
}
+#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
+#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
+
int
_rl_init_terminal_io (terminal_name)
char *terminal_name;
{
-#if defined (__GO32__)
- screenwidth = ScreenCols ();
- screenheight = ScreenRows ();
- screenchars = screenwidth * screenheight;
- term_cr = "\r";
- term_im = term_ei = term_ic = term_IC = (char *)NULL;
- term_up = term_dc = term_DC = visible_bell = (char *)NULL;
-
- /* Does the __GO32__ have a meta key? I don't know. */
- term_has_meta = 0;
- term_mm = term_mo = (char *)NULL;
-
- /* It probably has arrow keys, but I don't know what they are. */
- term_ku = term_kd = term_kr = term_kl = (char *)NULL;
-
-#if defined (HACK_TERMCAP_MOTION)
- term_forward_char = (char *)NULL;
-#endif /* HACK_TERMCAP_MOTION */
- terminal_can_insert = _rl_term_autowrap = 0;
- return;
-#else /* !__GO32__ */
-
char *term, *buffer;
- int tty;
+ int tty, tgetent_ret;
Keymap xkeymap;
term = terminal_name ? terminal_name : get_env_value ("TERM");
+ term_clrpag = term_cr = term_clreol = (char *)NULL;
+ tty = rl_instream ? fileno (rl_instream) : 0;
+ screenwidth = screenheight = 0;
- if (term_string_buffer == 0)
- term_string_buffer = xmalloc (2032);
+ if (term == 0)
+ term = "dumb";
- if (term_buffer == 0)
- term_buffer = xmalloc (4080);
+ /* I've separated this out for later work on not calling tgetent at all
+ if the calling application has supplied a custom redisplay function,
+ (and possibly if the application has supplied a custom input function). */
+ if (CUSTOM_REDISPLAY_FUNC())
+ {
+ tgetent_ret = -1;
+ }
+ else
+ {
+ if (term_string_buffer == 0)
+ term_string_buffer = xmalloc(2032);
- buffer = term_string_buffer;
+ if (term_buffer == 0)
+ term_buffer = xmalloc(4080);
- term_clrpag = term_cr = term_clreol = (char *)NULL;
+ buffer = term_string_buffer;
- if (term == 0)
- term = "dumb";
+ tgetent_ret = tgetent (term_buffer, term);
+ }
- if (tgetent (term_buffer, term) <= 0)
+ if (tgetent_ret <= 0)
{
+ FREE (term_string_buffer);
+ FREE (term_buffer);
+ buffer = term_buffer = term_string_buffer = (char *)NULL;
+
dumb_term = 1;
- screenwidth = 79;
- screenheight = 24;
- screenchars = 79 * 24;
+ _rl_term_autowrap = 0; /* used by _rl_get_screen_size */
+
+#if defined (__EMX__)
+ _emx_get_screensize (&screenwidth, &screenheight);
+ screenwidth--;
+#else /* !__EMX__ */
+ _rl_get_screen_size (tty, 0);
+#endif /* !__EMX__ */
+
+ /* Defaults. */
+ if (screenwidth <= 0 || screenheight <= 0)
+ {
+ screenwidth = 79;
+ screenheight = 24;
+ }
+
+ /* Everything below here is used by the redisplay code (tputs). */
+ screenchars = screenwidth * screenheight;
term_cr = "\r";
term_im = term_ei = term_ic = term_IC = (char *)NULL;
term_up = term_dc = term_DC = visible_bell = (char *)NULL;
term_ku = term_kd = term_kl = term_kr = (char *)NULL;
+ term_mm = term_mo = (char *)NULL;
#if defined (HACK_TERMCAP_MOTION)
term_forward_char = (char *)NULL;
#endif
- terminal_can_insert = 0;
+ terminal_can_insert = term_has_meta = 0;
+
+ /* Reasonable defaults for tgoto(). Readline currently only uses
+ tgoto if term_IC or term_DC is defined, but just in case we
+ change that later... */
+ PC = '\0';
+ BC = term_backspace = "\b";
+ UP = term_up;
+
return 0;
}
@@ -367,10 +394,6 @@ _rl_init_terminal_io (terminal_name)
if (!term_cr)
term_cr = "\r";
- tty = rl_instream ? fileno (rl_instream) : 0;
-
- screenwidth = screenheight = 0;
-
_rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
_rl_get_screen_size (tty, 0);
@@ -413,7 +436,6 @@ _rl_init_terminal_io (terminal_name)
_rl_keymap = xkeymap;
-#endif /* !__GO32__ */
return 0;
}
@@ -459,6 +481,7 @@ _rl_output_character_function (c)
return putc (c, _rl_out_stream);
}
#endif /* !_MINIX */
+
/* Write COUNT characters from STRING to the output stream. */
void
_rl_output_some_chars (string, count)
@@ -475,12 +498,10 @@ _rl_backspace (count)
{
register int i;
-#if !defined (__GO32__)
if (term_backspace)
for (i = 0; i < count; i++)
tputs (term_backspace, 1, _rl_output_character_function);
else
-#endif /* !__GO32__ */
for (i = 0; i < count; i++)
putc ('\b', _rl_out_stream);
return 0;
@@ -504,7 +525,6 @@ ding ()
{
if (readline_echoing_p)
{
-#if !defined (__GO32__)
switch (_rl_bell_preference)
{
case NO_BELL:
@@ -522,10 +542,6 @@ ding ()
fflush (stderr);
break;
}
-#else /* __GO32__ */
- fprintf (stderr, "\007");
- fflush (stderr);
-#endif /* __GO32__ */
return (0);
}
return (-1);
@@ -540,16 +556,20 @@ ding ()
void
_rl_enable_meta_key ()
{
+#if !defined (__DJGPP__)
if (term_has_meta && term_mm)
tputs (term_mm, 1, _rl_output_character_function);
+#endif
}
void
_rl_control_keypad (on)
int on;
{
+#if !defined (__DJGPP__)
if (on && term_ks)
tputs (term_ks, 1, _rl_output_character_function);
else if (!on && term_ke)
tputs (term_ke, 1, _rl_output_character_function);
+#endif
}
diff --git a/lib/readline/tilde.c b/lib/readline/tilde.c
index d1853bd..777b655 100644
--- a/lib/readline/tilde.c
+++ b/lib/readline/tilde.c
@@ -7,7 +7,7 @@
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 1, or (at your option) any
+ Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
@@ -47,12 +47,22 @@
#include "tilde.h"
+#if defined (TEST) || defined (STATIC_MALLOC)
+static char *xmalloc (), *xrealloc ();
+#else
+# if defined __STDC__
+extern char *xmalloc (int);
+extern char *xrealloc (void *, int);
+# else
+extern char *xmalloc (), *xrealloc ();
+# endif /* !__STDC__ */
+#endif /* TEST || STATIC_MALLOC */
+
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid (), *getpwnam ();
#endif /* !HAVE_GETPW_DECLS */
#if !defined (savestring)
-extern char *xmalloc ();
# ifndef strcpy
extern char *strcpy ();
# endif
@@ -67,17 +77,11 @@ extern char *strcpy ();
# endif /* !__STDC__ */
#endif /* !NULL */
-#if defined (TEST) || defined (STATIC_MALLOC)
-static char *xmalloc (), *xrealloc ();
-#else
-extern char *xmalloc (), *xrealloc ();
-#endif /* TEST || STATIC_MALLOC */
-
/* If being compiled as part of bash, these will be satisfied from
variables.o. If being compiled as part of readline, they will
be satisfied from shell.o. */
-extern char *get_home_dir ();
-extern char *get_env_value ();
+extern char *get_home_dir __P((void));
+extern char *get_env_value __P((char *));
/* The default value of tilde_additional_prefixes. This is set to
whitespace preceding a tilde so that simple programs which do not
@@ -122,7 +126,9 @@ tilde_find_prefix (string, len)
int *len;
{
register int i, j, string_len;
- register char **prefixes = tilde_additional_prefixes;
+ register char **prefixes;
+
+ prefixes = tilde_additional_prefixes;
string_len = strlen (string);
*len = 0;
@@ -161,7 +167,11 @@ tilde_find_suffix (string)
for (i = 0; i < string_len; i++)
{
+#if defined (__MSDOS__)
+ if (string[i] == '/' || string[i] == '\\' /* || !string[i] */)
+#else
if (string[i] == '/' /* || !string[i] */)
+#endif
break;
for (j = 0; suffixes && suffixes[j]; j++)
@@ -225,11 +235,18 @@ tilde_expand (string)
free (tilde_word);
len = strlen (expansion);
- if ((result_index + len + 1) > result_size)
- result = xrealloc (result, 1 + (result_size += (len + 20)));
+#ifdef __CYGWIN32__
+ /* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when
+ $HOME for `user' is /. On cygwin, // denotes a network drive. */
+ if (len > 1 || *expansion != '/' || *string != '/')
+#endif
+ {
+ if ((result_index + len + 1) > result_size)
+ result = xrealloc (result, 1 + (result_size += (len + 20)));
- strcpy (result + result_index, expansion);
- result_index += len;
+ strcpy (result + result_index, expansion);
+ result_index += len;
+ }
free (expansion);
}
@@ -250,7 +267,11 @@ isolate_tilde_prefix (fname, lenp)
int i;
ret = xmalloc (strlen (fname));
+#if defined (__MSDOS__)
+ for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
+#else
for (i = 1; fname[i] && fname[i] != '/'; i++)
+#endif
ret[i - 1] = fname[i];
ret[i - 1] = '\0';
if (lenp)
@@ -271,7 +292,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
plen = (prefix && *prefix) ? strlen (prefix) : 0;
slen = strlen (suffix + suffind);
ret = xmalloc (plen + slen + 1);
- if (prefix && *prefix)
+ if (plen)
strcpy (ret, prefix);
strcpy (ret + plen, suffix + suffind);
return ret;
diff --git a/lib/readline/tilde.h b/lib/readline/tilde.h
index 634b954..7783fd6 100644
--- a/lib/readline/tilde.h
+++ b/lib/readline/tilde.h
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,11 +19,27 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_TILDE_H_)
# define _TILDE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A function can be defined using prototypes and compile on both ANSI C
+ and traditional C compilers with something like this:
+ extern char *func __P((char *, char *, int)); */
+
+#if !defined (__P)
+# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
+# define __P(protos) protos
+# else
+# define __P(protos) ()
+# endif
+#endif
+
/* Function pointers can be declared as (Function *)foo. */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
@@ -56,10 +72,14 @@ extern char **tilde_additional_prefixes;
extern char **tilde_additional_suffixes;
/* Return a new string which is the result of tilde expanding STRING. */
-extern char *tilde_expand ();
+extern char *tilde_expand __P((char *));
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
tilde. If there is no expansion, call tilde_expansion_failure_hook. */
-extern char *tilde_expand_word ();
+extern char *tilde_expand_word __P((char *));
+
+#ifdef __cplusplus
+}
+#endif
#endif /* _TILDE_H_ */
diff --git a/lib/readline/undo.c b/lib/readline/undo.c
index 28ebcc8..f7f30d1 100644
--- a/lib/readline/undo.c
+++ b/lib/readline/undo.c
@@ -8,7 +8,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -47,6 +47,8 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+
#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
/* Non-zero tells rl_delete_text and rl_insert_text to not add to
diff --git a/lib/readline/util.c b/lib/readline/util.c
index 1dc3b66..be9e0a9 100644
--- a/lib/readline/util.c
+++ b/lib/readline/util.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
@@ -52,24 +52,10 @@
/* Some standard library routines. */
#include "readline.h"
-#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
-
-/* Pseudo-globals imported from readline.c */
-extern int readline_echoing_p;
-extern procenv_t readline_top_level;
-extern int rl_line_buffer_len;
-extern Function *rl_last_func;
-
-extern int _rl_defining_kbd_macro;
-extern char *_rl_executing_macro;
+#include "rlprivate.h"
+#include "xmalloc.h"
-/* Pseudo-global functions imported from other library files. */
-extern void _rl_replace_text ();
-extern void _rl_pop_executing_macro ();
-extern void _rl_set_the_line ();
-extern void _rl_init_argument ();
-
-extern char *xmalloc (), *xrealloc ();
+#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
/* **************************************************************** */
/* */
diff --git a/lib/readline/vi_keymap.c b/lib/readline/vi_keymap.c
index 14929a3..cf6724c 100644
--- a/lib/readline/vi_keymap.c
+++ b/lib/readline/vi_keymap.c
@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (BUFSIZ)
#include <stdio.h>
diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c
index d4868bf..be7f949 100644
--- a/lib/readline/vi_mode.c
+++ b/lib/readline/vi_mode.c
@@ -8,7 +8,7 @@
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -19,7 +19,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
/* **************************************************************** */
@@ -54,6 +54,9 @@
#include "readline.h"
#include "history.h"
+#include "rlprivate.h"
+#include "xmalloc.h"
+
#ifndef _rl_digit_p
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
#endif
@@ -74,26 +77,6 @@
#define exchange(x, y) do {int temp = x; x = y; y = temp;} while (0)
#endif
-extern char *xmalloc (), *xrealloc ();
-
-/* Variables imported from readline.c */
-extern int rl_point, rl_end, rl_mark;
-extern FILE *rl_instream;
-extern int rl_line_buffer_len, rl_explicit_arg, rl_numeric_arg;
-extern Keymap _rl_keymap;
-extern char *rl_prompt;
-extern char *rl_line_buffer;
-extern int rl_arg_sign;
-
-extern int _rl_doing_an_undo;
-extern int _rl_undo_group_level;
-
-extern void _rl_dispatch ();
-extern int _rl_char_search_internal ();
-
-extern void rl_extend_line_buffer ();
-extern int rl_vi_check ();
-
/* Non-zero means enter insertion mode. */
static int _rl_vi_doing_insert;
@@ -131,7 +114,7 @@ static char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
/* Arrays for the saved marks. */
static int vi_mark_chars[27];
-static int rl_digit_loop1 ();
+static int rl_digit_loop1 __P((void));
void
_rl_vi_initialize_line ()
@@ -1043,7 +1026,7 @@ rl_vi_char_search (count, key)
if (vi_redoing)
target = _rl_vi_last_search_char;
else
- _rl_vi_last_search_char = target = rl_getc (rl_instream);
+ _rl_vi_last_search_char = target = (*rl_getc_function) (rl_instream);
switch (key)
{
@@ -1159,7 +1142,7 @@ rl_vi_change_char (count, key)
if (vi_redoing)
c = _rl_vi_last_replacement;
else
- _rl_vi_last_replacement = c = rl_getc (rl_instream);
+ _rl_vi_last_replacement = c = (*rl_getc_function) (rl_instream);
if (c == '\033' || c == CTRL ('C'))
return -1;
diff --git a/lib/readline/xmalloc.c b/lib/readline/xmalloc.c
index 4160651..c0d0640 100644
--- a/lib/readline/xmalloc.c
+++ b/lib/readline/xmalloc.c
@@ -7,7 +7,7 @@
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 1, or (at your option) any
+ Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,8 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
#include <config.h>
@@ -31,7 +32,7 @@
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
-static void memory_error_and_abort ();
+#include "xmalloc.h"
/* **************************************************************** */
/* */
@@ -39,6 +40,14 @@ static void memory_error_and_abort ();
/* */
/* **************************************************************** */
+static void
+memory_error_and_abort (fname)
+ char *fname;
+{
+ fprintf (stderr, "%s: out of virtual memory\n", fname);
+ exit (2);
+}
+
/* Return a pointer to free()able block of memory large enough
to hold BYTES number of bytes. If the memory cannot be allocated,
print an error message and abort. */
@@ -56,7 +65,7 @@ xmalloc (bytes)
char *
xrealloc (pointer, bytes)
- char *pointer;
+ PTR_T pointer;
int bytes;
{
char *temp;
@@ -68,19 +77,11 @@ xrealloc (pointer, bytes)
return (temp);
}
-static void
-memory_error_and_abort (fname)
- char *fname;
-{
- fprintf (stderr, "%s: out of virtual memory\n", fname);
- exit (2);
-}
-
/* Use this as the function to call when adding unwind protects so we
don't need to know what free() returns. */
void
xfree (string)
- char *string;
+ PTR_T string;
{
if (string)
free (string);
diff --git a/lib/readline/xmalloc.h b/lib/readline/xmalloc.h
new file mode 100644
index 0000000..bdf251b
--- /dev/null
+++ b/lib/readline/xmalloc.h
@@ -0,0 +1,46 @@
+/* xmalloc.h -- memory allocation that aborts on errors. */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library, a library for
+ reading lines of text with interactive input and history editing.
+
+ The GNU Readline Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2, or
+ (at your option) any later version.
+
+ The GNU Readline Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ The GNU General Public License is often shipped with GNU software, and
+ is generally kept in a file called COPYING or LICENSE. If you do not
+ have a copy of the license, write to the Free Software Foundation,
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#if !defined (_XMALLOC_H_)
+#define _XMALLOC_H_
+
+#if defined (READLINE_LIBRARY)
+# include "rlstdc.h"
+#else
+# include <readline/rlstdc.h>
+#endif
+
+#ifndef PTR_T
+
+#ifdef __STDC__
+# define PTR_T void *
+#else
+# define PTR_T char *
+#endif
+
+#endif /* !PTR_T */
+
+extern char *xmalloc __P((int));
+extern char *xrealloc __P((void *, int));
+extern void xfree __P((void *));
+
+#endif /* _XMALLOC_H_ */
diff --git a/lib/sh/Makefile.in b/lib/sh/Makefile.in
index 439595c..789c544 100644
--- a/lib/sh/Makefile.in
+++ b/lib/sh/Makefile.in
@@ -1,13 +1,29 @@
#
# Makefile for the Bash library
#
+#
+# Copyright (C) 1998 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
BUILD_DIR = @BUILD_DIR@
-POSIX_INC = ${topdir}/lib/posixheaders
+BASHINCDIR = ${topdir}/include
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
@@ -33,7 +49,7 @@ PROFILE_FLAGS = @PROFILE_FLAGS@
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
-INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib -I$(POSIX_INC) -I$(srcdir)
+INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib -I$(BASHINCDIR) -I$(srcdir)
CCFLAGS = ${PROFILE_FLAGS} ${INCLUDES} $(DEFS) $(LOCAL_DEFS) $(LOCAL_CFLAGS) \
$(CFLAGS) $(CPPFLAGS)
@@ -45,17 +61,19 @@ CCFLAGS = ${PROFILE_FLAGS} ${INCLUDES} $(DEFS) $(LOCAL_DEFS) $(LOCAL_CFLAGS) \
LIBRARY_NAME = libsh.a
# The C code source files for this library.
-CSOURCES = clktck.c getcwd.c getenv.c oslib.c setlinebuf.c \
+CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
strcasecmp.c strerror.c strtod.c strtol.c strtoul.c \
- vprint.c itos.c rename.c
+ vprint.c itos.c rename.c zread.c zwrite.c shtty.c \
+ inet_aton.c netopen.c strpbrk.c timeval.c makepath.c
# The header files for this library.
HSOURCES =
# The object files contained in $(LIBRARY_NAME)
-OBJECTS = clktck.o getcwd.o getenv.o oslib.o setlinebuf.o \
+OBJECTS = clktck.o clock.o getcwd.o getenv.o oslib.o setlinebuf.o \
strcasecmp.o strerror.o strtod.o strtol.o strtoul.o \
- vprint.o itos.o rename.o
+ vprint.o itos.o rename.o zread.o zwrite.o shtty.o \
+ inet_aton.o netopen.o strpbrk.o timeval.o makepath.o
SUPPORT = Makefile
@@ -85,87 +103,124 @@ mostlyclean: clean
# rules for losing makes, like SunOS
clktck.o: clktck.c
+clock.o: clock.c
getcwd.o: getcwd.c
getenv.o: getenv.c
+inet_aton.o: inet_aton.c
itos.o: itos.c
+netopen.o: netopen.c
oslib.o: oslib.c
rename.o: rename.c
setlinebuf.o: setlinebuf.c
+shquote.o: shquote.c
+shtty.o: shtty.c
strcasecmp.o: strcasecmp.c
strerror.o: strerror.c
+strpbrk.o: strpbrk.c
strtod.o: strtod.c
strtol.o: strtol.c
strtoul.o: strtoul.c
+times.o: times.c
+timeval.o: timeval.c
vprint.o: vprint.c
+zread.o: zread.c
+zwrite.o: zwrite.c
# all files in the library depend on config.h
clktck.o: ${BUILD_DIR}/config.h
+clock.o: ${BUILD_DIR}/config.h
getcwd.o: ${BUILD_DIR}/config.h
getenv.o: ${BUILD_DIR}/config.h
+inet_aton.o: ${BUILD_DIR}/config.h
itos.o: ${BUILD_DIR}/config.h
+netopen.o: ${BUILD_DIR}/config.h
oslib.o: ${BUILD_DIR}/config.h
rename.o: ${BUILD_DIR}/config.h
setlinebuf.o: ${BUILD_DIR}/config.h
+shquote.o: ${BUILD_DIR}/config.h
+shtty.o: ${BUILD_DIR}/config.h
strcasecmp.o: ${BUILD_DIR}/config.h
strerror.o: ${BUILD_DIR}/config.h
+strpbrk.o: ${BUILD_DIR}/config.h
strtod.o: ${BUILD_DIR}/config.h
strtol.o: ${BUILD_DIR}/config.h
strtoul.o: ${BUILD_DIR}/config.h
+times.o: ${BUILD_DIR}/config.h
+timeval.o: ${BUILD_DIR}/config.h
vprint.o: ${BUILD_DIR}/config.h
+zread.o: ${BUILD_DIR}/config.h
+zwrite.o: ${BUILD_DIR}/config.h
clktck.o: ${topdir}/bashtypes.h
-getcwd.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${topdir}/maxpath.h
-getcwd.o: ${POSIX_INC}/posixstat.h ${POSIX_INC}/posixdir.h
-getcwd.o: ${POSIX_INC}/memalloc.h ${POSIX_INC}/ansi_stdlib.h
+getcwd.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/maxpath.h
+getcwd.o: ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/posixdir.h
+getcwd.o: ${BASHINCDIR}/memalloc.h ${BASHINCDIR}/ansi_stdlib.h
-getenv.o: ${topdir}/bashansi.h ${topdir}/ansi_stdlib.h
-getenv.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${topdir}/posixjmp.h
-getenv.o: ${topdir}/command.h ${topdir}/stdc.h ${topdir}/error.h
+getenv.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+getenv.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
+getenv.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
getenv.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h
getenv.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
getenv.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
getenv.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
getenv.o: ${topdir}/pathnames.h ${topdir}/externs.h
-itos.o: ${topdir}/bashansi.h ${topdir}/ansi_stdlib.h
-itos.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${topdir}/posixjmp.h
-itos.o: ${topdir}/command.h ${topdir}/stdc.h ${topdir}/error.h
+inet_aton.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+inet_aton.o: ${BASHINCDIR}/stdc.h
+
+itos.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+itos.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
+itos.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
itos.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h
itos.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
itos.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
itos.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
itos.o: ${topdir}/pathnames.h ${topdir}/externs.h
-oslib.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${topdir}/maxpath.h
-oslib.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${topdir}/posixjmp.h
-oslib.o: ${topdir}/command.h ${topdir}/stdc.h ${topdir}/error.h
+netopen.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+
+oslib.o: ${topdir}/bashtypes.h ${topdir}/bashansi.h ${BASHINCDIR}/maxpath.h
+oslib.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
+oslib.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
oslib.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h
oslib.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
oslib.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
oslib.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
oslib.o: ${topdir}/pathnames.h ${topdir}/externs.h
-oslib.o: ${POSIX_INC}/posixstat.h ${POSIX_INC}/filecntl.h
-oslib.o: ${POSIX_INC}/ansi_stdlib.h
+oslib.o: ${BASHINCDIR}/posixstat.h ${BASHINCDIR}/filecntl.h
+oslib.o: ${BASHINCDIR}/ansi_stdlib.h
-rename.o: ${topdir}/bashtypes.h ${topdir}/stdc.h
+rename.o: ${topdir}/bashtypes.h ${BASHINCDIR}/stdc.h
-strcasecmp.o: ${topdir}/stdc.h ${topdir}/bashansi.h ${topdir}/ansi_stdlib.h
+shtty.o: ${BASHINCDIR}/shtty.h
+shtty.o: ${BASHINCDIR}/stdc.h
+
+strcasecmp.o: ${BASHINCDIR}/stdc.h ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
strerror.o: ${topdir}/bashtypes.h
-strerror.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${topdir}/posixjmp.h
-strerror.o: ${topdir}/command.h ${topdir}/stdc.h ${topdir}/error.h
+strerror.o: ${topdir}/shell.h ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
+strerror.o: ${topdir}/command.h ${BASHINCDIR}/stdc.h ${topdir}/error.h
strerror.o: ${topdir}/general.h ${topdir}/bashtypes.h ${topdir}/variables.h
strerror.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
strerror.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
strerror.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
strerror.o: ${topdir}/pathnames.h ${topdir}/externs.h
+strpbrk.o: ${BASHINCDIR}/stdc.h
+
strtod.o: ${topdir}/bashansi.h
-strtod.o: ${POSIX_INC}/ansi_stdlib.h
+strtod.o: ${BASHINCDIR}/ansi_stdlib.h
strtol.o: ${topdir}/bashansi.h
-strtol.o: ${POSIX_INC}/ansi_stdlib.h
+strtol.o: ${BASHINCDIR}/ansi_stdlib.h
strtoul.o: ${topdir}/bashansi.h
-strtoul.o: ${POSIX_INC}/ansi_stdlib.h
+strtoul.o: ${BASHINCDIR}/ansi_stdlib.h
+
+times.o: ${BASHINCDIR}/systimes.h
+times.o: ${BASHINCDIR}/posixtime.h
+
+timeval.o: ${BASHINCDIR}/posixtime.h
+
+clock.o: ${BASHINCDIR}/posixtime.h
diff --git a/lib/sh/clock.c b/lib/sh/clock.c
new file mode 100644
index 0000000..9a91e38
--- /dev/null
+++ b/lib/sh/clock.c
@@ -0,0 +1,78 @@
+/* clock.c - operations on struct tms and clock_t's */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA */
+
+#include <config.h>
+
+#if defined (HAVE_TIMES)
+
+#include <sys/types.h>
+#include <posixtime.h>
+
+#if defined (HAVE_SYS_TIMES_H)
+# include <sys/times.h>
+#endif
+
+#include <stdio.h>
+
+void
+clock_t_to_secs (t, sp, sfp)
+ clock_t t;
+ long *sp;
+ int *sfp;
+{
+ static long clk_tck = -1;
+
+ if (clk_tck == -1)
+ clk_tck = get_clk_tck ();
+
+ *sfp = t % clk_tck;
+ *sfp = (*sfp * 1000) / clk_tck;
+
+ *sp = t / clk_tck;
+
+ /* Sanity check */
+ if (*sfp >= 1000)
+ {
+ *sp += 1;
+ *sfp -= 1000;
+ }
+}
+
+/* Print the time defined by a clock_t (returned by the `times' and `time'
+ system calls) in a standard way to stdio stream FP. This is scaled in
+ terms of the value of CLK_TCK, which is what is returned by the
+ `times' call. */
+void
+print_clock_t (fp, t)
+ FILE *fp;
+ clock_t t;
+{
+ int minutes, seconds_fraction;
+ long seconds;
+
+ clock_t_to_secs (t, &seconds, &seconds_fraction);
+
+ minutes = seconds / 60;
+ seconds %= 60;
+
+ fprintf (fp, "%0dm%0ld.%03ds", minutes, seconds, seconds_fraction);
+}
+#endif /* HAVE_TIMES */
+
diff --git a/lib/sh/getcwd.c b/lib/sh/getcwd.c
index 9a8b31f..d39655d 100644
--- a/lib/sh/getcwd.c
+++ b/lib/sh/getcwd.c
@@ -15,8 +15,8 @@
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If
- not, write to the Free Software Foundation, Inc., 675 Mass Ave,
- Cambridge, MA 02139, USA. */
+ not, write to the Free Software Foundation, Inc.,
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
@@ -64,6 +64,10 @@ extern int errno;
# define lstat stat
#endif
+#if !defined (NULL)
+# define NULL 0
+#endif
+
/* Get the pathname of the current working directory,
and put it in SIZE bytes of BUF. Returns NULL if the
directory couldn't be determined or SIZE was too small.
@@ -138,14 +142,14 @@ getcwd (buf, size)
char *new;
if (dotlist == dots)
{
- new = malloc (dotsize * 2 + 1);
+ new = (char *)malloc (dotsize * 2 + 1);
if (new == NULL)
goto lose;
memcpy (new, dots, dotsize);
}
else
{
- new = realloc ((PTR) dotlist, dotsize * 2 + 1);
+ new = (char *)realloc ((PTR) dotlist, dotsize * 2 + 1);
if (new == NULL)
goto lose;
}
@@ -222,13 +226,13 @@ getcwd (buf, size)
if (pathbuf == path)
{
- new = malloc (pathsize * 2);
+ new = (char *)malloc (pathsize * 2);
if (!new)
goto lose;
}
else
{
- new = realloc ((PTR) pathbuf, (pathsize * 2));
+ new = (char *)realloc ((PTR) pathbuf, (pathsize * 2));
if (!new)
goto lose;
pathp = new + space;
diff --git a/lib/sh/getenv.c b/lib/sh/getenv.c
index 6353615..3d81ee4 100644
--- a/lib/sh/getenv.c
+++ b/lib/sh/getenv.c
@@ -56,7 +56,7 @@ getenv (name)
{
FREE (last_tempenv_value);
- last_tempenv_value = savestring (value_cell (var));
+ last_tempenv_value = value_cell (var) ? savestring (value_cell (var)) : (char *)NULL;
dispose_variable (var);
return (last_tempenv_value);
}
diff --git a/lib/sh/inet_aton.c b/lib/sh/inet_aton.c
new file mode 100644
index 0000000..28cd979
--- /dev/null
+++ b/lib/sh/inet_aton.c
@@ -0,0 +1,205 @@
+/* Snagged from GNU C library, version 2.0.3. */
+
+/*
+ * ++Copyright++ 1983, 1990, 1993
+ * -
+ * Copyright (c) 1983, 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)inet_addr.c 8.1 (Berkeley) 6/17/93";
+static char rcsid[] = "$Id: inet_addr.c,v 1.5 1996/08/14 03:48:37 drepper Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <config.h>
+
+#if !defined (HAVE_INET_ATON) && defined (HAVE_NETWORK) && defined (HAVE_NETINET_IN_H) && defined (HAVE_ARPA_INET_H)
+
+#include <sys/types.h>
+#include <sys/param.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <bashansi.h>
+#include <ctype.h>
+#include <stdc.h>
+
+#ifndef INADDR_NONE
+# define INADDR_NONE 0xffffffff
+#endif
+
+/* these are compatibility routines, not needed on recent BSD releases */
+
+#if 0
+/* Not used, not needed. */
+/*
+ * Ascii internet address interpretation routine.
+ * The value returned is in network order.
+ */
+u_long
+inet_addr(cp)
+ register const char *cp;
+{
+ struct in_addr val;
+
+ if (inet_aton(cp, &val))
+ return (val.s_addr);
+ return (INADDR_NONE);
+}
+#endif
+
+/*
+ * Check whether "cp" is a valid ascii representation
+ * of an Internet address and convert to a binary address.
+ * Returns 1 if the address is valid, 0 if not.
+ * This replaces inet_addr, the return value from which
+ * cannot distinguish between failure and a local broadcast address.
+ */
+int
+inet_aton(cp, addr)
+ register const char *cp;
+ struct in_addr *addr;
+{
+ register u_bits32_t val;
+ register int base, n;
+ register char c;
+ u_int parts[4];
+ register u_int *pp = parts;
+
+ c = *cp;
+ for (;;) {
+ /*
+ * Collect number up to ``.''.
+ * Values are specified as for C:
+ * 0x=hex, 0=octal, isdigit=decimal.
+ */
+ if (!isdigit(c))
+ return (0);
+ val = 0; base = 10;
+ if (c == '0') {
+ c = *++cp;
+ if (c == 'x' || c == 'X')
+ base = 16, c = *++cp;
+ else
+ base = 8;
+ }
+ for (;;) {
+ if (isascii(c) && isdigit(c)) {
+ val = (val * base) + (c - '0');
+ c = *++cp;
+ } else if (base == 16 && isascii(c) && isxdigit(c)) {
+ val = (val << 4) |
+ (c + 10 - (islower(c) ? 'a' : 'A'));
+ c = *++cp;
+ } else
+ break;
+ }
+ if (c == '.') {
+ /*
+ * Internet format:
+ * a.b.c.d
+ * a.b.c (with c treated as 16 bits)
+ * a.b (with b treated as 24 bits)
+ */
+ if (pp >= parts + 3)
+ return (0);
+ *pp++ = val;
+ c = *++cp;
+ } else
+ break;
+ }
+ /*
+ * Check for trailing characters.
+ */
+ if (c != '\0' && (!isascii(c) || !isspace(c)))
+ return (0);
+ /*
+ * Concoct the address according to
+ * the number of parts specified.
+ */
+ n = pp - parts + 1;
+ switch (n) {
+
+ case 0:
+ return (0); /* initial nondigit */
+
+ case 1: /* a -- 32 bits */
+ break;
+
+ case 2: /* a.b -- 8.24 bits */
+ if (val > 0xffffff)
+ return (0);
+ val |= parts[0] << 24;
+ break;
+
+ case 3: /* a.b.c -- 8.8.16 bits */
+ if (val > 0xffff)
+ return (0);
+ val |= (parts[0] << 24) | (parts[1] << 16);
+ break;
+
+ case 4: /* a.b.c.d -- 8.8.8.8 bits */
+ if (val > 0xff)
+ return (0);
+ val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
+ break;
+ }
+ if (addr)
+ addr->s_addr = htonl(val);
+ return (1);
+}
+
+#endif /* !HAVE_INET_ATON */
diff --git a/lib/sh/itos.c b/lib/sh/itos.c
index 5105cb7..dee7883 100644
--- a/lib/sh/itos.c
+++ b/lib/sh/itos.c
@@ -16,7 +16,7 @@
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
- Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
diff --git a/lib/sh/makepath.c b/lib/sh/makepath.c
new file mode 100644
index 0000000..dfc1210
--- /dev/null
+++ b/lib/sh/makepath.c
@@ -0,0 +1,116 @@
+/* makepath.c - glue PATH and DIR together into a full pathname. */
+
+/* Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if defined (HAVE_UNISTD_H)
+# ifdef _MINIX
+# include <sys/types.h>
+# endif
+# include <unistd.h>
+#endif
+
+#include "bashansi.h"
+#include "shell.h"
+
+#include <tilde/tilde.h>
+
+#ifndef NULL
+# define NULL 0
+#endif
+
+/* MAKE SURE THESE AGREE WITH ../../externs.h. */
+
+#ifndef MP_DOTILDE
+# define MP_DOTILDE 0x01
+# define MP_DOCWD 0x02
+# define MP_RMDOT 0x04
+#endif
+
+extern char *get_working_directory __P((char *));
+
+/* Take PATH, an element from, e.g., $CDPATH, and DIR, a directory name,
+ and paste them together into PATH/DIR. Tilde expansion is performed on
+ PATH if (flags & MP_DOTILDE) is non-zero. If PATH is NULL or the empty
+ string, it is converted to the current directory. A full pathname is
+ used if (flags & MP_DOCWD) is non-zero, otherwise `./' is used. If
+ (flags & MP_RMDOT) is non-zero, any `./' is removed from the beginning
+ of DIR. */
+
+#define MAKEDOT() \
+ do { \
+ xpath = xmalloc (2); \
+ xpath[0] = '.'; \
+ xpath[1] = '\0'; \
+ pathlen = 1; \
+ } while (0)
+
+char *
+sh_makepath (path, dir, flags)
+ char *path, *dir;
+ int flags;
+{
+ int dirlen, pathlen;
+ char *ret, *xpath;
+
+ if (path == 0 || *path == '\0')
+ {
+ if (flags & MP_DOCWD)
+ {
+ xpath = get_working_directory ("sh_makepath");
+ if (xpath == 0)
+ {
+ ret = get_string_value ("PWD");
+ if (ret)
+ xpath = savestring (ret);
+ }
+ if (xpath == 0)
+ MAKEDOT();
+ else
+ pathlen = strlen (xpath);
+ }
+ else
+ MAKEDOT();
+ }
+ else
+ {
+ xpath = ((flags & MP_DOTILDE) && *path == '~') ? bash_tilde_expand (path) : path;
+ pathlen = strlen (xpath);
+ }
+
+ dirlen = strlen (dir);
+ if ((flags & MP_RMDOT) && dir[0] == '.' && dir[1] == '/')
+ {
+ dir += 2;
+ dirlen -= 2;
+ }
+
+ ret = xmalloc (2 + dirlen + pathlen);
+ strcpy (ret, xpath);
+ if (xpath[pathlen - 1] != '/')
+ {
+ ret[pathlen++] = '/';
+ ret[pathlen] = '\0';
+ }
+ strcpy (ret + pathlen, dir);
+ if (xpath != path)
+ free (xpath);
+ return (ret);
+}
diff --git a/lib/sh/netopen.c b/lib/sh/netopen.c
new file mode 100644
index 0000000..789a9b3
--- /dev/null
+++ b/lib/sh/netopen.c
@@ -0,0 +1,228 @@
+/*
+ * netopen.c -- functions to make tcp/udp connections
+ *
+ * Chet Ramey
+ * chet@ins.CWRU.Edu
+ */
+
+/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if defined (HAVE_NETWORK)
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#if defined (HAVE_SYS_SOCKET_H)
+# include <sys/socket.h>
+#endif
+
+#if defined (HAVE_NETINET_IN_H)
+# include <netinet/in.h>
+#endif
+
+#if defined (HAVE_NETDB_H)
+# include <netdb.h>
+#endif
+
+#if defined (HAVE_ARPA_INET_H)
+# include <arpa/inet.h>
+#endif
+
+#include <bashansi.h>
+#include <ctype.h>
+#include <errno.h>
+
+#ifndef errno
+extern int errno;
+#endif
+
+#if !defined (HAVE_INET_ATON)
+extern int inet_aton ();
+#endif
+
+extern char *xmalloc ();
+
+/* Stuff the internet address corresponding to HOST into AP, in network
+ byte order. Return 1 on success, 0 on failure. */
+
+static int
+_getaddr (host, ap)
+ char *host;
+ struct in_addr *ap;
+{
+ struct hostent *h;
+ int r;
+
+ r = 0;
+ if (isdigit (host[0]))
+ {
+ /* If the first character is a digit, guess that it's an
+ Internet address and return immediately if inet_aton succeeds. */
+ r = inet_aton (host, ap);
+ if (r)
+ return r;
+ }
+#if !defined (HAVE_GETHOSTBYNAME)
+ return 0;
+#else
+ h = gethostbyname (host);
+ if (h && h->h_addr)
+ {
+ bcopy(h->h_addr, (char *)ap, h->h_length);
+ return 1;
+ }
+#endif
+ return 0;
+
+}
+
+/* Return 1 if SERV is a valid port number and stuff the converted value into
+ PP in network byte order. */
+static int
+_getserv (serv, pp)
+ char *serv;
+ unsigned short *pp;
+{
+ long l;
+ unsigned short s;
+
+ if (legal_number (serv, &l))
+ {
+ if (l > 65535)
+ return 0;
+ s = (unsigned short)(l & 0xFFFF);
+ s = htons (s);
+ if (pp)
+ *pp = s;
+ return 1;
+ }
+ else
+ return 0;
+}
+
+static int
+_netopen(host, serv, typ)
+ char *host, *serv;
+ int typ;
+{
+ struct in_addr ina;
+ struct sockaddr_in sin;
+ unsigned short p;
+ int s;
+ char **cp;
+
+ if (_getaddr(host, &ina) == 0)
+ {
+ internal_error ("%s: host unknown", host);
+ return -1;
+ }
+
+ if (_getserv(serv, &p) == 0)
+ {
+ internal_error("%s: invalid service", serv);
+ return -1;
+ }
+
+ bzero ((char *)&sin, sizeof(sin));
+ sin.sin_family = AF_INET;
+ sin.sin_port = p;
+ sin.sin_addr = ina;
+
+ s = socket(AF_INET, (typ == 't') ? SOCK_STREAM : SOCK_DGRAM, 0);
+ if (s < 0)
+ {
+ sys_error ("socket");
+ return (-1);
+ }
+
+ if (connect (s, (struct sockaddr *)&sin, sizeof (sin)) < 0)
+ {
+ sys_error("connect");
+ close(s);
+ return (-1);
+ }
+
+ return(s);
+}
+
+/*
+ * Open a TCP or UDP connection given a path like `/dev/tcp/host/port' to
+ * host `host' on port `port' and return the connected socket.
+ */
+int
+netopen (path)
+ char *path;
+{
+ char *np, *s, *t;
+ int fd;
+
+ np = xmalloc (strlen (path) + 1);
+ strcpy (np, path);
+
+ s = np + 9;
+ t = strchr (s, '/');
+ if (t == 0)
+ {
+ internal_error ("%s: bad network path specification", path);
+ return -1;
+ }
+ *t++ = '\0';
+ fd = _netopen (s, t, path[5]);
+ free (np);
+
+ return fd;
+}
+
+#if 0
+/*
+ * Open a TCP connection to host `host' on the port defined for service
+ * `serv' and return the connected socket.
+ */
+int
+tcpopen (host, serv)
+ char *host, *serv;
+{
+ return (_netopen (host, serv, 't'));
+}
+
+/*
+ * Open a UDP connection to host `host' on the port defined for service
+ * `serv' and return the connected socket.
+ */
+int
+udpopen (host, serv)
+ char *host, *serv;
+{
+ return _netopen (host, serv, 'u');
+}
+#endif
+
+#else /* !HAVE_NETWORK */
+
+int
+netopen (path)
+ char *path;
+{
+ internal_error ("network operations not supported");
+ return -1;
+}
+
+#endif /* !HAVE_NETWORK */
diff --git a/lib/sh/rename.c b/lib/sh/rename.c
index 799cb69..cc12856 100644
--- a/lib/sh/rename.c
+++ b/lib/sh/rename.c
@@ -2,6 +2,24 @@
* rename - rename a file
*/
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
#include <config.h>
#if !defined (HAVE_RENAME)
diff --git a/lib/sh/setlinebuf.c b/lib/sh/setlinebuf.c
index 05f9579..fb097de 100644
--- a/lib/sh/setlinebuf.c
+++ b/lib/sh/setlinebuf.c
@@ -20,22 +20,44 @@
#include <config.h>
-#if !defined (HAVE_SETLINEBUF)
-
#include <stdio.h>
+extern char *xmalloc();
+
+#if defined (USING_BASH_MALLOC)
+# define LBUF_BUFSIZE 1008
+#else
+# define LBUF_BUFSIZE BUFSIZ
+#endif
+
/* Cause STREAM to buffer lines as opposed to characters or blocks. */
int
-setlinebuf (stream)
+sh_setlinebuf (stream)
FILE *stream;
{
-#if defined (_IOLBF)
+ char *local_linebuf;
+
+#if !defined (HAVE_SETLINEBUF) && !defined (HAVE_SETVBUF)
+ return (0);
+#endif
+
+#if defined (USING_BASH_MALLOC)
+ local_linebuf = xmalloc (LBUF_BUFSIZE);
+#else
+ local_linebuf = (char *)NULL;
+#endif
+
+#if defined (HAVE_SETVBUF)
+
# if defined (SETVBUF_REVERSED)
- setvbuf (stream, _IOLBF, (char *)NULL, BUFSIZ);
+ return (setvbuf (stream, _IOLBF, local_linebuf, LBUF_BUFSIZE));
# else /* !SETVBUF_REVERSED */
- setvbuf (stream, (char *)NULL, _IOLBF, BUFSIZ);
+ return (setvbuf (stream, local_linebuf, _IOLBF, LBUF_BUFSIZE));
# endif /* !SETVBUF_REVERSED */
-#endif /* _IOLBF */
+# else /* !HAVE_SETVBUF */
+
+ setlinebuf (stream));
return (0);
+
+#endif /* !HAVE_SETVBUF */
}
-#endif /* !HAVE_SETLINEBUF */
diff --git a/lib/sh/shquote.c b/lib/sh/shquote.c
new file mode 100644
index 0000000..ab8009d
--- /dev/null
+++ b/lib/sh/shquote.c
@@ -0,0 +1,217 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if defined (HAVE_UNISTD_H)
+# ifdef _MINIX
+# include <sys/types.h>
+# endif
+# include <unistd.h>
+#endif
+
+#include <stdio.h>
+
+#if !defined(slashify_in_quotes)
+# define slashify_in_quotes "\\`$\"\n"
+#endif
+
+extern char *xmalloc ();
+
+/* **************************************************************** */
+/* */
+/* Functions for quoting strings to be re-read as input */
+/* */
+/* **************************************************************** */
+
+/* Return a new string which is the single-quoted version of STRING.
+ Used by alias and trap, among others. */
+char *
+single_quote (string)
+ char *string;
+{
+ register int c;
+ char *result, *r, *s;
+
+ result = xmalloc (3 + (4 * strlen (string)));
+ r = result;
+ *r++ = '\'';
+
+ for (s = string; s && (c = *s); s++)
+ {
+ *r++ = c;
+
+ if (c == '\'')
+ {
+ *r++ = '\\'; /* insert escaped single quote */
+ *r++ = '\'';
+ *r++ = '\''; /* start new quoted string */
+ }
+ }
+
+ *r++ = '\'';
+ *r = '\0';
+
+ return (result);
+}
+
+/* Quote STRING using double quotes. Return a new string. */
+char *
+double_quote (string)
+ char *string;
+{
+ register int c;
+ char *result, *r, *s;
+
+ result = xmalloc (3 + (2 * strlen (string)));
+ r = result;
+ *r++ = '"';
+
+ for (s = string; s && (c = *s); s++)
+ {
+ switch (c)
+ {
+ case '"':
+ case '$':
+ case '`':
+ case '\\':
+ case '\n': /* XXX */
+ *r++ = '\\';
+ default:
+ *r++ = c;
+ break;
+ }
+ }
+
+ *r++ = '"';
+ *r = '\0';
+
+ return (result);
+}
+
+/* Remove backslashes that are quoting characters that are special between
+ double quotes. Return a new string. */
+char *
+un_double_quote (string)
+ char *string;
+{
+ register int c, pass_next;
+ char *result, *r, *s;
+
+ r = result = xmalloc (strlen (string) + 1);
+
+ for (pass_next = 0, s = string; s && (c = *s); s++)
+ {
+ if (pass_next)
+ {
+ *r++ = c;
+ pass_next = 0;
+ continue;
+ }
+ if (c == '\\' && strchr (slashify_in_quotes, s[1]))
+ {
+ pass_next = 1;
+ continue;
+ }
+ *r++ = c;
+ }
+
+ *r = '\0';
+ return result;
+}
+
+/* Quote special characters in STRING using backslashes. Return a new
+ string. */
+char *
+backslash_quote (string)
+ char *string;
+{
+ int c;
+ char *result, *r, *s;
+
+ result = xmalloc (2 * strlen (string) + 1);
+
+ for (r = result, s = string; s && (c = *s); s++)
+ {
+ switch (c)
+ {
+ case ' ': case '\t': case '\n': /* IFS white space */
+ case '\'': case '"': case '\\': /* quoting chars */
+ case '|': case '&': case ';': /* shell metacharacters */
+ case '(': case ')': case '<': case '>':
+ case '!': case '{': case '}': /* reserved words */
+ case '*': case '[': case '?': case ']': /* globbing chars */
+ case '^':
+ case '$': case '`': /* expansion chars */
+ *r++ = '\\';
+ *r++ = c;
+ break;
+#if 0
+ case '~': /* tilde expansion */
+ if (s == string || s[-1] == '=' || s[-1] == ':')
+ *r++ = '\\';
+ *r++ = c;
+ break;
+#endif
+ case '#': /* comment char */
+ if (s == string)
+ *r++ = '\\';
+ /* FALLTHROUGH */
+ default:
+ *r++ = c;
+ break;
+ }
+ }
+
+ *r = '\0';
+ return (result);
+}
+
+int
+contains_shell_metas (string)
+ char *string;
+{
+ char *s;
+
+ for (s = string; s && *s; s++)
+ {
+ switch (*s)
+ {
+ case ' ': case '\t': case '\n': /* IFS white space */
+ case '\'': case '"': case '\\': /* quoting chars */
+ case '|': case '&': case ';': /* shell metacharacters */
+ case '(': case ')': case '<': case '>':
+ case '!': case '{': case '}': /* reserved words */
+ case '*': case '[': case '?': case ']': /* globbing chars */
+ case '^':
+ case '$': case '`': /* expansion chars */
+ return (1);
+ case '~': /* tilde expansion */
+ if (s == string || s[-1] == '=' || s[-1] == ':')
+ return (1);
+ case '#':
+ if (s == string) /* comment char */
+ return (1);
+ /* FALLTHROUGH */
+ default:
+ break;
+ }
+ }
+
+ return (0);
+}
diff --git a/lib/sh/shtty.c b/lib/sh/shtty.c
new file mode 100644
index 0000000..15cc82f
--- /dev/null
+++ b/lib/sh/shtty.c
@@ -0,0 +1,284 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+/*
+ * shtty.c -- abstract interface to the terminal, focusing on capabilities.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <shtty.h>
+
+static TTYSTRUCT ttin, ttout;
+static int ttsaved = 0;
+
+int
+ttgetattr(fd, ttp)
+int fd;
+TTYSTRUCT *ttp;
+{
+#ifdef TERMIOS_TTY_DRIVER
+ return tcgetattr(fd, ttp);
+#else
+# ifdef TERMIO_TTY_DRIVER
+ return ioctl(fd, TCGETA, ttp);
+# else
+ return ioctl(fd, TIOCGETP, ttp);
+# endif
+#endif
+}
+
+int
+ttsetattr(fd, ttp)
+int fd;
+TTYSTRUCT *ttp;
+{
+#ifdef TERMIOS_TTY_DRIVER
+ return tcsetattr(fd, TCSADRAIN, ttp);
+#else
+# ifdef TERMIO_TTY_DRIVER
+ return ioctl(fd, TCSETAW, ttp);
+# else
+ return ioctl(fd, TIOCSETN, ttp);
+# endif
+#endif
+}
+
+void
+ttsave()
+{
+ if (ttsaved)
+ return;
+ ttgetattr (0, &ttin);
+ ttgetattr (1, &ttout);
+ ttsaved = 1;
+}
+
+void
+ttrestore()
+{
+ if (ttsaved == 0)
+ return;
+ ttsetattr (0, &ttin);
+ ttsetattr (1, &ttout);
+ ttsaved = 0;
+}
+
+/* Retrieve the attributes associated with tty fd FD. */
+TTYSTRUCT *
+ttattr (fd)
+ int fd;
+{
+ if (ttsaved == 0)
+ return ((TTYSTRUCT *)0);
+ if (fd == 0)
+ return &ttin;
+ else if (fd == 1)
+ return &ttout;
+ else
+ return ((TTYSTRUCT *)0);
+}
+
+/*
+ * Change attributes in ttp so that when it is installed using
+ * ttsetattr, the terminal will be in one-char-at-a-time mode.
+ */
+int
+tt_setonechar(ttp)
+ TTYSTRUCT *ttp;
+{
+#if defined (TERMIOS_TTY_DRIVER) || defined (TERMIO_TTY_DRIVER)
+
+ /* XXX - might not want this -- it disables erase and kill processing. */
+ ttp->c_lflag &= ~ICANON;
+
+ ttp->c_lflag |= ISIG;
+# ifdef IEXTEN
+ ttp->c_lflag |= IEXTEN;
+# endif
+
+ ttp->c_iflag |= ICRNL; /* make sure we get CR->NL on input */
+ ttp->c_iflag &= ~INLCR; /* but no NL->CR */
+
+# ifdef OPOST
+ ttp->c_oflag |= OPOST;
+# endif
+# ifdef ONLCR
+ ttp->c_oflag |= ONLCR;
+# endif
+# ifdef OCRNL
+ ttp->c_oflag &= ~OCRNL;
+# endif
+# ifdef ONOCR
+ ttp->c_oflag &= ~ONOCR;
+# endif
+# ifdef ONLRET
+ ttp->c_oflag &= ~ONLRET;
+# endif
+
+ ttp->c_cc[VMIN] = 1;
+ ttp->c_cc[VTIME] = 0;
+
+#else
+
+ ttp->sg_flags |= CBREAK;
+
+#endif
+
+ return 0;
+}
+
+/* Set the terminal into one-character-at-a-time mode */
+int
+ttonechar ()
+{
+ TTYSTRUCT tt;
+
+ if (ttsaved == 0)
+ return -1;
+ tt = ttin;
+ if (tt_setonechar(&tt) < 0)
+ return -1;
+ return (ttsetattr (0, &tt));
+}
+
+/*
+ * Change attributes in ttp so that when it is installed using
+ * ttsetattr, the terminal will be in no-echo mode.
+ */
+int
+tt_setnoecho(ttp)
+ TTYSTRUCT *ttp;
+{
+#if defined (TERMIOS_TTY_DRIVER) || defined (TERMIO_TTY_DRIVER)
+ ttp->c_lflag &= ~(ECHO|ECHOK|ECHONL);
+#else
+ ttp->sg_flags &= ~ECHO;
+#endif
+
+ return 0;
+}
+
+/* Set the terminal into no-echo mode */
+int
+ttnoecho ()
+{
+ TTYSTRUCT tt;
+
+ if (ttsaved == 0)
+ return -1;
+ tt = ttin;
+ if (tt_setnoecho (&tt) < 0)
+ return -1;
+ return (ttsetattr (0, &tt));
+}
+
+/*
+ * Change attributes in ttp so that when it is installed using
+ * ttsetattr, the terminal will be in eight-bit mode (pass8).
+ */
+int
+tt_seteightbit (ttp)
+ TTYSTRUCT *ttp;
+{
+#if defined (TERMIOS_TTY_DRIVER) || defined (TERMIO_TTY_DRIVER)
+ ttp->c_iflag &= ~ISTRIP;
+ ttp->c_cflag |= CS8;
+ ttp->c_cflag &= ~PARENB;
+#else
+ ttp->sg_flags |= ANYP;
+#endif
+
+ return 0;
+}
+
+/* Set the terminal into eight-bit mode */
+int
+tteightbit ()
+{
+ TTYSTRUCT tt;
+
+ if (ttsaved == 0)
+ return -1;
+ tt = ttin;
+ if (tt_seteightbit (&tt) < 0)
+ return -1;
+ return (ttsetattr (0, &tt));
+}
+
+/*
+ * Change attributes in ttp so that when it is installed using
+ * ttsetattr, the terminal will be in non-canonical input mode.
+ */
+int
+tt_setnocanon (ttp)
+ TTYSTRUCT *ttp;
+{
+#if defined (TERMIOS_TTY_DRIVER) || defined (TERMIO_TTY_DRIVER)
+ ttp->c_lflag &= ~ICANON;
+#endif
+
+ return 0;
+}
+
+/* Set the terminal into non-canonical mode */
+int
+ttnocanon ()
+{
+ TTYSTRUCT tt;
+
+ if (ttsaved == 0)
+ return -1;
+ tt = ttin;
+ if (tt_setnocanon (&tt) < 0)
+ return -1;
+ return (ttsetattr (0, &tt));
+}
+
+/*
+ * Change attributes in ttp so that when it is installed using
+ * ttsetattr, the terminal will be in cbreak, no-echo mode.
+ */
+int
+tt_setcbreak(ttp)
+ TTYSTRUCT *ttp;
+{
+ if (tt_setonechar (ttp) < 0)
+ return -1;
+ return (tt_setnoecho (ttp));
+}
+
+/* Set the terminal into cbreak (no-echo, one-character-at-a-time) mode */
+int
+ttcbreak ()
+{
+ TTYSTRUCT tt;
+
+ if (ttsaved == 0)
+ return -1;
+ tt = ttin;
+ if (tt_setcbreak (&tt) < 0)
+ return -1;
+ return (ttsetattr (0, &tt));
+}
diff --git a/lib/sh/strpbrk.c b/lib/sh/strpbrk.c
new file mode 100644
index 0000000..3c493a8
--- /dev/null
+++ b/lib/sh/strpbrk.c
@@ -0,0 +1,44 @@
+/* Copyright (C) 1991, 1994 Free Software Foundation, Inc.
+ NOTE: The canonical source of this file is maintained with the GNU C Library.
+ Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2, or (at your option) any
+ later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if !defined (HAVE_STRPBRK)
+
+#include <stdc.h>
+
+/* Find the first ocurrence in S of any character in ACCEPT. */
+char *
+strpbrk (s, accept)
+ register const char *s;
+ register const char *accept;
+{
+ while (*s != '\0')
+ {
+ const char *a = accept;
+ while (*a != '\0')
+ if (*a++ == *s)
+ return (char *) s;
+ ++s;
+ }
+
+ return 0;
+}
+#endif
diff --git a/lib/sh/times.c b/lib/sh/times.c
new file mode 100644
index 0000000..240aafe
--- /dev/null
+++ b/lib/sh/times.c
@@ -0,0 +1,77 @@
+/* times.c - times(3) library function */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if !defined (HAVE_TIMES)
+
+#include <sys/types.h>
+#include <posixtime.h>
+#include <systimes.h>
+
+#if defined (HAVE_SYS_RESOURCE_H) && defined (HAVE_GETRUSAGE)
+# include <sys/resource.h>
+#endif /* HAVE_SYS_RESOURCE_H && HAVE_GETRUSAGE */
+
+extern long get_clk_tck();
+
+#define CONVTCK(r) (r.tv_sec * clk_tck + r.tv_usec / (1000000 / clk_tck))
+
+clock_t
+times(tms)
+ struct tms *tms;
+{
+ clock_t rv;
+ static long clk_tck = -1;
+
+#if defined (HAVE_GETRUSAGE)
+ struct timeval tv;
+ struct rusage ru;
+
+ if (clk_tck == -1)
+ clk_tck = get_clk_tck();
+
+ if (getrusage(RUSAGE_SELF, &ru) < 0)
+ return ((clock_t)-1);
+ tms->tms_utime = CONVTCK(ru.ru_utime);
+ tms->tms_stime = CONVTCK(ru.ru_stime);
+
+ if (getrusage(RUSAGE_CHILDREN, &ru) < 0)
+ return ((clock_t)-1);
+ tms->tms_cutime = CONVTCK(ru.ru_utime);
+ tms->tms_cstime = CONVTCK(ru.ru_stime);
+
+ if (gettimeofday(&tv, (struct timezone *) 0) < 0)
+ return ((clock_t)-1);
+ rv = (clock_t)(CONVTCK(tv));
+#else /* !HAVE_GETRUSAGE */
+ if (clk_tck == -1)
+ clk_tck = get_clk_tck();
+
+ /* We can't do anything. */
+ tms->tms_utime = tms->tms_stime = (clock_t)0;
+ tms->tms_cutime = tms->tms_cstime = (clock_t)0;
+
+ rv = (clock_t)time((time_t *)0) * clk_tck;
+# endif /* HAVE_GETRUSAGE */
+
+ return rv;
+}
+#endif /* !HAVE_TIMES */
diff --git a/lib/sh/timeval.c b/lib/sh/timeval.c
new file mode 100644
index 0000000..809d411
--- /dev/null
+++ b/lib/sh/timeval.c
@@ -0,0 +1,144 @@
+/* timeval.c - functions to perform operations on struct timevals */
+
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#if defined (HAVE_TIMEVAL)
+
+#include <sys/types.h>
+#include <posixtime.h>
+
+#include <stdio.h>
+
+struct timeval *
+difftimeval (d, t1, t2)
+ struct timeval *d, *t1, *t2;
+{
+ d->tv_sec = t2->tv_sec - t1->tv_sec;
+ d->tv_usec = t2->tv_usec - t1->tv_usec;
+ if (d->tv_usec < 0)
+ {
+ d->tv_usec += 1000000;
+ d->tv_sec -= 1;
+ if (d->tv_sec < 0) /* ??? -- BSD/OS does this */
+ {
+ d->tv_sec = 0;
+ d->tv_usec = 0;
+ }
+ }
+ return d;
+}
+
+struct timeval *
+addtimeval (d, t1, t2)
+ struct timeval *d, *t1, *t2;
+{
+ d->tv_sec = t1->tv_sec + t2->tv_sec;
+ d->tv_usec = t1->tv_usec + t2->tv_usec;
+ if (d->tv_usec >= 1000000)
+ {
+ d->tv_usec -= 1000000;
+ d->tv_sec += 1;
+ }
+ return d;
+}
+
+/* Do "cpu = ((user + sys) * 10000) / real;" with timevals.
+ Barely-tested code from Deven T. Corzine <deven@ties.org>. */
+int
+timeval_to_cpu (rt, ut, st)
+ struct timeval *rt, *ut, *st; /* real, user, sys */
+{
+ struct timeval t1, t2;
+ register int i;
+
+ addtimeval (&t1, ut, st);
+ t2.tv_sec = rt->tv_sec;
+ t2.tv_usec = rt->tv_usec;
+
+ for (i = 0; i < 6; i++)
+ {
+ if ((t1.tv_sec > 99999999) || (t2.tv_sec > 99999999))
+ break;
+ t1.tv_sec *= 10;
+ t1.tv_sec += t1.tv_usec / 100000;
+ t1.tv_usec *= 10;
+ t1.tv_usec %= 1000000;
+ t2.tv_sec *= 10;
+ t2.tv_sec += t2.tv_usec / 100000;
+ t2.tv_usec *= 10;
+ t2.tv_usec %= 1000000;
+ }
+ for (i = 0; i < 4; i++)
+ {
+ if (t1.tv_sec < 100000000)
+ t1.tv_sec *= 10;
+ else
+ t2.tv_sec /= 10;
+ }
+
+ return ((t2.tv_sec == 0) ? 0 : t1.tv_sec / t2.tv_sec);
+}
+
+/* Convert a pointer to a struct timeval to seconds and thousandths of a
+ second, returning the values in *SP and *SFP, respectively. This does
+ rounding on the fractional part, not just truncation to three places. */
+void
+timeval_to_secs (tvp, sp, sfp)
+ struct timeval *tvp;
+ long *sp;
+ int *sfp;
+{
+ int rest;
+
+ *sp = tvp->tv_sec;
+
+ *sfp = tvp->tv_usec % 1000000; /* pretty much a no-op */
+ rest = *sfp % 1000;
+ *sfp = (*sfp * 1000) / 1000000;
+ if (rest >= 500)
+ *sfp += 1;
+
+ /* Sanity check */
+ if (*sfp >= 1000)
+ {
+ *sp += 1;
+ *sfp -= 1000;
+ }
+}
+
+/* Print the contents of a struct timeval * in a standard way to stdio
+ stream FP. */
+void
+print_timeval (fp, tvp)
+ FILE *fp;
+ struct timeval *tvp;
+{
+ int minutes, seconds_fraction;
+ long seconds;
+
+ timeval_to_secs (tvp, &seconds, &seconds_fraction);
+
+ minutes = seconds / 60;
+ seconds %= 60;
+
+ fprintf (fp, "%0dm%0ld.%03ds", minutes, seconds, seconds_fraction);
+}
+#endif /* HAVE_TIMEVAL */
diff --git a/lib/sh/vprint.c b/lib/sh/vprint.c
index 63ea3bf..929bdbc 100644
--- a/lib/sh/vprint.c
+++ b/lib/sh/vprint.c
@@ -6,7 +6,7 @@ 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 1, or (at your option) any later
+Software Foundation; either version 2, or (at your option) any later
version.
Bash is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -16,7 +16,7 @@ for more details.
You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software
-Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <config.h>
diff --git a/lib/sh/zread.c b/lib/sh/zread.c
new file mode 100644
index 0000000..0b23b38
--- /dev/null
+++ b/lib/sh/zread.c
@@ -0,0 +1,127 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#include <sys/types.h>
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#include <errno.h>
+
+#if !defined (errno)
+extern int errno;
+#endif
+
+#ifndef SEEK_CUR
+# define SEEK_CUR 1
+#endif
+
+/* Read LEN bytes from FD into BUF. Retry the read on EINTR. Any other
+ error causes the loop to break. */
+int
+zread (fd, buf, len)
+ int fd;
+ char *buf;
+ size_t len;
+{
+ int r;
+
+ while ((r = read (fd, buf, len)) < 0 && errno == EINTR)
+ ;
+ return r;
+}
+
+/* Read LEN bytes from FD into BUF. Retry the read on EINTR, up to three
+ interrupts. Any other error causes the loop to break. */
+
+#ifdef NUM_INTR
+# undef NUM_INTR
+#endif
+#define NUM_INTR 3
+
+int
+zread1 (fd, buf, len)
+ int fd;
+ char *buf;
+ size_t len;
+{
+ int r, nintr;
+
+ for (nintr = 0; ; )
+ {
+ r = read (fd, buf, len);
+ if (r >= 0)
+ return r;
+ if (r == -1 && errno == EINTR)
+ {
+ if (++nintr > NUM_INTR)
+ return -1;
+ continue;
+ }
+ return r;
+ }
+}
+
+/* Read one character from FD and return it in CP. Return values are as
+ in read(2). This does some local buffering to avoid many one-character
+ calls to read(2), like those the `read' builtin performs. */
+
+static unsigned char lbuf[128];
+static int lind, lused;
+
+int
+zreadc (fd, cp)
+ int fd;
+ char *cp;
+{
+ int r;
+
+ if (lind == lused || lused == 0)
+ {
+ lused = zread (fd, lbuf, sizeof (lbuf));
+ lind = 0;
+ if (lused <= 0)
+ return (lused);
+ }
+ if (cp)
+ *cp = (char)lbuf[lind++];
+ return 1;
+}
+
+void
+zreset ()
+{
+ lind = lused = 0;
+}
+
+/* Sync the seek pointer for FD so that the kernel's idea of the last char
+ read is the last char returned by zreadc. */
+void
+zsyncfd (fd)
+ int fd;
+{
+ int off;
+
+ off = lused - lind;
+ if (off > 0)
+ lseek (fd, -off, SEEK_CUR);
+ lused = lind = 0;
+}
diff --git a/lib/sh/zwrite.c b/lib/sh/zwrite.c
new file mode 100644
index 0000000..25550f8
--- /dev/null
+++ b/lib/sh/zwrite.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 1999 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it under
+ the terms of the GNU General Public License as published by the Free
+ Software Foundation; either version 2, or (at your option) any later
+ version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Bash; see the file COPYING. If not, write to the Free Software
+ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#include <config.h>
+
+#include <sys/types.h>
+
+#if defined (HAVE_UNISTD_H)
+# include <unistd.h>
+#endif
+
+#include <errno.h>
+
+#if !defined (errno)
+extern int errno;
+#endif
+
+/* Write NB bytes from BUF to file descriptor FD, retrying the write if
+ it is interrupted. We retry three times if we get a zero-length
+ write. Any other signal causes this function to return prematurely. */
+int
+zwrite (fd, buf, nb)
+ int fd;
+ unsigned char *buf;
+ size_t nb;
+{
+ int n, i, nt;
+
+ for (n = nb, nt = 0;;)
+ {
+ i = write (fd, buf, n);
+ if (i > 0)
+ {
+ n -= i;
+ if (n <= 0)
+ return nb;
+ }
+ else if (i == 0)
+ {
+ if (++nt > 3)
+ return (nb - n);
+ }
+ else if (errno != EINTR)
+ return -1;
+ }
+}
diff --git a/lib/termcap/Makefile.in b/lib/termcap/Makefile.in
index d5d33bc..1ed2c27 100644
--- a/lib/termcap/Makefile.in
+++ b/lib/termcap/Makefile.in
@@ -4,6 +4,22 @@
# #
####################################################################
+# Copyright (C) 1996 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
@@ -29,7 +45,7 @@ LDFLAGS = @LDFLAGS@
DEFS = @DEFS@
-INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib
+INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib -I$(srcdir)
CCFLAGS = $(CFLAGS) $(DEFS) $(CPPFLAGS) ${INCLUDES}
@@ -59,7 +75,10 @@ install:
clean:
$(RM) *.o *.a *.log *.cp *.tp *.vr *.fn *.aux *.pg *.toc
-mostlyclean distclean maintainer-clean: clean
+mostlyclean: clean
+
+distclean maintainer-clean: clean
+ $(RM) Makefile
$(DESTDIR)/libtermcap.a: libtermcap.a
${INSTALL_DATA} -c -m 644 libtermcap.a $@
diff --git a/lib/termcap/grot/COPYING b/lib/termcap/grot/COPYING
index a43ea21..2b940a4 100644
--- a/lib/termcap/grot/COPYING
+++ b/lib/termcap/grot/COPYING
@@ -2,10 +2,18 @@
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
- 675 Mass Ave, Cambridge, MA 02139, USA
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
+The Free Software Foundation has exempted Bash from the requirement of
+Paragraph 2c of the General Public License. This is to say, there is
+no requirement for Bash to print a notice when it is started
+interactively in the usual way. We made this exception because users
+and standards expect shells not to print such messages. This
+exception applies to any program that serves as a shell and that is
+based primarily on Bash as opposed to other GNU software.
+
Preamble
The licenses for most software are designed to take away your
@@ -305,7 +313,7 @@ the "copyright" line and a pointer to where the full notice is found.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Also add information on how to contact you by electronic and paper mail.
diff --git a/lib/termcap/grot/Makefile.in b/lib/termcap/grot/Makefile.in
index 66e5d02..e6f06ae 100644
--- a/lib/termcap/grot/Makefile.in
+++ b/lib/termcap/grot/Makefile.in
@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
-# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
#### Start of system configuration section. ####
diff --git a/lib/termcap/grot/termcap.texi b/lib/termcap/grot/termcap.texi
index 7a6cd56..eab49e8 100644
--- a/lib/termcap/grot/termcap.texi
+++ b/lib/termcap/grot/termcap.texi
@@ -61,7 +61,7 @@ by the Foundation.
Copyright @copyright{} 1988 Free Software Foundation, Inc.
Published by the Free Software Foundation
-(675 Mass Ave, Cambridge MA 02139).
+(59 Temple Place, Suite 330, Boston, MA 02111 USA).
Printed copies are available for $10 each.
Permission is granted to make and distribute verbatim copies of
@@ -3615,4 +3615,3 @@ Flag: Teleray 1061; several strange characteristics.
@contents
@bye
-
diff --git a/lib/termcap/ltcap.h b/lib/termcap/ltcap.h
new file mode 100644
index 0000000..507481f
--- /dev/null
+++ b/lib/termcap/ltcap.h
@@ -0,0 +1,29 @@
+/* Local declarations for termcap library.
+ Copyright (C) 1999 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
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
+
+#ifndef _LTCAP_H_
+#define _LTCAP_H_ 1
+
+#if !defined (__APPLE__)
+# define __private_extern__
+#endif
+
+#ifndef MAX_TGETENT_BUFSIZ
+# define MAX_TGETENT_BUFSIZ 2048
+#endif
+
+#endif /* _LTCAP_H_ */
diff --git a/lib/termcap/termcap.c b/lib/termcap/termcap.c
index eb690c9..eaf9471 100644
--- a/lib/termcap/termcap.c
+++ b/lib/termcap/termcap.c
@@ -12,8 +12,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with this program; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; see the file COPYING. If not, write to the
+Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Emacs config.h may rename various library functions such as malloc. */
#ifdef HAVE_CONFIG_H
@@ -27,6 +27,14 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <fcntl.h>
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+extern char *getenv ();
+extern char *malloc ();
+extern char *realloc ();
+#endif
+
#else /* not HAVE_CONFIG_H */
#ifdef STDC_HEADERS
@@ -77,6 +85,8 @@ int bufsize = 128;
#endif
#endif
+#include "ltcap.h"
+
#ifndef TERMCAP_FILE
#define TERMCAP_FILE "/etc/termcap"
#endif
@@ -137,6 +147,7 @@ find_capability (bp, cap)
return NULL;
}
+__private_extern__
int
tgetnum (cap)
char *cap;
@@ -147,6 +158,7 @@ tgetnum (cap)
return atoi (ptr);
}
+__private_extern__
int
tgetflag (cap)
char *cap;
@@ -160,6 +172,7 @@ tgetflag (cap)
to store the string. That pointer is advanced over the space used.
If AREA is null, space is allocated with `malloc'. */
+__private_extern__
char *
tgetstr (cap, area)
char *cap;
@@ -264,7 +277,7 @@ tgetst1 (ptr, area)
short ospeed;
/* If OSPEED is 0, we use this as the actual baud rate. */
int tputs_baud_rate;
-char PC;
+__private_extern__ char PC = '\0';
/* Actual baud rate if positive;
- baud rate / 100 if negative. */
@@ -280,6 +293,7 @@ static int speeds[] =
#endif /* not VMS */
};
+__private_extern__
void
tputs (str, nlines, outfun)
register char *str;
@@ -299,8 +313,10 @@ tputs (str, nlines, outfun)
#else
if (ospeed == 0)
speed = tputs_baud_rate;
- else
+ else if (ospeed > 0 && ospeed < (sizeof speeds / sizeof speeds[0]))
speed = speeds[ospeed];
+ else
+ speed = 0;
#endif
if (!str)
@@ -393,7 +409,8 @@ static int
valid_filename_p (fn)
char *fn;
{
- return *fn == '/' || fn[1] == ':';
+ return *fn == '\\' || *fn == '/' ||
+ (*fn >= 'A' && *fn <= 'z' && fn[1] == ':');
}
#else
#define valid_filename_p(fn) (*(fn) == '/')
@@ -412,6 +429,7 @@ valid_filename_p (fn)
0 if the data base is accessible but the type NAME is not defined
in it, and some other value otherwise. */
+__private_extern__
int
tgetent (bp, name)
char *bp, *name;
@@ -452,12 +470,14 @@ tgetent (bp, name)
termcap_name = getenv ("TERMCAP");
if (termcap_name && *termcap_name == '\0')
termcap_name = NULL;
+#if 0
#if defined (MSDOS) && !defined (TEST)
if (termcap_name && (*termcap_name == '\\'
|| *termcap_name == '/'
|| termcap_name[1] == ':'))
dostounix_filename(termcap_name);
#endif
+#endif
filep = termcap_name && valid_filename_p (termcap_name);
diff --git a/lib/termcap/termcap.h b/lib/termcap/termcap.h
index b19fb0a..40c2e29 100644
--- a/lib/termcap/termcap.h
+++ b/lib/termcap/termcap.h
@@ -13,7 +13,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _TERMCAP_H
#define _TERMCAP_H 1
diff --git a/lib/termcap/tparam.c b/lib/termcap/tparam.c
index 2470289..1c83f04 100644
--- a/lib/termcap/tparam.c
+++ b/lib/termcap/tparam.c
@@ -12,12 +12,21 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
-along with this program; see the file COPYING. If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+along with this program; see the file COPYING. If not, write to the
+Free Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* Emacs config.h may rename various library functions such as malloc. */
#ifdef HAVE_CONFIG_H
#include <config.h>
+
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#else
+extern char *getenv ();
+extern char *malloc ();
+extern char *realloc ();
+#endif
+
#else /* not HAVE_CONFIG_H */
#if defined(HAVE_STRING_H) || defined(STDC_HEADERS)
@@ -34,6 +43,8 @@ char *realloc ();
#endif /* not HAVE_CONFIG_H */
+#include "ltcap.h"
+
#ifndef NULL
#define NULL (char *) 0
#endif
@@ -101,11 +112,12 @@ tparam (string, outstring, len, arg0, arg1, arg2, arg3)
return tparam1 (string, outstring, len, NULL, NULL, arg);
}
-char *BC;
-char *UP;
+__private_extern__ char *BC;
+__private_extern__ char *UP;
static char tgoto_buf[50];
+__private_extern__
char *
tgoto (cm, hpos, vpos)
char *cm;
diff --git a/lib/termcap/version.c b/lib/termcap/version.c
index f5623a2..be7d9e7 100644
--- a/lib/termcap/version.c
+++ b/lib/termcap/version.c
@@ -1,2 +1,2 @@
/* Make the library identifiable with the RCS ident command. */
-static char *version_string = "\n$Version: GNU termcap 1.3 $\n";
+static char *termcap_version_string = "\n$Version: GNU termcap 1.3 $\n";
diff --git a/lib/tilde/Makefile.in b/lib/tilde/Makefile.in
index 55b8d5a..35543b5 100644
--- a/lib/tilde/Makefile.in
+++ b/lib/tilde/Makefile.in
@@ -4,6 +4,22 @@
# #
####################################################################
+# Copyright (C) 1996 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
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
+
srcdir = @srcdir@
VPATH = .:@srcdir@
topdir = @top_srcdir@
@@ -31,7 +47,9 @@ LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@
DEFS = @DEFS@
LOCAL_DEFS = @LOCAL_DEFS@
-INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib
+BASHINCDIR = ${topdir}/include
+
+INCLUDES = -I. -I../.. -I$(topdir) -I${BASHINCDIR} -I$(topdir)/lib
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
@@ -99,7 +117,7 @@ mostlyclean: clean
# #
######################################################################
-tilde.o: tilde.h $(topdir)/ansi_stdlib.h
+tilde.o: tilde.h $(BASHINCDIR)/ansi_stdlib.h
tilde.o: $(BUILD_DIR)/config.h
# Rules for deficient makes, like SunOS and Solaris
diff --git a/lib/tilde/shell.c b/lib/tilde/shell.c
index 91b1aaf..a45af2d 100644
--- a/lib/tilde/shell.c
+++ b/lib/tilde/shell.c
@@ -7,7 +7,7 @@
The GNU Tilde Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Tilde Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
diff --git a/lib/tilde/tilde.c b/lib/tilde/tilde.c
index d1853bd..777b655 100644
--- a/lib/tilde/tilde.c
+++ b/lib/tilde/tilde.c
@@ -7,7 +7,7 @@
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 1, or (at your option) any
+ Free Software Foundation; either version 2, or (at your option) any
later version.
Readline is distributed in the hope that it will be useful, but
@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free
- Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
@@ -47,12 +47,22 @@
#include "tilde.h"
+#if defined (TEST) || defined (STATIC_MALLOC)
+static char *xmalloc (), *xrealloc ();
+#else
+# if defined __STDC__
+extern char *xmalloc (int);
+extern char *xrealloc (void *, int);
+# else
+extern char *xmalloc (), *xrealloc ();
+# endif /* !__STDC__ */
+#endif /* TEST || STATIC_MALLOC */
+
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid (), *getpwnam ();
#endif /* !HAVE_GETPW_DECLS */
#if !defined (savestring)
-extern char *xmalloc ();
# ifndef strcpy
extern char *strcpy ();
# endif
@@ -67,17 +77,11 @@ extern char *strcpy ();
# endif /* !__STDC__ */
#endif /* !NULL */
-#if defined (TEST) || defined (STATIC_MALLOC)
-static char *xmalloc (), *xrealloc ();
-#else
-extern char *xmalloc (), *xrealloc ();
-#endif /* TEST || STATIC_MALLOC */
-
/* If being compiled as part of bash, these will be satisfied from
variables.o. If being compiled as part of readline, they will
be satisfied from shell.o. */
-extern char *get_home_dir ();
-extern char *get_env_value ();
+extern char *get_home_dir __P((void));
+extern char *get_env_value __P((char *));
/* The default value of tilde_additional_prefixes. This is set to
whitespace preceding a tilde so that simple programs which do not
@@ -122,7 +126,9 @@ tilde_find_prefix (string, len)
int *len;
{
register int i, j, string_len;
- register char **prefixes = tilde_additional_prefixes;
+ register char **prefixes;
+
+ prefixes = tilde_additional_prefixes;
string_len = strlen (string);
*len = 0;
@@ -161,7 +167,11 @@ tilde_find_suffix (string)
for (i = 0; i < string_len; i++)
{
+#if defined (__MSDOS__)
+ if (string[i] == '/' || string[i] == '\\' /* || !string[i] */)
+#else
if (string[i] == '/' /* || !string[i] */)
+#endif
break;
for (j = 0; suffixes && suffixes[j]; j++)
@@ -225,11 +235,18 @@ tilde_expand (string)
free (tilde_word);
len = strlen (expansion);
- if ((result_index + len + 1) > result_size)
- result = xrealloc (result, 1 + (result_size += (len + 20)));
+#ifdef __CYGWIN32__
+ /* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when
+ $HOME for `user' is /. On cygwin, // denotes a network drive. */
+ if (len > 1 || *expansion != '/' || *string != '/')
+#endif
+ {
+ if ((result_index + len + 1) > result_size)
+ result = xrealloc (result, 1 + (result_size += (len + 20)));
- strcpy (result + result_index, expansion);
- result_index += len;
+ strcpy (result + result_index, expansion);
+ result_index += len;
+ }
free (expansion);
}
@@ -250,7 +267,11 @@ isolate_tilde_prefix (fname, lenp)
int i;
ret = xmalloc (strlen (fname));
+#if defined (__MSDOS__)
+ for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
+#else
for (i = 1; fname[i] && fname[i] != '/'; i++)
+#endif
ret[i - 1] = fname[i];
ret[i - 1] = '\0';
if (lenp)
@@ -271,7 +292,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
plen = (prefix && *prefix) ? strlen (prefix) : 0;
slen = strlen (suffix + suffind);
ret = xmalloc (plen + slen + 1);
- if (prefix && *prefix)
+ if (plen)
strcpy (ret, prefix);
strcpy (ret + plen, suffix + suffind);
return ret;
diff --git a/lib/tilde/tilde.h b/lib/tilde/tilde.h
index 634b954..7783fd6 100644
--- a/lib/tilde/tilde.h
+++ b/lib/tilde/tilde.h
@@ -8,7 +8,7 @@
The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 1, or (at your option)
+ the Free Software Foundation; either version 2, or (at your option)
any later version.
The Library is distributed in the hope that it will be useful, but
@@ -19,11 +19,27 @@
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
- 675 Mass Ave, Cambridge, MA 02139, USA. */
+ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_TILDE_H_)
# define _TILDE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* A function can be defined using prototypes and compile on both ANSI C
+ and traditional C compilers with something like this:
+ extern char *func __P((char *, char *, int)); */
+
+#if !defined (__P)
+# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
+# define __P(protos) protos
+# else
+# define __P(protos) ()
+# endif
+#endif
+
/* Function pointers can be declared as (Function *)foo. */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
@@ -56,10 +72,14 @@ extern char **tilde_additional_prefixes;
extern char **tilde_additional_suffixes;
/* Return a new string which is the result of tilde expanding STRING. */
-extern char *tilde_expand ();
+extern char *tilde_expand __P((char *));
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
tilde. If there is no expansion, call tilde_expansion_failure_hook. */
-extern char *tilde_expand_word ();
+extern char *tilde_expand_word __P((char *));
+
+#ifdef __cplusplus
+}
+#endif
#endif /* _TILDE_H_ */