Commit dc403f81 authored by tsmith@ramayana.hindu.god's avatar tsmith@ramayana.hindu.god
Browse files

Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.0-build

into  ramayana.hindu.god:/home/tsmith/m/bk/build/50
parents 587c27e1 d3b0403a
Loading
Loading
Loading
Loading
+15 −1
Original line number Diff line number Diff line
Basic Installation
==================

These are installation instructions for Readline-5.0.
These are installation instructions for Readline-5.2.

The simplest way to compile readline is:

@@ -238,6 +238,9 @@ SHLIB_XLDFLAGS Additional flags to pass to SHOBJ_LD for shared library
SHLIB_LIBS	Any additional libraries that shared libraries should be
		linked against when they are created.

SHLIB_LIBPREF	The prefix to use when generating the filename of the shared
		library.  The default is `lib'; Cygwin uses `cyg'.

SHLIB_LIBSUFF	The suffix to add to `libreadline' and `libhistory' when
		generating the filename of the shared library.  Many systems
		use `so'; HP-UX uses `sl'.
@@ -254,6 +257,17 @@ SHLIB_LIBVERSION The string to append to the filename to indicate the version
		numbers; use `$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' on those systems.
		Other Unix versions use different schemes.

SHLIB_DLLVERSION The version number for shared libraries that determines API
		compatibility between readline versions and the underlying
		system.  Used only on Cygwin.  Defaults to $SHLIB_MAJOR, but
		can be overridden at configuration time by defining DLLVERSION
		in the environment.

SHLIB_DOT	The character used to separate the name of the shared library
		from the suffix and version information.  The default is `.';
		systems like Cygwin which don't separate version information
		from the library name should set this to the empty string.

SHLIB_STATUS	Set this to `supported' when you have defined the other
		necessary variables.  Make uses this to determine whether
		or not shared library creation should be attempted.  If
+16 −2
Original line number Diff line number Diff line
Introduction
============

This is the Gnu Readline library, version 5.0.
This is the Gnu Readline library, version 5.2.

The Readline library provides a set of functions for use by applications
that allow users to edit command lines as they are typed in.  Both
@@ -102,6 +102,9 @@ SHLIB_XLDFLAGS Additional flags to pass to SHOBJ_LD for shared library
SHLIB_LIBS	Any additional libraries that shared libraries should be
		linked against when they are created.

SHLIB_LIBPREF	The prefix to use when generating the filename of the shared
		library.  The default is `lib'; Cygwin uses `cyg'.

SHLIB_LIBSUFF	The suffix to add to `libreadline' and `libhistory' when
		generating the filename of the shared library.  Many systems
		use `so'; HP-UX uses `sl'.
@@ -118,6 +121,17 @@ SHLIB_LIBVERSION The string to append to the filename to indicate the version
		numbers; use `$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' on those systems.
		Other Unix versions use different schemes.

SHLIB_DLLVERSION The version number for shared libraries that determines API
		compatibility between readline versions and the underlying
		system.  Used only on Cygwin.  Defaults to $SHLIB_MAJOR, but
		can be overridden at configuration time by defining DLLVERSION
		in the environment.

SHLIB_DOT	The character used to separate the name of the shared library
		from the suffix and version information.  The default is `.';
		systems like Cygwin which don't separate version information
		from the library name should set this to the empty string.

