Commit d6d9cbc1 authored by Dmitry Antipov's avatar Dmitry Antipov
Browse files

Use union for the payload of struct Lisp_Vector.

This helps to avoid a few glitches dictated by C's aliasing rules.
* lisp.h (struct Lisp_Vector): Use union for next and
contents member.  Adjust comment.  Change related users.
* alloc.c (next_in_free_list, set_next_in_free_list): Remove.
Related users changed.
* buffer.c, bytecode.c, ccl.c, character.h, chartab.c, composite.c:
* composite.h, disptab.h, fns.c, fontset.c, indent.c, keyboard.c:
* lread.c, msdos.c, process.c, w32menu.c, window.c, xdisp.c:
* xfaces.c, xfont.c, xmenu.c: Related users changed.
parent ec7bc82f
......@@ -4473,8 +4473,8 @@ setup_for_ellipsis (struct it *it, int len)
if (it->dp && VECTORP (DISP_INVIS_VECTOR (it->dp)))
{
struct Lisp_Vector *v = XVECTOR (DISP_INVIS_VECTOR (it->dp));
it->dpvec = v->contents;
it->dpend = v->contents + v->header.size;
it->dpvec = v->u.contents;
it->dpend = v->u.contents + v->header.size;
}
else
{
......@@ -6778,8 +6778,8 @@ get_next_display_element (struct it *it)
if (v->header.size)
{
it->dpvec_char_len = it->len;
it->dpvec = v->contents;
it->dpend = v->contents + v->header.size;
it->dpvec = v->u.contents;
it->dpend = v->u.contents + v->header.size;
it->current.dpvec_index = 0;
it->dpvec_face_id = -1;
it->saved_face_id = it->face_id;
......@@ -27555,7 +27555,7 @@ on_hot_spot_p (Lisp_Object hot_spot, int x, int y)
if (VECTORP (XCDR (hot_spot)))
{
struct Lisp_Vector *v = XVECTOR (XCDR (hot_spot));
Lisp_Object *poly = v->contents;
Lisp_Object *poly = v->u.contents;
ptrdiff_t n = v->header.size;
ptrdiff_t i;
int inside = 0;
......
......@@ -1565,7 +1565,7 @@ the face font sort order. */)
vec = Fvconcat (ndrivers, drivers);
nfonts = ASIZE (vec);
qsort (XVECTOR (vec)->contents, nfonts, word_size,
qsort (XVECTOR (vec)->u.contents, nfonts, word_size,
compare_fonts_by_sort_order);
result = Qnil;
......@@ -1830,7 +1830,7 @@ check_lface (Lisp_Object lface)
if (!NILP (lface))
{
eassert (LFACEP (lface));
check_lface_attrs (XVECTOR (lface)->contents);
check_lface_attrs (XVECTOR (lface)->u.contents);
}
}
......@@ -2007,7 +2007,7 @@ get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name,
lface = lface_from_face_name_no_resolve (f, face_name, signal_p);
if (! NILP (lface))
memcpy (attrs, XVECTOR (lface)->contents,
memcpy (attrs, XVECTOR (lface)->u.contents,
LFACE_VECTOR_SIZE * sizeof *attrs);
return !NILP (lface);
......@@ -2690,7 +2690,7 @@ The value is TO. */)
copy = Finternal_make_lisp_face (to, new_frame);
}
vcopy (copy, 0, XVECTOR (lface)->contents, LFACE_VECTOR_SIZE);
vcopy (copy, 0, XVECTOR (lface)->u.contents, LFACE_VECTOR_SIZE);
/* Changing a named face means that all realized faces depending on
that face are invalid. Since we cannot tell which realized faces
......@@ -3093,7 +3093,7 @@ FRAME 0 means change the face on all frames, and change the default
f = XFRAME (frame);
if (! FONT_OBJECT_P (value))
{
Lisp_Object *attrs = XVECTOR (lface)->contents;
Lisp_Object *attrs = XVECTOR (lface)->u.contents;
Lisp_Object font_object;
font_object = font_load_for_lface (f, attrs, value);
......@@ -3161,7 +3161,7 @@ FRAME 0 means change the face on all frames, and change the default
the font to nil so that the font selector doesn't think that
the attribute is mandatory. Also, clear the average
width. */
font_clear_prop (XVECTOR (lface)->contents, prop_index);
font_clear_prop (XVECTOR (lface)->u.contents, prop_index);
}
/* Changing a named face means that all realized faces depending on
......@@ -3191,7 +3191,7 @@ FRAME 0 means change the face on all frames, and change the default
reflected in changed `font' frame parameters. */
if (FRAMEP (frame)
&& (prop_index || EQ (attr, QCfont))
&& lface_fully_specified_p (XVECTOR (lface)->contents))
&& lface_fully_specified_p (XVECTOR (lface)->u.contents))
set_font_frame_param (frame, lface);
else
#endif /* HAVE_WINDOW_SYSTEM */
......@@ -3371,7 +3371,7 @@ set_font_frame_param (Lisp_Object frame, Lisp_Object lface)
{
if (FONT_SPEC_P (font))
{
font = font_load_for_lface (f, XVECTOR (lface)->contents, font);
font = font_load_for_lface (f, XVECTOR (lface)->u.contents, font);
if (NILP (font))
return;
ASET (lface, LFACE_FONT_INDEX, font);
......@@ -3728,8 +3728,8 @@ Default face attributes override any local face attributes. */)
the local frame is defined from default specs in `face-defface-spec'
and those should be overridden by global settings. Hence the strange
"global before local" priority. */
lvec = XVECTOR (local_lface)->contents;
gvec = XVECTOR (global_lface)->contents;
lvec = XVECTOR (local_lface)->u.contents;
gvec = XVECTOR (global_lface)->u.contents;
for (i = 1; i < LFACE_VECTOR_SIZE; ++i)
if (IGNORE_DEFFACE_P (gvec[i]))
ASET (local_lface, i, Qunspecified);
......@@ -3913,8 +3913,8 @@ If FRAME is omitted or nil, use the selected frame. */)
lface1 = lface_from_face_name (f, face1, 1);
lface2 = lface_from_face_name (f, face2, 1);
equal_p = lface_equal_p (XVECTOR (lface1)->contents,
XVECTOR (lface2)->contents);
equal_p = lface_equal_p (XVECTOR (lface1)->u.contents,
XVECTOR (lface2)->u.contents);
return equal_p ? Qt : Qnil;
}
......@@ -4651,7 +4651,7 @@ DEFUN ("face-attributes-as-vector", Fface_attributes_as_vector,
Lisp_Object lface;
lface = Fmake_vector (make_number (LFACE_VECTOR_SIZE),
Qunspecified);
merge_face_ref (XFRAME (selected_frame), plist, XVECTOR (lface)->contents,
merge_face_ref (XFRAME (selected_frame), plist, XVECTOR (lface)->u.contents,
1, 0);
return lface;
}
......@@ -5331,9 +5331,9 @@ realize_default_face (struct frame *f)
ASET (lface, LFACE_STIPPLE_INDEX, Qnil);
/* Realize the face; it must be fully-specified now. */
eassert (lface_fully_specified_p (XVECTOR (lface)->contents));
eassert (lface_fully_specified_p (XVECTOR (lface)->u.contents));
check_lface (lface);
memcpy (attrs, XVECTOR (lface)->contents, sizeof attrs);
memcpy (attrs, XVECTOR (lface)->u.contents, sizeof attrs);
face = realize_face (c, attrs, DEFAULT_FACE_ID);
#ifdef HAVE_WINDOW_SYSTEM
......
......@@ -384,7 +384,7 @@ xfont_list_pattern (Display *display, const char *pattern,
if (num_fonts > 0)
{
char **indices = alloca (sizeof (char *) * num_fonts);
Lisp_Object *props = XVECTOR (xfont_scratch_props)->contents;
Lisp_Object *props = XVECTOR (xfont_scratch_props)->u.contents;
Lisp_Object scripts = Qnil;
for (i = 0; i < ASIZE (xfont_scratch_props); i++)
......
......@@ -990,7 +990,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
/* Save the frame's previous menu bar contents data. */
if (previous_menu_items_used)
memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents,
memcpy (previous_items, XVECTOR (f->menu_bar_vector)->u.contents,
previous_menu_items_used * word_size);
/* Fill in menu_items with the current menu bar contents.
......@@ -2187,7 +2187,7 @@ menu_help_callback (char const *help_string, int pane, int item)
Lisp_Object pane_name;
Lisp_Object menu_object;
first_item = XVECTOR (menu_items)->contents;
first_item = XVECTOR (menu_items)->u.contents;
if (EQ (first_item[0], Qt))
pane_name = first_item[MENU_ITEMS_PANE_NAME];
else if (EQ (first_item[0], Qquote))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment