Simplify redefinition of 'abort' (Bug#12316).
[bpt/emacs.git] / src / ftfont.c
index 5545b4b..10b5341 100644 (file)
@@ -211,7 +211,7 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra)
     return Qnil;
 
   file = (char *) str;
-  key = Fcons (make_unibyte_string (file, strlen (file)), make_number (idx));
+  key = Fcons (build_unibyte_string (file), make_number (idx));
   cache = ftfont_lookup_cache (key, FTFONT_CACHE_FOR_ENTITY);
   entity = XCAR (cache);
   if (! NILP (entity))
@@ -372,7 +372,7 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for)
     {
       entity = key;
       val = assq_no_quit (QCfont_entity, AREF (entity, FONT_EXTRA_INDEX));
-      xassert (CONSP (val));
+      eassert (CONSP (val));
       key = XCDR (val);
     }
   else
@@ -392,7 +392,7 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for)
          args[1] = Qequal;
          ft_face_cache = Fmake_hash_table (2, args);
        }
-      cache_data = xmalloc (sizeof (struct ftfont_cache_data));
+      cache_data = xmalloc (sizeof *cache_data);
       cache_data->ft_face = NULL;
       cache_data->fc_charset = NULL;
       val = make_save_value (NULL, 0);
@@ -525,7 +525,7 @@ static int ftfont_variation_glyphs (struct font *, int c,
 
 struct font_driver ftfont_driver =
   {
-    0,                         /* Qfreetype */
+    LISP_INITIALLY_ZERO,       /* Qfreetype */
     0,                         /* case insensitive */
     ftfont_get_cache,
     ftfont_list,
@@ -598,7 +598,9 @@ ftfont_get_charset (Lisp_Object registry)
   re[j] = '\0';
   regexp = make_unibyte_string (re, j);
   for (i = 0; fc_charset_table[i].name; i++)
-    if (fast_c_string_match_ignore_case (regexp, fc_charset_table[i].name) >= 0)
+    if (fast_c_string_match_ignore_case
+       (regexp, fc_charset_table[i].name,
+        strlen (fc_charset_table[i].name)) >= 0)
       break;
   if (! fc_charset_table[i].name)
     return -1;
@@ -657,7 +659,7 @@ struct OpenTypeSpec
 static struct OpenTypeSpec *
 ftfont_get_open_type_spec (Lisp_Object otf_spec)
 {
-  struct OpenTypeSpec *spec = malloc (sizeof (struct OpenTypeSpec));
+  struct OpenTypeSpec *spec = malloc (sizeof *spec);
   Lisp_Object val;
   int i, j, negative;
 
@@ -696,7 +698,7 @@ ftfont_get_open_type_spec (Lisp_Object otf_spec)
       spec->features[i] =
        (min (PTRDIFF_MAX, SIZE_MAX) / sizeof (int) < XINT (len)
         ? 0
-        : malloc (sizeof (int) * XINT (len)));
+        : malloc (XINT (len) * sizeof *spec->features[i]));
       if (! spec->features[i])
        {
          if (i > 0 && spec->features[0])
@@ -1325,7 +1327,7 @@ ftfont_close (FRAME_PTR f, struct font *font)
 
   val = Fcons (font->props[FONT_FILE_INDEX], make_number (ftfont_info->index));
   cache = ftfont_lookup_cache (val, FTFONT_CACHE_FOR_FACE);
-  xassert (CONSP (cache));
+  eassert (CONSP (cache));
   val = XCDR (cache);
   (XSAVE_VALUE (val)->integer)--;
   if (XSAVE_VALUE (val)->integer == 0)
@@ -1628,7 +1630,7 @@ ftfont_get_metrics (MFLTFont *font, MFLTGlyphString *gstring,
            FT_Glyph_Metrics *m;
 
            if (FT_Load_Glyph (ft_face, g->code, FT_LOAD_DEFAULT) != 0)
-             abort ();
+             emacs_abort ();
            m = &ft_face->glyph->metrics;
            if (flt_font_ft->matrix)
              {
@@ -2460,15 +2462,16 @@ ftfont_shape_by_flt (Lisp_Object lgstring, struct font *font,
   if (gstring.allocated == 0)
     {
       gstring.glyph_size = sizeof (MFLTGlyph);
-      gstring.glyphs = xnmalloc (len * 2, sizeof (MFLTGlyph));
+      gstring.glyphs = xnmalloc (len * 2, sizeof *gstring.glyphs);
       gstring.allocated = len * 2;
     }
   else if (gstring.allocated < len * 2)
     {
-      gstring.glyphs = xnrealloc (gstring.glyphs, len * 2, sizeof (MFLTGlyph));
+      gstring.glyphs = xnrealloc (gstring.glyphs, len * 2,
+                                 sizeof *gstring.glyphs);
       gstring.allocated = len * 2;
     }
-  memset (gstring.glyphs, 0, sizeof (MFLTGlyph) * len);
+  memset (gstring.glyphs, 0, len * sizeof *gstring.glyphs);
   for (i = 0; i < len; i++)
     {
       Lisp_Object g = LGSTRING_GLYPH (lgstring, i);