mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-27 15:43:18 +02:00
commit bash-20120921 snapshot
This commit is contained in:
@@ -3577,3 +3577,48 @@ subst.c,execute_cmd.c,lib/glob/sm_loop.c,lib/sh/shquote.c
|
||||
lib/readline/colors.h
|
||||
- workaround for HP NonStop compiler issue with <stdbool.h> from
|
||||
Joachim Schmitz <jojo@schmitz-digital.de>
|
||||
|
||||
9/17
|
||||
----
|
||||
builtins/printf.def
|
||||
- printf_builtin: handle localtime returning NULL, as can happen when
|
||||
encountering overflow. Bug report and initial fix from
|
||||
Eduardo A. Bustamante López <dualbus@gmail.com>
|
||||
|
||||
doc/{bash.1,bashref.texi}
|
||||
- emphasize that brace expansion using character ranges ({a..c}) acts
|
||||
as if the C locale were in use. Prompted by message from
|
||||
Marcel Giannelia <info@skeena.net>
|
||||
|
||||
9/20
|
||||
----
|
||||
lib/sh/wcsnwidth.c
|
||||
- wcsnwidth: new function, variant of wcwidth, returns the number of
|
||||
wide characters from a string that will be displayed to not exceed
|
||||
a specified max column position
|
||||
|
||||
9/21
|
||||
----
|
||||
builtins/help.def
|
||||
- show_builtin_command_help: break code that displays the short-doc
|
||||
for each builtin in two columns into a new function: dispcolumn
|
||||
- wdispcolumn: multibyte-char version of dispcolumn; uses wide
|
||||
chars and printf "%ls" format. Fixes problem reported by
|
||||
Nguyá»n Thái Ngá»c Duy <pclouds@gmail.c
|
||||
|
||||
9/22
|
||||
----
|
||||
execute_cmd.c
|
||||
- execute_disk_command: before running the command-not-found hook,
|
||||
call kill_current_pipeline() to make sure we don't add processes
|
||||
to an existing pipeline or wait for processes erroneously
|
||||
|
||||
9/23
|
||||
----
|
||||
lib/readline/input.c
|
||||
- rl_input_available_hook: new hook function, called from
|
||||
_rl_input_available (or _rl_input_queued) to return whether or not
|
||||
input is available wherever the input source is
|
||||
|
||||
lib/readline/doc/rltech.texi
|
||||
- rl_input_available_hook: document
|
||||
|
||||
@@ -3573,3 +3573,42 @@ configure.ac
|
||||
----
|
||||
subst.c,execute_cmd.c,lib/glob/sm_loop.c,lib/sh/shquote.c
|
||||
- minor code cleanups from Joachim Schmitz <jojo@schmitz-digital.de>
|
||||
|
||||
lib/readline/colors.h
|
||||
- workaround for HP NonStop compiler issue with <stdbool.h> from
|
||||
Joachim Schmitz <jojo@schmitz-digital.de>
|
||||
|
||||
9/17
|
||||
----
|
||||
builtins/printf.def
|
||||
- printf_builtin: handle localtime returning NULL, as can happen when
|
||||
encountering overflow. Bug report and initial fix from
|
||||
Eduardo A. Bustamante López <dualbus@gmail.com>
|
||||
|
||||
doc/{bash.1,bashref.texi}
|
||||
- emphasize that brace expansion using character ranges ({a..c}) acts
|
||||
as if the C locale were in use. Prompted by message from
|
||||
Marcel Giannelia <info@skeena.net>
|
||||
|
||||
9/20
|
||||
----
|
||||
lib/sh/wcsnwidth.c
|
||||
- wcsnwidth: new function, variant of wcwidth, returns the number of
|
||||
wide characters from a string that will be displayed to not exceed
|
||||
a specified max column position
|
||||
|
||||
9/21
|
||||
----
|
||||
builtins/help.def
|
||||
- show_builtin_command_help: break code that displays the short-doc
|
||||
for each builtin in two columns into a new function: dispcolumn
|
||||
- wdispcolumn: multibyte-char version of dispcolumn; uses wide
|
||||
chars and printf "%ls" format. Fixes problem reported by
|
||||
Nguyá»n Thái Ngá»c Duy <pclouds@gmail.c
|
||||
|
||||
9/22
|
||||
----
|
||||
execute_cmd.c
|
||||
- execute_disk_command: before running the command-not-found hook,
|
||||
call kill_current_pipeline() to make sure we don't add processes
|
||||
to an existing pipeline or wait for processes erroneously
|
||||
|
||||
@@ -450,6 +450,7 @@ lib/sh/ufuncs.c f
|
||||
lib/sh/unicode.c f
|
||||
lib/sh/vprint.c f
|
||||
lib/sh/wcsdup.c f
|
||||
lib/sh/wcsnwidth.c f
|
||||
lib/sh/wcswidth.c f
|
||||
lib/sh/winsize.c f
|
||||
lib/sh/zcatfd.c f
|
||||
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
# Makefile for bash-4.2, version 4.8
|
||||
# Makefile for bash-4.2, version 4.9
|
||||
#
|
||||
# Copyright (C) 1996-2012 Free Software Foundation, Inc.
|
||||
|
||||
@@ -215,7 +215,8 @@ SHLIB_SOURCE = ${SH_LIBSRC}/clktck.c ${SH_LIBSRC}/getcwd.c \
|
||||
${SH_LIBSRC}/ufuncs.c ${SH_LIBSRC}/dprintf.c \
|
||||
${SH_LIBSRC}/input_avail.c ${SH_LIBSRC}/mbscasecmp.c \
|
||||
${SH_LIBSRC}/fnxform.c ${SH_LIBSRC}/unicode.c \
|
||||
${SH_LIBSRC}/wcswidth.c ${SH_LIBSRC}/shmbchar.c
|
||||
${SH_LIBSRC}/wcswidth.c ${SH_LIBSRC}/wcsnwidth.c \
|
||||
${SH_LIBSRC}/shmbchar.c
|
||||
|
||||
SHLIB_LIB = -lsh
|
||||
SHLIB_LIBNAME = libsh.a
|
||||
|
||||
+141
-23
@@ -1,7 +1,7 @@
|
||||
This file is help.def, from which is created help.c.
|
||||
It implements the builtin "help" in Bash.
|
||||
|
||||
Copyright (C) 1987-2011 Free Software Foundation, Inc.
|
||||
Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
@@ -326,6 +326,140 @@ show_manpage (name, i)
|
||||
free (line);
|
||||
}
|
||||
|
||||
static void
|
||||
dispcolumn (i, buf, bufsize, width, height)
|
||||
int i;
|
||||
char *buf;
|
||||
size_t bufsize;
|
||||
int width, height;
|
||||
{
|
||||
int j;
|
||||
int displen;
|
||||
char *helpdoc;
|
||||
|
||||
/* first column */
|
||||
helpdoc = _(shell_builtins[i].short_doc);
|
||||
|
||||
buf[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
|
||||
strncpy (buf + 1, helpdoc, width - 2);
|
||||
buf[width - 2] = '>'; /* indicate truncation */
|
||||
buf[width - 1] = '\0';
|
||||
printf ("%s", buf);
|
||||
if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
|
||||
{
|
||||
printf ("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
displen = strlen (buf);
|
||||
/* two spaces */
|
||||
for (j = displen; j < width; j++)
|
||||
putc (' ', stdout);
|
||||
|
||||
/* second column */
|
||||
helpdoc = _(shell_builtins[i+height].short_doc);
|
||||
|
||||
buf[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*';
|
||||
strncpy (buf + 1, helpdoc, width - 3);
|
||||
buf[width - 3] = '>'; /* indicate truncation */
|
||||
buf[width - 2] = '\0';
|
||||
|
||||
printf ("%s\n", buf);
|
||||
}
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static void
|
||||
wdispcolumn (i, buf, bufsize, width, height)
|
||||
int i;
|
||||
char *buf;
|
||||
size_t bufsize;
|
||||
int width, height;
|
||||
{
|
||||
int j;
|
||||
int displen;
|
||||
char *helpdoc;
|
||||
wchar_t *wcstr;
|
||||
size_t slen, n;
|
||||
int wclen;
|
||||
|
||||
/* first column */
|
||||
helpdoc = _(shell_builtins[i].short_doc);
|
||||
|
||||
wcstr = 0;
|
||||
slen = mbstowcs ((wchar_t *)0, helpdoc, 0);
|
||||
if (slen == -1)
|
||||
{
|
||||
dispcolumn (i, buf, bufsize, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
/* No bigger than the passed max width */
|
||||
if (slen >= width)
|
||||
slen = width - 2;
|
||||
wcstr = (wchar_t *)xmalloc (sizeof (wchar_t) * (width + 2));
|
||||
n = mbstowcs (wcstr+1, helpdoc, slen + 1);
|
||||
wcstr[n+1] = L'\0';
|
||||
|
||||
/* Turn tabs and newlines into spaces for column display, since wcwidth
|
||||
returns -1 for them */
|
||||
for (j = 1; j < n; j++)
|
||||
if (wcstr[j] == L'\n' || wcstr[j] == L'\t')
|
||||
wcstr[j] = L' ';
|
||||
|
||||
displen = wcsnwidth (wcstr+1, slen, width - 2) + 1; /* +1 for ' ' or '*' */
|
||||
|
||||
wcstr[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? L' ' : L'*';
|
||||
|
||||
/* This assumes each wide char takes up one column position when displayed */
|
||||
wcstr[width - 2] = L'>'; /* indicate truncation */
|
||||
wcstr[width - 1] = L'\0';
|
||||
|
||||
printf ("%ls", wcstr);
|
||||
if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
|
||||
{
|
||||
printf ("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* at least one space */
|
||||
for (j = displen; j < width; j++)
|
||||
putc (' ', stdout);
|
||||
|
||||
/* second column */
|
||||
helpdoc = _(shell_builtins[i+height].short_doc);
|
||||
slen = mbstowcs ((wchar_t *)0, helpdoc, 0);
|
||||
if (slen == -1)
|
||||
{
|
||||
/* for now */
|
||||
printf ("%c%s\n", (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*', helpdoc);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reuse wcstr since it is already width wide chars long */
|
||||
if (slen >= width)
|
||||
slen = width - 2;
|
||||
n = mbstowcs (wcstr+1, helpdoc, slen + 1);
|
||||
wcstr[n+1] = L'\0'; /* make sure null-terminated */
|
||||
|
||||
/* Turn tabs and newlines into spaces for column display */
|
||||
for (j = 1; j < n; j++)
|
||||
if (wcstr[j] == L'\n' || wcstr[j] == L'\t')
|
||||
wcstr[j] = L' ';
|
||||
|
||||
displen = wcsnwidth (wcstr+1, slen, width - 2);
|
||||
|
||||
wcstr[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? L' ' : L'*';
|
||||
|
||||
/* This assumes each wide char takes up one column position when displayed */
|
||||
wcstr[width - 3] = L'>'; /* indicate truncation */
|
||||
wcstr[width - 2] = L'\0';
|
||||
|
||||
printf ("%ls\n", wcstr);
|
||||
|
||||
free (wcstr);
|
||||
}
|
||||
#endif /* HANDLE_MULTIBYTE */
|
||||
|
||||
static void
|
||||
show_builtin_command_help ()
|
||||
{
|
||||
@@ -358,28 +492,12 @@ A star (*) next to a name means that the command is disabled.\n\
|
||||
{
|
||||
QUIT;
|
||||
|
||||
/* first column */
|
||||
blurb[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
|
||||
strncpy (blurb + 1, _(shell_builtins[i].short_doc), width - 2);
|
||||
blurb[width - 2] = '>'; /* indicate truncation */
|
||||
blurb[width - 1] = '\0';
|
||||
printf ("%s", blurb);
|
||||
if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
|
||||
{
|
||||
printf ("\n");
|
||||
break;
|
||||
}
|
||||
|
||||
/* two spaces */
|
||||
for (j = strlen (blurb); j < width; j++)
|
||||
putc (' ', stdout);
|
||||
|
||||
/* second column */
|
||||
blurb[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*';
|
||||
strncpy (blurb + 1, _(shell_builtins[i+height].short_doc), width - 3);
|
||||
blurb[width - 3] = '>'; /* indicate truncation */
|
||||
blurb[width - 2] = '\0';
|
||||
printf ("%s\n", blurb);
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1)
|
||||
wdispcolumn (i, blurb, sizeof (blurb), width, height);
|
||||
else
|
||||
#endif
|
||||
dispcolumn (i, blurb, sizeof (blurb), width, height);
|
||||
}
|
||||
}
|
||||
#endif /* HELP_BUILTIN */
|
||||
|
||||
@@ -0,0 +1,479 @@
|
||||
This file is help.def, from which is created help.c.
|
||||
It implements the builtin "help" in Bash.
|
||||
|
||||
Copyright (C) 1987-2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$PRODUCES help.c
|
||||
|
||||
$BUILTIN help
|
||||
$FUNCTION help_builtin
|
||||
$DEPENDS_ON HELP_BUILTIN
|
||||
$SHORT_DOC help [-dms] [pattern ...]
|
||||
Display information about builtin commands.
|
||||
|
||||
Displays brief summaries of builtin commands. If PATTERN is
|
||||
specified, gives detailed help on all commands matching PATTERN,
|
||||
otherwise the list of help topics is printed.
|
||||
|
||||
Options:
|
||||
-d output short description for each topic
|
||||
-m display usage in pseudo-manpage format
|
||||
-s output only a short usage synopsis for each topic matching
|
||||
PATTERN
|
||||
|
||||
Arguments:
|
||||
PATTERN Pattern specifiying a help topic
|
||||
|
||||
Exit Status:
|
||||
Returns success unless PATTERN is not found or an invalid option is given.
|
||||
$END
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if defined (HELP_BUILTIN)
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <filecntl.h>
|
||||
|
||||
#include "../bashintl.h"
|
||||
|
||||
#include "../shell.h"
|
||||
#include "../builtins.h"
|
||||
#include "../pathexp.h"
|
||||
#include "common.h"
|
||||
#include "bashgetopt.h"
|
||||
|
||||
#include <glob/strmatch.h>
|
||||
#include <glob/glob.h>
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
||||
extern const char * const bash_copyright;
|
||||
extern const char * const bash_license;
|
||||
|
||||
static void show_builtin_command_help __P((void));
|
||||
static int open_helpfile __P((char *));
|
||||
static void show_desc __P((char *, int));
|
||||
static void show_manpage __P((char *, int));
|
||||
static void show_longdoc __P((int));
|
||||
|
||||
/* Print out a list of the known functions in the shell, and what they do.
|
||||
If LIST is supplied, print out the list which matches for each pattern
|
||||
specified. */
|
||||
int
|
||||
help_builtin (list)
|
||||
WORD_LIST *list;
|
||||
{
|
||||
register int i;
|
||||
char *pattern, *name;
|
||||
int plen, match_found, sflag, dflag, mflag;
|
||||
|
||||
dflag = sflag = mflag = 0;
|
||||
reset_internal_getopt ();
|
||||
while ((i = internal_getopt (list, "dms")) != -1)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 'd':
|
||||
dflag = 1;
|
||||
break;
|
||||
case 'm':
|
||||
mflag = 1;
|
||||
break;
|
||||
case 's':
|
||||
sflag = 1;
|
||||
break;
|
||||
default:
|
||||
builtin_usage ();
|
||||
return (EX_USAGE);
|
||||
}
|
||||
}
|
||||
list = loptend;
|
||||
|
||||
if (list == 0)
|
||||
{
|
||||
show_shell_version (0);
|
||||
show_builtin_command_help ();
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
/* We should consider making `help bash' do something. */
|
||||
|
||||
if (glob_pattern_p (list->word->word))
|
||||
{
|
||||
printf (ngettext ("Shell commands matching keyword `", "Shell commands matching keywords `", (list->next ? 2 : 1)));
|
||||
print_word_list (list, ", ");
|
||||
printf ("'\n\n");
|
||||
}
|
||||
|
||||
for (match_found = 0, pattern = ""; list; list = list->next)
|
||||
{
|
||||
pattern = list->word->word;
|
||||
plen = strlen (pattern);
|
||||
|
||||
for (i = 0; name = shell_builtins[i].name; i++)
|
||||
{
|
||||
QUIT;
|
||||
if ((strcmp (pattern, name) == 0) ||
|
||||
(strmatch (pattern, name, FNMATCH_EXTFLAG) != FNM_NOMATCH))
|
||||
{
|
||||
match_found++;
|
||||
if (dflag)
|
||||
{
|
||||
show_desc (name, i);
|
||||
continue;
|
||||
}
|
||||
else if (mflag)
|
||||
{
|
||||
show_manpage (name, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
printf ("%s: %s\n", name, _(shell_builtins[i].short_doc));
|
||||
|
||||
if (sflag == 0)
|
||||
show_longdoc (i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (match_found == 0)
|
||||
{
|
||||
builtin_error (_("no help topics match `%s'. Try `help help' or `man -k %s' or `info %s'."), pattern, pattern, pattern);
|
||||
return (EXECUTION_FAILURE);
|
||||
}
|
||||
|
||||
fflush (stdout);
|
||||
return (EXECUTION_SUCCESS);
|
||||
}
|
||||
|
||||
static int
|
||||
open_helpfile (name)
|
||||
char *name;
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open (name, O_RDONLY);
|
||||
if (fd == -1)
|
||||
{
|
||||
builtin_error (_("%s: cannot open: %s"), name, strerror (errno));
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* By convention, enforced by mkbuiltins.c, if separate help files are being
|
||||
used, the long_doc array contains one string -- the full pathname of the
|
||||
help file for this builtin. */
|
||||
static void
|
||||
show_longdoc (i)
|
||||
int i;
|
||||
{
|
||||
register int j;
|
||||
char * const *doc;
|
||||
int fd;
|
||||
|
||||
doc = shell_builtins[i].long_doc;
|
||||
|
||||
if (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL)
|
||||
{
|
||||
fd = open_helpfile (doc[0]);
|
||||
if (fd < 0)
|
||||
return;
|
||||
zcatfd (fd, 1, doc[0]);
|
||||
close (fd);
|
||||
}
|
||||
else if (doc)
|
||||
for (j = 0; doc[j]; j++)
|
||||
printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j]));
|
||||
}
|
||||
|
||||
static void
|
||||
show_desc (name, i)
|
||||
char *name;
|
||||
int i;
|
||||
{
|
||||
register int j;
|
||||
char **doc, *line;
|
||||
int fd, usefile;
|
||||
|
||||
doc = (char **)shell_builtins[i].long_doc;
|
||||
|
||||
usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL);
|
||||
if (usefile)
|
||||
{
|
||||
fd = open_helpfile (doc[0]);
|
||||
if (fd < 0)
|
||||
return;
|
||||
zmapfd (fd, &line, doc[0]);
|
||||
close (fd);
|
||||
}
|
||||
else
|
||||
line = doc ? doc[0] : (char *)NULL;
|
||||
|
||||
printf ("%s - ", name);
|
||||
for (j = 0; line && line[j]; j++)
|
||||
{
|
||||
putchar (line[j]);
|
||||
if (line[j] == '\n')
|
||||
break;
|
||||
}
|
||||
|
||||
fflush (stdout);
|
||||
|
||||
if (usefile)
|
||||
free (line);
|
||||
}
|
||||
|
||||
/* Print builtin help in pseudo-manpage format. */
|
||||
static void
|
||||
show_manpage (name, i)
|
||||
char *name;
|
||||
int i;
|
||||
{
|
||||
register int j;
|
||||
char **doc, *line;
|
||||
int fd, usefile;
|
||||
|
||||
doc = (char **)shell_builtins[i].long_doc;
|
||||
|
||||
usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL);
|
||||
if (usefile)
|
||||
{
|
||||
fd = open_helpfile (doc[0]);
|
||||
if (fd < 0)
|
||||
return;
|
||||
zmapfd (fd, &line, doc[0]);
|
||||
close (fd);
|
||||
}
|
||||
else
|
||||
line = doc ? _(doc[0]) : (char *)NULL;
|
||||
|
||||
/* NAME */
|
||||
printf ("NAME\n");
|
||||
printf ("%*s%s - ", BASE_INDENT, " ", name);
|
||||
for (j = 0; line && line[j]; j++)
|
||||
{
|
||||
putchar (line[j]);
|
||||
if (line[j] == '\n')
|
||||
break;
|
||||
}
|
||||
printf ("\n");
|
||||
|
||||
/* SYNOPSIS */
|
||||
printf ("SYNOPSIS\n");
|
||||
printf ("%*s%s\n\n", BASE_INDENT, " ", _(shell_builtins[i].short_doc));
|
||||
|
||||
/* DESCRIPTION */
|
||||
printf ("DESCRIPTION\n");
|
||||
if (usefile == 0)
|
||||
{
|
||||
for (j = 0; doc[j]; j++)
|
||||
printf ("%*s%s\n", BASE_INDENT, " ", _(doc[j]));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (j = 0; line && line[j]; j++)
|
||||
{
|
||||
putchar (line[j]);
|
||||
if (line[j] == '\n')
|
||||
printf ("%*s", BASE_INDENT, " ");
|
||||
}
|
||||
}
|
||||
putchar ('\n');
|
||||
|
||||
/* SEE ALSO */
|
||||
printf ("SEE ALSO\n");
|
||||
printf ("%*sbash(1)\n\n", BASE_INDENT, " ");
|
||||
|
||||
/* IMPLEMENTATION */
|
||||
printf ("IMPLEMENTATION\n");
|
||||
printf ("%*s", BASE_INDENT, " ");
|
||||
show_shell_version (0);
|
||||
printf ("%*s", BASE_INDENT, " ");
|
||||
printf ("%s\n", _(bash_copyright));
|
||||
printf ("%*s", BASE_INDENT, " ");
|
||||
printf ("%s\n", _(bash_license));
|
||||
|
||||
fflush (stdout);
|
||||
if (usefile)
|
||||
free (line);
|
||||
}
|
||||
|
||||
static void
|
||||
dispcolumn (i, buf, bufsize, width, height)
|
||||
int i;
|
||||
char *buf;
|
||||
size_t bufsize;
|
||||
int width, height;
|
||||
{
|
||||
int j;
|
||||
int displen;
|
||||
char *helpdoc;
|
||||
|
||||
/* first column */
|
||||
helpdoc = _(shell_builtins[i].short_doc);
|
||||
|
||||
buf[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? ' ' : '*';
|
||||
strncpy (buf + 1, helpdoc, width - 2);
|
||||
buf[width - 2] = '>'; /* indicate truncation */
|
||||
buf[width - 1] = '\0';
|
||||
printf ("%s", buf);
|
||||
if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
|
||||
{
|
||||
printf ("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
displen = strlen (buf);
|
||||
/* two spaces */
|
||||
for (j = displen; j < width; j++)
|
||||
putc (' ', stdout);
|
||||
|
||||
/* second column */
|
||||
helpdoc = _(shell_builtins[i+height].short_doc);
|
||||
|
||||
buf[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*';
|
||||
strncpy (buf + 1, helpdoc, width - 3);
|
||||
buf[width - 3] = '>'; /* indicate truncation */
|
||||
buf[width - 2] = '\0';
|
||||
|
||||
printf ("%s\n", buf);
|
||||
}
|
||||
|
||||
static void
|
||||
wdispcolumn (i, buf, bufsize, width, height)
|
||||
int i;
|
||||
char *buf;
|
||||
size_t bufsize;
|
||||
int width, height;
|
||||
{
|
||||
int j;
|
||||
int displen;
|
||||
char *helpdoc;
|
||||
wchar_t *wcstr;
|
||||
size_t slen;
|
||||
int wclen;
|
||||
|
||||
/* first column */
|
||||
helpdoc = _(shell_builtins[i].short_doc);
|
||||
|
||||
wcstr = 0;
|
||||
slen = mbstowcs ((wchar_t *)0, helpdoc, 0);
|
||||
if (slen == -1)
|
||||
{
|
||||
dispcolumn (i, buf, bufsize, width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
/* No bigger than the passed max width */
|
||||
if (slen >= width)
|
||||
slen = width - 1;
|
||||
wcstr = (wchar_t *)xmalloc (sizeof (wchar_t) * (width + 2));
|
||||
mbstowcs (wcstr+1, helpdoc, slen + 1);
|
||||
|
||||
displen = wcsnwidth (wcstr+1, slen, width - 2);
|
||||
|
||||
wcstr[0] = (shell_builtins[i].flags & BUILTIN_ENABLED) ? L' ' : L'*';
|
||||
|
||||
wcstr[width - 2] = L'>'; /* indicate truncation */
|
||||
wcstr[width - 1] = L'\0';
|
||||
printf ("%ls", wcstr);
|
||||
if (((i << 1) >= num_shell_builtins) || (i+height >= num_shell_builtins))
|
||||
{
|
||||
printf ("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* two spaces */
|
||||
for (j = displen; j < width; j++)
|
||||
putc (' ', stdout);
|
||||
|
||||
/* second column */
|
||||
helpdoc = _(shell_builtins[i+height].short_doc);
|
||||
slen = mbstowcs ((wchar_t *)0, helpdoc, 0);
|
||||
if (slen == -1)
|
||||
{
|
||||
/* for now */
|
||||
printf ("%c%s\n", (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? ' ' : '*', helpdoc);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reuse wcstr since it is already width wide chars long */
|
||||
if (slen >= width)
|
||||
slen = width - 1;
|
||||
mbstowcs (wcstr+1, helpdoc, slen + 1);
|
||||
|
||||
displen = wcsnwidth (wcstr+1, slen, width - 3);
|
||||
|
||||
wcstr[0] = (shell_builtins[i+height].flags & BUILTIN_ENABLED) ? L' ' : L'*';
|
||||
|
||||
wcstr[width - 3] = L'>'; /* indicate truncation */
|
||||
wcstr[width - 2] = L'\0';
|
||||
printf ("%ls\n", wcstr);
|
||||
|
||||
free (wcstr);
|
||||
}
|
||||
|
||||
static void
|
||||
show_builtin_command_help ()
|
||||
{
|
||||
int i, j;
|
||||
int height, width;
|
||||
char *t, blurb[128];
|
||||
|
||||
printf (
|
||||
_("These shell commands are defined internally. Type `help' to see this list.\n\
|
||||
Type `help name' to find out more about the function `name'.\n\
|
||||
Use `info bash' to find out more about the shell in general.\n\
|
||||
Use `man -k' or `info' to find out more about commands not in this list.\n\
|
||||
\n\
|
||||
A star (*) next to a name means that the command is disabled.\n\
|
||||
\n"));
|
||||
|
||||
t = get_string_value ("COLUMNS");
|
||||
width = (t && *t) ? atoi (t) : 80;
|
||||
if (width <= 0)
|
||||
width = 80;
|
||||
|
||||
width /= 2;
|
||||
if (width > sizeof (blurb))
|
||||
width = sizeof (blurb);
|
||||
if (width <= 3)
|
||||
width = 40;
|
||||
height = (num_shell_builtins + 1) / 2; /* number of rows */
|
||||
|
||||
for (i = 0; i < height; i++)
|
||||
{
|
||||
QUIT;
|
||||
|
||||
wdispcolumn (i, blurb, sizeof (blurb), width, height);
|
||||
}
|
||||
}
|
||||
#endif /* HELP_BUILTIN */
|
||||
+6
-1
@@ -472,7 +472,12 @@ printf_builtin (list)
|
||||
sv_tz ("TZ"); /* XXX -- just make sure */
|
||||
#endif
|
||||
tm = localtime (&secs);
|
||||
n = strftime (timebuf, sizeof (timebuf), timefmt, tm);
|
||||
if (tm == 0)
|
||||
{
|
||||
secs = 0;
|
||||
tm = localtime (&secs);
|
||||
}
|
||||
n = tm ? strftime (timebuf, sizeof (timebuf), timefmt, tm) : 0;
|
||||
free (timefmt);
|
||||
if (n == 0)
|
||||
timebuf[0] = '\0';
|
||||
|
||||
+8
-6
@@ -5,12 +5,12 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet@po.cwru.edu
|
||||
.\"
|
||||
.\" Last Change: Tue Aug 28 17:20:54 EDT 2012
|
||||
.\" Last Change: Mon Sep 17 09:26:34 EDT 2012
|
||||
.\"
|
||||
.\" bash_builtins, strip all but Built-Ins section
|
||||
.if \n(zZ=1 .ig zZ
|
||||
.if \n(zY=1 .ig zY
|
||||
.TH BASH 1 "2012 August 28" "GNU Bash 4.2"
|
||||
.TH BASH 1 "2012 September 17" "GNU Bash 4.2"
|
||||
.\"
|
||||
.\" There's some problem with having a `@'
|
||||
.\" in a tagged paragraph with the BSD man macros.
|
||||
@@ -2600,12 +2600,14 @@ and \fIincr\fP, an optional increment, is an integer.
|
||||
When integers are supplied, the expression expands to each number between
|
||||
\fIx\fP and \fIy\fP, inclusive.
|
||||
Supplied integers may be prefixed with \fI0\fP to force each term to have the
|
||||
same width. When either \fIx\fP or \fPy\fP begins with a zero, the shell
|
||||
same width.
|
||||
When either \fIx\fP or \fPy\fP begins with a zero, the shell
|
||||
attempts to force all generated terms to contain the same number of digits,
|
||||
zero-padding where necessary.
|
||||
When characters are supplied, the expression expands to each character
|
||||
lexicographically between \fIx\fP and \fIy\fP, inclusive. Note that
|
||||
both \fIx\fP and \fIy\fP must be of the same type.
|
||||
lexicographically between \fIx\fP and \fIy\fP, inclusive,
|
||||
using the default C locale.
|
||||
Note that both \fIx\fP and \fIy\fP must be of the same type.
|
||||
When the increment is supplied, it is used as the difference between
|
||||
each term. The default increment is 1 or -1 as appropriate.
|
||||
.PP
|
||||
@@ -3347,7 +3349,7 @@ Matches any single character.
|
||||
Matches any one of the enclosed characters. A pair of characters
|
||||
separated by a hyphen denotes a
|
||||
\fIrange expression\fP;
|
||||
any character that sorts between those two characters, inclusive,
|
||||
any character that falls between those two characters, inclusive,
|
||||
using the current locale's collating sequence and character set,
|
||||
is matched. If the first character following the
|
||||
.B [
|
||||
|
||||
+6
-4
@@ -1678,12 +1678,14 @@ and @var{incr}, an optional increment, is an integer.
|
||||
When integers are supplied, the expression expands to each number between
|
||||
@var{x} and @var{y}, inclusive.
|
||||
Supplied integers may be prefixed with @samp{0} to force each term to have the
|
||||
same width. When either @var{x} or @var{y} begins with a zero, the shell
|
||||
same width.
|
||||
When either @var{x} or @var{y} begins with a zero, the shell
|
||||
attempts to force all generated terms to contain the same number of digits,
|
||||
zero-padding where necessary.
|
||||
When characters are supplied, the expression expands to each character
|
||||
lexicographically between @var{x} and @var{y}, inclusive. Note that
|
||||
both @var{x} and @var{y} must be of the same type.
|
||||
lexicographically between @var{x} and @var{y}, inclusive,
|
||||
using the default C locale.
|
||||
Note that both @var{x} and @var{y} must be of the same type.
|
||||
When the increment is supplied, it is used as the difference between
|
||||
each term. The default increment is 1 or -1 as appropriate.
|
||||
|
||||
@@ -2334,7 +2336,7 @@ Matches any single character.
|
||||
@item [@dots{}]
|
||||
Matches any one of the enclosed characters. A pair of characters
|
||||
separated by a hyphen denotes a @var{range expression};
|
||||
any character that sorts between those two characters, inclusive,
|
||||
any character that falls between those two characters, inclusive,
|
||||
using the current locale's collating sequence and character set,
|
||||
is matched. If the first character following the
|
||||
@samp{[} is a @samp{!} or a @samp{^}
|
||||
|
||||
+2
-2
@@ -2,9 +2,9 @@
|
||||
Copyright (C) 1988-2012 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set LASTCHANGE Thu Sep 13 17:12:28 EDT 2012
|
||||
@set LASTCHANGE Mon Sep 17 09:26:53 EDT 2012
|
||||
|
||||
@set EDITION 4.2
|
||||
@set VERSION 4.2
|
||||
@set UPDATED 13 September 2012
|
||||
@set UPDATED 17 September 2012
|
||||
@set UPDATED-MONTH September 2012
|
||||
|
||||
+8
-4
@@ -714,7 +714,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
|
||||
dispose_exec_redirects ();
|
||||
#if defined (PROCESS_SUBSTITUTION)
|
||||
if (saved_fifo)
|
||||
free (ofifo_list);
|
||||
free ((void *)ofifo_list);
|
||||
#endif
|
||||
return (last_command_exit_value = EXECUTION_FAILURE);
|
||||
}
|
||||
@@ -1018,7 +1018,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
|
||||
nfifo = num_fifos ();
|
||||
if (nfifo > ofifo)
|
||||
close_new_fifos ((char *)ofifo_list, osize);
|
||||
free (ofifo_list);
|
||||
free ((void *)ofifo_list);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2859,7 +2859,8 @@ displen (s)
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
wchar_t *wcstr;
|
||||
size_t wclen, slen;
|
||||
size_t slen;
|
||||
int wclen;
|
||||
|
||||
wcstr = 0;
|
||||
slen = mbstowcs (wcstr, s, 0);
|
||||
@@ -2869,7 +2870,7 @@ displen (s)
|
||||
mbstowcs (wcstr, s, slen + 1);
|
||||
wclen = wcswidth (wcstr, slen);
|
||||
free (wcstr);
|
||||
return ((int)wclen);
|
||||
return (wclen < 0 ? STRLEN(s) : wclen);
|
||||
#else
|
||||
return (STRLEN (s));
|
||||
#endif
|
||||
@@ -4899,6 +4900,9 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
|
||||
exit (EX_NOTFOUND); /* Posix.2 says the exit status is 127 */
|
||||
}
|
||||
|
||||
/* May need to reinitialize more of the job control state here. */
|
||||
kill_current_pipeline ();
|
||||
|
||||
wl = make_word_list (make_word (NOTFOUND_HOOK), words);
|
||||
exit (execute_shell_function (hookf, wl));
|
||||
}
|
||||
|
||||
+10
-6
@@ -698,7 +698,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
|
||||
if (variable_context != 0)
|
||||
{
|
||||
ofifo = num_fifos ();
|
||||
ofifo_list = copy_fifo_list (&osize);
|
||||
ofifo_list = copy_fifo_list ((int *)&osize);
|
||||
saved_fifo = 1;
|
||||
}
|
||||
else
|
||||
@@ -714,7 +714,7 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
|
||||
dispose_exec_redirects ();
|
||||
#if defined (PROCESS_SUBSTITUTION)
|
||||
if (saved_fifo)
|
||||
free (ofifo_list);
|
||||
free ((void *)ofifo_list);
|
||||
#endif
|
||||
return (last_command_exit_value = EXECUTION_FAILURE);
|
||||
}
|
||||
@@ -1017,8 +1017,8 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
|
||||
{
|
||||
nfifo = num_fifos ();
|
||||
if (nfifo > ofifo)
|
||||
close_new_fifos (ofifo_list, osize);
|
||||
free (ofifo_list);
|
||||
close_new_fifos ((char *)ofifo_list, osize);
|
||||
free ((void *)ofifo_list);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2859,7 +2859,8 @@ displen (s)
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
wchar_t *wcstr;
|
||||
size_t wclen, slen;
|
||||
size_t slen;
|
||||
int wclen;
|
||||
|
||||
wcstr = 0;
|
||||
slen = mbstowcs (wcstr, s, 0);
|
||||
@@ -2869,7 +2870,7 @@ displen (s)
|
||||
mbstowcs (wcstr, s, slen + 1);
|
||||
wclen = wcswidth (wcstr, slen);
|
||||
free (wcstr);
|
||||
return ((int)wclen);
|
||||
return (wclen < 0 ? STRLEN(s) : wclen);
|
||||
#else
|
||||
return (STRLEN (s));
|
||||
#endif
|
||||
@@ -4899,6 +4900,9 @@ execute_disk_command (words, redirects, command_line, pipe_in, pipe_out,
|
||||
exit (EX_NOTFOUND); /* Posix.2 says the exit status is 127 */
|
||||
}
|
||||
|
||||
/* May need to reinitialize more of the job control state here. */
|
||||
stop_making_children ();
|
||||
|
||||
wl = make_word_list (make_word (NOTFOUND_HOOK), words);
|
||||
exit (execute_shell_function (hookf, wl));
|
||||
}
|
||||
|
||||
@@ -467,6 +467,11 @@ extern unsigned int fsleep __P((unsigned int, unsigned int));
|
||||
extern int u32cconv __P((unsigned long, char *));
|
||||
extern void u32reset __P((void));
|
||||
|
||||
/* declarations for functions defined in lib/sh/wcsnwidth.c */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
extern int wcsnwidth __P((const wchar_t *, size_t, int));
|
||||
#endif
|
||||
|
||||
/* declarations for functions defined in lib/sh/winsize.c */
|
||||
extern void get_new_window_size __P((int, int *, int *));
|
||||
|
||||
|
||||
@@ -442,6 +442,19 @@ to get a character from the input stream. By default, it is set to
|
||||
(@pxref{Character 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
|
||||
source.
|
||||
Readline queries for available input when implementing intra-key-sequence
|
||||
timeouts during input and incremental searches.
|
||||
This may use an application-specific timeout before returning a value;
|
||||
Readline uses the value passed to @code{rl_set_keyboard_input_timeout()}.
|
||||
This is designed for use by functions using Readline's callback interface
|
||||
(@pxref{Alternate Interface}), which may not use the traditional
|
||||
@code{read(2)} and file descriptor interface.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar {rl_voidfunc_t *} rl_redisplay_function
|
||||
If non-zero, Readline will call indirectly through this pointer
|
||||
to update the display with the current contents of the editing buffer.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@ Copyright (C) 1988-2012 Free Software Foundation, Inc.
|
||||
|
||||
@set EDITION 6.2
|
||||
@set VERSION 6.2
|
||||
@set UPDATED 27 August 2012
|
||||
@set UPDATED-MONTH August 2012
|
||||
@set UPDATED 23 September 2012
|
||||
@set UPDATED-MONTH September 2012
|
||||
|
||||
@set LASTCHANGE Mon Aug 27 09:54:01 EDT 2012
|
||||
@set LASTCHANGE Sun Sep 23 19:19:18 EDT 2012
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
@ignore
|
||||
Copyright (C) 1988-2012 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set EDITION 6.2
|
||||
@set VERSION 6.2
|
||||
@set UPDATED 27 August 2012
|
||||
@set UPDATED-MONTH August 2012
|
||||
|
||||
@set LASTCHANGE Mon Aug 27 09:54:01 EDT 2012
|
||||
@@ -80,6 +80,10 @@ extern int errno;
|
||||
character input. */
|
||||
rl_hook_func_t *rl_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;
|
||||
|
||||
rl_getc_func_t *rl_getc_function = rl_getc;
|
||||
|
||||
static int _keyboard_input_timeout = 100000; /* 0.1 seconds; it's in usec */
|
||||
@@ -293,6 +297,9 @@ _rl_input_available ()
|
||||
#endif
|
||||
int tty;
|
||||
|
||||
if (rl_input_available_hook)
|
||||
return (*rl_input_available_hook) ();
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
|
||||
@@ -0,0 +1,611 @@
|
||||
/* input.c -- character input functions for readline. */
|
||||
|
||||
/* Copyright (C) 1994-2011 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (__TANDEM)
|
||||
# include <floss.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#if defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif /* HAVE_SYS_FILE_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#include "posixselect.h"
|
||||
|
||||
#if defined (FIONREAD_IN_SYS_IOCTL)
|
||||
# include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* What kind of non-blocking I/O do we have? */
|
||||
#if !defined (O_NDELAY) && defined (O_NONBLOCK)
|
||||
# define O_NDELAY O_NONBLOCK /* Posix style */
|
||||
#endif
|
||||
|
||||
/* Non-null means it is a pointer to a function to run while waiting for
|
||||
character input. */
|
||||
rl_hook_func_t *rl_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;
|
||||
|
||||
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));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Character Input Buffering */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
static int pop_index, push_index;
|
||||
static unsigned char ibuffer[512];
|
||||
static int ibuffer_len = sizeof (ibuffer) - 1;
|
||||
|
||||
#define any_typein (push_index != pop_index)
|
||||
|
||||
int
|
||||
_rl_any_typein ()
|
||||
{
|
||||
return any_typein;
|
||||
}
|
||||
|
||||
/* Return the amount of space available in the buffer for stuffing
|
||||
characters. */
|
||||
static int
|
||||
ibuffer_space ()
|
||||
{
|
||||
if (pop_index > push_index)
|
||||
return (pop_index - push_index - 1);
|
||||
else
|
||||
return (ibuffer_len - (push_index - pop_index));
|
||||
}
|
||||
|
||||
/* Get a key from the buffer of characters to be read.
|
||||
Return the key in KEY.
|
||||
Result is non-zero if there was a key, or 0 if there wasn't. */
|
||||
static int
|
||||
rl_get_char (key)
|
||||
int *key;
|
||||
{
|
||||
if (push_index == pop_index)
|
||||
return (0);
|
||||
|
||||
*key = ibuffer[pop_index++];
|
||||
#if 0
|
||||
if (pop_index >= ibuffer_len)
|
||||
#else
|
||||
if (pop_index > ibuffer_len)
|
||||
#endif
|
||||
pop_index = 0;
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Stuff KEY into the *front* of the input buffer.
|
||||
Returns non-zero if successful, zero if there is
|
||||
no space left in the buffer. */
|
||||
int
|
||||
_rl_unget_char (key)
|
||||
int key;
|
||||
{
|
||||
if (ibuffer_space ())
|
||||
{
|
||||
pop_index--;
|
||||
if (pop_index < 0)
|
||||
pop_index = ibuffer_len;
|
||||
ibuffer[pop_index] = key;
|
||||
return (1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_rl_pushed_input_available ()
|
||||
{
|
||||
return (push_index != pop_index);
|
||||
}
|
||||
|
||||
/* If a character is available to be read, then read it and stuff it into
|
||||
IBUFFER. Otherwise, just return. Returns number of characters read
|
||||
(0 if none available) and -1 on error (EIO). */
|
||||
static int
|
||||
rl_gather_tyi ()
|
||||
{
|
||||
int tty;
|
||||
register int tem, result;
|
||||
int chars_avail, k;
|
||||
char input;
|
||||
#if defined(HAVE_SELECT)
|
||||
fd_set readfds, exceptfds;
|
||||
struct timeval timeout;
|
||||
#endif
|
||||
|
||||
chars_avail = 0;
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
FD_ZERO (&readfds);
|
||||
FD_ZERO (&exceptfds);
|
||||
FD_SET (tty, &readfds);
|
||||
FD_SET (tty, &exceptfds);
|
||||
USEC_TO_TIMEVAL (_keyboard_input_timeout, timeout);
|
||||
result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
|
||||
if (result <= 0)
|
||||
return 0; /* Nothing to read. */
|
||||
#endif
|
||||
|
||||
result = -1;
|
||||
#if defined (FIONREAD)
|
||||
errno = 0;
|
||||
result = ioctl (tty, FIONREAD, &chars_avail);
|
||||
if (result == -1 && errno == EIO)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
#if defined (O_NDELAY)
|
||||
if (result == -1)
|
||||
{
|
||||
tem = fcntl (tty, F_GETFL, 0);
|
||||
|
||||
fcntl (tty, F_SETFL, (tem | O_NDELAY));
|
||||
chars_avail = read (tty, &input, 1);
|
||||
|
||||
fcntl (tty, F_SETFL, tem);
|
||||
if (chars_avail == -1 && errno == EAGAIN)
|
||||
return 0;
|
||||
if (chars_avail == 0) /* EOF */
|
||||
{
|
||||
rl_stuff_char (EOF);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
#endif /* O_NDELAY */
|
||||
|
||||
#if defined (__MINGW32__)
|
||||
/* Use getch/_kbhit to check for available console input, in the same way
|
||||
that we read it normally. */
|
||||
chars_avail = isatty (tty) ? _kbhit () : 0;
|
||||
result = 0;
|
||||
#endif
|
||||
|
||||
/* If there's nothing available, don't waste time trying to read
|
||||
something. */
|
||||
if (chars_avail <= 0)
|
||||
return 0;
|
||||
|
||||
tem = ibuffer_space ();
|
||||
|
||||
if (chars_avail > tem)
|
||||
chars_avail = tem;
|
||||
|
||||
/* One cannot read all of the available input. I can only read a single
|
||||
character at a time, or else programs which require input can be
|
||||
thwarted. If the buffer is larger than one character, I lose.
|
||||
Damn! */
|
||||
if (tem < ibuffer_len)
|
||||
chars_avail = 0;
|
||||
|
||||
if (result != -1)
|
||||
{
|
||||
while (chars_avail--)
|
||||
{
|
||||
RL_CHECK_SIGNALS ();
|
||||
k = (*rl_getc_function) (rl_instream);
|
||||
if (rl_stuff_char (k) == 0)
|
||||
break; /* some problem; no more room */
|
||||
if (k == NEWLINE || k == RETURN)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chars_avail)
|
||||
rl_stuff_char (input);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
rl_set_keyboard_input_timeout (u)
|
||||
int u;
|
||||
{
|
||||
int o;
|
||||
|
||||
o = _keyboard_input_timeout;
|
||||
if (u >= 0)
|
||||
_keyboard_input_timeout = u;
|
||||
return (o);
|
||||
}
|
||||
|
||||
/* Is there input available to be read on the readline input file
|
||||
descriptor? Only works if the system has select(2) or FIONREAD.
|
||||
Uses the value of _keyboard_input_timeout as the timeout; if another
|
||||
readline function wants to specify a timeout and not leave it up to
|
||||
the user, it should use _rl_input_queued(timeout_value_in_microseconds)
|
||||
instead. */
|
||||
int
|
||||
_rl_input_available ()
|
||||
{
|
||||
#if defined(HAVE_SELECT)
|
||||
fd_set readfds, exceptfds;
|
||||
struct timeval timeout;
|
||||
#endif
|
||||
#if !defined (HAVE_SELECT) && defined(FIONREAD)
|
||||
int chars_avail;
|
||||
#endif
|
||||
int tty;
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
FD_ZERO (&readfds);
|
||||
FD_ZERO (&exceptfds);
|
||||
FD_SET (tty, &readfds);
|
||||
FD_SET (tty, &exceptfds);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = _keyboard_input_timeout;
|
||||
return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
|
||||
#else
|
||||
|
||||
#if defined (FIONREAD)
|
||||
if (ioctl (tty, FIONREAD, &chars_avail) == 0)
|
||||
return (chars_avail);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#if defined (__MINGW32__)
|
||||
if (isatty (tty))
|
||||
return (_kbhit ());
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_input_queued (t)
|
||||
int t;
|
||||
{
|
||||
int old_timeout, r;
|
||||
|
||||
old_timeout = rl_set_keyboard_input_timeout (t);
|
||||
r = _rl_input_available ();
|
||||
rl_set_keyboard_input_timeout (old_timeout);
|
||||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
_rl_insert_typein (c)
|
||||
int c;
|
||||
{
|
||||
int key, t, i;
|
||||
char *string;
|
||||
|
||||
i = key = 0;
|
||||
string = (char *)xmalloc (ibuffer_len + 1);
|
||||
string[i++] = (char) c;
|
||||
|
||||
while ((t = rl_get_char (&key)) &&
|
||||
_rl_keymap[key].type == ISFUNC &&
|
||||
_rl_keymap[key].function == rl_insert)
|
||||
string[i++] = key;
|
||||
|
||||
if (t)
|
||||
_rl_unget_char (key);
|
||||
|
||||
string[i] = '\0';
|
||||
rl_insert_text (string);
|
||||
xfree (string);
|
||||
}
|
||||
|
||||
/* Add KEY to the buffer of characters to be read. Returns 1 if the
|
||||
character was stuffed correctly; 0 otherwise. */
|
||||
int
|
||||
rl_stuff_char (key)
|
||||
int key;
|
||||
{
|
||||
if (ibuffer_space () == 0)
|
||||
return 0;
|
||||
|
||||
if (key == EOF)
|
||||
{
|
||||
key = NEWLINE;
|
||||
rl_pending_input = EOF;
|
||||
RL_SETSTATE (RL_STATE_INPUTPENDING);
|
||||
}
|
||||
ibuffer[push_index++] = key;
|
||||
#if 0
|
||||
if (push_index >= ibuffer_len)
|
||||
#else
|
||||
if (push_index > ibuffer_len)
|
||||
#endif
|
||||
push_index = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Make C be the next command to be executed. */
|
||||
int
|
||||
rl_execute_next (c)
|
||||
int c;
|
||||
{
|
||||
rl_pending_input = c;
|
||||
RL_SETSTATE (RL_STATE_INPUTPENDING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Clear any pending input pushed with rl_execute_next() */
|
||||
int
|
||||
rl_clear_pending_input ()
|
||||
{
|
||||
rl_pending_input = 0;
|
||||
RL_UNSETSTATE (RL_STATE_INPUTPENDING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Character Input */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Read a key, including pending input. */
|
||||
int
|
||||
rl_read_key ()
|
||||
{
|
||||
int c, r;
|
||||
|
||||
if (rl_pending_input)
|
||||
{
|
||||
c = rl_pending_input;
|
||||
rl_clear_pending_input ();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If input is coming from a macro, then use that. */
|
||||
if (c = _rl_next_macro_key ())
|
||||
return (c);
|
||||
|
||||
/* If the user has an event function, then call it periodically. */
|
||||
if (rl_event_hook)
|
||||
{
|
||||
while (rl_event_hook)
|
||||
{
|
||||
if (rl_get_char (&c) != 0)
|
||||
break;
|
||||
|
||||
if ((r = rl_gather_tyi ()) < 0) /* XXX - EIO */
|
||||
{
|
||||
rl_done = 1;
|
||||
return ('\n');
|
||||
}
|
||||
else if (r > 0) /* read something */
|
||||
continue;
|
||||
|
||||
RL_CHECK_SIGNALS ();
|
||||
if (rl_done) /* XXX - experimental */
|
||||
return ('\n');
|
||||
(*rl_event_hook) ();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rl_get_char (&c) == 0)
|
||||
c = (*rl_getc_function) (rl_instream);
|
||||
/* fprintf(stderr, "rl_read_key: calling RL_CHECK_SIGNALS: _rl_caught_signal = %d", _rl_caught_signal); */
|
||||
RL_CHECK_SIGNALS ();
|
||||
}
|
||||
}
|
||||
|
||||
return (c);
|
||||
}
|
||||
|
||||
int
|
||||
rl_getc (stream)
|
||||
FILE *stream;
|
||||
{
|
||||
int result;
|
||||
unsigned char c;
|
||||
|
||||
while (1)
|
||||
{
|
||||
RL_CHECK_SIGNALS ();
|
||||
|
||||
/* We know at this point that _rl_caught_signal == 0 */
|
||||
|
||||
#if defined (__MINGW32__)
|
||||
if (isatty (fileno (stream)))
|
||||
return (getch ());
|
||||
#endif
|
||||
result = read (fileno (stream), &c, sizeof (unsigned char));
|
||||
|
||||
if (result == sizeof (unsigned char))
|
||||
return (c);
|
||||
|
||||
/* If zero characters are returned, then the file that we are
|
||||
reading from is empty! Return EOF in that case. */
|
||||
if (result == 0)
|
||||
return (EOF);
|
||||
|
||||
#if defined (__BEOS__)
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
#if defined (EWOULDBLOCK)
|
||||
# define X_EWOULDBLOCK EWOULDBLOCK
|
||||
#else
|
||||
# define X_EWOULDBLOCK -99
|
||||
#endif
|
||||
|
||||
#if defined (EAGAIN)
|
||||
# define X_EAGAIN EAGAIN
|
||||
#else
|
||||
# define X_EAGAIN -99
|
||||
#endif
|
||||
|
||||
if (errno == X_EWOULDBLOCK || errno == X_EAGAIN)
|
||||
{
|
||||
if (sh_unset_nodelay_mode (fileno (stream)) < 0)
|
||||
return (EOF);
|
||||
continue;
|
||||
}
|
||||
|
||||
#undef X_EWOULDBLOCK
|
||||
#undef X_EAGAIN
|
||||
|
||||
/* If the error that we received was EINTR, then try again,
|
||||
this is simply an interrupted system call to read ().
|
||||
Otherwise, some error ocurred, also signifying EOF. */
|
||||
if (errno != EINTR)
|
||||
return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF);
|
||||
else if (_rl_caught_signal == SIGHUP || _rl_caught_signal == SIGTERM)
|
||||
return (RL_ISSTATE (RL_STATE_READCMD) ? READERR : EOF);
|
||||
else if (rl_event_hook)
|
||||
(*rl_event_hook) ();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
/* read multibyte char */
|
||||
int
|
||||
_rl_read_mbchar (mbchar, size)
|
||||
char *mbchar;
|
||||
int size;
|
||||
{
|
||||
int mb_len, c;
|
||||
size_t mbchar_bytes_length;
|
||||
wchar_t wc;
|
||||
mbstate_t ps, ps_back;
|
||||
|
||||
memset(&ps, 0, sizeof (mbstate_t));
|
||||
memset(&ps_back, 0, sizeof (mbstate_t));
|
||||
|
||||
mb_len = 0;
|
||||
while (mb_len < size)
|
||||
{
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
|
||||
if (c < 0)
|
||||
break;
|
||||
|
||||
mbchar[mb_len++] = c;
|
||||
|
||||
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))
|
||||
{
|
||||
/* shorted bytes */
|
||||
ps = ps_back;
|
||||
continue;
|
||||
}
|
||||
else if (mbchar_bytes_length == 0)
|
||||
{
|
||||
mbchar[0] = '\0'; /* null wide character */
|
||||
mb_len = 1;
|
||||
break;
|
||||
}
|
||||
else if (mbchar_bytes_length > (size_t)(0))
|
||||
break;
|
||||
}
|
||||
|
||||
return mb_len;
|
||||
}
|
||||
|
||||
/* Read a multibyte-character string whose first character is FIRST into
|
||||
the buffer MB of length MLEN. Returns the last character read, which
|
||||
may be FIRST. Used by the search functions, among others. Very similar
|
||||
to _rl_read_mbchar. */
|
||||
int
|
||||
_rl_read_mbstring (first, mb, mlen)
|
||||
int first;
|
||||
char *mb;
|
||||
int mlen;
|
||||
{
|
||||
int i, c;
|
||||
mbstate_t ps;
|
||||
|
||||
c = first;
|
||||
memset (mb, 0, mlen);
|
||||
for (i = 0; c >= 0 && i < mlen; i++)
|
||||
{
|
||||
mb[i] = (char)c;
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
if (_rl_get_char_len (mb, &ps) == -2)
|
||||
{
|
||||
/* Read more for multibyte character */
|
||||
RL_SETSTATE (RL_STATE_MOREINPUT);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE (RL_STATE_MOREINPUT);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
#endif /* HANDLE_MULTIBYTE */
|
||||
@@ -563,6 +563,10 @@ extern rl_hook_func_t *rl_pre_input_hook;
|
||||
awaiting character input, or NULL, for no event handling. */
|
||||
extern rl_hook_func_t *rl_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;
|
||||
|
||||
/* The address of the function to call to fetch a character from the current
|
||||
Readline input stream */
|
||||
extern rl_getc_func_t *rl_getc_function;
|
||||
|
||||
@@ -0,0 +1,907 @@
|
||||
/* Readline.h -- the names of functions callable from within readline. */
|
||||
|
||||
/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library (Readline), a library
|
||||
for reading lines of text with interactive input and history editing.
|
||||
|
||||
Readline is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Readline is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Readline. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#if !defined (_READLINE_H_)
|
||||
#define _READLINE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined (READLINE_LIBRARY)
|
||||
# include "rlstdc.h"
|
||||
# include "rltypedefs.h"
|
||||
# include "keymaps.h"
|
||||
# include "tilde.h"
|
||||
#else
|
||||
# include <readline/rlstdc.h>
|
||||
# include <readline/rltypedefs.h>
|
||||
# include <readline/keymaps.h>
|
||||
# include <readline/tilde.h>
|
||||
#endif
|
||||
|
||||
/* Hex-encoded Readline version number. */
|
||||
#define RL_READLINE_VERSION 0x0602 /* Readline 6.2 */
|
||||
#define RL_VERSION_MAJOR 6
|
||||
#define RL_VERSION_MINOR 2
|
||||
|
||||
/* Readline data structures. */
|
||||
|
||||
/* Maintaining the state of undo. We remember individual deletes and inserts
|
||||
on a chain of things to do. */
|
||||
|
||||
/* The actions that undo knows how to undo. Notice that UNDO_DELETE means
|
||||
to insert some text, and UNDO_INSERT means to delete some text. I.e.,
|
||||
the code tells undo what to undo, not how to undo it. */
|
||||
enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
|
||||
|
||||
/* What an element of THE_UNDO_LIST looks like. */
|
||||
typedef struct undo_list {
|
||||
struct undo_list *next;
|
||||
int start, end; /* Where the change took place. */
|
||||
char *text; /* The text to insert, if undoing a delete. */
|
||||
enum undo_code what; /* Delete, Insert, Begin, End. */
|
||||
} UNDO_LIST;
|
||||
|
||||
/* The current undo list for RL_LINE_BUFFER. */
|
||||
extern UNDO_LIST *rl_undo_list;
|
||||
|
||||
/* The data structure for mapping textual names to code addresses. */
|
||||
typedef struct _funmap {
|
||||
const char *name;
|
||||
rl_command_func_t *function;
|
||||
} FUNMAP;
|
||||
|
||||
extern FUNMAP **funmap;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Functions available to bind to key sequences */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Bindable commands for numeric arguments. */
|
||||
extern int rl_digit_argument PARAMS((int, int));
|
||||
extern int rl_universal_argument PARAMS((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_skip_csi_sequence PARAMS((int, int));
|
||||
extern int rl_arrow_keys PARAMS((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));
|
||||
|
||||
/* 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));
|
||||
|
||||
/* Bindable commands for transposing characters and words. */
|
||||
extern int rl_transpose_words PARAMS((int, int));
|
||||
extern int rl_transpose_chars PARAMS((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));
|
||||
|
||||
/* 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));
|
||||
|
||||
/* 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));
|
||||
|
||||
/* 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));
|
||||
|
||||
/* Bindable commands to change the insert mode (insert or overwrite) */
|
||||
extern int rl_overwrite_mode PARAMS((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));
|
||||
|
||||
/* 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));
|
||||
|
||||
/* 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));
|
||||
/* Not available unless __CYGWIN__ is defined. */
|
||||
#ifdef __CYGWIN__
|
||||
extern int rl_paste_from_clipboard PARAMS((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));
|
||||
|
||||
/* 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));
|
||||
|
||||
/* Bindable undo commands. */
|
||||
extern int rl_revert_line PARAMS((int, int));
|
||||
extern int rl_undo_command PARAMS((int, int));
|
||||
|
||||
/* Bindable tilde expansion commands. */
|
||||
extern int rl_tilde_expand PARAMS((int, int));
|
||||
|
||||
/* Bindable terminal control commands. */
|
||||
extern int rl_restart_output PARAMS((int, int));
|
||||
extern int rl_stop_output PARAMS((int, int));
|
||||
|
||||
/* Miscellaneous bindable commands. */
|
||||
extern int rl_abort PARAMS((int, int));
|
||||
extern int rl_tty_status PARAMS((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));
|
||||
|
||||
/* Bindable command used when inserting a matching close character. */
|
||||
extern int rl_insert_close PARAMS((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));
|
||||
|
||||
/* 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_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_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));
|
||||
|
||||
/* 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 void rl_vi_start_inserting PARAMS((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));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Well Published Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Readline functions. */
|
||||
/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
|
||||
extern char *readline PARAMS((const char *));
|
||||
|
||||
extern int rl_set_prompt PARAMS((const char *));
|
||||
extern int rl_expand_prompt PARAMS((char *));
|
||||
|
||||
extern int rl_initialize PARAMS((void));
|
||||
|
||||
/* Undocumented; unused by readline */
|
||||
extern int rl_discard_argument PARAMS((void));
|
||||
|
||||
/* Utility functions to bind keys to readline commands. */
|
||||
extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
|
||||
extern int rl_bind_key PARAMS((int, rl_command_func_t *));
|
||||
extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
|
||||
extern int rl_unbind_key PARAMS((int));
|
||||
extern int rl_unbind_key_in_map PARAMS((int, Keymap));
|
||||
extern int rl_bind_key_if_unbound PARAMS((int, rl_command_func_t *));
|
||||
extern int rl_bind_key_if_unbound_in_map PARAMS((int, rl_command_func_t *, Keymap));
|
||||
extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
|
||||
extern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
|
||||
extern int rl_bind_keyseq PARAMS((const char *, rl_command_func_t *));
|
||||
extern int rl_bind_keyseq_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
|
||||
extern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *));
|
||||
extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
|
||||
extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
|
||||
|
||||
extern char *rl_variable_value PARAMS((const char *));
|
||||
extern int rl_variable_bind PARAMS((const char *, const char *));
|
||||
|
||||
/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
|
||||
extern int rl_set_key PARAMS((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));
|
||||
|
||||
/* 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 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 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_function_dumper PARAMS((int));
|
||||
extern void rl_macro_dumper PARAMS((int));
|
||||
extern void rl_variable_dumper PARAMS((int));
|
||||
|
||||
extern int rl_read_init_file PARAMS((const char *));
|
||||
extern int rl_parse_and_bind PARAMS((char *));
|
||||
|
||||
/* Functions for manipulating keymaps. */
|
||||
extern Keymap rl_make_bare_keymap PARAMS((void));
|
||||
extern Keymap rl_copy_keymap PARAMS((Keymap));
|
||||
extern Keymap rl_make_keymap PARAMS((void));
|
||||
extern void rl_discard_keymap PARAMS((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));
|
||||
/* 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));
|
||||
|
||||
/* 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));
|
||||
/* Undocumented, only used internally -- there is only one funmap, and this
|
||||
function may be called only once. */
|
||||
extern void rl_initialize_funmap PARAMS((void));
|
||||
|
||||
/* Utility functions for managing keyboard macros. */
|
||||
extern void rl_push_macro_input PARAMS((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));
|
||||
|
||||
/* 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_message PARAMS((void));
|
||||
extern int rl_reset_line_state PARAMS((void));
|
||||
extern int rl_crlf PARAMS((void));
|
||||
|
||||
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
|
||||
extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
|
||||
#else
|
||||
extern int rl_message ();
|
||||
#endif
|
||||
|
||||
extern int rl_show_char PARAMS((int));
|
||||
|
||||
/* Undocumented in texinfo manual. */
|
||||
extern int rl_character_len PARAMS((int, int));
|
||||
|
||||
/* Save and restore internal prompt redisplay information. */
|
||||
extern void rl_save_prompt PARAMS((void));
|
||||
extern void rl_restore_prompt PARAMS((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));
|
||||
|
||||
/* 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 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 char *rl_get_termcap PARAMS((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));
|
||||
|
||||
/* `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 *));
|
||||
|
||||
/* 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 void rl_echo_signal_char PARAMS((int));
|
||||
|
||||
extern int rl_set_paren_blink_timeout PARAMS((int));
|
||||
|
||||
/* 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));
|
||||
|
||||
/* Completion functions. */
|
||||
extern int rl_complete_internal PARAMS((int));
|
||||
extern void rl_display_match_list PARAMS((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 int rl_completion_mode PARAMS((rl_command_func_t *));
|
||||
|
||||
#if 0
|
||||
/* Backwards compatibility (compat.c). These will go away sometime. */
|
||||
extern void free_undo_list PARAMS((void));
|
||||
extern int maybe_save_line PARAMS((void));
|
||||
extern int maybe_unsave_line PARAMS((void));
|
||||
extern int maybe_replace_line PARAMS((void));
|
||||
|
||||
extern int ding PARAMS((void));
|
||||
extern int alphabetic PARAMS((int));
|
||||
extern int crlf PARAMS((void));
|
||||
|
||||
extern char **completion_matches PARAMS((char *, rl_compentry_func_t *));
|
||||
extern char *username_completion_function PARAMS((const char *, int));
|
||||
extern char *filename_completion_function PARAMS((const char *, int));
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Well Published Variables */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* The version of this incarnation of the readline library. */
|
||||
extern const char *rl_library_version; /* e.g., "4.2" */
|
||||
extern int rl_readline_version; /* e.g., 0x0402 */
|
||||
|
||||
/* True if this is real GNU readline. */
|
||||
extern int rl_gnu_readline_p;
|
||||
|
||||
/* Flags word encapsulating the current readline state. */
|
||||
extern int rl_readline_state;
|
||||
|
||||
/* Says which editing mode readline is currently using. 1 means emacs mode;
|
||||
0 means vi mode. */
|
||||
extern int rl_editing_mode;
|
||||
|
||||
/* Insert or overwrite mode for emacs mode. 1 means insert mode; 0 means
|
||||
overwrite mode. Reset to insert mode on each input line. */
|
||||
extern int rl_insert_mode;
|
||||
|
||||
/* The name of the calling program. You should initialize this to
|
||||
whatever was in argv[0]. It is used when parsing conditionals. */
|
||||
extern const char *rl_readline_name;
|
||||
|
||||
/* The prompt readline uses. This is set from the argument to
|
||||
readline (), and should not be assigned to directly. */
|
||||
extern char *rl_prompt;
|
||||
|
||||
/* The prompt string that is actually displayed by rl_redisplay. Public so
|
||||
applications can more easily supply their own redisplay functions. */
|
||||
extern char *rl_display_prompt;
|
||||
|
||||
/* The line buffer that is in use. */
|
||||
extern char *rl_line_buffer;
|
||||
|
||||
/* The location of point, and end. */
|
||||
extern int rl_point;
|
||||
extern int rl_end;
|
||||
|
||||
/* The mark, or saved cursor position. */
|
||||
extern int rl_mark;
|
||||
|
||||
/* Flag to indicate that readline has finished with the current input
|
||||
line and should return it. */
|
||||
extern int rl_done;
|
||||
|
||||
/* If set to a character value, that will be the next keystroke read. */
|
||||
extern int rl_pending_input;
|
||||
|
||||
/* Non-zero if we called this function from _rl_dispatch(). It's present
|
||||
so functions can find out whether they were called from a key binding
|
||||
or directly from an application. */
|
||||
extern int rl_dispatching;
|
||||
|
||||
/* Non-zero if the user typed a numeric argument before executing the
|
||||
current function. */
|
||||
extern int rl_explicit_arg;
|
||||
|
||||
/* The current value of the numeric argument specified by the user. */
|
||||
extern int rl_numeric_arg;
|
||||
|
||||
/* The address of the last command function Readline executed. */
|
||||
extern rl_command_func_t *rl_last_func;
|
||||
|
||||
/* The name of the terminal to use. */
|
||||
extern const char *rl_terminal_name;
|
||||
|
||||
/* The input and output streams. */
|
||||
extern FILE *rl_instream;
|
||||
extern FILE *rl_outstream;
|
||||
|
||||
/* If non-zero, Readline gives values of LINES and COLUMNS from the environment
|
||||
greater precedence than values fetched from the kernel when computing the
|
||||
screen dimensions. */
|
||||
extern int rl_prefer_env_winsize;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call just
|
||||
before readline_internal () prints the first prompt. */
|
||||
extern rl_hook_func_t *rl_startup_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function to call just before
|
||||
readline_internal_setup () returns and readline_internal starts
|
||||
reading input characters. */
|
||||
extern rl_hook_func_t *rl_pre_input_hook;
|
||||
|
||||
/* The address of a function to call periodically while Readline is
|
||||
awaiting character input, or NULL, for no event handling. */
|
||||
extern rl_hook_func_t *rl_event_hook;
|
||||
|
||||
/* The address of the function to call to fetch a character from the current
|
||||
Readline input stream */
|
||||
extern rl_getc_func_t *rl_getc_function;
|
||||
|
||||
extern rl_voidfunc_t *rl_redisplay_function;
|
||||
|
||||
extern rl_vintfunc_t *rl_prep_term_function;
|
||||
extern rl_voidfunc_t *rl_deprep_term_function;
|
||||
|
||||
/* Dispatch variables. */
|
||||
extern Keymap rl_executing_keymap;
|
||||
extern Keymap rl_binding_keymap;
|
||||
|
||||
extern int rl_executing_key;
|
||||
extern char *rl_executing_keyseq;
|
||||
extern int rl_key_sequence_length;
|
||||
|
||||
/* Display variables. */
|
||||
/* If non-zero, readline will erase the entire line, including any prompt,
|
||||
if the only thing typed on an otherwise-blank line is something bound to
|
||||
rl_newline. */
|
||||
extern int rl_erase_empty_line;
|
||||
|
||||
/* If non-zero, the application has already printed the prompt (rl_prompt)
|
||||
before calling readline, so readline should not output it the first time
|
||||
redisplay is done. */
|
||||
extern int rl_already_prompted;
|
||||
|
||||
/* A non-zero value means to read only this many characters rather than
|
||||
up to a character bound to accept-line. */
|
||||
extern int rl_num_chars_to_read;
|
||||
|
||||
/* The text of a currently-executing keyboard macro. */
|
||||
extern char *rl_executing_macro;
|
||||
|
||||
/* Variables to control readline signal handling. */
|
||||
/* If non-zero, readline will install its own signal handlers for
|
||||
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
|
||||
extern int rl_catch_signals;
|
||||
|
||||
/* If non-zero, readline will install a signal handler for SIGWINCH
|
||||
that also attempts to call any calling application's SIGWINCH signal
|
||||
handler. Note that the terminal is not cleaned up before the
|
||||
application's signal handler is called; use rl_cleanup_after_signal()
|
||||
to do that. */
|
||||
extern int rl_catch_sigwinch;
|
||||
|
||||
/* Completion variables. */
|
||||
/* Pointer to the generator function for completion_matches ().
|
||||
NULL means to use rl_filename_completion_function (), the default
|
||||
filename completer. */
|
||||
extern rl_compentry_func_t *rl_completion_entry_function;
|
||||
|
||||
/* Optional generator for menu completion. Default is
|
||||
rl_completion_entry_function (rl_filename_completion_function). */
|
||||
extern rl_compentry_func_t *rl_menu_completion_entry_function;
|
||||
|
||||
/* If rl_ignore_some_completions_function is non-NULL it is the address
|
||||
of a function to call after all of the possible matches have been
|
||||
generated, but before the actual completion is done to the input line.
|
||||
The function is called with one argument; a NULL terminated array
|
||||
of (char *). If your function removes any of the elements, they
|
||||
must be free()'ed. */
|
||||
extern rl_compignore_func_t *rl_ignore_some_completions_function;
|
||||
|
||||
/* Pointer to alternative function to create matches.
|
||||
Function is called with TEXT, START, and END.
|
||||
START and END are indices in RL_LINE_BUFFER saying what the boundaries
|
||||
of TEXT are.
|
||||
If this function exists and returns NULL then call the value of
|
||||
rl_completion_entry_function to try to match, otherwise use the
|
||||
array of strings returned. */
|
||||
extern rl_completion_func_t *rl_attempted_completion_function;
|
||||
|
||||
/* The basic list of characters that signal a break between words for the
|
||||
completer routine. The initial contents of this variable is what
|
||||
breaks words in the shell, i.e. "n\"\\'`@$>". */
|
||||
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;
|
||||
|
||||
/* Hook function to allow an application to set the completion word
|
||||
break characters before readline breaks up the line. Allows
|
||||
position-dependent word break characters. */
|
||||
extern rl_cpvfunc_t *rl_completion_word_break_hook;
|
||||
|
||||
/* List of characters which can be used to quote a substring of the line.
|
||||
Completion occurs on the entire substring, and within the substring
|
||||
rl_completer_word_break_characters are treated as any other character,
|
||||
unless they also appear within this list. */
|
||||
extern const char *rl_completer_quote_characters;
|
||||
|
||||
/* List of quote characters which cause a word break. */
|
||||
extern const char *rl_basic_quote_characters;
|
||||
|
||||
/* List of characters that need to be quoted in filenames by the completer. */
|
||||
extern const char *rl_filename_quote_characters;
|
||||
|
||||
/* List of characters that are word break characters, but should be left
|
||||
in TEXT when it is passed to the completion function. The shell uses
|
||||
this to help determine what kind of completing to do. */
|
||||
extern const char *rl_special_prefixes;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing on a directory name. The function is called with
|
||||
the address of a string (the current directory name) as an arg. It
|
||||
changes what is displayed when the possible completions are printed
|
||||
or inserted. The directory completion hook should perform
|
||||
any necessary dequoting. This function should return 1 if it modifies
|
||||
the directory name pointer passed as an argument. If the directory
|
||||
completion hook returns 0, it should not modify the directory name
|
||||
pointer passed as an argument. */
|
||||
extern rl_icppfunc_t *rl_directory_completion_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function to call when completing
|
||||
a directory name. This function takes the address of the directory name
|
||||
to be modified as an argument. Unlike rl_directory_completion_hook, it
|
||||
only modifies the directory name used in opendir(2), not what is displayed
|
||||
when the possible completions are printed or inserted. If set, it takes
|
||||
precedence over rl_directory_completion_hook. The directory rewrite
|
||||
hook should perform any necessary dequoting. This function has the same
|
||||
return value properties as the directory_completion_hook.
|
||||
|
||||
I'm not happy with how this works yet, so it's undocumented. I'm trying
|
||||
it in bash to see how well it goes. */
|
||||
extern rl_icppfunc_t *rl_directory_rewrite_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function for the completer to call
|
||||
before deciding which character to append to a completed name. It should
|
||||
modify the directory name passed as an argument if appropriate, and return
|
||||
non-zero if it modifies the name. This should not worry about dequoting
|
||||
the filename; that has already happened by the time it gets here. */
|
||||
extern rl_icppfunc_t *rl_filename_stat_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function to call when reading
|
||||
directory entries from the filesystem for completion and comparing
|
||||
them to the partial word to be completed. The function should
|
||||
either return its first argument (if no conversion takes place) or
|
||||
newly-allocated memory. This can, for instance, convert filenames
|
||||
between character sets for comparison against what's typed at the
|
||||
keyboard. The returned value is what is added to the list of
|
||||
matches. The second argument is the length of the filename to be
|
||||
converted. */
|
||||
extern rl_dequote_func_t *rl_filename_rewrite_hook;
|
||||
|
||||
/* Backwards compatibility with previous versions of readline. */
|
||||
#define rl_symbolic_link_hook rl_directory_completion_hook
|
||||
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing a word would normally display the list of possible matches.
|
||||
This function is called instead of actually doing the display.
|
||||
It takes three arguments: (char **matches, int num_matches, int max_length)
|
||||
where MATCHES is the array of strings that matched, NUM_MATCHES is the
|
||||
number of strings in that array, and MAX_LENGTH is the length of the
|
||||
longest string in that array. */
|
||||
extern rl_compdisp_func_t *rl_completion_display_matches_hook;
|
||||
|
||||
/* Non-zero means that the results of the matches are to be treated
|
||||
as filenames. This is ALWAYS zero on entry, and can only be changed
|
||||
within a completion entry finder function. */
|
||||
extern int rl_filename_completion_desired;
|
||||
|
||||
/* Non-zero means that the results of the matches are to be quoted using
|
||||
double quotes (or an application-specific quoting mechanism) if the
|
||||
filename contains any characters in rl_word_break_chars. This is
|
||||
ALWAYS non-zero on entry, and can only be changed within a completion
|
||||
entry finder function. */
|
||||
extern int rl_filename_quoting_desired;
|
||||
|
||||
/* Set to a function to quote a filename in an application-specific fashion.
|
||||
Called with the text to quote, the type of match found (single or multiple)
|
||||
and a pointer to the quoting character to be used, which the function can
|
||||
reset if desired. */
|
||||
extern rl_quote_func_t *rl_filename_quoting_function;
|
||||
|
||||
/* Function to call to remove quoting characters from a filename. Called
|
||||
before completion is attempted, so the embedded quotes do not interfere
|
||||
with matching names in the file system. */
|
||||
extern rl_dequote_func_t *rl_filename_dequoting_function;
|
||||
|
||||
/* Function to call to decide whether or not a word break character is
|
||||
quoted. If a character is quoted, it does not break words for the
|
||||
completer. */
|
||||
extern rl_linebuf_func_t *rl_char_is_quoted_p;
|
||||
|
||||
/* Non-zero means to suppress normal filename completion after the
|
||||
user-specified completion function has been called. */
|
||||
extern int rl_attempted_completion_over;
|
||||
|
||||
/* Set to a character describing the type of completion being attempted by
|
||||
rl_complete_internal; available for use by application completion
|
||||
functions. */
|
||||
extern int rl_completion_type;
|
||||
|
||||
/* Set to the last key used to invoke one of the completion functions */
|
||||
extern int rl_completion_invoking_key;
|
||||
|
||||
/* Up to this many items will be displayed in response to a
|
||||
possible-completions call. After that, we ask the user if she
|
||||
is sure she wants to see them all. The default value is 100. */
|
||||
extern int rl_completion_query_items;
|
||||
|
||||
/* Character appended to completed words when at the end of the line. The
|
||||
default is a space. Nothing is added if this is '\0'. */
|
||||
extern int rl_completion_append_character;
|
||||
|
||||
/* If set to non-zero by an application completion function,
|
||||
rl_completion_append_character will not be appended. */
|
||||
extern int rl_completion_suppress_append;
|
||||
|
||||
/* Set to any quote character readline thinks it finds before any application
|
||||
completion function is called. */
|
||||
extern int rl_completion_quote_character;
|
||||
|
||||
/* Set to a non-zero value if readline found quoting anywhere in the word to
|
||||
be completed; set before any application completion function is called. */
|
||||
extern int rl_completion_found_quote;
|
||||
|
||||
/* If non-zero, the completion functions don't append any closing quote.
|
||||
This is set to 0 by rl_complete_internal and may be changed by an
|
||||
application-specific completion function. */
|
||||
extern int rl_completion_suppress_quote;
|
||||
|
||||
/* If non-zero, readline will sort the completion matches. On by default. */
|
||||
extern int rl_sort_completion_matches;
|
||||
|
||||
/* If non-zero, a slash will be appended to completed filenames that are
|
||||
symbolic links to directory names, subject to the value of the
|
||||
mark-directories variable (which is user-settable). This exists so
|
||||
that application completion functions can override the user's preference
|
||||
(set via the mark-symlinked-directories variable) if appropriate.
|
||||
It's set to the value of _rl_complete_mark_symlink_dirs in
|
||||
rl_complete_internal before any application-specific completion
|
||||
function is called, so without that function doing anything, the user's
|
||||
preferences are honored. */
|
||||
extern int rl_completion_mark_symlink_dirs;
|
||||
|
||||
/* If non-zero, then disallow duplicates in the matches. */
|
||||
extern int rl_ignore_completion_duplicates;
|
||||
|
||||
/* If this is non-zero, completion is (temporarily) inhibited, and the
|
||||
completion character will be inserted as any other. */
|
||||
extern int rl_inhibit_completion;
|
||||
|
||||
/* Input error; can be returned by (*rl_getc_function) if readline is reading
|
||||
a top-level command (RL_ISSTATE (RL_STATE_READCMD)). */
|
||||
#define READERR (-2)
|
||||
|
||||
/* Definitions available for use by readline clients. */
|
||||
#define RL_PROMPT_START_IGNORE '\001'
|
||||
#define RL_PROMPT_END_IGNORE '\002'
|
||||
|
||||
/* Possible values for do_replace argument to rl_filename_quoting_function,
|
||||
called by rl_complete_internal. */
|
||||
#define NO_MATCH 0
|
||||
#define SINGLE_MATCH 1
|
||||
#define MULT_MATCH 2
|
||||
|
||||
/* Possible state values for rl_readline_state */
|
||||
#define RL_STATE_NONE 0x000000 /* no state; before first call */
|
||||
|
||||
#define RL_STATE_INITIALIZING 0x0000001 /* initializing */
|
||||
#define RL_STATE_INITIALIZED 0x0000002 /* initialization done */
|
||||
#define RL_STATE_TERMPREPPED 0x0000004 /* terminal is prepped */
|
||||
#define RL_STATE_READCMD 0x0000008 /* reading a command key */
|
||||
#define RL_STATE_METANEXT 0x0000010 /* reading input after ESC */
|
||||
#define RL_STATE_DISPATCHING 0x0000020 /* dispatching to a command */
|
||||
#define RL_STATE_MOREINPUT 0x0000040 /* reading more input in a command function */
|
||||
#define RL_STATE_ISEARCH 0x0000080 /* doing incremental search */
|
||||
#define RL_STATE_NSEARCH 0x0000100 /* doing non-inc search */
|
||||
#define RL_STATE_SEARCH 0x0000200 /* doing a history search */
|
||||
#define RL_STATE_NUMERICARG 0x0000400 /* reading numeric argument */
|
||||
#define RL_STATE_MACROINPUT 0x0000800 /* getting input from a macro */
|
||||
#define RL_STATE_MACRODEF 0x0001000 /* defining keyboard macro */
|
||||
#define RL_STATE_OVERWRITE 0x0002000 /* overwrite mode */
|
||||
#define RL_STATE_COMPLETING 0x0004000 /* doing completion */
|
||||
#define RL_STATE_SIGHANDLER 0x0008000 /* in readline sighandler */
|
||||
#define RL_STATE_UNDOING 0x0010000 /* doing an undo */
|
||||
#define RL_STATE_INPUTPENDING 0x0020000 /* rl_execute_next called */
|
||||
#define RL_STATE_TTYCSAVED 0x0040000 /* tty special chars saved */
|
||||
#define RL_STATE_CALLBACK 0x0080000 /* using the callback interface */
|
||||
#define RL_STATE_VIMOTION 0x0100000 /* reading vi motion arg */
|
||||
#define RL_STATE_MULTIKEY 0x0200000 /* reading multiple-key command */
|
||||
#define RL_STATE_VICMDONCE 0x0400000 /* entered vi command mode at least once */
|
||||
#define RL_STATE_REDISPLAYING 0x0800000 /* updating terminal display */
|
||||
|
||||
#define RL_STATE_DONE 0x1000000 /* done; accepted line */
|
||||
|
||||
#define RL_SETSTATE(x) (rl_readline_state |= (x))
|
||||
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
|
||||
#define RL_ISSTATE(x) (rl_readline_state & (x))
|
||||
|
||||
struct readline_state {
|
||||
/* line state */
|
||||
int point;
|
||||
int end;
|
||||
int mark;
|
||||
char *buffer;
|
||||
int buflen;
|
||||
UNDO_LIST *ul;
|
||||
char *prompt;
|
||||
|
||||
/* global state */
|
||||
int rlstate;
|
||||
int done;
|
||||
Keymap kmap;
|
||||
|
||||
/* input state */
|
||||
rl_command_func_t *lastfunc;
|
||||
int insmode;
|
||||
int edmode;
|
||||
int kseqlen;
|
||||
FILE *inf;
|
||||
FILE *outf;
|
||||
int pendingin;
|
||||
char *macro;
|
||||
|
||||
/* signal state */
|
||||
int catchsigs;
|
||||
int catchsigwinch;
|
||||
|
||||
/* search state */
|
||||
|
||||
/* completion state */
|
||||
|
||||
/* options state */
|
||||
|
||||
/* reserved for future expansion, so the struct size doesn't change */
|
||||
char reserved[64];
|
||||
};
|
||||
|
||||
extern int rl_save_state PARAMS((struct readline_state *));
|
||||
extern int rl_restore_state PARAMS((struct readline_state *));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _READLINE_H_ */
|
||||
+8
-2
@@ -92,7 +92,7 @@ CSOURCES = clktck.c clock.c getcwd.c getenv.c oslib.c setlinebuf.c \
|
||||
mktime.c strftime.c mbschr.c zcatfd.c zmapfd.c winsize.c eaccess.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 shmbchar.c
|
||||
strchrnul.c unicode.c wcswidth.c wcsnwidth.c shmbchar.c
|
||||
|
||||
# The header files for this library.
|
||||
HSOURCES =
|
||||
@@ -106,7 +106,8 @@ OBJECTS = clktck.o clock.o getenv.o oslib.o setlinebuf.o strnlen.o \
|
||||
strtrans.o snprintf.o mailstat.o fmtulong.o \
|
||||
fmtullong.o fmtumax.o zcatfd.o zmapfd.o winsize.o wcsdup.o \
|
||||
fpurge.o zgetline.o mbscmp.o uconvert.o ufuncs.o casemod.o \
|
||||
input_avail.o mbscasecmp.o fnxform.o unicode.o shmbchar.o ${LIBOBJS}
|
||||
input_avail.o mbscasecmp.o fnxform.o unicode.o shmbchar.o \
|
||||
wcsnwidth.o ${LIBOBJS}
|
||||
|
||||
SUPPORT = Makefile
|
||||
|
||||
@@ -197,6 +198,7 @@ uconvert.o: uconvert.c
|
||||
ufuncs.o: ufuncs.c
|
||||
vprint.o: vprint.c
|
||||
wcsdup.o: wcsdup.c
|
||||
wcsnwidth.o: wcsnwidth.c
|
||||
wcswidth.o: wcswidth.c
|
||||
mbschr.o: mbschr.c
|
||||
zcatfd.o: zcatfd.c
|
||||
@@ -269,6 +271,7 @@ uconvert.o: ${BUILD_DIR}/config.h
|
||||
ufuncs.o: ${BUILD_DIR}/config.h
|
||||
vprint.o: ${BUILD_DIR}/config.h
|
||||
wcsdup.o: ${BUILD_DIR}/config.h
|
||||
wcsnwidth.o: ${BUILD_DIR}/config.h
|
||||
wcswidth.o: ${BUILD_DIR}/config.h
|
||||
mbschr.o: ${BUILD_DIR}/config.h
|
||||
zcatfd.o: ${BUILD_DIR}/config.h
|
||||
@@ -521,6 +524,9 @@ wcsdup.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
wcsdup.o: ${BASHINCDIR}/stdc.h
|
||||
wcsdup.o: ${topdir}/xmalloc.h
|
||||
|
||||
wcsnwidth.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
wcsnwidth.o: ${BASHINCDIR}/stdc.h
|
||||
|
||||
wcswidth.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
|
||||
wcswidth.o: ${BASHINCDIR}/stdc.h
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/* wcsnwidth.c - compute display width of wide character string, up to max
|
||||
specified width, return length. */
|
||||
|
||||
/* Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Bash is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Bash. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
|
||||
#include <stdc.h>
|
||||
#include <wchar.h>
|
||||
#include <bashansi.h>
|
||||
|
||||
/* Return the number of wide characters that will be displayed from wide string
|
||||
PWCS. If the display width exceeds MAX, return the number of wide chars
|
||||
from PWCS required to display MAX characters on the screen. */
|
||||
int
|
||||
wcsnwidth(pwcs, n, max)
|
||||
const wchar_t *pwcs;
|
||||
size_t n, max;
|
||||
{
|
||||
wchar_t wc, *ws;
|
||||
int len, l;
|
||||
|
||||
len = 0;
|
||||
ws = pwcs;
|
||||
while (n-- > 0 && (wc = *ws++) != L'\0')
|
||||
{
|
||||
l = wcwidth (wc);
|
||||
if (l < 0)
|
||||
return (-1);
|
||||
else if (l == max - len)
|
||||
return (ws - pwcs);
|
||||
else if (l > max - len)
|
||||
return (--ws - pwcs);
|
||||
len += l;
|
||||
}
|
||||
return (ws - pwcs);
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user