Generalize run-time debugging checks.
[bpt/emacs.git] / src / xfaces.c
index f2cd0eb..a319c54 100644 (file)
@@ -539,7 +539,7 @@ int color_count[256];
 void
 register_color (unsigned long pixel)
 {
-  xassert (pixel < 256);
+  eassert (pixel < 256);
   ++color_count[pixel];
 }
 
@@ -549,7 +549,7 @@ register_color (unsigned long pixel)
 void
 unregister_color (unsigned long pixel)
 {
-  xassert (pixel < 256);
+  eassert (pixel < 256);
   if (color_count[pixel] > 0)
     --color_count[pixel];
   else
@@ -663,7 +663,7 @@ static inline void
 x_free_gc (struct frame *f, GC gc)
 {
   eassert (interrupt_input_blocked);
-  IF_DEBUG (xassert (--ngcs >= 0));
+  IF_DEBUG (eassert (--ngcs >= 0));
   XFreeGC (FRAME_X_DISPLAY (f), gc);
 }
 
@@ -689,7 +689,7 @@ x_create_gc (struct frame *f, unsigned long mask, XGCValues *xgcv)
 static inline void
 x_free_gc (struct frame *f, GC gc)
 {
-  IF_DEBUG (xassert (--ngcs >= 0));
+  IF_DEBUG (eassert (--ngcs >= 0));
   xfree (gc);
 }
 
@@ -1325,8 +1325,8 @@ load_color (struct frame *f, struct face *face, Lisp_Object name,
 {
   XColor color;
 
-  xassert (STRINGP (name));
-  xassert (target_index == LFACE_FOREGROUND_INDEX
+  eassert (STRINGP (name));
+  eassert (target_index == LFACE_FOREGROUND_INDEX
           || target_index == LFACE_BACKGROUND_INDEX
           || target_index == LFACE_UNDERLINE_INDEX
           || target_index == LFACE_OVERLINE_INDEX
@@ -1855,7 +1855,7 @@ the WIDTH times as wide as FACE on FRAME.  */)
 #define LFACE_INHERIT(LFACE)       AREF ((LFACE), LFACE_INHERIT_INDEX)
 #define LFACE_FONTSET(LFACE)       AREF ((LFACE), LFACE_FONTSET_INDEX)
 
-#if XASSERTS
+#ifdef ENABLE_CHECKING
 /* Non-zero if LFACE is a Lisp face.  A Lisp face is a vector of size
    LFACE_VECTOR_SIZE which has the symbol `face' in slot 0.  */
 
@@ -1873,68 +1873,68 @@ the WIDTH times as wide as FACE on FRAME.  */)
 static void
 check_lface_attrs (Lisp_Object *attrs)
 {
-  xassert (UNSPECIFIEDP (attrs[LFACE_FAMILY_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_FAMILY_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_FAMILY_INDEX])
           || STRINGP (attrs[LFACE_FAMILY_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_FOUNDRY_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_FOUNDRY_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_FOUNDRY_INDEX])
           || STRINGP (attrs[LFACE_FOUNDRY_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_SWIDTH_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_SWIDTH_INDEX])
           || SYMBOLP (attrs[LFACE_SWIDTH_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_HEIGHT_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_HEIGHT_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_HEIGHT_INDEX])
           || INTEGERP (attrs[LFACE_HEIGHT_INDEX])
           || FLOATP (attrs[LFACE_HEIGHT_INDEX])
           || FUNCTIONP (attrs[LFACE_HEIGHT_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_WEIGHT_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_WEIGHT_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_WEIGHT_INDEX])
           || SYMBOLP (attrs[LFACE_WEIGHT_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_SLANT_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_SLANT_INDEX])
           || SYMBOLP (attrs[LFACE_SLANT_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_UNDERLINE_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_UNDERLINE_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_UNDERLINE_INDEX])
           || SYMBOLP (attrs[LFACE_UNDERLINE_INDEX])
           || STRINGP (attrs[LFACE_UNDERLINE_INDEX])
           || CONSP (attrs[LFACE_UNDERLINE_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_OVERLINE_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_OVERLINE_INDEX])
           || SYMBOLP (attrs[LFACE_OVERLINE_INDEX])
           || STRINGP (attrs[LFACE_OVERLINE_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_STRIKE_THROUGH_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_STRIKE_THROUGH_INDEX])
           || SYMBOLP (attrs[LFACE_STRIKE_THROUGH_INDEX])
           || STRINGP (attrs[LFACE_STRIKE_THROUGH_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_BOX_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_BOX_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_BOX_INDEX])
           || SYMBOLP (attrs[LFACE_BOX_INDEX])
           || STRINGP (attrs[LFACE_BOX_INDEX])
           || INTEGERP (attrs[LFACE_BOX_INDEX])
           || CONSP (attrs[LFACE_BOX_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_INVERSE_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_INVERSE_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_INVERSE_INDEX])
           || SYMBOLP (attrs[LFACE_INVERSE_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_FOREGROUND_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_FOREGROUND_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_FOREGROUND_INDEX])
           || STRINGP (attrs[LFACE_FOREGROUND_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_BACKGROUND_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_BACKGROUND_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_BACKGROUND_INDEX])
           || STRINGP (attrs[LFACE_BACKGROUND_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_INHERIT_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_INHERIT_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_INHERIT_INDEX])
           || NILP (attrs[LFACE_INHERIT_INDEX])
           || SYMBOLP (attrs[LFACE_INHERIT_INDEX])
           || CONSP (attrs[LFACE_INHERIT_INDEX]));
 #ifdef HAVE_WINDOW_SYSTEM
-  xassert (UNSPECIFIEDP (attrs[LFACE_STIPPLE_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_STIPPLE_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_STIPPLE_INDEX])
           || SYMBOLP (attrs[LFACE_STIPPLE_INDEX])
           || !NILP (Fbitmap_spec_p (attrs[LFACE_STIPPLE_INDEX])));
-  xassert (UNSPECIFIEDP (attrs[LFACE_FONT_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_FONT_INDEX])
           || IGNORE_DEFFACE_P (attrs[LFACE_FONT_INDEX])
           || FONTP (attrs[LFACE_FONT_INDEX]));
-  xassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX])
+  eassert (UNSPECIFIEDP (attrs[LFACE_FONTSET_INDEX])
           || STRINGP (attrs[LFACE_FONTSET_INDEX])
           || NILP (attrs[LFACE_FONTSET_INDEX]));
 #endif
@@ -1948,7 +1948,7 @@ check_lface (Lisp_Object lface)
 {
   if (!NILP (lface))
     {
-      xassert (LFACEP (lface));
+      eassert (LFACEP (lface));
       check_lface_attrs (XVECTOR (lface)->contents);
     }
 }
@@ -2225,7 +2225,7 @@ set_lface_from_font (struct frame *f, Lisp_Object lface,
     {
       int pt = PIXEL_TO_POINT (font->pixel_size * 10, f->resy);
 
-      xassert (pt > 0);
+      eassert (pt > 0);
       LFACE_HEIGHT (lface) = make_number (pt);
     }
 
@@ -2731,7 +2731,7 @@ Value is a vector of face attributes.  */)
       ++windows_or_buffers_changed;
     }
 
-  xassert (LFACEP (lface));
+  eassert (LFACEP (lface));
   check_lface (lface);
   return lface;
 }
