mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-15 16:10:50 +02:00
bash-5.2-alpha release
This commit is contained 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.
|
||||
|
||||
+89
-46
@@ -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
|
||||
#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)
|
||||
@@ -895,7 +936,8 @@ glob_vector (pat, dir, flags)
|
||||
nextname = (char *) malloc (D_NAMLEN (dp) + 1);
|
||||
if (nextlink == 0 || nextname == 0)
|
||||
{
|
||||
FREE (nextlink);
|
||||
if (firstmalloc)
|
||||
FREE (nextlink);
|
||||
FREE (nextname);
|
||||
lose = 1;
|
||||
break;
|
||||
@@ -914,7 +956,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 +986,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 +1483,7 @@ only_filename:
|
||||
{
|
||||
if (free_dirname)
|
||||
free (directory_name);
|
||||
free ((char *) result);
|
||||
return ((char **)&glob_error_return);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -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));
|
||||
|
||||
+47
-8
@@ -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
|
||||
|
||||
+22
-1
@@ -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
|
||||
|
||||
+2
-1
@@ -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
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
GNU gettext library from gettext-0.12.1
|
||||
|
||||
This is here only in the case the system doesn't provide it
|
||||
|
||||
Executable → Regular
Executable → Regular
@@ -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 $<
|
||||
|
||||
+142
-65
@@ -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 */
|
||||
|
||||
#define STARTBUCK 1
|
||||
/* Which bin do we prepopulate with the initial sbrk memory? */
|
||||
#define PREPOP_BIN 1
|
||||
#define PREPOP_SIZE 64
|
||||
|
||||
#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 ();
|
||||
@@ -741,14 +755,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 +764,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 +831,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 +845,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 +896,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 +953,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 +987,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;
|
||||
@@ -1084,6 +1089,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 +1149,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 +1189,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 +1216,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 +1246,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 +1350,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;
|
||||
|
||||
+2
-2
@@ -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
|
||||
|
||||
/*
|
||||
|
||||
@@ -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} $@
|
||||
|
||||
+124
-29
@@ -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-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.
|
||||
@@ -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,19 +1983,19 @@ 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_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;
|
||||
@@ -2548,6 +2634,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 == '"')
|
||||
|
||||
+10
-1
@@ -147,6 +147,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 ();
|
||||
}
|
||||
|
||||
@@ -278,7 +286,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])
|
||||
|
||||
+16
-15
@@ -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))
|
||||
#ifndef UCHAR_MAX
|
||||
# define UCHAR_MAX 255
|
||||
#endif
|
||||
#ifndef CHAR_MAX
|
||||
# define CHAR_MAX 127
|
||||
#endif
|
||||
|
||||
/* 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) isascii(c)
|
||||
# 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
|
||||
|
||||
#if defined (CTYPE_NON_ASCII)
|
||||
# define NON_NEGATIVE(c) 1
|
||||
#else
|
||||
# define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
|
||||
#endif
|
||||
|
||||
/* Some systems define these; we want our definitions. */
|
||||
#undef ISPRINT
|
||||
|
||||
@@ -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
|
||||
|
||||
+21
-2
@@ -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
|
||||
|
||||
+11
-11
@@ -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. */
|
||||
|
||||
|
||||
+48
-46
@@ -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)
|
||||
@@ -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))
|
||||
|
||||
+68
-50
@@ -1,6 +1,6 @@
|
||||
/* display.c -- readline redisplay facility. */
|
||||
|
||||
/* 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.
|
||||
@@ -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,11 @@ 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 (p != (igstart + 1))
|
||||
last = r - ret - 1;
|
||||
continue;
|
||||
@@ -498,10 +504,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';
|
||||
@@ -749,7 +762,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 +996,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 +1171,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++;
|
||||
@@ -1662,7 +1675,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 +1694,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 +1710,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 +1731,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 +1753,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 +1965,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 +2434,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 +2601,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 +3386,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 +3469,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 +3538,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
|
||||
|
||||
@@ -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
|
||||
.SUFFIXES: .ps .txt .dvi .html .pdf
|
||||
|
||||
all: info dvi html ps
|
||||
.ps.pdf:
|
||||
$(RM) $@
|
||||
-${PSPDF} $<
|
||||
|
||||
.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
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -250,6 +251,11 @@ 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.
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -455,6 +455,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
|
||||
@@ -588,6 +593,10 @@ 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.
|
||||
@end table
|
||||
|
||||
@end deftypevar
|
||||
@@ -876,6 +885,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.
|
||||
@@ -1063,8 +1081,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 +1170,27 @@ 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 specfied 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 @code{*secs} and @code{*usecs}, respectively.
|
||||
Returns -1 on error or when there is no timeout set, 0 when the timeout has
|
||||
expired (leaving @code{*secs} and @code{*usecs} unchanged), and 1 if the
|
||||
timeout has not expired. If @code{secs} and @code{usecs} are @code{NULL},
|
||||
the return value indicates whether the timeout has expired.
|
||||
@end deftypefun
|
||||
|
||||
@node Terminal Management
|
||||
@subsection Terminal Management
|
||||
|
||||
@@ -1611,7 +1651,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
|
||||
@@ -2159,9 +2199,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
|
||||
|
||||
@@ -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
|
||||
@@ -444,6 +445,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 +500,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
|
||||
@@ -540,6 +545,19 @@ 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 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
|
||||
@@ -1332,6 +1350,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
|
||||
@@ -1772,6 +1795,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
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
@ignore
|
||||
Copyright (C) 1988-2020 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2021 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 UPDATED 15 November 2021
|
||||
@set UPDATED-MONTH November 2021
|
||||
|
||||
@set LASTCHANGE Thu Oct 29 16:49:01 EDT 2020
|
||||
@set LASTCHANGE Mon Nov 15 17:05:28 EST 2021
|
||||
|
||||
@@ -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 },
|
||||
|
||||
+34
-11
@@ -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'.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 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,12 @@ 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 *);
|
||||
|
||||
/* histfile.c */
|
||||
extern void _hs_append_history_line (int, const char *);
|
||||
|
||||
#endif /* !_HISTLIB_H_ */
|
||||
|
||||
@@ -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);
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
|
||||
+42
-37
@@ -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-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.
|
||||
@@ -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 0x0801 /* History 8.1 */
|
||||
#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;
|
||||
|
||||
@@ -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
|
||||
|
||||
+302
-17
@@ -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>
|
||||
@@ -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)
|
||||
@@ -463,6 +505,242 @@ rl_clear_pending_input (void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* 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(¤t_time, 0) != 0)
|
||||
return -1;
|
||||
|
||||
/* Return 0 when timeout has already expired. */
|
||||
/* could use timercmp (&timeout_point, ¤t_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))
|
||||
|
||||
@@ -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. */
|
||||
@@ -276,6 +273,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 +320,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
|
||||
|
||||
@@ -690,8 +689,9 @@ 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;
|
||||
cxt->search_string[cxt->search_string_index] = '\0';
|
||||
free (paste);
|
||||
break;
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
+29
-5
@@ -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--;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+18
-18
@@ -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 */
|
||||
|
||||
+52
-12
@@ -1,6 +1,6 @@
|
||||
/* misc.c -- miscellaneous bindable readline functions. */
|
||||
|
||||
/* Copyright (C) 1987-2019 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.
|
||||
@@ -53,11 +53,8 @@
|
||||
#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,8 +306,7 @@ _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;
|
||||
}
|
||||
|
||||
@@ -355,6 +351,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 */
|
||||
@@ -384,6 +382,14 @@ _rl_free_saved_history_line (void)
|
||||
{
|
||||
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 +631,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 +643,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 +706,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;
|
||||
|
||||
|
||||
+5
-5
@@ -1,6 +1,6 @@
|
||||
/* nls.c -- skeletal internationalization code. */
|
||||
|
||||
/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996-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.
|
||||
@@ -54,7 +54,7 @@
|
||||
#include "rlshell.h"
|
||||
#include "rlprivate.h"
|
||||
|
||||
static int utf8locale PARAMS((char *));
|
||||
static int utf8locale (char *);
|
||||
|
||||
#if !defined (HAVE_SETLOCALE)
|
||||
/* A list of legal values for the LANG or LC_CTYPE environment variables.
|
||||
@@ -78,12 +78,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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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_ */
|
||||
+57
-31
@@ -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-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.
|
||||
@@ -72,35 +72,34 @@ extern int errno;
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#if defined (COLOR_SUPPORT)
|
||||
# include "parse-colors.h"
|
||||
#endif
|
||||
|
||||
#ifndef RL_LIBRARY_VERSION
|
||||
# define RL_LIBRARY_VERSION "8.0"
|
||||
# define RL_LIBRARY_VERSION "8.1"
|
||||
#endif
|
||||
|
||||
#ifndef RL_READLINE_VERSION
|
||||
# define RL_READLINE_VERSION 0x0800
|
||||
# define RL_READLINE_VERSION 0x0801
|
||||
#endif
|
||||
|
||||
extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
|
||||
|
||||
#if defined (COLOR_SUPPORT)
|
||||
extern void _rl_parse_colors PARAMS((void)); /* XXX */
|
||||
#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 bind_arrow_keys_internal PARAMS((Keymap));
|
||||
static void bind_arrow_keys PARAMS((void));
|
||||
static void run_startup_hooks (void);
|
||||
|
||||
static void bind_bracketed_paste_prefix PARAMS((void));
|
||||
static void bind_arrow_keys_internal (Keymap);
|
||||
static void bind_arrow_keys (void);
|
||||
|
||||
static void readline_default_bindings PARAMS((void));
|
||||
static void reset_default_bindings PARAMS((void));
|
||||
static void bind_bracketed_paste_prefix (void);
|
||||
|
||||
static int _rl_subseq_result PARAMS((int, Keymap, int, int));
|
||||
static int _rl_subseq_getchar PARAMS((int));
|
||||
static void readline_default_bindings (void);
|
||||
static void reset_default_bindings (void);
|
||||
|
||||
static int _rl_subseq_result (int, Keymap, int, int);
|
||||
static int _rl_subseq_getchar (int);
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
@@ -403,6 +402,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 +431,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 ();
|
||||
|
||||
@@ -511,6 +516,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 +577,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
|
||||
@@ -668,11 +687,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)
|
||||
@@ -1143,6 +1157,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)
|
||||
@@ -1282,8 +1299,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 +1549,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--;
|
||||
}
|
||||
|
||||
+300
-288
@@ -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-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.
|
||||
@@ -39,7 +39,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/* Hex-encoded Readline version number. */
|
||||
#define RL_READLINE_VERSION 0x0801 /* Readline 8.0 */
|
||||
#define RL_READLINE_VERSION 0x0801 /* Readline 8.1 */
|
||||
#define RL_VERSION_MAJOR 8
|
||||
#define RL_VERSION_MINOR 1
|
||||
|
||||
@@ -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_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 PARAMS((int, int));
|
||||
extern int rl_next_screen_line PARAMS((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 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 PARAMS((const char *));
|
||||
extern int rl_variable_bind PARAMS((const char *, const char *));
|
||||
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 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 PARAMS((void));
|
||||
extern int alphabetic PARAMS((int));
|
||||
extern int crlf PARAMS((void));
|
||||
extern int ding (void);
|
||||
extern int alphabetic (int);
|
||||
extern int crlf (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 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
|
||||
|
||||
/* **************************************************************** */
|
||||
@@ -599,6 +608,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 +700,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 +917,7 @@ 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
|
||||
|
||||
#define RL_SETSTATE(x) (rl_readline_state |= (x))
|
||||
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
|
||||
@@ -949,7 +961,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 +971,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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
+25
-13
@@ -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.
|
||||
@@ -81,6 +81,19 @@
|
||||
/* end of multibyte capability checks for I18N */
|
||||
/************************************************/
|
||||
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
+166
-146
@@ -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-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.
|
||||
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,111 @@ 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);
|
||||
|
||||
/* 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 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 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);
|
||||
|
||||
/* 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);
|
||||
|
||||
/* 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 +448,37 @@ extern void _rl_ttymsg ();
|
||||
extern void _rl_errmsg ();
|
||||
extern void _rl_trace ();
|
||||
#endif
|
||||
extern void _rl_audit_tty PARAMS((char *));
|
||||
extern void _rl_audit_tty (char *);
|
||||
|
||||
extern int _rl_tropen PARAMS((void));
|
||||
extern int _rl_tropen (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 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 *
|
||||
@@ -602,4 +616,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_ */
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
+20
-18
@@ -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-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.
|
||||
@@ -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,9 @@ rl_deprep_terminal (void)
|
||||
if (terminal_prepped & TPX_BRACKPASTE)
|
||||
{
|
||||
fprintf (rl_outstream, BRACK_PASTE_FINI);
|
||||
if (_rl_eof_found)
|
||||
if (_rl_eof_found && (RL_ISSTATE (RL_STATE_TIMEOUT) == 0))
|
||||
fprintf (rl_outstream, "\n");
|
||||
else if (_rl_echoing_p == 0)
|
||||
fprintf (rl_outstream, "\n");
|
||||
}
|
||||
|
||||
|
||||
+26
-26
@@ -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 int rl_icpfunc_t (char *);
|
||||
typedef int rl_icppfunc_t (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 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 PARAMS((void));
|
||||
typedef char *rl_cpifunc_t PARAMS((int));
|
||||
typedef char *rl_cpcpfunc_t PARAMS((char *));
|
||||
typedef char *rl_cpcppfunc_t PARAMS((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 */
|
||||
|
||||
|
||||
+29
-19
@@ -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-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.
|
||||
@@ -55,11 +55,6 @@
|
||||
|
||||
_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;
|
||||
|
||||
@@ -72,16 +67,16 @@ 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,12 @@ static int _rl_nsearch_dispatch PARAMS((_rl_search_cxt *, int));
|
||||
static void
|
||||
make_history_line_current (HIST_ENTRY *entry)
|
||||
{
|
||||
/* 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_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,9 +101,10 @@ 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. */
|
||||
if (_rl_saved_line_for_history)
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
_rl_free_saved_history_line ();
|
||||
}
|
||||
|
||||
/* Search the history list for STRING starting at absolute history position
|
||||
@@ -264,11 +266,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);
|
||||
}
|
||||
@@ -524,6 +526,9 @@ rl_history_search_internal (int count, int dir)
|
||||
char *t;
|
||||
|
||||
rl_maybe_save_line ();
|
||||
/* This will either be restored from the saved line or set from the
|
||||
found history line. */
|
||||
rl_undo_list = 0;
|
||||
temp = (HIST_ENTRY *)NULL;
|
||||
|
||||
/* Search COUNT times through the history for a line matching
|
||||
@@ -577,6 +582,11 @@ rl_history_search_internal (int count, int dir)
|
||||
/* Copy the line we found into the current line buffer. */
|
||||
make_history_line_current (temp);
|
||||
|
||||
/* Make sure we set the current history position to the last line found so
|
||||
we can do things like operate-and-get-next from here. This is similar to
|
||||
how incremental search behaves. */
|
||||
history_set_pos (rl_history_search_pos); /* XXX */
|
||||
|
||||
/* 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 */
|
||||
|
||||
@@ -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
|
||||
|
||||
+24
-49
@@ -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;
|
||||
|
||||
+20
-5
@@ -1,6 +1,6 @@
|
||||
/* terminal.c -- controlling the terminal with termcap. */
|
||||
|
||||
/* Copyright (C) 1996-2017 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1996-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.
|
||||
@@ -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,6 +177,10 @@ 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 */
|
||||
@@ -194,7 +198,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 +386,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 +423,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 */
|
||||
@@ -478,6 +488,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 +551,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;
|
||||
@@ -629,6 +641,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;
|
||||
}
|
||||
|
||||
|
||||
+23
-15
@@ -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 ();
|
||||
|
||||
+5
-17
@@ -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
|
||||
}
|
||||
|
||||
+2
-4
@@ -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. */
|
||||
|
||||
+4
-3
@@ -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 ();
|
||||
|
||||
+65
-58
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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_ */
|
||||
|
||||
+14
-3
@@ -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
|
||||
utf8.c random.c gettimeofday.c timers.c
|
||||
|
||||
# The header files for this library.
|
||||
HSOURCES =
|
||||
@@ -108,7 +109,7 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.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}
|
||||
utf8.o random.o gettimeofday.o timers.o wcsnwidth.o ${LIBOBJS}
|
||||
|
||||
SUPPORT = Makefile
|
||||
|
||||
@@ -197,6 +198,7 @@ strtoul.o: strtoul.c
|
||||
strtoull.o: strtoull.c
|
||||
strtoumax.o: strtoumax.c
|
||||
strtrans.o: strtrans.c
|
||||
timers.o: timers.c
|
||||
times.o: times.c
|
||||
timeval.o: timeval.c
|
||||
tmpfile.o: tmpfile.c
|
||||
@@ -277,6 +279,7 @@ strtoul.o: ${BUILD_DIR}/config.h
|
||||
strtoull.o: ${BUILD_DIR}/config.h
|
||||
strtoumax.o: ${BUILD_DIR}/config.h
|
||||
strtrans.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
|
||||
@@ -620,6 +623,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
|
||||
|
||||
+4
-6
@@ -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;
|
||||
|
||||
+1
-1
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -48,12 +48,7 @@ sh_setlinebuf (stream)
|
||||
#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 */
|
||||
|
||||
setlinebuf (stream);
|
||||
|
||||
+1
-1
@@ -311,7 +311,7 @@ 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. */
|
||||
char *
|
||||
|
||||
+10
-10
@@ -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);
|
||||
|
||||
+3
-6
@@ -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>
|
||||
|
||||
|
||||
+5
-5
@@ -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;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if !defined (HAVE_STRTOL)
|
||||
#if !HAVE_STRTOL
|
||||
|
||||
#include <chartypes.h>
|
||||
#include <errno.h>
|
||||
|
||||
+2
-2
@@ -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 */
|
||||
|
||||
+2
-2
@@ -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 */
|
||||
|
||||
+5
-5
@@ -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;
|
||||
|
||||
+262
@@ -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;
|
||||
}
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+8
-2
@@ -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
|
||||
}
|
||||
|
||||
+5
-1
@@ -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;
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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) $<
|
||||
|
||||
+5
-17
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user