* 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.
This commit is contained in:
parent
a705278de7
commit
201b685783
6 changed files with 32 additions and 42 deletions
|
@ -1,3 +1,12 @@
|
|||
2014-07-14 Dmitry Antipov <dmantipov@yandex.ru>
|
||||
|
||||
* 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.
|
||||
|
||||
2014-07-13 Paul Eggert <eggert@cs.ucla.edu>
|
||||
|
||||
Improve behavior of 'bzr up; cd src; make -k'.
|
||||
|
|
14
src/fns.c
14
src/fns.c
|
@ -1151,13 +1151,7 @@ With one argument, just copy STRING (with properties, if any). */)
|
|||
Lisp_Object res;
|
||||
ptrdiff_t size, ifrom, ito;
|
||||
|
||||
if (STRINGP (string))
|
||||
size = SCHARS (string);
|
||||
else if (VECTORP (string))
|
||||
size = ASIZE (string);
|
||||
else
|
||||
wrong_type_argument (Qarrayp, string);
|
||||
|
||||
size = CHECK_VECTOR_OR_STRING (string);
|
||||
validate_subarray (string, from, to, size, &ifrom, &ito);
|
||||
|
||||
if (STRINGP (string))
|
||||
|
@ -1212,11 +1206,7 @@ substring_both (Lisp_Object string, ptrdiff_t from, ptrdiff_t from_byte,
|
|||
ptrdiff_t to, ptrdiff_t to_byte)
|
||||
{
|
||||
Lisp_Object res;
|
||||
ptrdiff_t size;
|
||||
|
||||
CHECK_VECTOR_OR_STRING (string);
|
||||
|
||||
size = STRINGP (string) ? SCHARS (string) : ASIZE (string);
|
||||
ptrdiff_t size = CHECK_VECTOR_OR_STRING (string);
|
||||
|
||||
if (!(0 <= from && from <= to && to <= size))
|
||||
args_out_of_range_3 (string, make_number (from), make_number (to));
|
||||
|
|
|
@ -1571,13 +1571,7 @@ If BITMAP already exists, the existing definition is replaced. */)
|
|||
int fill1 = 0, fill2 = 0;
|
||||
|
||||
CHECK_SYMBOL (bitmap);
|
||||
|
||||
if (STRINGP (bits))
|
||||
h = SCHARS (bits);
|
||||
else if (VECTORP (bits))
|
||||
h = ASIZE (bits);
|
||||
else
|
||||
wrong_type_argument (Qsequencep, bits);
|
||||
h = CHECK_VECTOR_OR_STRING (bits);
|
||||
|
||||
if (NILP (height))
|
||||
fb.height = h;
|
||||
|
|
|
@ -1092,9 +1092,7 @@ binding KEY to DEF is added at the front of KEYMAP. */)
|
|||
GCPRO3 (keymap, key, def);
|
||||
keymap = get_keymap (keymap, 1, 1);
|
||||
|
||||
CHECK_VECTOR_OR_STRING (key);
|
||||
|
||||
length = XFASTINT (Flength (key));
|
||||
length = CHECK_VECTOR_OR_STRING (key);
|
||||
if (length == 0)
|
||||
RETURN_UNGCPRO (Qnil);
|
||||
|
||||
|
@ -1248,9 +1246,7 @@ recognize the default bindings, just as `read-key-sequence' does. */)
|
|||
GCPRO2 (keymap, key);
|
||||
keymap = get_keymap (keymap, 1, 1);
|
||||
|
||||
CHECK_VECTOR_OR_STRING (key);
|
||||
|
||||
length = XFASTINT (Flength (key));
|
||||
length = CHECK_VECTOR_OR_STRING (key);
|
||||
if (length == 0)
|
||||
RETURN_UNGCPRO (keymap);
|
||||
|
||||
|
|
|
@ -2555,10 +2555,15 @@ CHECK_BOOL_VECTOR (Lisp_Object x)
|
|||
{
|
||||
CHECK_TYPE (BOOL_VECTOR_P (x), Qbool_vector_p, x);
|
||||
}
|
||||
INLINE void
|
||||
/* This is a bit special because we always need size afterwards. */
|
||||
INLINE ptrdiff_t
|
||||
CHECK_VECTOR_OR_STRING (Lisp_Object x)
|
||||
{
|
||||
CHECK_TYPE (VECTORP (x) || STRINGP (x), Qarrayp, x);
|
||||
if (VECTORP (x))
|
||||
return ASIZE (x);
|
||||
if (STRINGP (x))
|
||||
return SCHARS (x);
|
||||
wrong_type_argument (Qarrayp, x);
|
||||
}
|
||||
INLINE void
|
||||
CHECK_ARRAY (Lisp_Object x, Lisp_Object predicate)
|
||||
|
|
26
src/macros.c
26
src/macros.c
|
@ -80,28 +80,24 @@ macro before appending to it. */)
|
|||
}
|
||||
else
|
||||
{
|
||||
ptrdiff_t i;
|
||||
EMACS_INT len;
|
||||
const ptrdiff_t 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 = CHECK_VECTOR_OR_STRING (KVAR (current_kboard, Vlast_kbd_macro));
|
||||
|
||||
len = XINT (Flength (KVAR (current_kboard, Vlast_kbd_macro)));
|
||||
if (INT_ADD_OVERFLOW (len, incr))
|
||||
memory_full (SIZE_MAX);
|
||||
|
||||
/* 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,
|
||||
¤t_kboard->kbd_macro_bufsize,
|
||||
len + 30 - current_kboard->kbd_macro_bufsize, -1,
|
||||
sizeof *current_kboard->kbd_macro_buffer);
|
||||
}
|
||||
if (current_kboard->kbd_macro_bufsize < len + incr)
|
||||
current_kboard->kbd_macro_buffer =
|
||||
xpalloc (current_kboard->kbd_macro_buffer,
|
||||
¤t_kboard->kbd_macro_bufsize,
|
||||
len + incr - current_kboard->kbd_macro_bufsize, -1,
|
||||
sizeof *current_kboard->kbd_macro_buffer);
|
||||
|
||||
/* Must convert meta modifier when copying string to vector. */
|
||||
cvt = STRINGP (KVAR (current_kboard, Vlast_kbd_macro));
|
||||
|
|
Loading…
Add table
Reference in a new issue