@@ -3515,7 +3515,7 @@ face_boolean_x_resource_value (Lisp_Object value, int signal_p)
 {
   Lisp_Object result = make_number (0);
 
-  xassert (STRINGP (value));
+  eassert (STRINGP (value));
 
   if (xstrcasecmp (SSDATA (value), "on") == 0
       || xstrcasecmp (SSDATA (value), "true") == 0)
@@ -4088,7 +4088,7 @@ hash_string_case_insensitive (Lisp_Object string)
 {
   const unsigned char *s;
   unsigned hash = 0;
-  xassert (STRINGP (string));
+  eassert (STRINGP (string));
   for (s = SDATA (string); *s; ++s)
     hash = (hash << 1) ^ tolower (*s);
   return hash;
@@ -4119,7 +4119,7 @@ lface_hash (Lisp_Object *v)
 static inline int
 lface_same_font_attributes_p (Lisp_Object *lface1, Lisp_Object *lface2)
 {
-  xassert (lface_fully_specified_p (lface1)
+  eassert (lface_fully_specified_p (lface1)
           && lface_fully_specified_p (lface2));
   return (xstrcasecmp (SSDATA (lface1[LFACE_FAMILY_INDEX]),
                       SSDATA (lface2[LFACE_FAMILY_INDEX])) == 0
@@ -4200,7 +4200,7 @@ void
 prepare_face_for_display (struct frame *f, struct face *face)
 {
 #ifdef HAVE_WINDOW_SYSTEM
-  xassert (FRAME_WINDOW_P (f));
+  eassert (FRAME_WINDOW_P (f));
 
   if (face->gc == 0)
     {
@@ -4472,7 +4472,7 @@ cache_face (struct face_cache *c, struct face *face, unsigned int hash)
        if (face1->id == i)
          ++n;
 
-    xassert (n == 1);
+    eassert (n == 1);
   }
 #endif /* GLYPH_DEBUG */
 
@@ -4523,7 +4523,7 @@ lookup_face (struct frame *f, Lisp_Object *attr)
   int i;
   struct face *face;
 
-  xassert (cache != NULL);
+  eassert (cache != NULL);
   check_lface_attrs (attr);
 
   /* Look up ATTR in the face cache.  */
@@ -4548,7 +4548,7 @@ lookup_face (struct frame *f, Lisp_Object *attr)
     face = realize_face (cache, attr, -1);
 
 #if GLYPH_DEBUG
-  xassert (face == FACE_FROM_ID (f, face->id));
+  eassert (face == FACE_FROM_ID (f, face->id));
 #endif /* GLYPH_DEBUG */
 
   return face->id;
@@ -4569,7 +4569,7 @@ face_for_font (struct frame *f, Lisp_Object font_object, struct face *base_face)
   int i;
   struct face *face;
 
-  xassert (cache != NULL);
+  eassert (cache != NULL);
   base_face = base_face->ascii_face;
   hash = lface_hash (base_face->lface);
   i = hash % FACE_CACHE_BUCKETS_SIZE;
@@ -5470,7 +5470,7 @@ realize_default_face (struct frame *f)
     LFACE_STIPPLE (lface) = Qnil;
 
   /* Realize the face; it must be fully-specified now.  */
-  xassert (lface_fully_specified_p (XVECTOR (lface)->contents));
+  eassert (lface_fully_specified_p (XVECTOR (lface)->contents));
   check_lface (lface);
   memcpy (attrs, XVECTOR (lface)->contents, sizeof attrs);
   face = realize_face (c, attrs, DEFAULT_FACE_ID);
@@ -5511,7 +5511,7 @@ realize_named_face (struct frame *f, Lisp_Object symbol, int id)
   /* The default face must exist and be fully specified.  */
   get_lface_attributes_no_remap (f, Qdefault, attrs, 1);
   check_lface_attrs (attrs);
-  xassert (lface_fully_specified_p (attrs));
+  eassert (lface_fully_specified_p (attrs));
 
   /* If SYMBOL isn't know as a face, create it.  */
   if (NILP (lface))
@@ -5541,7 +5541,7 @@ realize_face (struct face_cache *cache, Lisp_Object *attrs, int former_face_id)
   struct face *face;
 
   /* LFACE must be fully specified.  */
-  xassert (cache != NULL);
+  eassert (cache != NULL);
   check_lface_attrs (attrs);
 
   if (former_face_id >= 0 && cache->used > former_face_id)
@@ -5621,7 +5621,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object *attrs)
   struct frame *f;
   Lisp_Object stipple, underline, overline, strike_through, box;
 
-  xassert (FRAME_WINDOW_P (cache->f));
+  eassert (FRAME_WINDOW_P (cache->f));
 
   /* Allocate a new realized face.  */
   face = make_realized_face (attrs);
@@ -5699,7 +5699,7 @@ realize_x_face (struct face_cache *cache, Lisp_Object *attrs)
     {
       /* Simple box of specified line width in foreground color of the
         face.  */
-      xassert (XINT (box) != 0);
+      eassert (XINT (box) != 0);
       face->box = FACE_SIMPLE_BOX;
       face->box_line_width = XINT (box);
       face->box_color = face->foreground;
@@ -5880,7 +5880,7 @@ map_tty_color (struct frame *f, struct face *face,
     foreground_p ? FACE_TTY_DEFAULT_BG_COLOR : FACE_TTY_DEFAULT_FG_COLOR;
 #endif
 
-  xassert (idx == LFACE_FOREGROUND_INDEX || idx == LFACE_BACKGROUND_INDEX);
+  eassert (idx == LFACE_FOREGROUND_INDEX || idx == LFACE_BACKGROUND_INDEX);
 
   XSETFRAME (frame, f);
   color = face->lface[idx];
@@ -5948,7 +5948,7 @@ realize_tty_face (struct face_cache *cache, Lisp_Object *attrs)
   struct frame *f = cache->f;
 
   /* Frame must be a termcap frame.  */
-  xassert (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f));
+  eassert (FRAME_TERMCAP_P (cache->f) || FRAME_MSDOS_P (cache->f));
 
   /* Allocate a new realized face.  */
   face = make_realized_face (attrs);
@@ -6079,7 +6079,7 @@ face_at_buffer_position (struct window *w, ptrdiff_t pos,
 
   /* W must display the current buffer.  We could write this function
      to use the frame and buffer of W, but right now it doesn't.  */
-  /* xassert (XBUFFER (w->buffer) == current_buffer); */
+  /* eassert (XBUFFER (w->buffer) == current_buffer); */
 
   XSETFRAME (frame, f);
   XSETFASTINT (position, pos);
@@ -6189,7 +6189,7 @@ face_for_overlay_string (struct window *w, ptrdiff_t pos,
 
   /* W must display the current buffer.  We could write this function
      to use the frame and buffer of W, but right now it doesn't.  */
-  /* xassert (XBUFFER (w->buffer) == current_buffer); */
+  /* eassert (XBUFFER (w->buffer) == current_buffer); */
 
   XSETFRAME (frame, f);
   XSETFASTINT (position, pos);
@@ -6293,7 +6293,7 @@ face_at_string_position (struct window *w, Lisp_Object string,
     *endptr = -1;
 
   base_face = FACE_FROM_ID (f, base_face_id);
-  xassert (base_face);
+  eassert (base_face);
 
   /* Optimize the default case that there is no face property and we
      are not in the region.  */