Commit 953f6c51 authored by unknown's avatar unknown

upgrade readline to version 4.3


client/completion_hash.cc:
  correct headers of functions for readline 4.3 (add const modifier to char*)
client/completion_hash.h:
  correct headers of functions for readline 4.3 (add const modifier to char*)
client/mysql.cc:
  correct functions for readline 4.3
parent 0fb3b8d9
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include <my_sys.h> #include <my_sys.h>
#include "completion_hash.h" #include "completion_hash.h"
uint hashpjw(char *arKey, uint nKeyLength) uint hashpjw(const char *arKey, uint nKeyLength)
{ {
uint h = 0, g, i; uint h = 0, g, i;
...@@ -111,7 +111,7 @@ int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength, ...@@ -111,7 +111,7 @@ int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength,
return SUCCESS; return SUCCESS;
} }
static Bucket *completion_hash_find(HashTable *ht, char *arKey, static Bucket *completion_hash_find(HashTable *ht, const char *arKey,
uint nKeyLength) uint nKeyLength)
{ {
uint h, nIndex; uint h, nIndex;
...@@ -156,7 +156,7 @@ int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength) ...@@ -156,7 +156,7 @@ int completion_hash_exists(HashTable *ht, char *arKey, uint nKeyLength)
return 0; return 0;
} }
Bucket *find_all_matches(HashTable *ht, char *str, uint length, Bucket *find_all_matches(HashTable *ht, const char *str, uint length,
uint *res_length) uint *res_length)
{ {
Bucket *b; Bucket *b;
......
...@@ -43,14 +43,14 @@ typedef struct hashtable { ...@@ -43,14 +43,14 @@ typedef struct hashtable {
uint nTableSize; uint nTableSize;
uint initialized; uint initialized;
MEM_ROOT mem_root; MEM_ROOT mem_root;
uint(*pHashFunction) (char *arKey, uint nKeyLength); uint(*pHashFunction) (const char *arKey, uint nKeyLength);
Bucket **arBuckets; Bucket **arBuckets;
} HashTable; } HashTable;
extern int completion_hash_init(HashTable *ht, uint nSize); extern int completion_hash_init(HashTable *ht, uint nSize);
extern int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength, char *str); extern int completion_hash_update(HashTable *ht, char *arKey, uint nKeyLength, char *str);
extern int hash_exists(HashTable *ht, char *arKey); extern int hash_exists(HashTable *ht, char *arKey);
extern Bucket *find_all_matches(HashTable *ht, char *str, uint length, uint *res_length); extern Bucket *find_all_matches(HashTable *ht, const char *str, uint length, uint *res_length);
extern Bucket *find_longest_match(HashTable *ht, char *str, uint length, uint *res_length); extern Bucket *find_longest_match(HashTable *ht, char *str, uint length, uint *res_length);
extern void add_word(HashTable *ht,char *str); extern void add_word(HashTable *ht,char *str);
extern void completion_hash_clean(HashTable *ht); extern void completion_hash_clean(HashTable *ht);
......
...@@ -1049,8 +1049,8 @@ static bool add_line(String &buffer,char *line,char *in_string) ...@@ -1049,8 +1049,8 @@ static bool add_line(String &buffer,char *line,char *in_string)
#ifdef HAVE_READLINE #ifdef HAVE_READLINE
static char *new_command_generator(char *text, int); static char *new_command_generator(const char *text, int);
static char **new_mysql_completion (char *text, int start, int end); static char **new_mysql_completion (const char *text, int start, int end);
/* /*
Tell the GNU Readline library how to complete. We want to try to complete Tell the GNU Readline library how to complete. We want to try to complete
...@@ -1058,8 +1058,8 @@ static char **new_mysql_completion (char *text, int start, int end); ...@@ -1058,8 +1058,8 @@ static char **new_mysql_completion (char *text, int start, int end);
if not. if not.
*/ */
char **no_completion (char *text __attribute__ ((unused)), char *no_completion (const char *text __attribute__ ((unused)),
char *word __attribute__ ((unused))) int )
{ {
return 0; /* No filename completion */ return 0; /* No filename completion */
} }
...@@ -1071,8 +1071,8 @@ static void initialize_readline (char *name) ...@@ -1071,8 +1071,8 @@ static void initialize_readline (char *name)
/* Tell the completer that we want a crack first. */ /* Tell the completer that we want a crack first. */
/* rl_attempted_completion_function = (CPPFunction *)mysql_completion;*/ /* rl_attempted_completion_function = (CPPFunction *)mysql_completion;*/
rl_attempted_completion_function = (CPPFunction *) new_mysql_completion; rl_attempted_completion_function = &new_mysql_completion;
rl_completion_entry_function=(Function *) no_completion; rl_completion_entry_function= &no_completion;
} }
/* /*
...@@ -1082,17 +1082,17 @@ static void initialize_readline (char *name) ...@@ -1082,17 +1082,17 @@ static void initialize_readline (char *name)
array of matches, or NULL if there aren't any. array of matches, or NULL if there aren't any.
*/ */
static char **new_mysql_completion (char *text, static char **new_mysql_completion (const char *text,
int start __attribute__((unused)), int start __attribute__((unused)),
int end __attribute__((unused))) int end __attribute__((unused)))
{ {
if (!status.batch && !quick) if (!status.batch && !quick)
return completion_matches(text, (CPFunction*) new_command_generator); return rl_completion_matches(text, new_command_generator);
else else
return (char**) 0; return (char**) 0;
} }
static char *new_command_generator(char *text,int state) static char *new_command_generator(const char *text,int state)
{ {
static int textlen; static int textlen;
char *ptr; char *ptr;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
Version 2, June 1991 Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc. Copyright (C) 1989, 1991 Free Software Foundation, Inc.
675 Mass Ave, Cambridge, MA 02139, USA 59 Temple Place, Suite 330, Boston, MA 02111 USA
Everyone is permitted to copy and distribute verbatim copies Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed. of this license document, but changing it is not allowed.
...@@ -305,7 +305,7 @@ the "copyright" line and a pointer to where the full notice is found. ...@@ -305,7 +305,7 @@ the "copyright" line and a pointer to where the full notice is found.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
Also add information on how to contact you by electronic and paper mail. Also add information on how to contact you by electronic and paper mail.
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ libreadline_a_SOURCES = readline.c funmap.c keymaps.c \ ...@@ -15,7 +15,7 @@ libreadline_a_SOURCES = readline.c funmap.c keymaps.c \
callback.c terminal.c xmalloc.c \ callback.c terminal.c xmalloc.c \
history.c histsearch.c histexpand.c \ history.c histsearch.c histexpand.c \
histfile.c nls.c search.c \ histfile.c nls.c search.c \
shell.c tilde.c shell.c tilde.c misc.c text.c mbutil.c
pkginclude_HEADERS = readline.h chardefs.h keymaps.h history.h tilde.h pkginclude_HEADERS = readline.h chardefs.h keymaps.h history.h tilde.h
......
Introduction Introduction
============ ============
This is the Gnu Readline library, version 4.0. This is the Gnu Readline library, version 4.3.
The Readline library provides a set of functions for use by applications 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 that allow users to edit command lines as they are typed in. Both
...@@ -16,8 +16,8 @@ may be used without Readline in applications which desire its ...@@ -16,8 +16,8 @@ may be used without Readline in applications which desire its
capabilities. capabilities.
The Readline library is free software, distributed under the terms of The Readline library is free software, distributed under the terms of
the GNU Public License, version 2. For more information, see the file the [GNU] General Public License, version 2. For more information, see
COPYING. the file COPYING.
To build the library, try typing `./configure', then `make'. The To build the library, try typing `./configure', then `make'. The
configuration process is automated, so no further intervention should configuration process is automated, so no further intervention should
...@@ -37,6 +37,9 @@ to customize and control the build process. ...@@ -37,6 +37,9 @@ to customize and control the build process.
The file rlconf.h contains C preprocessor defines that enable and disable The file rlconf.h contains C preprocessor defines that enable and disable
certain Readline features. certain Readline features.
The special make target `everything' will build the static and shared
libraries (if the target platform supports them) and the examples.
Examples Examples
======== ========
...@@ -54,6 +57,9 @@ a Makefile in the `shlib' subdirectory, and typing `make shared' ...@@ -54,6 +57,9 @@ a Makefile in the `shlib' subdirectory, and typing `make shared'
will cause shared versions of the Readline and History libraries will cause shared versions of the Readline and History libraries
to be built on supported platforms. to be built on supported platforms.
If `configure' is given the `--enable-shared' option, it will attempt
to build the shared libraries by default on supported platforms.
Configure calls the script support/shobj-conf to test whether or Configure calls the script support/shobj-conf to test whether or
not shared library creation is supported and to generate the values not shared library creation is supported and to generate the values
of variables that are substituted into shlib/Makefile. If you of variables that are substituted into shlib/Makefile. If you
...@@ -64,8 +70,8 @@ your platform. ...@@ -64,8 +70,8 @@ your platform.
If you need to update support/shobj-conf, you will need to create If you need to update support/shobj-conf, you will need to create
a `stanza' for your operating system and compiler. The script uses a `stanza' for your operating system and compiler. The script uses
the value of host_os and ${CC} as determined by configure. For the value of host_os and ${CC} as determined by configure. For
instance, FreeBSD 2.2.5 with any version of gcc is identified as instance, FreeBSD 4.2 with any version of gcc is identified as
`freebsd2.2.5-gcc*'. `freebsd4.2-gcc*'.
In the stanza for your operating system-compiler pair, you will need to In the stanza for your operating system-compiler pair, you will need to
define several variables. They are: define several variables. They are:
...@@ -122,18 +128,21 @@ Once you have updated support/shobj-conf, re-run configure and type ...@@ -122,18 +128,21 @@ Once you have updated support/shobj-conf, re-run configure and type
`make shared'. The shared libraries will be created in the shlib `make shared'. The shared libraries will be created in the shlib
subdirectory. subdirectory.
Since shared libraries are not created on all platforms, `make install' If shared libraries are created, `make install' will install them.
will not automatically install the shared libraries. To install them, You may install only the shared libraries by running `make
change the current directory to shlib and type `make install'. Running install-shared' from the top-level build directory. Running `make
`make install-shared' from the top-level build directory will also work. install' in the shlib subdirectory will also work. If you don't want
to install any created shared libraries, run `make install-static'.
Documentation Documentation
============= =============
The documentation for the Readline and History libraries appears in the The documentation for the Readline and History libraries appears in
`doc' subdirectory. There are two texinfo files and a Unix-style manual the `doc' subdirectory. There are three texinfo files and a
page describing the programming facilities available in the Readline Unix-style manual page describing the facilities available in the
library. The texinfo files include both user and programmer's manuals. Readline library. The texinfo files include both user and
programmer's manuals. HTML versions of the manuals appear in the
`doc' subdirectory as well.
Reporting Bugs Reporting Bugs
============== ==============
...@@ -144,7 +153,7 @@ Bug reports for Readline should be sent to: ...@@ -144,7 +153,7 @@ Bug reports for Readline should be sent to:
When reporting a bug, please include the following information: When reporting a bug, please include the following information:
* the version number and release status of Readline (e.g., 4.0-release) * the version number and release status of Readline (e.g., 4.2-release)
* the machine and OS that it is running on * the machine and OS that it is running on
* a list of the compilation flags or the contents of `config.h', if * a list of the compilation flags or the contents of `config.h', if
appropriate appropriate
......
...@@ -18,18 +18,31 @@ ...@@ -18,18 +18,31 @@
You should have received a copy of the GNU General Public License along You should have received a copy of the GNU General Public License along
with Bash; see the file COPYING. If not, write to the Free Software with Bash; see the file COPYING. If not, write to the Free Software
Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_STDLIB_H_) #if !defined (_STDLIB_H_)
#define _STDLIB_H_ 1 #define _STDLIB_H_ 1
/* String conversion functions. */ /* String conversion functions. */
extern int atoi (); extern int atoi ();
extern long int atol ();
extern double atof ();
extern double strtod ();
/* Memory allocation functions. */ /* Memory allocation functions. */
extern char *malloc (); /* Generic pointer type. */
extern char *realloc (); #ifndef PTR_T
#if defined (__STDC__)
# define PTR_T void *
#else
# define PTR_T char *
#endif
#endif /* PTR_T */
extern PTR_T malloc ();
extern PTR_T realloc ();
extern void free (); extern void free ();
/* Other miscellaneous functions. */ /* Other miscellaneous functions. */
......
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 1, or as published by the Free Software Foundation; either version 2, or
(at your option) any later version. (at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be The GNU Readline Library is distributed in the hope that it will be
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation, have a copy of the license, write to the Free Software Foundation,
675 Mass Ave, Cambridge, MA 02139, USA. */ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY #define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H) #if defined (HAVE_CONFIG_H)
...@@ -29,22 +29,20 @@ ...@@ -29,22 +29,20 @@
#if defined (READLINE_CALLBACKS) #if defined (READLINE_CALLBACKS)
#include <stdlib.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif
#include <stdio.h> #include <stdio.h>
/* System-specific feature definitions and include files. */ /* System-specific feature definitions and include files. */
#include "rldefs.h" #include "rldefs.h"
#include "readline.h" #include "readline.h"
#include "rlprivate.h"
extern void readline_internal_setup ();
extern char *readline_internal_teardown ();
extern int readline_internal_char ();
extern void _rl_init_line_state ();
extern int _rl_meta_flag;
extern char *rl_prompt;
extern int rl_visible_prompt_length;
/* **************************************************************** */ /* **************************************************************** */
/* */ /* */
...@@ -61,7 +59,7 @@ extern int rl_visible_prompt_length; ...@@ -61,7 +59,7 @@ extern int rl_visible_prompt_length;
text read in at each end of line. The terminal is kept prepped and text read in at each end of line. The terminal is kept prepped and
signals handled all the time, except during calls to the user's function. */ signals handled all the time, except during calls to the user's function. */
VFunction *rl_linefunc; /* user callback function */ rl_vcpfunc_t *rl_linefunc; /* user callback function */
static int in_handler; /* terminal_prepped and signals set? */ static int in_handler; /* terminal_prepped and signals set? */
/* Make sure the terminal is set up, initialize readline, and prompt. */ /* Make sure the terminal is set up, initialize readline, and prompt. */
...@@ -87,11 +85,10 @@ _rl_callback_newline () ...@@ -87,11 +85,10 @@ _rl_callback_newline ()
/* Install a readline handler, set up the terminal, and issue the prompt. */ /* Install a readline handler, set up the terminal, and issue the prompt. */
void void
rl_callback_handler_install (prompt, linefunc) rl_callback_handler_install (prompt, linefunc)
char *prompt; const char *prompt;
VFunction *linefunc; rl_vcpfunc_t *linefunc;
{ {
rl_prompt = prompt; rl_set_prompt (prompt);
rl_visible_prompt_length = rl_prompt ? rl_expand_prompt (rl_prompt) : 0;
rl_linefunc = linefunc; rl_linefunc = linefunc;
_rl_callback_newline (); _rl_callback_newline ();
} }
...@@ -111,6 +108,9 @@ rl_callback_read_char () ...@@ -111,6 +108,9 @@ rl_callback_read_char ()
eof = readline_internal_char (); eof = readline_internal_char ();
/* We loop in case some function has pushed input back with rl_execute_next. */
for (;;)
{
if (rl_done) if (rl_done)
{ {
line = readline_internal_teardown (eof); line = readline_internal_teardown (eof);
...@@ -126,10 +126,16 @@ rl_callback_read_char () ...@@ -126,10 +126,16 @@ rl_callback_read_char ()
if (rl_line_buffer[0]) if (rl_line_buffer[0])
_rl_init_line_state (); _rl_init_line_state ();
/* Redisplay the prompt if readline_handler_{install,remove} not called. */ /* Redisplay the prompt if readline_handler_{install,remove}
not called. */
if (in_handler == 0 && rl_linefunc) if (in_handler == 0 && rl_linefunc)
_rl_callback_newline (); _rl_callback_newline ();
} }
if (rl_pending_input)
eof = readline_internal_char ();
else
break;
}
} }
/* Remove the handler, and make sure the terminal is in its normal state. */ /* Remove the handler, and make sure the terminal is in its normal state. */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 1, or as published by the Free Software Foundation; either version 2, or
(at your option) any later version. (at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be The GNU Readline Library is distributed in the hope that it will be
...@@ -18,21 +18,23 @@ ...@@ -18,21 +18,23 @@
The GNU General Public License is often shipped with GNU software, and The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation, have a copy of the license, write to the Free Software Foundation,
675 Mass Ave, Cambridge, MA 02139, USA. */ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _CHARDEFS_H_ #ifndef _CHARDEFS_H_
#define _CHARDEFS_H_ #define _CHARDEFS_H_
#ifndef _m_ctype_h
#include <ctype.h> #include <ctype.h>
#endif
#if defined (HAVE_CONFIG_H) #if defined (HAVE_CONFIG_H)
# if defined (HAVE_STRING_H) # if defined (HAVE_STRING_H)
# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
# include <memory.h>
# endif
# include <string.h> # include <string.h>
# else
# include <strings.h>
# endif /* HAVE_STRING_H */ # endif /* HAVE_STRING_H */
# if defined (HAVE_STRINGS_H)
# include <strings.h>
# endif /* HAVE_STRINGS_H */
#else #else
# include <string.h> # include <string.h>
#endif /* !HAVE_CONFIG_H */ #endif /* !HAVE_CONFIG_H */
...@@ -42,7 +44,10 @@ ...@@ -42,7 +44,10 @@
#endif #endif
#ifdef CTRL #ifdef CTRL
#undef CTRL # undef CTRL
#endif
#ifdef UNCTRL
# undef UNCTRL
#endif #endif
/* Some character stuff. */ /* Some character stuff. */
...@@ -53,7 +58,7 @@ ...@@ -53,7 +58,7 @@
#define meta_character_bit 0x080 /* x0000000, must be on. */ #define meta_character_bit 0x080 /* x0000000, must be on. */
#define largest_char 255 /* Largest character value. */ #define largest_char 255 /* Largest character value. */
#define CTRL_CHAR(c) ((c) < control_character_threshold && (c) >= 0) #define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char) #define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
#define CTRL(c) ((c) & control_character_mask) #define CTRL(c) ((c) & control_character_mask)
...@@ -62,32 +67,58 @@ ...@@ -62,32 +67,58 @@
#define UNMETA(c) ((c) & (~meta_character_bit)) #define UNMETA(c) ((c) & (~meta_character_bit))
#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit)) #define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
/* Old versions #if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII))
#define _rl_lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1))) # define IN_CTYPE_DOMAIN(c) 1
#define _rl_uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1))) #else
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9') # define IN_CTYPE_DOMAIN(c) isascii(c)
*/ #endif
#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
#endif
#define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
#define _rl_lowercase_p(c) (islower(c)) /* Some systems define these; we want our definitions. */
#define _rl_uppercase_p(c) (isupper(c)) #undef ISPRINT
#define _rl_digit_p(x) (isdigit (x))
#define _rl_pure_alphabetic(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c)) #define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
#define ALPHABETIC(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c) || _rl_digit_p(c)) #define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
/* Old versions #define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c))
# define _rl_to_upper(c) (_rl_lowercase_p(c) ? ((c) - 32) : (c)) #define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c))
# define _rl_to_lower(c) (_rl_uppercase_p(c) ? ((c) + 32) : (c)) #define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
*/
#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c))
#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c))
#ifndef _rl_to_upper #ifndef _rl_to_upper
# define _rl_to_upper(c) (islower(c) ? toupper(c) : (c)) # define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c))
# define _rl_to_lower(c) (isupper(c) ? tolower(c) : (c)) # define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c))
#endif #endif
#ifndef _rl_digit_value #ifndef _rl_digit_value
#define _rl_digit_value(x) ((x) - '0') # define _rl_digit_value(x) ((x) - '0')
#endif
#ifndef _rl_isident
# define _rl_isident(c) (ISALNUM(c) || (c) == '_')
#endif
#ifndef ISOCTAL
# define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
#endif #endif
#define OCTVALUE(c) ((c) - '0')
#define HEXVALUE(c) \
(((c) >= 'a' && (c) <= 'f') \
? (c)-'a'+10 \
: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
#ifndef NEWLINE #ifndef NEWLINE
#define NEWLINE '\n' #define NEWLINE '\n'
...@@ -125,18 +156,4 @@ ...@@ -125,18 +156,4 @@
#endif #endif
#define ESC CTRL('[') #define ESC CTRL('[')
#ifndef ISOCTAL
#define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
#endif
#define OCTVALUE(c) ((c) - '0')
#ifndef isxdigit
# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
#endif
#define HEXVALUE(c) \
(((c) >= 'a' && (c) <= 'f') \
? (c)-'a'+10 \
: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
#endif /* _CHARDEFS_H_ */ #endif /* _CHARDEFS_H_ */
This diff is collapsed.
This diff is collapsed.
...@@ -4,34 +4,49 @@ dnl ...@@ -4,34 +4,49 @@ dnl
dnl report bugs to chet@po.cwru.edu dnl report bugs to chet@po.cwru.edu
dnl dnl
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
AC_REVISION([for Readline 4.0, version 2.14, from autoconf version] AC_ACVERSION) AC_REVISION([for Readline 4.3, version 2.45, from autoconf version] AC_ACVERSION)
LIBVERSION=4.0
AC_INIT(readline.h) AC_INIT(readline, 4.3, bug-readline@gnu.org)
AC_CONFIG_HEADER(config.h)
dnl make sure we are using a recent autoconf version dnl make sure we are using a recent autoconf version
AC_PREREQ(2.10) AC_PREREQ(2.50)
AC_CONFIG_SRCDIR(readline.h)
AC_CONFIG_AUX_DIR(./support) AC_CONFIG_AUX_DIR(./support)
AC_CONFIG_HEADERS(config.h)
dnl update the value of RL_READLINE_VERSION in readline.h when this changes
LIBVERSION=4.3
AC_CANONICAL_HOST AC_CANONICAL_HOST
dnl configure defaults dnl configure defaults
opt_curses=no opt_curses=no
opt_shared=no
dnl arguments to configure dnl arguments to configure
AC_ARG_WITH(curses, --with-curses use the curses library instead of the termcap library,opt_curses=$withval) AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
if test "$opt_curses" = "yes"; then if test "$opt_curses" = "yes"; then
prefer_curses=yes prefer_curses=yes
fi fi
dnl option parsing for optional features
opt_static_libs=yes
opt_shared_libs=yes
AC_ARG_ENABLE(shared, AC_HELP_STRING([--enable-shared], [build shared libraries [[default=YES]]]), opt_shared_libs=$enableval)
AC_ARG_ENABLE(static, AC_HELP_STRING([--enable-static], [build static libraries [[default=YES]]]), opt_static_libs=$enableval)
echo ""
echo "Beginning configuration for readline-$LIBVERSION for ${host_cpu}-${host_vendor}-${host_os}"
echo ""
# We want these before the checks, so the checks can modify their values. # We want these before the checks, so the checks can modify their values.
test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1 test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
AC_PROG_MAKE_SET
AC_PROG_CC AC_PROG_CC
dnl AC_AIX
AC_MINIX AC_MINIX
# If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS. # If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
...@@ -39,7 +54,7 @@ test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O" ...@@ -39,7 +54,7 @@ test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
AC_PROG_GCC_TRADITIONAL AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL AC_PROG_INSTALL
AC_CHECK_PROG(AR, ar, ar) AC_CHECK_PROG(AR, ar, , ar)
dnl Set default for ARFLAGS, since autoconf does not have a macro for it. dnl Set default for ARFLAGS, since autoconf does not have a macro for it.
dnl This allows people to set it when running configure or make dnl This allows people to set it when running configure or make
test -n "$ARFLAGS" || ARFLAGS="cr" test -n "$ARFLAGS" || ARFLAGS="cr"
...@@ -48,32 +63,42 @@ AC_PROG_RANLIB ...@@ -48,32 +63,42 @@ AC_PROG_RANLIB
MAKE_SHELL=/bin/sh MAKE_SHELL=/bin/sh
AC_SUBST(MAKE_SHELL) AC_SUBST(MAKE_SHELL)
AC_RETSIGTYPE AC_C_CONST
AC_C_PROTOTYPES
AC_C_CHAR_UNSIGNED
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_CHECK_TYPE(ssize_t, int)
AC_HEADER_STAT AC_HEADER_STAT
AC_HEADER_DIRENT AC_HEADER_DIRENT
AC_CHECK_FUNCS(strcasecmp select setenv putenv tcgetattr setlocale lstat) AC_CHECK_FUNCS(lstat memmove putenv select setenv setlocale \
strcasecmp strpbrk tcgetattr vsnprintf isascii isxdigit)
AC_FUNC_STRCOLL AC_FUNC_STRCOLL
AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h \ AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h strings.h \
sys/ptem.h sys/pte.h sys/stream.h sys/select.h \ limits.h sys/ptem.h sys/pte.h sys/stream.h sys/select.h \
termcap.h termios.h termio.h sys/file.h locale.h) termcap.h termios.h termio.h sys/file.h locale.h memory.h )
BASH_SIGNAL_CHECK BASH_SYS_SIGNAL_VINTAGE
BASH_REINSTALL_SIGHANDLERS BASH_SYS_REINSTALL_SIGHANDLERS
BASH_FUNC_POSIX_SETJMP BASH_FUNC_POSIX_SETJMP
BASH_FUNC_LSTAT BASH_FUNC_LSTAT
BASH_CHECK_GETPW_FUNCS
BASH_FUNC_STRCOLL BASH_FUNC_STRCOLL
BASH_CHECK_GETPW_FUNCS
AC_HEADER_TIOCGWINSZ
BASH_TYPE_SIGHANDLER BASH_TYPE_SIGHANDLER
BASH_HAVE_TIOCGWINSZ
BASH_HAVE_TIOCSTAT BASH_HAVE_TIOCSTAT
BASH_HAVE_FIONREAD BASH_HAVE_FIONREAD
BASH_MISC_SPEED_T BASH_CHECK_SPEED_T
BASH_STRUCT_WINSIZE BASH_STRUCT_WINSIZE
BASH_STRUCT_DIRENT_D_INO BASH_STRUCT_DIRENT_D_INO
BASH_STRUCT_DIRENT_D_FILENO BASH_STRUCT_DIRENT_D_FILENO
...@@ -84,11 +109,18 @@ aix*) prefer_curses=yes ;; ...@@ -84,11 +109,18 @@ aix*) prefer_curses=yes ;;
esac esac
BASH_CHECK_LIB_TERMCAP BASH_CHECK_LIB_TERMCAP
if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
if test "$prefer_curses" = yes; then
TERMCAP_LIB=-lcurses
else
TERMCAP_LIB=-ltermcap #default TERMCAP_LIB=-ltermcap #default
fi
fi fi
BASH_CHECK_MULTIBYTE
case "$host_cpu" in case "$host_cpu" in
*cray*) LOCAL_CFLAGS=-DCRAY ;; *cray*) LOCAL_CFLAGS=-DCRAY ;;
*s390*) LOCAL_CFLAGS=-fsigned-char ;;
esac esac
case "$host_os" in case "$host_os" in
...@@ -102,7 +134,7 @@ esac ...@@ -102,7 +134,7 @@ esac
# #
if test -f ${srcdir}/support/shobj-conf; then if test -f ${srcdir}/support/shobj-conf; then
AC_MSG_CHECKING(configuration for building shared libraries) AC_MSG_CHECKING(configuration for building shared libraries)
eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C ${CC} -c ${host_cpu} -o ${host_os} -v ${host_vendor}` eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
AC_SUBST(SHOBJ_CC) AC_SUBST(SHOBJ_CC)
AC_SUBST(SHOBJ_CFLAGS) AC_SUBST(SHOBJ_CFLAGS)
AC_SUBST(SHOBJ_LD) AC_SUBST(SHOBJ_LD)
...@@ -116,9 +148,40 @@ if test -f ${srcdir}/support/shobj-conf; then ...@@ -116,9 +148,40 @@ if test -f ${srcdir}/support/shobj-conf; then
AC_SUBST(SHLIB_LIBVERSION) AC_SUBST(SHLIB_LIBVERSION)
AC_SUBST(SHLIB_LIBS) AC_SUBST(SHLIB_LIBS)
AC_MSG_RESULT($SHLIB_STATUS) AC_MSG_RESULT($SHLIB_STATUS)
# SHLIB_STATUS is either `supported' or `unsupported'. If it's
# `unsupported', turn off any default shared library building
if test "$SHLIB_STATUS" = 'unsupported'; then
opt_shared_libs=no
fi
# shared library versioning
# quoted for m4 so I can use character classes
SHLIB_MAJOR=[`expr "$LIBVERSION" : '\([0-9]\)\..*'`]
SHLIB_MINOR=[`expr "$LIBVERSION" : '[0-9]\.\([0-9]\).*'`]
AC_SUBST(SHLIB_MAJOR)
AC_SUBST(SHLIB_MINOR)
fi
if test "$opt_static_libs" = "yes"; then
STATIC_TARGET=static
STATIC_INSTALL_TARGET=install-static
fi
if test "$opt_shared_libs" = "yes"; then
SHARED_TARGET=shared
SHARED_INSTALL_TARGET=install-shared
fi fi
BUILD_DIR=`pwd` AC_SUBST(STATIC_TARGET)
AC_SUBST(SHARED_TARGET)
AC_SUBST(STATIC_INSTALL_TARGET)
AC_SUBST(SHARED_INSTALL_TARGET)
case "$host_os" in
msdosdjgpp*) BUILD_DIR=`pwd.exe` ;; # to prevent //d/path/file
*) BUILD_DIR=`pwd` ;;
esac
AC_SUBST(BUILD_DIR) AC_SUBST(BUILD_DIR)
AC_SUBST(CFLAGS) AC_SUBST(CFLAGS)
......
This diff is collapsed.
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 1, or as published by the Free Software Foundation; either version 2, or
(at your option) any later version. (at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be The GNU Readline Library is distributed in the hope that it will be
...@@ -18,15 +18,13 @@ ...@@ -18,15 +18,13 @@
The GNU General Public License is often shipped with GNU software, and The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation, have a copy of the license, write to the Free Software Foundation,
675 Mass Ave, Cambridge, MA 02139, USA. */ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY #define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H) #if defined (HAVE_CONFIG_H)
# include <config.h> # include <config.h>
#endif #endif
extern char *xmalloc (), *xrealloc ();
#if !defined (BUFSIZ) #if !defined (BUFSIZ)
#include <stdio.h> #include <stdio.h>
#endif /* BUFSIZ */ #endif /* BUFSIZ */
...@@ -40,7 +38,15 @@ extern char *xmalloc (), *xrealloc (); ...@@ -40,7 +38,15 @@ extern char *xmalloc (), *xrealloc ();
#include "rlconf.h" #include "rlconf.h"
#include "readline.h" #include "readline.h"
extern int _rl_qsort_string_compare (); #include "xmalloc.h"
#ifdef __STDC__
typedef int QSFUNC (const void *, const void *);
#else
typedef int QSFUNC ();
#endif
extern int _rl_qsort_string_compare PARAMS((char **, char **));
FUNMAP **funmap; FUNMAP **funmap;
static int funmap_size; static int funmap_size;
...@@ -54,7 +60,8 @@ static FUNMAP default_funmap[] = { ...@@ -54,7 +60,8 @@ static FUNMAP default_funmap[] = {
{ "abort", rl_abort }, { "abort", rl_abort },
{ "accept-line", rl_newline }, { "accept-line", rl_newline },
{ "arrow-key-prefix", rl_arrow_keys }, { "arrow-key-prefix", rl_arrow_keys },
{ "backward-char", rl_backward }, { "backward-byte", rl_backward_byte },
{ "backward-char", rl_backward_char },
{ "backward-delete-char", rl_rubout }, { "backward-delete-char", rl_rubout },
{ "backward-kill-line", rl_backward_kill_line }, { "backward-kill-line", rl_backward_kill_line },
{ "backward-kill-word", rl_backward_kill_word }, { "backward-kill-word", rl_backward_kill_word },
...@@ -85,7 +92,8 @@ static FUNMAP default_funmap[] = { ...@@ -85,7 +92,8 @@ static FUNMAP default_funmap[] = {
{ "end-of-line", rl_end_of_line }, { "end-of-line", rl_end_of_line },
{ "exchange-point-and-mark", rl_exchange_point_and_mark }, { "exchange-point-and-mark", rl_exchange_point_and_mark },
{ "forward-backward-delete-char", rl_rubout_or_delete }, { "forward-backward-delete-char", rl_rubout_or_delete },
{ "forward-char", rl_forward }, { "forward-byte", rl_forward_byte },
{ "forward-char", rl_forward_char },
{ "forward-search-history", rl_forward_search_history }, { "forward-search-history", rl_forward_search_history },
{ "forward-word", rl_forward_word }, { "forward-word", rl_forward_word },
{ "history-search-backward", rl_history_search_backward }, { "history-search-backward", rl_history_search_backward },
...@@ -102,7 +110,8 @@ static FUNMAP default_funmap[] = { ...@@ -102,7 +110,8 @@ static FUNMAP default_funmap[] = {
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search }, { "non-incremental-reverse-search-history", rl_noninc_reverse_search },
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again }, { "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again }, { "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
#ifdef __CYGWIN32__ { "overwrite-mode", rl_overwrite_mode },
#ifdef __CYGWIN__
{ "paste-from-clipboard", rl_paste_from_clipboard }, { "paste-from-clipboard", rl_paste_from_clipboard },
#endif #endif
{ "possible-completions", rl_possible_completions }, { "possible-completions", rl_possible_completions },
...@@ -136,7 +145,6 @@ static FUNMAP default_funmap[] = { ...@@ -136,7 +145,6 @@ static FUNMAP default_funmap[] = {
{ "vi-arg-digit", rl_vi_arg_digit }, { "vi-arg-digit", rl_vi_arg_digit },
{ "vi-back-to-indent", rl_vi_back_to_indent }, { "vi-back-to-indent", rl_vi_back_to_indent },
{ "vi-bWord", rl_vi_bWord }, { "vi-bWord", rl_vi_bWord },
{ "vi-bracktype", rl_vi_bracktype },
{ "vi-bword", rl_vi_bword }, { "vi-bword", rl_vi_bword },
{ "vi-change-case", rl_vi_change_case }, { "vi-change-case", rl_vi_change_case },
{ "vi-change-char", rl_vi_change_char }, { "vi-change-char", rl_vi_change_char },
...@@ -176,11 +184,13 @@ static FUNMAP default_funmap[] = { ...@@ -176,11 +184,13 @@ static FUNMAP default_funmap[] = {
{ "vi-yank-to", rl_vi_yank_to }, { "vi-yank-to", rl_vi_yank_to },
#endif /* VI_MODE */ #endif /* VI_MODE */
{(char *)NULL, (Function *)NULL } {(char *)NULL, (rl_command_func_t *)NULL }
}; };
int int
rl_add_funmap_entry (const char *name, Function *function) rl_add_funmap_entry (name, function)
const char *name;
rl_command_func_t *function;
{ {
if (funmap_entry + 2 >= funmap_size) if (funmap_entry + 2 >= funmap_size)
{ {
...@@ -217,36 +227,27 @@ rl_initialize_funmap () ...@@ -217,36 +227,27 @@ rl_initialize_funmap ()
/* Produce a NULL terminated array of known function names. The array /* Produce a NULL terminated array of known function names. The array
is sorted. The array itself is allocated, but not the strings inside. is sorted. The array itself is allocated, but not the strings inside.
You should free () the array when you done, but not the pointrs. */ You should free () the array when you done, but not the pointrs. */
char ** const char **
rl_funmap_names () rl_funmap_names ()
{ {
char **result; const char **result;
int result_size, result_index; int result_size, result_index;
/* Make sure that the function map has been initialized. */ /* Make sure that the function map has been initialized. */
rl_initialize_funmap (); rl_initialize_funmap ();
for (result_index = result_size = 0, result = (char **)NULL; funmap[result_index]; result_index++) for (result_index = result_size = 0, result = (const char **)NULL; funmap[result_index]; result_index++)
{ {
if (result_index + 2 > result_size) if (result_index + 2 > result_size)
{ {
result_size += 20; result_size += 20;
result = (char **)xrealloc (result, result_size * sizeof (char *)); result = (const char **)xrealloc (result, result_size * sizeof (char *));
} }
result[result_index] = (char*) funmap[result_index]->name; result[result_index] = funmap[result_index]->name;
result[result_index + 1] = (char *)NULL; result[result_index + 1] = (char *)NULL;
} }
qsort (result, result_index, sizeof (char *), _rl_qsort_string_compare); qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
return (result); return (result);
} }
/* Things that mean `Control'. */
const char *possible_control_prefixes[] = {
"Control-", "C-", "CTRL-", (char *)NULL
};
const char *possible_meta_prefixes[] = {
"Meta", "M-", (char *)NULL
};
This diff is collapsed.
This diff is collapsed.
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
The Library is free software; you can redistribute it and/or modify The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
The Library is distributed in the hope that it will be useful, but The Library is distributed in the hope that it will be useful, but
...@@ -17,27 +17,24 @@ ...@@ -17,27 +17,24 @@
The GNU General Public License is often shipped with GNU software, and The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation, have a copy of the license, write to the Free Software Foundation,
675 Mass Ave, Cambridge, MA 02139, USA. */ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_HISTLIB_H_) #if !defined (_HISTLIB_H_)
#define _HISTLIB_H_ #define _HISTLIB_H_
/* Function pointers can be declared as (Function *)foo. */ #if defined (HAVE_STRING_H)
#if !defined (_FUNCTION_DEF) # include <string.h>
# define _FUNCTION_DEF #else
typedef int Function (); # include <strings.h>
typedef void VFunction (); #endif /* !HAVE_STRING_H */
typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif /* _FUNCTION_DEF */
#if !defined (STREQ)
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0)) #define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
#define STREQN(a, b, n) (((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0)) #define STREQN(a, b, n) (((n) == 0) ? (1) \
: ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
#endif
#ifndef savestring #ifndef savestring
# ifndef strcpy
extern char *strcpy ();
# endif
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x)) #define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#endif #endif
...@@ -79,4 +76,7 @@ extern char *strchr (); ...@@ -79,4 +76,7 @@ extern char *strchr ();
#define HISTORY_APPEND 0 #define HISTORY_APPEND 0
#define HISTORY_OVERWRITE 1 #define HISTORY_OVERWRITE 1
/* Some variable definitions shared across history source files. */
extern int history_offset;
#endif /* !_HISTLIB_H_ */ #endif /* !_HISTLIB_H_ */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
The Library is free software; you can redistribute it and/or modify The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
The Library is distributed in the hope that it will be useful, but The Library is distributed in the hope that it will be useful, but
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation, have a copy of the license, write to the Free Software Foundation,
675 Mass Ave, Cambridge, MA 02139, USA. */ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* The goal is to make the implementation transparent, so that you /* The goal is to make the implementation transparent, so that you
don't have to know what data types are used, just what functions don't have to know what data types are used, just what functions
...@@ -44,16 +44,10 @@ ...@@ -44,16 +44,10 @@
# include <unistd.h> # include <unistd.h>
#endif #endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "history.h" #include "history.h"
#include "histlib.h" #include "histlib.h"
extern char *xmalloc (), *xrealloc (); #include "xmalloc.h"
/* The number of slots to increase the_history by. */ /* The number of slots to increase the_history by. */
#define DEFAULT_HISTORY_GROW_SIZE 50 #define DEFAULT_HISTORY_GROW_SIZE 50
...@@ -71,9 +65,13 @@ static HIST_ENTRY **the_history = (HIST_ENTRY **)NULL; ...@@ -71,9 +65,13 @@ static HIST_ENTRY **the_history = (HIST_ENTRY **)NULL;
history that we save. */ history that we save. */
static int history_stifled; static int history_stifled;
/* The current number of slots allocated to the input_history. */
static int history_size;
/* If HISTORY_STIFLED is non-zero, then this is the maximum number of /* If HISTORY_STIFLED is non-zero, then this is the maximum number of
entries to remember. */ entries to remember. */
int max_input_history; int history_max_entries;
int max_input_history; /* backwards compatibility */
/* The current location of the interactive history pointer. Just makes /* The current location of the interactive history pointer. Just makes
life easier for outside callers. */ life easier for outside callers. */
...@@ -82,9 +80,6 @@ int history_offset; ...@@ -82,9 +80,6 @@ int history_offset;
/* The number of strings currently stored in the history list. */ /* The number of strings currently stored in the history list. */
int history_length; int history_length;
/* The current number of slots allocated to the input_history. */
static int history_size;
/* The logical `base' of the history array. It defaults to 1. */ /* The logical `base' of the history array. It defaults to 1. */
int history_base = 1; int history_base = 1;
...@@ -134,9 +129,7 @@ history_total_bytes () ...@@ -134,9 +129,7 @@ history_total_bytes ()
{ {
register int i, result; register int i, result;
result = 0; for (i = result = 0; the_history && the_history[i]; i++)
for (i = 0; the_history && the_history[i]; i++)
result += strlen (the_history[i]->line); result += strlen (the_history[i]->line);
return (result); return (result);
...@@ -217,16 +210,16 @@ history_get (offset) ...@@ -217,16 +210,16 @@ history_get (offset)
is set to NULL. */ is set to NULL. */
void void
add_history (string) add_history (string)
char *string; const char *string;
{ {
HIST_ENTRY *temp; HIST_ENTRY *temp;
if (history_stifled && (history_length == max_input_history)) if (history_stifled && (history_length == history_max_entries))
{ {
register int i; register int i;
/* If the history is stifled, and history_length is zero, /* If the history is stifled, and history_length is zero,
and it equals max_input_history, we don't save items. */ and it equals history_max_entries, we don't save items. */
if (history_length == 0) if (history_length == 0)
return; return;
...@@ -277,15 +270,15 @@ add_history (string) ...@@ -277,15 +270,15 @@ add_history (string)
HIST_ENTRY * HIST_ENTRY *
replace_history_entry (which, line, data) replace_history_entry (which, line, data)
int which; int which;
char *line; const char *line;
histdata_t data; histdata_t data;
{ {
HIST_ENTRY *temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY)); HIST_ENTRY *temp, *old_value;
HIST_ENTRY *old_value;
if (which >= history_length) if (which >= history_length)
return ((HIST_ENTRY *)NULL); return ((HIST_ENTRY *)NULL);
temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
old_value = the_history[which]; old_value = the_history[which];
temp->line = savestring (line); temp->line = savestring (line);
...@@ -303,12 +296,12 @@ remove_history (which) ...@@ -303,12 +296,12 @@ remove_history (which)
int which; int which;
{ {
HIST_ENTRY *return_value; HIST_ENTRY *return_value;
register int i;
if (which >= history_length || !history_length) if (which >= history_length || !history_length)
return_value = (HIST_ENTRY *)NULL; return_value = (HIST_ENTRY *)NULL;
else else
{ {
register int i;
return_value = the_history[which]; return_value = the_history[which];
for (i = which; i < history_length; i++) for (i = which; i < history_length; i++)
...@@ -325,13 +318,13 @@ void ...@@ -325,13 +318,13 @@ void
stifle_history (max) stifle_history (max)
int max; int max;
{ {
register int i, j;
if (max < 0) if (max < 0)
max = 0; max = 0;
if (history_length > max) if (history_length > max)
{ {
register int i, j;
/* This loses because we cannot free the data. */ /* This loses because we cannot free the data. */
for (i = 0, j = history_length - max; i < j; i++) for (i = 0, j = history_length - max; i < j; i++)
{ {
...@@ -347,22 +340,22 @@ stifle_history (max) ...@@ -347,22 +340,22 @@ stifle_history (max)
} }
history_stifled = 1; history_stifled = 1;
max_input_history = max; max_input_history = history_max_entries = max;
} }
/* Stop stifling the history. This returns the previous amount the /* Stop stifling the history. This returns the previous maximum
history was stifled by. The value is positive if the history was number of history entries. The value is positive if the history
stifled, negative if it wasn't. */ was stifled, negative if it wasn't. */
int int
unstifle_history () unstifle_history ()
{ {
if (history_stifled) if (history_stifled)
{ {
history_stifled = 0; history_stifled = 0;
return (-max_input_history); return (history_max_entries);
} }
else
return (max_input_history); return (-history_max_entries);
} }
int int
......
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
The Library is free software; you can redistribute it and/or modify The Library is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option) the Free Software Foundation; either version 2, or (at your option)
any later version. any later version.
The Library is distributed in the hope that it will be useful, but The Library is distributed in the hope that it will be useful, but
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
The GNU General Public License is often shipped with GNU software, and The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation, have a copy of the license, write to the Free Software Foundation,
675 Mass Ave, Cambridge, MA 02139, USA. */ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY #define READLINE_LIBRARY
...@@ -32,27 +32,22 @@ ...@@ -32,27 +32,22 @@
#else #else
# include "ansi_stdlib.h" # include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */ #endif /* HAVE_STDLIB_H */
#if defined (HAVE_UNISTD_H) #if defined (HAVE_UNISTD_H)
# ifdef _MINIX # ifdef _MINIX
# include <sys/types.h> # include <sys/types.h>
# endif # endif
# include <unistd.h> # include <unistd.h>
#endif #endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "history.h" #include "history.h"
#include "histlib.h" #include "histlib.h"
/* Variables imported from other history library files. */
extern int history_offset;
/* The list of alternate characters that can delimit a history search /* The list of alternate characters that can delimit a history search
string. */ string. */
const char *history_search_delimiter_chars = (char *)NULL; char *history_search_delimiter_chars = (char *)NULL;
static int history_search_internal PARAMS((const char *, int, int));
/* Search the history for STRING, starting at history_offset. /* Search the history for STRING, starting at history_offset.
If DIRECTION < 0, then the search is through previous entries, else If DIRECTION < 0, then the search is through previous entries, else
...@@ -66,7 +61,7 @@ const char *history_search_delimiter_chars = (char *)NULL; ...@@ -66,7 +61,7 @@ const char *history_search_delimiter_chars = (char *)NULL;
static int static int
history_search_internal (string, direction, anchored) history_search_internal (string, direction, anchored)
char *string; const char *string;
int direction, anchored; int direction, anchored;
{ {
register int i, reverse; register int i, reverse;
...@@ -162,7 +157,7 @@ history_search_internal (string, direction, anchored) ...@@ -162,7 +157,7 @@ history_search_internal (string, direction, anchored)
/* Do a non-anchored search for STRING through the history in DIRECTION. */ /* Do a non-anchored search for STRING through the history in DIRECTION. */
int int
history_search (string, direction) history_search (string, direction)
char *string; const char *string;
int direction; int direction;
{ {
return (history_search_internal (string, direction, NON_ANCHORED_SEARCH)); return (history_search_internal (string, direction, NON_ANCHORED_SEARCH));
...@@ -171,7 +166,7 @@ history_search (string, direction) ...@@ -171,7 +166,7 @@ history_search (string, direction)
/* Do an anchored search for string through the history in DIRECTION. */ /* Do an anchored search for string through the history in DIRECTION. */
int int
history_search_prefix (string, direction) history_search_prefix (string, direction)
char *string; const char *string;
int direction; int direction;
{ {
return (history_search_internal (string, direction, ANCHORED_SEARCH)); return (history_search_internal (string, direction, ANCHORED_SEARCH));
...@@ -182,7 +177,7 @@ history_search_prefix (string, direction) ...@@ -182,7 +177,7 @@ history_search_prefix (string, direction)
which point to begin searching. */ which point to begin searching. */
int int
history_search_pos (string, dir, pos) history_search_pos (string, dir, pos)
char *string; const char *string;
int dir, pos; int dir, pos;
{ {
int ret, old; int ret, old;
......
This diff is collapsed.
This diff is collapsed.
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
Readline is free software; you can redistribute it and/or modify it 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 under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 1, or (at your option) any Free Software Foundation; either version 2, or (at your option) any
later version. later version.
Readline is distributed in the hope that it will be useful, but Readline is distributed in the hope that it will be useful, but
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with Readline; see the file COPYING. If not, write to the Free along with Readline; see the file COPYING. If not, write to the Free
Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY #define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H) #if defined (HAVE_CONFIG_H)
...@@ -30,18 +30,18 @@ ...@@ -30,18 +30,18 @@
# include "ansi_stdlib.h" # include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */ #endif /* HAVE_STDLIB_H */
#include <stdio.h> /* for FILE * definition for readline.h */
#include "readline.h"
#include "rlconf.h" #include "rlconf.h"
#include "keymaps.h"
#include "emacs_keymap.c" #include "emacs_keymap.c"
#if defined (VI_MODE) #if defined (VI_MODE)
#include "vi_keymap.c" #include "vi_keymap.c"
#endif #endif
extern int rl_do_lowercase_version (); #include "xmalloc.h"
extern int rl_rubout (), rl_insert ();
extern char *xmalloc (), *xrealloc ();
/* **************************************************************** */ /* **************************************************************** */
/* */ /* */
...@@ -61,7 +61,7 @@ rl_make_bare_keymap () ...@@ -61,7 +61,7 @@ rl_make_bare_keymap ()
for (i = 0; i < KEYMAP_SIZE; i++) for (i = 0; i < KEYMAP_SIZE; i++)
{ {
keymap[i].type = ISFUNC; keymap[i].type = ISFUNC;
keymap[i].function = (Function *)NULL; keymap[i].function = (rl_command_func_t *)NULL;
} }
for (i = 'A'; i < ('Z' + 1); i++) for (i = 'A'; i < ('Z' + 1); i++)
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
The GNU Readline Library is free software; you can redistribute it The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 1, or as published by the Free Software Foundation; either version 2, or
(at your option) any later version. (at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be The GNU Readline Library is distributed in the hope that it will be
...@@ -18,25 +18,23 @@ ...@@ -18,25 +18,23 @@
The GNU General Public License is often shipped with GNU software, and The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation, have a copy of the license, write to the Free Software Foundation,
675 Mass Ave, Cambridge, MA 02139, USA. */ 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _KEYMAPS_H_ #ifndef _KEYMAPS_H_
#define _KEYMAPS_H_ #define _KEYMAPS_H_
#ifdef __cplusplus
extern "C" {
#endif
#if defined (READLINE_LIBRARY) #if defined (READLINE_LIBRARY)
# include "rlstdc.h" # include "rlstdc.h"
# include "chardefs.h" # include "chardefs.h"
# include "rltypedefs.h"
#else #else
# include <readline/rlstdc.h> # include <readline/rlstdc.h>
# include <readline/chardefs.h> # include <readline/chardefs.h>
#endif # include <readline/rltypedefs.h>
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif #endif
/* A keymap contains one entry for each key in the ASCII set. /* A keymap contains one entry for each key in the ASCII set.
...@@ -46,16 +44,17 @@ typedef char **CPPFunction (); ...@@ -46,16 +44,17 @@ typedef char **CPPFunction ();
TYPE says which kind of thing FUNCTION is. */ TYPE says which kind of thing FUNCTION is. */
typedef struct _keymap_entry { typedef struct _keymap_entry {
char type; char type;
Function *function; rl_command_func_t *function;
} KEYMAP_ENTRY; } KEYMAP_ENTRY;
/* This must be large enough to hold bindings for all of the characters /* This must be large enough to hold bindings for all of the characters
in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x, in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
and so on). */ and so on) plus one for subsequence matching. */
#define KEYMAP_SIZE 256 #define KEYMAP_SIZE 257
#define ANYOTHERKEY KEYMAP_SIZE-1
/* I wanted to make the above structure contain a union of: /* I wanted to make the above structure contain a union of:
union { Function *function; struct _keymap_entry *keymap; } value; union { rl_command_func_t *function; struct _keymap_entry *keymap; } value;
but this made it impossible for me to create a static array. but this made it impossible for me to create a static array.
Maybe I need C lessons. */ Maybe I need C lessons. */
...@@ -72,29 +71,33 @@ extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap; ...@@ -72,29 +71,33 @@ extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
/* Return a new, empty keymap. /* Return a new, empty keymap.
Free it with free() when you are done. */ Free it with free() when you are done. */
extern Keymap rl_make_bare_keymap __P((void)); extern Keymap rl_make_bare_keymap PARAMS((void));
/* Return a new keymap which is a copy of MAP. */ /* Return a new keymap which is a copy of MAP. */
extern Keymap rl_copy_keymap __P((Keymap)); extern Keymap rl_copy_keymap PARAMS((Keymap));
/* Return a new keymap with the printing characters bound to rl_insert, /* Return a new keymap with the printing characters bound to rl_insert,
the lowercase Meta characters bound to run their equivalents, and the lowercase Meta characters bound to run their equivalents, and
the Meta digits bound to produce numeric arguments. */ the Meta digits bound to produce numeric arguments. */
extern Keymap rl_make_keymap __P((void)); extern Keymap rl_make_keymap PARAMS((void));
/* Free the storage associated with a keymap. */ /* Free the storage associated with a keymap. */
extern void rl_discard_keymap __P((Keymap)); extern void rl_discard_keymap PARAMS((Keymap));
/* These functions actually appear in bind.c */ /* These functions actually appear in bind.c */
/* Return the keymap corresponding to a given name. Names look like /* Return the keymap corresponding to a given name. Names look like
`emacs' or `emacs-meta' or `vi-insert'. */ `emacs' or `emacs-meta' or `vi-insert'. */
extern Keymap rl_get_keymap_by_name __P((char *)); extern Keymap rl_get_keymap_by_name PARAMS((const char *));
/* Return the current keymap. */ /* Return the current keymap. */
extern Keymap rl_get_keymap __P((void)); extern Keymap rl_get_keymap PARAMS((void));
/* Set the current keymap to MAP. */ /* Set the current keymap to MAP. */
extern void rl_set_keymap __P((Keymap)); extern void rl_set_keymap PARAMS((Keymap));
#ifdef __cplusplus
}
#endif
#endif /* _KEYMAPS_H_ */ #endif /* _KEYMAPS_H_ */
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment