summaryrefslogtreecommitdiff
path: root/readline/macro.c
diff options
context:
space:
mode:
authorunknown <vva@genie.(none)>2002-11-19 18:26:53 +0400
committerunknown <vva@genie.(none)>2002-11-19 18:26:53 +0400
commit953f6c51fed3478cc3905d2ce15728e5c3e7f00c (patch)
tree6f25883717e7c6cfc40b292a86148e469567534c /readline/macro.c
parent0fb3b8d9abc3eb2e3072c2f8681099e7db0a256e (diff)
downloadmariadb-git-953f6c51fed3478cc3905d2ce15728e5c3e7f00c.tar.gz
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
Diffstat (limited to 'readline/macro.c')
-rw-r--r--readline/macro.c86
1 files changed, 37 insertions, 49 deletions
diff --git a/readline/macro.c b/readline/macro.c
index b4d7835c631..7ab4b6ca657 100644
--- a/readline/macro.c
+++ b/readline/macro.c
@@ -7,7 +7,7 @@
The GNU Readline Library 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 1, or
+ as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
@@ -18,7 +18,7 @@
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
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
#if defined (HAVE_CONFIG_H)
@@ -46,19 +46,8 @@
#include "readline.h"
#include "history.h"
-#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
-
-/* Forward definitions. */
-void _rl_push_executing_macro (), _rl_pop_executing_macro ();
-void _rl_add_macro_char ();
-
-/* Extern declarations. */
-extern int rl_explicit_arg;
-extern int rl_key_sequence_length;
-
-extern void _rl_abort_internal ();
-
-extern char *xmalloc (), *xrealloc ();
+#include "rlprivate.h"
+#include "xmalloc.h"
/* **************************************************************** */
/* */
@@ -66,12 +55,9 @@ extern char *xmalloc (), *xrealloc ();
/* */
/* **************************************************************** */
-/* Non-zero means to save keys that we dispatch on in a kbd macro. */
-int _rl_defining_kbd_macro = 0;
-
/* The currently executing macro string. If this is non-zero,
then it is a malloc ()'ed string where input is coming from. */
-char *_rl_executing_macro = (char *)NULL;
+char *rl_executing_macro = (char *)NULL;
/* The offset in the above string to the next character to be read. */
static int executing_macro_index;
@@ -90,7 +76,7 @@ static int current_macro_index;
It is a linked list of string/index for each saved macro. */
struct saved_macro {
struct saved_macro *next;
- const char *string;
+ char *string;
int sindex;
};
@@ -100,11 +86,13 @@ static struct saved_macro *macro_list = (struct saved_macro *)NULL;
/* Set up to read subsequent input from STRING.
STRING is free ()'ed when we are done with it. */
void
-_rl_with_macro_input (const char *string)
+_rl_with_macro_input (string)
+ char *string;
{
_rl_push_executing_macro ();
- _rl_executing_macro = (char*) string;
+ rl_executing_macro = string;
executing_macro_index = 0;
+ RL_SETSTATE(RL_STATE_MACROINPUT);
}
/* Return the next character available from a macro, or 0 if
@@ -112,16 +100,16 @@ _rl_with_macro_input (const char *string)
int
_rl_next_macro_key ()
{
- if (_rl_executing_macro == 0)
+ if (rl_executing_macro == 0)
return (0);
- if (_rl_executing_macro[executing_macro_index] == 0)
+ if (rl_executing_macro[executing_macro_index] == 0)
{
_rl_pop_executing_macro ();
return (_rl_next_macro_key ());
}
- return (_rl_executing_macro[executing_macro_index++]);
+ return (rl_executing_macro[executing_macro_index++]);
}
/* Save the currently executing macro on a stack of saved macros. */
@@ -133,7 +121,7 @@ _rl_push_executing_macro ()
saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro));
saver->next = macro_list;
saver->sindex = executing_macro_index;
- saver->string = _rl_executing_macro;
+ saver->string = rl_executing_macro;
macro_list = saver;
}
@@ -145,20 +133,21 @@ _rl_pop_executing_macro ()
{
struct saved_macro *macro;
- if (_rl_executing_macro)
- free (_rl_executing_macro);
-
- _rl_executing_macro = (char *)NULL;
+ FREE (rl_executing_macro);
+ rl_executing_macro = (char *)NULL;
executing_macro_index = 0;
if (macro_list)
{
macro = macro_list;
- _rl_executing_macro = (char*) macro_list->string;
+ rl_executing_macro = macro_list->string;
executing_macro_index = macro_list->sindex;
macro_list = macro_list->next;
free (macro);
}
+
+ if (rl_executing_macro == 0)
+ RL_UNSETSTATE(RL_STATE_MACROINPUT);
}
/* Add a character to the macro being built. */
@@ -169,9 +158,9 @@ _rl_add_macro_char (c)
if (current_macro_index + 1 >= current_macro_size)
{
if (current_macro == 0)
- current_macro = xmalloc (current_macro_size = 25);
+ current_macro = (char *)xmalloc (current_macro_size = 25);
else
- current_macro = xrealloc (current_macro, current_macro_size += 25);
+ current_macro = (char *)xrealloc (current_macro, current_macro_size += 25);
}
current_macro[current_macro_index++] = c;
@@ -188,14 +177,11 @@ _rl_kill_kbd_macro ()
}
current_macro_size = current_macro_index = 0;
- if (_rl_executing_macro)
- {
- free (_rl_executing_macro);
- _rl_executing_macro = (char *) NULL;
- }
+ FREE (rl_executing_macro);
+ rl_executing_macro = (char *) NULL;
executing_macro_index = 0;
- _rl_defining_kbd_macro = 0;
+ RL_UNSETSTATE(RL_STATE_MACRODEF);
}
/* Begin defining a keyboard macro.
@@ -205,10 +191,10 @@ _rl_kill_kbd_macro ()
definition to the end of the existing macro, and start by
re-executing the existing macro. */
int
-rl_start_kbd_macro (int count __attribute__((unused)),
- int key __attribute__((unused)))
+rl_start_kbd_macro (ignore1, ignore2)
+ int ignore1 __attribute__((unused)), ignore2 __attribute__((unused));
{
- if (_rl_defining_kbd_macro)
+ if (RL_ISSTATE (RL_STATE_MACRODEF))
{
_rl_abort_internal ();
return -1;
@@ -222,7 +208,7 @@ rl_start_kbd_macro (int count __attribute__((unused)),
else
current_macro_index = 0;
- _rl_defining_kbd_macro = 1;
+ RL_SETSTATE(RL_STATE_MACRODEF);
return 0;
}
@@ -230,9 +216,10 @@ rl_start_kbd_macro (int count __attribute__((unused)),
A numeric argument says to execute the macro right now,
that many times, counting the definition as the first time. */
int
-rl_end_kbd_macro (int count, int ignore __attribute__((unused)))
+rl_end_kbd_macro (count, ignore)
+ int count, ignore __attribute__((unused));
{
- if (_rl_defining_kbd_macro == 0)
+ if (RL_ISSTATE (RL_STATE_MACRODEF) == 0)
{
_rl_abort_internal ();
return -1;
@@ -241,7 +228,7 @@ rl_end_kbd_macro (int count, int ignore __attribute__((unused)))
current_macro_index -= rl_key_sequence_length - 1;
current_macro[current_macro_index] = '\0';
- _rl_defining_kbd_macro = 0;
+ RL_UNSETSTATE(RL_STATE_MACRODEF);
return (rl_call_last_kbd_macro (--count, 0));
}
@@ -249,14 +236,15 @@ rl_end_kbd_macro (int count, int ignore __attribute__((unused)))
/* Execute the most recently defined keyboard macro.
COUNT says how many times to execute it. */
int
-rl_call_last_kbd_macro (int count, int key __attribute__((unused)))
+rl_call_last_kbd_macro (count, ignore)
+ int count, ignore __attribute__((unused));
{
if (current_macro == 0)
_rl_abort_internal ();
- if (_rl_defining_kbd_macro)
+ if (RL_ISSTATE (RL_STATE_MACRODEF))
{
- ding (); /* no recursive macros */
+ rl_ding (); /* no recursive macros */
current_macro[--current_macro_index] = '\0'; /* erase this char */
return 0;
}