]> code.delx.au - gnu-emacs/blobdiff - src/macros.c
Update copyright year to 2015
[gnu-emacs] / src / macros.c
index acba125edc57806bef7279c3e3450c391b271b35..0801f0ac288125d9be3de9c773291179e8bbfa4e 100644 (file)
@@ -1,6 +1,6 @@
 /* Keyboard macros.
 
-Copyright (C) 1985-1986, 1993, 2000-2014 Free Software Foundation, Inc.
+Copyright (C) 1985-1986, 1993, 2000-2015 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -63,6 +63,8 @@ macro before appending to it.  */)
     {
       current_kboard->kbd_macro_buffer = xmalloc (30 * word_size);
       current_kboard->kbd_macro_bufsize = 30;
+      current_kboard->kbd_macro_ptr = current_kboard->kbd_macro_buffer;
+      current_kboard->kbd_macro_end = current_kboard->kbd_macro_buffer;
     }
   update_mode_lines = 19;
   if (NILP (append))
@@ -80,28 +82,21 @@ macro before appending to it.  */)
     }
   else
     {
-      ptrdiff_t i;
-      EMACS_INT len;
+      int incr = 30;
+      ptrdiff_t i, len;
       bool cvt;
 
       /* Check the type of last-kbd-macro in case Lisp code changed it.  */
-      CHECK_VECTOR_OR_STRING (KVAR (current_kboard, Vlast_kbd_macro));
-
-      len = XINT (Flength (KVAR (current_kboard, Vlast_kbd_macro)));
+      len = CHECK_VECTOR_OR_STRING (KVAR (current_kboard, Vlast_kbd_macro));
 
       /* Copy last-kbd-macro into the buffer, in case the Lisp code
         has put another macro there.  */
-      if (current_kboard->kbd_macro_bufsize < len + 30)
-       {
-         if (PTRDIFF_MAX < MOST_POSITIVE_FIXNUM + 30
-             && PTRDIFF_MAX < len + 30)
-           memory_full (SIZE_MAX);
-         current_kboard->kbd_macro_buffer =
-           xpalloc (current_kboard->kbd_macro_buffer,
-                    &current_kboard->kbd_macro_bufsize,
-                    len + 30 - current_kboard->kbd_macro_bufsize, -1,
-                    sizeof *current_kboard->kbd_macro_buffer);
-       }
+      if (current_kboard->kbd_macro_bufsize - incr < len)
+       current_kboard->kbd_macro_buffer =
+         xpalloc (current_kboard->kbd_macro_buffer,
+                  &current_kboard->kbd_macro_bufsize,
+                  len - current_kboard->kbd_macro_bufsize + incr, -1,
+                  sizeof *current_kboard->kbd_macro_buffer);
 
       /* Must convert meta modifier when copying string to vector.  */
       cvt = STRINGP (KVAR (current_kboard, Vlast_kbd_macro));