X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/2fab8395070ff77b836cb8ca9b84c261c4387a9a..56adbe62a5c90ec0935d751fa311d41eb6d86a39:/src/macros.c diff --git a/src/macros.c b/src/macros.c index f6cd3a3cca..0b1eda0b8a 100644 --- a/src/macros.c +++ b/src/macros.c @@ -1,6 +1,6 @@ /* Keyboard macros. -Copyright (C) 1985-1986, 1993, 2000-2011 Free Software Foundation, Inc. +Copyright (C) 1985-1986, 1993, 2000-2012 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -23,6 +23,7 @@ along with GNU Emacs. If not, see . */ #include "lisp.h" #include "macros.h" #include "commands.h" +#include "character.h" #include "buffer.h" #include "window.h" #include "keyboard.h" @@ -35,7 +36,7 @@ static Lisp_Object Qkbd_macro_termination_hook; This is not bound at each level, so after an error, it describes the innermost interrupted macro. */ -int executing_kbd_macro_iterations; +EMACS_INT executing_kbd_macro_iterations; /* This is the macro that was executing. This is not bound at each level, @@ -62,8 +63,7 @@ macro before appending to it. */) if (!current_kboard->kbd_macro_buffer) { - current_kboard->kbd_macro_buffer - = (Lisp_Object *)xmalloc (30 * sizeof (Lisp_Object)); + current_kboard->kbd_macro_buffer = xmalloc (30 * sizeof (Lisp_Object)); current_kboard->kbd_macro_bufsize = 30; } update_mode_lines++; @@ -95,13 +95,14 @@ macro before appending to it. */) has put another macro there. */ if (current_kboard->kbd_macro_bufsize < len + 30) { - if (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (Lisp_Object) - 30 - < current_kboard->kbd_macro_bufsize) + if (PTRDIFF_MAX < MOST_POSITIVE_FIXNUM + 30 + && PTRDIFF_MAX < len + 30) memory_full (SIZE_MAX); - current_kboard->kbd_macro_buffer - = (Lisp_Object *)xrealloc (current_kboard->kbd_macro_buffer, - (len + 30) * sizeof (Lisp_Object)); - current_kboard->kbd_macro_bufsize = len + 30; + current_kboard->kbd_macro_buffer = + xpalloc (current_kboard->kbd_macro_buffer, + ¤t_kboard->kbd_macro_bufsize, + len + 30 - current_kboard->kbd_macro_bufsize, -1, + sizeof *current_kboard->kbd_macro_buffer); } /* Must convert meta modifier when copying string to vector. */ @@ -175,11 +176,11 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) if (XFASTINT (repeat) == 0) Fexecute_kbd_macro (KVAR (current_kboard, Vlast_kbd_macro), repeat, loopfunc); - else + else if (XINT (repeat) > 1) { XSETINT (repeat, XINT (repeat)-1); - if (XINT (repeat) > 0) - Fexecute_kbd_macro (KVAR (current_kboard, Vlast_kbd_macro), repeat, loopfunc); + Fexecute_kbd_macro (KVAR (current_kboard, Vlast_kbd_macro), + repeat, loopfunc); } return Qnil; } @@ -203,8 +204,7 @@ store_kbd_macro_char (Lisp_Object c) < kb->kbd_macro_bufsize) memory_full (SIZE_MAX); nbytes = kb->kbd_macro_bufsize * (2 * sizeof *kb->kbd_macro_buffer); - kb->kbd_macro_buffer - = (Lisp_Object *) xrealloc (kb->kbd_macro_buffer, nbytes); + kb->kbd_macro_buffer = xrealloc (kb->kbd_macro_buffer, nbytes); kb->kbd_macro_bufsize *= 2; kb->kbd_macro_ptr = kb->kbd_macro_buffer + ptr_offset; kb->kbd_macro_end = kb->kbd_macro_buffer + end_offset; @@ -258,7 +258,7 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) from before this macro started. */ Vthis_command = KVAR (current_kboard, Vlast_command); /* C-x z after the macro should repeat the macro. */ - real_this_command = KVAR (current_kboard, Vlast_kbd_macro); + Vreal_this_command = KVAR (current_kboard, Vlast_kbd_macro); if (! NILP (KVAR (current_kboard, defining_kbd_macro))) error ("Can't execute anonymous macro while defining one"); @@ -285,7 +285,7 @@ pop_kbd_macro (Lisp_Object info) Vexecuting_kbd_macro = XCAR (info); tem = XCDR (info); executing_kbd_macro_index = XINT (XCAR (tem)); - real_this_command = XCDR (tem); + Vreal_this_command = XCDR (tem); Frun_hooks (1, &Qkbd_macro_termination_hook); return Qnil; } @@ -301,10 +301,10 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) { Lisp_Object final; Lisp_Object tem; - int pdlcount = SPECPDL_INDEX (); - int repeat = 1; + ptrdiff_t pdlcount = SPECPDL_INDEX (); + EMACS_INT repeat = 1; struct gcpro gcpro1, gcpro2; - int success_count = 0; + EMACS_INT success_count = 0; executing_kbd_macro_iterations = 0; @@ -320,7 +320,7 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) tem = Fcons (Vexecuting_kbd_macro, Fcons (make_number (executing_kbd_macro_index), - real_this_command)); + Vreal_this_command)); record_unwind_protect (pop_kbd_macro, tem); GCPRO2 (final, loopfunc); @@ -351,7 +351,7 @@ each iteration of the macro. Iteration stops if LOOPFUNC returns nil. */) executing_kbd_macro = Qnil; - real_this_command = Vexecuting_kbd_macro; + Vreal_this_command = Vexecuting_kbd_macro; UNGCPRO; return unbind_to (pdlcount, Qnil);