SHLIB_STATUS	Set this to `supported' when you have defined the other
		necessary variables.  Make uses this to determine whether
		or not shared library creation should be attempted.
@@ -169,4 +183,4 @@ list (mirrored to the Usenet newsgroup gnu.bash.bug) often contains
Readline bug reports and fixes. 

Chet Ramey
chet@po.cwru.edu
chet.ramey@case.edu
+201 −109
Original line number Diff line number Diff line
/* bind.c -- key binding and startup file support for the readline library. */

/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
/* Copyright (C) 1987-2006 Free Software Foundation, Inc.

   This file is part of the GNU Readline Library, a library for
   reading lines of text with interactive input and history editing.
@@ -26,7 +26,9 @@
#  include <floss.h>
#endif

#include "config_readline.h"
#if defined (HAVE_CONFIG_H)
#  include <config.h>
#endif

#include <stdio.h>
#include <sys/types.h>
@@ -75,6 +77,9 @@ static char *_rl_read_file PARAMS((char *, size_t *));
static void _rl_init_file_error PARAMS((const char *));
static int _rl_read_init_file PARAMS((const char *, int));
static int glean_key_from_name PARAMS((char *));
static int find_boolean_var PARAMS((const char *));

static char *_rl_get_string_variable_value PARAMS((const char *));
static int substring_member_of_array PARAMS((char *, const char **));

static int currently_reading_init_file;
@@ -337,10 +342,9 @@ rl_generic_bind (type, keyseq, data, map)
  KEYMAP_ENTRY k;

  k.function = 0;
  k.type= 0;

  /* If no keys to bind to, exit right away. */
  if (!keyseq || !*keyseq)
  if (keyseq == 0 || *keyseq == 0)
    {
      if (type == ISMACR)
	free (data);
@@ -366,9 +370,12 @@ rl_generic_bind (type, keyseq, data, map)

      ic = uc;
      if (ic < 0 || ic >= KEYMAP_SIZE)
        {
          free (keys);
	  return -1;
        }

      if (_rl_convert_meta_chars_to_ascii && META_CHAR (ic))
      if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
	{
	  ic = UNMETA (ic);
	  if (map[ESC].type == ISKMAP)
@@ -435,7 +442,7 @@ rl_translate_keyseq (seq, array, len)
{
  register int i, c, l, temp;

  for (i = l = 0; (c = seq[i]); i++)
  for (i = l = 0; c = seq[i]; i++)
    {
      if (c == '\\')
	{
@@ -458,8 +465,24 @@ rl_translate_keyseq (seq, array, len)
		}
	      else if (c == 'M')
		{
		  i++;
		  i++;		/* seq[i] == '-' */
		  /* XXX - obey convert-meta setting */
		  if (_rl_convert_meta_chars_to_ascii && _rl_keymap[ESC].type == ISKMAP)
		    array[l++] = ESC;	/* ESC is meta-prefix */
		  else if (seq[i+1] == '\\' && seq[i+2] == 'C' && seq[i+3] == '-')
		    {
		      i += 4;
		      temp = (seq[i] == '?') ? RUBOUT : CTRL (_rl_to_upper (seq[i]));
		      array[l++] = META (temp);
		    }
		  else
		    {
		      /* This doesn't yet handle things like \M-\a, which may
			 or may not have any reasonable meaning.  You're
			 probably better off using straight octal or hex. */
		      i++;
		      array[l++] = META (seq[i]);
		    }
		}
	      else if (c == 'C')
		{
@@ -554,6 +577,11 @@ rl_untranslate_keyseq (seq)
      kseq[i++] = '-';
      c = UNMETA (c);
    }
  else if (c == ESC)
    {
      kseq[i++] = '\\';
      c = 'e';
    }
  else if (CTRL_CHAR (c))
    {
      kseq[i++] = '\\';
@@ -602,7 +630,12 @@ _rl_untranslate_macro_value (seq)
	  *r++ = '-';
	  c = UNMETA (c);
	}
      else if (CTRL_CHAR (c) && c != ESC)
      else if (c == ESC)
	{
	  *r++ = '\\';
	  c = 'e';
	}
      else if (CTRL_CHAR (c))
	{
	  *r++ = '\\';
	  *r++ = 'C';
@@ -661,7 +694,7 @@ rl_function_of_keyseq (keyseq, map, type)
{
  register int i;

  if (!map)
  if (map == 0)
    map = _rl_keymap;

  for (i = 0; keyseq && keyseq[i]; i++)
@@ -670,25 +703,27 @@ rl_function_of_keyseq (keyseq, map, type)

      if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
	{
	  if (map[ESC].type != ISKMAP)
	  if (map[ESC].type == ISKMAP)
	    {
	      map = FUNCTION_TO_KEYMAP (map, ESC);
	      ic = UNMETA (ic);
	    }
	  /* XXX - should we just return NULL here, since this obviously
	     doesn't match? */
	  else
	    {
	      if (type)
		*type = map[ESC].type;

	      return (map[ESC].function);
	    }
	  else
	    {
	      map = FUNCTION_TO_KEYMAP (map, ESC);
	      ic = UNMETA (ic);
	    }
	}

      if (map[ic].type == ISKMAP)
	{
	  /* If this is the last key in the key sequence, return the
	     map. */
	  if (!keyseq[i + 1])
	  if (keyseq[i + 1] == '\0')
	    {
	      if (type)
		*type = ISKMAP;
@@ -698,7 +733,12 @@ rl_function_of_keyseq (keyseq, map, type)
	  else
	    map = FUNCTION_TO_KEYMAP (map, ic);
	}
      else
      /* If we're not at the end of the key sequence, and the current key
	 is bound to something other than a keymap, then the entire key
	 sequence is not bound. */
      else if (map[ic].type != ISKMAP && keyseq[i+1])
	return ((rl_command_func_t *)NULL);
      else	/* map[ic].type != ISKMAP && keyseq[i+1] == 0 */
	{
	  if (type)
	    *type = map[ic].type;
@@ -736,8 +776,7 @@ _rl_read_file (filename, sizep)
  file_size = (size_t)finfo.st_size;

  /* check for overflow on very large files */
  if ((long long) file_size != (long long) finfo.st_size ||
      file_size + 1 < file_size)
  if (file_size != finfo.st_size || file_size + 1 < file_size)
    {
      if (file >= 0)
	close (file);
@@ -767,8 +806,8 @@ _rl_read_file (filename, sizep)

/* Re-read the current keybindings file. */
int
rl_re_read_init_file (int count __attribute__((unused)),
                      int ignore __attribute__((unused)))
rl_re_read_init_file (count, ignore)
     int count, ignore;
{
  int r;
  r = rl_read_init_file ((const char *)NULL);
@@ -781,6 +820,7 @@ rl_re_read_init_file (int count __attribute__((unused)),
     1. the filename used for the previous call
     2. the value of the shell variable `INPUTRC'
     3. ~/.inputrc
     4. /etc/inputrc
   If the file existed and could be opened and read, 0 is returned,
   otherwise errno is returned. */
