Commit 4939150c authored by Paul Eggert's avatar Paul Eggert

Use "ASET (a, i, v)" rather than "AREF (a, i) = v".

This how ASET and AREF are supposed to work, and makes
it easier to think about future improvements.  See
<http://lists.gnu.org/archive/html/emacs-devel/2012-08/msg00026.html>.
* charset.h (set_charset_attr): New function.
All lvalue-style uses of CHARSET_DECODER etc. changed to use it.
* lisp.h (ASET): Rewrite so as not to use AREF in an lvalue style.
(aref_addr): New function.  All uses of &AREF(...) changed.
(set_hash_key, set_hash_value, set_hash_next, set_hash_hash)
(set_hash_index): New functions.  All lvalue-style uses of
HASH_KEY etc. changed.
* keyboard.c (set_prop): New function.  All lvalue-style uses
of PROP changed.
parent 947b2afd
2012-08-01 Paul Eggert <eggert@cs.ucla.edu>
Use "ASET (a, i, v)" rather than "AREF (a, i) = v".
This how ASET and AREF are supposed to work, and makes
it easier to think about future improvements. See
<http://lists.gnu.org/archive/html/emacs-devel/2012-08/msg00026.html>.
* charset.h (set_charset_attr): New function.
All lvalue-style uses of CHARSET_DECODER etc. changed to use it.
* lisp.h (ASET): Rewrite so as not to use AREF in an lvalue style.
(aref_addr): New function. All uses of &AREF(...) changed.
(set_hash_key, set_hash_value, set_hash_next, set_hash_hash)
(set_hash_index): New functions. All lvalue-style uses of
HASH_KEY etc. changed.
* keyboard.c (set_prop): New function. All lvalue-style uses
of PROP changed.
2012-08-01 Alp Aker <alp.tekin.aker@gmail.com>
* nsterm.m (ns_set_vertical_scroll_bar, ns_redeem_scroll_bar)
......
......@@ -272,8 +272,8 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries,
{
int n = CODE_POINT_TO_INDEX (charset, max_code) + 1;
vec = CHARSET_DECODER (charset)
= Fmake_vector (make_number (n), make_number (-1));
vec = Fmake_vector (make_number (n), make_number (-1));
set_charset_attr (charset, charset_decoder, vec);
}
else
{
......@@ -285,10 +285,10 @@ load_charset_map (struct charset *charset, struct charset_map_entries *entries,
else
{
table = Fmake_char_table (Qnil, Qnil);
if (charset->method == CHARSET_METHOD_MAP)
CHARSET_ENCODER (charset) = table;
else
CHARSET_DEUNIFIER (charset) = table;
set_charset_attr (charset,
(charset->method == CHARSET_METHOD_MAP
? charset_encoder : charset_deunifier),
table);
}
}
else
......@@ -1133,7 +1133,7 @@ usage: (define-charset-internal ...) */)
{
new_definition_p = 0;
id = XFASTINT (CHARSET_SYMBOL_ID (args[charset_arg_name]));
HASH_VALUE (hash_table, charset.hash_index) = attrs;
set_hash_value (hash_table, charset.hash_index, attrs);
}
else
{
......@@ -1336,7 +1336,7 @@ DEFUN ("set-charset-plist", Fset_charset_plist, Sset_charset_plist, 2, 2, 0,
Lisp_Object attrs;
CHECK_CHARSET_GET_ATTR (charset, attrs);
CHARSET_ATTR_PLIST (attrs) = plist;
ASET (attrs, charset_plist, plist);
return plist;
}
......@@ -1375,7 +1375,7 @@ Optional third argument DEUNIFY, if non-nil, means to de-unify CHARSET. */)
{
if (! STRINGP (unify_map) && ! VECTORP (unify_map))
signal_error ("Bad unify-map", unify_map);
CHARSET_UNIFY_MAP (cs) = unify_map;
set_charset_attr (cs, charset_unify_map, unify_map);
}
if (NILP (Vchar_unify_table))
Vchar_unify_table = Fmake_char_table (Qnil, Qnil);
......
......@@ -325,6 +325,13 @@ extern int emacs_mule_charset[256];
#define CHARSET_DEUNIFIER(charset) \
(CHARSET_ATTR_DEUNIFIER (CHARSET_ATTRIBUTES (charset)))
static inline void
set_charset_attr (struct charset *charset, enum charset_attr_index idx,
Lisp_Object val)
{
ASET (CHARSET_ATTRIBUTES (charset), idx, val);
}
/* Nonzero if OBJ is a valid charset symbol. */
#define CHARSETP(obj) (CHARSET_SYMBOL_HASH_INDEX (obj) >= 0)
......
......@@ -2674,8 +2674,8 @@ encode_coding_emacs_mule (struct coding_system *coding)
CODING_GET_INFO (coding, attrs, charset_list);
if (! EQ (charset_list, Vemacs_mule_charset_list))
{
CODING_ATTR_CHARSET_LIST (attrs)
= charset_list = Vemacs_mule_charset_list;
charset_list = Vemacs_mule_charset_list;
ASET (attrs, coding_attr_charset_list, charset_list);
}
while (charbuf < charbuf_end)
......@@ -2967,8 +2967,8 @@ setup_iso_safe_charsets (Lisp_Object attrs)
if ((flags & CODING_ISO_FLAG_FULL_SUPPORT)
&& ! EQ (charset_list, Viso_2022_charset_list))
{
CODING_ATTR_CHARSET_LIST (attrs)
= charset_list = Viso_2022_charset_list;
charset_list = Viso_2022_charset_list;
ASET (attrs, coding_attr_charset_list, charset_list);
ASET (attrs, coding_attr_safe_charsets, Qnil);
}
......@@ -9603,16 +9603,16 @@ usage: (define-coding-system-internal ...) */)
name = args[coding_arg_name];
CHECK_SYMBOL (name);
CODING_ATTR_BASE_NAME (attrs) = name;
ASET (attrs, coding_attr_base_name, name);
val = args[coding_arg_mnemonic];
if (! STRINGP (val))
CHECK_CHARACTER (val);
CODING_ATTR_MNEMONIC (attrs) = val;
ASET (attrs, coding_attr_mnemonic, val);
coding_type = args[coding_arg_coding_type];
CHECK_SYMBOL (coding_type);
CODING_ATTR_TYPE (attrs) = coding_type;
ASET (attrs, coding_attr_type, coding_type);
charset_list = args[coding_arg_charset_list];
if (SYMBOLP (charset_list))
......@@ -9659,49 +9659,49 @@ usage: (define-coding-system-internal ...) */)
max_charset_id = charset->id;
}
}
CODING_ATTR_CHARSET_LIST (attrs) = charset_list;
ASET (attrs, coding_attr_charset_list, charset_list);
safe_charsets = make_uninit_string (max_charset_id + 1);
memset (SDATA (safe_charsets), 255, max_charset_id + 1);
for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
SSET (safe_charsets, XFASTINT (XCAR (tail)), 0);
CODING_ATTR_SAFE_CHARSETS (attrs) = safe_charsets;
ASET (attrs, coding_attr_safe_charsets, safe_charsets);
CODING_ATTR_ASCII_COMPAT (attrs) = args[coding_arg_ascii_compatible_p];
ASET (attrs, coding_attr_ascii_compat, args[coding_arg_ascii_compatible_p]);
val = args[coding_arg_decode_translation_table];
if (! CHAR_TABLE_P (val) && ! CONSP (val))
CHECK_SYMBOL (val);
CODING_ATTR_DECODE_TBL (attrs) = val;
ASET (attrs, coding_attr_decode_tbl, val);
val = args[coding_arg_encode_translation_table];
if (! CHAR_TABLE_P (val) && ! CONSP (val))
CHECK_SYMBOL (val);
CODING_ATTR_ENCODE_TBL (attrs) = val;
ASET (attrs, coding_attr_encode_tbl, val);
val = args[coding_arg_post_read_conversion];
CHECK_SYMBOL (val);
CODING_ATTR_POST_READ (attrs) = val;
ASET (attrs, coding_attr_post_read, val);
val = args[coding_arg_pre_write_conversion];
CHECK_SYMBOL (val);
CODING_ATTR_PRE_WRITE (attrs) = val;
ASET (attrs, coding_attr_pre_write, val);
val = args[coding_arg_default_char];
if (NILP (val))
CODING_ATTR_DEFAULT_CHAR (attrs) = make_number (' ');
ASET (attrs, coding_attr_default_char, make_number (' '));
else
{
CHECK_CHARACTER (val);
CODING_ATTR_DEFAULT_CHAR (attrs) = val;
ASET (attrs, coding_attr_default_char, val);
}
val = args[coding_arg_for_unibyte];
CODING_ATTR_FOR_UNIBYTE (attrs) = NILP (val) ? Qnil : Qt;
ASET (attrs, coding_attr_for_unibyte, NILP (val) ? Qnil : Qt);
val = args[coding_arg_plist];
CHECK_LIST (val);
CODING_ATTR_PLIST (attrs) = val;
ASET (attrs, coding_attr_plist, val);
if (EQ (coding_type, Qcharset))
{
......@@ -9726,7 +9726,7 @@ usage: (define-coding-system-internal ...) */)
int idx = (dim - 1) * 4;
if (CHARSET_ASCII_COMPATIBLE_P (charset))
CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
ASET (attrs, coding_attr_ascii_compat, Qt);
for (i = charset->code_space[idx];
i <= charset->code_space[idx + 1]; i++)
......@@ -9824,7 +9824,7 @@ usage: (define-coding-system-internal ...) */)
{
Lisp_Object bom, endian;
CODING_ATTR_ASCII_COMPAT (attrs) = Qnil;
ASET (attrs, coding_attr_ascii_compat, Qnil);
if (nargs < coding_arg_utf16_max)
goto short_args;
......@@ -9877,7 +9877,7 @@ usage: (define-coding-system-internal ...) */)
CHECK_CHARSET_GET_CHARSET (val, charset);
ASET (initial, i, make_number (CHARSET_ID (charset)));
if (i == 0 && CHARSET_ASCII_COMPATIBLE_P (charset))
CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
ASET (attrs, coding_attr_ascii_compat, Qt);
}
else
ASET (initial, i, make_number (-1));
......@@ -9938,13 +9938,13 @@ usage: (define-coding-system-internal ...) */)
}
if (category != coding_category_iso_8_1
&& category != coding_category_iso_8_2)
CODING_ATTR_ASCII_COMPAT (attrs) = Qnil;
ASET (attrs, coding_attr_ascii_compat, Qnil);
}
else if (EQ (coding_type, Qemacs_mule))
{
if (EQ (args[coding_arg_charset_list], Qemacs_mule))
ASET (attrs, coding_attr_emacs_mule_full, Qt);
CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
ASET (attrs, coding_attr_ascii_compat, Qt);
category = coding_category_emacs_mule;
}
else if (EQ (coding_type, Qshift_jis))
......@@ -9961,7 +9961,7 @@ usage: (define-coding-system-internal ...) */)
error ("Dimension of charset %s is not one",
SDATA (SYMBOL_NAME (CHARSET_NAME (charset))));
if (CHARSET_ASCII_COMPATIBLE_P (charset))
CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
ASET (attrs, coding_attr_ascii_compat, Qt);
charset_list = XCDR (charset_list);
charset = CHARSET_FROM_ID (XINT (XCAR (charset_list)));
......@@ -9999,7 +9999,7 @@ usage: (define-coding-system-internal ...) */)
error ("Dimension of charset %s is not one",
SDATA (SYMBOL_NAME (CHARSET_NAME (charset))));
if (CHARSET_ASCII_COMPATIBLE_P (charset))
CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
ASET (attrs, coding_attr_ascii_compat, Qt);
charset_list = XCDR (charset_list);
charset = CHARSET_FROM_ID (XINT (XCAR (charset_list)));
......@@ -10013,7 +10013,7 @@ usage: (define-coding-system-internal ...) */)
else if (EQ (coding_type, Qraw_text))
{
category = coding_category_raw_text;
CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
ASET (attrs, coding_attr_ascii_compat, Qt);
}
else if (EQ (coding_type, Qutf_8))
{
......@@ -10033,7 +10033,7 @@ usage: (define-coding-system-internal ...) */)
}
ASET (attrs, coding_attr_utf_bom, bom);
if (NILP (bom))
CODING_ATTR_ASCII_COMPAT (attrs) = Qt;
ASET (attrs, coding_attr_ascii_compat, Qt);
category = (CONSP (bom) ? coding_category_utf_8_auto
: NILP (bom) ? coding_category_utf_8_nosig
......@@ -10045,14 +10045,15 @@ usage: (define-coding-system-internal ...) */)
error ("Invalid coding system type: %s",
SDATA (SYMBOL_NAME (coding_type)));
CODING_ATTR_CATEGORY (attrs) = make_number (category);
CODING_ATTR_PLIST (attrs)
= Fcons (QCcategory, Fcons (AREF (Vcoding_category_table, category),
CODING_ATTR_PLIST (attrs)));
CODING_ATTR_PLIST (attrs)
= Fcons (QCascii_compatible_p,
Fcons (CODING_ATTR_ASCII_COMPAT (attrs),
CODING_ATTR_PLIST (attrs)));
ASET (attrs, coding_attr_category, make_number (category));
ASET (attrs, coding_attr_plist,
Fcons (QCcategory,
Fcons (AREF (Vcoding_category_table, category),
CODING_ATTR_PLIST (attrs))));
ASET (attrs, coding_attr_plist,
Fcons (QCascii_compatible_p,
Fcons (CODING_ATTR_ASCII_COMPAT (attrs),
CODING_ATTR_PLIST (attrs))));
eol_type = args[coding_arg_eol_type];
if (! NILP (eol_type)
......@@ -10126,7 +10127,7 @@ DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put,
{
if (! STRINGP (val))
CHECK_CHARACTER (val);
CODING_ATTR_MNEMONIC (attrs) = val;
ASET (attrs, coding_attr_mnemonic, val);
}
else if (EQ (prop, QCdefault_char))
{
......@@ -10134,37 +10135,37 @@ DEFUN ("coding-system-put", Fcoding_system_put, Scoding_system_put,
val = make_number (' ');
else
CHECK_CHARACTER (val);
CODING_ATTR_DEFAULT_CHAR (attrs) = val;
ASET (attrs, coding_attr_default_char, val);
}
else if (EQ (prop, QCdecode_translation_table))
{
if (! CHAR_TABLE_P (val) && ! CONSP (val))
CHECK_SYMBOL (val);
CODING_ATTR_DECODE_TBL (attrs) = val;
ASET (attrs, coding_attr_decode_tbl, val);
}
else if (EQ (prop, QCencode_translation_table))
{
if (! CHAR_TABLE_P (val) && ! CONSP (val))
CHECK_SYMBOL (val);
CODING_ATTR_ENCODE_TBL (attrs) = val;
ASET (attrs, coding_attr_encode_tbl, val);
}
else if (EQ (prop, QCpost_read_conversion))
{
CHECK_SYMBOL (val);
CODING_ATTR_POST_READ (attrs) = val;
ASET (attrs, coding_attr_post_read, val);
}
else if (EQ (prop, QCpre_write_conversion))
{
CHECK_SYMBOL (val);
CODING_ATTR_PRE_WRITE (attrs) = val;
ASET (attrs, coding_attr_pre_write, val);
}
else if (EQ (prop, QCascii_compatible_p))
{
CODING_ATTR_ASCII_COMPAT (attrs) = val;
ASET (attrs, coding_attr_ascii_compat, val);
}
CODING_ATTR_PLIST (attrs)
= Fplist_put (CODING_ATTR_PLIST (attrs), prop, val);
ASET (attrs, coding_attr_plist,
Fplist_put (CODING_ATTR_PLIST (attrs), prop, val));
return val;
}
......
......@@ -762,7 +762,7 @@ composition_gstring_width (Lisp_Object gstring, ptrdiff_t from, ptrdiff_t to,
}
metrics->width = metrics->lbearing = metrics->rbearing = 0;
}
for (glyph = &LGSTRING_GLYPH (gstring, from); from < to; from++, glyph++)
for (glyph = lgstring_glyph_addr (gstring, from); from < to; from++, glyph++)
{
int x;
......
......@@ -247,6 +247,11 @@ extern void compose_text (ptrdiff_t, ptrdiff_t, Lisp_Object, Lisp_Object,
#define LGSTRING_GLYPH_LEN(lgs) (ASIZE ((lgs)) - 2)
#define LGSTRING_GLYPH(lgs, idx) AREF ((lgs), (idx) + 2)
#define LGSTRING_SET_GLYPH(lgs, idx, val) ASET ((lgs), (idx) + 2, (val))
static inline Lisp_Object *
lgstring_glyph_addr (Lisp_Object lgs, ptrdiff_t idx)
{
return aref_addr (lgs, idx + 2);
}
/* Vector size of Lispy glyph. */
enum lglyph_indices
......
......@@ -1192,7 +1192,7 @@ value is a new vector that contains the elements between index FROM
string, make_number (0), res, Qnil);
}
else
res = Fvector (to_char - from_char, &AREF (string, from_char));
res = Fvector (to_char - from_char, aref_addr (string, from_char));
return res;
}
......@@ -1274,7 +1274,7 @@ substring_both (Lisp_Object string, ptrdiff_t from, ptrdiff_t from_byte,
string, make_number (0), res, Qnil);
}
else
res = Fvector (to - from, &AREF (string, from));
res = Fvector (to - from, aref_addr (string, from));
return res;
}
......@@ -3663,7 +3663,7 @@ make_hash_table (Lisp_Object test, Lisp_Object size, Lisp_Object rehash_size,
/* Set up the free list. */
for (i = 0; i < sz - 1; ++i)
HASH_NEXT (h, i) = make_number (i + 1);
set_hash_next (h, i, make_number (i + 1));
h->next_free = make_number (0);
XSET_HASH_TABLE (table, h);
......@@ -3770,7 +3770,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
the end of the free list. This makes some operations like
maphash faster. */
for (i = old_size; i < new_size - 1; ++i)
HASH_NEXT (h, i) = make_number (i + 1);
set_hash_next (h, i, make_number (i + 1));
if (!NILP (h->next_free))
{
......@@ -3781,7 +3781,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
!NILP (next))
last = next;
HASH_NEXT (h, XFASTINT (last)) = make_number (old_size);
set_hash_next (h, XFASTINT (last), make_number (old_size));
}
else
XSETFASTINT (h->next_free, old_size);
......@@ -3792,8 +3792,8 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h)
{
EMACS_UINT hash_code = XUINT (HASH_HASH (h, i));
ptrdiff_t start_of_bucket = hash_code % ASIZE (h->index);
HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket);
HASH_INDEX (h, start_of_bucket) = make_number (i);
set_hash_next (h, i, HASH_INDEX (h, start_of_bucket));
set_hash_index (h, start_of_bucket, make_number (i));
}
}
}
......@@ -3852,16 +3852,16 @@ hash_put (struct Lisp_Hash_Table *h, Lisp_Object key, Lisp_Object value,
/* Store key/value in the key_and_value vector. */
i = XFASTINT (h->next_free);
h->next_free = HASH_NEXT (h, i);
HASH_KEY (h, i) = key;
HASH_VALUE (h, i) = value;
set_hash_key (h, i, key);
set_hash_value (h, i, value);
/* Remember its hash code. */
HASH_HASH (h, i) = make_number (hash);
set_hash_hash (h, i, make_number (hash));
/* Add new entry to its collision chain. */
start_of_bucket = hash % ASIZE (h->index);
HASH_NEXT (h, i) = HASH_INDEX (h, start_of_bucket);
HASH_INDEX (h, start_of_bucket) = make_number (i);
set_hash_next (h, i, HASH_INDEX (h, start_of_bucket));
set_hash_index (h, start_of_bucket, make_number (i));
return i;
}
......@@ -3892,14 +3892,16 @@ hash_remove_from_table (struct Lisp_Hash_Table *h, Lisp_Object key)
{
/* Take entry out of collision chain. */
if (NILP (prev))
HASH_INDEX (h, start_of_bucket) = HASH_NEXT (h, i);
set_hash_index (h, start_of_bucket, HASH_NEXT (h, i));
else
HASH_NEXT (h, XFASTINT (prev)) = HASH_NEXT (h, i);
set_hash_next (h, XFASTINT (prev), HASH_NEXT (h, i));
/* Clear slots in key_and_value and add the slots to
the free list. */
HASH_KEY (h, i) = HASH_VALUE (h, i) = HASH_HASH (h, i) = Qnil;
HASH_NEXT (h, i) = h->next_free;
set_hash_key (h, i, Qnil);
set_hash_value (h, i, Qnil);
set_hash_hash (h, i, Qnil);
set_hash_next (h, i, h->next_free);
h->next_free = make_number (i);
h->count--;
eassert (h->count >= 0);
......@@ -3925,10 +3927,10 @@ hash_clear (struct Lisp_Hash_Table *h)
for (i = 0; i < size; ++i)
{
HASH_NEXT (h, i) = i < size - 1 ? make_number (i + 1) : Qnil;
HASH_KEY (h, i) = Qnil;
HASH_VALUE (h, i) = Qnil;
HASH_HASH (h, i) = Qnil;
set_hash_next (h, i, i < size - 1 ? make_number (i + 1) : Qnil);
set_hash_key (h, i, Qnil);
set_hash_value (h, i, Qnil);
set_hash_hash (h, i, Qnil);
}
for (i = 0; i < ASIZE (h->index); ++i)
......@@ -3992,17 +3994,18 @@ sweep_weak_table (struct Lisp_Hash_Table *h, int remove_entries_p)
{
/* Take out of collision chain. */
if (NILP (prev))
HASH_INDEX (h, bucket) = next;
set_hash_index (h, bucket, next);
else
HASH_NEXT (h, XFASTINT (prev)) = next;
set_hash_next (h, XFASTINT (prev), next);
/* Add to free list. */
HASH_NEXT (h, i) = h->next_free;
set_hash_next (h, i, h->next_free);
h->next_free = idx;
/* Clear key, value, and hash. */
HASH_KEY (h, i) = HASH_VALUE (h, i) = Qnil;
HASH_HASH (h, i) = Qnil;
set_hash_key (h, i, Qnil);
set_hash_value (h, i, Qnil);
set_hash_hash (h, i, Qnil);
h->count--;
}
......@@ -4509,7 +4512,7 @@ VALUE. In any case, return VALUE. */)
i = hash_lookup (h, key, &hash);
if (i >= 0)
HASH_VALUE (h, i) = value;
set_hash_value (h, i, value);
else
hash_put (h, key, value, hash);
......
......@@ -4722,7 +4722,7 @@ the corresponding element is nil. */)
Lisp_Object elt = AREF (object, XFASTINT (from) + i);
CHECK_CHARACTER (elt);
}
chars = &(AREF (object, XFASTINT (from)));
chars = aref_addr (object, XFASTINT (from));
}
vec = Fmake_vector (make_number (len), Qnil);
......
......@@ -5551,7 +5551,7 @@ make_lispy_event (struct input_event *event)
mouse_syms = larger_vector (mouse_syms, incr, -1);
}
start_pos_ptr = &AREF (button_down_location, button);
start_pos_ptr = aref_addr (button_down_location, button);
start_pos = *start_pos_ptr;
*start_pos_ptr = Qnil;
......@@ -5959,7 +5959,7 @@ make_lispy_event (struct input_event *event)
mouse_syms = larger_vector (mouse_syms, incr, -1);
}
start_pos_ptr = &AREF (button_down_location, button);
start_pos_ptr = aref_addr (button_down_location, button);
start_pos = *start_pos_ptr;
position = make_lispy_position (f, event->x, event->y,
......@@ -7525,8 +7525,8 @@ menu_bar_items (Lisp_Object old)
tem2 = AREF (menu_bar_items_vector, i + 2);
tem3 = AREF (menu_bar_items_vector, i + 3);
if (end > i + 4)
memmove (&AREF (menu_bar_items_vector, i),
&AREF (menu_bar_items_vector, i + 4),
memmove (aref_addr (menu_bar_items_vector, i),
aref_addr (menu_bar_items_vector, i + 4),
(end - i - 4) * sizeof (Lisp_Object));
ASET (menu_bar_items_vector, end - 4, tem0);
ASET (menu_bar_items_vector, end - 3, tem1);
......@@ -7575,8 +7575,8 @@ menu_bar_item (Lisp_Object key, Lisp_Object item, Lisp_Object dummy1, void *dumm
if (EQ (key, AREF (menu_bar_items_vector, i)))
{
if (menu_bar_items_index > i + 4)
memmove (&AREF (menu_bar_items_vector, i),
&AREF (menu_bar_items_vector, i + 4),
memmove (aref_addr (menu_bar_items_vector, i),
aref_addr (menu_bar_items_vector, i + 4),
(menu_bar_items_index - i - 4) * sizeof (Lisp_Object));
menu_bar_items_index -= 4;
}
......@@ -8096,6 +8096,14 @@ process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void
UNGCPRO;
}
/* Access slot with index IDX of vector tool_bar_item_properties. */
#define PROP(IDX) AREF (tool_bar_item_properties, (IDX))
static inline void
set_prop (ptrdiff_t idx, Lisp_Object val)
{
ASET (tool_bar_item_properties, idx, val);
}
/* Parse a tool bar item specification ITEM for key KEY and return the
result in tool_bar_item_properties. Value is zero if ITEM is
......@@ -8146,9 +8154,6 @@ process_tool_bar_item (Lisp_Object key, Lisp_Object def, Lisp_Object data, void
static int
parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
{
/* Access slot with index IDX of vector tool_bar_item_properties. */
#define PROP(IDX) AREF (tool_bar_item_properties, (IDX))
Lisp_Object filter = Qnil;
Lisp_Object caption;
int i, have_label = 0;
......@@ -8172,15 +8177,15 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
if (VECTORP (tool_bar_item_properties))
{
for (i = 0; i < TOOL_BAR_ITEM_NSLOTS; ++i)
PROP (i) = Qnil;
set_prop (i, Qnil);
}
else
tool_bar_item_properties
= Fmake_vector (make_number (TOOL_BAR_ITEM_NSLOTS), Qnil);
/* Set defaults. */
PROP (TOOL_BAR_ITEM_KEY) = key;
PROP (TOOL_BAR_ITEM_ENABLED_P) = Qt;
set_prop (TOOL_BAR_ITEM_KEY, key);
set_prop (TOOL_BAR_ITEM_ENABLED_P, Qt);
/* Get the caption of the item. If the caption is not a string,
evaluate it to get a string. If we don't get a string, skip this
......@@ -8192,7 +8197,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
if (!STRINGP (caption))
return 0;
}
PROP (TOOL_BAR_ITEM_CAPTION) = caption;
set_prop (TOOL_BAR_ITEM_CAPTION, caption);
/* If the rest following the caption is not a list, the menu item is
either a separator, or invalid. */
......@@ -8201,7 +8206,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
{
if (menu_separator_name_p (SSDATA (caption)))
{
PROP (TOOL_BAR_ITEM_TYPE) = Qt;
set_prop (TOOL_BAR_ITEM_TYPE, Qt);
#if !defined (USE_GTK) && !defined (HAVE_NS)
/* If we use build_desired_tool_bar_string to render the
tool bar, the separator is rendered as an image. */
......@@ -8217,7 +8222,7 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
}
/* Store the binding. */
PROP (TOOL_BAR_ITEM_BINDING) = XCAR (item);
set_prop (TOOL_BAR_ITEM_BINDING, XCAR (item));
item = XCDR (item);
/* Ignore cached key binding, if any. */
......@@ -8236,9 +8241,9 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
{
/* `:enable FORM'. */
if (!NILP (Venable_disabled_menus_and_buttons))
PROP (TOOL_BAR_ITEM_ENABLED_P) = Qt;
set_prop (TOOL_BAR_ITEM_ENABLED_P, Qt);
else
PROP (TOOL_BAR_ITEM_ENABLED_P) = value;
set_prop (TOOL_BAR_ITEM_ENABLED_P, value);
}
else if (EQ (ikey, QCvisible))
{
......@@ -8249,17 +8254,16 @@ parse_tool_bar_item (Lisp_Object key, Lisp_Object item)
}
else if (EQ (ikey, QChelp))