diff options
| author | Dmitry Antipov | 2014-07-14 08:44:01 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-07-14 08:44:01 +0400 |
| commit | 201b685783301c9acfda413d1860763f0e941601 (patch) | |
| tree | c16759bbe8c1e4a6ddea7f783e55c0710f00f0a5 /src/macros.c | |
| parent | a705278de7c661af9b78d956af25e13055cba864 (diff) | |
| download | emacs-201b685783301c9acfda413d1860763f0e941601.tar.gz emacs-201b685783301c9acfda413d1860763f0e941601.zip | |
* lisp.h (CHECK_VECTOR_OR_STRING): Return number of elements
or characters in string, respectively. Add comment.
* fringe.c (Fdefine_fringe_bitmap):
* fns.c (Fsubstring, substring_both): Use it.
* keymap.c (Fdefine_key, Flookup_key):
* macros.c (Fstart_kbd_macro): Likewise. Avoid call to Flength.
Diffstat (limited to 'src/macros.c')
| -rw-r--r-- | src/macros.c | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/macros.c b/src/macros.c index acba125edc5..c73986abd34 100644 --- a/src/macros.c +++ b/src/macros.c | |||
| @@ -80,28 +80,24 @@ macro before appending to it. */) | |||
| 80 | } | 80 | } |
| 81 | else | 81 | else |
| 82 | { | 82 | { |
| 83 | ptrdiff_t i; | 83 | const ptrdiff_t incr = 30; |
| 84 | EMACS_INT len; | 84 | ptrdiff_t i, len; |
| 85 | bool cvt; | 85 | bool cvt; |
| 86 | 86 | ||
| 87 | /* Check the type of last-kbd-macro in case Lisp code changed it. */ | 87 | /* Check the type of last-kbd-macro in case Lisp code changed it. */ |
| 88 | CHECK_VECTOR_OR_STRING (KVAR (current_kboard, Vlast_kbd_macro)); | 88 | len = CHECK_VECTOR_OR_STRING (KVAR (current_kboard, Vlast_kbd_macro)); |
| 89 | 89 | ||
| 90 | len = XINT (Flength (KVAR (current_kboard, Vlast_kbd_macro))); | 90 | if (INT_ADD_OVERFLOW (len, incr)) |
| 91 | memory_full (SIZE_MAX); | ||
| 91 | 92 | ||
| 92 | /* Copy last-kbd-macro into the buffer, in case the Lisp code | 93 | /* Copy last-kbd-macro into the buffer, in case the Lisp code |
| 93 | has put another macro there. */ | 94 | has put another macro there. */ |
| 94 | if (current_kboard->kbd_macro_bufsize < len + 30) | 95 | if (current_kboard->kbd_macro_bufsize < len + incr) |
| 95 | { | 96 | current_kboard->kbd_macro_buffer = |
| 96 | if (PTRDIFF_MAX < MOST_POSITIVE_FIXNUM + 30 | 97 | xpalloc (current_kboard->kbd_macro_buffer, |
| 97 | && PTRDIFF_MAX < len + 30) | 98 | ¤t_kboard->kbd_macro_bufsize, |
| 98 | memory_full (SIZE_MAX); | 99 | len + incr - current_kboard->kbd_macro_bufsize, -1, |
| 99 | current_kboard->kbd_macro_buffer = | 100 | sizeof *current_kboard->kbd_macro_buffer); |
| 100 | xpalloc (current_kboard->kbd_macro_buffer, | ||
| 101 | ¤t_kboard->kbd_macro_bufsize, | ||
| 102 | len + 30 - current_kboard->kbd_macro_bufsize, -1, | ||
| 103 | sizeof *current_kboard->kbd_macro_buffer); | ||
| 104 | } | ||
| 105 | 101 | ||
| 106 | /* Must convert meta modifier when copying string to vector. */ | 102 | /* Must convert meta modifier when copying string to vector. */ |
| 107 | cvt = STRINGP (KVAR (current_kboard, Vlast_kbd_macro)); | 103 | cvt = STRINGP (KVAR (current_kboard, Vlast_kbd_macro)); |