int
@@ -789,17 +829,18 @@ rl_read_init_file (filename)
{
  /* Default the filename. */
  if (filename == 0)
    {
    filename = last_readline_init_file;
  if (filename == 0)
    filename = sh_get_env_value ("INPUTRC");
      if (filename == 0)
  if (filename == 0 || *filename == 0)
    {
      filename = DEFAULT_INPUTRC;
      /* Try to read DEFAULT_INPUTRC; fall back to SYS_INPUTRC on failure */
      if (_rl_read_init_file (filename, 0) == 0)
	return 0;
      filename = SYS_INPUTRC;
    }

  if (*filename == 0)
    filename = DEFAULT_INPUTRC;

#if defined (__MSDOS__)
  if (_rl_read_init_file (filename, 0) == 0)
    return 0;
@@ -989,7 +1030,8 @@ parser_if (args)

/* Invert the current parser state if there is anything on the stack. */
static int
parser_else (char *args __attribute__((unused)))
parser_else (args)
     char *args;
{
  register int i;

@@ -1019,7 +1061,8 @@ parser_else (char *args __attribute__((unused)))
/* Terminate a conditional, popping the value of
   _rl_parsing_conditionalized_out from the stack. */
static int
parser_endif (char *args __attribute__((unused)))
parser_endif (args)
     char *args;
{
  if (if_stack_depth)
    _rl_parsing_conditionalized_out = if_stack[--if_stack_depth];
@@ -1142,7 +1185,7 @@ rl_parse_and_bind (string)
    {
      int passc = 0;

      for (i = 1; (c = string[i]); i++)
      for (i = 1; c = string[i]; i++)
	{
	  if (passc)
	    {
@@ -1183,9 +1226,9 @@ rl_parse_and_bind (string)
  /* If this is a command to set a variable, then do that. */
  if (_rl_stricmp (string, "set") == 0)
    {
      char *var = string + i;
      char *value;
      char *var, *value, *e;

      var = string + i;
      /* Make VAR point to start of variable name. */
      while (*var && whitespace (*var)) var++;

@@ -1196,6 +1239,20 @@ rl_parse_and_bind (string)
	*value++ = '\0';
      while (*value && whitespace (*value)) value++;

      /* Strip trailing whitespace from values to boolean variables.  Temp
	 fix until I get a real quoted-string parser here. */
      i = find_boolean_var (var);
      if (i >= 0)
	{
	  /* remove trailing whitespace */
	  e = value + strlen (value) - 1;
	  while (e >= value && whitespace (*e))
	    e--;
	  e++;		/* skip back to whitespace or EOS */
	  if (*e && e >= value)
	    *e = '\0';
	}

      rl_variable_bind (var, value);
      return 0;
    }
@@ -1216,9 +1273,10 @@ rl_parse_and_bind (string)
     the quoted string delimiter, like the shell. */
  if (*funname == '\'' || *funname == '"')
    {
      int delimiter = string[i++], passc;
      int delimiter, passc;

      for (passc = 0; (c = string[i]); i++)
      delimiter = string[i++];
      for (passc = 0; c = string[i]; i++)
	{
	  if (passc)
	    {
@@ -1353,6 +1411,7 @@ static struct {
  int *value;
  int flags;
} boolean_varlist [] = {
  { "bind-tty-special-chars",	&_rl_bind_stty_chars,		0 },
  { "blink-matching-paren",	&rl_blink_matching_paren,	V_SPECIAL },
  { "byte-oriented",		&rl_byte_oriented,		0 },
  { "completion-ignore-case",	&_rl_completion_case_fold,	0 },
@@ -1377,7 +1436,7 @@ static struct {
#if defined (VISIBLE_STATS)
  { "visible-stats",		&rl_visible_stats,		0 },
#endif /* VISIBLE_STATS */
  { (char *)NULL, (int *)NULL, 0 }
  { (char *)NULL, (int *)NULL }
};

static int
@@ -1446,7 +1505,7 @@ static struct {
  { "editing-mode",	V_STRING,	sv_editmode },
  { "isearch-terminators", V_STRING,	sv_isrchterm },
  { "keymap",		V_STRING,	sv_keymap },
  { (char *)NULL,	0, 0 }
  { (char *)NULL,	0 }
};

static int
@@ -1473,6 +1532,25 @@ const char *value;
		(value[0] == '1' && value[1] == '\0'));
}

char *
rl_variable_value (name)
     const char *name;
{
  register int i;

  /* Check for simple variables first. */
  i = find_boolean_var (name);
  if (i >= 0)
    return (*boolean_varlist[i].value ? "on" : "off");

  i = find_string_var (name);
  if (i >= 0)
    return (_rl_get_string_variable_value (string_varlist[i].name));

  /* Unknown variable names return NULL. */
  return 0;
}

int
rl_variable_bind (name, value)
     const char *name, *value;
@@ -1725,13 +1803,13 @@ char *
rl_get_keymap_name_from_edit_mode ()
{
  if (rl_editing_mode == emacs_mode)
    return (char*) "emacs";
    return "emacs";
#if defined (VI_MODE)
  else if (rl_editing_mode == vi_mode)
    return (char*) "vi";
    return "vi";
#endif /* VI_MODE */
  else
    return (char*) "none";
    return "none";
}

/* **************************************************************** */
@@ -1899,12 +1977,16 @@ rl_invoking_keyseqs_in_map (function, map)
		char *keyname = (char *)xmalloc (6 + strlen (seqs[i]));

		if (key == ESC)
#if 0
		  sprintf (keyname, "\\e");
#else
		/* XXX - experimental */
		  {
		    /* If ESC is the meta prefix and we're converting chars
		       with the eighth bit set to ESC-prefixed sequences, then
		       we can use \M-.  Otherwise we need to use the sequence
		       for ESC. */
		    if (_rl_convert_meta_chars_to_ascii && map[ESC].type == ISKMAP)
		      sprintf (keyname, "\\M-");
#endif
		    else
		      sprintf (keyname, "\\e");
		  }
		else if (CTRL_CHAR (key))
		  sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key)));
		else if (key == RUBOUT)
@@ -1966,7 +2048,7 @@ rl_function_dumper (print_readably)

  fprintf (rl_outstream, "\n");

  for (i = 0; (name = names[i]); i++)
  for (i = 0; name = names[i]; i++)
    {
      rl_command_func_t *function;
      char **invokers;
@@ -2025,8 +2107,8 @@ rl_function_dumper (print_readably)
   rl_outstream.  If an explicit argument is given, then print
   the output in such a way that it can be read back in. */
int
rl_dump_functions (int count __attribute__((unused)),
                   int key  __attribute__((unused)))
rl_dump_functions (count, key)
     int count, key;
{
  if (rl_dispatching)
    fprintf (rl_outstream, "\r\n");
@@ -2105,7 +2187,8 @@ rl_macro_dumper (print_readably)
}

int
rl_dump_macros(int count __attribute__((unused)), int key __attribute__((unused)))
rl_dump_macros (count, key)
     int count, key;
{
  if (rl_dispatching)
    fprintf (rl_outstream, "\r\n");
@@ -2114,87 +2197,96 @@ rl_dump_macros(int count __attribute__((unused)), int key __attribute__((unused)
  return (0);
}

void
rl_variable_dumper (print_readably)
     int print_readably;
static char *
_rl_get_string_variable_value (name)
     const char *name;
{
  int i;
  const char *kname;
  static char numbuf[32];
  char *ret;

  for (i = 0; boolean_varlist[i].name; i++)
  if (_rl_stricmp (name, "bell-style") == 0)
    {
      if (print_readably)
        fprintf (rl_outstream, "set %s %s\n", boolean_varlist[i].name,
			       *boolean_varlist[i].value ? "on" : "off");
      else
        fprintf (rl_outstream, "%s is set to `%s'\n", boolean_varlist[i].name,
			       *boolean_varlist[i].value ? "on" : "off");
    }

  /* bell-style */
      switch (_rl_bell_preference)
	{
	  case NO_BELL:
      kname = "none"; break;
	    return "none";
	  case VISIBLE_BELL:
      kname = "visible"; break;
	    return "visible";
	  case AUDIBLE_BELL:
	  default:
      kname = "audible"; break;
	    return "audible";
	}
    }
  else if (_rl_stricmp (name, "comment-begin") == 0)
    return (_rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
  else if (_rl_stricmp (name, "completion-query-items") == 0)
    {
      sprintf (numbuf, "%d", rl_completion_query_items);
      return (numbuf);
    }
  else if (_rl_stricmp (name, "editing-mode") == 0)
    return (rl_get_keymap_name_from_edit_mode ());
  else if (_rl_stricmp (name, "isearch-terminators") == 0)
    {
      if (_rl_isearch_terminators == 0)
	return 0;
      ret = _rl_untranslate_macro_value (_rl_isearch_terminators);
      if (ret)
	{
	  strncpy (numbuf, ret, sizeof (numbuf) - 1);
	  free (ret);
	  numbuf[sizeof(numbuf) - 1] = '\0';
	}
  if (print_readably)
    fprintf (rl_outstream, "set bell-style %s\n", kname);
  else
    fprintf (rl_outstream, "bell-style is set to `%s'\n", kname);

  /* comment-begin */
  if (print_readably)
    fprintf (rl_outstream, "set comment-begin %s\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
  else
    fprintf (rl_outstream, "comment-begin is set to `%s'\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);

  /* completion-query-items */
  if (print_readably)
    fprintf (rl_outstream, "set completion-query-items %d\n", rl_completion_query_items);
      else
    fprintf (rl_outstream, "completion-query-items is set to `%d'\n", rl_completion_query_items);

  /* editing-mode */
  if (print_readably)
    fprintf (rl_outstream, "set editing-mode %s\n", (rl_editing_mode == emacs_mode) ? "emacs" : "vi");
	numbuf[0] = '\0';
      return numbuf;
    }
  else if (_rl_stricmp (name, "keymap") == 0)
    {
      ret = rl_get_keymap_name (_rl_keymap);
      if (ret == 0)
	ret = rl_get_keymap_name_from_edit_mode ();
      return (ret ? ret : "none");
    }
  else
    fprintf (rl_outstream, "editing-mode is set to `%s'\n", (rl_editing_mode == emacs_mode) ? "emacs" : "vi");
    return (0);
}

  /* isearch-terminators */
  if (_rl_isearch_terminators)
void
rl_variable_dumper (print_readably)
     int print_readably;
{
      char *disp;

      disp = _rl_untranslate_macro_value (_rl_isearch_terminators);
  int i;
  char *v;

  for (i = 0; boolean_varlist[i].name; i++)
    {
      if (print_readably)
	fprintf (rl_outstream, "set isearch-terminators \"%s\"\n", disp);
        fprintf (rl_outstream, "set %s %s\n", boolean_varlist[i].name,
			       *boolean_varlist[i].value ? "on" : "off");
      else
	fprintf (rl_outstream, "isearch-terminators is set to \"%s\"\n", disp);

      free (disp);
        fprintf (rl_outstream, "%s is set to `%s'\n", boolean_varlist[i].name,
			       *boolean_varlist[i].value ? "on" : "off");
    }

  /* keymap */
  kname = rl_get_keymap_name (_rl_keymap);
  if (kname == 0)
    kname = rl_get_keymap_name_from_edit_mode ();
  for (i = 0; string_varlist[i].name; i++)
    {
      v = _rl_get_string_variable_value (string_varlist[i].name);
      if (v == 0)	/* _rl_isearch_terminators can be NULL */
	continue;
      if (print_readably)
    fprintf (rl_outstream, "set keymap %s\n", kname ? kname : "none");
        fprintf (rl_outstream, "set %s %s\n", string_varlist[i].name, v);
      else
    fprintf (rl_outstream, "keymap is set to `%s'\n", kname ? kname : "none");
        fprintf (rl_outstream, "%s is set to `%s'\n", string_varlist[i].name, v);
    }
}

/* Print all of the current variables and their values to
   rl_outstream.  If an explicit argument is given, then print
   the output in such a way that it can be read back in. */
int
rl_dump_variables(int count __attribute__((unused)), int key __attribute__((unused)))
rl_dump_variables (count, key)
     int count, key;
{
  if (rl_dispatching)
    fprintf (rl_outstream, "\r\n");
+118 −14
Original line number Diff line number Diff line
/* callback.c -- functions to use readline as an X `callback' mechanism. */

/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
/* Copyright (C) 1987-2005 Free Software Foundation, Inc.

   This file is part of the GNU Readline Library, a library for
   reading lines of text with interactive input and history editing.
@@ -21,7 +21,9 @@
   59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY

#include "config_readline.h"
#if defined (HAVE_CONFIG_H)
#  include <config.h>
#endif

#include "rlconf.h"

@@ -41,6 +43,12 @@
#include "rldefs.h"
#include "readline.h"
#include "rlprivate.h"
#include "xmalloc.h"

/* Private data for callback registration functions.  See comments in
   rl_callback_read_char for more details. */
_rl_callback_func_t *_rl_callback_func = 0;
_rl_callback_generic_arg *_rl_callback_data = 0;

/* **************************************************************** */
/*								    */
@@ -70,6 +78,7 @@ _rl_callback_newline ()
    {
      in_handler = 1;

      if (rl_prep_term_function)
	(*rl_prep_term_function) (_rl_meta_flag);

#if defined (HANDLE_SIGNALS)
@@ -87,6 +96,7 @@ rl_callback_handler_install (prompt, linefunc)
     rl_vcpfunc_t *linefunc;
{
  rl_set_prompt (prompt);
  RL_SETSTATE (RL_STATE_CALLBACK);
  rl_linefunc = linefunc;
  _rl_callback_newline ();
}
@@ -96,7 +106,8 @@ void
rl_callback_read_char ()
{
  char *line;
  int eof;
  int eof, jcode;
  static procenv_t olevel;

  if (rl_linefunc == NULL)
    {
@@ -104,15 +115,88 @@ rl_callback_read_char ()
      abort ();
    }

  memcpy ((void *)olevel, (void *)readline_top_level, sizeof (procenv_t));
  jcode = setjmp (readline_top_level);
  if (jcode)
    {
      (*rl_redisplay_function) ();
      _rl_want_redisplay = 0;
      memcpy ((void *)readline_top_level, (void *)olevel, sizeof (procenv_t));
      return;
    }

  do
    {
      if  (RL_ISSTATE (RL_STATE_ISEARCH))
	{
	  eof = _rl_isearch_callback (_rl_iscxt);
	  if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
	    rl_callback_read_char ();

	  return;
	}
      else if  (RL_ISSTATE (RL_STATE_NSEARCH))
	{
	  eof = _rl_nsearch_callback (_rl_nscxt);
	  return;
	}
      else if (RL_ISSTATE (RL_STATE_NUMERICARG))
	{
	  eof = _rl_arg_callback (_rl_argcxt);
	  if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
	    rl_callback_read_char ();
	  /* XXX - this should handle _rl_last_command_was_kill better */
	  else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
	    _rl_internal_char_cleanup ();

	  return;
	}
      else if (RL_ISSTATE (RL_STATE_MULTIKEY))
	{
	  eof = _rl_dispatch_callback (_rl_kscxt);	/* For now */
	  while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED))
	    eof = _rl_dispatch_callback (_rl_kscxt);
	  if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0)
	    {
	      _rl_internal_char_cleanup ();
	      _rl_want_redisplay = 1;
	    }
	}
      else if (_rl_callback_func)
	{
	  /* This allows functions that simply need to read an additional
	     character (like quoted-insert) to register a function to be
	     called when input is available.  _rl_callback_data is simply a
	     pointer to a struct that has the argument count originally
	     passed to the registering function and space for any additional
	     parameters.  */
	  eof = (*_rl_callback_func) (_rl_callback_data);
	  /* If the function `deregisters' itself, make sure the data is
	     cleaned up. */
	  if (_rl_callback_func == 0)
	    {
	      if (_rl_callback_data) 	
		{
		  _rl_callback_data_dispose (_rl_callback_data);
		  _rl_callback_data = 0;
		}
	      _rl_internal_char_cleanup ();
	    }
	}
      else
	eof = readline_internal_char ();

  /* We loop in case some function has pushed input back with rl_execute_next. */
  for (;;)
      if (rl_done == 0 && _rl_want_redisplay)
	{
	  (*rl_redisplay_function) ();
	  _rl_want_redisplay = 0;
	}

      if (rl_done)
	{
	  line = readline_internal_teardown (eof);

	  if (rl_deprep_term_function)
	    (*rl_deprep_term_function) ();
#if defined (HANDLE_SIGNALS)
	  rl_clear_signals ();
@@ -129,11 +213,8 @@ rl_callback_read_char ()
	  if (in_handler == 0 && rl_linefunc)
	    _rl_callback_newline ();
	}
      if (rl_pending_input || _rl_pushed_input_available ())
	eof = readline_internal_char ();
      else
        break;
    }
  while (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT));
}

/* Remove the handler, and make sure the terminal is in its normal state. */
@@ -141,9 +222,11 @@ void
rl_callback_handler_remove ()
{
  rl_linefunc = NULL;
  RL_UNSETSTATE (RL_STATE_CALLBACK);
  if (in_handler)
    {
      in_handler = 0;
      if (rl_deprep_term_function)
	(*rl_deprep_term_function) ();
#if defined (HANDLE_SIGNALS)
      rl_clear_signals ();
@@ -151,4 +234,25 @@ rl_callback_handler_remove ()
    }
}

_rl_callback_generic_arg *
_rl_callback_data_alloc (count)
     int count;
{
  _rl_callback_generic_arg *arg;

  arg = (_rl_callback_generic_arg *)xmalloc (sizeof (_rl_callback_generic_arg));
  arg->count = count;

  arg->i1 = arg->i2 = 0;

  return arg;
}

void _rl_callback_data_dispose (arg)
     _rl_callback_generic_arg *arg;
{
  if (arg)
    free (arg);
}

#endif
+2 −4
Original line number Diff line number Diff line
@@ -59,11 +59,7 @@
#define largest_char 255		    /* Largest character value. */

#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
#if largest_char >= 255
#define META_CHAR(c) ((c) > meta_character_threshold)
#else
#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
#endif

#define CTRL(c) ((c) & control_character_mask)
#define META(c) ((c) | meta_character_bit)
@@ -90,6 +86,8 @@
/* Some systems define these; we want our definitions. */
#undef ISPRINT

/* Beware:  these only work with single-byte ASCII characters. */

#define ISALNUM(c)	(IN_CTYPE_DOMAIN (c) && isalnum (c))
#define ISALPHA(c)	(IN_CTYPE_DOMAIN (c) && isalpha (c))
#define ISDIGIT(c)	(IN_CTYPE_DOMAIN (c) && isdigit (c))
Loading