changeset 1261:60b30565326c

* keyboard.c (recent_keys): Turn this from an array, which is a pain in the neck to staticpro, into a vector, which is easier. (read_char, Frecent_keys): Access recent_keys as a lisp vector, not a C array. (init_keyboard): Set recent_keys to be a vector, and staticpro it.
author Jim Blandy <jimb@redhat.com>
date Tue, 29 Sep 1992 13:44:55 +0000
parents a2d017a57391
children c9fc221502e4
files src/keyboard.c
diffstat 1 files changed, 12 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/keyboard.c	Tue Sep 29 13:25:14 1992 +0000
+++ b/src/keyboard.c	Tue Sep 29 13:44:55 1992 +0000
@@ -76,7 +76,7 @@
 #define NUM_RECENT_KEYS (100)
 int recent_keys_index;	/* Index for storing next element into recent_keys */
 int total_keys;		/* Total number of elements stored into recent_keys */
-Lisp_Object recent_keys[NUM_RECENT_KEYS]; /* Holds last 100 keystrokes */
+Lisp_Object recent_keys; /* A vector, holding the last 100 keystrokes */
 
 /* Buffer holding the key that invoked the current command.  */
 Lisp_Object *this_command_keys;
@@ -1267,8 +1267,8 @@
     }
 
   total_keys++;
-  recent_keys[recent_keys_index] = c;
-  if (++recent_keys_index >= (sizeof (recent_keys)/sizeof(recent_keys[0])))
+  XVECTOR (recent_keys)->contents[recent_keys_index] = c;
+  if (++recent_keys_index >= NUM_RECENT_KEYS)
     recent_keys_index = 0;
 
   /* Write c to the dribble file.  If c is a lispy event, write
@@ -3113,17 +3113,18 @@
   "Return vector of last 100 chars read from terminal.")
   ()
 {
+  Lisp_Object *keys = XVECTOR (recent_keys)->contents;
   Lisp_Object val;
 
   if (total_keys < NUM_RECENT_KEYS)
-    return Fvector (total_keys, recent_keys);
+    return Fvector (total_keys, keys);
   else
     {
-      val = Fvector (NUM_RECENT_KEYS, recent_keys);
-      bcopy (recent_keys + recent_keys_index,
+      val = Fvector (NUM_RECENT_KEYS, keys);
+      bcopy (keys + recent_keys_index,
 	     XVECTOR (val)->contents,
 	     (NUM_RECENT_KEYS - recent_keys_index) * sizeof (Lisp_Object));
-      bcopy (recent_keys,
+      bcopy (keys,
 	     XVECTOR (val)->contents + NUM_RECENT_KEYS - recent_keys_index,
 	     recent_keys_index * sizeof (Lisp_Object));
       return val;
@@ -3472,13 +3473,16 @@
   immediate_quit = 0;
   quit_char = Ctl ('g');
   unread_command_char = Qnil;
-  recent_keys_index = 0;
   total_keys = 0;
   kbd_fetch_ptr = kbd_buffer;
   kbd_store_ptr = kbd_buffer;
   do_mouse_tracking = 0;
   input_pending = 0;
 
+  recent_keys = Fmake_vector (make_number (NUM_RECENT_KEYS), Qnil);
+  staticpro (&recent_keys);
+  recent_keys_index = 0;
+
   if (!noninteractive)
     {
       signal (SIGINT, interrupt_signal);