summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChet Ramey <chet.ramey@case.edu>2022-09-26 11:49:46 -0400
committerChet Ramey <chet.ramey@case.edu>2022-09-26 11:49:46 -0400
commit74091dd4e8086db518b30df7f222691524469998 (patch)
treeebe89d8f0ed44b7f79aa3c759d3f85e15996eaee /lib
parent9439ce094c9aa7557a9d53ac7b412a23aa66e36b (diff)
downloadbash-74091dd4e8086db518b30df7f222691524469998.tar.gz
bash-5.2 distribution sources and documentationbash-5.2
Diffstat (limited to 'lib')
-rw-r--r--lib/glob/Makefile.in3
-rw-r--r--lib/glob/glob.c153
-rw-r--r--lib/glob/glob.h3
-rw-r--r--lib/glob/sm_loop.c55
-rw-r--r--lib/glob/smatch.c23
-rw-r--r--lib/glob/strmatch.h3
-rw-r--r--lib/intl/VERSION2
-rw-r--r--[-rwxr-xr-x]lib/intl/ref-add.sin0
-rw-r--r--[-rwxr-xr-x]lib/intl/ref-del.sin0
-rw-r--r--lib/malloc/Makefile.in5
-rw-r--r--lib/malloc/imalloc.h5
-rw-r--r--lib/malloc/malloc.c216
-rw-r--r--lib/malloc/mstats.h4
-rw-r--r--lib/readline/Makefile.in3
-rw-r--r--lib/readline/bind.c169
-rw-r--r--lib/readline/callback.c22
-rw-r--r--lib/readline/chardefs.h31
-rw-r--r--lib/readline/colors.c23
-rw-r--r--lib/readline/compat.c22
-rw-r--r--lib/readline/complete.c96
-rw-r--r--lib/readline/display.c132
-rw-r--r--lib/readline/doc/Makefile26
-rw-r--r--lib/readline/doc/history.texi2
-rw-r--r--lib/readline/doc/hstech.texi2
-rw-r--r--lib/readline/doc/hsuser.texi22
-rw-r--r--lib/readline/doc/rlman.texi2
-rw-r--r--lib/readline/doc/rltech.texi96
-rw-r--r--lib/readline/doc/rluser.texi110
-rw-r--r--lib/readline/doc/rluserman.texi2
-rw-r--r--lib/readline/doc/version.texi13
-rw-r--r--lib/readline/examples/excallback.c4
-rw-r--r--lib/readline/examples/histexamp.c3
-rw-r--r--lib/readline/examples/rl-callbacktest.c27
-rw-r--r--lib/readline/examples/rl.c8
-rw-r--r--lib/readline/examples/rlcat.c8
-rw-r--r--lib/readline/examples/rltest.c8
-rw-r--r--lib/readline/funmap.c6
-rw-r--r--lib/readline/histexpand.c45
-rw-r--r--lib/readline/histfile.c14
-rw-r--r--lib/readline/histlib.h11
-rw-r--r--lib/readline/history.c13
-rw-r--r--lib/readline/history.h79
-rw-r--r--lib/readline/histsearch.c6
-rw-r--r--lib/readline/input.c321
-rw-r--r--lib/readline/isearch.c25
-rw-r--r--lib/readline/keymaps.h18
-rw-r--r--lib/readline/kill.c46
-rw-r--r--lib/readline/macro.c2
-rw-r--r--lib/readline/mbutil.c36
-rw-r--r--lib/readline/misc.c68
-rw-r--r--lib/readline/nls.c96
-rw-r--r--lib/readline/parens.c8
-rw-r--r--lib/readline/posixdir.h2
-rw-r--r--lib/readline/posixtime.h84
-rw-r--r--lib/readline/readline.c119
-rw-r--r--lib/readline/readline.h603
-rw-r--r--lib/readline/rldefs.h8
-rw-r--r--lib/readline/rlmbutil.h38
-rw-r--r--lib/readline/rlprivate.h326
-rw-r--r--lib/readline/rlshell.h12
-rw-r--r--lib/readline/rltty.c40
-rw-r--r--lib/readline/rltypedefs.h56
-rw-r--r--lib/readline/search.c90
-rw-r--r--lib/readline/shell.c4
-rw-r--r--lib/readline/signals.c73
-rw-r--r--lib/readline/terminal.c110
-rw-r--r--lib/readline/text.c38
-rw-r--r--lib/readline/tilde.h22
-rw-r--r--lib/readline/undo.c6
-rw-r--r--lib/readline/util.c7
-rw-r--r--lib/readline/vi_mode.c123
-rw-r--r--lib/readline/xmalloc.h8
-rw-r--r--lib/sh/Makefile.in28
-rw-r--r--lib/sh/casemod.c10
-rw-r--r--lib/sh/fmtullong.c2
-rw-r--r--lib/sh/input_avail.c2
-rw-r--r--lib/sh/oslib.c14
-rw-r--r--lib/sh/setlinebuf.c27
-rw-r--r--lib/sh/shmatch.c17
-rw-r--r--lib/sh/shquote.c7
-rw-r--r--lib/sh/snprintf.c20
-rw-r--r--lib/sh/strdup.c1
-rw-r--r--lib/sh/strftime.c9
-rw-r--r--lib/sh/strtoimax.c10
-rw-r--r--lib/sh/strtol.c2
-rw-r--r--lib/sh/strtoll.c4
-rw-r--r--lib/sh/strtoull.c4
-rw-r--r--lib/sh/strtoumax.c10
-rw-r--r--lib/sh/strvis.c154
-rw-r--r--lib/sh/timers.c262
-rw-r--r--lib/sh/unicode.c2
-rw-r--r--lib/sh/winsize.c10
-rw-r--r--lib/sh/zgetline.c3
-rw-r--r--lib/sh/zmapfd.c2
-rw-r--r--lib/sh/zread.c6
-rw-r--r--lib/termcap/termcap.c7
-rw-r--r--lib/tilde/Makefile.in5
-rw-r--r--lib/tilde/tilde.h22
98 files changed, 3135 insertions, 1371 deletions
diff --git a/lib/glob/Makefile.in b/lib/glob/Makefile.in
index 314622f1..27e34f9d 100644
--- a/lib/glob/Makefile.in
+++ b/lib/glob/Makefile.in
@@ -42,6 +42,7 @@ PROFILE_FLAGS = @PROFILE_FLAGS@
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@
+STYLE_CFLAGS = @STYLE_CFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@
@@ -53,7 +54,7 @@ BASHINCDIR = ${topdir}/include
INCLUDES = -I. -I../.. -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib
CCFLAGS = $(PROFILE_FLAGS) $(DEFS) $(LOCAL_DEFS) ${INCLUDES} $(CPPFLAGS) \
- $(LOCAL_CFLAGS) $(CFLAGS) ${ADDON_CFLAGS}
+ $(STYLE_CFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) ${ADDON_CFLAGS}
# Here is a rule for making .o files from .c files that doesn't force
# the type of the machine (like -sun3) into the flags.
diff --git a/lib/glob/glob.c b/lib/glob/glob.c
index eb6277f0..b66af85c 100644
--- a/lib/glob/glob.c
+++ b/lib/glob/glob.c
@@ -1,6 +1,6 @@
/* glob.c -- file-name wildcard pattern matching for Bash.
- Copyright (C) 1985-2020 Free Software Foundation, Inc.
+ Copyright (C) 1985-2021 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne-Again SHell.
@@ -103,7 +103,7 @@ int glob_ignore_case = 0;
/* Global variable controlling whether globbing ever returns . or ..
regardless of the pattern. If set to 1, no glob pattern will ever
match `.' or `..'. Disabled by default. */
-int glob_always_skip_dot_and_dotdot = 0;
+int glob_always_skip_dot_and_dotdot = 1;
/* Global variable to return to signify an error in globbing. */
char *glob_error_return;
@@ -119,10 +119,10 @@ void udequote_pathname PARAMS((char *));
#if HANDLE_MULTIBYTE
void wcdequote_pathname PARAMS((wchar_t *));
static void wdequote_pathname PARAMS((char *));
+static void dequote_pathname PARAMS((char *));
#else
-# define dequote_pathname udequote_pathname
+# define dequote_pathname(p) udequote_pathname(p)
#endif
-static void dequote_pathname PARAMS((char *));
static int glob_testdir PARAMS((char *, int));
static char **glob_dir_to_array PARAMS((char *, char **, int));
@@ -185,6 +185,13 @@ glob_pattern_p (pattern)
}
#if EXTENDED_GLOB
+
+#if defined (HANDLE_MULTIBYTE)
+# define XSKIPNAME(p, d, f) mbskipname(p, d, f)
+#else
+# define XSKIPNAME(p, d, f) skipname(p, d, f)
+#endif
+
/* Return 1 if all subpatterns in the extended globbing pattern PAT indicate
that the name should be skipped. XXX - doesn't handle pattern negation,
not sure if it should */
@@ -194,30 +201,30 @@ extglob_skipname (pat, dname, flags)
int flags;
{
char *pp, *pe, *t, *se;
- int n, r, negate, wild, nullpat;
+ int n, r, negate, wild, nullpat, xflags;
negate = *pat == '!';
wild = *pat == '*' || *pat == '?';
pp = pat + 2;
- se = pp + strlen (pp) - 1; /* end of string */
- pe = glob_patscan (pp, se, 0); /* end of extglob pattern (( */
- /* we should check for invalid extglob pattern here */
+ se = pp + strlen (pp); /* end of pattern string */
+ pe = glob_patscan (pp, se, 0); /* end of extglob pattern */
+
+ /* if pe == 0, this is an invalid extglob pattern */
if (pe == 0)
return 0;
+ xflags = flags | ( negate ? GX_NEGATE : 0);
+
/* if pe != se we have more of the pattern at the end of the extglob
pattern. Check the easy case first ( */
- if (pe == se && *pe == ')' && (t = strchr (pp, '|')) == 0)
+ if (pe == se && *pe == 0 && pe[-1] == ')' && (t = strchr (pp, '|')) == 0)
{
- *pe = '\0';
-#if defined (HANDLE_MULTIBYTE)
- r = mbskipname (pp, dname, flags);
-#else
- r = skipname (pp, dname, flags); /*(*/
-#endif
- *pe = ')';
- if (wild && pe[1]) /* if we can match zero instances, check further */
- return (skipname (pe+1, dname, flags));
+ pe[-1] = '\0';
+ /* This is where we check whether the pattern is being negated and
+ match all files beginning with `.' if the pattern begins with a
+ literal `.'. */
+ r = XSKIPNAME (pp, dname, xflags); /*(*/
+ pe[-1] = ')';
return r;
}
@@ -229,21 +236,21 @@ extglob_skipname (pat, dname, flags)
/* check every subpattern */
while (t = glob_patscan (pp, pe, '|'))
{
+ /* If T == PE and *T == 0 (&& PE[-1] == RPAREN), we have hit the end
+ of a pattern with no trailing characters. */
n = t[-1]; /* ( */
- if (extglob_pattern_p (pp) && n == ')')
+ if (extglob_pattern_p (pp) && n == ')') /* nested extglob? */
t[-1] = n; /* no-op for now */
else
t[-1] = '\0';
-#if defined (HANDLE_MULTIBYTE)
- r = mbskipname (pp, dname, flags);
-#else
- r = skipname (pp, dname, flags);
-#endif
+ r = XSKIPNAME (pp, dname, xflags);
t[-1] = n;
if (r == 0) /* if any pattern says not skip, we don't skip */
return r;
pp = t;
- } /*(*/
+ if (pp == pe)
+ break;
+ }
/* glob_patscan might find end of string */
if (pp == se)
@@ -251,7 +258,8 @@ extglob_skipname (pat, dname, flags)
/* but if it doesn't then we didn't match a leading dot */
if (wild && *pe) /* if we can match zero instances, check further */
- return (skipname (pe, dname, flags));
+ return (XSKIPNAME (pe, dname, flags));
+
return 1;
}
#endif
@@ -264,6 +272,8 @@ skipname (pat, dname, flags)
char *dname;
int flags;
{
+ int i;
+
#if EXTENDED_GLOB
if (extglob_pattern_p (pat)) /* XXX */
return (extglob_skipname (pat, dname, flags));
@@ -279,9 +289,19 @@ skipname (pat, dname, flags)
DOT_OR_DOTDOT (dname))
return 1;
+#if 0
+ /* This is where we check whether the pattern is being negated and
+ match all files beginning with `.' if the pattern begins with a
+ literal `.'. This is the negation of the next clause. */
+ else if ((flags & GX_NEGATE) && noglob_dot_filenames == 0 &&
+ dname[0] == '.' &&
+ (pat[0] == '.' || (pat[0] == '\\' && pat[1] == '.')))
+ return 0;
+#endif
+
/* If a dot must be explicitly matched, check to see if they do. */
- else if (noglob_dot_filenames && dname[0] == '.' && pat[0] != '.' &&
- (pat[0] != '\\' || pat[1] != '.'))
+ else if (noglob_dot_filenames && dname[0] == '.' &&
+ pat[0] != '.' && (pat[0] != '\\' || pat[1] != '.'))
return 1;
return 0;
@@ -294,6 +314,8 @@ wskipname (pat, dname, flags)
wchar_t *pat, *dname;
int flags;
{
+ int i;
+
if (glob_always_skip_dot_and_dotdot && WDOT_OR_DOTDOT (dname))
return 1;
@@ -304,11 +326,20 @@ wskipname (pat, dname, flags)
WDOT_OR_DOTDOT (dname))
return 1;
+#if 0
+ /* This is where we check whether the pattern is being negated and
+ match all files beginning with `.' if the pattern begins with a
+ literal `.'. This is the negation of the next clause. */
+ else if ((flags & GX_NEGATE) && noglob_dot_filenames == 0 &&
+ dname[0] == L'.' &&
+ (pat[0] == L'.' || (pat[0] == L'\\' && pat[1] == L'.')))
+ return 0;
+#endif
+
/* If a leading dot must be explicitly matched, check to see if the
pattern and dirname both have one. */
- else if (noglob_dot_filenames && dname[0] == L'.' &&
- pat[0] != L'.' &&
- (pat[0] != L'\\' || pat[1] != L'.'))
+ else if (noglob_dot_filenames && dname[0] == L'.' &&
+ pat[0] != L'.' && (pat[0] != L'\\' || pat[1] != L'.'))
return 1;
return 0;
@@ -320,22 +351,28 @@ wextglob_skipname (pat, dname, flags)
int flags;
{
#if EXTENDED_GLOB
- wchar_t *pp, *pe, *t, n, *se;
- int r, negate, wild, nullpat;
+ wchar_t *pp, *pe, *t, *se, n;
+ int r, negate, wild, nullpat, xflags;
negate = *pat == L'!';
wild = *pat == L'*' || *pat == L'?';
pp = pat + 2;
- se = pp + wcslen (pp) - 1; /*(*/
+ se = pp + wcslen (pp);
pe = glob_patscan_wc (pp, se, 0);
- if (pe == se && *pe == ')' && (t = wcschr (pp, L'|')) == 0)
+ /* if pe == 0, this is an invalid extglob pattern */
+ if (pe == 0)
+ return 0;
+
+ xflags = flags | ( negate ? GX_NEGATE : 0);
+
+ /* if pe != se we have more of the pattern at the end of the extglob
+ pattern. Check the easy case first ( */
+ if (pe == se && *pe == L'\0' && pe[-1] == L')' && (t = wcschr (pp, L'|')) == 0)
{
- *pe = L'\0';
- r = wskipname (pp, dname, flags); /*(*/
- *pe = L')';
- if (wild && pe[1] != L'\0')
- return (wskipname (pe+1, dname, flags));
+ pe[-1] = L'\0';
+ r = wskipname (pp, dname, xflags); /*(*/
+ pe[-1] = L')';
return r;
}
@@ -348,23 +385,27 @@ wextglob_skipname (pat, dname, flags)
while (t = glob_patscan_wc (pp, pe, '|'))
{
n = t[-1]; /* ( */
- if (wextglob_pattern_p (pp) && n == L')')
+ if (wextglob_pattern_p (pp) && n == L')') /* nested extglob? */
t[-1] = n; /* no-op for now */
else
t[-1] = L'\0';
- r = wskipname (pp, dname, flags);
+ r = wskipname (pp, dname, xflags);
t[-1] = n;
if (r == 0)
return 0;
pp = t;
+ if (pp == pe)
+ break;
}
- if (pp == pe) /* glob_patscan_wc might find end of pattern */
+ /* glob_patscan_wc might find end of string */
+ if (pp == se)
return r;
/* but if it doesn't then we didn't match a leading dot */
if (wild && *pe != L'\0')
return (wskipname (pe, dname, flags));
+
return 1;
#else
return (wskipname (pat, dname, flags));
@@ -765,7 +806,7 @@ glob_vector (pat, dir, flags)
/* Compute the flags that will be passed to strmatch(). We don't
need to do this every time through the loop. */
- mflags = (noglob_dot_filenames ? FNM_PERIOD : 0) | FNM_PATHNAME;
+ mflags = (noglob_dot_filenames ? FNM_PERIOD : FNM_DOTDOT) | FNM_PATHNAME;
#ifdef FNM_CASEFOLD
if (glob_ignore_case)
@@ -777,8 +818,7 @@ glob_vector (pat, dir, flags)
add_current = ((flags & (GX_ALLDIRS|GX_ADDCURDIR)) == (GX_ALLDIRS|GX_ADDCURDIR));
- /* Scan the directory, finding all names that match.
- For each name that matches, allocate a struct globval
+ /* Scan the directory, finding all names that match For each name that matches, allocate a struct globval
on the stack and store the name in it.
Chain those structs together; lastlink is the front of the chain. */
while (1)
@@ -860,6 +900,9 @@ glob_vector (pat, dir, flags)
nextname = (char *) malloc (sdlen + 1);
if (nextlink == 0 || nextname == 0)
{
+ if (firstmalloc && firstmalloc == nextlink)
+ firstmalloc = 0;
+ /* If we reset FIRSTMALLOC we can free this here. */
FREE (nextlink);
FREE (nextname);
free (subdir);
@@ -895,7 +938,18 @@ glob_vector (pat, dir, flags)
nextname = (char *) malloc (D_NAMLEN (dp) + 1);
if (nextlink == 0 || nextname == 0)
{
- FREE (nextlink);
+ /* We free NEXTLINK here, since it won't be added to the
+ LASTLINK chain. If we used malloc, and it returned non-
+ NULL, firstmalloc will be set to something valid. If it's
+ NEXTLINK, reset it before we free NEXTLINK to avoid
+ duplicate frees. If not, it will be taken care of by the
+ loop below with TMPLINK. */
+ if (firstmalloc)
+ {
+ if (firstmalloc == nextlink)
+ firstmalloc = 0;
+ FREE (nextlink);
+ }
FREE (nextname);
lose = 1;
break;
@@ -914,7 +968,7 @@ glob_vector (pat, dir, flags)
/* compat: if GX_ADDCURDIR, add the passed directory also. Add an empty
directory name as a placeholder if GX_NULLDIR (in which case the passed
directory name is "."). */
- if (add_current)
+ if (add_current && lose == 0)
{
sdlen = strlen (dir);
nextname = (char *)malloc (sdlen + 1);
@@ -944,7 +998,7 @@ glob_vector (pat, dir, flags)
lose |= name_vector == NULL;
}
- /* Have we run out of memory? */
+ /* Have we run out of memory or been interrupted? */
if (lose)
{
tmplink = 0;
@@ -1441,6 +1495,7 @@ only_filename:
{
if (free_dirname)
free (directory_name);
+ free ((char *) result);
return ((char **)&glob_error_return);
}
}
diff --git a/lib/glob/glob.h b/lib/glob/glob.h
index ca3a66cf..47410577 100644
--- a/lib/glob/glob.h
+++ b/lib/glob/glob.h
@@ -1,5 +1,5 @@
/* File-name wildcard pattern matching for GNU.
- Copyright (C) 1985-2020 Free Software Foundation, Inc.
+ Copyright (C) 1985-2021 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne-Again SHell.
@@ -32,6 +32,7 @@
#define GX_GLOBSTAR 0x400 /* turn on special handling of ** */
#define GX_RECURSE 0x800 /* internal -- glob_filename called recursively */
#define GX_SYMLINK 0x1000 /* internal -- symlink to a directory */
+#define GX_NEGATE 0x2000 /* internal -- extglob pattern being negated */
extern int glob_pattern_p PARAMS((const char *));
extern char **glob_vector PARAMS((char *, char *, int));
diff --git a/lib/glob/sm_loop.c b/lib/glob/sm_loop.c
index a98c14bd..247ba28a 100644
--- a/lib/glob/sm_loop.c
+++ b/lib/glob/sm_loop.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -16,6 +16,8 @@
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
+extern int interrupt_state, terminating_signal;
+
struct STRUCT
{
CHAR *pattern;
@@ -81,6 +83,9 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
sc = n < se ? *n : '\0';
+ if (interrupt_state || terminating_signal)
+ return FNM_NOMATCH;
+
#ifdef EXTENDED_GLOB
/* EXTMATCH () will handle recursively calling GMATCH, so we can
just return what EXTMATCH() returns. */
@@ -90,7 +95,7 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
int lflags;
/* If we're not matching the start of the string, we're not
concerned about the special cases for matching `.' */
- lflags = (n == string) ? flags : (flags & ~FNM_PERIOD);
+ lflags = (n == string) ? flags : (flags & ~(FNM_PERIOD|FNM_DOTDOT));
return (EXTMATCH (c, n, se, p, pe, lflags));
}
#endif /* EXTENDED_GLOB */
@@ -109,6 +114,15 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
string or if it is the first character following a slash and
we are matching a pathname. */
return FNM_NOMATCH;
+
+ /* `?' cannot match `.' or `..' if it is the first character of the
+ string or if it is the first character following a slash and
+ we are matching a pathname. */
+ if ((flags & FNM_DOTDOT) &&
+ ((n == string && SDOT_OR_DOTDOT(n)) ||
+ ((flags & FNM_PATHNAME) && n[-1] == L('/') && PDOT_OR_DOTDOT(n))))
+ return FNM_NOMATCH;
+
break;
case L('\\'): /* backslash escape removes special meaning */
@@ -147,6 +161,14 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
we are matching a pathname. */
return FNM_NOMATCH;
+ /* `*' cannot match `.' or `..' if it is the first character of the
+ string or if it is the first character following a slash and
+ we are matching a pathname. */
+ if ((flags & FNM_DOTDOT) &&
+ ((n == string && SDOT_OR_DOTDOT(n)) ||
+ ((flags & FNM_PATHNAME) && n[-1] == L('/') && PDOT_OR_DOTDOT(n))))
+ return FNM_NOMATCH;
+
if (p == pe)
return 0;
@@ -288,7 +310,7 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
continue;
/* Otherwise, we just recurse. */
- if (GMATCH (n, se, p, pe, &end, flags & ~FNM_PERIOD) == 0)
+ if (GMATCH (n, se, p, pe, &end, flags & ~(FNM_PERIOD|FNM_DOTDOT)) == 0)
{
if (end.pattern == NULL)
return (0);
@@ -321,6 +343,14 @@ fprintf(stderr, "gmatch: pattern = %s; pe = %s\n", pattern, pe);
(n == string || ((flags & FNM_PATHNAME) && n[-1] == L('/'))))
return (FNM_NOMATCH);
+ /* `?' cannot match `.' or `..' if it is the first character of the
+ string or if it is the first character following a slash and
+ we are matching a pathname. */
+ if ((flags & FNM_DOTDOT) &&
+ ((n == string && SDOT_OR_DOTDOT(n)) ||
+ ((flags & FNM_PATHNAME) && n[-1] == L('/') && PDOT_OR_DOTDOT(n))))
+ return FNM_NOMATCH;
+
p = BRACKMATCH (p, sc, flags);
if (p == 0)
return FNM_NOMATCH;
@@ -843,7 +873,7 @@ fprintf(stderr, "extmatch: flags = %d\n", flags);
if (m1)
{
/* if srest > s, we are not at start of string */
- xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags;
+ xflags = (srest > s) ? (flags & ~(FNM_PERIOD|FNM_DOTDOT)) : flags;
m2 = (GMATCH (srest, se, prest, pe, NULL, xflags) == 0) ||
(s != srest && GMATCH (srest, se, p - 1, pe, NULL, xflags) == 0);
}
@@ -873,7 +903,7 @@ fprintf(stderr, "extmatch: flags = %d\n", flags);
for ( ; srest <= se; srest++)
{
/* if srest > s, we are not at start of string */
- xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags;
+ xflags = (srest > s) ? (flags & ~(FNM_PERIOD|FNM_DOTDOT)) : flags;
if (GMATCH (s, srest, psub, pnext - 1, NULL, flags) == 0 &&
GMATCH (srest, se, prest, pe, NULL, xflags) == 0)
return (0);
@@ -899,12 +929,17 @@ fprintf(stderr, "extmatch: flags = %d\n", flags);
/* If nothing matched, but the string starts with a period and we
need to match periods explicitly, don't return this as a match,
- even for negation. Might need to do this only if srest == s. */
- if (m1 == 0 && *s == '.' && (flags & FNM_PERIOD))
+ even for negation. */
+ if (m1 == 0 && (flags & FNM_PERIOD) && *s == '.')
+ return (FNM_NOMATCH);
+
+ if (m1 == 0 && (flags & FNM_DOTDOT) &&
+ (SDOT_OR_DOTDOT (s) ||
+ ((flags & FNM_PATHNAME) && s[-1] == L('/') && PDOT_OR_DOTDOT(s))))
return (FNM_NOMATCH);
/* if srest > s, we are not at start of string */
- xflags = (srest > s) ? (flags & ~FNM_PERIOD) : flags;
+ xflags = (srest > s) ? (flags & ~(FNM_PERIOD|FNM_DOTDOT)) : flags;
if (m1 == 0 && GMATCH (srest, se, prest, pe, NULL, xflags) == 0)
return (0);
}
@@ -939,4 +974,8 @@ fprintf(stderr, "extmatch: flags = %d\n", flags);
#undef MEMCHR
#undef COLLEQUIV
#undef RANGECMP
+#undef ISDIRSEP
+#undef PATHSEP
+#undef PDOT_OR_DOTDOT
+#undef SDOT_OR_DOTDOT
#undef L
diff --git a/lib/glob/smatch.c b/lib/glob/smatch.c
index a58456d7..379c2d2e 100644
--- a/lib/glob/smatch.c
+++ b/lib/glob/smatch.c
@@ -1,7 +1,7 @@
/* strmatch.c -- ksh-like extended pattern matching for the shell and filename
globbing. */
-/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -308,6 +308,16 @@ is_cclass (c, name)
? TOLOWER ((unsigned char)c) \
: ((unsigned char)c))
+#if !defined (__CYGWIN__)
+# define ISDIRSEP(c) ((c) == '/')
+#else
+# define ISDIRSEP(c) ((c) == '/' || (c) == '\\')
+#endif /* __CYGWIN__ */
+#define PATHSEP(c) (ISDIRSEP(c) || (c) == 0)
+
+# define PDOT_OR_DOTDOT(s) (s[0] == '.' && (PATHSEP (s[1]) || (s[1] == '.' && PATHSEP (s[2]))))
+# define SDOT_OR_DOTDOT(s) (s[0] == '.' && (s[1] == 0 || (s[1] == '.' && s[2] == 0)))
+
#define FCT internal_strmatch
#define GMATCH gmatch
#define COLLSYM collsym
@@ -553,6 +563,17 @@ posix_cclass_only (pattern)
/* Now include `sm_loop.c' for multibyte characters. */
#define FOLD(c) ((flags & FNM_CASEFOLD) && iswupper (c) ? towlower (c) : (c))
+
+# if !defined (__CYGWIN__)
+# define ISDIRSEP(c) ((c) == L'/')
+# else
+# define ISDIRSEP(c) ((c) == L'/' || (c) == L'\\')
+# endif /* __CYGWIN__ */
+# define PATHSEP(c) (ISDIRSEP(c) || (c) == L'\0')
+
+# define PDOT_OR_DOTDOT(w) (w[0] == L'.' && (PATHSEP(w[1]) || (w[1] == L'.' && PATHSEP(w[2]))))
+# define SDOT_OR_DOTDOT(w) (w[0] == L'.' && (w[1] == L'\0' || (w[1] == L'.' && w[2] == L'\0')))
+
#define FCT internal_wstrmatch
#define GMATCH gmatch_wc
#define COLLSYM collwcsym
diff --git a/lib/glob/strmatch.h b/lib/glob/strmatch.h
index fa7be7bb..d6a6b0fb 100644
--- a/lib/glob/strmatch.h
+++ b/lib/glob/strmatch.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2021 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne-Again SHell.
@@ -47,6 +47,7 @@
#define FNM_EXTMATCH (1 << 5) /* Use ksh-like extended matching. */
#define FNM_FIRSTCHAR (1 << 6) /* Match only the first character */
+#define FNM_DOTDOT (1 << 7) /* force `.' and `..' to match explicitly even if FNM_PERIOD not supplied. */
/* Value returned by `strmatch' if STRING does not match PATTERN. */
#undef FNM_NOMATCH
diff --git a/lib/intl/VERSION b/lib/intl/VERSION
index 13031835..f49e0dd8 100644
--- a/lib/intl/VERSION
+++ b/lib/intl/VERSION
@@ -1 +1,3 @@
GNU gettext library from gettext-0.12.1
+
+This is here only in the case the system doesn't provide it
diff --git a/lib/intl/ref-add.sin b/lib/intl/ref-add.sin
index 6fd32ed9..6fd32ed9 100755..100644
--- a/lib/intl/ref-add.sin
+++ b/lib/intl/ref-add.sin
diff --git a/lib/intl/ref-del.sin b/lib/intl/ref-del.sin
index 65ce9afa..65ce9afa 100755..100644
--- a/lib/intl/ref-del.sin
+++ b/lib/intl/ref-del.sin
diff --git a/lib/malloc/Makefile.in b/lib/malloc/Makefile.in
index 0ef3cfd5..7ec8f64f 100644
--- a/lib/malloc/Makefile.in
+++ b/lib/malloc/Makefile.in
@@ -1,6 +1,6 @@
# Skeleton Makefile for the GNU malloc code
#
-# Copyright (C) 1996-2009 Free Software Foundation, Inc.
+# Copyright (C) 1996-2021 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
@@ -38,6 +38,7 @@ PROFILE_FLAGS = @PROFILE_FLAGS@
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@
+STYLE_CFLAGS = @STYLE_CFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
@@ -56,7 +57,7 @@ LIBINTL_H = @LIBINTL_H@
INCLUDES = -I. -I../.. -I$(topdir) -I$(BASHINCDIR) -I$(topdir)/lib $(INTL_INC)
CCFLAGS = ${PROFILE_FLAGS} ${INCLUDES} $(DEFS) $(LOCAL_DEFS) $(LOCAL_CFLAGS) \
- $(CFLAGS) $(MALLOC_CFLAGS) $(CPPFLAGS)
+ $(CFLAGS) $(MALLOC_CFLAGS) $(STYLE_CFLAGS) $(CPPFLAGS)
.c.o:
$(CC) $(CCFLAGS) -c $<
diff --git a/lib/malloc/imalloc.h b/lib/malloc/imalloc.h
index d07adac2..bebd1364 100644
--- a/lib/malloc/imalloc.h
+++ b/lib/malloc/imalloc.h
@@ -32,6 +32,11 @@
#define MALLOC_WRAPFUNCS
+/* If defined, as it is by default, use the lesscore() function to attempt
+ to reduce the top of the heap when freeing memory blocks larger than a
+ defined threshold. */
+#define USE_LESSCORE
+
/* Generic pointer type. */
#ifndef PTR_T
# if defined (__STDC__)
diff --git a/lib/malloc/malloc.c b/lib/malloc/malloc.c
index 92e6efa5..f61f0271 100644
--- a/lib/malloc/malloc.c
+++ b/lib/malloc/malloc.c
@@ -1,6 +1,6 @@
/* malloc.c - dynamic memory allocation for bash. */
-/* Copyright (C) 1985-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1985-2021 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne-Again SHell.
@@ -47,10 +47,10 @@
*/
/*
- * nextf[i] is the pointer to the next free block of size 2^(i+3). The
- * smallest allocatable block is 8 bytes. The overhead information will
- * go in the first int of the block, and the returned pointer will point
- * to the second.
+ * nextf[i] is the pointer to the next free block of size 2^(i+5). The
+ * smallest allocatable block is 32 bytes. The overhead information will
+ * go in the first 16 bytes of the block, and the returned pointer will point
+ * to the rest.
*/
/* Define MEMSCRAMBLE to have free() write 0xcf into memory as it's freed, to
@@ -121,8 +121,8 @@
# define NO_VALLOC
#endif
-/* SIZEOF_LONG * 4 - 2, usable bins from 1..NBUCKETS-1 */
-#define NBUCKETS 30
+#define MALLOC_PAGESIZE_MIN 4096
+#define MALLOC_INCR_PAGES 8192
#define ISALLOC ((char) 0xf7) /* magic byte that implies allocation */
#define ISFREE ((char) 0x54) /* magic byte that implies free block */
@@ -140,20 +140,14 @@
enough room in the block for the new size. Range checking is always
done. */
union mhead {
-#if SIZEOF_CHAR_P == 8
bits64_t mh_align[2]; /* 16 */
-#else
- bits64_t mh_align; /* 8 */
-#endif
struct {
char mi_alloc; /* ISALLOC or ISFREE */ /* 1 */
char mi_index; /* index in nextf[] */ /* 1 */
/* Remainder are valid only when block is allocated */
u_bits16_t mi_magic2; /* should be == MAGIC2 */ /* 2 */
u_bits32_t mi_nbytes; /* # of bytes allocated */ /* 4 */
-#if SIZEOF_CHAR_P == 8
char mi_magic8[8]; /* MAGIC1 guard bytes */ /* 8 */
-#endif
} minfo;
};
#define mh_alloc minfo.mi_alloc
@@ -162,14 +156,14 @@ union mhead {
#define mh_magic2 minfo.mi_magic2
#define mh_magic8 minfo.mi_magic8
+#define MAGIC8_NUMBYTES 8
+#define MALLOC_SIZE_T u_bits32_t
+
#define MOVERHEAD sizeof(union mhead)
-#if SIZEOF_CHAR_P == 8
-#define MALIGN_MASK 15
-#else
-#define MALIGN_MASK 7 /* one less than desired alignment */
-#endif
+#define MALIGN_MASK 15 /* one less than desired alignment */
+/* Guard bytes we write at the end of the allocation, encoding the size. */
typedef union _malloc_guard {
char s[4];
u_bits32_t i;
@@ -181,6 +175,8 @@ typedef union _malloc_guard {
because we want sizeof (union mhead)
to describe the overhead for when the block is in use,
and we do not want the free-list pointer to count in that. */
+/* If we have mmap, this is not used for chunks larger than mmap_threshold,
+ since we munmap immediately on free(). */
/* If SIZEOF_CHAR_P == 8, this goes into the mh_magic8 buffer at the end of
the rest of the struct. This may need adjusting. */
@@ -194,10 +190,11 @@ typedef union _malloc_guard {
/* Written in the bytes before the block's real space (-SIZEOF_CHAR_P bytes) */
#define MAGIC1 0x55
#define MAGIC2 0x5555
-#define MSLOP 4 /* 4 bytes extra for u_bits32_t size */
+
+#define MSLOP 4 /* 4 bytes extra for u_bits32_t end guard size */
/* How many bytes are actually allocated for a request of size N --
- rounded up to nearest multiple of 2*SIZEOF_CHAR_P after accounting for
+ rounded up to nearest multiple of 16 (alignment) after accounting for
malloc overhead. */
#define ALLOCATED_BYTES(n) \
(((n) + MOVERHEAD + MSLOP + MALIGN_MASK) & ~MALIGN_MASK)
@@ -211,18 +208,22 @@ typedef union _malloc_guard {
/* Minimum and maximum bucket indices for block splitting (and to bound
the search for a block to split). */
-#define SPLIT_MIN 2 /* XXX - was 3 */
-#define SPLIT_MID 11
-#define SPLIT_MAX 14
+#define SPLIT_MIN 1 /* 64 */
+#define SPLIT_MID 9 /* 16384 */
+#define SPLIT_MAX 12 /* 131072 */
/* Minimum and maximum bucket indices for block coalescing. */
-#define COMBINE_MIN 2
-#define COMBINE_MAX (pagebucket - 1) /* XXX */
+#define COMBINE_MIN 1 /* 64 */
+#define COMBINE_MAX (pagebucket - 1) /* 2048 for 4096-byte pages */
-#define LESSCORE_MIN 10
-#define LESSCORE_FRC 13
+#define LESSCORE_MIN 8 /* 8192 */
+#define LESSCORE_FRC 11 /* 65536 */
+
+/* Which bin do we prepopulate with the initial sbrk memory? */
+#define PREPOP_BIN 1
+#define PREPOP_SIZE 64
-#define STARTBUCK 1
+#define STARTBUCK 0
/* Should we use mmap for large allocations? */
#if defined (HAVE_MMAP)
@@ -232,15 +233,25 @@ typedef union _malloc_guard {
#endif
#if defined (HAVE_MMAP) && defined (MAP_ANONYMOUS)
-# define USE_MMAP
+# define USE_MMAP 1
#endif
#if defined (USE_MMAP)
-# define MMAP_THRESHOLD 14 /* must be >= SPLIT_MAX, COMBINE_MAX */
+# define MMAP_THRESHOLD 12 /* must be >= SPLIT_MAX, COMBINE_MAX */
#else
# define MMAP_THRESHOLD (8 * SIZEOF_LONG)
#endif
+/* We don't try to decipher the differences between the Linux-style and
+ BSD-style implementations of mremap here; we use the Linux one. */
+#if USE_MMAP == 1 && defined (HAVE_MREMAP) && defined (MREMAP_MAYMOVE)
+# define USE_MREMAP 1
+#endif
+
+/* usable bins from STARTBUCK..NBUCKETS-1 */
+
+#define NBUCKETS 28
+
/* Flags for the internal functions. */
#define MALLOC_WRAPPER 0x01 /* wrapper function */
#define MALLOC_INTERNAL 0x02 /* internal function calling another */
@@ -265,7 +276,7 @@ typedef union _malloc_guard {
#define RIGHT_BUCKET(nb, nu) \
(((nb) > binsizes[(nu)-1]) && ((nb) <= binsizes[(nu)]))
-/* nextf[i] is free list of blocks of size 2**(i + 3) */
+/* nextf[i] is free list of blocks of size 2**(i + 5) */
static union mhead *nextf[NBUCKETS];
@@ -280,16 +291,18 @@ static int maxbuck; /* highest bucket receiving allocation request. */
static char *memtop; /* top of heap */
static const unsigned long binsizes[NBUCKETS] = {
- 8UL, 16UL, 32UL, 64UL, 128UL, 256UL, 512UL, 1024UL, 2048UL, 4096UL,
+ 32UL, 64UL, 128UL, 256UL, 512UL, 1024UL, 2048UL, 4096UL,
8192UL, 16384UL, 32768UL, 65536UL, 131072UL, 262144UL, 524288UL,
1048576UL, 2097152UL, 4194304UL, 8388608UL, 16777216UL, 33554432UL,
67108864UL, 134217728UL, 268435456UL, 536870912UL, 1073741824UL,
2147483648UL, 4294967295UL
};
-/* binsizes[x] == (1 << ((x) + 3)) */
+/* binsizes[x] == (1 << ((x) + 5)) */
#define binsize(x) binsizes[(x)]
+#define MAXALLOC_SIZE binsizes[NBUCKETS-1]
+
#if !defined (errno)
extern int errno;
#endif
@@ -306,6 +319,7 @@ static void internal_cfree PARAMS((PTR_T, const char *, int, int));
#ifndef NO_VALLOC
static PTR_T internal_valloc PARAMS((size_t, const char *, int, int));
#endif
+static PTR_T internal_remap PARAMS((PTR_T, size_t, int, int));
#if defined (botch)
extern void botch ();
@@ -583,6 +597,7 @@ _malloc_unblock_signals (setp, osetp)
#endif
}
+#if defined (USE_LESSCORE)
/* Return some memory to the system by reducing the break. This is only
called with NU > pagebucket, so we're always assured of giving back
more than one page of memory. */
@@ -603,6 +618,7 @@ lesscore (nu) /* give system back some memory */
_mstats.nlesscore[nu]++;
#endif
}
+#endif /* USE_LESSCORE */
/* Ask system for more memory; add to NEXTF[NU]. BUSY[NU] must be set to 1. */
static void
@@ -741,14 +757,6 @@ malloc_debug_dummy ()
write (1, "malloc_debug_dummy\n", 19);
}
-#if SIZEOF_CHAR_P == 8
-#define PREPOP_BIN 3
-#define PREPOP_SIZE 64
-#else
-#define PREPOP_BIN 2
-#define PREPOP_SIZE 32
-#endif
-
static int
pagealign ()
{
@@ -758,8 +766,8 @@ pagealign ()
char *curbrk;
pagesz = getpagesize ();
- if (pagesz < 1024)
- pagesz = 1024;
+ if (pagesz < MALLOC_PAGESIZE_MIN)
+ pagesz = MALLOC_PAGESIZE_MIN;
/* OK, how much do we need to allocate to make things page-aligned?
Some of this partial page will be wasted space, but we'll use as
@@ -825,7 +833,7 @@ internal_malloc (n, file, line, flags) /* get a block */
register union mhead *p;
register int nunits;
register char *m, *z;
- long nbytes;
+ MALLOC_SIZE_T nbytes;
mguard_t mg;
/* Get the system page size and align break pointer so future sbrks will
@@ -839,6 +847,10 @@ internal_malloc (n, file, line, flags) /* get a block */
multiple of 8, then figure out which nextf[] area to use. Try to
be smart about where to start searching -- if the number of bytes
needed is greater than the page size, we can start at pagebucket. */
+#if SIZEOF_SIZE_T == 8
+ if (ALLOCATED_BYTES(n) > MAXALLOC_SIZE)
+ return ((PTR_T) NULL);
+#endif
nbytes = ALLOCATED_BYTES(n);
nunits = (nbytes <= (pagesz >> 1)) ? STARTBUCK : pagebucket;
for ( ; nunits < NBUCKETS; nunits++)
@@ -886,10 +898,8 @@ internal_malloc (n, file, line, flags) /* get a block */
p->mh_magic2 = MAGIC2;
p->mh_nbytes = n;
-#if SIZEOF_CHAR_P == 8
/* Begin guard */
- MALLOC_MEMSET ((char *)p->mh_magic8, MAGIC1, 8);
-#endif
+ MALLOC_MEMSET ((char *)p->mh_magic8, MAGIC1, MAGIC8_NUMBYTES);
/* End guard */
mg.i = n;
@@ -945,8 +955,8 @@ internal_free (mem, file, line, flags)
register union mhead *p;
register char *ap, *z;
register int nunits;
- register unsigned int nbytes;
- int ubytes; /* caller-requested size */
+ register MALLOC_SIZE_T nbytes;
+ MALLOC_SIZE_T ubytes; /* caller-requested size */
mguard_t mg;
if ((ap = (char *)mem) == 0)
@@ -979,28 +989,25 @@ internal_free (mem, file, line, flags)
nunits = p->mh_index;
nbytes = ALLOCATED_BYTES(p->mh_nbytes);
- /* Since the sizeof(u_bits32_t) bytes before the memory handed to the user
- are now used for the number of bytes allocated, a simple check of
- mh_magic2 is no longer sufficient to catch things like p[-1] = 'x'.
+ /* The MAGIC8_NUMBYTES bytes before the memory handed to the user are now
+ used for a simple check to catch things like p[-1] = 'x'.
We sanity-check the value of mh_nbytes against the size of the blocks
in the appropriate bucket before we use it. This can still cause problems
and obscure errors if mh_nbytes is wrong but still within range; the
checks against the size recorded at the end of the chunk will probably
- fail then. Using MALLOC_REGISTER will help here, since it saves the
+ fail then. Using MALLOC_REGISTER will help here, since it saves the
original number of bytes requested. */
if (IN_BUCKET(nbytes, nunits) == 0)
xbotch (mem, ERR_UNDERFLOW,
_("free: underflow detected; mh_nbytes out of range"), file, line);
-#if SIZEOF_CHAR_P == 8
{
int i;
- for (i = 0, z = p->mh_magic8; i < 8; i++)
+ for (i = 0, z = p->mh_magic8; i < MAGIC8_NUMBYTES; i++)
if (*z++ != MAGIC1)
xbotch (mem, ERR_UNDERFLOW,
_("free: underflow detected; magic8 corrupted"), file, line);
}
-#endif
ap += p->mh_nbytes;
z = mg.s;
@@ -1019,11 +1026,9 @@ internal_free (mem, file, line, flags)
}
#endif
-#if GLIBC21
- if (nunits >= LESSCORE_MIN && ((char *)p + binsize(nunits) == sbrk (0)))
-#else
+#if defined (USE_LESSCORE)
+ /* We take care of the mmap case and munmap above */
if (nunits >= LESSCORE_MIN && ((char *)p + binsize(nunits) == memtop))
-#endif
{
/* If above LESSCORE_FRC, give back unconditionally. This should be set
high enough to be infrequently encountered. If between LESSCORE_MIN
@@ -1036,6 +1041,7 @@ internal_free (mem, file, line, flags)
goto free_return;
}
}
+#endif /* USE_LESSCORE */
#ifdef MEMSCRAMBLE
if (p->mh_nbytes)
@@ -1084,6 +1090,58 @@ free_return:
#endif
}
+#if USE_MREMAP == 1
+/* Assume the caller (internal_realloc) has already performed the sanity and
+ overflow tests. Basically we kill the old guard information, determine the
+ new size, call mremap with the new size, and add the bookkeeping and guard
+ information back in. */
+static PTR_T
+internal_remap (mem, n, nunits, flags)
+ PTR_T mem;
+ register size_t n;
+ int nunits;
+ int flags;
+{
+ register union mhead *p, *np;
+ char *m, *z;
+ mguard_t mg;
+ MALLOC_SIZE_T nbytes;
+
+ if (nunits >= NBUCKETS) /* Uh oh */
+ return ((PTR_T) NULL);
+
+ p = (union mhead *)mem - 1;
+
+ m = (char *)mem + p->mh_nbytes;
+ z = mg.s;
+ *m++ = 0; *m++ = 0; *m++ = 0; *m++ = 0; /* erase guard */
+
+ nbytes = ALLOCATED_BYTES(n);
+
+ busy[nunits] = 1;
+ np = (union mhead *)mremap (p, binsize (p->mh_index), binsize (nunits), MREMAP_MAYMOVE);
+ busy[nunits] = 0;
+ if (np == MAP_FAILED)
+ return (PTR_T)NULL;
+
+ if (np != p)
+ {
+ np->mh_alloc = ISALLOC;
+ np->mh_magic2 = MAGIC2;
+ MALLOC_MEMSET ((char *)np->mh_magic8, MAGIC1, MAGIC8_NUMBYTES);
+ }
+ np->mh_index = nunits;
+ np->mh_nbytes = n;
+
+ mg.i = n;
+ z = mg.s;
+ m = (char *)(np + 1) + n;
+ *m++ = *z++, *m++ = *z++, *m++ = *z++, *m++ = *z++;
+
+ return ((PTR_T)(np + 1));
+}
+#endif
+
static PTR_T
internal_realloc (mem, n, file, line, flags)
PTR_T mem;
@@ -1092,9 +1150,9 @@ internal_realloc (mem, n, file, line, flags)
int line, flags;
{
register union mhead *p;
- register u_bits32_t tocopy;
- register unsigned int nbytes;
- register int nunits;
+ register MALLOC_SIZE_T tocopy;
+ register MALLOC_SIZE_T nbytes;
+ register int newunits, nunits;
register char *m, *z;
mguard_t mg;
@@ -1132,16 +1190,14 @@ internal_realloc (mem, n, file, line, flags)
if (IN_BUCKET(nbytes, nunits) == 0)
xbotch (mem, ERR_UNDERFLOW,
_("realloc: underflow detected; mh_nbytes out of range"), file, line);
-#if SIZEOF_CHAR_P == 8
{
int i;
- for (i = 0, z = p->mh_magic8; i < 8; i++)
+ for (i = 0, z = p->mh_magic8; i < MAGIC8_NUMBYTES; i++)
if (*z++ != MAGIC1)
xbotch (mem, ERR_UNDERFLOW,
_("realloc: underflow detected; magic8 corrupted"), file, line);
}
-#endif
m = (char *)mem + (tocopy = p->mh_nbytes);
z = mg.s;
@@ -1161,6 +1217,10 @@ internal_realloc (mem, n, file, line, flags)
if (n == p->mh_nbytes)
return mem;
+#if SIZEOF_SIZE_T == 8
+ if (ALLOCATED_BYTES(n) > MAXALLOC_SIZE)
+ return ((PTR_T) NULL);
+#endif
/* See if desired size rounds to same power of 2 as actual size. */
nbytes = ALLOCATED_BYTES(n);
@@ -1187,12 +1247,31 @@ internal_realloc (mem, n, file, line, flags)
_mstats.nrcopy++;
#endif
- /* If we are using mmap and have mremap, we could use it here. */
+#if USE_MREMAP == 1
+ /* If we are using mmap and have mremap, we use it here. Make sure that
+ the old size and new size are above the threshold where we use mmap */
+ if (nbytes > p->mh_nbytes)
+ newunits = nunits;
+ else
+ newunits = (nbytes <= (pagesz >> 1)) ? STARTBUCK : pagebucket;
+ for ( ; newunits < NBUCKETS; newunits++)
+ if (nbytes <= binsize(newunits))
+ break;
+ if (nunits > malloc_mmap_threshold && newunits > malloc_mmap_threshold)
+ {
+ m = internal_remap (mem, n, newunits, MALLOC_INTERNAL);
+ if (m == 0)
+ return 0;
+ }
+ else
+#endif /* USE_MREMAP */
+ {
if ((m = internal_malloc (n, file, line, MALLOC_INTERNAL|MALLOC_NOTRACE|MALLOC_NOREG)) == 0)
return 0;
FASTCOPY (mem, m, tocopy);
internal_free (mem, file, line, MALLOC_INTERNAL);
+ }
#ifdef MALLOC_TRACE
if (malloc_trace && (flags & MALLOC_NOTRACE) == 0)
@@ -1272,14 +1351,13 @@ malloc_usable_size (mem)
{
register union mhead *p;
register char *ap;
- register int maxbytes;
-
if ((ap = (char *)mem) == 0)
return 0;
/* Find the true start of the memory block to discover which bin */
p = (union mhead *) ap - 1;
+
if (p->mh_alloc == ISMEMALIGN)
{
ap -= p->mh_nbytes;
diff --git a/lib/malloc/mstats.h b/lib/malloc/mstats.h
index ce8aaeca..aa3fa33b 100644
--- a/lib/malloc/mstats.h
+++ b/lib/malloc/mstats.h
@@ -1,6 +1,6 @@
/* mstats.h - definitions for malloc statistics */
-/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne-Again SHell.
@@ -27,7 +27,7 @@
/* This needs to change if the definition in malloc.c changes */
#ifndef NBUCKETS
-# define NBUCKETS 30
+# define NBUCKETS 28
#endif
/*
diff --git a/lib/readline/Makefile.in b/lib/readline/Makefile.in
index b2358c67..3b16139d 100644
--- a/lib/readline/Makefile.in
+++ b/lib/readline/Makefile.in
@@ -56,6 +56,7 @@ DEBUG = @DEBUG@
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG}
+STYLE_CFLAGS = @STYLE_CFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
@@ -65,7 +66,7 @@ LOCAL_DEFS = @LOCAL_DEFS@
INCLUDES = -I. -I$(BUILD_DIR) -I$(topdir) -I$(topdir)/lib
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(APP_CFLAGS) $(CPPFLAGS) ${INCLUDES} \
- $(LOCAL_CFLAGS) $(CFLAGS) ${ADDON_CFLAGS}
+ $(STYLE_CFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) ${ADDON_CFLAGS}
.c.o:
${RM} $@
diff --git a/lib/readline/bind.c b/lib/readline/bind.c
index 76103786..971116a9 100644
--- a/lib/readline/bind.c
+++ b/lib/readline/bind.c
@@ -1,6 +1,6 @@
/* bind.c -- key binding and startup file support for the readline library. */
-/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -72,7 +72,7 @@ extern char *strchr (), *strrchr ();
/* Variables exported by this file. */
Keymap rl_binding_keymap;
-static int _rl_skip_to_delim PARAMS((char *, int, int));
+static int _rl_skip_to_delim (char *, int, int);
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
static void _rl_init_file_error (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
@@ -80,23 +80,23 @@ static void _rl_init_file_error (const char *, ...) __attribute__((__format__ (
static void _rl_init_file_error ();
#endif
-static rl_command_func_t *_rl_function_of_keyseq_internal PARAMS((const char *, size_t, Keymap, int *));
+static rl_command_func_t *_rl_function_of_keyseq_internal (const char *, size_t, Keymap, int *);
-static char *_rl_read_file PARAMS((char *, size_t *));
-static int _rl_read_init_file PARAMS((const char *, int));
-static int glean_key_from_name PARAMS((char *));
+static char *_rl_read_file (char *, size_t *);
+static int _rl_read_init_file (const char *, int);
+static int glean_key_from_name (char *);
-static int find_boolean_var PARAMS((const char *));
-static int find_string_var PARAMS((const char *));
+static int find_boolean_var (const char *);
+static int find_string_var (const char *);
-static const char *boolean_varname PARAMS((int));
-static const char *string_varname PARAMS((int));
+static const char *boolean_varname (int);
+static const char *string_varname (int);
-static char *_rl_get_string_variable_value PARAMS((const char *));
-static int substring_member_of_array PARAMS((const char *, const char * const *));
+static char *_rl_get_string_variable_value (const char *);
+static int substring_member_of_array (const char *, const char * const *);
-static int _rl_get_keymap_by_name PARAMS((const char *));
-static int _rl_get_keymap_by_map PARAMS((Keymap));
+static int _rl_get_keymap_by_name (const char *);
+static int _rl_get_keymap_by_map (Keymap);
static int currently_reading_init_file;
@@ -880,6 +880,85 @@ rl_function_of_keyseq_len (const char *keyseq, size_t len, Keymap map, int *type
return _rl_function_of_keyseq_internal (keyseq, len, map, type);
}
+/* Assuming there is a numeric argument at the beginning of KEYSEQ (the
+ caller is responsible for checking), return the index of the portion of
+ the key sequence following the numeric argument. If there's no numeric
+ argument (?), or if KEYSEQ consists solely of a numeric argument (?),
+ return -1. */
+int
+rl_trim_arg_from_keyseq (const char *keyseq, size_t len, Keymap map)
+{
+ register int i, j, parsing_digits;
+ unsigned char ic;
+ Keymap map0;
+
+ if (map == 0)
+ map = _rl_keymap;
+ map0 = map;
+
+ /* The digits following the initial one (e.g., the binding to digit-argument)
+ or the optional `-' in a binding to digit-argument or universal-argument
+ are not added to rl_executing_keyseq. This is basically everything read by
+ rl_digit_loop. The parsing_digits logic is here in case they ever are. */
+ for (i = j = parsing_digits = 0; keyseq && i < len; i++)
+ {
+ ic = keyseq[i];
+
+ if (parsing_digits)
+ {
+ if (_rl_digit_p (ic))
+ {
+ j = i + 1;
+ continue;
+ }
+ parsing_digits = 0;
+ }
+
+ if (map[ic].type == ISKMAP)
+ {
+ if (i + 1 == len)
+ return -1;
+ map = FUNCTION_TO_KEYMAP (map, ic);
+ continue;
+ }
+ if (map[ic].type == ISFUNC)
+ {
+#if defined (VI_MODE)
+ if (map[ic].function != rl_digit_argument && map[ic].function != rl_universal_argument && map[ic].function != rl_vi_arg_digit)
+#else
+ if (map[ic].function != rl_digit_argument && map[ic].function != rl_universal_argument)
+#endif
+ return (j);
+
+ /* We don't bother with a keyseq that is only a numeric argument */
+ if (i + 1 == len)
+ return -1;
+
+ parsing_digits = 1;
+
+ /* This logic should be identical to rl_digit_loop */
+ /* We accept M-- as equivalent to M--1, C-u- as equivalent to C-u-1
+ but set parsing_digits to 2 to note that we saw `-' */
+ if (map[ic].function == rl_universal_argument && (i + 1 == '-'))
+ {
+ i++;
+ parsing_digits = 2;
+ }
+ if (map[ic].function == rl_digit_argument && ic == '-')
+ {
+ parsing_digits = 2;
+ }
+
+ map = map0;
+ j = i + 1;
+ }
+ }
+
+ /* If we're still parsing digits by the time we get here, we don't allow a
+ key sequence that consists solely of a numeric argument */
+ return -1;
+}
+
/* The last key bindings file read. */
static char *last_readline_init_file = (char *)NULL;
@@ -1143,7 +1222,7 @@ parse_comparison_op (s, indp)
/* */
/* **************************************************************** */
-typedef int _rl_parser_func_t PARAMS((char *));
+typedef int _rl_parser_func_t (char *);
/* Things that mean `Control'. */
const char * const _rl_possible_control_prefixes[] = {
@@ -1154,6 +1233,12 @@ const char * const _rl_possible_meta_prefixes[] = {
"Meta", "M-", (const char *)NULL
};
+/* Forward declarations */
+static int parser_if (char *);
+static int parser_else (char *);
+static int parser_endif (char *);
+static int parser_include (char *);
+
/* Conditionals. */
/* Calling programs set this to have their argv[0]. */
@@ -1813,6 +1898,7 @@ static const struct {
{ "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 },
{ "disable-completion", &rl_inhibit_completion, 0 },
{ "echo-control-characters", &_rl_echo_control_chars, 0 },
+ { "enable-active-region", &_rl_enable_active_region, 0 },
{ "enable-bracketed-paste", &_rl_enable_bracketed_paste, V_SPECIAL },
{ "enable-keypad", &_rl_enable_keypad, 0 },
{ "enable-meta-key", &_rl_enable_meta, 0 },
@@ -1883,7 +1969,7 @@ hack_special_boolean_var (int i)
_rl_enable_active_region = _rl_enable_bracketed_paste;
}
-typedef int _rl_sv_func_t PARAMS((const char *));
+typedef int _rl_sv_func_t (const char *);
/* These *must* correspond to the array indices for the appropriate
string variable. (Though they're not used right now.) */
@@ -1897,25 +1983,29 @@ typedef int _rl_sv_func_t PARAMS((const char *));
#define V_INT 2
/* Forward declarations */
-static int sv_bell_style PARAMS((const char *));
-static int sv_combegin PARAMS((const char *));
-static int sv_dispprefix PARAMS((const char *));
-static int sv_compquery PARAMS((const char *));
-static int sv_compwidth PARAMS((const char *));
-static int sv_editmode PARAMS((const char *));
-static int sv_emacs_modestr PARAMS((const char *));
-static int sv_histsize PARAMS((const char *));
-static int sv_isrchterm PARAMS((const char *));
-static int sv_keymap PARAMS((const char *));
-static int sv_seqtimeout PARAMS((const char *));
-static int sv_viins_modestr PARAMS((const char *));
-static int sv_vicmd_modestr PARAMS((const char *));
+static int sv_region_start_color (const char *);
+static int sv_region_end_color (const char *);
+static int sv_bell_style (const char *);
+static int sv_combegin (const char *);
+static int sv_dispprefix (const char *);
+static int sv_compquery (const char *);
+static int sv_compwidth (const char *);
+static int sv_editmode (const char *);
+static int sv_emacs_modestr (const char *);
+static int sv_histsize (const char *);
+static int sv_isrchterm (const char *);
+static int sv_keymap (const char *);
+static int sv_seqtimeout (const char *);
+static int sv_viins_modestr (const char *);
+static int sv_vicmd_modestr (const char *);
static const struct {
const char * const name;
int flags;
_rl_sv_func_t *set_func;
} string_varlist[] = {
+ { "active-region-end-color", V_STRING, sv_region_end_color },
+ { "active-region-start-color", V_STRING, sv_region_start_color },
{ "bell-style", V_STRING, sv_bell_style },
{ "comment-begin", V_STRING, sv_combegin },
{ "completion-display-width", V_INT, sv_compwidth },
@@ -2135,6 +2225,18 @@ sv_seqtimeout (const char *value)
}
static int
+sv_region_start_color (const char *value)
+{
+ return (_rl_reset_region_color (0, value));
+}
+
+static int
+sv_region_end_color (const char *value)
+{
+ return (_rl_reset_region_color (1, value));
+}
+
+static int
sv_bell_style (const char *value)
{
if (value == 0 || *value == '\0')
@@ -2548,6 +2650,15 @@ _rl_get_keyname (int key)
keyname[i++] = (c / 8) + '0';
c = (c % 8) + '0';
}
+ /* These characters are valid UTF-8; convert them into octal escape
+ sequences as well. This changes C. */
+ else if (c >= 160)
+ {
+ keyname[i++] = '\\';
+ keyname[i++] = '0' + ((((unsigned char)c) >> 6) & 0x07);
+ keyname[i++] = '0' + ((((unsigned char)c) >> 3) & 0x07);
+ c = (c % 8) + '0';
+ }
/* Now, if the character needs to be quoted with a backslash, do that. */
if (c == '\\' || c == '"')
diff --git a/lib/readline/callback.c b/lib/readline/callback.c
index a466cf9b..69df77df 100644
--- a/lib/readline/callback.c
+++ b/lib/readline/callback.c
@@ -1,6 +1,6 @@
/* callback.c -- functions to use readline as an X `callback' mechanism. */
-/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -136,6 +136,8 @@ rl_callback_read_char (void)
abort ();
}
+ eof = 0;
+
memcpy ((void *)olevel, (void *)_rl_top_level, sizeof (procenv_t));
#if defined (HAVE_POSIX_SIGSETJMP)
jcode = sigsetjmp (_rl_top_level, 0);
@@ -147,6 +149,14 @@ rl_callback_read_char (void)
(*rl_redisplay_function) ();
_rl_want_redisplay = 0;
memcpy ((void *)_rl_top_level, (void *)olevel, sizeof (procenv_t));
+
+ /* If we longjmped because of a timeout, handle it here. */
+ if (RL_ISSTATE (RL_STATE_TIMEOUT))
+ {
+ RL_SETSTATE (RL_STATE_DONE);
+ rl_done = 1;
+ }
+
CALLBACK_READ_RETURN ();
}
@@ -268,6 +278,13 @@ rl_callback_read_char (void)
_rl_want_redisplay = 0;
}
+ /* Make sure application hooks can see whether we saw EOF. */
+ if (eof > 0)
+ {
+ rl_eof_found = eof;
+ RL_SETSTATE(RL_STATE_EOF);
+ }
+
if (rl_done)
{
line = readline_internal_teardown (eof);
@@ -278,7 +295,8 @@ rl_callback_read_char (void)
rl_clear_signals ();
#endif
in_handler = 0;
- (*rl_linefunc) (line);
+ if (rl_linefunc) /* just in case */
+ (*rl_linefunc) (line);
/* If the user did not clear out the line, do it for him. */
if (rl_line_buffer[0])
diff --git a/lib/readline/chardefs.h b/lib/readline/chardefs.h
index 3cf1326a..24a25f1f 100644
--- a/lib/readline/chardefs.h
+++ b/lib/readline/chardefs.h
@@ -1,6 +1,6 @@
/* chardefs.h -- Character definitions for readline. */
-/* Copyright (C) 1994-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -26,9 +26,6 @@
#if defined (HAVE_CONFIG_H)
# if defined (HAVE_STRING_H)
-# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
-# include <memory.h>
-# endif
# include <string.h>
# endif /* HAVE_STRING_H */
# if defined (HAVE_STRINGS_H)
@@ -66,22 +63,26 @@
#define UNMETA(c) ((c) & (~meta_character_bit))
#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
-#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII))
-# define IN_CTYPE_DOMAIN(c) 1
-#else
-# define IN_CTYPE_DOMAIN(c) isascii(c)
+#ifndef UCHAR_MAX
+# define UCHAR_MAX 255
#endif
-
-#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT) && !defined (__cplusplus)
-# define isxdigit(c) (isdigit((unsigned char)(c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
+#ifndef CHAR_MAX
+# define CHAR_MAX 127
#endif
-#if defined (CTYPE_NON_ASCII)
+/* use this as a proxy for C89 */
+#if defined (HAVE_STDLIB_H) && defined (HAVE_STRING_H)
+# define IN_CTYPE_DOMAIN(c) 1
# define NON_NEGATIVE(c) 1
#else
+# define IN_CTYPE_DOMAIN(c) ((c) >= 0 && (c) <= CHAR_MAX)
# define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
#endif
+#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT) && !defined (__cplusplus)
+# define isxdigit(c) (isdigit((unsigned char)(c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
+#endif
+
/* Some systems define these; we want our definitions. */
#undef ISPRINT
@@ -99,12 +100,12 @@
#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c))
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
+#define _rl_alphabetic_p(c) (NON_NEGATIVE(c) && ISALNUM(c))
#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c))
-#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c))
#ifndef _rl_to_upper
-# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c))
-# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c))
+# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)(c)) : (c))
+# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)(c)) : (c))
#endif
#ifndef _rl_digit_value
diff --git a/lib/readline/colors.c b/lib/readline/colors.c
index 9e37527e..dba81a27 100644
--- a/lib/readline/colors.c
+++ b/lib/readline/colors.c
@@ -2,7 +2,7 @@
Modified by Chet Ramey for Readline.
- Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015, 2017, 2019
+ Copyright (C) 1985, 1988, 1990-1991, 1995-2021
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
@@ -73,6 +73,8 @@
static bool is_colored (enum indicator_no type);
static void restore_default_color (void);
+#define RL_COLOR_PREFIX_EXTENSION "readline-colored-completion-prefix"
+
COLOR_EXT_TYPE *_rl_color_ext_list = 0;
/* Output a color indicator (which may contain nulls). */
@@ -110,13 +112,28 @@ _rl_set_normal_color (void)
}
}
+static struct bin_str *
+_rl_custom_readline_prefix (void)
+{
+ size_t len;
+ COLOR_EXT_TYPE *ext;
+
+ len = strlen (RL_COLOR_PREFIX_EXTENSION);
+ for (ext = _rl_color_ext_list; ext; ext = ext->next)
+ if (ext->ext.len == len && STREQN (ext->ext.string, RL_COLOR_PREFIX_EXTENSION, len))
+ return (&ext->seq);
+ return (NULL);
+}
+
bool
_rl_print_prefix_color (void)
{
struct bin_str *s;
/* What do we want to use for the prefix? Let's try cyan first, see colors.h */
- s = &_rl_color_indicator[C_PREFIX];
+ s = _rl_custom_readline_prefix ();
+ if (s == 0)
+ s = &_rl_color_indicator[C_PREFIX];
if (s->string != NULL)
{
if (is_colored (C_NORM))
@@ -239,8 +256,10 @@ _rl_print_color_indicator (const char *f)
else if (S_ISSOCK (mode))
colored_filetype = C_SOCK;
#endif
+#if defined (S_ISBLK)
else if (S_ISBLK (mode))
colored_filetype = C_BLK;
+#endif
else if (S_ISCHR (mode))
colored_filetype = C_CHR;
else
diff --git a/lib/readline/compat.c b/lib/readline/compat.c
index 3ade3629..fc2a48f4 100644
--- a/lib/readline/compat.c
+++ b/lib/readline/compat.c
@@ -1,6 +1,6 @@
/* compat.c -- backwards compatibility functions. */
-/* Copyright (C) 2000-2017 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -30,18 +30,18 @@
#include "rlstdc.h"
#include "rltypedefs.h"
-extern void rl_free_undo_list PARAMS((void));
-extern int rl_maybe_save_line PARAMS((void));
-extern int rl_maybe_unsave_line PARAMS((void));
-extern int rl_maybe_replace_line PARAMS((void));
+extern void rl_free_undo_list (void);
+extern int rl_maybe_save_line (void);
+extern int rl_maybe_unsave_line (void);
+extern int rl_maybe_replace_line (void);
-extern int rl_crlf PARAMS((void));
-extern int rl_ding PARAMS((void));
-extern int rl_alphabetic PARAMS((int));
+extern int rl_crlf (void);
+extern int rl_ding (void);
+extern int rl_alphabetic (int);
-extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
-extern char *rl_username_completion_function PARAMS((const char *, int));
-extern char *rl_filename_completion_function PARAMS((const char *, int));
+extern char **rl_completion_matches (const char *, rl_compentry_func_t *);
+extern char *rl_username_completion_function (const char *, int);
+extern char *rl_filename_completion_function (const char *, int);
/* Provide backwards-compatible entry points for old function names. */
diff --git a/lib/readline/complete.c b/lib/readline/complete.c
index fc5c3adb..e5d224ed 100644
--- a/lib/readline/complete.c
+++ b/lib/readline/complete.c
@@ -1,6 +1,6 @@
/* complete.c -- filename completion for readline. */
-/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -95,7 +95,7 @@ typedef int QSFUNC ();
/* Most systems don't declare getpwent in <pwd.h> if _POSIX_SOURCE is
defined. */
#if defined (HAVE_GETPWENT) && (!defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE))
-extern struct passwd *getpwent PARAMS((void));
+extern struct passwd *getpwent (void);
#endif /* HAVE_GETPWENT && (!HAVE_GETPW_DECLS || _POSIX_SOURCE) */
/* If non-zero, then this is the address of a function to call when
@@ -114,44 +114,44 @@ rl_compdisp_func_t *rl_completion_display_matches_hook = (rl_compdisp_func_t *)N
#endif
#if defined (VISIBLE_STATS)
-static int stat_char PARAMS((char *));
+static int stat_char (char *);
#endif
#if defined (COLOR_SUPPORT)
-static int colored_stat_start PARAMS((const char *));
-static void colored_stat_end PARAMS((void));
-static int colored_prefix_start PARAMS((void));
-static void colored_prefix_end PARAMS((void));
+static int colored_stat_start (const char *);
+static void colored_stat_end (void);
+static int colored_prefix_start (void);
+static void colored_prefix_end (void);
#endif
-static int path_isdir PARAMS((const char *));
+static int path_isdir (const char *);
-static char *rl_quote_filename PARAMS((char *, int, char *));
+static char *rl_quote_filename (char *, int, char *);
-static void _rl_complete_sigcleanup PARAMS((int, void *));
+static void _rl_complete_sigcleanup (int, void *);
-static void set_completion_defaults PARAMS((int));
-static int get_y_or_n PARAMS((int));
-static int _rl_internal_pager PARAMS((int));
-static char *printable_part PARAMS((char *));
-static int fnwidth PARAMS((const char *));
-static int fnprint PARAMS((const char *, int, const char *));
-static int print_filename PARAMS((char *, char *, int));
+static void set_completion_defaults (int);
+static int get_y_or_n (int);
+static int _rl_internal_pager (int);
+static char *printable_part (char *);
+static int fnwidth (const char *);
+static int fnprint (const char *, int, const char *);
+static int print_filename (char *, char *, int);
-static char **gen_completion_matches PARAMS((char *, int, int, rl_compentry_func_t *, int, int));
+static char **gen_completion_matches (char *, int, int, rl_compentry_func_t *, int, int);
-static char **remove_duplicate_matches PARAMS((char **));
-static void insert_match PARAMS((char *, int, int, char *));
-static int append_to_match PARAMS((char *, int, int, int));
-static void insert_all_matches PARAMS((char **, int, char *));
-static int complete_fncmp PARAMS((const char *, int, const char *, int));
-static void display_matches PARAMS((char **));
-static int compute_lcd_of_matches PARAMS((char **, int, const char *));
-static int postprocess_matches PARAMS((char ***, int));
-static int compare_match PARAMS((char *, const char *));
-static int complete_get_screenwidth PARAMS((void));
+static char **remove_duplicate_matches (char **);
+static void insert_match (char *, int, int, char *);
+static int append_to_match (char *, int, int, int);
+static void insert_all_matches (char **, int, char *);
+static int complete_fncmp (const char *, int, const char *, int);
+static void display_matches (char **);
+static int compute_lcd_of_matches (char **, int, const char *);
+static int postprocess_matches (char ***, int);
+static int compare_match (char *, const char *);
+static int complete_get_screenwidth (void);
-static char *make_quoted_replacement PARAMS((char *, int, char *));
+static char *make_quoted_replacement (char *, int, char *);
/* **************************************************************** */
/* */
@@ -304,7 +304,7 @@ const char *rl_basic_quote_characters = "\"'";
/* The list of characters that signal a break between words for
rl_complete_internal. The default list is the contents of
rl_basic_word_break_characters. */
-/*const*/ char *rl_completer_word_break_characters = (/*const*/ char *)NULL;
+const char *rl_completer_word_break_characters = 0;
/* Hook function to allow an application to set the completion word
break characters before readline breaks up the line. Allows
@@ -757,7 +757,7 @@ fnwidth (const char *string)
mbstate_t ps;
int left, w;
size_t clen;
- wchar_t wc;
+ WCHAR_T wc;
left = strlen (string) + 1;
memset (&ps, 0, sizeof (mbstate_t));
@@ -774,7 +774,7 @@ fnwidth (const char *string)
else
{
#if defined (HANDLE_MULTIBYTE)
- clen = mbrtowc (&wc, string + pos, left - pos, &ps);
+ clen = MBRTOWC (&wc, string + pos, left - pos, &ps);
if (MB_INVALIDCH (clen))
{
width++;
@@ -812,7 +812,7 @@ fnprint (const char *to_print, int prefix_bytes, const char *real_pathname)
const char *end;
size_t tlen;
int width;
- wchar_t wc;
+ WCHAR_T wc;
print_len = strlen (to_print);
end = to_print + print_len + 1;
@@ -835,7 +835,8 @@ fnprint (const char *to_print, int prefix_bytes, const char *real_pathname)
colored_stat_start (real_pathname);
#endif
- if (prefix_bytes && _rl_completion_prefix_display_length > 0)
+ if (prefix_bytes && _rl_completion_prefix_display_length > 0 &&
+ prefix_bytes > _rl_completion_prefix_display_length)
{
char ellipsis;
@@ -880,7 +881,7 @@ fnprint (const char *to_print, int prefix_bytes, const char *real_pathname)
else
{
#if defined (HANDLE_MULTIBYTE)
- tlen = mbrtowc (&wc, s, end - s, &ps);
+ tlen = MBRTOWC (&wc, s, end - s, &ps);
if (MB_INVALIDCH (tlen))
{
tlen = 1;
@@ -1078,7 +1079,8 @@ char
_rl_find_completion_word (int *fp, int *dp)
{
int scan, end, found_quote, delimiter, pass_next, isbrk;
- char quote_char, *brkchars;
+ char quote_char;
+ const char *brkchars;
end = rl_point;
found_quote = delimiter = 0;
@@ -1321,7 +1323,7 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
int v;
size_t v1, v2;
mbstate_t ps1, ps2;
- wchar_t wc1, wc2;
+ WCHAR_T wc1, wc2;
#endif
/* If only one match, just use that. Otherwise, compare each
@@ -1353,8 +1355,8 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
- v1 = mbrtowc(&wc1, match_list[i]+si, strlen (match_list[i]+si), &ps1);
- v2 = mbrtowc (&wc2, match_list[i+1]+si, strlen (match_list[i+1]+si), &ps2);
+ v1 = MBRTOWC (&wc1, match_list[i]+si, strlen (match_list[i]+si), &ps1);
+ v2 = MBRTOWC (&wc2, match_list[i+1]+si, strlen (match_list[i+1]+si), &ps2);
if (MB_INVALIDCH (v1) || MB_INVALIDCH (v2))
{
if (c1 != c2) /* do byte comparison */
@@ -1364,7 +1366,7 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
if (_rl_completion_case_fold)
{
wc1 = towlower (wc1);
- wc2 = towlower (wc2);
+ wc2 = towlower (wc2);
}
if (wc1 != wc2)
break;
@@ -1547,7 +1549,7 @@ rl_display_match_list (char **matches, int len, int max)
if (common_length > _rl_completion_prefix_display_length && common_length > ELLIPSIS_LEN)
max -= common_length - ELLIPSIS_LEN;
- else
+ else if (_rl_colored_completion_prefix <= 0)
common_length = sind = 0;
}
#if defined (COLOR_SUPPORT)
@@ -1979,7 +1981,7 @@ compare_match (char *text, const char *match)
{
temp = (*rl_filename_dequoting_function) (text, rl_completion_quote_character);
r = strcmp (temp, match);
- free (temp);
+ xfree (temp);
return r;
}
return (strcmp (text, match));
@@ -2330,7 +2332,7 @@ complete_fncmp (const char *convfn, int convlen, const char *filename, int filen
#if defined (HANDLE_MULTIBYTE)
size_t v1, v2;
mbstate_t ps1, ps2;
- wchar_t wc1, wc2;
+ WCHAR_T wc1, wc2;
#endif
#if defined (HANDLE_MULTIBYTE)
@@ -2357,8 +2359,8 @@ complete_fncmp (const char *convfn, int convlen, const char *filename, int filen
{
do
{
- v1 = mbrtowc (&wc1, s1, convlen, &ps1);
- v2 = mbrtowc (&wc2, s2, filename_len, &ps2);
+ v1 = MBRTOWC (&wc1, s1, convlen, &ps1);
+ v2 = MBRTOWC (&wc2, s2, filename_len, &ps2);
if (v1 == 0 && v2 == 0)
return 1;
else if (MB_INVALIDCH (v1) || MB_INVALIDCH (v2))
@@ -2407,8 +2409,8 @@ complete_fncmp (const char *convfn, int convlen, const char *filename, int filen
{
do
{
- v1 = mbrtowc (&wc1, s1, convlen, &ps1);
- v2 = mbrtowc (&wc2, s2, filename_len, &ps2);
+ v1 = MBRTOWC (&wc1, s1, convlen, &ps1);
+ v2 = MBRTOWC (&wc2, s2, filename_len, &ps2);
if (v1 == 0 && v2 == 0)
return 1;
else if (MB_INVALIDCH (v1) || MB_INVALIDCH (v2))
diff --git a/lib/readline/display.c b/lib/readline/display.c
index f5d32945..c1135ec5 100644
--- a/lib/readline/display.c
+++ b/lib/readline/display.c
@@ -1,6 +1,6 @@
/* display.c -- readline redisplay facility. */
-/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -63,23 +63,23 @@
extern char *strchr (), *strrchr ();
#endif /* !strchr && !__STDC__ */
-static void putc_face PARAMS((int, int, char *));
-static void puts_face PARAMS((const char *, const char *, int));
-static void norm_face PARAMS((char *, int));
+static void putc_face (int, int, char *);
+static void puts_face (const char *, const char *, int);
+static void norm_face (char *, int);
-static void update_line PARAMS((char *, char *, char *, char *, int, int, int, int));
-static void space_to_eol PARAMS((int));
-static void delete_chars PARAMS((int));
-static void insert_some_chars PARAMS((char *, int, int));
-static void open_some_spaces PARAMS((int));
-static void cr PARAMS((void));
-static void redraw_prompt PARAMS((char *));
-static void _rl_move_cursor_relative PARAMS((int, const char *, const char *));
+static void update_line (char *, char *, char *, char *, int, int, int, int);
+static void space_to_eol (int);
+static void delete_chars (int);
+static void insert_some_chars (char *, int, int);
+static void open_some_spaces (int);
+static void cr (void);
+static void redraw_prompt (char *);
+static void _rl_move_cursor_relative (int, const char *, const char *);
/* Values for FLAGS */
#define PMT_MULTILINE 0x01
-static char *expand_prompt PARAMS((char *, int, int *, int *, int *, int *));
+static char *expand_prompt (char *, int, int *, int *, int *, int *);
#define DEFAULT_LINE_BUFFER_SIZE 1024
@@ -115,7 +115,7 @@ static int line_structures_initialized = 0;
#define inv_face (line_state_invisible->lface)
#if defined (HANDLE_MULTIBYTE)
-static int _rl_col_width PARAMS((const char *, int, int, int));
+static int _rl_col_width (const char *, int, int, int);
#else
# define _rl_col_width(l, s, e, f) (((e) <= (s)) ? 0 : (e) - (s))
#endif
@@ -356,7 +356,7 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp)
{
char *r, *ret, *p, *igstart, *nprompt, *ms;
int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars;
- int mlen, newlines, newlines_guess, bound;
+ int mlen, newlines, newlines_guess, bound, can_add_invis;
int mb_cur_max;
/* We only expand the mode string for the last line of a multiline prompt
@@ -372,6 +372,7 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp)
else
nprompt = pmt;
+ can_add_invis = 0;
mb_cur_max = MB_CUR_MAX;
if (_rl_screenwidth == 0)
@@ -434,6 +435,19 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp)
else if (ignoring && *p == RL_PROMPT_END_IGNORE)
{
ignoring = 0;
+ /* If we have a run of invisible characters, adjust local_prompt_newlines
+ to add them, since update_line expects them to be counted before
+ wrapping the line. */
+ if (can_add_invis)
+ {
+ local_prompt_newlines[newlines] = r - ret;
+ /* If we're adding to the number of invisible characters on the
+ first line of the prompt, but we've already set the number of
+ invisible characters on that line, we need to adjust the
+ counter. */
+ if (invflset && newlines == 1)
+ invfl = ninvis;
+ }
if (p != (igstart + 1))
last = r - ret - 1;
continue;
@@ -498,10 +512,17 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp)
new = r - ret;
local_prompt_newlines[++newlines] = new;
}
+
+ /* What if a physical character of width >= 2 is split? There is
+ code that wraps before the physical screen width if the character
+ width would exceed it, but it needs to be checked against this
+ code and local_prompt_newlines[]. */
+ if (ignoring == 0)
+ can_add_invis = (physchars == bound);
}
}
- if (rl < _rl_screenwidth)
+ if (rl <= _rl_screenwidth)
invfl = ninvis;
*r = '\0';
@@ -515,7 +536,7 @@ expand_prompt (char *pmt, int flags, int *lp, int *lip, int *niflp, int *vlp)
*vlp = physchars;
if (nprompt != pmt)
- free (nprompt);
+ xfree (nprompt);
return ret;
}
@@ -749,7 +770,7 @@ rl_redisplay (void)
int hl_begin, hl_end;
int mb_cur_max = MB_CUR_MAX;
#if defined (HANDLE_MULTIBYTE)
- wchar_t wc;
+ WCHAR_T wc;
size_t wc_bytes;
int wc_width;
mbstate_t ps;
@@ -983,11 +1004,11 @@ rl_redisplay (void)
memset (&ps, 0, sizeof (mbstate_t));
if (_rl_utf8locale && UTF8_SINGLEBYTE(rl_line_buffer[0]))
{
- wc = (wchar_t)rl_line_buffer[0];
+ wc = (WCHAR_T)rl_line_buffer[0];
wc_bytes = 1;
}
else
- wc_bytes = mbrtowc (&wc, rl_line_buffer, rl_end, &ps);
+ wc_bytes = MBRTOWC (&wc, rl_line_buffer, rl_end, &ps);
}
else
wc_bytes = 1;
@@ -1158,12 +1179,12 @@ rl_redisplay (void)
in += wc_bytes;
if (_rl_utf8locale && UTF8_SINGLEBYTE(rl_line_buffer[in]))
{
- wc = (wchar_t)rl_line_buffer[in];
+ wc = (WCHAR_T)rl_line_buffer[in];
wc_bytes = 1;
memset (&ps, 0, sizeof (mbstate_t)); /* re-init state */
}
else
- wc_bytes = mbrtowc (&wc, rl_line_buffer + in, rl_end - in, &ps);
+ wc_bytes = MBRTOWC (&wc, rl_line_buffer + in, rl_end - in, &ps);
}
else
in++;
@@ -1582,9 +1603,9 @@ putc_face (int c, int face, char *cur_face)
if (face != FACE_NORMAL && face != FACE_STANDOUT)
return;
if (face == FACE_STANDOUT && cf == FACE_NORMAL)
- _rl_standout_on ();
+ _rl_region_color_on ();
if (face == FACE_NORMAL && cf == FACE_STANDOUT)
- _rl_standout_off ();
+ _rl_region_color_off ();
*cur_face = face;
}
if (c != EOF)
@@ -1662,7 +1683,7 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
#if defined (HANDLE_MULTIBYTE)
if (mb_cur_max > 1 && rl_byte_oriented == 0)
{
- wchar_t wc;
+ WCHAR_T wc;
mbstate_t ps;
int oldwidth, newwidth;
int oldbytes, newbytes;
@@ -1681,7 +1702,7 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
/* 1. how many screen positions does first char in old consume? */
memset (&ps, 0, sizeof (mbstate_t));
- ret = mbrtowc (&wc, old, mb_cur_max, &ps);
+ ret = MBRTOWC (&wc, old, mb_cur_max, &ps);
oldbytes = ret;
if (MB_INVALIDCH (ret))
{
@@ -1697,7 +1718,7 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
/* 2. how many screen positions does the first char in new consume? */
memset (&ps, 0, sizeof (mbstate_t));
- ret = mbrtowc (&wc, new, mb_cur_max, &ps);
+ ret = MBRTOWC (&wc, new, mb_cur_max, &ps);
newbytes = ret;
if (MB_INVALIDCH (ret))
{
@@ -1718,7 +1739,7 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
{
int t;
- ret = mbrtowc (&wc, new+newbytes, mb_cur_max, &ps);
+ ret = MBRTOWC (&wc, new+newbytes, mb_cur_max, &ps);
if (MB_INVALIDCH (ret))
{
newwidth += 1;
@@ -1740,7 +1761,7 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
{
int t;
- ret = mbrtowc (&wc, old+oldbytes, mb_cur_max, &ps);
+ ret = MBRTOWC (&wc, old+oldbytes, mb_cur_max, &ps);
if (MB_INVALIDCH (ret))
{
oldwidth += 1;
@@ -1952,14 +1973,14 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
#if defined (HANDLE_MULTIBYTE)
if (mb_cur_max > 1 && rl_byte_oriented == 0 && _rl_utf8locale)
{
- wchar_t wc;
+ WCHAR_T wc;
mbstate_t ps = { 0 };
int t;
/* If the first character in the difference is a zero-width character,
assume it's a combining character and back one up so the two base
characters no longer compare equivalently. */
- t = mbrtowc (&wc, ofd, mb_cur_max, &ps);
+ t = MBRTOWC (&wc, ofd, mb_cur_max, &ps);
if (t > 0 && UNICODE_COMBINING_CHAR (wc) && WCWIDTH (wc) == 0)
{
old_offset = _rl_find_prev_mbchar (old, ofd - old, MB_FIND_ANY);
@@ -2421,9 +2442,24 @@ dumb_update:
((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth+prompt_invis_chars_first_line))))
ADJUST_CPOS (wrap_offset - prompt_invis_chars_first_line);
- /* XXX - what happens if wrap_offset == prompt_invis_chars_first_line
- and we are drawing the first line (current_line == 0)? We should
- adjust by _rl_last_c_pos -= prompt_invis_chars_first_line */
+ /* What happens if wrap_offset == prompt_invis_chars_first_line
+ and we are drawing the first line (current_line == 0), or if we
+ are drawing the first line and changing the number of invisible
+ characters in the line? If we're starting to draw before the last
+ invisible character in the prompt, we need to adjust by
+ _rl_last_c_pos -= prompt_invis_chars_first_line. This can happen
+ when we finish reading a digit argument (with the "(arg: N)"
+ prompt) and are switching back to displaying a line with a prompt
+ containing invisible characters, since we have to redraw the
+ entire prompt string. */
+ if ((mb_cur_max > 1 && rl_byte_oriented == 0) &&
+ current_line == 0 && wrap_offset &&
+ displaying_prompt_first_line &&
+ wrap_offset == prompt_invis_chars_first_line &&
+ visible_wrap_offset != current_invis_chars &&
+ visible_wrap_offset != prompt_invis_chars_first_line &&
+ ((nfd-new) < prompt_last_invisible))
+ ADJUST_CPOS (prompt_invis_chars_first_line);
}
}
else /* Delete characters from line. */
@@ -2573,7 +2609,8 @@ rl_clear_visible_line (void)
for (curr_line = _rl_last_v_pos; curr_line >= 0; curr_line--)
{
_rl_move_vert (curr_line);
- _rl_clear_to_eol (0);
+ _rl_clear_to_eol (_rl_screenwidth);
+ _rl_cr (); /* in case we use space_to_eol() */
}
return 0;
@@ -3357,27 +3394,16 @@ _rl_redisplay_after_sigwinch (void)
screen line. */
if (_rl_term_cr)
{
- _rl_move_vert (_rl_vis_botlin);
-
- _rl_cr ();
- _rl_last_c_pos = 0;
-
-#if !defined (__MSDOS__)
- if (_rl_term_clreol)
- tputs (_rl_term_clreol, 1, _rl_output_character_function);
- else
-#endif
- {
- space_to_eol (_rl_screenwidth);
- _rl_cr ();
- }
-
+ rl_clear_visible_line ();
if (_rl_last_v_pos > 0)
_rl_move_vert (0);
}
else
rl_crlf ();
+ if (_rl_screenwidth < prompt_visible_length)
+ _rl_reset_prompt (); /* update local_prompt_newlines array */
+
/* Redraw only the last line of a multi-line prompt. */
t = strrchr (rl_display_prompt, '\n');
if (t)
@@ -3451,7 +3477,7 @@ _rl_refresh_line (void)
static int
_rl_col_width (const char *str, int start, int end, int flags)
{
- wchar_t wc;
+ WCHAR_T wc;
mbstate_t ps;
int tmp, point, width, max;
@@ -3520,10 +3546,10 @@ _rl_col_width (const char *str, int start, int end, int flags)
if (_rl_utf8locale && UTF8_SINGLEBYTE(str[point]))
{
tmp = 1;
- wc = (wchar_t) str[point];
+ wc = (WCHAR_T) str[point];
}
else
- tmp = mbrtowc (&wc, str + point, max, &ps);
+ tmp = MBRTOWC (&wc, str + point, max, &ps);
if (MB_INVALIDCH ((size_t)tmp))
{
/* In this case, the bytes are invalid or too short to compose a
diff --git a/lib/readline/doc/Makefile b/lib/readline/doc/Makefile
index af5ee3e5..2ad833a9 100644
--- a/lib/readline/doc/Makefile
+++ b/lib/readline/doc/Makefile
@@ -18,7 +18,6 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-
topdir = .
srcdir = .
VPATH = .
@@ -49,6 +48,8 @@ TEXI2HTML = $(srcdir)/texi2html
QUIETPS = #set this to -q to shut up dvips
PSDPI = 300 # I don't have any 600-dpi printers
DVIPS = dvips -D ${PSDPI} $(QUIETPS) -o $@ # tricky
+DVIPDF = dvipdfm -o $@ -p ${PAPERSIZE}
+PSPDF = gs -sPAPERSIZE=${PAPERSIZE} -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=$@
RLSRC = $(srcdir)/rlman.texi $(srcdir)/rluser.texi \
$(srcdir)/rltech.texi $(srcdir)/version.texi \
@@ -66,15 +67,25 @@ 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
+PDFOBJ = readline.pdf history.pdf rluserman.pdf
INTERMEDIATE_OBJ = rlman.dvi
-CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ)
+CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ) $(PDFOBJ)
+
+.SUFFIXES: .ps .txt .dvi .html .pdf
-.SUFFIXES: .ps .txt .dvi
+.ps.pdf:
+ $(RM) $@
+ -${PSPDF} $<
-all: info dvi html ps
+.dvi.pdf:
+ $(RM) $@
+ -${DVIPDF} $<
+
+all: info dvi html ps
nodvi: info html
+pdf: $(PDFOBJ)
readline.dvi: $(RLSRC)
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rlman.texi
@@ -123,14 +134,17 @@ dvi: $(DVIOBJ)
ps: $(PSOBJ)
html: $(HTMLOBJ)
+readline.pdf: readline.dvi
+history.pdf: history.dvi
+rluserman.pdf: rluserman.dvi
+
clean:
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
- *.fns *.kys *.tps *.vrs *.o core
+ *.fns *.kys *.tps *.vrs *.bt *.bts *.o core *.core
distclean: clean
$(RM) $(CREATED_DOCS)
$(RM) $(INTERMEDIATE_OBJ)
- $(RM) Makefile
mostlyclean: clean
diff --git a/lib/readline/doc/history.texi b/lib/readline/doc/history.texi
index 7a3a4767..721118bc 100644
--- a/lib/readline/doc/history.texi
+++ b/lib/readline/doc/history.texi
@@ -12,7 +12,7 @@ This document describes the GNU History library
a programming tool that provides a consistent user interface for
recalling lines of previously typed input.
-Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
diff --git a/lib/readline/doc/hstech.texi b/lib/readline/doc/hstech.texi
index 7ac11953..da6417b4 100644
--- a/lib/readline/doc/hstech.texi
+++ b/lib/readline/doc/hstech.texi
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
-Copyright (C) 1988-2020 Free Software Foundation, Inc.
+Copyright (C) 1988-2022 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
diff --git a/lib/readline/doc/hsuser.texi b/lib/readline/doc/hsuser.texi
index b8fedf33..9081baf8 100644
--- a/lib/readline/doc/hsuser.texi
+++ b/lib/readline/doc/hsuser.texi
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
-Copyright (C) 1988--2020 Free Software Foundation, Inc.
+Copyright (C) 1988--2022 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
@@ -214,8 +214,9 @@ end of the history, and an index of @samp{-1} refers to the current
@code{history -d} command.
@item -d @var{start}-@var{end}
-Delete the history entries between positions @var{start} and @var{end},
-inclusive. Positive and negative values for @var{start} and @var{end}
+Delete the range of history entries between positions @var{start} and
+@var{end}, inclusive.
+Positive and negative values for @var{start} and @var{end}
are interpreted as described above.
@item -a
@@ -245,10 +246,15 @@ the history list as a single entry.
@end table
-When any of the @option{-w}, @option{-r}, @option{-a}, or @option{-n} options is
-used, if @var{filename}
-is given, then it is used as the history file. If not, then
-the value of the @env{HISTFILE} variable is used.
+If a @var{filename} argument is supplied
+when any of the @option{-w}, @option{-r}, @option{-a}, or @option{-n} options
+is used, Bash uses @var{filename} as the history file.
+If not, then the value of the @env{HISTFILE} variable is used.
+
+The return value is 0 unless an invalid option is encountered, an
+error occurs while reading or writing the history file, an invalid
+@var{offset} or range is supplied as an argument to @option{-d}, or the
+history expansion supplied as an argument to @option{-p} fails.
@end table
@end ifset
@@ -507,7 +513,7 @@ substituted, or, if no previous history substitutions took place,
the last @var{string}
in a !?@var{string}@code{[?]}
search.
-If @var{new} is is null, each matching @var{old} is deleted.
+If @var{new} is null, each matching @var{old} is deleted.
The final delimiter is optional if it is the last
character on the input line.
diff --git a/lib/readline/doc/rlman.texi b/lib/readline/doc/rlman.texi
index ec7487b7..d046b87d 100644
--- a/lib/readline/doc/rlman.texi
+++ b/lib/readline/doc/rlman.texi
@@ -13,7 +13,7 @@ This manual describes the GNU Readline Library
consistency of user interface across discrete programs which provide
a command line interface.
-Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi
index bbf57c23..a93f77da 100644
--- a/lib/readline/doc/rltech.texi
+++ b/lib/readline/doc/rltech.texi
@@ -7,7 +7,7 @@ This document describes the GNU Readline Library, a utility for aiding
in the consistency of user interface across discrete programs that need
to provide a command line interface.
-Copyright (C) 1988--2020 Free Software Foundation, Inc.
+Copyright (C) 1988--2022 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -323,6 +323,14 @@ and point define a @emph{region}.
@deftypevar int rl_done
Setting this to a non-zero value causes Readline to return the current
line immediately.
+Readline will set this variable when it has read a key sequence bound
+to @code{accept-line} and is about to return the line to the caller.
+@end deftypevar
+
+@deftypevar int rl_eof_found
+Readline will set this variable when it has read an EOF character (e.g., the
+stty @samp{EOF} character) on an empty line or encountered a read error and
+is about to return a NULL line to the caller.
@end deftypevar
@deftypevar int rl_num_chars_to_read
@@ -385,7 +393,7 @@ value 0x0402.
@end deftypevar
@deftypevar {int} rl_gnu_readline_p
-Always set to 1, denoting that this is @sc{gnu} readline rather than some
+Always set to 1, denoting that this is @sc{gnu} Readline rather than some
emulation.
@end deftypevar
@@ -455,6 +463,11 @@ If non-zero, this is the address of a function to call if a read system
call is interrupted when Readline is reading terminal input.
@end deftypevar
+@deftypevar {rl_hook_func_t *} rl_timeout_event_hook
+If non-zero, this is the address of a function to call if Readline times
+out while reading input.
+@end deftypevar
+
@deftypevar {rl_hook_func_t *} rl_input_available_hook
If non-zero, Readline will use this function's return value when it needs
to determine whether or not there is available input on the current input
@@ -502,7 +515,7 @@ By default, this is set to @code{rl_deprep_terminal}
@deftypevar {Keymap} rl_executing_keymap
This variable is set to the keymap (@pxref{Keymaps}) in which the
-currently executing readline function was found.
+currently executing Readline function was found.
@end deftypevar
@deftypevar {Keymap} rl_binding_keymap
@@ -588,6 +601,13 @@ the current call to @code{readline()}.
@item RL_STATE_DONE
Readline has read a key sequence bound to @code{accept-line}
and is about to return the line to the caller.
+@item RL_STATE_TIMEOUT
+Readline has timed out (it did not receive a line or specified number of
+characters before the timeout duration specified by @code{rl_set_timeout}
+elapsed) and is returning that status to the caller.
+@item RL_STATE_EOF
+Readline has read an EOF character (e.g., the stty @samp{EOF} character)
+or encountered a read error and is about to return a NULL line to the caller.
@end table
@end deftypevar
@@ -876,6 +896,15 @@ It takes a "translated" key sequence and should be used if the key sequence
can include NUL.
@end deftypefun
+@deftypefun {int} rl_trim_arg_from_keyseq (const char *keyseq, size_t len, Keymap map)
+If there is a numeric argument at the beginning of @var{keyseq}, possibly
+including digits, return the index of the first character in @var{keyseq}
+following the numeric argument.
+This can be used to skip over the numeric argument (which is available as
+@code{rl_numeric_arg} while traversing the key sequence that invoked the
+current command.
+@end deftypefun
+
@deftypefun {char **} rl_invoking_keyseqs (rl_command_func_t *function)
Return an array of strings representing the key sequences used to
invoke @var{function} in the current keymap.
@@ -887,7 +916,7 @@ invoke @var{function} in the keymap @var{map}.
@end deftypefun
@deftypefun void rl_function_dumper (int readable)
-Print the readline function names and the key sequences currently
+Print the Readline function names and the key sequences currently
bound to them to @code{rl_outstream}. If @var{readable} is non-zero,
the list is formatted in such a way that it can be made part of an
@code{inputrc} file and re-read.
@@ -1063,8 +1092,9 @@ It returns the number of visible characters on the last line of the
Applications may indicate that the prompt contains characters that take
up no physical screen space when displayed by bracketing a sequence of
such characters with the special markers @code{RL_PROMPT_START_IGNORE}
-and @code{RL_PROMPT_END_IGNORE} (declared in @file{readline.h}). This may
-be used to embed terminal-specific escape sequences in prompts.
+and @code{RL_PROMPT_END_IGNORE} (declared in @file{readline.h} as
+@samp{\001} and @samp{\002}, respectively).
+This may be used to embed terminal-specific escape sequences in prompts.
@end deftypefun
@deftypefun int rl_set_prompt (const char *prompt)
@@ -1151,6 +1181,30 @@ The default waiting period is one-tenth of a second.
Returns the old timeout value.
@end deftypefun
+@deftypefun int rl_set_timeout (unsigned int secs, unsigned int usecs)
+Set a timeout for subsequent calls to @code{readline()}. If Readline does
+not read a complete line, or the number of characters specified by
+@code{rl_num_chars_to_read}, before the duration specified by @var{secs}
+(in seconds) and @var{usecs} (microseconds), it returns and sets
+@code{RL_STATE_TIMEOUT} in @code{rl_readline_state}.
+Passing 0 for @code{secs} and @code{usecs} cancels any previously set
+timeout; the convenience macro @code{rl_clear_timeout()} is shorthand
+for this.
+Returns 0 if the timeout is set successfully.
+@end deftypefun
+
+@deftypefun int rl_timeout_remaining (unsigned int *secs, unsigned int *usecs)
+Return the number of seconds and microseconds remaining in the current
+timeout duration in @var{*secs} and @var{*usecs}, respectively.
+Both @var{*secs} and @var{*usecs} must be non-NULL to return any values.
+The return value is -1 on error or when there is no timeout set,
+0 when the timeout has expired (leaving @var{*secs} and @var{*usecs}
+unchanged),
+and 1 if the timeout has not expired.
+If either of @var{secs} and @var{usecs} is @code{NULL},
+the return value indicates whether the timeout has expired.
+@end deftypefun
+
@node Terminal Management
@subsection Terminal Management
@@ -1304,7 +1358,7 @@ that it can be made part of an @code{inputrc} file and re-read.
@deftypefun int rl_variable_bind (const char *variable, const char *value)
Make the Readline variable @var{variable} have @var{value}.
-This behaves as if the readline command
+This behaves as if the Readline command
@samp{set @var{variable} @var{value}} had been executed in an @code{inputrc}
file (@pxref{Readline Init File Syntax}).
@end deftypefun
@@ -1315,7 +1369,7 @@ For boolean variables, this string is either @samp{on} or @samp{off}.
@end deftypefun
@deftypefun void rl_variable_dumper (int readable)
-Print the readline variable names and their current values
+Print the Readline variable names and their current values
to @code{rl_outstream}.
If @var{readable} is non-zero, the list is formatted in such a way
that it can be made part of an @code{inputrc} file and re-read.
@@ -1346,7 +1400,7 @@ Readline saves in the history list.
Enable an @emph{active} mark.
When this is enabled, the text between point and mark (the @var{region}) is
displayed in the terminal's standout mode (a @var{face}).
-This is called by various readline functions that set the mark and insert
+This is called by various Readline functions that set the mark and insert
text, and is available for applications to call.
@end deftypefun
@@ -1355,10 +1409,10 @@ Turn off the active mark.
@end deftypefun
@deftypefun {void} rl_keep_mark_active (void)
-Indicate that the mark should remain active when the current readline function
-completes and after redisplay occurs.
+Indicate that the mark should remain active when the current Readline
+function completes and after redisplay occurs.
In most cases, the mark remains active for only the duration of a single
-bindable readline function.
+bindable Readline function.
@end deftypefun
@deftypefun {int} rl_mark_active_p (void)
@@ -1371,12 +1425,12 @@ Return a non-zero value if the mark is currently active; zero otherwise.
An alternate interface is available to plain @code{readline()}. Some
applications need to interleave keyboard I/O with file, device, or
window system I/O, typically by using a main loop to @code{select()}
-on various file descriptors. To accommodate this need, readline can
+on various file descriptors. To accommodate this need, Readline can
also be invoked as a `callback' function from an event loop. There
are functions available to make this easy.
@deftypefun void rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *lhandler)
-Set up the terminal for readline I/O and display the initial
+Set up the terminal for Readline I/O and display the initial
expanded value of @var{prompt}. Save the value of @var{lhandler} to
use as a handler function to call when a complete line of input has been
entered.
@@ -1611,7 +1665,7 @@ main (int c, char **v)
Signals are asynchronous events sent to a process by the Unix kernel,
sometimes on behalf of another process. They are intended to indicate
-exceptional events, like a user pressing the interrupt key on his terminal,
+exceptional events, like a user pressing the terminal's interrupt key,
or a network connection being broken. There is a class of signals that can
be sent to the process currently reading input from the keyboard. Since
Readline changes the terminal attributes when it is called, it needs to
@@ -1761,7 +1815,7 @@ a @code{SIGWINCH}.
@deftypefun void rl_echo_signal_char (int sig)
If an application wishes to install its own signal handlers, but still
-have readline display characters that generate signals, calling this
+have Readline display characters that generate signals, calling this
function with @var{sig} set to @code{SIGINT}, @code{SIGQUIT}, or
@code{SIGTSTP} will display the character generating that signal.
@end deftypefun
@@ -2159,9 +2213,10 @@ shell variables and hostnames.
@deftypevar int rl_completion_query_items
Up to this many items will be displayed in response to a
-possible-completions call. After that, readline asks the user if she is sure
-she wants to see them all. The default value is 100. A negative value
-indicates that Readline should never ask the user.
+possible-completions call. After that, Readline asks the user for
+confirmation before displaying them.
+The default value is 100. A negative value
+indicates that Readline should never ask for confirmation.
@end deftypevar
@deftypevar {int} rl_completion_append_character
@@ -2313,6 +2368,7 @@ history list.
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>
+#include <locale.h>
#if defined (HAVE_STRING_H)
# include <string.h>
@@ -2393,6 +2449,8 @@ main (argc, argv)
@{
char *line, *s;
+ setlocale (LC_ALL, "");
+
progname = argv[0];
initialize_readline (); /* Bind our completer. */
diff --git a/lib/readline/doc/rluser.texi b/lib/readline/doc/rluser.texi
index 26b0ff07..cbcbb45c 100644
--- a/lib/readline/doc/rluser.texi
+++ b/lib/readline/doc/rluser.texi
@@ -9,7 +9,7 @@ use these features. There is a document entitled "readline.texinfo"
which contains both end-user and programmer documentation for the
GNU Readline Library.
-Copyright (C) 1988--2020 Free Software Foundation, Inc.
+Copyright (C) 1988--2022 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
@@ -179,7 +179,7 @@ empty line.
@end table
@noindent
-(Depending on your configuration, the @key{Backspace} key be set to
+(Depending on your configuration, the @key{Backspace} key might 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 @kbd{C-d}, rather
than the character to the left of the cursor.)
@@ -246,7 +246,7 @@ words, to the end of the next word.
Word boundaries are the same as those used by @kbd{M-f}.
@item M-@key{DEL}
-Kill from the cursor the start of the current word, or, if between
+Kill from the cursor to the start of the current word, or, if between
words, to the start of the previous word.
Word boundaries are the same as those used by @kbd{M-b}.
@@ -339,7 +339,8 @@ 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, conventionally in his home directory.
+commands in an @dfn{inputrc} file,
+conventionally in their home directory.
The name of this
@ifset BashFeatures
file is taken from the value of the shell variable @env{INPUTRC}. If
@@ -418,6 +419,32 @@ variables.
@cindex variables, readline
@table @code
+@item active-region-start-color
+@vindex active-region-start-color
+A string variable that controls the text color and background when displaying
+the text in the active region (see the description of
+@code{enable-active-region} below).
+This string must not take up any physical character positions on the display,
+so it should consist only of terminal escape sequences.
+It is output to the terminal before displaying the text in the active region.
+This variable is reset to the default value whenever the terminal type changes.
+The default value is the string that puts the terminal in standout mode,
+as obtained from the terminal's terminfo description.
+A sample value might be @samp{\e[01;33m}.
+
+@item active-region-end-color
+@vindex active-region-end-color
+A string variable that "undoes" the effects of @code{active-region-start-color}
+and restores "normal" terminal display appearance after displaying text
+in the active region.
+This string must not take up any physical character positions on the display,
+so it should consist only of terminal escape sequences.
+It is output to the terminal after displaying the text in the active region.
+This variable is reset to the default value whenever the terminal type changes.
+The default value is the string that restores the terminal from standout mode,
+as obtained from the terminal's terminfo description.
+A sample value might be @samp{\e[0m}.
+
@item bell-style
@vindex bell-style
Controls what happens when Readline wants to ring the terminal bell.
@@ -444,6 +471,9 @@ If set to @samp{on}, when listing completions, Readline displays the
common prefix of the set of possible completions using a different color.
The color definitions are taken from the value of the @env{LS_COLORS}
environment variable.
+If there is a color definition in @env{LS_COLORS} for the custom suffix
+@samp{readline-colored-completion-prefix}, Readline uses this color for
+the common prefix instead of its default.
The default is @samp{off}.
@item colored-stats
@@ -496,8 +526,9 @@ asked whether the list of possibilities should be displayed.
If the number of possible completions is greater than or equal to this value,
Readline will ask whether or not the user wishes to view them;
otherwise, they are simply listed.
-This variable must be set to an integer value greater than or equal to 0.
-A negative value means Readline should never ask.
+This variable must be set to an integer value greater than or equal to zero.
+A zero value means Readline should never ask; negative values are
+treated as zero.
The default limit is @code{100}.
@item convert-meta
@@ -505,9 +536,12 @@ The default limit is @code{100}.
If set to @samp{on}, Readline will convert characters with the
eighth bit set to an @sc{ascii} key sequence by stripping the eighth
bit and prefixing an @key{ESC} character, converting them to a
-meta-prefixed key sequence. The default value is @samp{on}, but
+meta-prefixed key sequence.
+The default value is @samp{on}, but
will be set to @samp{off} if the locale is one that contains
eight-bit characters.
+This variable is dependent on the @code{LC_CTYPE} locale category, and
+may change if the locale is changed.
@item disable-completion
@vindex disable-completion
@@ -518,7 +552,7 @@ been mapped to @code{self-insert}. The default is @samp{off}.
@item echo-control-characters
@vindex echo-control-characters
When set to @samp{on}, on operating systems that indicate they support it,
-readline echoes a character corresponding to a signal generated from the
+Readline echoes a character corresponding to a signal generated from the
keyboard. The default is @samp{on}.
@item editing-mode
@@ -540,13 +574,30 @@ non-printing characters, which can be used to embed a terminal control
sequence into the mode string.
The default is @samp{@@}.
+@item enable-active-region
+@vindex enable-active-region
+The @dfn{point} is the current cursor position, and @dfn{mark} refers
+to a saved cursor position (@pxref{Commands For Moving}).
+The text between the point and mark is referred to as the @dfn{region}.
+When this variable is set to @samp{On}, Readline allows certain commands
+to designate the region as @dfn{active}.
+When the region is active, Readline highlights the text in the region using
+the value of the @code{active-region-start-color}, which defaults to the
+string that enables
+the terminal's standout mode.
+The active region shows the text inserted by bracketed-paste and any
+matching text found by incremental and non-incremental history searches.
+The default is @samp{On}.
+
@item enable-bracketed-paste
@vindex enable-bracketed-paste
-When set to @samp{On}, Readline will configure the terminal in a way
-that will enable it to insert each paste into the editing buffer as a
-single string of characters, instead of treating each character as if
-it had been read from the keyboard. This can prevent pasted characters
-from being interpreted as editing commands. The default is @samp{On}.
+When set to @samp{On}, Readline configures the terminal to insert each
+paste into the editing buffer as a single string of characters, instead
+of treating each character as if it had been read from the keyboard.
+This is called putting the terminal into @dfn{bracketed paste mode};
+it prevents Readline from executing any editing commands bound to key
+sequences appearing in the pasted text.
+The default is @samp{On}.
@item enable-keypad
@vindex enable-keypad
@@ -601,6 +652,8 @@ regardless of what the terminal claims it can support. The
default value is @samp{off}, but Readline will set it to @samp{on} if the
locale contains eight-bit characters.
The name @code{meta-flag} is a synonym for this variable.
+This variable is dependent on the @code{LC_CTYPE} locale category, and
+may change if the locale is changed.
@item isearch-terminators
@vindex isearch-terminators
@@ -683,6 +736,8 @@ eighth bit set directly rather than as a meta-prefixed escape
sequence.
The default is @samp{off}, but Readline will set it to @samp{on} if the
locale contains eight-bit characters.
+This variable is dependent on the @code{LC_CTYPE} locale category, and
+may change if the locale is changed.
@item page-completions
@vindex page-completions
@@ -700,7 +755,7 @@ The default is @samp{off}.
If set to @samp{on}, Readline will undo all changes to history lines
before returning when @code{accept-line} is executed. By default,
history lines may be modified and retain individual undo lists across
-calls to @code{readline}. The default is @samp{off}.
+calls to @code{readline()}. The default is @samp{off}.
@item show-all-if-ambiguous
@vindex show-all-if-ambiguous
@@ -732,7 +787,7 @@ The default value is @samp{off}.
@vindex skip-completed-text
If set to @samp{on}, this alters the default completion behavior when
inserting a single match into the line. It's only active when
-performing completion in the middle of a word. If enabled, readline
+performing completion in the middle of a word. If enabled, Readline
does not insert characters from the completion that match characters
after point in the word being completed, so portions of the word
following the cursor are not duplicated.
@@ -792,12 +847,12 @@ interpreted as part of the key name.
The name of the key can be expressed in different ways, depending on
what you find most comfortable.
-In addition to command names, readline allows keys to be bound
+In addition to command names, Readline allows keys to be bound
to a string that is inserted when the key is pressed (a @var{macro}).
@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.
+bindings in a format that can be put directly into an initialization file.
@xref{Bash Builtins}.
@end ifset
@@ -1332,6 +1387,11 @@ for editing.
A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
+@item fetch-history ()
+With a numeric argument, fetch that entry from the history list
+and make it the current line.
+Without an argument, move back to the first entry in the history list.
+
@end ftable
@node Commands For Text
@@ -1668,7 +1728,7 @@ Re-execute the last keyboard macro defined, by making the characters
in the macro appear as if typed at the keyboard.
@item print-last-kbd-macro ()
-Print the last keboard macro defined in a format suitable for the
+Print the last keyboard macro defined in a format suitable for the
@var{inputrc} file.
@end ftable
@@ -1721,11 +1781,11 @@ the saved position, and the old cursor position is saved as the mark.
@item character-search (C-])
A character is read and point is moved to the next occurrence of that
-character. A negative count searches for previous occurrences.
+character. A negative argument searches for previous occurrences.
@item character-search-backward (M-C-])
A character is read and point is moved to the previous occurrence
-of that character. A negative count searches for subsequent
+of that character. A negative argument searches for subsequent
occurrences.
@item skip-csi-sequence ()
@@ -1733,7 +1793,7 @@ Read enough characters to consume a multi-key sequence such as those
defined for keys like Home and End. Such sequences begin with a
Control Sequence Indicator (CSI), usually ESC-[. If this sequence is
bound to "\e[", keys producing such sequences will have no effect
-unless explicitly bound to a readline command, instead of inserting
+unless explicitly bound to a Readline command, instead of inserting
stray characters into the editing buffer. This is unbound by default,
but usually bound to ESC-[.
@@ -1772,6 +1832,11 @@ the output is formatted in such a way that it can be made part
of an @var{inputrc} file. This command is unbound by default.
@ifset BashFeatures
+@item spell-correct-word (C-x s)
+Perform spelling correction on the current word, treating it as a directory
+or filename, in the same way as the @code{cdspell} shell option.
+Word boundaries are the same as those used by @code{shell-forward-word}.
+
@item glob-complete-word (M-g)
The word before point is treated as a pattern for pathname expansion,
with an asterisk implicitly appended. This pattern is used to
@@ -2224,6 +2289,7 @@ Names of all shell variables. May also be specified as @option{-v}.
@item -C @var{command}
@var{command} is executed in a subshell environment, and its output is
used as the possible completions.
+Arguments are passed as with the @option{-F} option.
@item -F @var{function}
The shell function @var{function} is executed in the current shell
@@ -2401,7 +2467,7 @@ via @var{CDPATH}: Readline can't tell those completions are directories).
The @option{-o nospace} option tells Readline to not append a space
character to the directory name, in case we want to append to it.
The @option{-o bashdefault} option brings in the rest of the "Bash default"
-completions -- possible completion that Bash adds to the default Readline
+completions -- possible completions that Bash adds to the default Readline
set. These include things like command name completion, variable completion
for words beginning with @samp{$} or @samp{$@{}, completions containing pathname
expansion patterns (@pxref{Filename Expansion}), and so on.
diff --git a/lib/readline/doc/rluserman.texi b/lib/readline/doc/rluserman.texi
index 6e8e848b..ae9ec6eb 100644
--- a/lib/readline/doc/rluserman.texi
+++ b/lib/readline/doc/rluserman.texi
@@ -12,7 +12,7 @@ This manual describes the end user interface of the GNU Readline Library
consistency of user interface across discrete programs which provide
a command line interface.
-Copyright @copyright{} 1988--2020 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2022 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi
index abb9cb6b..d3102734 100644
--- a/lib/readline/doc/version.texi
+++ b/lib/readline/doc/version.texi
@@ -1,10 +1,11 @@
@ignore
-Copyright (C) 1988-2020 Free Software Foundation, Inc.
+Copyright (C) 1988-2022 Free Software Foundation, Inc.
@end ignore
-@set EDITION 8.1
-@set VERSION 8.1
-@set UPDATED 29 October 2020
-@set UPDATED-MONTH October 2020
+@set EDITION 8.2
+@set VERSION 8.2
-@set LASTCHANGE Thu Oct 29 16:49:01 EDT 2020
+@set UPDATED 19 September 2022
+@set UPDATED-MONTH September 2022
+
+@set LASTCHANGE Mon Sep 19 11:15:16 EDT 2022
diff --git a/lib/readline/examples/excallback.c b/lib/readline/examples/excallback.c
index 4206acfc..923c9238 100644
--- a/lib/readline/examples/excallback.c
+++ b/lib/readline/examples/excallback.c
@@ -50,6 +50,8 @@ Copyright (C) 1999 Jeff Solomon
#include <stdio.h>
#include <termios.h> /* xxx - should make this more general */
+#include <locale.h>
+
#ifdef READLINE_LIBRARY
# include "readline.h"
#else
@@ -104,6 +106,8 @@ main()
{
fd_set fds;
+ setlocale (LC_ALL, "");
+
/* Adjust the terminal slightly before the handler is installed. Disable
* canonical mode processing and set the input character time flag to be
* non-blocking.
diff --git a/lib/readline/examples/histexamp.c b/lib/readline/examples/histexamp.c
index 3b43674f..309d769b 100644
--- a/lib/readline/examples/histexamp.c
+++ b/lib/readline/examples/histexamp.c
@@ -27,8 +27,11 @@
# include <readline/history.h>
#endif
+#include <unistd.h>
+#include <stdlib.h>
#include <string.h>
+int
main (argc, argv)
int argc;
char **argv;
diff --git a/lib/readline/examples/rl-callbacktest.c b/lib/readline/examples/rl-callbacktest.c
index 0f00e57c..7febacd1 100644
--- a/lib/readline/examples/rl-callbacktest.c
+++ b/lib/readline/examples/rl-callbacktest.c
@@ -7,9 +7,13 @@
#include <sys/types.h>
#include <sys/select.h>
+#include <signal.h>
+
#include <errno.h>
#include <stdio.h>
+#include <locale.h>
+
/* Standard readline include files. */
#if defined (READLINE_LIBRARY)
# include "readline.h"
@@ -22,10 +26,19 @@
extern int errno;
static void cb_linehandler (char *);
+static void signandler (int);
-int running;
+int running, sigwinch_received;
const char *prompt = "rltest$ ";
+/* Handle SIGWINCH and window size changes when readline is not active and
+ reading a character. */
+static void
+sighandler (int sig)
+{
+ sigwinch_received = 1;
+}
+
/* Callback function called for each line when accept-line executed, EOF
seen, or EOF character read. This sets a flag and returns; it could
also call exit(3). */
@@ -60,6 +73,11 @@ main (int c, char **v)
fd_set fds;
int r;
+ setlocale (LC_ALL, "");
+
+ /* Handle SIGWINCH */
+ signal (SIGWINCH, sighandler);
+
/* Install the line handler. */
rl_callback_handler_install (prompt, cb_linehandler);
@@ -80,6 +98,13 @@ main (int c, char **v)
rl_callback_handler_remove ();
break;
}
+ if (sigwinch_received)
+ {
+ rl_resize_terminal ();
+ sigwinch_received = 0;
+ }
+ if (r < 0)
+ continue;
if (FD_ISSET (fileno (rl_instream), &fds))
rl_callback_read_char ();
diff --git a/lib/readline/examples/rl.c b/lib/readline/examples/rl.c
index a5cf276c..39e5b8eb 100644
--- a/lib/readline/examples/rl.c
+++ b/lib/readline/examples/rl.c
@@ -38,6 +38,10 @@
extern void exit();
#endif
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
+
#if defined (READLINE_LIBRARY)
# include "posixstat.h"
# include "readline.h"
@@ -93,6 +97,10 @@ main (argc, argv)
else
progname++;
+#ifdef HAVE_SETLOCALE
+ setlocale (LC_ALL, "");
+#endif
+
/* defaults */
prompt = "readline$ ";
fd = nch = 0;
diff --git a/lib/readline/examples/rlcat.c b/lib/readline/examples/rlcat.c
index b4942413..aabe0ca3 100644
--- a/lib/readline/examples/rlcat.c
+++ b/lib/readline/examples/rlcat.c
@@ -45,6 +45,10 @@
extern void exit();
#endif
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
+
#ifndef errno
extern int errno;
#endif
@@ -79,6 +83,10 @@ main (argc, argv)
char *temp;
int opt, Vflag, Nflag;
+#ifdef HAVE_SETLOCALE
+ setlocale (LC_ALL, ""):
+#endif
+
progname = strrchr(argv[0], '/');
if (progname == 0)
progname = argv[0];
diff --git a/lib/readline/examples/rltest.c b/lib/readline/examples/rltest.c
index 65abe87c..8b7c00c8 100644
--- a/lib/readline/examples/rltest.c
+++ b/lib/readline/examples/rltest.c
@@ -36,6 +36,10 @@
extern void exit();
#endif
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
+
#ifdef READLINE_LIBRARY
# include "readline.h"
# include "history.h"
@@ -52,6 +56,10 @@ main ()
char *temp, *prompt;
int done;
+#ifdef HAVE_SETLOCALE
+ setlocale (LC_ALL, "");
+#endif
+
temp = (char *)NULL;
prompt = "readline$ ";
done = 0;
diff --git a/lib/readline/funmap.c b/lib/readline/funmap.c
index eca49a3e..8b1cb402 100644
--- a/lib/readline/funmap.c
+++ b/lib/readline/funmap.c
@@ -1,6 +1,6 @@
/* funmap.c -- attach names to functions. */
-/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -46,7 +46,7 @@ typedef int QSFUNC (const void *, const void *);
typedef int QSFUNC ();
#endif
-extern int _rl_qsort_string_compare PARAMS((char **, char **));
+extern int _rl_qsort_string_compare (char **, char **);
FUNMAP **funmap;
static int funmap_size;
@@ -93,6 +93,7 @@ static const FUNMAP default_funmap[] = {
{ "end-of-history", rl_end_of_history },
{ "end-of-line", rl_end_of_line },
{ "exchange-point-and-mark", rl_exchange_point_and_mark },
+ { "fetch-history", rl_fetch_history },
{ "forward-backward-delete-char", rl_rubout_or_delete },
{ "forward-byte", rl_forward_byte },
{ "forward-char", rl_forward_char },
@@ -198,6 +199,7 @@ static const FUNMAP default_funmap[] = {
{ "vi-set-mark", rl_vi_set_mark },
{ "vi-subst", rl_vi_subst },
{ "vi-tilde-expand", rl_vi_tilde_expand },
+ { "vi-undo", rl_vi_undo },
{ "vi-unix-word-rubout", rl_vi_unix_word_rubout },
{ "vi-yank-arg", rl_vi_yank_arg },
{ "vi-yank-pop", rl_vi_yank_pop },
diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c
index b986dba0..8ab68091 100644
--- a/lib/readline/histexpand.c
+++ b/lib/readline/histexpand.c
@@ -1,6 +1,6 @@
/* histexpand.c -- history expansion. */
-/* Copyright (C) 1989-2018 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -57,7 +57,7 @@
#define fielddelim(c) (whitespace(c) || (c) == '\n')
-typedef int _hist_search_func_t PARAMS((const char *, int));
+typedef int _hist_search_func_t (const char *, int);
static char error_pointer;
@@ -70,14 +70,14 @@ static int subst_rhs_len;
specifications from word designators. Static for now */
static char *history_event_delimiter_chars = HISTORY_EVENT_DELIMITERS;
-static char *get_history_word_specifier PARAMS((char *, char *, int *));
-static int history_tokenize_word PARAMS((const char *, int));
-static char **history_tokenize_internal PARAMS((const char *, int, int *));
-static char *history_substring PARAMS((const char *, int, int));
-static void freewords PARAMS((char **, int));
-static char *history_find_word PARAMS((char *, int));
+static char *get_history_word_specifier (char *, char *, int *);
+static int history_tokenize_word (const char *, int);
+static char **history_tokenize_internal (const char *, int, int *);
+static char *history_substring (const char *, int, int);
+static void freewords (char **, int);
+static char *history_find_word (char *, int);
-static char *quote_breaks PARAMS((char *));
+static char *quote_breaks (char *);
/* Variables exported by this file. */
/* The character that represents the start of a history expansion
@@ -1207,13 +1207,36 @@ history_expand (char *hstring, char **output)
characters in history_no_expand_chars, then it is not a
candidate for expansion of any kind. */
if (cc == 0 || member (cc, history_no_expand_chars) ||
- (dquote && cc == '"') ||
- (history_inhibit_expansion_function && (*history_inhibit_expansion_function) (string, i)))
+ (dquote && cc == '"'))
{
ADD_CHAR (string[i]);
break;
}
+ /* If the application has defined a function to determine whether
+ or not a history expansion should be performed, call it here. */
+ /* We check against what we've expanded so far, with the current
+ expansion appended, because that seems to be what csh does. We
+ decide to expand based on what we have to this point, not what
+ we started with. */
+ if (history_inhibit_expansion_function)
+ {
+ int save_j, temp;
+
+ save_j = j;
+ ADD_CHAR (string[i]);
+ ADD_CHAR (cc);
+
+ temp = (*history_inhibit_expansion_function) (result, save_j);
+ if (temp)
+ {
+ result[--j] = '\0'; /* `unadd' cc, leaving ADD_CHAR(string[i]) */
+ break;
+ }
+ else
+ result[j = save_j] = '\0';
+ }
+
#if defined (NO_BANG_HASH_MODIFIERS)
/* There is something that is listed as a `word specifier' in csh
documentation which means `the expanded text to this point'.
diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c
index f0fa5ce1..3bfec550 100644
--- a/lib/readline/histfile.c
+++ b/lib/readline/histfile.c
@@ -114,8 +114,6 @@ extern int errno;
# define PATH_MAX 1024 /* default */
#endif
-extern void _hs_append_history_line PARAMS((int, const char *));
-
/* history file version; currently unused */
int history_file_version = 1;
@@ -141,11 +139,11 @@ int history_lines_written_to_file = 0;
for more extensive tests. */
#define HIST_TIMESTAMP_START(s) (*(s) == history_comment_char && isdigit ((unsigned char)(s)[1]) )
-static char *history_backupfile PARAMS((const char *));
-static char *history_tempfile PARAMS((const char *));
-static int histfile_backup PARAMS((const char *, const char *));
-static int histfile_restore PARAMS((const char *, const char *));
-static int history_rename PARAMS((const char *, const char *));
+static char *history_backupfile (const char *);
+static char *history_tempfile (const char *);
+static int histfile_backup (const char *, const char *);
+static int histfile_restore (const char *, const char *);
+static int history_rename (const char *, const char *);
/* Return the string that should be used in the place of this
filename. This only matters when you don't specify the
@@ -312,7 +310,7 @@ read_history_range (const char *filename, int from, int to)
if (file_size == 0)
{
- free (input);
+ xfree (input);
close (file);
return 0; /* don't waste time if we don't have to */
}
diff --git a/lib/readline/histlib.h b/lib/readline/histlib.h
index 9627b245..29fc4d2e 100644
--- a/lib/readline/histlib.h
+++ b/lib/readline/histlib.h
@@ -1,6 +1,6 @@
/* histlib.h -- internal definitions for the history library. */
-/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2009,2021-2022 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -80,6 +80,13 @@ extern char *strchr ();
/* internal extern function declarations used by other parts of the library */
/* histsearch.c */
-extern int _hs_history_patsearch PARAMS((const char *, int, int));
+extern int _hs_history_patsearch (const char *, int, int);
+
+/* history.c */
+extern void _hs_replace_history_data (int, histdata_t *, histdata_t *);
+extern int _hs_at_end_of_history (void);
+
+/* histfile.c */
+extern void _hs_append_history_line (int, const char *);
#endif /* !_HISTLIB_H_ */
diff --git a/lib/readline/history.c b/lib/readline/history.c
index 67158b14..81d4c168 100644
--- a/lib/readline/history.c
+++ b/lib/readline/history.c
@@ -1,6 +1,6 @@
/* history.c -- standalone history library */
-/* Copyright (C) 1989-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -62,7 +62,7 @@ extern int errno;
/* The number of slots to increase the_history by. */
#define DEFAULT_HISTORY_GROW_SIZE 50
-static char *hist_inittime PARAMS((void));
+static char *hist_inittime (void);
/* **************************************************************** */
/* */
@@ -165,6 +165,13 @@ history_set_pos (int pos)
history_offset = pos;
return (1);
}
+
+/* Are we currently at the end of the history list? */
+int
+_hs_at_end_of_history (void)
+{
+ return (the_history == 0 || history_offset == history_length);
+}
/* Return the current history array. The caller has to be careful, since this
is the actual array of data, and could be bashed or made corrupt easily.
@@ -390,7 +397,7 @@ replace_history_entry (int which, const char *line, histdata_t data)
temp->line = savestring (line);
temp->data = data;
- temp->timestamp = savestring (old_value->timestamp);
+ temp->timestamp = old_value->timestamp ? savestring (old_value->timestamp) : 0;
the_history[which] = temp;
return (old_value);
diff --git a/lib/readline/history.h b/lib/readline/history.h
index cc3de29a..5208f9a4 100644
--- a/lib/readline/history.h
+++ b/lib/readline/history.h
@@ -1,6 +1,6 @@
/* history.h -- the names of functions that you can call in history. */
-/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
+/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -42,6 +42,11 @@ typedef void *histdata_t;
typedef char *histdata_t;
#endif
+/* Let's not step on anyone else's define for now, since we don't use this yet. */
+#ifndef HS_HISTORY_VERSION
+# define HS_HISTORY_VERSION 0x0802 /* History 8.2 */
+#endif
+
/* The structure used to store a history entry. */
typedef struct _hist_entry {
char *line;
@@ -68,102 +73,102 @@ typedef struct _hist_state {
/* Begin a session in which the history functions might be used. This
just initializes the interactive variables. */
-extern void using_history PARAMS((void));
+extern void using_history (void);
/* Return the current HISTORY_STATE of the history. */
-extern HISTORY_STATE *history_get_history_state PARAMS((void));
+extern HISTORY_STATE *history_get_history_state (void);
/* Set the state of the current history array to STATE. */
-extern void history_set_history_state PARAMS((HISTORY_STATE *));
+extern void history_set_history_state (HISTORY_STATE *);
/* Manage the history list. */
/* Place STRING at the end of the history list.
The associated data field (if any) is set to NULL. */
-extern void add_history PARAMS((const char *));
+extern void add_history (const char *);
/* Change the timestamp associated with the most recent history entry to
STRING. */
-extern void add_history_time PARAMS((const char *));
+extern void add_history_time (const char *);
/* Remove an entry from the history list. WHICH is the magic number that
tells us which element to delete. The elements are numbered from 0. */
-extern HIST_ENTRY *remove_history PARAMS((int));
+extern HIST_ENTRY *remove_history (int);
/* Remove a set of entries from the history list: FIRST to LAST, inclusive */
-extern HIST_ENTRY **remove_history_range PARAMS((int, int));
+extern HIST_ENTRY **remove_history_range (int, int);
/* Allocate a history entry consisting of STRING and TIMESTAMP and return
a pointer to it. */
-extern HIST_ENTRY *alloc_history_entry PARAMS((char *, char *));
+extern HIST_ENTRY *alloc_history_entry (char *, char *);
/* Copy the history entry H, but not the (opaque) data pointer */
-extern HIST_ENTRY *copy_history_entry PARAMS((HIST_ENTRY *));
+extern HIST_ENTRY *copy_history_entry (HIST_ENTRY *);
/* Free the history entry H and return any application-specific data
associated with it. */
-extern histdata_t free_history_entry PARAMS((HIST_ENTRY *));
+extern histdata_t free_history_entry (HIST_ENTRY *);
/* Make the history entry at WHICH have LINE and DATA. This returns
the old entry so you can dispose of the data. In the case of an
invalid WHICH, a NULL pointer is returned. */
-extern HIST_ENTRY *replace_history_entry PARAMS((int, const char *, histdata_t));
+extern HIST_ENTRY *replace_history_entry (int, const char *, histdata_t);
/* Clear the history list and start over. */
-extern void clear_history PARAMS((void));
+extern void clear_history (void);
/* Stifle the history list, remembering only MAX number of entries. */
-extern void stifle_history PARAMS((int));
+extern void stifle_history (int);
/* Stop stifling the history. This returns the previous amount the
history was stifled by. The value is positive if the history was
stifled, negative if it wasn't. */
-extern int unstifle_history PARAMS((void));
+extern int unstifle_history (void);
/* Return 1 if the history is stifled, 0 if it is not. */
-extern int history_is_stifled PARAMS((void));
+extern int history_is_stifled (void);
/* Information about the history list. */
/* Return a NULL terminated array of HIST_ENTRY which is the current input
history. Element 0 of this list is the beginning of time. If there
is no history, return NULL. */
-extern HIST_ENTRY **history_list PARAMS((void));
+extern HIST_ENTRY **history_list (void);
/* Returns the number which says what history element we are now
looking at. */
-extern int where_history PARAMS((void));
+extern int where_history (void);
/* Return the history entry at the current position, as determined by
history_offset. If there is no entry there, return a NULL pointer. */
-extern HIST_ENTRY *current_history PARAMS((void));
+extern HIST_ENTRY *current_history (void);
/* Return the history entry which is logically at OFFSET in the history
array. OFFSET is relative to history_base. */
-extern HIST_ENTRY *history_get PARAMS((int));
+extern HIST_ENTRY *history_get (int);
/* Return the timestamp associated with the HIST_ENTRY * passed as an
argument */
-extern time_t history_get_time PARAMS((HIST_ENTRY *));
+extern time_t history_get_time (HIST_ENTRY *);
/* Return the number of bytes that the primary history entries are using.
This just adds up the lengths of the_history->lines. */
-extern int history_total_bytes PARAMS((void));
+extern int history_total_bytes (void);
/* Moving around the history list. */
/* Set the position in the history list to POS. */
-extern int history_set_pos PARAMS((int));
+extern int history_set_pos (int);
/* Back up history_offset to the previous history entry, and return
a pointer to that entry. If there is no previous entry, return
a NULL pointer. */
-extern HIST_ENTRY *previous_history PARAMS((void));
+extern HIST_ENTRY *previous_history (void);
/* Move history_offset forward to the next item in the input_history,
and return the a pointer to that entry. If there is no next entry,
return a NULL pointer. */
-extern HIST_ENTRY *next_history PARAMS((void));
+extern HIST_ENTRY *next_history (void);
/* Searching the history list. */
@@ -173,45 +178,45 @@ extern HIST_ENTRY *next_history PARAMS((void));
current_history () is the history entry, and the value of this function
is the offset in the line of that history entry that the string was
found in. Otherwise, nothing is changed, and a -1 is returned. */
-extern int history_search PARAMS((const char *, int));
+extern int history_search (const char *, int);
/* Search the history for STRING, starting at history_offset.
The search is anchored: matching lines must begin with string.
DIRECTION is as in history_search(). */
-extern int history_search_prefix PARAMS((const char *, int));
+extern int history_search_prefix (const char *, int);
/* Search for STRING in the history list, starting at POS, an
absolute index into the list. DIR, if negative, says to search
backwards from POS, else forwards.
Returns the absolute index of the history element where STRING
was found, or -1 otherwise. */
-extern int history_search_pos PARAMS((const char *, int, int));
+extern int history_search_pos (const char *, int, int);
/* Managing the history file. */
/* Add the contents of FILENAME to the history list, a line at a time.
If FILENAME is NULL, then read from ~/.history. Returns 0 if
successful, or errno if not. */
-extern int read_history PARAMS((const char *));
+extern int read_history (const char *);
/* Read a range of lines from FILENAME, adding them to the history list.
Start reading at the FROM'th line and end at the TO'th. If FROM
is zero, start at the beginning. If TO is less than FROM, read
until the end of the file. If FILENAME is NULL, then read from
~/.history. Returns 0 if successful, or errno if not. */
-extern int read_history_range PARAMS((const char *, int, int));
+extern int read_history_range (const char *, int, int);
/* Write the current history to FILENAME. If FILENAME is NULL,
then write the history list to ~/.history. Values returned
are as in read_history (). */
-extern int write_history PARAMS((const char *));
+extern int write_history (const 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. */
-extern int append_history PARAMS((int, const char *));
+extern int append_history (int, const char *);
/* Truncate the history file, leaving only the last NLINES lines. */
-extern int history_truncate_file PARAMS((const char *, int));
+extern int history_truncate_file (const char *, int);
/* History expansion. */
@@ -227,12 +232,12 @@ extern int history_truncate_file PARAMS((const char *, int));
If an error occurred in expansion, then OUTPUT contains a descriptive
error message. */
-extern int history_expand PARAMS((char *, char **));
+extern int history_expand (char *, char **);
/* Extract a string segment consisting of the FIRST through LAST
arguments present in STRING. Arguments are broken up as in
the shell. */
-extern char *history_arg_extract PARAMS((int, int, const char *));
+extern char *history_arg_extract (int, int, const char *);
/* Return the text of the history event beginning at the current
offset into STRING. Pass STRING with *INDEX equal to the
@@ -240,11 +245,11 @@ extern char *history_arg_extract PARAMS((int, int, const char *));
DELIMITING_QUOTE is a character that is allowed to end the string
specification for what to search for in addition to the normal
characters `:', ` ', `\t', `\n', and sometimes `?'. */
-extern char *get_history_event PARAMS((const char *, int *, int));
+extern char *get_history_event (const char *, int *, int);
/* Return an array of tokens, much as the shell might. The tokens are
parsed out of STRING. */
-extern char **history_tokenize PARAMS((const char *));
+extern char **history_tokenize (const char *);
/* Exported history variables. */
extern int history_base;
diff --git a/lib/readline/histsearch.c b/lib/readline/histsearch.c
index 7a426c96..b62c06b7 100644
--- a/lib/readline/histsearch.c
+++ b/lib/readline/histsearch.c
@@ -1,6 +1,6 @@
/* histsearch.c -- searching the history list. */
-/* Copyright (C) 1989, 1992-2009,2017 Free Software Foundation, Inc.
+/* Copyright (C) 1989, 1992-2009,2017,2021 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -51,7 +51,7 @@
string. */
char *history_search_delimiter_chars = (char *)NULL;
-static int history_search_internal PARAMS((const char *, int, int));
+static int history_search_internal (const char *, int, int);
/* Search the history for STRING, starting at history_offset.
If DIRECTION < 0, then the search is through previous entries, else
@@ -248,7 +248,7 @@ _hs_history_patsearch (const char *string, int direction, int flags)
ret = history_search_internal (pat, direction, flags|PATTERN_SEARCH);
if (pat != string)
- free (pat);
+ xfree (pat);
return ret;
}
diff --git a/lib/readline/input.c b/lib/readline/input.c
index 61b0fde3..6f038d45 100644
--- a/lib/readline/input.c
+++ b/lib/readline/input.c
@@ -1,6 +1,6 @@
/* input.c -- character input functions for readline. */
-/* Copyright (C) 1994-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -50,6 +50,7 @@
#include <signal.h>
#include "posixselect.h"
+#include "posixtime.h"
#if defined (FIONREAD_IN_SYS_IOCTL)
# include <sys/ioctl.h>
@@ -78,7 +79,7 @@ extern int errno;
# define O_NDELAY O_NONBLOCK /* Posix style */
#endif
-#if defined (HAVE_PSELECT)
+#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
extern sigset_t _rl_orig_sigset;
#endif
@@ -89,6 +90,9 @@ rl_hook_func_t *rl_event_hook = (rl_hook_func_t *)NULL;
/* A function to call if a read(2) is interrupted by a signal. */
rl_hook_func_t *rl_signal_event_hook = (rl_hook_func_t *)NULL;
+/* A function to call when readline times out after a time is specified. */
+rl_hook_func_t *rl_timeout_event_hook = (rl_hook_func_t *)NULL;
+
/* A function to replace _rl_input_available for applications using the
callback interface. */
rl_hook_func_t *rl_input_available_hook = (rl_hook_func_t *)NULL;
@@ -97,9 +101,9 @@ rl_getc_func_t *rl_getc_function = rl_getc;
static int _keyboard_input_timeout = 100000; /* 0.1 seconds; it's in usec */
-static int ibuffer_space PARAMS((void));
-static int rl_get_char PARAMS((int *));
-static int rl_gather_tyi PARAMS((void));
+static int ibuffer_space (void);
+static int rl_get_char (int *);
+static int rl_gather_tyi (void);
/* Windows isatty returns true for every character device, including the null
device, so we need to perform additional checks. */
@@ -132,6 +136,36 @@ win32_isatty (int fd)
#define isatty(x) win32_isatty(x)
#endif
+/* Readline timeouts */
+
+/* I don't know how to set a timeout for _getch() in MinGW32, so we use
+ SIGALRM. */
+#if (defined (HAVE_PSELECT) || defined (HAVE_SELECT)) && !defined (__MINGW32__)
+# define RL_TIMEOUT_USE_SELECT
+#else
+# define RL_TIMEOUT_USE_SIGALRM
+#endif
+
+int rl_set_timeout (unsigned int, unsigned int);
+int rl_timeout_remaining (unsigned int *, unsigned int *);
+
+int _rl_timeout_init (void);
+int _rl_timeout_sigalrm_handler (void);
+int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *);
+
+static void _rl_timeout_handle (void);
+#if defined (RL_TIMEOUT_USE_SIGALRM)
+static int set_alarm (unsigned int *, unsigned int *);
+static void reset_alarm (void);
+#endif
+
+/* We implement timeouts as a future time using a supplied interval
+ (timeout_duration) from when the timeout is set (timeout_point).
+ That allows us to easily determine whether the timeout has occurred
+ and compute the time remaining until it does. */
+static struct timeval timeout_point;
+static struct timeval timeout_duration;
+
/* **************************************************************** */
/* */
/* Character Input Buffering */
@@ -223,13 +257,17 @@ rl_gather_tyi (void)
input = 0;
tty = fileno (rl_instream);
-#if defined (HAVE_SELECT)
+#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
FD_ZERO (&readfds);
FD_ZERO (&exceptfds);
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
+#if defined (RL_TIMEOUT_USE_SELECT)
+ result = _rl_timeout_select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout, NULL);
+#else
result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
+#endif
if (result <= 0)
return 0; /* Nothing to read. */
#endif
@@ -330,11 +368,11 @@ rl_set_keyboard_input_timeout (int u)
int
_rl_input_available (void)
{
-#if defined(HAVE_SELECT)
+#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
fd_set readfds, exceptfds;
struct timeval timeout;
#endif
-#if !defined (HAVE_SELECT) && defined(FIONREAD)
+#if !defined (HAVE_SELECT) && defined (FIONREAD)
int chars_avail;
#endif
int tty;
@@ -344,13 +382,17 @@ _rl_input_available (void)
tty = fileno (rl_instream);
-#if defined (HAVE_SELECT)
+#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
FD_ZERO (&readfds);
FD_ZERO (&exceptfds);
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
+# if defined (RL_TIMEOUT_USE_SELECT)
+ return (_rl_timeout_select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout, NULL) > 0);
+# else
return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
+# endif
#else
#if defined (FIONREAD)
@@ -465,6 +507,242 @@ rl_clear_pending_input (void)
/* **************************************************************** */
/* */
+/* Timeout utility */
+/* */
+/* **************************************************************** */
+
+#if defined (RL_TIMEOUT_USE_SIGALRM)
+# if defined (HAVE_SETITIMER)
+
+static int
+set_alarm (unsigned int *secs, unsigned int *usecs)
+{
+ struct itimerval it;
+
+ timerclear (&it.it_interval);
+ timerset (&it.it_value, *secs, *usecs);
+ return setitimer (ITIMER_REAL, &it, NULL);
+}
+
+static void
+reset_alarm ()
+{
+ struct itimerval it;
+
+ timerclear (&it.it_interval);
+ timerclear (&it.it_value);
+ setitimer (ITIMER_REAL, &it, NULL);
+}
+# else
+static int
+set_alarm (unsigned int *secs, unsigned int *usecs)
+{
+ if (*secs == 0 || *usecs >= USEC_PER_SEC / 2)
+ (*secs)++;
+ *usecs = 0;
+
+ return alarm (*secs);
+}
+static void
+reset_alarm ()
+{
+ alarm (0);
+}
+# endif
+#endif
+
+/* Set a timeout which will be used for the next call of `readline
+ ()'. When (0, 0) are specified the timeout is cleared. */
+int
+rl_set_timeout (unsigned int secs, unsigned int usecs)
+{
+ timeout_duration.tv_sec = secs + usecs / USEC_PER_SEC;
+ timeout_duration.tv_usec = usecs % USEC_PER_SEC;
+
+ return 0;
+}
+
+/* Start measuring the time. Returns 0 on success. Returns -1 on
+ error. */
+int
+_rl_timeout_init (void)
+{
+ unsigned int secs, usecs;
+
+ /* Clear the timeout state of the previous edit */
+ RL_UNSETSTATE(RL_STATE_TIMEOUT);
+ timerclear (&timeout_point);
+
+ /* Return 0 when timeout is unset. */
+ if (timerisunset (&timeout_duration))
+ return 0;
+
+ /* Return -1 on gettimeofday error. */
+ if (gettimeofday(&timeout_point, 0) != 0)
+ {
+ timerclear (&timeout_point);
+ return -1;
+ }
+
+ secs = timeout_duration.tv_sec;
+ usecs = timeout_duration.tv_usec;
+
+#if defined (RL_TIMEOUT_USE_SIGALRM)
+ /* If select(2)/pselect(2) is unavailable, use SIGALRM. */
+ if (set_alarm (&secs, &usecs) < 0)
+ return -1;
+#endif
+
+ timeout_point.tv_sec += secs;
+ timeout_point.tv_usec += usecs;
+ if (timeout_point.tv_usec >= USEC_PER_SEC)
+ {
+ timeout_point.tv_sec++;
+ timeout_point.tv_usec -= USEC_PER_SEC;
+ }
+
+ return 0;
+}
+
+/* Get the remaining time until the scheduled timeout. Returns -1 on
+ error or no timeout set with secs and usecs unchanged. Returns 0
+ on an expired timeout with secs and usecs unchanged. Returns 1
+ when the timeout has not yet expired. The remaining time is stored
+ in secs and usecs. When NULL is specified to either of the
+ arguments, just the expiration is tested. */
+int
+rl_timeout_remaining (unsigned int *secs, unsigned int *usecs)
+{
+ struct timeval current_time;
+
+ /* Return -1 when timeout is unset. */
+ if (timerisunset (&timeout_point))
+ {
+ errno = 0;
+ return -1;
+ }
+
+ /* Return -1 on error. errno is set by gettimeofday. */
+ if (gettimeofday(&current_time, 0) != 0)
+ return -1;
+
+ /* Return 0 when timeout has already expired. */
+ /* could use timercmp (&timeout_point, &current_time, <) here */
+ if (current_time.tv_sec > timeout_point.tv_sec ||
+ (current_time.tv_sec == timeout_point.tv_sec &&
+ current_time.tv_usec >= timeout_point.tv_usec))
+ return 0;
+
+ if (secs && usecs)
+ {
+ *secs = timeout_point.tv_sec - current_time.tv_sec;
+ *usecs = timeout_point.tv_usec - current_time.tv_usec;
+ if (timeout_point.tv_usec < current_time.tv_usec)
+ {
+ (*secs)--;
+ *usecs += USEC_PER_SEC;
+ }
+ }
+
+ return 1;
+}
+
+/* This should only be called if RL_TIMEOUT_USE_SELECT is defined. */
+
+#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
+int
+_rl_timeout_select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, const struct timeval *timeout, const sigset_t *sigmask)
+{
+ int result;
+#if defined (HAVE_PSELECT)
+ struct timespec ts;
+#else
+ sigset_t origmask;
+ struct timeval tv;
+#endif
+ int tmout_status;
+ struct timeval tmout;
+ unsigned int sec, usec;
+
+ /* When the remaining time for rl_timeout is shorter than the
+ keyboard input timeout, replace `timeout' with the remaining time
+ for `rl_timeout' and set `tmout_status = 1'. */
+ tmout_status = rl_timeout_remaining (&sec, &usec);
+ tmout.tv_sec = sec;
+ tmout.tv_usec = usec;
+
+ if (tmout_status == 0)
+ _rl_timeout_handle ();
+ else if (tmout_status == 1)
+ {
+ if (timeout == NULL || timercmp (&tmout, timeout, <))
+ timeout = &tmout;
+ else
+ tmout_status = -1;
+ }
+
+#if defined (HAVE_PSELECT)
+ if (timeout)
+ {
+ TIMEVAL_TO_TIMESPEC (timeout, &ts);
+ result = pselect (nfds, readfds, writefds, exceptfds, &ts, sigmask);
+ }
+ else
+ result = pselect (nfds, readfds, writefds, exceptfds, NULL, sigmask);
+#else
+ if (sigmask)
+ sigprocmask (SIG_SETMASK, sigmask, &origmask);
+
+ if (timeout)
+ {
+ tv.tv_sec = timeout->tv_sec;
+ tv.tv_usec = timeout->tv_usec;
+ result = select (nfds, readfds, writefds, exceptfds, &tv);
+ }
+ else
+ result = select (nfds, readfds, writefds, exceptfds, NULL);
+
+ if (sigmask)
+ sigprocmask (SIG_SETMASK, &origmask, NULL);
+#endif
+
+ if (tmout_status == 1 && result == 0)
+ _rl_timeout_handle ();
+
+ return result;
+}
+#endif
+
+static void
+_rl_timeout_handle ()
+{
+ if (rl_timeout_event_hook)
+ (*rl_timeout_event_hook) ();
+
+ RL_SETSTATE(RL_STATE_TIMEOUT);
+ _rl_abort_internal ();
+}
+
+int
+_rl_timeout_handle_sigalrm ()
+{
+#if defined (RL_TIMEOUT_USE_SIGALRM)
+ if (timerisunset (&timeout_point))
+ return -1;
+
+ /* Reset `timeout_point' to the current time to ensure that later
+ calls of `rl_timeout_pending ()' return 0 (timeout expired). */
+ if (gettimeofday(&timeout_point, 0) != 0)
+ timerclear (&timeout_point);
+
+ reset_alarm ();
+
+ _rl_timeout_handle ();
+#endif
+ return -1;
+}
+/* **************************************************************** */
+/* */
/* Character Input */
/* */
/* **************************************************************** */
@@ -497,6 +775,7 @@ rl_read_key (void)
if ((r = rl_gather_tyi ()) < 0) /* XXX - EIO */
{
rl_done = 1;
+ RL_SETSTATE (RL_STATE_DONE);
return (errno == EIO ? (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF) : '\n');
}
else if (r > 0) /* read something */
@@ -525,11 +804,13 @@ rl_getc (FILE *stream)
{
int result;
unsigned char c;
+ int fd;
#if defined (HAVE_PSELECT)
sigset_t empty_set;
fd_set readfds;
#endif
+ fd = fileno (stream);
while (1)
{
RL_CHECK_SIGNALS ();
@@ -537,23 +818,27 @@ rl_getc (FILE *stream)
/* We know at this point that _rl_caught_signal == 0 */
#if defined (__MINGW32__)
- if (isatty (fileno (stream)))
+ if (isatty (fd)
return (_getch ()); /* "There is no error return." */
#endif
result = 0;
-#if defined (HAVE_PSELECT)
+#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
+ /* At this point, if we have pselect, we're using select/pselect for the
+ timeouts. We handled MinGW above. */
FD_ZERO (&readfds);
- FD_SET (fileno (stream), &readfds);
+ FD_SET (fd, &readfds);
# if defined (HANDLE_SIGNALS)
- result = pselect (fileno (stream) + 1, &readfds, NULL, NULL, NULL, &_rl_orig_sigset);
+ result = _rl_timeout_select (fd + 1, &readfds, NULL, NULL, NULL, &_rl_orig_sigset);
# else
sigemptyset (&empty_set);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &empty_set);
- result = pselect (fileno (stream) + 1, &readfds, NULL, NULL, NULL, &empty_set);
+ result = _rl_timeout_select (fd + 1, &readfds, NULL, NULL, NULL, &empty_set);
# endif /* HANDLE_SIGNALS */
+ if (result == 0)
+ _rl_timeout_handle (); /* check the timeout */
#endif
if (result >= 0)
- result = read (fileno (stream), &c, sizeof (unsigned char));
+ result = read (fd, &c, sizeof (unsigned char));
if (result == sizeof (unsigned char))
return (c);
@@ -582,7 +867,7 @@ rl_getc (FILE *stream)
if (errno == X_EWOULDBLOCK || errno == X_EAGAIN)
{
- if (sh_unset_nodelay_mode (fileno (stream)) < 0)
+ if (sh_unset_nodelay_mode (fd) < 0)
return (EOF);
continue;
}
@@ -645,7 +930,7 @@ _rl_read_mbchar (char *mbchar, int size)
{
int mb_len, c;
size_t mbchar_bytes_length;
- wchar_t wc;
+ WCHAR_T wc;
mbstate_t ps, ps_back;
memset(&ps, 0, sizeof (mbstate_t));
@@ -661,7 +946,7 @@ _rl_read_mbchar (char *mbchar, int size)
mbchar[mb_len++] = c;
- mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
+ mbchar_bytes_length = MBRTOWC (&wc, mbchar, mb_len, &ps);
if (mbchar_bytes_length == (size_t)(-1))
break; /* invalid byte sequence for the current locale */
else if (mbchar_bytes_length == (size_t)(-2))
diff --git a/lib/readline/isearch.c b/lib/readline/isearch.c
index 080ba3cb..c2d4d236 100644
--- a/lib/readline/isearch.c
+++ b/lib/readline/isearch.c
@@ -6,7 +6,7 @@
/* */
/* **************************************************************** */
-/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -59,13 +59,10 @@ char *_rl_isearch_terminators = (char *)NULL;
_rl_search_cxt *_rl_iscxt = 0;
-/* Variables imported from other files in the readline library. */
-extern HIST_ENTRY *_rl_saved_line_for_history;
+static int rl_search_history (int, int);
-static int rl_search_history PARAMS((int, int));
-
-static _rl_search_cxt *_rl_isearch_init PARAMS((int));
-static void _rl_isearch_fini PARAMS((_rl_search_cxt *));
+static _rl_search_cxt *_rl_isearch_init (int);
+static void _rl_isearch_fini (_rl_search_cxt *);
/* Last line found by the current incremental search, so we don't `find'
identical lines many times in a row. Now part of isearch context. */
@@ -197,7 +194,10 @@ rl_display_search (char *search_string, int flags, int where)
rl_message ("%s", message);
xfree (message);
+#if 0
+ /* rl_message calls this */
(*rl_redisplay_function) ();
+#endif
}
static _rl_search_cxt *
@@ -276,6 +276,8 @@ _rl_isearch_fini (_rl_search_cxt *cxt)
last_isearch_string = cxt->search_string;
last_isearch_string_len = cxt->search_string_index;
cxt->search_string = 0;
+ cxt->search_string_size = 0;
+ cxt->search_string_index = 0;
if (cxt->last_found_line < cxt->save_line)
rl_get_previous_history (cxt->save_line - cxt->last_found_line, 0);
@@ -321,7 +323,7 @@ _rl_search_getchar (_rl_search_cxt *cxt)
#if defined (HANDLE_MULTIBYTE)
/* This ends up with C (and LASTC) being set to the last byte of the
multibyte character. In most cases c == lastc == mb[0] */
- if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
+ if (c >= 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0)
c = cxt->lastc = _rl_read_mbstring (cxt->lastc, cxt->mb, MB_LEN_MAX);
#endif
@@ -680,7 +682,7 @@ opcode_dispatch:
paste = _rl_bracketed_text (&pastelen);
if (paste == 0 || *paste == 0)
{
- free (paste);
+ xfree (paste);
break;
}
if (_rl_enable_active_region)
@@ -690,9 +692,10 @@ opcode_dispatch:
cxt->search_string_size += pastelen + 2;
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
}
- strcpy (cxt->search_string + cxt->search_string_index, paste);
+ memcpy (cxt->search_string + cxt->search_string_index, paste, pastelen);
cxt->search_string_index += pastelen;
- free (paste);
+ cxt->search_string[cxt->search_string_index] = '\0';
+ xfree (paste);
break;
/* Add character to search string and continue search. */
diff --git a/lib/readline/keymaps.h b/lib/readline/keymaps.h
index 1fa853d8..29038148 100644
--- a/lib/readline/keymaps.h
+++ b/lib/readline/keymaps.h
@@ -1,6 +1,6 @@
/* keymaps.h -- Manipulation of readline keymaps. */
-/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1989, 1992-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -65,33 +65,33 @@ extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
/* Return a new, empty keymap.
Free it with free() when you are done. */
-extern Keymap rl_make_bare_keymap PARAMS((void));
+extern Keymap rl_make_bare_keymap (void);
/* Return a new keymap which is a copy of MAP. */
-extern Keymap rl_copy_keymap PARAMS((Keymap));
+extern Keymap rl_copy_keymap (Keymap);
/* Return a new keymap with the printing characters bound to rl_insert,
the lowercase Meta characters bound to run their equivalents, and
the Meta digits bound to produce numeric arguments. */
-extern Keymap rl_make_keymap PARAMS((void));
+extern Keymap rl_make_keymap (void);
/* Free the storage associated with a keymap. */
-extern void rl_discard_keymap PARAMS((Keymap));
+extern void rl_discard_keymap (Keymap);
/* These functions actually appear in bind.c */
/* Return the keymap corresponding to a given name. Names look like
`emacs' or `emacs-meta' or `vi-insert'. */
-extern Keymap rl_get_keymap_by_name PARAMS((const char *));
+extern Keymap rl_get_keymap_by_name (const char *);
/* Return the current keymap. */
-extern Keymap rl_get_keymap PARAMS((void));
+extern Keymap rl_get_keymap (void);
/* Set the current keymap to MAP. */
-extern void rl_set_keymap PARAMS((Keymap));
+extern void rl_set_keymap (Keymap);
/* Set the name of MAP to NAME */
-extern int rl_set_keymap_name PARAMS((const char *, Keymap));
+extern int rl_set_keymap_name (const char *, Keymap);
#ifdef __cplusplus
}
diff --git a/lib/readline/kill.c b/lib/readline/kill.c
index 50c3fdea..4cf933b2 100644
--- a/lib/readline/kill.c
+++ b/lib/readline/kill.c
@@ -1,6 +1,6 @@
/* kill.c -- kill ring management. */
-/* Copyright (C) 1994-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -70,10 +70,10 @@ static int rl_kill_index;
/* How many slots we have in the kill ring. */
static int rl_kill_ring_length;
-static int _rl_copy_to_kill_ring PARAMS((char *, int));
-static int region_kill_internal PARAMS((int));
-static int _rl_copy_word_as_kill PARAMS((int, int));
-static int rl_yank_nth_arg_internal PARAMS((int, int, int));
+static int _rl_copy_to_kill_ring (char *, int);
+static int region_kill_internal (int);
+static int _rl_copy_word_as_kill (int, int);
+static int rl_yank_nth_arg_internal (int, int, int);
/* How to say that you only want to save a certain amount
of kill material. */
@@ -351,6 +351,30 @@ rl_unix_filename_rubout (int count, int key)
while (count--)
{
c = rl_line_buffer[rl_point - 1];
+
+ /* First move backwards through whitespace */
+ while (rl_point && whitespace (c))
+ {
+ rl_point--;
+ c = rl_line_buffer[rl_point - 1];
+ }
+
+ /* Consume one or more slashes. */
+ if (c == '/')
+ {
+ int i;
+
+ i = rl_point - 1;
+ while (i > 0 && c == '/')
+ c = rl_line_buffer[--i];
+ if (i == 0 || whitespace (c))
+ {
+ rl_point = i + whitespace (c);
+ continue; /* slashes only */
+ }
+ c = '/';
+ }
+
while (rl_point && (whitespace (c) || c == '/'))
{
rl_point--;
@@ -535,7 +559,7 @@ rl_yank_pop (int count, int key)
int
rl_vi_yank_pop (int count, int key)
{
- int l, n;
+ int l, n, origpoint;
if (((rl_last_func != rl_vi_yank_pop) && (rl_last_func != rl_vi_put)) ||
!rl_kill_ring)
@@ -545,11 +569,21 @@ rl_vi_yank_pop (int count, int key)
}
l = strlen (rl_kill_ring[rl_kill_index]);
+#if 0 /* TAG:readline-8.3 8/29/2022 matteopaolini1995@gmail.com */
+ origpoint = rl_point;
+ n = rl_point - l + 1;
+#else
n = rl_point - l;
+#endif
if (n >= 0 && STREQN (rl_line_buffer + n, rl_kill_ring[rl_kill_index], l))
{
+#if 0 /* TAG:readline-8.3 */
+ rl_delete_text (n, n + l); /* remember vi cursor positioning */
+ rl_point = origpoint - l;
+#else
rl_delete_text (n, rl_point);
rl_point = n;
+#endif
rl_kill_index--;
if (rl_kill_index < 0)
rl_kill_index = rl_kill_ring_length - 1;
diff --git a/lib/readline/macro.c b/lib/readline/macro.c
index 92cc55c3..231a24bc 100644
--- a/lib/readline/macro.c
+++ b/lib/readline/macro.c
@@ -276,6 +276,8 @@ rl_end_kbd_macro (int count, int ignore)
}
current_macro_index -= rl_key_sequence_length;
+ if (current_macro_index < 0)
+ current_macro_index = 0;
current_macro[current_macro_index] = '\0';
RL_UNSETSTATE(RL_STATE_MACRODEF);
diff --git a/lib/readline/mbutil.c b/lib/readline/mbutil.c
index dc62b4cc..47e9100a 100644
--- a/lib/readline/mbutil.c
+++ b/lib/readline/mbutil.c
@@ -1,6 +1,6 @@
/* mbutil.c -- readline multibyte character utility functions */
-/* Copyright (C) 2001-2020 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -153,7 +153,7 @@ _rl_find_next_mbchar_internal (char *string, int seed, int count, int find_non_z
size_t tmp, len;
mbstate_t ps;
int point;
- wchar_t wc;
+ WCHAR_T wc;
tmp = 0;
@@ -183,11 +183,11 @@ _rl_find_next_mbchar_internal (char *string, int seed, int count, int find_non_z
if (_rl_utf8locale && UTF8_SINGLEBYTE(string[point]))
{
tmp = 1;
- wc = (wchar_t) string[point];
+ wc = (WCHAR_T) string[point];
memset(&ps, 0, sizeof(mbstate_t));
}
else
- tmp = mbrtowc (&wc, string+point, len, &ps);
+ tmp = MBRTOWC (&wc, string+point, len, &ps);
if (MB_INVALIDCH ((size_t)tmp))
{
/* invalid bytes. assume a byte represents a character */
@@ -216,11 +216,11 @@ _rl_find_next_mbchar_internal (char *string, int seed, int count, int find_non_z
if (find_non_zero)
{
- tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
+ tmp = MBRTOWC (&wc, string + point, strlen (string + point), &ps);
while (MB_NULLWCH (tmp) == 0 && MB_INVALIDCH (tmp) == 0 && WCWIDTH (wc) == 0)
{
point += tmp;
- tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
+ tmp = MBRTOWC (&wc, string + point, strlen (string + point), &ps);
}
}
@@ -231,11 +231,11 @@ static inline int
_rl_test_nonzero (char *string, int ind, int len)
{
size_t tmp;
- wchar_t wc;
+ WCHAR_T wc;
mbstate_t ps;
memset (&ps, 0, sizeof (mbstate_t));
- tmp = mbrtowc (&wc, string + ind, len - ind, &ps);
+ tmp = MBRTOWC (&wc, string + ind, len - ind, &ps);
/* treat invalid multibyte sequences as non-zero-width */
return (MB_INVALIDCH (tmp) || MB_NULLWCH (tmp) || WCWIDTH (wc) > 0);
}
@@ -293,7 +293,7 @@ _rl_find_prev_mbchar_internal (char *string, int seed, int find_non_zero)
mbstate_t ps;
int prev, non_zero_prev, point, length;
size_t tmp;
- wchar_t wc;
+ WCHAR_T wc;
if (_rl_utf8locale)
return (_rl_find_prev_utf8char (string, seed, find_non_zero));
@@ -312,11 +312,11 @@ _rl_find_prev_mbchar_internal (char *string, int seed, int find_non_zero)
if (_rl_utf8locale && UTF8_SINGLEBYTE(string[point]))
{
tmp = 1;
- wc = (wchar_t) string[point];
+ wc = (WCHAR_T) string[point];
memset(&ps, 0, sizeof(mbstate_t));
}
else
- tmp = mbrtowc (&wc, string + point, length - point, &ps);
+ tmp = MBRTOWC (&wc, string + point, length - point, &ps);
if (MB_INVALIDCH ((size_t)tmp))
{
/* in this case, bytes are invalid or too short to compose
@@ -470,27 +470,27 @@ _rl_is_mbchar_matched (char *string, int seed, int end, char *mbchar, int length
return 1;
}
-wchar_t
+WCHAR_T
_rl_char_value (char *buf, int ind)
{
size_t tmp;
- wchar_t wc;
+ WCHAR_T wc;
mbstate_t ps;
int l;
if (MB_LEN_MAX == 1 || rl_byte_oriented)
- return ((wchar_t) buf[ind]);
+ return ((WCHAR_T) buf[ind]);
if (_rl_utf8locale && UTF8_SINGLEBYTE(buf[ind]))
- return ((wchar_t) buf[ind]);
+ return ((WCHAR_T) buf[ind]);
l = strlen (buf);
if (ind >= l - 1)
- return ((wchar_t) buf[ind]);
+ return ((WCHAR_T) buf[ind]);
if (l < ind) /* Sanity check */
l = strlen (buf+ind);
memset (&ps, 0, sizeof (mbstate_t));
- tmp = mbrtowc (&wc, buf + ind, l - ind, &ps);
+ tmp = MBRTOWC (&wc, buf + ind, l - ind, &ps);
if (MB_INVALIDCH (tmp) || MB_NULLWCH (tmp))
- return ((wchar_t) buf[ind]);
+ return ((WCHAR_T) buf[ind]);
return wc;
}
#endif /* HANDLE_MULTIBYTE */
diff --git a/lib/readline/misc.c b/lib/readline/misc.c
index 3d9a674c..4bca9c58 100644
--- a/lib/readline/misc.c
+++ b/lib/readline/misc.c
@@ -1,6 +1,6 @@
/* misc.c -- miscellaneous bindable readline functions. */
-/* Copyright (C) 1987-2019 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -50,14 +50,12 @@
#include "history.h"
#include "rlprivate.h"
+#include "histlib.h"
#include "rlshell.h"
#include "xmalloc.h"
-static int rl_digit_loop PARAMS((void));
-static void _rl_history_set_point PARAMS((void));
-
-/* Forward declarations used in this file */
-void _rl_free_history_entry PARAMS((HIST_ENTRY *));
+static int rl_digit_loop (void);
+static void _rl_history_set_point (void);
/* If non-zero, rl_get_previous_history and rl_get_next_history attempt
to preserve the value of rl_point from line to line. */
@@ -309,9 +307,9 @@ _rl_start_using_history (void)
{
using_history ();
if (_rl_saved_line_for_history)
- _rl_free_history_entry (_rl_saved_line_for_history);
-
+ _rl_free_saved_history_line ();
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
+ _rl_history_search_pos = -99; /* some random invalid history position */
}
/* Free the contents (and containing structure) of a HIST_ENTRY. */
@@ -355,6 +353,8 @@ rl_maybe_unsave_line (void)
list from a history entry, as in rl_replace_from_history() below. */
rl_replace_line (_rl_saved_line_for_history->line, 0);
rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
+
+ /* Doesn't free `data'. */
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
rl_point = rl_end; /* rl_replace_line sets rl_end */
@@ -382,8 +382,18 @@ rl_maybe_save_line (void)
int
_rl_free_saved_history_line (void)
{
+ UNDO_LIST *orig;
+
if (_rl_saved_line_for_history)
{
+ if (rl_undo_list && rl_undo_list == (UNDO_LIST *)_rl_saved_line_for_history->data)
+ rl_undo_list = 0;
+ /* Have to free this separately because _rl_free_history entry can't:
+ it doesn't know whether or not this has application data. Only the
+ callers that know this is _rl_saved_line_for_history can know that
+ it's an undo list. */
+ if (_rl_saved_line_for_history->data)
+ _rl_free_undo_list ((UNDO_LIST *)_rl_saved_line_for_history->data);
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
@@ -625,7 +635,7 @@ rl_get_previous_history (int count, int key)
if (temp == 0)
{
if (had_saved_line == 0)
- _rl_free_saved_history_line ();
+ _rl_free_saved_history_line ();
rl_ding ();
}
else
@@ -637,6 +647,42 @@ rl_get_previous_history (int count, int key)
return 0;
}
+/* With an argument, move back that many history lines, else move to the
+ beginning of history. */
+int
+rl_fetch_history (int count, int c)
+{
+ int wanted, nhist;
+
+ /* Giving an argument of n means we want the nth command in the history
+ file. The command number is interpreted the same way that the bash
+ `history' command does it -- that is, giving an argument count of 450
+ to this command would get the command listed as number 450 in the
+ output of `history'. */
+ if (rl_explicit_arg)
+ {
+ nhist = history_base + where_history ();
+ /* Negative arguments count back from the end of the history list. */
+ wanted = (count >= 0) ? nhist - count : -count;
+
+ if (wanted <= 0 || wanted >= nhist)
+ {
+ /* In vi mode, we don't change the line with an out-of-range
+ argument, as for the `G' command. */
+ if (rl_editing_mode == vi_mode)
+ rl_ding ();
+ else
+ rl_beginning_of_history (0, 0);
+ }
+ else
+ rl_get_previous_history (wanted, c);
+ }
+ else
+ rl_beginning_of_history (count, 0);
+
+ return (0);
+}
+
/* The equivalent of the Korn shell C-o operate-and-get-next-history-line
editing command. */
@@ -664,15 +710,13 @@ set_saved_history ()
}
int
-rl_operate_and_get_next (count, c)
- int count, c;
+rl_operate_and_get_next (int count, int c)
{
/* Accept the current line. */
rl_newline (1, c);
saved_history_logical_offset = rl_explicit_arg ? count : where_history () + history_base + 1;
-
_rl_saved_internal_startup_hook = _rl_internal_startup_hook;
_rl_internal_startup_hook = set_saved_history;
diff --git a/lib/readline/nls.c b/lib/readline/nls.c
index d2f67e0d..5c6a13b6 100644
--- a/lib/readline/nls.c
+++ b/lib/readline/nls.c
@@ -1,6 +1,6 @@
/* nls.c -- skeletal internationalization code. */
-/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -53,8 +53,12 @@
#include "readline.h"
#include "rlshell.h"
#include "rlprivate.h"
+#include "xmalloc.h"
-static int utf8locale PARAMS((char *));
+static int utf8locale (char *);
+
+#define RL_DEFAULT_LOCALE "C"
+static char *_rl_current_locale = 0;
#if !defined (HAVE_SETLOCALE)
/* A list of legal values for the LANG or LC_CTYPE environment variables.
@@ -78,12 +82,12 @@ static char *legal_lang_values[] =
0
};
-static char *normalize_codeset PARAMS((char *));
+static char *normalize_codeset (char *);
#endif /* !HAVE_SETLOCALE */
-static char *find_codeset PARAMS((char *, size_t *));
+static char *find_codeset (char *, size_t *);
-static char *_rl_get_locale_var PARAMS((const char *));
+static char *_rl_get_locale_var (const char *);
static char *
_rl_get_locale_var (const char *v)
@@ -131,50 +135,61 @@ _rl_init_locale (void)
that doesn't return anything, we set lspec to the empty string to
force the subsequent call to setlocale() to define the `native'
environment. */
+#if defined (HAVE_SETLOCALE)
if (lspec == 0 || *lspec == 0)
lspec = setlocale (LC_CTYPE, (char *)NULL);
if (lspec == 0)
lspec = "";
ret = setlocale (LC_CTYPE, lspec); /* ok, since it does not change locale */
+#else
+ ret = (lspec == 0 || *lspec == 0) ? RL_DEFAULT_LOCALE : lspec;
+#endif
_rl_utf8locale = (ret && *ret) ? utf8locale (ret) : 0;
+ _rl_current_locale = savestring (ret);
return ret;
}
-/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value
- to decide the defaults for 8-bit character input and output. Returns
- 1 if we set eight-bit mode. */
-int
-_rl_init_eightbit (void)
-{
/* If we have setlocale(3), just check the current LC_CTYPE category
- value, and go into eight-bit mode if it's not C or POSIX. */
+ value (passed as LOCALESTR), and go into eight-bit mode if it's not "C"
+ or "POSIX". If FORCE is non-zero, we reset the locale variables to values
+ appropriate for the C locale if the locale is "C" or "POSIX". FORCE is 0
+ when this is called from _rl_init_eightbit, since we're modifying the
+ default initial values and don't need to change anything else. If we
+ don't have setlocale(3), we check the codeset portion of LOCALESTR against
+ a set of known values and go into eight-bit mode if it matches one of those.
+ Returns 1 if we set eight-bit (multibyte) mode. */
+static int
+_rl_set_localevars (char *localestr, int force)
+{
#if defined (HAVE_SETLOCALE)
- char *lspec, *t;
-
- t = _rl_init_locale (); /* returns static pointer */
-
- if (t && *t && (t[0] != 'C' || t[1]) && (STREQ (t, "POSIX") == 0))
+ if (localestr && *localestr && (localestr[0] != 'C' || localestr[1]) && (STREQ (localestr, "POSIX") == 0))
{
_rl_meta_flag = 1;
_rl_convert_meta_chars_to_ascii = 0;
_rl_output_meta_chars = 1;
return (1);
}
+ else if (force)
+ {
+ /* Default "C" locale settings. */
+ _rl_meta_flag = 0;
+ _rl_convert_meta_chars_to_ascii = 1;
+ _rl_output_meta_chars = 0;
+ return (0);
+ }
else
return (0);
#else /* !HAVE_SETLOCALE */
- char *lspec, *t;
+ char *t;
int i;
/* We don't have setlocale. Finesse it. Check the environment for the
appropriate variables and set eight-bit mode if they have the right
values. */
- lspec = _rl_get_locale_var ("LC_CTYPE");
-
- if (lspec == 0 || (t = normalize_codeset (lspec)) == 0)
+ if (localestr == 0 || (t = normalize_codeset (localestr)) == 0)
return (0);
for (i = 0; t && legal_lang_values[i]; i++)
if (STREQ (t, legal_lang_values[i]))
@@ -185,6 +200,14 @@ _rl_init_eightbit (void)
break;
}
+ if (force && legal_lang_values[i] == 0) /* didn't find it */
+ {
+ /* Default "C" locale settings. */
+ _rl_meta_flag = 0;
+ _rl_convert_meta_chars_to_ascii = 1;
+ _rl_output_meta_chars = 0;
+ }
+
_rl_utf8locale = *t ? STREQ (t, "utf8") : 0;
xfree (t);
@@ -192,6 +215,21 @@ _rl_init_eightbit (void)
#endif /* !HAVE_SETLOCALE */
}
+/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value
+ to decide the defaults for 8-bit character input and output. Returns
+ 1 if we set eight-bit mode. */
+int
+_rl_init_eightbit (void)
+{
+ char *t, *ol;
+
+ ol = _rl_current_locale;
+ t = _rl_init_locale (); /* resets _rl_current_locale, returns static pointer */
+ xfree (ol);
+
+ return (_rl_set_localevars (t, 0));
+}
+
#if !defined (HAVE_SETLOCALE)
static char *
normalize_codeset (char *codeset)
@@ -288,3 +326,19 @@ find_codeset (char *name, size_t *lenp)
return result;
}
+
+void
+_rl_reset_locale (void)
+{
+ char *ol, *nl;
+
+ /* This should not be NULL; _rl_init_eightbit sets it on the first call to
+ readline() or rl_initialize(). */
+ ol = _rl_current_locale;
+ nl = _rl_init_locale (); /* resets _rl_current_locale */
+
+ if ((ol == 0 && nl) || (ol && nl && (STREQ (ol, nl) == 0)))
+ (void)_rl_set_localevars (nl, 1);
+
+ xfree (ol);
+}
diff --git a/lib/readline/parens.c b/lib/readline/parens.c
index af479773..57ce7045 100644
--- a/lib/readline/parens.c
+++ b/lib/readline/parens.c
@@ -1,6 +1,6 @@
/* parens.c -- implementation of matching parentheses feature. */
-/* Copyright (C) 1987, 1989, 1992-2015, 2017 Free Software Foundation, Inc.
+/* Copyright (C) 1987, 1989, 1992-2015, 2017, 2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -53,7 +53,7 @@ extern char *strchr (), *strrchr ();
#include "readline.h"
#include "rlprivate.h"
-static int find_matching_open PARAMS((char *, int, int));
+static int find_matching_open (char *, int, int);
/* Non-zero means try to blink the matching open parenthesis when the
close parenthesis is inserted. */
@@ -135,7 +135,11 @@ rl_insert_close (int count, int invoking_key)
orig_point = rl_point;
rl_point = match_point;
(*rl_redisplay_function) ();
+# if defined (RL_TIMEOUT_USE_SELECT)
+ ready = _rl_timeout_select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer, NULL);
+# else
ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer);
+# endif
rl_point = orig_point;
#else /* !HAVE_SELECT */
_rl_insert_char (count, invoking_key);
diff --git a/lib/readline/posixdir.h b/lib/readline/posixdir.h
index af5be801..b737bd7d 100644
--- a/lib/readline/posixdir.h
+++ b/lib/readline/posixdir.h
@@ -1,6 +1,6 @@
/* posixdir.h -- Posix directory reading includes and defines. */
-/* Copyright (C) 1987,1991,2012 Free Software Foundation, Inc.
+/* Copyright (C) 1987,1991,2012,2019,2021 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
diff --git a/lib/readline/posixtime.h b/lib/readline/posixtime.h
new file mode 100644
index 00000000..e70ebec6
--- /dev/null
+++ b/lib/readline/posixtime.h
@@ -0,0 +1,84 @@
+/* posixtime.h -- wrapper for time.h, sys/times.h mess. */
+
+/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef _POSIXTIME_H_
+#define _POSIXTIME_H_
+
+/* include this after config.h */
+/* Some systems require this, mostly for the definition of `struct timezone'.
+ For example, Dynix/ptx has that definition in <time.h> rather than
+ sys/time.h */
+#if defined (HAVE_SYS_TIME_H)
+# include <sys/time.h>
+#endif
+#include <time.h>
+
+#if !defined (HAVE_SYSCONF) || !defined (_SC_CLK_TCK)
+# if !defined (CLK_TCK)
+# if defined (HZ)
+# define CLK_TCK HZ
+# else
+# define CLK_TCK 60 /* 60HZ */
+# endif
+# endif /* !CLK_TCK */
+#endif /* !HAVE_SYSCONF && !_SC_CLK_TCK */
+
+#if !HAVE_TIMEVAL
+struct timeval
+{
+ time_t tv_sec;
+ long int tv_usec;
+};
+#endif
+
+#if !HAVE_GETTIMEOFDAY
+extern int gettimeofday PARAMS((struct timeval *, void *));
+#endif
+
+/* These exist on BSD systems, at least. */
+#if !defined (timerclear)
+# define timerclear(tvp) do { (tvp)->tv_sec = 0; (tvp)->tv_usec = 0; } while (0)
+#endif
+#if !defined (timerisset)
+# define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#endif
+#if !defined (timercmp)
+# define timercmp(a, b, CMP) \
+ (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_usec CMP (b)->tv_usec) \
+ : ((a)->tv_sec CMP (b)->tv_sec))
+#endif
+
+/* These are non-standard. */
+#if !defined (timerisunset)
+# define timerisunset(tvp) ((tvp)->tv_sec == 0 && (tvp)->tv_usec == 0)
+#endif
+#if !defined (timerset)
+# define timerset(tvp, s, u) do { tvp->tv_sec = s; tvp->tv_usec = u; } while (0)
+#endif
+
+#ifndef TIMEVAL_TO_TIMESPEC
+# define TIMEVAL_TO_TIMESPEC(tv, ts) \
+ do { \
+ (ts)->tv_sec = (tv)->tv_sec; \
+ (ts)->tv_nsec = (tv)->tv_usec * 1000; \
+ } while (0)
+#endif
+
+#endif /* _POSIXTIME_H_ */
diff --git a/lib/readline/readline.c b/lib/readline/readline.c
index e61d188b..9d42a8d6 100644
--- a/lib/readline/readline.c
+++ b/lib/readline/readline.c
@@ -1,7 +1,7 @@
/* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */
-/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -72,35 +72,34 @@ extern int errno;
#include "rlshell.h"
#include "xmalloc.h"
-#ifndef RL_LIBRARY_VERSION
-# define RL_LIBRARY_VERSION "8.0"
+#if defined (COLOR_SUPPORT)
+# include "parse-colors.h"
#endif
-#ifndef RL_READLINE_VERSION
-# define RL_READLINE_VERSION 0x0800
+#ifndef RL_LIBRARY_VERSION
+# define RL_LIBRARY_VERSION "8.1"
#endif
-extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
-
-#if defined (COLOR_SUPPORT)
-extern void _rl_parse_colors PARAMS((void)); /* XXX */
+#ifndef RL_READLINE_VERSION
+# define RL_READLINE_VERSION 0x0801
#endif
-
/* Forward declarations used in this file. */
-static char *readline_internal PARAMS((void));
-static void readline_initialize_everything PARAMS((void));
+static char *readline_internal (void);
+static void readline_initialize_everything (void);
+
+static void run_startup_hooks (void);
-static void bind_arrow_keys_internal PARAMS((Keymap));
-static void bind_arrow_keys PARAMS((void));
+static void bind_arrow_keys_internal (Keymap);
+static void bind_arrow_keys (void);
-static void bind_bracketed_paste_prefix PARAMS((void));
+static void bind_bracketed_paste_prefix (void);
-static void readline_default_bindings PARAMS((void));
-static void reset_default_bindings PARAMS((void));
+static void readline_default_bindings (void);
+static void reset_default_bindings (void);
-static int _rl_subseq_result PARAMS((int, Keymap, int, int));
-static int _rl_subseq_getchar PARAMS((int));
+static int _rl_subseq_result (int, Keymap, int, int);
+static int _rl_subseq_getchar (int);
/* **************************************************************** */
/* */
@@ -165,6 +164,9 @@ int rl_end;
/* Make this non-zero to return the current input_line. */
int rl_done;
+/* If non-zero when readline_internal returns, it means we found EOF */
+int rl_eof_found = 0;
+
/* The last function executed by readline. */
rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL;
@@ -218,9 +220,6 @@ int _rl_eof_char = CTRL ('D');
/* Non-zero makes this the next keystroke to read. */
int rl_pending_input = 0;
-/* If non-zero when readline_internal returns, it means we found EOF */
-int _rl_eof_found = 0;
-
/* Pointer to a useful terminal name. */
const char *rl_terminal_name = (const char *)NULL;
@@ -241,6 +240,9 @@ char *_rl_comment_begin;
/* Keymap holding the function currently being executed. */
Keymap rl_executing_keymap;
+/* The function currently being executed. */
+rl_command_func_t *_rl_executing_func;
+
/* Keymap we're currently using to dispatch. */
Keymap _rl_dispatching_keymap;
@@ -403,6 +405,16 @@ readline (const char *prompt)
return (value);
}
+static void
+run_startup_hooks (void)
+{
+ if (rl_startup_hook)
+ (*rl_startup_hook) ();
+
+ if (_rl_internal_startup_hook)
+ (*_rl_internal_startup_hook) ();
+}
+
#if defined (READLINE_CALLBACKS)
# define STATIC_CALLBACK
#else
@@ -422,11 +434,7 @@ readline_internal_setup (void)
if (_rl_enable_meta & RL_ISSTATE (RL_STATE_TERMPREPPED))
_rl_enable_meta_key ();
- if (rl_startup_hook)
- (*rl_startup_hook) ();
-
- if (_rl_internal_startup_hook)
- (*_rl_internal_startup_hook) ();
+ run_startup_hooks ();
rl_deactivate_mark ();
@@ -474,12 +482,18 @@ readline_internal_teardown (int eof)
RL_CHECK_SIGNALS ();
+ if (eof)
+ RL_SETSTATE (RL_STATE_EOF); /* XXX */
+
/* Restore the original of this history line, iff the line that we
are editing was originally in the history, AND the line has changed. */
entry = current_history ();
+ /* We don't want to do this if we executed functions that call
+ history_set_pos to set the history offset to the line containing the
+ non-incremental search string. */
if (entry && rl_undo_list)
- {
+ {
temp = savestring (the_line);
rl_revert_line (1, 0);
entry = replace_history_entry (where_history (), the_line, (histdata_t)NULL);
@@ -511,6 +525,11 @@ readline_internal_teardown (int eof)
void
_rl_internal_char_cleanup (void)
{
+ if (_rl_keep_mark_active)
+ _rl_keep_mark_active = 0;
+ else if (rl_mark_active_p ())
+ rl_deactivate_mark ();
+
#if defined (VI_MODE)
/* In vi mode, when you exit insert mode, the cursor moves back
over the previous character. We explicitly check for that here. */
@@ -567,6 +586,15 @@ readline_internal_charloop (void)
{
(*rl_redisplay_function) ();
_rl_want_redisplay = 0;
+
+ /* If we longjmped because of a timeout, handle it here. */
+ if (RL_ISSTATE (RL_STATE_TIMEOUT))
+ {
+ RL_SETSTATE (RL_STATE_DONE);
+ rl_done = 1;
+ return 1;
+ }
+
/* If we get here, we're not being called from something dispatched
from _rl_callback_read_char(), which sets up its own value of
_rl_top_level (saving and restoring the old, of course), so
@@ -596,6 +624,7 @@ readline_internal_charloop (void)
RL_SETSTATE(RL_STATE_DONE);
return (rl_done = 1);
#else
+ RL_SETSTATE(RL_STATE_EOF);
eof_found = 1;
break;
#endif
@@ -636,6 +665,7 @@ readline_internal_charloop (void)
RL_SETSTATE(RL_STATE_DONE);
return (rl_done = 1);
#else
+ RL_SETSTATE(RL_STATE_EOF);
eof_found = 1;
break;
#endif
@@ -652,6 +682,8 @@ readline_internal_charloop (void)
rl_executing_keymap = _rl_command_to_execute->map;
rl_executing_key = _rl_command_to_execute->key;
+ _rl_executing_func = _rl_command_to_execute->func;
+
rl_dispatching = 1;
RL_SETSTATE(RL_STATE_DISPATCHING);
r = (*(_rl_command_to_execute->func)) (_rl_command_to_execute->count, _rl_command_to_execute->key);
@@ -668,11 +700,6 @@ readline_internal_charloop (void)
if (rl_pending_input == 0 && lk == _rl_last_command_was_kill)
_rl_last_command_was_kill = 0;
- if (_rl_keep_mark_active)
- _rl_keep_mark_active = 0;
- else if (rl_mark_active_p ())
- rl_deactivate_mark ();
-
_rl_internal_char_cleanup ();
#if defined (READLINE_CALLBACKS)
@@ -703,8 +730,8 @@ static char *
readline_internal (void)
{
readline_internal_setup ();
- _rl_eof_found = readline_internal_charloop ();
- return (readline_internal_teardown (_rl_eof_found));
+ rl_eof_found = readline_internal_charloop ();
+ return (readline_internal_teardown (rl_eof_found));
}
void
@@ -878,6 +905,8 @@ _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
rl_executing_keymap = map;
rl_executing_key = key;
+ _rl_executing_func = func;
+
RESIZE_KEYSEQ_BUFFER();
rl_executing_keyseq[rl_key_sequence_length++] = key;
rl_executing_keyseq[rl_key_sequence_length] = '\0';
@@ -1143,6 +1172,9 @@ _rl_subseq_result (int r, Keymap map, int key, int got_subseq)
int
rl_initialize (void)
{
+ /* Initialize the timeout first to get the precise start time. */
+ _rl_timeout_init ();
+
/* If we have never been called before, initialize the
terminal and data structures. */
if (rl_initialized == 0)
@@ -1154,14 +1186,14 @@ rl_initialize (void)
RL_SETSTATE(RL_STATE_INITIALIZED);
}
else
- (void)_rl_init_locale (); /* check current locale */
+ _rl_reset_locale (); /* check current locale and set locale variables */
/* Initialize the current line information. */
_rl_init_line_state ();
/* We aren't done yet. We haven't even gotten started yet! */
rl_done = 0;
- RL_UNSETSTATE(RL_STATE_DONE);
+ RL_UNSETSTATE(RL_STATE_DONE|RL_STATE_TIMEOUT|RL_STATE_EOF);
/* Tell the history routines what is going on. */
_rl_start_using_history ();
@@ -1282,8 +1314,8 @@ readline_initialize_everything (void)
/* If the completion parser's default word break characters haven't
been set yet, then do so now. */
- if (rl_completer_word_break_characters == (char *)NULL)
- rl_completer_word_break_characters = (char *)rl_basic_word_break_characters;
+ if (rl_completer_word_break_characters == 0)
+ rl_completer_word_break_characters = rl_basic_word_break_characters;
#if defined (COLOR_SUPPORT)
if (_rl_colored_stats || _rl_colored_completion_prefix)
@@ -1532,3 +1564,12 @@ _rl_add_executing_keyseq (int key)
RESIZE_KEYSEQ_BUFFER ();
rl_executing_keyseq[rl_key_sequence_length++] = key;
}
+
+/* `delete' the last character added to the executing key sequence. Use this
+ before calling rl_execute_next to avoid keys being added twice. */
+void
+_rl_del_executing_keyseq (void)
+{
+ if (rl_key_sequence_length > 0)
+ rl_key_sequence_length--;
+}
diff --git a/lib/readline/readline.h b/lib/readline/readline.h
index 78fa39d0..cac269f0 100644
--- a/lib/readline/readline.h
+++ b/lib/readline/readline.h
@@ -1,6 +1,6 @@
/* Readline.h -- the names of functions callable from within readline. */
-/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -39,9 +39,9 @@ extern "C" {
#endif
/* Hex-encoded Readline version number. */
-#define RL_READLINE_VERSION 0x0801 /* Readline 8.0 */
+#define RL_READLINE_VERSION 0x0802 /* Readline 8.2 */
#define RL_VERSION_MAJOR 8
-#define RL_VERSION_MINOR 1
+#define RL_VERSION_MINOR 2
/* Readline data structures. */
@@ -79,211 +79,212 @@ extern FUNMAP **funmap;
/* **************************************************************** */
/* Bindable commands for numeric arguments. */
-extern int rl_digit_argument PARAMS((int, int));
-extern int rl_universal_argument PARAMS((int, int));
+extern int rl_digit_argument (int, int);
+extern int rl_universal_argument (int, int);
/* Bindable commands for moving the cursor. */
-extern int rl_forward_byte PARAMS((int, int));
-extern int rl_forward_char PARAMS((int, int));
-extern int rl_forward PARAMS((int, int));
-extern int rl_backward_byte PARAMS((int, int));
-extern int rl_backward_char PARAMS((int, int));
-extern int rl_backward PARAMS((int, int));
-extern int rl_beg_of_line PARAMS((int, int));
-extern int rl_end_of_line PARAMS((int, int));
-extern int rl_forward_word PARAMS((int, int));
-extern int rl_backward_word PARAMS((int, int));
-extern int rl_refresh_line PARAMS((int, int));
-extern int rl_clear_screen PARAMS((int, int));
-extern int rl_clear_display PARAMS((int, int));
-extern int rl_skip_csi_sequence PARAMS((int, int));
-extern int rl_arrow_keys PARAMS((int, int));
-
-extern int rl_previous_screen_line PARAMS((int, int));
-extern int rl_next_screen_line PARAMS((int, int));
+extern int rl_forward_byte (int, int);
+extern int rl_forward_char (int, int);
+extern int rl_forward (int, int);
+extern int rl_backward_byte (int, int);
+extern int rl_backward_char (int, int);
+extern int rl_backward (int, int);
+extern int rl_beg_of_line (int, int);
+extern int rl_end_of_line (int, int);
+extern int rl_forward_word (int, int);
+extern int rl_backward_word (int, int);
+extern int rl_refresh_line (int, int);
+extern int rl_clear_screen (int, int);
+extern int rl_clear_display (int, int);
+extern int rl_skip_csi_sequence (int, int);
+extern int rl_arrow_keys (int, int);
+
+extern int rl_previous_screen_line (int, int);
+extern int rl_next_screen_line (int, int);
/* Bindable commands for inserting and deleting text. */
-extern int rl_insert PARAMS((int, int));
-extern int rl_quoted_insert PARAMS((int, int));
-extern int rl_tab_insert PARAMS((int, int));
-extern int rl_newline PARAMS((int, int));
-extern int rl_do_lowercase_version PARAMS((int, int));
-extern int rl_rubout PARAMS((int, int));
-extern int rl_delete PARAMS((int, int));
-extern int rl_rubout_or_delete PARAMS((int, int));
-extern int rl_delete_horizontal_space PARAMS((int, int));
-extern int rl_delete_or_show_completions PARAMS((int, int));
-extern int rl_insert_comment PARAMS((int, int));
+extern int rl_insert (int, int);
+extern int rl_quoted_insert (int, int);
+extern int rl_tab_insert (int, int);
+extern int rl_newline (int, int);
+extern int rl_do_lowercase_version (int, int);
+extern int rl_rubout (int, int);
+extern int rl_delete (int, int);
+extern int rl_rubout_or_delete (int, int);
+extern int rl_delete_horizontal_space (int, int);
+extern int rl_delete_or_show_completions (int, int);
+extern int rl_insert_comment (int, int);
/* Bindable commands for changing case. */
-extern int rl_upcase_word PARAMS((int, int));
-extern int rl_downcase_word PARAMS((int, int));
-extern int rl_capitalize_word PARAMS((int, int));
+extern int rl_upcase_word (int, int);
+extern int rl_downcase_word (int, int);
+extern int rl_capitalize_word (int, int);
/* Bindable commands for transposing characters and words. */
-extern int rl_transpose_words PARAMS((int, int));
-extern int rl_transpose_chars PARAMS((int, int));
+extern int rl_transpose_words (int, int);
+extern int rl_transpose_chars (int, int);
/* Bindable commands for searching within a line. */
-extern int rl_char_search PARAMS((int, int));
-extern int rl_backward_char_search PARAMS((int, int));
+extern int rl_char_search (int, int);
+extern int rl_backward_char_search (int, int);
/* Bindable commands for readline's interface to the command history. */
-extern int rl_beginning_of_history PARAMS((int, int));
-extern int rl_end_of_history PARAMS((int, int));
-extern int rl_get_next_history PARAMS((int, int));
-extern int rl_get_previous_history PARAMS((int, int));
-extern int rl_operate_and_get_next PARAMS((int, int));
+extern int rl_beginning_of_history (int, int);
+extern int rl_end_of_history (int, int);
+extern int rl_get_next_history (int, int);
+extern int rl_get_previous_history (int, int);
+extern int rl_operate_and_get_next (int, int);
+extern int rl_fetch_history (int, int);
/* Bindable commands for managing the mark and region. */
-extern int rl_set_mark PARAMS((int, int));
-extern int rl_exchange_point_and_mark PARAMS((int, int));
+extern int rl_set_mark (int, int);
+extern int rl_exchange_point_and_mark (int, int);
/* Bindable commands to set the editing mode (emacs or vi). */
-extern int rl_vi_editing_mode PARAMS((int, int));
-extern int rl_emacs_editing_mode PARAMS((int, int));
+extern int rl_vi_editing_mode (int, int);
+extern int rl_emacs_editing_mode (int, int);
/* Bindable commands to change the insert mode (insert or overwrite) */
-extern int rl_overwrite_mode PARAMS((int, int));
+extern int rl_overwrite_mode (int, int);
/* Bindable commands for managing key bindings. */
-extern int rl_re_read_init_file PARAMS((int, int));
-extern int rl_dump_functions PARAMS((int, int));
-extern int rl_dump_macros PARAMS((int, int));
-extern int rl_dump_variables PARAMS((int, int));
+extern int rl_re_read_init_file (int, int);
+extern int rl_dump_functions (int, int);
+extern int rl_dump_macros (int, int);
+extern int rl_dump_variables (int, int);
/* Bindable commands for word completion. */
-extern int rl_complete PARAMS((int, int));
-extern int rl_possible_completions PARAMS((int, int));
-extern int rl_insert_completions PARAMS((int, int));
-extern int rl_old_menu_complete PARAMS((int, int));
-extern int rl_menu_complete PARAMS((int, int));
-extern int rl_backward_menu_complete PARAMS((int, int));
+extern int rl_complete (int, int);
+extern int rl_possible_completions (int, int);
+extern int rl_insert_completions (int, int);
+extern int rl_old_menu_complete (int, int);
+extern int rl_menu_complete (int, int);
+extern int rl_backward_menu_complete (int, int);
/* Bindable commands for killing and yanking text, and managing the kill ring. */
-extern int rl_kill_word PARAMS((int, int));
-extern int rl_backward_kill_word PARAMS((int, int));
-extern int rl_kill_line PARAMS((int, int));
-extern int rl_backward_kill_line PARAMS((int, int));
-extern int rl_kill_full_line PARAMS((int, int));
-extern int rl_unix_word_rubout PARAMS((int, int));
-extern int rl_unix_filename_rubout PARAMS((int, int));
-extern int rl_unix_line_discard PARAMS((int, int));
-extern int rl_copy_region_to_kill PARAMS((int, int));
-extern int rl_kill_region PARAMS((int, int));
-extern int rl_copy_forward_word PARAMS((int, int));
-extern int rl_copy_backward_word PARAMS((int, int));
-extern int rl_yank PARAMS((int, int));
-extern int rl_yank_pop PARAMS((int, int));
-extern int rl_yank_nth_arg PARAMS((int, int));
-extern int rl_yank_last_arg PARAMS((int, int));
-extern int rl_bracketed_paste_begin PARAMS((int, int));
+extern int rl_kill_word (int, int);
+extern int rl_backward_kill_word (int, int);
+extern int rl_kill_line (int, int);
+extern int rl_backward_kill_line (int, int);
+extern int rl_kill_full_line (int, int);
+extern int rl_unix_word_rubout (int, int);
+extern int rl_unix_filename_rubout (int, int);
+extern int rl_unix_line_discard (int, int);
+extern int rl_copy_region_to_kill (int, int);
+extern int rl_kill_region (int, int);
+extern int rl_copy_forward_word (int, int);
+extern int rl_copy_backward_word (int, int);
+extern int rl_yank (int, int);
+extern int rl_yank_pop (int, int);
+extern int rl_yank_nth_arg (int, int);
+extern int rl_yank_last_arg (int, int);
+extern int rl_bracketed_paste_begin (int, int);
/* Not available unless _WIN32 is defined. */
#if defined (_WIN32)
-extern int rl_paste_from_clipboard PARAMS((int, int));
+extern int rl_paste_from_clipboard (int, int);
#endif
/* Bindable commands for incremental searching. */
-extern int rl_reverse_search_history PARAMS((int, int));
-extern int rl_forward_search_history PARAMS((int, int));
+extern int rl_reverse_search_history (int, int);
+extern int rl_forward_search_history (int, int);
/* Bindable keyboard macro commands. */
-extern int rl_start_kbd_macro PARAMS((int, int));
-extern int rl_end_kbd_macro PARAMS((int, int));
-extern int rl_call_last_kbd_macro PARAMS((int, int));
-extern int rl_print_last_kbd_macro PARAMS((int, int));
+extern int rl_start_kbd_macro (int, int);
+extern int rl_end_kbd_macro (int, int);
+extern int rl_call_last_kbd_macro (int, int);
+extern int rl_print_last_kbd_macro (int, int);
/* Bindable undo commands. */
-extern int rl_revert_line PARAMS((int, int));
-extern int rl_undo_command PARAMS((int, int));
+extern int rl_revert_line (int, int);
+extern int rl_undo_command (int, int);
/* Bindable tilde expansion commands. */
-extern int rl_tilde_expand PARAMS((int, int));
+extern int rl_tilde_expand (int, int);
/* Bindable terminal control commands. */
-extern int rl_restart_output PARAMS((int, int));
-extern int rl_stop_output PARAMS((int, int));
+extern int rl_restart_output (int, int);
+extern int rl_stop_output (int, int);
/* Miscellaneous bindable commands. */
-extern int rl_abort PARAMS((int, int));
-extern int rl_tty_status PARAMS((int, int));
+extern int rl_abort (int, int);
+extern int rl_tty_status (int, int);
/* Bindable commands for incremental and non-incremental history searching. */
-extern int rl_history_search_forward PARAMS((int, int));
-extern int rl_history_search_backward PARAMS((int, int));
-extern int rl_history_substr_search_forward PARAMS((int, int));
-extern int rl_history_substr_search_backward PARAMS((int, int));
-extern int rl_noninc_forward_search PARAMS((int, int));
-extern int rl_noninc_reverse_search PARAMS((int, int));
-extern int rl_noninc_forward_search_again PARAMS((int, int));
-extern int rl_noninc_reverse_search_again PARAMS((int, int));
+extern int rl_history_search_forward (int, int);
+extern int rl_history_search_backward (int, int);
+extern int rl_history_substr_search_forward (int, int);
+extern int rl_history_substr_search_backward (int, int);
+extern int rl_noninc_forward_search (int, int);
+extern int rl_noninc_reverse_search (int, int);
+extern int rl_noninc_forward_search_again (int, int);
+extern int rl_noninc_reverse_search_again (int, int);
/* Bindable command used when inserting a matching close character. */
-extern int rl_insert_close PARAMS((int, int));
+extern int rl_insert_close (int, int);
/* Not available unless READLINE_CALLBACKS is defined. */
-extern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *));
-extern void rl_callback_read_char PARAMS((void));
-extern void rl_callback_handler_remove PARAMS((void));
-extern void rl_callback_sigcleanup PARAMS((void));
+extern void rl_callback_handler_install (const char *, rl_vcpfunc_t *);
+extern void rl_callback_read_char (void);
+extern void rl_callback_handler_remove (void);
+extern void rl_callback_sigcleanup (void);
/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
/* VI-mode bindable commands. */
-extern int rl_vi_redo PARAMS((int, int));
-extern int rl_vi_undo PARAMS((int, int));
-extern int rl_vi_yank_arg PARAMS((int, int));
-extern int rl_vi_fetch_history PARAMS((int, int));
-extern int rl_vi_search_again PARAMS((int, int));
-extern int rl_vi_search PARAMS((int, int));
-extern int rl_vi_complete PARAMS((int, int));
-extern int rl_vi_tilde_expand PARAMS((int, int));
-extern int rl_vi_prev_word PARAMS((int, int));
-extern int rl_vi_next_word PARAMS((int, int));
-extern int rl_vi_end_word PARAMS((int, int));
-extern int rl_vi_insert_beg PARAMS((int, int));
-extern int rl_vi_append_mode PARAMS((int, int));
-extern int rl_vi_append_eol PARAMS((int, int));
-extern int rl_vi_eof_maybe PARAMS((int, int));
-extern int rl_vi_insertion_mode PARAMS((int, int));
-extern int rl_vi_insert_mode PARAMS((int, int));
-extern int rl_vi_movement_mode PARAMS((int, int));
-extern int rl_vi_arg_digit PARAMS((int, int));
-extern int rl_vi_change_case PARAMS((int, int));
-extern int rl_vi_put PARAMS((int, int));
-extern int rl_vi_column PARAMS((int, int));
-extern int rl_vi_delete_to PARAMS((int, int));
-extern int rl_vi_change_to PARAMS((int, int));
-extern int rl_vi_yank_to PARAMS((int, int));
-extern int rl_vi_yank_pop PARAMS((int, int));
-extern int rl_vi_rubout PARAMS((int, int));
-extern int rl_vi_delete PARAMS((int, int));
-extern int rl_vi_back_to_indent PARAMS((int, int));
-extern int rl_vi_unix_word_rubout PARAMS((int, int));
-extern int rl_vi_first_print PARAMS((int, int));
-extern int rl_vi_char_search PARAMS((int, int));
-extern int rl_vi_match PARAMS((int, int));
-extern int rl_vi_change_char PARAMS((int, int));
-extern int rl_vi_subst PARAMS((int, int));
-extern int rl_vi_overstrike PARAMS((int, int));
-extern int rl_vi_overstrike_delete PARAMS((int, int));
-extern int rl_vi_replace PARAMS((int, int));
-extern int rl_vi_set_mark PARAMS((int, int));
-extern int rl_vi_goto_mark PARAMS((int, int));
+extern int rl_vi_redo (int, int);
+extern int rl_vi_undo (int, int);
+extern int rl_vi_yank_arg (int, int);
+extern int rl_vi_fetch_history (int, int);
+extern int rl_vi_search_again (int, int);
+extern int rl_vi_search (int, int);
+extern int rl_vi_complete (int, int);
+extern int rl_vi_tilde_expand (int, int);
+extern int rl_vi_prev_word (int, int);
+extern int rl_vi_next_word (int, int);
+extern int rl_vi_end_word (int, int);
+extern int rl_vi_insert_beg (int, int);
+extern int rl_vi_append_mode (int, int);
+extern int rl_vi_append_eol (int, int);
+extern int rl_vi_eof_maybe (int, int);
+extern int rl_vi_insertion_mode (int, int);
+extern int rl_vi_insert_mode (int, int);
+extern int rl_vi_movement_mode (int, int);
+extern int rl_vi_arg_digit (int, int);
+extern int rl_vi_change_case (int, int);
+extern int rl_vi_put (int, int);
+extern int rl_vi_column (int, int);
+extern int rl_vi_delete_to (int, int);
+extern int rl_vi_change_to (int, int);
+extern int rl_vi_yank_to (int, int);
+extern int rl_vi_yank_pop (int, int);
+extern int rl_vi_rubout (int, int);
+extern int rl_vi_delete (int, int);
+extern int rl_vi_back_to_indent (int, int);
+extern int rl_vi_unix_word_rubout (int, int);
+extern int rl_vi_first_print (int, int);
+extern int rl_vi_char_search (int, int);
+extern int rl_vi_match (int, int);
+extern int rl_vi_change_char (int, int);
+extern int rl_vi_subst (int, int);
+extern int rl_vi_overstrike (int, int);
+extern int rl_vi_overstrike_delete (int, int);
+extern int rl_vi_replace (int, int);
+extern int rl_vi_set_mark (int, int);
+extern int rl_vi_goto_mark (int, int);
/* VI-mode utility functions. */
-extern int rl_vi_check PARAMS((void));
-extern int rl_vi_domove PARAMS((int, int *));
-extern int rl_vi_bracktype PARAMS((int));
+extern int rl_vi_check (void);
+extern int rl_vi_domove (int, int *);
+extern int rl_vi_bracktype (int);
-extern void rl_vi_start_inserting PARAMS((int, int, int));
+extern void rl_vi_start_inserting (int, int, int);
/* VI-mode pseudo-bindable commands, used as utility functions. */
-extern int rl_vi_fWord PARAMS((int, int));
-extern int rl_vi_bWord PARAMS((int, int));
-extern int rl_vi_eWord PARAMS((int, int));
-extern int rl_vi_fword PARAMS((int, int));
-extern int rl_vi_bword PARAMS((int, int));
-extern int rl_vi_eword PARAMS((int, int));
+extern int rl_vi_fWord (int, int);
+extern int rl_vi_bWord (int, int);
+extern int rl_vi_eWord (int, int);
+extern int rl_vi_fword (int, int);
+extern int rl_vi_bword (int, int);
+extern int rl_vi_eword (int, int);
/* **************************************************************** */
/* */
@@ -293,114 +294,115 @@ extern int rl_vi_eword PARAMS((int, int));
/* Readline functions. */
/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
-extern char *readline PARAMS((const char *));
+extern char *readline (const char *);
-extern int rl_set_prompt PARAMS((const char *));
-extern int rl_expand_prompt PARAMS((char *));
+extern int rl_set_prompt (const char *);
+extern int rl_expand_prompt (char *);
-extern int rl_initialize PARAMS((void));
+extern int rl_initialize (void);
/* Undocumented; unused by readline */
-extern int rl_discard_argument PARAMS((void));
+extern int rl_discard_argument (void);
/* Utility functions to bind keys to readline commands. */
-extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
-extern int rl_bind_key PARAMS((int, rl_command_func_t *));
-extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
-extern int rl_unbind_key PARAMS((int));
-extern int rl_unbind_key_in_map PARAMS((int, Keymap));
-extern int rl_bind_key_if_unbound PARAMS((int, rl_command_func_t *));
-extern int rl_bind_key_if_unbound_in_map PARAMS((int, rl_command_func_t *, Keymap));
-extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
-extern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
-extern int rl_bind_keyseq PARAMS((const char *, rl_command_func_t *));
-extern int rl_bind_keyseq_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
-extern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *));
-extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
-extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
-
-extern char *rl_variable_value PARAMS((const char *));
-extern int rl_variable_bind PARAMS((const char *, const char *));
+extern int rl_add_defun (const char *, rl_command_func_t *, int);
+extern int rl_bind_key (int, rl_command_func_t *);
+extern int rl_bind_key_in_map (int, rl_command_func_t *, Keymap);
+extern int rl_unbind_key (int);
+extern int rl_unbind_key_in_map (int, Keymap);
+extern int rl_bind_key_if_unbound (int, rl_command_func_t *);
+extern int rl_bind_key_if_unbound_in_map (int, rl_command_func_t *, Keymap);
+extern int rl_unbind_function_in_map (rl_command_func_t *, Keymap);
+extern int rl_unbind_command_in_map (const char *, Keymap);
+extern int rl_bind_keyseq (const char *, rl_command_func_t *);
+extern int rl_bind_keyseq_in_map (const char *, rl_command_func_t *, Keymap);
+extern int rl_bind_keyseq_if_unbound (const char *, rl_command_func_t *);
+extern int rl_bind_keyseq_if_unbound_in_map (const char *, rl_command_func_t *, Keymap);
+extern int rl_generic_bind (int, const char *, char *, Keymap);
+
+extern char *rl_variable_value (const char *);
+extern int rl_variable_bind (const char *, const char *);
/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
-extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
+extern int rl_set_key (const char *, rl_command_func_t *, Keymap);
/* Backwards compatibility, use rl_generic_bind instead. */
-extern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
+extern int rl_macro_bind (const char *, const char *, Keymap);
/* Undocumented in the texinfo manual; not really useful to programs. */
-extern int rl_translate_keyseq PARAMS((const char *, char *, int *));
-extern char *rl_untranslate_keyseq PARAMS((int));
+extern int rl_translate_keyseq (const char *, char *, int *);
+extern char *rl_untranslate_keyseq (int);
-extern rl_command_func_t *rl_named_function PARAMS((const char *));
-extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *));
-extern rl_command_func_t *rl_function_of_keyseq_len PARAMS((const char *, size_t, Keymap, int *));
+extern rl_command_func_t *rl_named_function (const char *);
+extern rl_command_func_t *rl_function_of_keyseq (const char *, Keymap, int *);
+extern rl_command_func_t *rl_function_of_keyseq_len (const char *, size_t, Keymap, int *);
+extern int rl_trim_arg_from_keyseq (const char *, size_t, Keymap);
-extern void rl_list_funmap_names PARAMS((void));
-extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
-extern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *));
+extern void rl_list_funmap_names (void);
+extern char **rl_invoking_keyseqs_in_map (rl_command_func_t *, Keymap);
+extern char **rl_invoking_keyseqs (rl_command_func_t *);
-extern void rl_function_dumper PARAMS((int));
-extern void rl_macro_dumper PARAMS((int));
-extern void rl_variable_dumper PARAMS((int));
+extern void rl_function_dumper (int);
+extern void rl_macro_dumper (int);
+extern void rl_variable_dumper (int);
-extern int rl_read_init_file PARAMS((const char *));
-extern int rl_parse_and_bind PARAMS((char *));
+extern int rl_read_init_file (const char *);
+extern int rl_parse_and_bind (char *);
/* Functions for manipulating keymaps. */
-extern Keymap rl_make_bare_keymap PARAMS((void));
-extern int rl_empty_keymap PARAMS((Keymap));
-extern Keymap rl_copy_keymap PARAMS((Keymap));
-extern Keymap rl_make_keymap PARAMS((void));
-extern void rl_discard_keymap PARAMS((Keymap));
-extern void rl_free_keymap PARAMS((Keymap));
+extern Keymap rl_make_bare_keymap (void);
+extern int rl_empty_keymap (Keymap);
+extern Keymap rl_copy_keymap (Keymap);
+extern Keymap rl_make_keymap (void);
+extern void rl_discard_keymap (Keymap);
+extern void rl_free_keymap (Keymap);
-extern Keymap rl_get_keymap_by_name PARAMS((const char *));
-extern char *rl_get_keymap_name PARAMS((Keymap));
-extern void rl_set_keymap PARAMS((Keymap));
-extern Keymap rl_get_keymap PARAMS((void));
+extern Keymap rl_get_keymap_by_name (const char *);
+extern char *rl_get_keymap_name (Keymap);
+extern void rl_set_keymap (Keymap);
+extern Keymap rl_get_keymap (void);
-extern int rl_set_keymap_name PARAMS((const char *, Keymap));
+extern int rl_set_keymap_name (const char *, Keymap);
/* Undocumented; used internally only. */
-extern void rl_set_keymap_from_edit_mode PARAMS((void));
-extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
+extern void rl_set_keymap_from_edit_mode (void);
+extern char *rl_get_keymap_name_from_edit_mode (void);
/* Functions for manipulating the funmap, which maps command names to functions. */
-extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
-extern const char **rl_funmap_names PARAMS((void));
+extern int rl_add_funmap_entry (const char *, rl_command_func_t *);
+extern const char **rl_funmap_names (void);
/* Undocumented, only used internally -- there is only one funmap, and this
function may be called only once. */
-extern void rl_initialize_funmap PARAMS((void));
+extern void rl_initialize_funmap (void);
/* Utility functions for managing keyboard macros. */
-extern void rl_push_macro_input PARAMS((char *));
+extern void rl_push_macro_input (char *);
/* Functions for undoing, from undo.c */
-extern void rl_add_undo PARAMS((enum undo_code, int, int, char *));
-extern void rl_free_undo_list PARAMS((void));
-extern int rl_do_undo PARAMS((void));
-extern int rl_begin_undo_group PARAMS((void));
-extern int rl_end_undo_group PARAMS((void));
-extern int rl_modifying PARAMS((int, int));
+extern void rl_add_undo (enum undo_code, int, int, char *);
+extern void rl_free_undo_list (void);
+extern int rl_do_undo (void);
+extern int rl_begin_undo_group (void);
+extern int rl_end_undo_group (void);
+extern int rl_modifying (int, int);
/* Functions for redisplay. */
-extern void rl_redisplay PARAMS((void));
-extern int rl_on_new_line PARAMS((void));
-extern int rl_on_new_line_with_prompt PARAMS((void));
-extern int rl_forced_update_display PARAMS((void));
-extern int rl_clear_visible_line PARAMS((void));
-extern int rl_clear_message PARAMS((void));
-extern int rl_reset_line_state PARAMS((void));
-extern int rl_crlf PARAMS((void));
+extern void rl_redisplay (void);
+extern int rl_on_new_line (void);
+extern int rl_on_new_line_with_prompt (void);
+extern int rl_forced_update_display (void);
+extern int rl_clear_visible_line (void);
+extern int rl_clear_message (void);
+extern int rl_reset_line_state (void);
+extern int rl_crlf (void);
/* Functions to manage the mark and region, especially the notion of an
active mark and an active region. */
-extern void rl_keep_mark_active PARAMS((void));
+extern void rl_keep_mark_active (void);
-extern void rl_activate_mark PARAMS((void));
-extern void rl_deactivate_mark PARAMS((void));
-extern int rl_mark_active_p PARAMS((void));
+extern void rl_activate_mark (void);
+extern void rl_deactivate_mark (void);
+extern int rl_mark_active_p (void);
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
@@ -408,99 +410,106 @@ extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1,
extern int rl_message ();
#endif
-extern int rl_show_char PARAMS((int));
+extern int rl_show_char (int);
/* Undocumented in texinfo manual. */
-extern int rl_character_len PARAMS((int, int));
-extern void rl_redraw_prompt_last_line PARAMS((void));
+extern int rl_character_len (int, int);
+extern void rl_redraw_prompt_last_line (void);
/* Save and restore internal prompt redisplay information. */
-extern void rl_save_prompt PARAMS((void));
-extern void rl_restore_prompt PARAMS((void));
+extern void rl_save_prompt (void);
+extern void rl_restore_prompt (void);
/* Modifying text. */
-extern void rl_replace_line PARAMS((const char *, int));
-extern int rl_insert_text PARAMS((const char *));
-extern int rl_delete_text PARAMS((int, int));
-extern int rl_kill_text PARAMS((int, int));
-extern char *rl_copy_text PARAMS((int, int));
+extern void rl_replace_line (const char *, int);
+extern int rl_insert_text (const char *);
+extern int rl_delete_text (int, int);
+extern int rl_kill_text (int, int);
+extern char *rl_copy_text (int, int);
/* Terminal and tty mode management. */
-extern void rl_prep_terminal PARAMS((int));
-extern void rl_deprep_terminal PARAMS((void));
-extern void rl_tty_set_default_bindings PARAMS((Keymap));
-extern void rl_tty_unset_default_bindings PARAMS((Keymap));
+extern void rl_prep_terminal (int);
+extern void rl_deprep_terminal (void);
+extern void rl_tty_set_default_bindings (Keymap);
+extern void rl_tty_unset_default_bindings (Keymap);
-extern int rl_tty_set_echoing PARAMS((int));
-extern int rl_reset_terminal PARAMS((const char *));
-extern void rl_resize_terminal PARAMS((void));
-extern void rl_set_screen_size PARAMS((int, int));
-extern void rl_get_screen_size PARAMS((int *, int *));
-extern void rl_reset_screen_size PARAMS((void));
+extern int rl_tty_set_echoing (int);
+extern int rl_reset_terminal (const char *);
+extern void rl_resize_terminal (void);
+extern void rl_set_screen_size (int, int);
+extern void rl_get_screen_size (int *, int *);
+extern void rl_reset_screen_size (void);
-extern char *rl_get_termcap PARAMS((const char *));
+extern char *rl_get_termcap (const char *);
/* Functions for character input. */
-extern int rl_stuff_char PARAMS((int));
-extern int rl_execute_next PARAMS((int));
-extern int rl_clear_pending_input PARAMS((void));
-extern int rl_read_key PARAMS((void));
-extern int rl_getc PARAMS((FILE *));
-extern int rl_set_keyboard_input_timeout PARAMS((int));
+extern int rl_stuff_char (int);
+extern int rl_execute_next (int);
+extern int rl_clear_pending_input (void);
+extern int rl_read_key (void);
+extern int rl_getc (FILE *);
+extern int rl_set_keyboard_input_timeout (int);
+
+/* Functions to set and reset timeouts. */
+extern int rl_set_timeout (unsigned int, unsigned int);
+extern int rl_timeout_remaining (unsigned int *, unsigned int *);
+
+#undef rl_clear_timeout
+#define rl_clear_timeout() rl_set_timeout (0, 0)
/* `Public' utility functions . */
-extern void rl_extend_line_buffer PARAMS((int));
-extern int rl_ding PARAMS((void));
-extern int rl_alphabetic PARAMS((int));
-extern void rl_free PARAMS((void *));
+extern void rl_extend_line_buffer (int);
+extern int rl_ding (void);
+extern int rl_alphabetic (int);
+extern void rl_free (void *);
/* Readline signal handling, from signals.c */
-extern int rl_set_signals PARAMS((void));
-extern int rl_clear_signals PARAMS((void));
-extern void rl_cleanup_after_signal PARAMS((void));
-extern void rl_reset_after_signal PARAMS((void));
-extern void rl_free_line_state PARAMS((void));
+extern int rl_set_signals (void);
+extern int rl_clear_signals (void);
+extern void rl_cleanup_after_signal (void);
+extern void rl_reset_after_signal (void);
+extern void rl_free_line_state (void);
-extern int rl_pending_signal PARAMS((void));
-extern void rl_check_signals PARAMS((void));
+extern int rl_pending_signal (void);
+extern void rl_check_signals (void);
-extern void rl_echo_signal_char PARAMS((int));
+extern void rl_echo_signal_char (int);
-extern int rl_set_paren_blink_timeout PARAMS((int));
+extern int rl_set_paren_blink_timeout (int);
/* History management functions. */
-extern void rl_clear_history PARAMS((void));
+extern void rl_clear_history (void);
/* Undocumented. */
-extern int rl_maybe_save_line PARAMS((void));
-extern int rl_maybe_unsave_line PARAMS((void));
-extern int rl_maybe_replace_line PARAMS((void));
+extern int rl_maybe_save_line (void);
+extern int rl_maybe_unsave_line (void);
+extern int rl_maybe_replace_line (void);
/* Completion functions. */
-extern int rl_complete_internal PARAMS((int));
-extern void rl_display_match_list PARAMS((char **, int, int));
+extern int rl_complete_internal (int);
+extern void rl_display_match_list (char **, int, int);
-extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
-extern char *rl_username_completion_function PARAMS((const char *, int));
-extern char *rl_filename_completion_function PARAMS((const char *, int));
+extern char **rl_completion_matches (const char *, rl_compentry_func_t *);
+extern char *rl_username_completion_function (const char *, int);
+extern char *rl_filename_completion_function (const char *, int);
-extern int rl_completion_mode PARAMS((rl_command_func_t *));
+extern int rl_completion_mode (rl_command_func_t *);
#if 0
/* Backwards compatibility (compat.c). These will go away sometime. */
-extern void free_undo_list PARAMS((void));
-extern int maybe_save_line PARAMS((void));
-extern int maybe_unsave_line PARAMS((void));
-extern int maybe_replace_line PARAMS((void));
-
-extern int ding PARAMS((void));
-extern int alphabetic PARAMS((int));
-extern int crlf PARAMS((void));
-
-extern char **completion_matches PARAMS((char *, rl_compentry_func_t *));
-extern char *username_completion_function PARAMS((const char *, int));
-extern char *filename_completion_function PARAMS((const char *, int));
+extern void free_undo_list (void);
+extern int maybe_save_line (void);
+extern int maybe_unsave_line (void);
+extern int maybe_replace_line (void);
+
+extern int ding (void);
+extern int alphabetic (int);
+extern int crlf (void);
+
+extern char **completion_matches (char *, rl_compentry_func_t *);
+extern char *username_completion_function (const char *, int);
+extern char *filename_completion_function (const char *, int);
#endif
/* **************************************************************** */
@@ -553,6 +562,10 @@ extern int rl_mark;
line and should return it. */
extern int rl_done;
+/* Flag to indicate that readline has read an EOF character or read has
+ returned 0 or error, and is returning a NULL line as a result. */
+extern int rl_eof_found;
+
/* If set to a character value, that will be the next keystroke read. */
extern int rl_pending_input;
@@ -599,6 +612,8 @@ extern rl_hook_func_t *rl_event_hook;
/* The address of a function to call if a read is interrupted by a signal. */
extern rl_hook_func_t *rl_signal_event_hook;
+extern rl_hook_func_t *rl_timeout_event_hook;
+
/* The address of a function to call if Readline needs to know whether or not
there is data available from the current input source. */
extern rl_hook_func_t *rl_input_available_hook;
@@ -689,7 +704,7 @@ extern const char *rl_basic_word_break_characters;
/* The list of characters that signal a break between words for
rl_complete_internal. The default list is the contents of
rl_basic_word_break_characters. */
-extern /*const*/ char *rl_completer_word_break_characters;
+extern const char *rl_completer_word_break_characters;
/* Hook function to allow an application to set the completion word
break characters before readline breaks up the line. Allows
@@ -906,6 +921,8 @@ extern int rl_persistent_signal_handlers;
#define RL_STATE_REDISPLAYING 0x1000000 /* updating terminal display */
#define RL_STATE_DONE 0x2000000 /* done; accepted line */
+#define RL_STATE_TIMEOUT 0x4000000 /* done; timed out */
+#define RL_STATE_EOF 0x8000000 /* done; got eof on read */
#define RL_SETSTATE(x) (rl_readline_state |= (x))
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
@@ -949,7 +966,7 @@ struct readline_state {
rl_compentry_func_t *menuentryfunc;
rl_compignore_func_t *ignorefunc;
rl_completion_func_t *attemptfunc;
- char *wordbreakchars;
+ const char *wordbreakchars;
/* options state */
@@ -959,8 +976,8 @@ struct readline_state {
char reserved[64];
};
-extern int rl_save_state PARAMS((struct readline_state *));
-extern int rl_restore_state PARAMS((struct readline_state *));
+extern int rl_save_state (struct readline_state *);
+extern int rl_restore_state (struct readline_state *);
#ifdef __cplusplus
}
diff --git a/lib/readline/rldefs.h b/lib/readline/rldefs.h
index dab1beba..98577a64 100644
--- a/lib/readline/rldefs.h
+++ b/lib/readline/rldefs.h
@@ -2,7 +2,7 @@
for readline. This should be included after any files that define
system-specific constants like _POSIX_VERSION or USG. */
-/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -79,14 +79,14 @@ extern char *strchr (), *strrchr ();
#define _rl_stricmp strcasecmp
#define _rl_strnicmp strncasecmp
#else
-extern int _rl_stricmp PARAMS((const char *, const char *));
-extern int _rl_strnicmp PARAMS((const char *, const char *, int));
+extern int _rl_stricmp (const char *, const char *);
+extern int _rl_strnicmp (const char *, const char *, int);
#endif
#if defined (HAVE_STRPBRK) && !defined (HAVE_MULTIBYTE)
# define _rl_strpbrk(a,b) strpbrk((a),(b))
#else
-extern char *_rl_strpbrk PARAMS((const char *, const char *));
+extern char *_rl_strpbrk (const char *, const char *);
#endif
#if !defined (emacs_mode)
diff --git a/lib/readline/rlmbutil.h b/lib/readline/rlmbutil.h
index 4d3e9070..d9060572 100644
--- a/lib/readline/rlmbutil.h
+++ b/lib/readline/rlmbutil.h
@@ -1,6 +1,6 @@
/* rlmbutil.h -- utility functions for multibyte characters. */
-/* Copyright (C) 2001-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -82,6 +82,19 @@
/************************************************/
/*
+ * wchar_t doesn't work for 32-bit values on Windows using MSVC
+ */
+#ifdef WCHAR_T_BROKEN
+# define WCHAR_T char32_t
+# define MBRTOWC mbrtoc32
+# define WCRTOMB c32rtomb
+#else /* normal systems */
+# define WCHAR_T wchar_t
+# define MBRTOWC mbrtowc
+# define WCRTOMB wcrtomb
+#endif
+
+/*
* Flags for _rl_find_prev_mbchar and _rl_find_next_mbchar:
*
* MB_FIND_ANY find any multibyte character
@@ -91,22 +104,22 @@
#define MB_FIND_ANY 0x00
#define MB_FIND_NONZERO 0x01
-extern int _rl_find_prev_mbchar PARAMS((char *, int, int));
-extern int _rl_find_next_mbchar PARAMS((char *, int, int, int));
+extern int _rl_find_prev_mbchar (char *, int, int);
+extern int _rl_find_next_mbchar (char *, int, int, int);
#ifdef HANDLE_MULTIBYTE
-extern int _rl_compare_chars PARAMS((char *, int, mbstate_t *, char *, int, mbstate_t *));
-extern int _rl_get_char_len PARAMS((char *, mbstate_t *));
-extern int _rl_adjust_point PARAMS((char *, int, mbstate_t *));
+extern int _rl_compare_chars (char *, int, mbstate_t *, char *, int, mbstate_t *);
+extern int _rl_get_char_len (char *, mbstate_t *);
+extern int _rl_adjust_point (char *, int, mbstate_t *);
-extern int _rl_read_mbchar PARAMS((char *, int));
-extern int _rl_read_mbstring PARAMS((int, char *, int));
+extern int _rl_read_mbchar (char *, int);
+extern int _rl_read_mbstring (int, char *, int);
-extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int));
+extern int _rl_is_mbchar_matched (char *, int, int, char *, int);
-extern wchar_t _rl_char_value PARAMS((char *, int));
-extern int _rl_walphabetic PARAMS((wchar_t));
+extern WCHAR_T _rl_char_value (char *, int);
+extern int _rl_walphabetic (WCHAR_T);
#define _rl_to_wupper(wc) (iswlower (wc) ? towupper (wc) : (wc))
#define _rl_to_wlower(wc) (iswupper (wc) ? towlower (wc) : (wc))
@@ -126,8 +139,7 @@ extern int _rl_walphabetic PARAMS((wchar_t));
/* Try and shortcut the printable ascii characters to cut down the number of
calls to a libc wcwidth() */
static inline int
-_rl_wcwidth (wc)
- wchar_t wc;
+_rl_wcwidth (WCHAR_T wc)
{
switch (wc)
{
diff --git a/lib/readline/rlprivate.h b/lib/readline/rlprivate.h
index 23ab2d8c..d87d07a7 100644
--- a/lib/readline/rlprivate.h
+++ b/lib/readline/rlprivate.h
@@ -1,10 +1,10 @@
/* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */
-/* Copyright (C) 1999-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
- for reading lines of text with interactive input and history editing.
+ for reading lines of text with interactive input and history editing.
Readline is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -78,7 +78,7 @@ typedef struct __rl_search_context
int search_string_size;
char **lines;
- char *allocated_line;
+ char *allocated_line;
int hlen;
int hindex;
@@ -169,16 +169,16 @@ typedef struct __rl_vimotion_context
/* fill in more as needed */
/* `Generic' callback data and functions */
-typedef struct __rl_callback_generic_arg
+typedef struct __rl_callback_generic_arg
{
int count;
int i1, i2;
/* add here as needed */
} _rl_callback_generic_arg;
-typedef int _rl_callback_func_t PARAMS((_rl_callback_generic_arg *));
+typedef int _rl_callback_func_t (_rl_callback_generic_arg *);
-typedef void _rl_sigcleanup_func_t PARAMS((int, void *));
+typedef void _rl_sigcleanup_func_t (int, void *);
/*************************************************************************
* *
@@ -221,16 +221,16 @@ extern int rl_blink_matching_paren;
*************************************************************************/
/* kill.c */
-extern int rl_set_retained_kills PARAMS((int));
+extern int rl_set_retained_kills (int);
/* terminal.c */
-extern void _rl_set_screen_size PARAMS((int, int));
+extern void _rl_set_screen_size (int, int);
/* undo.c */
-extern int _rl_fix_last_undo_of_type PARAMS((int, int, int));
+extern int _rl_fix_last_undo_of_type (int, int, int);
/* util.c */
-extern char *_rl_savestring PARAMS((const char *));
+extern char *_rl_savestring (const char *);
/*************************************************************************
* *
@@ -250,66 +250,73 @@ extern char *_rl_savestring PARAMS((const char *));
#if defined(READLINE_CALLBACKS)
/* readline.c */
-extern void readline_internal_setup PARAMS((void));
-extern char *readline_internal_teardown PARAMS((int));
-extern int readline_internal_char PARAMS((void));
+extern void readline_internal_setup (void);
+extern char *readline_internal_teardown (int);
+extern int readline_internal_char (void);
-extern _rl_keyseq_cxt *_rl_keyseq_cxt_alloc PARAMS((void));
-extern void _rl_keyseq_cxt_dispose PARAMS((_rl_keyseq_cxt *));
-extern void _rl_keyseq_chain_dispose PARAMS((void));
+extern _rl_keyseq_cxt *_rl_keyseq_cxt_alloc (void);
+extern void _rl_keyseq_cxt_dispose (_rl_keyseq_cxt *);
+extern void _rl_keyseq_chain_dispose (void);
+
+extern int _rl_dispatch_callback (_rl_keyseq_cxt *);
-extern int _rl_dispatch_callback PARAMS((_rl_keyseq_cxt *));
-
/* callback.c */
-extern _rl_callback_generic_arg *_rl_callback_data_alloc PARAMS((int));
-extern void _rl_callback_data_dispose PARAMS((_rl_callback_generic_arg *));
+extern _rl_callback_generic_arg *_rl_callback_data_alloc (int);
+extern void _rl_callback_data_dispose (_rl_callback_generic_arg *);
#endif /* READLINE_CALLBACKS */
/* bind.c */
-extern char *_rl_untranslate_macro_value PARAMS((char *, int));
+extern char *_rl_untranslate_macro_value (char *, int);
/* complete.c */
-extern void _rl_reset_completion_state PARAMS((void));
-extern char _rl_find_completion_word PARAMS((int *, int *));
-extern void _rl_free_match_list PARAMS((char **));
+extern void _rl_reset_completion_state (void);
+extern char _rl_find_completion_word (int *, int *);
+extern void _rl_free_match_list (char **);
/* display.c */
-extern char *_rl_strip_prompt PARAMS((char *));
-extern void _rl_reset_prompt PARAMS((void));
-extern void _rl_move_vert PARAMS((int));
-extern void _rl_save_prompt PARAMS((void));
-extern void _rl_restore_prompt PARAMS((void));
-extern char *_rl_make_prompt_for_search PARAMS((int));
-extern void _rl_erase_at_end_of_line PARAMS((int));
-extern void _rl_clear_to_eol PARAMS((int));
-extern void _rl_clear_screen PARAMS((int));
-extern void _rl_update_final PARAMS((void));
-extern void _rl_optimize_redisplay PARAMS((void));
-extern void _rl_redisplay_after_sigwinch PARAMS((void));
-extern void _rl_clean_up_for_exit PARAMS((void));
-extern void _rl_erase_entire_line PARAMS((void));
-extern int _rl_current_display_line PARAMS((void));
-extern void _rl_refresh_line PARAMS((void));
+extern char *_rl_strip_prompt (char *);
+extern void _rl_reset_prompt (void);
+extern void _rl_move_vert (int);
+extern void _rl_save_prompt (void);
+extern void _rl_restore_prompt (void);
+extern char *_rl_make_prompt_for_search (int);
+extern void _rl_erase_at_end_of_line (int);
+extern void _rl_clear_to_eol (int);
+extern void _rl_clear_screen (int);
+extern void _rl_update_final (void);
+extern void _rl_optimize_redisplay (void);
+extern void _rl_redisplay_after_sigwinch (void);
+extern void _rl_clean_up_for_exit (void);
+extern void _rl_erase_entire_line (void);
+extern int _rl_current_display_line (void);
+extern void _rl_refresh_line (void);
/* input.c */
-extern int _rl_any_typein PARAMS((void));
-extern int _rl_input_available PARAMS((void));
-extern int _rl_nchars_available PARAMS((void));
-extern int _rl_input_queued PARAMS((int));
-extern void _rl_insert_typein PARAMS((int));
-extern int _rl_unget_char PARAMS((int));
-extern int _rl_pushed_input_available PARAMS((void));
+extern int _rl_any_typein (void);
+extern int _rl_input_available (void);
+extern int _rl_nchars_available (void);
+extern int _rl_input_queued (int);
+extern void _rl_insert_typein (int);
+extern int _rl_unget_char (int);
+extern int _rl_pushed_input_available (void);
+
+extern int _rl_timeout_init (void);
+extern int _rl_timeout_handle_sigalrm (void);
+#if defined (_POSIXSELECT_H_)
+/* use as a sentinel for fd_set, struct timeval, and sigset_t definitions */
+extern int _rl_timeout_select (int, fd_set *, fd_set *, fd_set *, const struct timeval *, const sigset_t *);
+#endif
/* isearch.c */
-extern _rl_search_cxt *_rl_scxt_alloc PARAMS((int, int));
-extern void _rl_scxt_dispose PARAMS((_rl_search_cxt *, int));
+extern _rl_search_cxt *_rl_scxt_alloc (int, int);
+extern void _rl_scxt_dispose (_rl_search_cxt *, int);
-extern int _rl_isearch_dispatch PARAMS((_rl_search_cxt *, int));
-extern int _rl_isearch_callback PARAMS((_rl_search_cxt *));
-extern int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, int));
+extern int _rl_isearch_dispatch (_rl_search_cxt *, int);
+extern int _rl_isearch_callback (_rl_search_cxt *);
+extern int _rl_isearch_cleanup (_rl_search_cxt *, int);
-extern int _rl_search_getchar PARAMS((_rl_search_cxt *));
+extern int _rl_search_getchar (_rl_search_cxt *);
/* kill.c */
#ifndef BRACKETED_PASTE_DEFAULT
@@ -325,110 +332,117 @@ extern int _rl_search_getchar PARAMS((_rl_search_cxt *));
#define BRACK_PASTE_INIT "\033[?2004h"
#define BRACK_PASTE_FINI "\033[?2004l\r"
-extern int _rl_read_bracketed_paste_prefix PARAMS((int));
-extern char *_rl_bracketed_text PARAMS((size_t *));
-extern int _rl_bracketed_read_key PARAMS((void));
-extern int _rl_bracketed_read_mbstring PARAMS((char *, int));
+extern int _rl_read_bracketed_paste_prefix (int);
+extern char *_rl_bracketed_text (size_t *);
+extern int _rl_bracketed_read_key (void);
+extern int _rl_bracketed_read_mbstring (char *, int);
/* macro.c */
-extern void _rl_with_macro_input PARAMS((char *));
-extern int _rl_peek_macro_key PARAMS((void));
-extern int _rl_next_macro_key PARAMS((void));
-extern int _rl_prev_macro_key PARAMS((void));
-extern void _rl_push_executing_macro PARAMS((void));
-extern void _rl_pop_executing_macro PARAMS((void));
-extern void _rl_add_macro_char PARAMS((int));
-extern void _rl_kill_kbd_macro PARAMS((void));
+extern void _rl_with_macro_input (char *);
+extern int _rl_peek_macro_key (void);
+extern int _rl_next_macro_key (void);
+extern int _rl_prev_macro_key (void);
+extern void _rl_push_executing_macro (void);
+extern void _rl_pop_executing_macro (void);
+extern void _rl_add_macro_char (int);
+extern void _rl_kill_kbd_macro (void);
/* misc.c */
-extern int _rl_arg_overflow PARAMS((void));
-extern void _rl_arg_init PARAMS((void));
-extern int _rl_arg_getchar PARAMS((void));
-extern int _rl_arg_callback PARAMS((_rl_arg_cxt));
-extern void _rl_reset_argument PARAMS((void));
+extern int _rl_arg_overflow (void);
+extern void _rl_arg_init (void);
+extern int _rl_arg_getchar (void);
+extern int _rl_arg_callback (_rl_arg_cxt);
+extern void _rl_reset_argument (void);
-extern void _rl_start_using_history PARAMS((void));
-extern int _rl_free_saved_history_line PARAMS((void));
-extern void _rl_set_insert_mode PARAMS((int, int));
+extern void _rl_start_using_history (void);
+extern int _rl_free_saved_history_line (void);
+extern void _rl_set_insert_mode (int, int);
-extern void _rl_revert_previous_lines PARAMS((void));
-extern void _rl_revert_all_lines PARAMS((void));
+extern void _rl_revert_previous_lines (void);
+extern void _rl_revert_all_lines (void);
/* nls.c */
-extern char *_rl_init_locale PARAMS((void));
-extern int _rl_init_eightbit PARAMS((void));
+extern char *_rl_init_locale (void);
+extern int _rl_init_eightbit (void);
+extern void _rl_reset_locale (void);
/* parens.c */
-extern void _rl_enable_paren_matching PARAMS((int));
+extern void _rl_enable_paren_matching (int);
/* readline.c */
-extern void _rl_init_line_state PARAMS((void));
-extern void _rl_set_the_line PARAMS((void));
-extern int _rl_dispatch PARAMS((int, Keymap));
-extern int _rl_dispatch_subseq PARAMS((int, Keymap, int));
-extern void _rl_internal_char_cleanup PARAMS((void));
+extern void _rl_init_line_state (void);
+extern void _rl_set_the_line (void);
+extern int _rl_dispatch (int, Keymap);
+extern int _rl_dispatch_subseq (int, Keymap, int);
+extern void _rl_internal_char_cleanup (void);
+
+extern void _rl_init_executing_keyseq (void);
+extern void _rl_term_executing_keyseq (void);
+extern void _rl_end_executing_keyseq (void);
+extern void _rl_add_executing_keyseq (int);
+extern void _rl_del_executing_keyseq (void);
-extern void _rl_init_executing_keyseq PARAMS((void));
-extern void _rl_term_executing_keyseq PARAMS((void));
-extern void _rl_end_executing_keyseq PARAMS((void));
-extern void _rl_add_executing_keyseq PARAMS((int));
+extern rl_command_func_t *_rl_executing_func;
/* rltty.c */
-extern int _rl_disable_tty_signals PARAMS((void));
-extern int _rl_restore_tty_signals PARAMS((void));
+extern int _rl_disable_tty_signals (void);
+extern int _rl_restore_tty_signals (void);
/* search.c */
-extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *));
-extern int _rl_nsearch_cleanup PARAMS((_rl_search_cxt *, int));
+extern int _rl_nsearch_callback (_rl_search_cxt *);
+extern int _rl_nsearch_cleanup (_rl_search_cxt *, int);
/* signals.c */
-extern void _rl_signal_handler PARAMS((int));
+extern void _rl_signal_handler (int);
-extern void _rl_block_sigint PARAMS((void));
-extern void _rl_release_sigint PARAMS((void));
-extern void _rl_block_sigwinch PARAMS((void));
-extern void _rl_release_sigwinch PARAMS((void));
+extern void _rl_block_sigint (void);
+extern void _rl_release_sigint (void);
+extern void _rl_block_sigwinch (void);
+extern void _rl_release_sigwinch (void);
/* terminal.c */
-extern void _rl_get_screen_size PARAMS((int, int));
-extern void _rl_sigwinch_resize_terminal PARAMS((void));
-extern int _rl_init_terminal_io PARAMS((const char *));
+extern void _rl_get_screen_size (int, int);
+extern void _rl_sigwinch_resize_terminal (void);
+extern int _rl_init_terminal_io (const char *);
#ifdef _MINIX
-extern void _rl_output_character_function PARAMS((int));
+extern void _rl_output_character_function (int);
#else
-extern int _rl_output_character_function PARAMS((int));
+extern int _rl_output_character_function (int);
#endif
-extern void _rl_cr PARAMS((void));
-extern void _rl_output_some_chars PARAMS((const char *, int));
-extern int _rl_backspace PARAMS((int));
-extern void _rl_enable_meta_key PARAMS((void));
-extern void _rl_disable_meta_key PARAMS((void));
-extern void _rl_control_keypad PARAMS((int));
-extern void _rl_set_cursor PARAMS((int, int));
-extern void _rl_standout_on PARAMS((void));
-extern void _rl_standout_off PARAMS((void));
+extern void _rl_cr (void);
+extern void _rl_output_some_chars (const char *, int);
+extern int _rl_backspace (int);
+extern void _rl_enable_meta_key (void);
+extern void _rl_disable_meta_key (void);
+extern void _rl_control_keypad (int);
+extern void _rl_set_cursor (int, int);
+extern void _rl_standout_on (void);
+extern void _rl_standout_off (void);
+extern int _rl_reset_region_color (int, const char *);
+extern void _rl_region_color_on (void);
+extern void _rl_region_color_off (void);
/* text.c */
-extern void _rl_fix_point PARAMS((int));
-extern void _rl_fix_mark PARAMS((void));
-extern int _rl_replace_text PARAMS((const char *, int, int));
-extern int _rl_forward_char_internal PARAMS((int));
-extern int _rl_backward_char_internal PARAMS((int));
-extern int _rl_insert_char PARAMS((int, int));
-extern int _rl_overwrite_char PARAMS((int, int));
-extern int _rl_overwrite_rubout PARAMS((int, int));
-extern int _rl_rubout_char PARAMS((int, int));
+extern void _rl_fix_point (int);
+extern void _rl_fix_mark (void);
+extern int _rl_replace_text (const char *, int, int);
+extern int _rl_forward_char_internal (int);
+extern int _rl_backward_char_internal (int);
+extern int _rl_insert_char (int, int);
+extern int _rl_overwrite_char (int, int);
+extern int _rl_overwrite_rubout (int, int);
+extern int _rl_rubout_char (int, int);
#if defined (HANDLE_MULTIBYTE)
-extern int _rl_char_search_internal PARAMS((int, int, char *, int));
+extern int _rl_char_search_internal (int, int, char *, int);
#else
-extern int _rl_char_search_internal PARAMS((int, int, int));
+extern int _rl_char_search_internal (int, int, int);
#endif
-extern int _rl_set_mark_at_pos PARAMS((int));
+extern int _rl_set_mark_at_pos (int);
/* undo.c */
-extern UNDO_LIST *_rl_copy_undo_entry PARAMS((UNDO_LIST *));
-extern UNDO_LIST *_rl_copy_undo_list PARAMS((UNDO_LIST *));
-extern void _rl_free_undo_list PARAMS((UNDO_LIST *));
+extern UNDO_LIST *_rl_copy_undo_entry (UNDO_LIST *);
+extern UNDO_LIST *_rl_copy_undo_list (UNDO_LIST *);
+extern void _rl_free_undo_list (UNDO_LIST *);
/* util.c */
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
@@ -440,31 +454,37 @@ extern void _rl_ttymsg ();
extern void _rl_errmsg ();
extern void _rl_trace ();
#endif
-extern void _rl_audit_tty PARAMS((char *));
-
-extern int _rl_tropen PARAMS((void));
-
-extern int _rl_abort_internal PARAMS((void));
-extern int _rl_null_function PARAMS((int, int));
-extern char *_rl_strindex PARAMS((const char *, const char *));
-extern int _rl_qsort_string_compare PARAMS((char **, char **));
-extern int (_rl_uppercase_p) PARAMS((int));
-extern int (_rl_lowercase_p) PARAMS((int));
-extern int (_rl_pure_alphabetic) PARAMS((int));
-extern int (_rl_digit_p) PARAMS((int));
-extern int (_rl_to_lower) PARAMS((int));
-extern int (_rl_to_upper) PARAMS((int));
-extern int (_rl_digit_value) PARAMS((int));
+extern void _rl_audit_tty (char *);
+
+extern int _rl_tropen (void);
+
+extern int _rl_abort_internal (void);
+extern int _rl_null_function (int, int);
+extern char *_rl_strindex (const char *, const char *);
+extern int _rl_qsort_string_compare (char **, char **);
+extern int (_rl_uppercase_p) (int);
+extern int (_rl_lowercase_p) (int);
+extern int (_rl_pure_alphabetic) (int);
+extern int (_rl_digit_p) (int);
+extern int (_rl_to_lower) (int);
+extern int (_rl_to_upper) (int);
+extern int (_rl_digit_value) (int);
/* vi_mode.c */
-extern void _rl_vi_initialize_line PARAMS((void));
-extern void _rl_vi_reset_last PARAMS((void));
-extern void _rl_vi_set_last PARAMS((int, int, int));
-extern int _rl_vi_textmod_command PARAMS((int));
-extern int _rl_vi_motion_command PARAMS((int));
-extern void _rl_vi_done_inserting PARAMS((void));
-extern int _rl_vi_domove_callback PARAMS((_rl_vimotion_cxt *));
-extern int _rl_vi_domove_motion_cleanup PARAMS((int, _rl_vimotion_cxt *));
+extern void _rl_vi_initialize_line (void);
+extern void _rl_vi_reset_last (void);
+extern void _rl_vi_set_last (int, int, int);
+extern int _rl_vi_textmod_command (int);
+extern int _rl_vi_motion_command (int);
+extern void _rl_vi_done_inserting (void);
+extern int _rl_vi_domove_callback (_rl_vimotion_cxt *);
+extern int _rl_vi_domove_motion_cleanup (int, _rl_vimotion_cxt *);
+
+/* Use HS_HISTORY_VERSION as the sentinel to see if we've included history.h
+ and so can use HIST_ENTRY */
+#if defined (HS_HISTORY_VERSION)
+extern void _rl_free_history_entry (HIST_ENTRY *);
+#endif
/*************************************************************************
* Undocumented private variables *
@@ -537,6 +557,8 @@ extern int _rl_echo_control_chars;
extern int _rl_show_mode_in_prompt;
extern int _rl_enable_bracketed_paste;
extern int _rl_enable_active_region;
+extern char *_rl_active_region_start_color;
+extern char *_rl_active_region_end_color;
extern char *_rl_comment_begin;
extern unsigned char _rl_parsing_conditionalized_out;
extern Keymap _rl_keymap;
@@ -544,7 +566,6 @@ extern FILE *_rl_in_stream;
extern FILE *_rl_out_stream;
extern int _rl_last_command_was_kill;
extern int _rl_eof_char;
-extern int _rl_eof_found;
extern procenv_t _rl_top_level;
extern _rl_keyseq_cxt *_rl_kscxt;
extern int _rl_keyseq_timeout;
@@ -555,6 +576,7 @@ extern rl_hook_func_t *_rl_internal_startup_hook;
/* search.c */
extern _rl_search_cxt *_rl_nscxt;
+extern int _rl_history_search_pos;
/* signals.c */
extern int volatile _rl_caught_signal;
@@ -602,4 +624,10 @@ extern int _rl_vi_last_command;
extern int _rl_vi_redoing;
extern _rl_vimotion_cxt *_rl_vimvcxt;
+/* Use HS_HISTORY_VERSION as the sentinel to see if we've included history.h
+ and so can use HIST_ENTRY */
+#if defined (HS_HISTORY_VERSION)
+extern HIST_ENTRY *_rl_saved_line_for_history;
+#endif
+
#endif /* _RL_PRIVATE_H_ */
diff --git a/lib/readline/rlshell.h b/lib/readline/rlshell.h
index 3e17d8bc..6055b144 100644
--- a/lib/readline/rlshell.h
+++ b/lib/readline/rlshell.h
@@ -1,6 +1,6 @@
/* rlshell.h -- utility functions normally provided by bash. */
-/* Copyright (C) 1999-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -24,10 +24,10 @@
#include "rlstdc.h"
-extern char *sh_single_quote PARAMS((char *));
-extern void sh_set_lines_and_columns PARAMS((int, int));
-extern char *sh_get_env_value PARAMS((const char *));
-extern char *sh_get_home_dir PARAMS((void));
-extern int sh_unset_nodelay_mode PARAMS((int));
+extern char *sh_single_quote (char *);
+extern void sh_set_lines_and_columns (int, int);
+extern char *sh_get_env_value (const char *);
+extern char *sh_get_home_dir (void);
+extern int sh_unset_nodelay_mode (int);
#endif /* _RL_SHELL_H_ */
diff --git a/lib/readline/rltty.c b/lib/readline/rltty.c
index d0cd5727..882a3d46 100644
--- a/lib/readline/rltty.c
+++ b/lib/readline/rltty.c
@@ -1,7 +1,7 @@
/* rltty.c -- functions to prepare and restore the terminal for readline's
use. */
-/* Copyright (C) 1992-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -52,7 +52,7 @@ extern int errno;
rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
-static void set_winsize PARAMS((int));
+static void set_winsize (int);
/* **************************************************************** */
/* */
@@ -119,15 +119,15 @@ struct bsdtty {
static TIOTYPE otio;
-static void save_tty_chars PARAMS((TIOTYPE *));
-static int _get_tty_settings PARAMS((int, TIOTYPE *));
-static int get_tty_settings PARAMS((int, TIOTYPE *));
-static int _set_tty_settings PARAMS((int, TIOTYPE *));
-static int set_tty_settings PARAMS((int, TIOTYPE *));
+static void save_tty_chars (TIOTYPE *);
+static int _get_tty_settings (int, TIOTYPE *);
+static int get_tty_settings (int, TIOTYPE *);
+static int _set_tty_settings (int, TIOTYPE *);
+static int set_tty_settings (int, TIOTYPE *);
-static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
+static void prepare_terminal_settings (int, TIOTYPE, TIOTYPE *);
-static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t *));
+static void set_special_char (Keymap, TIOTYPE *, int, rl_command_func_t *);
static void
save_tty_chars (TIOTYPE *tiop)
@@ -332,16 +332,16 @@ prepare_terminal_settings (int meta_flag, TIOTYPE oldtio, TIOTYPE *tiop)
static TIOTYPE otio;
-static void save_tty_chars PARAMS((TIOTYPE *));
-static int _get_tty_settings PARAMS((int, TIOTYPE *));
-static int get_tty_settings PARAMS((int, TIOTYPE *));
-static int _set_tty_settings PARAMS((int, TIOTYPE *));
-static int set_tty_settings PARAMS((int, TIOTYPE *));
+static void save_tty_chars (TIOTYPE *);
+static int _get_tty_settings (int, TIOTYPE *);
+static int get_tty_settings (int, TIOTYPE *);
+static int _set_tty_settings (int, TIOTYPE *);
+static int set_tty_settings (int, TIOTYPE *);
-static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
+static void prepare_terminal_settings (int, TIOTYPE, TIOTYPE *);
-static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t *));
-static void _rl_bind_tty_special_chars PARAMS((Keymap, TIOTYPE));
+static void set_special_char (Keymap, TIOTYPE *, int, rl_command_func_t *);
+static void _rl_bind_tty_special_chars (Keymap, TIOTYPE);
#if defined (FLUSHO)
# define OUTPUT_BEING_FLUSHED(tp) (tp->c_lflag & FLUSHO)
@@ -692,7 +692,11 @@ rl_deprep_terminal (void)
if (terminal_prepped & TPX_BRACKPASTE)
{
fprintf (rl_outstream, BRACK_PASTE_FINI);
- if (_rl_eof_found)
+ /* Since the last character in BRACK_PASTE_FINI is \r */
+ _rl_last_c_pos = 0;
+ if (rl_eof_found && (RL_ISSTATE (RL_STATE_TIMEOUT) == 0))
+ fprintf (rl_outstream, "\n");
+ else if (_rl_echoing_p == 0)
fprintf (rl_outstream, "\n");
}
diff --git a/lib/readline/rltypedefs.h b/lib/readline/rltypedefs.h
index f9f5cd3a..16365492 100644
--- a/lib/readline/rltypedefs.h
+++ b/lib/readline/rltypedefs.h
@@ -1,6 +1,6 @@
/* rltypedefs.h -- Type declarations for readline functions. */
-/* Copyright (C) 2000-2011 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -32,10 +32,10 @@ extern "C" {
# define _FUNCTION_DEF
#if defined(__GNUC__) || defined(__clang__)
-typedef int Function () __attribute__ ((deprecated));
-typedef void VFunction () __attribute__ ((deprecated));
-typedef char *CPFunction () __attribute__ ((deprecated));
-typedef char **CPPFunction () __attribute__ ((deprecated));
+typedef int Function () __attribute__((deprecated));
+typedef void VFunction () __attribute__((deprecated));
+typedef char *CPFunction () __attribute__((deprecated));
+typedef char **CPPFunction () __attribute__((deprecated));
#else
typedef int Function ();
typedef void VFunction ();
@@ -51,45 +51,45 @@ typedef char **CPPFunction ();
# define _RL_FUNCTION_TYPEDEF
/* Bindable functions */
-typedef int rl_command_func_t PARAMS((int, int));
+typedef int rl_command_func_t (int, int);
/* Typedefs for the completion system */
-typedef char *rl_compentry_func_t PARAMS((const char *, int));
-typedef char **rl_completion_func_t PARAMS((const char *, int, int));
+typedef char *rl_compentry_func_t (const char *, int);
+typedef char **rl_completion_func_t (const char *, int, int);
-typedef char *rl_quote_func_t PARAMS((char *, int, char *));
-typedef char *rl_dequote_func_t PARAMS((char *, int));
+typedef char *rl_quote_func_t (char *, int, char *);
+typedef char *rl_dequote_func_t (char *, int);
-typedef int rl_compignore_func_t PARAMS((char **));
+typedef int rl_compignore_func_t (char **);
-typedef void rl_compdisp_func_t PARAMS((char **, int, int));
+typedef void rl_compdisp_func_t (char **, int, int);
/* Type for input and pre-read hook functions like rl_event_hook */
-typedef int rl_hook_func_t PARAMS((void));
+typedef int rl_hook_func_t (void);
/* Input function type */
-typedef int rl_getc_func_t PARAMS((FILE *));
+typedef int rl_getc_func_t (FILE *);
/* Generic function that takes a character buffer (which could be the readline
line buffer) and an index into it (which could be rl_point) and returns
an int. */
-typedef int rl_linebuf_func_t PARAMS((char *, int));
+typedef int rl_linebuf_func_t (char *, int);
/* `Generic' function pointer typedefs */
-typedef int rl_intfunc_t PARAMS((int));
+typedef int rl_intfunc_t (int);
#define rl_ivoidfunc_t rl_hook_func_t
-typedef int rl_icpfunc_t PARAMS((char *));
-typedef int rl_icppfunc_t PARAMS((char **));
-
-typedef void rl_voidfunc_t PARAMS((void));
-typedef void rl_vintfunc_t PARAMS((int));
-typedef void rl_vcpfunc_t PARAMS((char *));
-typedef void rl_vcppfunc_t PARAMS((char **));
-
-typedef char *rl_cpvfunc_t PARAMS((void));
-typedef char *rl_cpifunc_t PARAMS((int));
-typedef char *rl_cpcpfunc_t PARAMS((char *));
-typedef char *rl_cpcppfunc_t PARAMS((char **));
+typedef int rl_icpfunc_t (char *);
+typedef int rl_icppfunc_t (char **);
+
+typedef void rl_voidfunc_t (void);
+typedef void rl_vintfunc_t (int);
+typedef void rl_vcpfunc_t (char *);
+typedef void rl_vcppfunc_t (char **);
+
+typedef char *rl_cpvfunc_t (void);
+typedef char *rl_cpifunc_t (int);
+typedef char *rl_cpcpfunc_t (char *);
+typedef char *rl_cpcppfunc_t (char **);
#endif /* _RL_FUNCTION_TYPEDEF */
diff --git a/lib/readline/search.c b/lib/readline/search.c
index 38a29361..eea23011 100644
--- a/lib/readline/search.c
+++ b/lib/readline/search.c
@@ -1,6 +1,6 @@
/* search.c - code for non-incremental searching in emacs and vi modes. */
-/* Copyright (C) 1992-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -55,33 +55,28 @@
_rl_search_cxt *_rl_nscxt = 0;
-extern HIST_ENTRY *_rl_saved_line_for_history;
-
-/* Functions imported from the rest of the library. */
-extern void _rl_free_history_entry PARAMS((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 int rl_history_search_flags;
+static int _rl_history_search_len;
+/*static*/ int _rl_history_search_pos;
+static int _rl_history_search_flags;
static char *history_search_string;
static int history_string_size;
-static void make_history_line_current PARAMS((HIST_ENTRY *));
-static int noninc_search_from_pos PARAMS((char *, int, int, int, int *));
-static int noninc_dosearch PARAMS((char *, int, int));
-static int noninc_search PARAMS((int, int));
-static int rl_history_search_internal PARAMS((int, int));
-static void rl_history_search_reinit PARAMS((int));
+static void make_history_line_current (HIST_ENTRY *);
+static int noninc_search_from_pos (char *, int, int, int, int *);
+static int noninc_dosearch (char *, int, int);
+static int noninc_search (int, int);
+static int rl_history_search_internal (int, int);
+static void rl_history_search_reinit (int);
-static _rl_search_cxt *_rl_nsearch_init PARAMS((int, int));
-static void _rl_nsearch_abort PARAMS((_rl_search_cxt *));
-static int _rl_nsearch_dispatch PARAMS((_rl_search_cxt *, int));
+static _rl_search_cxt *_rl_nsearch_init (int, int);
+static void _rl_nsearch_abort (_rl_search_cxt *);
+static int _rl_nsearch_dispatch (_rl_search_cxt *, int);
/* 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
@@ -89,6 +84,15 @@ static int _rl_nsearch_dispatch PARAMS((_rl_search_cxt *, int));
static void
make_history_line_current (HIST_ENTRY *entry)
{
+ UNDO_LIST *xlist;
+
+ xlist = _rl_saved_line_for_history ? (UNDO_LIST *)_rl_saved_line_for_history->data : 0;
+ /* At this point, rl_undo_list points to a private search string list. */
+ if (rl_undo_list && rl_undo_list != (UNDO_LIST *)entry->data && rl_undo_list != xlist)
+ rl_free_undo_list ();
+
+ /* Now we create a new undo list with a single insert for this text.
+ WE DON'T CHANGE THE ORIGINAL HISTORY ENTRY UNDO LIST */
_rl_replace_text (entry->line, 0, rl_end);
_rl_fix_point (1);
#if defined (VI_MODE)
@@ -100,6 +104,11 @@ make_history_line_current (HIST_ENTRY *entry)
rl_free_undo_list ();
#endif
+ /* This will need to free the saved undo list associated with the original
+ (pre-search) line buffer.
+ XXX - look at _rl_free_saved_history_line and consider calling it if
+ rl_undo_list != xlist (or calling rl_free_undo list directly on
+ _rl_saved_line_for_history->data) */
if (_rl_saved_line_for_history)
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
@@ -264,11 +273,11 @@ static void
_rl_nsearch_abort (_rl_search_cxt *cxt)
{
rl_maybe_unsave_line ();
- rl_clear_message ();
rl_point = cxt->save_point;
rl_mark = cxt->save_mark;
- _rl_fix_point (1);
rl_restore_prompt ();
+ rl_clear_message ();
+ _rl_fix_point (1);
RL_UNSETSTATE (RL_STATE_NSEARCH);
}
@@ -521,8 +530,10 @@ rl_history_search_internal (int count, int dir)
{
HIST_ENTRY *temp;
int ret, oldpos, newcol;
+ int had_saved_line;
char *t;
+ had_saved_line = _rl_saved_line_for_history != 0;
rl_maybe_save_line ();
temp = (HIST_ENTRY *)NULL;
@@ -534,14 +545,14 @@ rl_history_search_internal (int count, int dir)
while (count)
{
RL_CHECK_SIGNALS ();
- ret = noninc_search_from_pos (history_search_string, rl_history_search_pos + dir, dir, 0, &newcol);
+ ret = noninc_search_from_pos (history_search_string, _rl_history_search_pos + dir, dir, 0, &newcol);
if (ret == -1)
break;
/* Get the history entry we found. */
- rl_history_search_pos = ret;
+ _rl_history_search_pos = ret;
oldpos = where_history ();
- history_set_pos (rl_history_search_pos);
+ history_set_pos (_rl_history_search_pos);
temp = current_history (); /* will never be NULL after successful search */
history_set_pos (oldpos);
@@ -555,20 +566,21 @@ rl_history_search_internal (int count, int dir)
/* If we didn't find anything at all, return. */
if (temp == 0)
{
+ /* XXX - check had_saved_line here? */
rl_maybe_unsave_line ();
rl_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)
+ if (rl_point > _rl_history_search_len)
{
- rl_point = rl_end = rl_history_search_len;
+ rl_point = rl_end = _rl_history_search_len;
rl_line_buffer[rl_end] = '\0';
rl_mark = 0;
}
#else
- rl_point = rl_history_search_len; /* rl_maybe_unsave_line changes it */
+ rl_point = _rl_history_search_len; /* rl_maybe_unsave_line changes it */
rl_mark = rl_end;
#endif
return 1;
@@ -578,13 +590,13 @@ rl_history_search_internal (int count, int dir)
make_history_line_current (temp);
/* decide where to put rl_point -- need to change this for pattern search */
- if (rl_history_search_flags & ANCHORED_SEARCH)
- rl_point = rl_history_search_len; /* easy case */
+ if (_rl_history_search_flags & ANCHORED_SEARCH)
+ rl_point = _rl_history_search_len; /* easy case */
else
{
#if 0
t = strstr (rl_line_buffer, history_search_string); /* XXX */
- rl_point = t ? (int)(t - rl_line_buffer) + rl_history_search_len : rl_end;
+ rl_point = t ? (int)(t - rl_line_buffer) + _rl_history_search_len : rl_end;
#else
rl_point = (newcol >= 0) ? newcol : rl_end;
#endif
@@ -599,17 +611,17 @@ rl_history_search_reinit (int flags)
{
int sind;
- rl_history_search_pos = where_history ();
- rl_history_search_len = rl_point;
- rl_history_search_flags = flags;
+ _rl_history_search_pos = where_history ();
+ _rl_history_search_len = rl_point;
+ _rl_history_search_flags = flags;
prev_line_found = (char *)NULL;
if (rl_point)
{
/* Allocate enough space for anchored and non-anchored searches */
- if (rl_history_search_len >= history_string_size - 2)
+ if (_rl_history_search_len >= history_string_size - 2)
{
- history_string_size = rl_history_search_len + 2;
+ history_string_size = _rl_history_search_len + 2;
history_search_string = (char *)xrealloc (history_search_string, history_string_size);
}
sind = 0;
@@ -618,7 +630,7 @@ rl_history_search_reinit (int flags)
strncpy (history_search_string + sind, rl_line_buffer, rl_point);
history_search_string[rl_point + sind] = '\0';
}
- _rl_free_saved_history_line ();
+ _rl_free_saved_history_line (); /* XXX rl_undo_list? */
}
/* Search forward in the history for the string of characters
@@ -634,7 +646,7 @@ rl_history_search_forward (int count, int ignore)
rl_last_func != rl_history_search_backward)
rl_history_search_reinit (ANCHORED_SEARCH);
- if (rl_history_search_len == 0)
+ if (_rl_history_search_len == 0)
return (rl_get_next_history (count, ignore));
return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
}
@@ -652,7 +664,7 @@ rl_history_search_backward (int count, int ignore)
rl_last_func != rl_history_search_backward)
rl_history_search_reinit (ANCHORED_SEARCH);
- if (rl_history_search_len == 0)
+ if (_rl_history_search_len == 0)
return (rl_get_previous_history (count, ignore));
return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1));
}
@@ -671,7 +683,7 @@ rl_history_substr_search_forward (int count, int ignore)
rl_last_func != rl_history_substr_search_backward)
rl_history_search_reinit (NON_ANCHORED_SEARCH);
- if (rl_history_search_len == 0)
+ if (_rl_history_search_len == 0)
return (rl_get_next_history (count, ignore));
return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
}
@@ -689,7 +701,7 @@ rl_history_substr_search_backward (int count, int ignore)
rl_last_func != rl_history_substr_search_backward)
rl_history_search_reinit (NON_ANCHORED_SEARCH);
- if (rl_history_search_len == 0)
+ 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 7fe2e97c..36c91484 100644
--- a/lib/readline/shell.c
+++ b/lib/readline/shell.c
@@ -1,7 +1,7 @@
/* shell.c -- readline utility functions that are normally provided by
bash when readline is linked as part of the shell. */
-/* Copyright (C) 1997-2009,2017 Free Software Foundation, Inc.
+/* Copyright (C) 1997-2009,2017,2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -64,7 +64,7 @@
#include "xmalloc.h"
#if defined (HAVE_GETPWUID) && !defined (HAVE_GETPW_DECLS)
-extern struct passwd *getpwuid PARAMS((uid_t));
+extern struct passwd *getpwuid (uid_t);
#endif /* HAVE_GETPWUID && !HAVE_GETPW_DECLS */
#ifndef NULL
diff --git a/lib/readline/signals.c b/lib/readline/signals.c
index f9174ab8..9df365e4 100644
--- a/lib/readline/signals.c
+++ b/lib/readline/signals.c
@@ -1,6 +1,6 @@
/* signals.c -- signal handling support for readline. */
-/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -48,23 +48,11 @@
#if defined (HANDLE_SIGNALS)
-#if !defined (RETSIGTYPE)
-# if defined (VOID_SIGHANDLER)
-# define RETSIGTYPE void
-# else
-# define RETSIGTYPE int
-# endif /* !VOID_SIGHANDLER */
-#endif /* !RETSIGTYPE */
-
-#if defined (VOID_SIGHANDLER)
-# define SIGHANDLER_RETURN return
-#else
-# define SIGHANDLER_RETURN return (0)
-#endif
+#define SIGHANDLER_RETURN return
/* This typedef is equivalent to the one for Function; it allows us
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
-typedef RETSIGTYPE SigHandler ();
+typedef void SigHandler (int);
#if defined (HAVE_POSIX_SIGNALS)
typedef struct sigaction sighandler_cxt;
@@ -78,12 +66,12 @@ typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt
# define SA_RESTART 0
#endif
-static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
-static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
-static void rl_maybe_restore_sighandler PARAMS((int, sighandler_cxt *));
+static SigHandler *rl_set_sighandler (int, SigHandler *, sighandler_cxt *);
+static void rl_maybe_set_sighandler (int, SigHandler *, sighandler_cxt *);
+static void rl_maybe_restore_sighandler (int, sighandler_cxt *);
-static RETSIGTYPE rl_signal_handler PARAMS((int));
-static RETSIGTYPE _rl_handle_signal PARAMS((int));
+static void rl_signal_handler (int);
+static void _rl_handle_signal (int);
/* Exported variables for use by applications. */
@@ -136,7 +124,7 @@ void *_rl_sigcleanarg;
/* Readline signal handler functions. */
/* Called from RL_CHECK_SIGNALS() macro to run signal handling code. */
-RETSIGTYPE
+void
_rl_signal_handler (int sig)
{
_rl_caught_signal = 0; /* XXX */
@@ -163,7 +151,7 @@ _rl_signal_handler (int sig)
SIGHANDLER_RETURN;
}
-static RETSIGTYPE
+static void
rl_signal_handler (int sig)
{
_rl_caught_signal = sig;
@@ -173,7 +161,7 @@ rl_signal_handler (int sig)
/* This is called to handle a signal when it is safe to do so (out of the
signal handler execution path). Called by _rl_signal_handler for all the
signals readline catches except SIGWINCH. */
-static RETSIGTYPE
+static void
_rl_handle_signal (int sig)
{
int block_sig;
@@ -222,6 +210,9 @@ _rl_handle_signal (int sig)
switch (sig)
{
case SIGINT:
+ /* We will end up blocking SIGTTOU while we are resetting the tty, so
+ watch out for this if it causes problems. We could prevent this by
+ setting block_sig to 1 without modifying SET. */
_rl_reset_completion_state ();
rl_free_line_state ();
#if defined (READLINE_CALLBACKS)
@@ -242,8 +233,11 @@ _rl_handle_signal (int sig)
this even if we've been stopped on SIGTTOU, since we handle signals
when we have returned from the signal handler and the signal is no
longer blocked. */
- sigaddset (&set, SIGTTOU);
- block_sig = 1;
+ if (block_sig == 0)
+ {
+ sigaddset (&set, SIGTTOU);
+ block_sig = 1;
+ }
# endif
#endif /* SIGTSTP */
/* Any signals that should be blocked during cleanup should go here. */
@@ -261,13 +255,17 @@ _rl_handle_signal (int sig)
case SIGTERM:
#if defined (SIGALRM)
case SIGALRM:
+ if (sig == SIGALRM)
+ _rl_timeout_handle_sigalrm ();
#endif
#if defined (SIGQUIT)
case SIGQUIT:
#endif
+#if defined (HAVE_POSIX_SIGNALS)
if (block_sig)
sigprocmask (SIG_BLOCK, &set, &oset);
+#endif
rl_echo_signal_char (sig);
rl_cleanup_after_signal ();
@@ -283,19 +281,6 @@ _rl_handle_signal (int sig)
/* We don't have to bother unblocking the signal because we are not
running in a signal handler context. */
-#if 0
-#if defined (HAVE_POSIX_SIGNALS)
- /* Make sure this signal is not blocked when we resend it to the
- calling application. */
- sigemptyset (&set);
- sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
- sigdelset (&set, sig);
-#else /* !HAVE_POSIX_SIGNALS */
-# if defined (HAVE_BSD_SIGNALS)
- omask = sigblock (0);
-# endif /* HAVE_BSD_SIGNALS */
-#endif /* !HAVE_POSIX_SIGNALS */
-#endif
#if defined (__EMX__)
signal (sig, SIG_ACK);
@@ -309,16 +294,6 @@ _rl_handle_signal (int sig)
/* We don't need to modify the signal mask now that this is not run in
a signal handler context. */
-#if 0
- /* Let the signal that we just sent through if it is blocked. */
-#if defined (HAVE_POSIX_SIGNALS)
- sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL);
-#else /* !HAVE_POSIX_SIGNALS */
-# if defined (HAVE_BSD_SIGNALS)
- sigsetmask (omask & ~(sigmask (sig)));
-# endif /* HAVE_BSD_SIGNALS */
-#endif /* !HAVE_POSIX_SIGNALS */
-#endif
rl_reset_after_signal ();
}
@@ -328,7 +303,7 @@ _rl_handle_signal (int sig)
}
#if defined (SIGWINCH)
-static RETSIGTYPE
+static void
rl_sigwinch_handler (int sig)
{
SigHandler *oh;
diff --git a/lib/readline/terminal.c b/lib/readline/terminal.c
index 05415dc4..9997161f 100644
--- a/lib/readline/terminal.c
+++ b/lib/readline/terminal.c
@@ -1,6 +1,6 @@
/* terminal.c -- controlling the terminal with termcap. */
-/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -73,11 +73,11 @@
# include <windows.h>
# include <wincon.h>
-static void _win_get_screensize PARAMS((int *, int *));
+static void _win_get_screensize (int *, int *);
#endif
#if defined (__EMX__)
-static void _emx_get_screensize PARAMS((int *, int *));
+static void _emx_get_screensize (int *, int *);
#endif
/* If the calling application sets this to a non-zero value, readline will
@@ -177,10 +177,19 @@ static char *_rl_term_kD;
/* Insert key */
static char *_rl_term_kI;
+/* Page up and page down keys */
+static char *_rl_term_kP;
+static char *_rl_term_kN;
+
/* Cursor control */
static char *_rl_term_vs; /* very visible */
static char *_rl_term_ve; /* normal */
+/* User-settable color sequences to begin and end the active region. Defaults
+ are rl_term_so and rl_term_se on non-dumb terminals. */
+char *_rl_active_region_start_color = NULL;
+char *_rl_active_region_end_color = NULL;
+
/* It's not clear how HPUX is so broken here. */
#ifdef TGETENT_BROKEN
# define TGETENT_SUCCESS 0
@@ -194,7 +203,7 @@ static char *_rl_term_ve; /* normal */
#endif
#define TGETFLAG(cap) (tgetflag (cap) == TGETFLAG_SUCCESS)
-static void bind_termcap_arrow_keys PARAMS((Keymap));
+static void bind_termcap_arrow_keys (Keymap);
/* Variables that hold the screen dimensions, used by the display code. */
int _rl_screenwidth, _rl_screenheight, _rl_screenchars;
@@ -382,8 +391,12 @@ _rl_sigwinch_resize_terminal (void)
void
rl_resize_terminal (void)
{
+ int width, height;
+
+ width = _rl_screenwidth;
+ height = _rl_screenheight;
_rl_get_screen_size (fileno (rl_instream), 1);
- if (_rl_echoing_p)
+ if (_rl_echoing_p && (width != _rl_screenwidth || height != _rl_screenheight))
{
if (CUSTOM_REDISPLAY_FUNC ())
rl_forced_update_display ();
@@ -415,6 +428,8 @@ static const struct _tc_string tc_strings[] =
{ "kD", &_rl_term_kD }, /* delete */
{ "kH", &_rl_term_kH }, /* home down ?? */
{ "kI", &_rl_term_kI }, /* insert */
+ { "kN", &_rl_term_kN }, /* page down */
+ { "kP", &_rl_term_kP }, /* page up */
{ "kd", &_rl_term_kd },
{ "ke", &_rl_term_ke }, /* end keypad mode */
{ "kh", &_rl_term_kh }, /* home */
@@ -456,7 +471,7 @@ _rl_init_terminal_io (const char *terminal_name)
{
const char *term;
char *buffer;
- int tty, tgetent_ret, dumbterm;
+ int tty, tgetent_ret, dumbterm, reset_region_colors;
term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
_rl_term_clrpag = _rl_term_cr = _rl_term_clreol = _rl_term_clrscroll = (char *)NULL;
@@ -467,6 +482,8 @@ _rl_init_terminal_io (const char *terminal_name)
dumbterm = STREQ (term, "dumb");
+ reset_region_colors = 1;
+
#ifdef __MSDOS__
_rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
_rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
@@ -478,6 +495,7 @@ _rl_init_terminal_io (const char *terminal_name)
_rl_term_goto = _rl_term_pc = _rl_term_ip = (char *)NULL;
_rl_term_ks = _rl_term_ke =_rl_term_vs = _rl_term_ve = (char *)NULL;
_rl_term_kh = _rl_term_kH = _rl_term_at7 = _rl_term_kI = (char *)NULL;
+ _rl_term_kN = _rl_term_kP = (char *)NULL;
_rl_term_so = _rl_term_se = (char *)NULL;
#if defined(HACK_TERMCAP_MOTION)
_rl_term_forward_char = (char *)NULL;
@@ -540,6 +558,7 @@ _rl_init_terminal_io (const char *terminal_name)
_rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
_rl_term_kh = _rl_term_kH = _rl_term_kI = _rl_term_kD = (char *)NULL;
_rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL;
+ _rl_term_kN = _rl_term_kP = (char *)NULL;
_rl_term_mm = _rl_term_mo = (char *)NULL;
_rl_term_ve = _rl_term_vs = (char *)NULL;
_rl_term_forward_char = (char *)NULL;
@@ -550,6 +569,11 @@ _rl_init_terminal_io (const char *terminal_name)
escape sequences */
_rl_enable_bracketed_paste = 0;
+ /* No terminal so/se capabilities. */
+ _rl_enable_active_region = 0;
+ _rl_reset_region_color (0, NULL);
+ _rl_reset_region_color (1, NULL);
+
/* Reasonable defaults for tgoto(). Readline currently only uses
tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
change that later... */
@@ -604,8 +628,14 @@ _rl_init_terminal_io (const char *terminal_name)
/* There's no way to determine whether or not a given terminal supports
bracketed paste mode, so we assume a terminal named "dumb" does not. */
if (dumbterm)
- _rl_enable_bracketed_paste = 0;
-
+ _rl_enable_bracketed_paste = _rl_enable_active_region = 0;
+
+ if (reset_region_colors)
+ {
+ _rl_reset_region_color (0, _rl_term_so);
+ _rl_reset_region_color (1, _rl_term_se);
+ }
+
return 0;
}
@@ -629,6 +659,9 @@ bind_termcap_arrow_keys (Keymap map)
rl_bind_keyseq_if_unbound (_rl_term_kD, rl_delete);
rl_bind_keyseq_if_unbound (_rl_term_kI, rl_overwrite_mode); /* Insert */
+ rl_bind_keyseq_if_unbound (_rl_term_kN, rl_history_search_forward); /* Page Down */
+ rl_bind_keyseq_if_unbound (_rl_term_kP, rl_history_search_backward); /* Page Up */
+
_rl_keymap = xkeymap;
}
@@ -776,6 +809,67 @@ _rl_standout_off (void)
/* **************************************************************** */
/* */
+/* Controlling color for a portion of the line */
+/* */
+/* **************************************************************** */
+
+/* Reset the region color variables to VALUE depending on WHICH (0 == start,
+ 1 == end). This is where all the memory allocation for the color variable
+ strings is performed. We might want to pass a flag saying whether or not
+ to translate VALUE like a key sequence, but it doesn't really matter. */
+int
+_rl_reset_region_color (int which, const char *value)
+{
+ int len;
+
+ if (which == 0)
+ {
+ xfree (_rl_active_region_start_color);
+ if (value && *value)
+ {
+ _rl_active_region_start_color = (char *)xmalloc (2 * strlen (value) + 1);
+ rl_translate_keyseq (value, _rl_active_region_start_color, &len);
+ _rl_active_region_start_color[len] = '\0';
+ }
+ else
+ _rl_active_region_start_color = NULL;
+ }
+ else
+ {
+ xfree (_rl_active_region_end_color);
+ if (value && *value)
+ {
+ _rl_active_region_end_color = (char *)xmalloc (2 * strlen (value) + 1);
+ rl_translate_keyseq (value, _rl_active_region_end_color, &len);
+ _rl_active_region_end_color[len] = '\0';
+ }
+ else
+ _rl_active_region_end_color = NULL;
+ }
+
+ return 0;
+}
+
+void
+_rl_region_color_on (void)
+{
+#ifndef __MSDOS__
+ if (_rl_active_region_start_color && _rl_active_region_end_color)
+ tputs (_rl_active_region_start_color, 1, _rl_output_character_function);
+#endif
+}
+
+void
+_rl_region_color_off (void)
+{
+#ifndef __MSDOS__
+ if (_rl_active_region_start_color && _rl_active_region_end_color)
+ tputs (_rl_active_region_end_color, 1, _rl_output_character_function);
+#endif
+}
+
+/* **************************************************************** */
+/* */
/* Controlling the Meta Key and Keypad */
/* */
/* **************************************************************** */
diff --git a/lib/readline/text.c b/lib/readline/text.c
index 2567dea2..91c3f330 100644
--- a/lib/readline/text.c
+++ b/lib/readline/text.c
@@ -1,6 +1,6 @@
/* text.c -- text handling commands for readline. */
-/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -59,12 +59,12 @@
#include "xmalloc.h"
/* Forward declarations. */
-static int rl_change_case PARAMS((int, int));
-static int _rl_char_search PARAMS((int, int, int));
+static int rl_change_case (int, int);
+static int _rl_char_search (int, int, int);
#if defined (READLINE_CALLBACKS)
-static int _rl_insert_next_callback PARAMS((_rl_callback_generic_arg *));
-static int _rl_char_search_callback PARAMS((_rl_callback_generic_arg *));
+static int _rl_insert_next_callback (_rl_callback_generic_arg *);
+static int _rl_char_search_callback (_rl_callback_generic_arg *);
#endif
/* The largest chunk of text that can be inserted in one call to
@@ -96,6 +96,7 @@ rl_insert_text (const char *string)
for (i = rl_end; i >= rl_point; i--)
rl_line_buffer[i + l] = rl_line_buffer[i];
+
strncpy (rl_line_buffer + rl_point, string, l);
/* Remember how to undo this if we aren't undoing something. */
@@ -735,7 +736,7 @@ _rl_insert_char (int count, int c)
}
else
{
- wchar_t wc;
+ WCHAR_T wc;
size_t ret;
if (stored_count <= 0)
@@ -745,7 +746,7 @@ _rl_insert_char (int count, int c)
ps_back = ps;
pending_bytes[pending_bytes_length++] = c;
- ret = mbrtowc (&wc, pending_bytes, pending_bytes_length, &ps);
+ ret = MBRTOWC (&wc, pending_bytes, pending_bytes_length, &ps);
if (ret == (size_t)-2)
{
@@ -919,8 +920,11 @@ _rl_overwrite_char (int count, int c)
int k;
/* Read an entire multibyte character sequence to insert COUNT times. */
+ k = 1;
if (count > 0 && MB_CUR_MAX > 1 && rl_byte_oriented == 0)
k = _rl_read_mbstring (c, mbkey, MB_LEN_MAX);
+ if (k < 0)
+ return 1;
#endif
rl_begin_undo_group ();
@@ -1132,7 +1136,7 @@ rl_newline (int count, int key)
int
rl_do_lowercase_version (int ignore1, int ignore2)
{
- return 0;
+ return 99999; /* prevent from being combined with _rl_null_function */
}
/* This is different from what vi does, so the code's not shared. Emacs
@@ -1401,9 +1405,9 @@ rl_change_case (int count, int op)
{
int start, next, end;
int inword, nc, nop;
- wchar_t c;
+ WCHAR_T c;
#if defined (HANDLE_MULTIBYTE)
- wchar_t wc, nwc;
+ WCHAR_T wc, nwc;
char mb[MB_LEN_MAX+1];
int mlen;
size_t m;
@@ -1462,9 +1466,9 @@ rl_change_case (int count, int op)
#if defined (HANDLE_MULTIBYTE)
else
{
- m = mbrtowc (&wc, rl_line_buffer + start, end - start, &mps);
+ m = MBRTOWC (&wc, rl_line_buffer + start, end - start, &mps);
if (MB_INVALIDCH (m))
- wc = (wchar_t)rl_line_buffer[start];
+ wc = (WCHAR_T)rl_line_buffer[start];
else if (MB_NULLWCH (m))
wc = L'\0';
nwc = (nop == UpCase) ? _rl_to_wupper (wc) : _rl_to_wlower (wc);
@@ -1474,12 +1478,12 @@ rl_change_case (int count, int op)
mbstate_t ts;
memset (&ts, 0, sizeof (mbstate_t));
- mlen = wcrtomb (mb, nwc, &ts);
+ mlen = WCRTOMB (mb, nwc, &ts);
if (mlen < 0)
{
nwc = wc;
memset (&ts, 0, sizeof (mbstate_t));
- mlen = wcrtomb (mb, nwc, &ts);
+ mlen = WCRTOMB (mb, nwc, &ts);
if (mlen < 0) /* should not happen */
strncpy (mb, rl_line_buffer + start, mlen = m);
}
@@ -1536,7 +1540,10 @@ rl_transpose_words (int count, int key)
{
char *word1, *word2;
int w1_beg, w1_end, w2_beg, w2_end;
- int orig_point = rl_point;
+ int orig_point, orig_end;
+
+ orig_point = rl_point;
+ orig_end = rl_end;
if (!count)
return 0;
@@ -1580,6 +1587,7 @@ rl_transpose_words (int count, int key)
/* This is exactly correct since the text before this point has not
changed in length. */
rl_point = w2_end;
+ rl_end = orig_end; /* just make sure */
/* I think that does it. */
rl_end_undo_group ();
diff --git a/lib/readline/tilde.h b/lib/readline/tilde.h
index e26dd047..bc8022af 100644
--- a/lib/readline/tilde.h
+++ b/lib/readline/tilde.h
@@ -1,6 +1,6 @@
/* tilde.h: Externally available variables and function in libtilde.a. */
-/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2009,2021 Free Software Foundation, Inc.
This file contains the Readline Library (Readline), a set of
routines for providing Emacs style line input to programs that ask
@@ -27,19 +27,7 @@
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 PARAMS((char *, char *, int)); */
-
-#if !defined (PARAMS)
-# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
-# define PARAMS(protos) protos
-# else
-# define PARAMS(protos) ()
-# endif
-#endif
-
-typedef char *tilde_hook_func_t PARAMS((char *));
+typedef char *tilde_hook_func_t (char *);
/* If non-null, this contains the address of a function that the application
wants called before trying the standard tilde expansions. The function
@@ -64,14 +52,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 PARAMS((const char *));
+extern char *tilde_expand (const 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 PARAMS((const char *));
+extern char *tilde_expand_word (const char *);
/* Find the portion of the string beginning with ~ that should be expanded. */
-extern char *tilde_find_word PARAMS((const char *, int, int *));
+extern char *tilde_find_word (const char *, int, int *);
#ifdef __cplusplus
}
diff --git a/lib/readline/undo.c b/lib/readline/undo.c
index 14799911..e4c457dc 100644
--- a/lib/readline/undo.c
+++ b/lib/readline/undo.c
@@ -1,6 +1,6 @@
/* undo.c - manage list of changes to lines, offering opportunity to undo them */
-/* Copyright (C) 1987-2017 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -49,9 +49,7 @@
#include "rlprivate.h"
#include "xmalloc.h"
-extern void _hs_replace_history_data PARAMS((int, histdata_t *, histdata_t *));
-
-extern HIST_ENTRY *_rl_saved_line_for_history;
+#include "histlib.h"
/* Non-zero tells rl_delete_text and rl_insert_text to not add to
the undo list. */
diff --git a/lib/readline/util.c b/lib/readline/util.c
index 1576b55d..2e986db0 100644
--- a/lib/readline/util.c
+++ b/lib/readline/util.c
@@ -72,7 +72,7 @@ static const char * const pathname_alphabetic_chars = "/-_=~.#$";
int
rl_alphabetic (int c)
{
- if (ALPHABETIC (c))
+ if (_rl_alphabetic_p (c))
return (1);
return (_rl_allow_pathname_alphabetic_chars &&
@@ -81,7 +81,7 @@ rl_alphabetic (int c)
#if defined (HANDLE_MULTIBYTE)
int
-_rl_walphabetic (wchar_t wc)
+_rl_walphabetic (WCHAR_T wc)
{
int c;
@@ -98,7 +98,8 @@ _rl_walphabetic (wchar_t wc)
int
_rl_abort_internal (void)
{
- rl_ding ();
+ if (RL_ISSTATE (RL_STATE_TIMEOUT) == 0)
+ rl_ding (); /* Don't ring the bell on a timeout */
rl_clear_message ();
_rl_reset_argument ();
rl_clear_pending_input ();
diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c
index 742341e3..3a033bab 100644
--- a/lib/readline/vi_mode.c
+++ b/lib/readline/vi_mode.c
@@ -1,7 +1,7 @@
/* vi_mode.c -- A vi emulation mode for Bash.
Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
-/* Copyright (C) 1987-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -124,44 +124,44 @@ static const char * const vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
/* Arrays for the saved marks. */
static int vi_mark_chars['z' - 'a' + 1];
-static void _rl_vi_replace_insert PARAMS((int));
-static void _rl_vi_save_replace PARAMS((void));
-static void _rl_vi_stuff_insert PARAMS((int));
-static void _rl_vi_save_insert PARAMS((UNDO_LIST *));
+static void _rl_vi_replace_insert (int);
+static void _rl_vi_save_replace (void);
+static void _rl_vi_stuff_insert (int);
+static void _rl_vi_save_insert (UNDO_LIST *);
-static void vi_save_insert_buffer PARAMS ((int, int));
+static void vi_save_insert_buffer (int, int);
-static inline void _rl_vi_backup PARAMS((void));
+static inline void _rl_vi_backup (void);
-static int _rl_vi_arg_dispatch PARAMS((int));
-static int rl_digit_loop1 PARAMS((void));
+static int _rl_vi_arg_dispatch (int);
+static int rl_digit_loop1 (void);
-static int _rl_vi_set_mark PARAMS((void));
-static int _rl_vi_goto_mark PARAMS((void));
+static int _rl_vi_set_mark (void);
+static int _rl_vi_goto_mark (void);
-static inline int _rl_vi_advance_point PARAMS((void));
-static inline int _rl_vi_backup_point PARAMS((void));
+static inline int _rl_vi_advance_point (void);
+static inline int _rl_vi_backup_point (void);
-static void _rl_vi_append_forward PARAMS((int));
+static void _rl_vi_append_forward (int);
-static int _rl_vi_callback_getchar PARAMS((char *, int));
+static int _rl_vi_callback_getchar (char *, int);
#if defined (READLINE_CALLBACKS)
-static int _rl_vi_callback_set_mark PARAMS((_rl_callback_generic_arg *));
-static int _rl_vi_callback_goto_mark PARAMS((_rl_callback_generic_arg *));
-static int _rl_vi_callback_change_char PARAMS((_rl_callback_generic_arg *));
-static int _rl_vi_callback_char_search PARAMS((_rl_callback_generic_arg *));
+static int _rl_vi_callback_set_mark (_rl_callback_generic_arg *);
+static int _rl_vi_callback_goto_mark (_rl_callback_generic_arg *);
+static int _rl_vi_callback_change_char (_rl_callback_generic_arg *);
+static int _rl_vi_callback_char_search (_rl_callback_generic_arg *);
#endif
-static int rl_domove_read_callback PARAMS((_rl_vimotion_cxt *));
-static int rl_domove_motion_callback PARAMS((_rl_vimotion_cxt *));
-static int rl_vi_domove_getchar PARAMS((_rl_vimotion_cxt *));
+static int rl_domove_read_callback (_rl_vimotion_cxt *);
+static int rl_domove_motion_callback (_rl_vimotion_cxt *);
+static int rl_vi_domove_getchar (_rl_vimotion_cxt *);
-static int vi_change_dispatch PARAMS((_rl_vimotion_cxt *));
-static int vi_delete_dispatch PARAMS((_rl_vimotion_cxt *));
-static int vi_yank_dispatch PARAMS((_rl_vimotion_cxt *));
+static int vi_change_dispatch (_rl_vimotion_cxt *);
+static int vi_delete_dispatch (_rl_vimotion_cxt *);
+static int vi_yank_dispatch (_rl_vimotion_cxt *);
-static int vidomove_dispatch PARAMS((_rl_vimotion_cxt *));
+static int vidomove_dispatch (_rl_vimotion_cxt *);
void
_rl_vi_initialize_line (void)
@@ -337,24 +337,7 @@ rl_vi_yank_arg (int count, int key)
int
rl_vi_fetch_history (int count, int c)
{
- int wanted;
-
- /* Giving an argument of n means we want the nth command in the history
- file. The command number is interpreted the same way that the bash
- `history' command does it -- that is, giving an argument count of 450
- to this command would get the command listed as number 450 in the
- output of `history'. */
- if (rl_explicit_arg)
- {
- wanted = history_base + where_history () - count;
- if (wanted <= 0)
- rl_beginning_of_history (0, 0);
- else
- rl_get_previous_history (wanted, c);
- }
- else
- rl_beginning_of_history (count, 0);
- return (0);
+ return (rl_fetch_history (count, c));
}
/* Search again for the last thing searched for. */
@@ -944,7 +927,7 @@ rl_vi_arg_digit (int count, int c)
static int
_rl_vi_change_mbchar_case (int count)
{
- wchar_t wc;
+ WCHAR_T wc;
char mb[MB_LEN_MAX+1];
int mlen, p;
size_t m;
@@ -955,9 +938,9 @@ _rl_vi_change_mbchar_case (int count)
count--;
while (count-- && rl_point < rl_end)
{
- m = mbrtowc (&wc, rl_line_buffer + rl_point, rl_end - rl_point, &ps);
+ m = MBRTOWC (&wc, rl_line_buffer + rl_point, rl_end - rl_point, &ps);
if (MB_INVALIDCH (m))
- wc = (wchar_t)rl_line_buffer[rl_point];
+ wc = (WCHAR_T)rl_line_buffer[rl_point];
else if (MB_NULLWCH (m))
wc = L'\0';
if (iswupper (wc))
@@ -975,7 +958,7 @@ _rl_vi_change_mbchar_case (int count)
if (wc)
{
p = rl_point;
- mlen = wcrtomb (mb, wc, &ps);
+ mlen = WCRTOMB (mb, wc, &ps);
if (mlen >= 0)
mb[mlen] = '\0';
rl_begin_undo_group ();
@@ -1389,8 +1372,15 @@ int
rl_vi_delete_to (int count, int key)
{
int c, r;
+ _rl_vimotion_cxt *savecxt;
- if (_rl_vimvcxt)
+ savecxt = 0;
+ if (_rl_vi_redoing)
+ {
+ savecxt = _rl_vimvcxt;
+ _rl_vimvcxt = _rl_mvcxt_alloc (VIM_DELETE, key);
+ }
+ else if (_rl_vimvcxt)
_rl_mvcxt_init (_rl_vimvcxt, VIM_DELETE, key);
else
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_DELETE, key);
@@ -1433,7 +1423,7 @@ rl_vi_delete_to (int count, int key)
}
_rl_mvcxt_dispose (_rl_vimvcxt);
- _rl_vimvcxt = 0;
+ _rl_vimvcxt = savecxt;
return r;
}
@@ -1481,8 +1471,15 @@ int
rl_vi_change_to (int count, int key)
{
int c, r;
+ _rl_vimotion_cxt *savecxt;
- if (_rl_vimvcxt)
+ savecxt = 0;
+ if (_rl_vi_redoing)
+ {
+ savecxt = _rl_vimvcxt;
+ _rl_vimvcxt = _rl_mvcxt_alloc (VIM_CHANGE, key);
+ }
+ else if (_rl_vimvcxt)
_rl_mvcxt_init (_rl_vimvcxt, VIM_CHANGE, key);
else
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_CHANGE, key);
@@ -1524,7 +1521,7 @@ rl_vi_change_to (int count, int key)
}
_rl_mvcxt_dispose (_rl_vimvcxt);
- _rl_vimvcxt = 0;
+ _rl_vimvcxt = savecxt;
return r;
}
@@ -1553,8 +1550,15 @@ int
rl_vi_yank_to (int count, int key)
{
int c, r;
+ _rl_vimotion_cxt *savecxt;
- if (_rl_vimvcxt)
+ savecxt = 0;
+ if (_rl_vi_redoing)
+ {
+ savecxt = _rl_vimvcxt;
+ _rl_vimvcxt = _rl_mvcxt_alloc (VIM_YANK, key);
+ }
+ else if (_rl_vimvcxt)
_rl_mvcxt_init (_rl_vimvcxt, VIM_YANK, key);
else
_rl_vimvcxt = _rl_mvcxt_alloc (VIM_YANK, key);
@@ -1596,7 +1600,7 @@ rl_vi_yank_to (int count, int key)
}
_rl_mvcxt_dispose (_rl_vimvcxt);
- _rl_vimvcxt = 0;
+ _rl_vimvcxt = savecxt;
return r;
}
@@ -2036,6 +2040,9 @@ _rl_vi_callback_change_char (_rl_callback_generic_arg *data)
char mb[MB_LEN_MAX+1];
c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+ if (c < 0)
+ return -1;
+
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
strncpy (_rl_vi_last_replacement, mb, MB_LEN_MAX);
@@ -2044,9 +2051,6 @@ _rl_vi_callback_change_char (_rl_callback_generic_arg *data)
_rl_vi_last_replacement[0] = c;
_rl_vi_last_replacement[MB_LEN_MAX] = '\0'; /* XXX */
- if (c < 0)
- return -1;
-
_rl_callback_func = 0;
_rl_want_redisplay = 1;
@@ -2077,6 +2081,8 @@ rl_vi_change_char (int count, int key)
else
{
c = _rl_vi_callback_getchar (mb, MB_LEN_MAX);
+ if (c < 0)
+ return -1;
#ifdef HANDLE_MULTIBYTE
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
strncpy (_rl_vi_last_replacement, mb, MB_LEN_MAX);
@@ -2113,7 +2119,8 @@ rl_vi_overstrike (int count, int key)
if (count > 0)
{
- _rl_overwrite_char (count, key);
+ if (_rl_overwrite_char (count, key) != 0)
+ return (1);
vi_replace_count += count;
}
diff --git a/lib/readline/xmalloc.h b/lib/readline/xmalloc.h
index f40d7a59..0fb9df9c 100644
--- a/lib/readline/xmalloc.h
+++ b/lib/readline/xmalloc.h
@@ -1,6 +1,6 @@
/* xmalloc.h -- memory allocation that aborts on errors. */
-/* Copyright (C) 1999-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2009,2010-2021 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing.
@@ -38,8 +38,8 @@
#endif /* !PTR_T */
-extern PTR_T xmalloc PARAMS((size_t));
-extern PTR_T xrealloc PARAMS((void *, size_t));
-extern void xfree PARAMS((void *));
+extern PTR_T xmalloc (size_t);
+extern PTR_T xrealloc (void *, size_t);
+extern void xfree (void *);
#endif /* _XMALLOC_H_ */
diff --git a/lib/sh/Makefile.in b/lib/sh/Makefile.in
index 98064de5..8c42c73d 100644
--- a/lib/sh/Makefile.in
+++ b/lib/sh/Makefile.in
@@ -2,7 +2,7 @@
# Makefile for the Bash library
#
#
-# Copyright (C) 1998-2020 Free Software Foundation, Inc.
+# Copyright (C) 1998-2022 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
@@ -57,6 +57,7 @@ SHELL = @MAKE_SHELL@
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@ ${DEBUG}
+STYLE_CFLAGS = @STYLE_CFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@
@@ -68,7 +69,7 @@ LOCAL_DEFS = @LOCAL_DEFS@
INCLUDES = -I. -I../.. -I$(topdir) -I$(topdir)/lib -I$(BASHINCDIR) -I$(srcdir) $(INTL_INC)
CCFLAGS = ${ADDON_CFLAGS} ${PROFILE_FLAGS} ${INCLUDES} $(DEFS) $(LOCAL_DEFS) \
- $(LOCAL_CFLAGS) $(CFLAGS) $(CPPFLAGS)
+ $(LOCAL_CFLAGS) $(STYLE_CFLAGS) $(CFLAGS) $(CPPFLAGS)
GCC_LINT_FLAGS = -Wall -Wshadow -Wpointer-arith -Wcast-qual \
-Wcast-align -Wstrict-prototypes -Wconversion \
@@ -93,7 +94,7 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
wcsdup.c fpurge.c zgetline.c mbscmp.c uconvert.c ufuncs.c \
casemod.c dprintf.c input_avail.c mbscasecmp.c fnxform.c \
strchrnul.c unicode.c wcswidth.c wcsnwidth.c shmbchar.c strdup.c \
- utf8.c random.c gettimeofday.c
+ strvis.c utf8.c random.c gettimeofday.c timers.c
# The header files for this library.
HSOURCES =
@@ -107,8 +108,8 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \
strtrans.o snprintf.o mailstat.o fmtulong.o \
fmtullong.o fmtumax.o zcatfd.o zmapfd.o winsize.o wcsdup.o \
fpurge.o zgetline.o mbscmp.o uconvert.o ufuncs.o casemod.o \
- input_avail.o mbscasecmp.o fnxform.o unicode.o shmbchar.o \
- utf8.o random.o gettimeofday.o wcsnwidth.o ${LIBOBJS}
+ input_avail.o mbscasecmp.o fnxform.o unicode.o shmbchar.o strvis.o \
+ utf8.o random.o gettimeofday.o timers.o wcsnwidth.o ${LIBOBJS}
SUPPORT = Makefile
@@ -197,6 +198,8 @@ strtoul.o: strtoul.c
strtoull.o: strtoull.c
strtoumax.o: strtoumax.c
strtrans.o: strtrans.c
+strvis.o: strvis.c
+timers.o: timers.c
times.o: times.c
timeval.o: timeval.c
tmpfile.o: tmpfile.c
@@ -277,6 +280,8 @@ strtoul.o: ${BUILD_DIR}/config.h
strtoull.o: ${BUILD_DIR}/config.h
strtoumax.o: ${BUILD_DIR}/config.h
strtrans.o: ${BUILD_DIR}/config.h
+strvis.o: ${BUILD_DIR}/config.h
+timers.o: ${BUILD_DIR}/config.h
times.o: ${BUILD_DIR}/config.h
timeval.o: ${BUILD_DIR}/config.h
tmpfile.o: ${BUILD_DIR}/config.h ${topdir}/config-top.h
@@ -509,6 +514,11 @@ strtrans.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
strtrans.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
#strtrans.o: ${BUILD_DIR}/version.h
+strvis.o: ${topdir}/bashansi.h
+strvis.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/chartypes.h
+strvis.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
+strvis.o: ${topdir}/bashintl.h ${LIBINTL_H} $(BASHINCDIR)/gettext.h
+
times.o: ${BASHINCDIR}/systimes.h
times.o: ${BASHINCDIR}/posixtime.h
@@ -620,6 +630,14 @@ fnxform.o: ${topdir}/bashintl.h ${LIBINTL_H} ${BASHINCDIR}/gettext.h
shmbchar.o: ${BASHINCDIR}/shmbchar.h
shmbchar.o: ${BASHINCDIR}/shmbutil.h
+timers.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
+timers.o: ${BASHINCDIR}/stdc.h
+timers.o: ${topdir}/xmalloc.h ${topdir}/sig.h
+timers.o: ${BASHINCDIR}/posixtime.h ${BASHINCDIR}/stat-time.h
+timers.o: ${BASHINCDIR}/posixselect.h
+timers.o: ${topdir}/bashjmp.h ${BASHINCDIR}/posixjmp.h
+timers.o: ${BASHINCDIR}/timer.h
+
unicode.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
unicode.o: ${BASHINCDIR}/stdc.h
unicode.o: ${topdir}/xmalloc.h
diff --git a/lib/sh/casemod.c b/lib/sh/casemod.c
index bdd96f84..0403f91c 100644
--- a/lib/sh/casemod.c
+++ b/lib/sh/casemod.c
@@ -47,7 +47,7 @@
#define _to_wlower(wc) (iswupper (wc) ? towlower (wc) : (wc))
#if !defined (HANDLE_MULTIBYTE)
-# define cval(s, i) ((s)[(i)])
+# define cval(s, i, l) ((s)[(i)])
# define iswalnum(c) (isalnum(c))
# define TOGGLE(x) (ISUPPER (x) ? tolower ((unsigned char)x) : (TOUPPER (x)))
#else
@@ -75,18 +75,16 @@ extern char *substring PARAMS((char *, int, int));
#if defined (HANDLE_MULTIBYTE)
static wchar_t
-cval (s, i)
+cval (s, i, l)
char *s;
- int i;
+ int i, l;
{
size_t tmp;
wchar_t wc;
- int l;
mbstate_t mps;
if (MB_CUR_MAX == 1 || is_basic (s[i]))
return ((wchar_t)s[i]);
- l = strlen (s);
if (i >= (l - 1))
return ((wchar_t)s[i]);
memset (&mps, 0, sizeof (mbstate_t));
@@ -143,7 +141,7 @@ sh_modcase (string, pat, flags)
inword = 0;
while (start < end)
{
- wc = cval ((char *)string, start);
+ wc = cval ((char *)string, start, end);
if (iswalnum (wc) == 0)
inword = 0;
diff --git a/lib/sh/fmtullong.c b/lib/sh/fmtullong.c
index 97a1dc18..46eaf509 100644
--- a/lib/sh/fmtullong.c
+++ b/lib/sh/fmtullong.c
@@ -20,7 +20,7 @@
#include <config.h>
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
#define LONG long long
#define UNSIGNED_LONG unsigned long long
diff --git a/lib/sh/input_avail.c b/lib/sh/input_avail.c
index 695165fd..2ac44616 100644
--- a/lib/sh/input_avail.c
+++ b/lib/sh/input_avail.c
@@ -110,7 +110,7 @@ nchars_avail (fd, nchars)
#if defined(HAVE_SELECT)
fd_set readfds, exceptfds;
#endif
-#if defined (HAVE_PSELECT)
+#if defined (HAVE_PSELECT) || defined (HAVE_SELECT)
sigset_t set, oset;
#endif
diff --git a/lib/sh/oslib.c b/lib/sh/oslib.c
index 65eb99d9..edc5c6f2 100644
--- a/lib/sh/oslib.c
+++ b/lib/sh/oslib.c
@@ -167,8 +167,8 @@ getdtablesize ()
# endif
void
bcopy (s,d,n)
- char *d, *s;
- int n;
+ void *d, *s;
+ size_t n;
{
FASTCOPY (s, d, n);
}
@@ -180,8 +180,8 @@ bcopy (s,d,n)
# endif
void
bzero (s, n)
- char *s;
- int n;
+ void *s;
+ size_t n;
{
register int i;
register char *r;
@@ -197,7 +197,7 @@ bzero (s, n)
int
gethostname (name, namelen)
char *name;
- int namelen;
+ size_t namelen;
{
int i;
struct utsname ut;
@@ -214,7 +214,7 @@ gethostname (name, namelen)
int
gethostname (name, namelen)
char *name;
- int namelen;
+ size_t namelen;
{
strncpy (name, "unknown", namelen);
name[namelen] = '\0';
@@ -237,7 +237,7 @@ killpg (pgrp, sig)
int
mkfifo (path, mode)
char *path;
- int mode;
+ mode_t mode;
{
#if defined (S_IFIFO)
return (mknod (path, (mode | S_IFIFO), 0));
diff --git a/lib/sh/setlinebuf.c b/lib/sh/setlinebuf.c
index 6473ddfc..dd76e9fc 100644
--- a/lib/sh/setlinebuf.c
+++ b/lib/sh/setlinebuf.c
@@ -1,6 +1,6 @@
/* setlinebuf.c - line-buffer a stdio stream. */
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997,2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -25,36 +25,39 @@
#include <xmalloc.h>
#if defined (USING_BASH_MALLOC)
-# define LBUF_BUFSIZE 1008
+# define LBUF_BUFSIZE 2016
#else
# define LBUF_BUFSIZE BUFSIZ
#endif
+static char *stdoutbuf = 0;
+static char *stderrbuf = 0;
+
/* Cause STREAM to buffer lines as opposed to characters or blocks. */
int
sh_setlinebuf (stream)
FILE *stream;
{
- char *local_linebuf;
-
#if !defined (HAVE_SETLINEBUF) && !defined (HAVE_SETVBUF)
return (0);
#endif
+#if defined (HAVE_SETVBUF)
+ char *local_linebuf;
+
#if defined (USING_BASH_MALLOC)
- local_linebuf = (char *)xmalloc (LBUF_BUFSIZE);
+ if (stream == stdout && stdoutbuf == 0)
+ local_linebuf = stdoutbuf = (char *)xmalloc (LBUF_BUFSIZE);
+ else if (stream == stderr && stderrbuf == 0)
+ local_linebuf = stderrbuf = (char *)xmalloc (LBUF_BUFSIZE);
+ else
+ local_linebuf = (char *)NULL; /* let stdio handle it */
#else
local_linebuf = (char *)NULL;
#endif
-#if defined (HAVE_SETVBUF)
-
-# if defined (SETVBUF_REVERSED)
- return (setvbuf (stream, _IOLBF, local_linebuf, LBUF_BUFSIZE));
-# else /* !SETVBUF_REVERSED */
return (setvbuf (stream, local_linebuf, _IOLBF, LBUF_BUFSIZE));
-# endif /* !SETVBUF_REVERSED */
-# else /* !HAVE_SETVBUF */
+#else /* !HAVE_SETVBUF */
setlinebuf (stream);
return (0);
diff --git a/lib/sh/shmatch.c b/lib/sh/shmatch.c
index d6e7f904..a717d45c 100644
--- a/lib/sh/shmatch.c
+++ b/lib/sh/shmatch.c
@@ -2,7 +2,7 @@
* shmatch.c -- shell interface to posix regular expression matching.
*/
-/* Copyright (C) 2003-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2022 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -41,6 +41,10 @@
extern int glob_ignore_case, match_ignore_case;
+#if defined (ARRAY_VARS)
+extern SHELL_VAR *builtin_find_indexed_array (char *, int);
+#endif
+
int
sh_regmatch (string, pattern, flags)
const char *string;
@@ -92,11 +96,16 @@ sh_regmatch (string, pattern, flags)
/* Store the parenthesized subexpressions in the array BASH_REMATCH.
Element 0 is the portion that matched the entire regexp. Element 1
is the part that matched the first subexpression, and so on. */
- unbind_variable_noref ("BASH_REMATCH");
+#if 1
+ unbind_global_variable_noref ("BASH_REMATCH");
rematch = make_new_array_variable ("BASH_REMATCH");
- amatch = array_cell (rematch);
+#else
+ /* TAG:bash-5.3 */
+ rematch = builtin_find_indexed_array ("BASH_REMATCH", 1);
+#endif
+ amatch = rematch ? array_cell (rematch) : (ARRAY *)0;
- if (matches && (flags & SHMAT_SUBEXP) && result == EXECUTION_SUCCESS && subexp_str)
+ if (matches && amatch && (flags & SHMAT_SUBEXP) && result == EXECUTION_SUCCESS && subexp_str)
{
for (subexp_ind = 0; subexp_ind <= regex.re_nsub; subexp_ind++)
{
diff --git a/lib/sh/shquote.c b/lib/sh/shquote.c
index 680f84ed..26fe0185 100644
--- a/lib/sh/shquote.c
+++ b/lib/sh/shquote.c
@@ -311,12 +311,13 @@ sh_backslash_quote (string, table, flags)
return (result);
}
-#if defined (PROMPT_STRING_DECODE)
+#if defined (PROMPT_STRING_DECODE) || defined (TRANSLATABLE_STRINGS)
/* Quote characters that get special treatment when in double quotes in STRING
- using backslashes. Return a new string. */
+ using backslashes. FLAGS is reserved for future use. Return a new string. */
char *
-sh_backslash_quote_for_double_quotes (string)
+sh_backslash_quote_for_double_quotes (string, flags)
char *string;
+ int flags;
{
unsigned char c;
char *result, *r, *s, *send;
diff --git a/lib/sh/snprintf.c b/lib/sh/snprintf.c
index 406a3a50..1f0f4c73 100644
--- a/lib/sh/snprintf.c
+++ b/lib/sh/snprintf.c
@@ -70,7 +70,7 @@
#endif
#if defined(DRIVER) && !defined(HAVE_CONFIG_H)
-#define HAVE_LONG_LONG
+#define HAVE_LONG_LONG_INT
#define HAVE_LONG_DOUBLE
#ifdef __linux__
#define HAVE_PRINTF_A_FORMAT
@@ -286,7 +286,7 @@ static void floating PARAMS((struct DATA *, double));
static void exponent PARAMS((struct DATA *, double));
#endif
static void number PARAMS((struct DATA *, unsigned long, int));
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
static void lnumber PARAMS((struct DATA *, unsigned long long, int));
#endif
static void pointer PARAMS((struct DATA *, unsigned long));
@@ -767,7 +767,7 @@ number(p, d, base)
FREE (t);
}
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
/*
* identical to number() but works for `long long'
*/
@@ -1262,7 +1262,7 @@ vsnprintf_internal(data, string, length, format, args)
long double ld; /* for later */
#endif
unsigned long ul;
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_UNSIGNED_LONG_LONG_INT
unsigned long long ull;
#endif
int state, i, c, n;
@@ -1486,7 +1486,7 @@ conv_break:
/* FALLTHROUGH */
case 'u':
STAR_ARGS(data);
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
if (data->flags & PF_LONGLONG)
{
ull = GETARG (unsigned long long);
@@ -1506,7 +1506,7 @@ conv_break:
case 'd': /* decimal */
case 'i':
STAR_ARGS(data);
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
if (data->flags & PF_LONGLONG)
{
ull = GETARG (long long);
@@ -1522,7 +1522,7 @@ conv_break:
break;
case 'o': /* octal */
STAR_ARGS(data);
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
if (data->flags & PF_LONGLONG)
{
ull = GETARG (unsigned long long);
@@ -1539,7 +1539,7 @@ conv_break:
case 'x':
case 'X': /* hexadecimal */
STAR_ARGS(data);
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
if (data->flags & PF_LONGLONG)
{
ull = GETARG (unsigned long long);
@@ -1602,7 +1602,7 @@ conv_break:
state = 0;
break;
case 'n':
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
if (data->flags & PF_LONGLONG)
*(GETARG (long long *)) = data->counter;
else
@@ -2082,7 +2082,7 @@ main()
printf("<%s>\n", holder);
printf("<%s>\n\n", h);
-#ifdef HAVE_LONG_LONG
+#ifdef HAVE_LONG_LONG_INT
printf ("<%%llu> LLONG_MAX+1\n");
i = snprintf(holder, 100, "%llu", (unsigned long long)(LLONG_MAX)+1);
i = asprintf(&h, "%llu", (unsigned long long)(LLONG_MAX)+1);
diff --git a/lib/sh/strdup.c b/lib/sh/strdup.c
index 90fa3532..3d35f7c0 100644
--- a/lib/sh/strdup.c
+++ b/lib/sh/strdup.c
@@ -17,7 +17,6 @@
You should have received a copy of the GNU General Public License
along with Bash. If not, see <http://www.gnu.org/licenses/>.
*/
-
#include <config.h>
diff --git a/lib/sh/strftime.c b/lib/sh/strftime.c
index 08ccb9a3..60bee79f 100644
--- a/lib/sh/strftime.c
+++ b/lib/sh/strftime.c
@@ -59,16 +59,13 @@
*/
#include <config.h>
+#include <sys/types.h>
+
#include <stdio.h>
#include <ctype.h>
-#include <time.h>
+#include <posixtime.h>
#include <errno.h>
-#if defined(TM_IN_SYS_TIME)
-#include <sys/types.h>
-#include <sys/time.h>
-#endif
-
#include <stdlib.h>
#include <string.h>
diff --git a/lib/sh/strtoimax.c b/lib/sh/strtoimax.c
index 676e02ef..584fa0ba 100644
--- a/lib/sh/strtoimax.c
+++ b/lib/sh/strtoimax.c
@@ -51,7 +51,7 @@ extern long strtol PARAMS((const char *, char **, int));
#ifndef HAVE_DECL_STRTOLL
"this configure-time declaration test was not run"
#endif
-#if !HAVE_DECL_STRTOLL && HAVE_LONG_LONG
+#if !HAVE_DECL_STRTOLL && HAVE_LONG_LONG_INT
extern long long strtoll PARAMS((const char *, char **, int));
#endif
@@ -65,7 +65,7 @@ strtoimax (ptr, endptr, base)
char **endptr;
int base;
{
-#if HAVE_LONG_LONG
+#if HAVE_LONG_LONG_INT
verify(size_is_that_of_long_or_long_long,
(sizeof (intmax_t) == sizeof (long) ||
sizeof (intmax_t) == sizeof (long long)));
@@ -86,20 +86,20 @@ main ()
{
char *p, *endptr;
intmax_t x;
-#if HAVE_LONG_LONG
+#if HAVE_LONG_LONG_INT
long long y;
#endif
long z;
printf ("sizeof intmax_t: %d\n", sizeof (intmax_t));
-#if HAVE_LONG_LONG
+#if HAVE_LONG_LONG_INT
printf ("sizeof long long: %d\n", sizeof (long long));
#endif
printf ("sizeof long: %d\n", sizeof (long));
x = strtoimax("42", &endptr, 10);
-#if HAVE_LONG_LONG
+#if HAVE_LONG_LONG_INT
y = strtoll("42", &endptr, 10);
#else
y = -1;
diff --git a/lib/sh/strtol.c b/lib/sh/strtol.c
index 8aa74788..c839a97c 100644
--- a/lib/sh/strtol.c
+++ b/lib/sh/strtol.c
@@ -20,7 +20,7 @@
#include <config.h>
-#if !defined (HAVE_STRTOL)
+#if !HAVE_STRTOL
#include <chartypes.h>
#include <errno.h>
diff --git a/lib/sh/strtoll.c b/lib/sh/strtoll.c
index f6060eef..f90300b9 100644
--- a/lib/sh/strtoll.c
+++ b/lib/sh/strtoll.c
@@ -20,11 +20,11 @@
#include <config.h>
-#if defined (HAVE_LONG_LONG) && !defined (HAVE_STRTOLL)
+#if defined (HAVE_LONG_LONG_INT) && !HAVE_STRTOLL
#define QUAD 1
#undef HAVE_STRTOL
#include "strtol.c"
-#endif /* HAVE_LONG_LONG && !HAVE_STRTOLL */
+#endif /* HAVE_LONG_LONG_INT && !HAVE_STRTOLL */
diff --git a/lib/sh/strtoull.c b/lib/sh/strtoull.c
index 02ddebb9..fe6592e5 100644
--- a/lib/sh/strtoull.c
+++ b/lib/sh/strtoull.c
@@ -20,7 +20,7 @@
#include <config.h>
-#if defined (HAVE_LONG_LONG) && !defined (HAVE_STRTOULL)
+#if defined (HAVE_UNSIGNED_LONG_LONG_INT) && !HAVE_STRTOULL
#define QUAD 1
#define UNSIGNED 1
@@ -28,4 +28,4 @@
#include "strtol.c"
-#endif /* HAVE_LONG_LONG && !HAVE_STRTOULL */
+#endif /* HAVE_UNSIGNED_LONG_LONG_INT && !HAVE_STRTOULL */
diff --git a/lib/sh/strtoumax.c b/lib/sh/strtoumax.c
index 0247e57b..2e26efcf 100644
--- a/lib/sh/strtoumax.c
+++ b/lib/sh/strtoumax.c
@@ -51,7 +51,7 @@ extern unsigned long strtoul PARAMS((const char *, char **, int));
#ifndef HAVE_DECL_STRTOULL
"this configure-time declaration test was not run"
#endif
-#if !HAVE_DECL_STRTOULL && HAVE_UNSIGNED_LONG_LONG
+#if !HAVE_DECL_STRTOULL && HAVE_UNSIGNED_LONG_LONG_INT
extern unsigned long long strtoull PARAMS((const char *, char **, int));
#endif
@@ -65,7 +65,7 @@ strtoumax (ptr, endptr, base)
char **endptr;
int base;
{
-#if HAVE_UNSIGNED_LONG_LONG
+#if HAVE_UNSIGNED_LONG_LONG_INT
verify (size_is_that_of_unsigned_long_or_unsigned_long_long,
(sizeof (uintmax_t) == sizeof (unsigned long) ||
sizeof (uintmax_t) == sizeof (unsigned long long)));
@@ -86,20 +86,20 @@ main ()
{
char *p, *endptr;
uintmax_t x;
-#if HAVE_UNSIGNED_LONG_LONG
+#if HAVE_UNSIGNED_LONG_LONG_INT
unsigned long long y;
#endif
unsigned long z;
printf ("sizeof uintmax_t: %d\n", sizeof (uintmax_t));
-#if HAVE_UNSIGNED_LONG_LONG
+#if HAVE_UNSIGNED_LONG_LONG_INT
printf ("sizeof unsigned long long: %d\n", sizeof (unsigned long long));
#endif
printf ("sizeof unsigned long: %d\n", sizeof (unsigned long));
x = strtoumax("42", &endptr, 10);
-#if HAVE_LONG_LONG
+#if HAVE_LONG_LONG_INT
y = strtoull("42", &endptr, 10);
#else
y = 0;
diff --git a/lib/sh/strvis.c b/lib/sh/strvis.c
new file mode 100644
index 00000000..7a11d579
--- /dev/null
+++ b/lib/sh/strvis.c
@@ -0,0 +1,154 @@
+/* strvis.c - make unsafe graphical characters in a string visible. */
+
+/* Copyright (C) 2022 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+/* This is a stripped-down version suitable for the shell's use. */
+#include <config.h>
+
+#include <unistd.h>
+
+#include "bashansi.h"
+#include <stdio.h>
+
+#include "chartypes.h"
+#include "bashintl.h"
+#include "shmbutil.h"
+
+#define SAFECHAR(c) ((c) == ' ' || (c) == '\t')
+
+#ifndef RUBOUT
+#define RUBOUT 0x7f
+#endif
+
+#ifndef CTRL_CHAR
+#define CTRL_CHAR(c) ((c) < 0x20)
+#endif
+
+#ifndef META_CHAR
+#define META_CHAR(c) ((c) > 0x7f && (c) <= UCHAR_MAX)
+#endif
+
+#ifndef UNCTRL
+#define UNCTRL(c) (TOUPPER ((c) | 0x40))
+#endif
+
+#ifndef UNMETA
+#define UNMETA(c) ((c) & 0x7f)
+#endif
+
+int
+sh_charvis (s, sindp, slen, ret, rindp)
+ const char *s;
+ size_t *sindp;
+ size_t slen;
+ char *ret;
+ size_t *rindp;
+{
+ unsigned char c;
+ size_t si, ri;
+ const char *send;
+ DECLARE_MBSTATE;
+
+ si = *sindp;
+ ri = *rindp;
+ c = s[*sindp];
+
+#if defined (HANDLE_MULTIBYTE)
+ send = (locale_mb_cur_max > 1) ? s + slen : 0;
+#else
+ send = 0;
+#endif
+
+ if (SAFECHAR (c))
+ {
+ ret[ri++] = c;
+ si++;
+ }
+ else if (c == RUBOUT)
+ {
+ ret[ri++] = '^';
+ ret[ri++] = '?';
+ si++;
+ }
+ else if (CTRL_CHAR (c))
+ {
+ ret[ri++] = '^';
+ ret[ri++] = UNCTRL (c);
+ si++;
+ }
+#if defined (HANDLE_MULTIBYTE)
+ else if (locale_utf8locale && (c & 0x80))
+ COPY_CHAR_I (ret, ri, s, send, si);
+ else if (locale_mb_cur_max > 1 && is_basic (c) == 0)
+ COPY_CHAR_I (ret, ri, s, send, si);
+#endif
+ else if (META_CHAR (c))
+ {
+ ret[ri++] = 'M';
+ ret[ri++] = '-';
+ ret[ri++] = UNMETA (c);
+ si++;
+ }
+ else
+ ret[ri++] = s[si++];
+
+ *sindp = si;
+ *rindp = ri;
+
+ return si;
+}
+
+/* Return a new string with `unsafe' non-graphical characters in S rendered
+ in a visible way. */
+char *
+sh_strvis (string)
+ const char *string;
+{
+ size_t slen, sind;
+ char *ret;
+ size_t retind, retsize;
+ unsigned char c;
+ DECLARE_MBSTATE;
+
+ if (string == 0)
+ return 0;
+ if (*string == '\0')
+ {
+ if ((ret = (char *)malloc (1)) == 0)
+ return 0;
+ ret[0] = '\0';
+ return ret;
+ }
+
+ slen = strlen (string);
+ retsize = 3 * slen + 1;
+
+ ret = (char *)malloc (retsize);
+ if (ret == 0)
+ return 0;
+
+ retind = 0;
+ sind = 0;
+
+ while (string[sind])
+ sind = sh_charvis (string, &sind, slen, ret, &retind);
+
+ ret[retind] = '\0';
+ return ret;
+}
diff --git a/lib/sh/timers.c b/lib/sh/timers.c
new file mode 100644
index 00000000..69b754c9
--- /dev/null
+++ b/lib/sh/timers.c
@@ -0,0 +1,262 @@
+/* timers - functions to manage shell timers */
+
+/* Copyright (C) 2021 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Bash is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "config.h"
+
+#include "bashtypes.h"
+#include "posixtime.h"
+
+#if defined (HAVE_UNISTD_H)
+#include <unistd.h>
+#endif
+
+#if defined (HAVE_SELECT)
+# include "posixselect.h"
+# include "stat-time.h"
+#endif
+
+#include "sig.h"
+#include "bashjmp.h"
+#include "xmalloc.h"
+
+#include "timer.h"
+
+#include <errno.h>
+#if !defined (errno)
+extern int errno;
+#endif /* !errno */
+
+#ifndef FREE
+#define FREE(s) do { if (s) free (s); } while (0)
+#endif
+
+extern unsigned int falarm (unsigned int, unsigned int);
+
+static void shtimer_zero (sh_timer *);
+
+static void
+shtimer_zero (sh_timer *t)
+{
+ t->tmout.tv_sec = 0;
+ t->tmout.tv_usec = 0;
+
+ t->fd = -1;
+ t->flags = t->alrmflag = 0;
+
+ t->alrm_handler = t->old_handler = 0;
+
+ memset (t->jmpenv, '\0', sizeof (t->jmpenv));
+
+ t->tm_handler = 0;
+ t->data = 0;
+}
+
+sh_timer *
+shtimer_alloc (void)
+{
+ sh_timer *t;
+
+ t = (sh_timer *)xmalloc (sizeof (sh_timer));
+ shtimer_zero (t);
+ return t;
+}
+
+void
+shtimer_flush (sh_timer *t)
+{
+ /* The caller can manage t->data arbitrarily as long as it frees and sets
+ t->data to 0 before calling this function. Otherwise, we do what we can
+ to avoid memleaks. */
+ FREE (t->data);
+ shtimer_zero (t);
+}
+
+void
+shtimer_dispose (sh_timer *t)
+{
+ free (t);
+}
+
+/* We keep the timer as an offset into the future from the time it's set. */
+void
+shtimer_set (sh_timer *t, time_t sec, long usec)
+{
+ struct timeval now;
+
+ if (t->flags & SHTIMER_ALARM)
+ {
+ t->alrmflag = 0; /* just paranoia */
+ t->old_handler = set_signal_handler (SIGALRM, t->alrm_handler);
+ t->flags |= SHTIMER_SIGSET;
+ falarm (t->tmout.tv_sec = sec, t->tmout.tv_usec = usec);
+ t->flags |= SHTIMER_ALRMSET;
+ return;
+ }
+
+ if (gettimeofday (&now, 0) < 0)
+ timerclear (&now);
+
+ t->tmout.tv_sec = now.tv_sec + sec;
+ t->tmout.tv_usec = now.tv_usec + usec;
+ if (t->tmout.tv_usec > USEC_PER_SEC)
+ {
+ t->tmout.tv_sec++;
+ t->tmout.tv_usec -= USEC_PER_SEC;
+ }
+}
+
+void
+shtimer_unset (sh_timer *t)
+{
+ t->tmout.tv_sec = 0;
+ t->tmout.tv_usec = 0;
+
+ if (t->flags & SHTIMER_ALARM)
+ {
+ t->alrmflag = 0;
+ if (t->flags & SHTIMER_ALRMSET)
+ falarm (0, 0);
+ if (t->old_handler && (t->flags & SHTIMER_SIGSET))
+ {
+ set_signal_handler (SIGALRM, t->old_handler);
+ t->flags &= ~SHTIMER_SIGSET;
+ t->old_handler = 0;
+ }
+ }
+}
+
+void
+shtimer_cleanup (sh_timer *t)
+{
+ shtimer_unset (t);
+}
+
+void
+shtimer_clear (sh_timer *t)
+{
+ shtimer_unset (t);
+ shtimer_dispose (t);
+}
+
+int
+shtimer_chktimeout (sh_timer *t)
+{
+ struct timeval now;
+ int r;
+
+ /* Use the flag to avoid returning sigalrm_seen here */
+ if (t->flags & SHTIMER_ALARM)
+ return t->alrmflag;
+
+ /* Could check a flag for this */
+ if (t->tmout.tv_sec == 0 && t->tmout.tv_usec == 0)
+ return 0;
+
+ if (gettimeofday (&now, 0) < 0)
+ return 0;
+ r = ((now.tv_sec > t->tmout.tv_sec) ||
+ (now.tv_sec == t->tmout.tv_sec && now.tv_usec >= t->tmout.tv_usec));
+
+ return r;
+}
+
+#if defined (HAVE_SELECT) || defined (HAVE_PSELECT)
+int
+shtimer_select (sh_timer *t)
+{
+ int r, nfd;
+ sigset_t blocked_sigs, prevmask;
+ struct timeval now, tv;
+ fd_set readfds;
+#if defined (HAVE_PSELECT)
+ struct timespec ts;
+#endif
+
+ /* We don't want a SIGCHLD to interrupt this */
+ sigemptyset (&blocked_sigs);
+# if defined (SIGCHLD)
+ sigaddset (&blocked_sigs, SIGCHLD);
+# endif
+
+ if (gettimeofday (&now, 0) < 0)
+ {
+ if (t->flags & SHTIMER_LONGJMP)
+ sh_longjmp (t->jmpenv, 1);
+ else
+ return -1;
+ }
+
+ /* If the timer has already expired, return immediately */
+ if ((now.tv_sec > t->tmout.tv_sec) ||
+ (now.tv_sec == t->tmout.tv_sec && now.tv_usec >= t->tmout.tv_usec))
+ {
+ if (t->flags & SHTIMER_LONGJMP)
+ sh_longjmp (t->jmpenv, 1);
+ else if (t->tm_handler)
+ return ((*t->tm_handler) (t));
+ else
+ return 0;
+ }
+
+ /* compute timeout */
+ tv.tv_sec = t->tmout.tv_sec - now.tv_sec;
+ tv.tv_usec = t->tmout.tv_usec - now.tv_usec;
+ if (tv.tv_usec < 0)
+ {
+ tv.tv_sec--;
+ tv.tv_usec += USEC_PER_SEC;
+ }
+
+#if defined (HAVE_PSELECT)
+ ts.tv_sec = tv.tv_sec;
+ ts.tv_nsec = tv.tv_usec * 1000;
+#else
+ sigemptyset (&prevmask);
+#endif /* !HAVE_PSELECT */
+
+ nfd = (t->fd >= 0) ? t->fd + 1 : 0;
+ FD_ZERO (&readfds);
+ if (t->fd >= 0)
+ FD_SET (t->fd, &readfds);
+
+#if defined (HAVE_PSELECT)
+ r = pselect(nfd, &readfds, (fd_set *)0, (fd_set *)0, &ts, &blocked_sigs);
+#else
+ sigprocmask (SIG_SETMASK, &blocked_sigs, &prevmask);
+ r = select(nfd, &readfds, (fd_set *)0, (fd_set *)0, &tv);
+ sigprocmask (SIG_SETMASK, &prevmask, NULL);
+#endif
+
+ if (r < 0)
+ return r; /* caller will handle */
+ else if (r == 0 && (t->flags & SHTIMER_LONGJMP))
+ sh_longjmp (t->jmpenv, 1);
+ else if (r == 0 && t->tm_handler)
+ return ((*t->tm_handler) (t));
+ else
+ return r;
+}
+#endif /* !HAVE_TIMEVAL || !HAVE_SELECT */
+
+int
+shtimer_alrm (sh_timer *t)
+{
+ return 0;
+}
diff --git a/lib/sh/unicode.c b/lib/sh/unicode.c
index d95d1e25..d781353b 100644
--- a/lib/sh/unicode.c
+++ b/lib/sh/unicode.c
@@ -145,7 +145,7 @@ u32tocesc (wc, s)
if (wc < 0x10000)
l = sprintf (s, "\\u%04X", wc);
else
- l = sprintf (s, "\\u%08X", wc);
+ l = sprintf (s, "\\U%08X", wc);
return l;
}
diff --git a/lib/sh/winsize.c b/lib/sh/winsize.c
index 861c7c89..846fcd58 100644
--- a/lib/sh/winsize.c
+++ b/lib/sh/winsize.c
@@ -68,6 +68,11 @@ extern int errno;
extern int shell_tty;
#if defined (READLINE)
+/* Let's not call readline, forcing readline to initialize the termcap/terminfo
+ variables it needs, unless we have to. */
+extern int interactive_shell;
+extern int no_line_editing;
+extern int bash_readline_initialized;
extern void rl_set_screen_size PARAMS((int, int));
#endif
extern void sh_set_lines_and_columns PARAMS((int, int));
@@ -87,12 +92,13 @@ get_new_window_size (from_sig, rp, cp)
{
sh_set_lines_and_columns (win.ws_row, win.ws_col);
#if defined (READLINE)
- rl_set_screen_size (win.ws_row, win.ws_col);
+ if ((interactive_shell && no_line_editing == 0) || bash_readline_initialized)
+ rl_set_screen_size (win.ws_row, win.ws_col);
+#endif
if (rp)
*rp = win.ws_row;
if (cp)
*cp = win.ws_col;
-#endif
}
#endif
}
diff --git a/lib/sh/zgetline.c b/lib/sh/zgetline.c
index 8ded1442..5e1ef724 100644
--- a/lib/sh/zgetline.c
+++ b/lib/sh/zgetline.c
@@ -68,7 +68,8 @@ zgetline (fd, lineptr, n, delim, unbuffered_read)
int delim;
int unbuffered_read;
{
- int nr, retval;
+ int retval;
+ size_t nr;
char *line, c;
if (lineptr == 0 || n == 0 || (*lineptr == 0 && *n != 0))
diff --git a/lib/sh/zmapfd.c b/lib/sh/zmapfd.c
index f9e9ed71..9ff50a47 100644
--- a/lib/sh/zmapfd.c
+++ b/lib/sh/zmapfd.c
@@ -54,7 +54,7 @@ zmapfd (fd, ostr, fn)
int rval;
char lbuf[ZBUFSIZ];
char *result;
- int rsize, rind;
+ size_t rsize, rind;
rval = 0;
result = (char *)xmalloc (rsize = ZBUFSIZ);
diff --git a/lib/sh/zread.c b/lib/sh/zread.c
index 71a06a76..dafb7f60 100644
--- a/lib/sh/zread.c
+++ b/lib/sh/zread.c
@@ -46,6 +46,7 @@ extern int executing_builtin;
extern void check_signals_and_traps (void);
extern void check_signals (void);
extern int signal_is_trapped (int);
+extern int read_builtin_timeout (int);
/* Read LEN bytes from FD into BUF. Retry the read on EINTR. Any other
error causes the loop to break. */
@@ -58,7 +59,10 @@ zread (fd, buf, len)
ssize_t r;
check_signals (); /* check for signals before a blocking read */
- while ((r = read (fd, buf, len)) < 0 && errno == EINTR)
+ /* should generalize into a mechanism where different parts of the shell can
+ `register' timeouts and have them checked here. */
+ while (((r = read_builtin_timeout (fd)) < 0 || (r = read (fd, buf, len)) < 0) &&
+ errno == EINTR)
{
int t;
t = errno;
diff --git a/lib/termcap/termcap.c b/lib/termcap/termcap.c
index ba3dab2c..87fae05f 100644
--- a/lib/termcap/termcap.c
+++ b/lib/termcap/termcap.c
@@ -52,15 +52,18 @@ extern char *realloc ();
#else /* not HAVE_CONFIG_H */
-#ifdef STDC_HEADERS
+#ifdef HAVE_STDLIB_H
#include <stdlib.h>
-#include <string.h>
#else
char *getenv ();
char *malloc ();
char *realloc ();
#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
/* Do this after the include, in case string.h prototypes bcopy. */
#if (defined(HAVE_STRING_H) || defined(STDC_HEADERS)) && !defined(bcopy)
#define bcopy(s, d, n) memcpy ((d), (s), (n))
diff --git a/lib/tilde/Makefile.in b/lib/tilde/Makefile.in
index c21d3897..e61c6718 100644
--- a/lib/tilde/Makefile.in
+++ b/lib/tilde/Makefile.in
@@ -4,7 +4,7 @@
# #
####################################################################
-# Copyright (C) 1996-2009 Free Software Foundation, Inc.
+# Copyright (C) 1996-2021 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
@@ -42,6 +42,7 @@ PROFILE_FLAGS = @PROFILE_FLAGS@
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@
+STYLE_CFLAGS = @STYLE_CFLAGS@
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@
@@ -53,7 +54,7 @@ BASHINCDIR = ${topdir}/include
INCLUDES = -I. -I../.. -I$(topdir) -I${BASHINCDIR} -I$(topdir)/lib
CCFLAGS = ${ASAN_CFLAGS} $(PROFILE_FLAGS) $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) \
- ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
+ ${INCLUDES} $(STYLE_CFLAGS) $(LOCAL_CFLAGS) $(CFLAGS)
.c.o:
$(CC) -c $(CCFLAGS) $<
diff --git a/lib/tilde/tilde.h b/lib/tilde/tilde.h
index e26dd047..bc8022af 100644
--- a/lib/tilde/tilde.h
+++ b/lib/tilde/tilde.h
@@ -1,6 +1,6 @@
/* tilde.h: Externally available variables and function in libtilde.a. */
-/* Copyright (C) 1992-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2009,2021 Free Software Foundation, Inc.
This file contains the Readline Library (Readline), a set of
routines for providing Emacs style line input to programs that ask
@@ -27,19 +27,7 @@
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 PARAMS((char *, char *, int)); */
-
-#if !defined (PARAMS)
-# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
-# define PARAMS(protos) protos
-# else
-# define PARAMS(protos) ()
-# endif
-#endif
-
-typedef char *tilde_hook_func_t PARAMS((char *));
+typedef char *tilde_hook_func_t (char *);
/* If non-null, this contains the address of a function that the application
wants called before trying the standard tilde expansions. The function
@@ -64,14 +52,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 PARAMS((const char *));
+extern char *tilde_expand (const 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 PARAMS((const char *));
+extern char *tilde_expand_word (const char *);
/* Find the portion of the string beginning with ~ that should be expanded. */
-extern char *tilde_find_word PARAMS((const char *, int, int *));
+extern char *tilde_find_word (const char *, int, int *);
#ifdef __cplusplus
}