Use "ASET (a, i, v)" rather than "AREF (a, i) = v".
[bpt/emacs.git] / src / xfont.c
index 8b1e37a..736c116 100644 (file)
@@ -1,5 +1,5 @@
 /* xfont.c -- X core font driver.
 /* xfont.c -- X core font driver.
-   Copyright (C) 2006-2011 Free Software Foundation, Inc.
+   Copyright (C) 2006-2012 Free Software Foundation, Inc.
    Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H13PRO009
    Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011
      National Institute of Advanced Industrial Science and Technology (AIST)
      Registration Number H13PRO009
@@ -132,7 +132,7 @@ static int xfont_check (FRAME_PTR, struct font *);
 
 struct font_driver xfont_driver =
   {
 
 struct font_driver xfont_driver =
   {
-    0,                         /* Qx */
+    LISP_INITIALLY_ZERO,       /* Qx */
     0,                         /* case insensitive */
     xfont_get_cache,
     xfont_list,
     0,                         /* case insensitive */
     xfont_get_cache,
     xfont_list,
@@ -164,8 +164,9 @@ xfont_get_cache (FRAME_PTR f)
 static int
 compare_font_names (const void *name1, const void *name2)
 {
 static int
 compare_font_names (const void *name1, const void *name2)
 {
-  return xstrcasecmp (*(const char **) name1,
-                     *(const char **) name2);
+  char *const *n1 = name1;
+  char *const *n2 = name2;
+  return xstrcasecmp (*n1, *n2);
 }
 
 /* Decode XLFD as iso-8859-1 into OUTPUT, and return the byte length
 }
 
 /* Decode XLFD as iso-8859-1 into OUTPUT, and return the byte length
@@ -173,7 +174,7 @@ compare_font_names (const void *name1, const void *name2)
    XLFD is NULL terminated.  The caller must assure that OUTPUT is at
    least twice (plus 1) as large as XLFD.  */
 
    XLFD is NULL terminated.  The caller must assure that OUTPUT is at
    least twice (plus 1) as large as XLFD.  */
 
-static int
+static ptrdiff_t
 xfont_decode_coding_xlfd (char *xlfd, int len, char *output)
 {
   char *p0 = xlfd, *p1 = output;
 xfont_decode_coding_xlfd (char *xlfd, int len, char *output)
 {
   char *p0 = xlfd, *p1 = output;
@@ -272,8 +273,8 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont,
   return 0;
 }
 
   return 0;
 }
 
-/* A hash table recoding which font supports which scritps.  Each key
-   is a vector of characteristic font propertis FOUNDRY to WIDTH and
+/* A hash table recoding which font supports which scripts.  Each key
+   is a vector of characteristic font properties FOUNDRY to WIDTH and
    ADDSTYLE, and each value is a list of script symbols.
 
    We assume that fonts that have the same value in the above
    ADDSTYLE, and each value is a list of script symbols.
 
    We assume that fonts that have the same value in the above
@@ -281,7 +282,7 @@ xfont_chars_supported (Lisp_Object chars, XFontStruct *xfont,
 
 static Lisp_Object xfont_scripts_cache;
 
 
 static Lisp_Object xfont_scripts_cache;
 
-/* Re-usable vector to store characteristic font properites.   */
+/* Re-usable vector to store characteristic font properties.   */
 static Lisp_Object xfont_scratch_props;
 
 /* Return a list of scripts supported by the font of FONTNAME whose
 static Lisp_Object xfont_scratch_props;
 
 /* Return a list of scripts supported by the font of FONTNAME whose
@@ -396,13 +397,14 @@ xfont_list_pattern (Display *display, const char *pattern,
 
       for (i = 0; i < num_fonts; i++)
        {
 
       for (i = 0; i < num_fonts; i++)
        {
+         ptrdiff_t len;
          Lisp_Object entity;
 
          if (i > 0 && xstrcasecmp (indices[i - 1], indices[i]) == 0)
            continue;
          entity = font_make_entity ();
          Lisp_Object entity;
 
          if (i > 0 && xstrcasecmp (indices[i - 1], indices[i]) == 0)
            continue;
          entity = font_make_entity ();
-         xfont_decode_coding_xlfd (indices[i], -1, buf);
-         if (font_parse_xlfd (buf, entity) < 0)
+         len = xfont_decode_coding_xlfd (indices[i], -1, buf);
+         if (font_parse_xlfd (buf, len, entity) < 0)
            continue;
          ASET (entity, FONT_TYPE_INDEX, Qx);
          /* Avoid auto-scaled fonts.  */
            continue;
          ASET (entity, FONT_TYPE_INDEX, Qx);
          /* Avoid auto-scaled fonts.  */
@@ -432,7 +434,8 @@ xfont_list_pattern (Display *display, const char *pattern,
                {
                  elt = XCAR (tail);
                  if (STRINGP (elt)
                {
                  elt = XCAR (tail);
                  if (STRINGP (elt)
-                     && fast_c_string_match_ignore_case (elt, indices[i]) >= 0)
+                     && fast_c_string_match_ignore_case (elt, indices[i],
+                                                         len) >= 0)
                    break;
                }
              if (! CONSP (tail))
                    break;
                }
              if (! CONSP (tail))
@@ -460,11 +463,11 @@ xfont_list_pattern (Display *display, const char *pattern,
                list = Fcons (entity, list);
              continue;
            }
                list = Fcons (entity, list);
              continue;
            }
-         if (memcmp (props, &(AREF (entity, FONT_FOUNDRY_INDEX)),
+         if (memcmp (props, aref_addr (entity, FONT_FOUNDRY_INDEX),
                      sizeof (Lisp_Object) * 7)
              || ! EQ (AREF (entity, FONT_SPACING_INDEX), props[7]))
            {
                      sizeof (Lisp_Object) * 7)
              || ! EQ (AREF (entity, FONT_SPACING_INDEX), props[7]))
            {
-             memcpy (props, &(AREF (entity, FONT_FOUNDRY_INDEX)),
+             memcpy (props, aref_addr (entity, FONT_FOUNDRY_INDEX),
                      sizeof (Lisp_Object) * 7);
              props[7] = AREF (entity, FONT_SPACING_INDEX);
              scripts = xfont_supported_scripts (display, indices[i],
                      sizeof (Lisp_Object) * 7);
              props[7] = AREF (entity, FONT_SPACING_INDEX);
              scripts = xfont_supported_scripts (display, indices[i],
@@ -603,10 +606,11 @@ xfont_match (Lisp_Object frame, Lisp_Object spec)
             string.  We must avoid such a name.  */
          if (*s)
            {
             string.  We must avoid such a name.  */
          if (*s)
            {
+             ptrdiff_t len;
              entity = font_make_entity ();
              ASET (entity, FONT_TYPE_INDEX, Qx);
              entity = font_make_entity ();
              ASET (entity, FONT_TYPE_INDEX, Qx);
-             xfont_decode_coding_xlfd (s, -1, name);
-             if (font_parse_xlfd (name, entity) < 0)
+             len = xfont_decode_coding_xlfd (s, -1, name);
+             if (font_parse_xlfd (name, len, entity) < 0)
                entity = Qnil;
            }
          XFree (s);
                entity = Qnil;
            }
          XFree (s);
@@ -795,7 +799,7 @@ xfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
   ASET (font_object, FONT_TYPE_INDEX, Qx);
   if (STRINGP (fullname))
     {
   ASET (font_object, FONT_TYPE_INDEX, Qx);
   if (STRINGP (fullname))
     {
-      font_parse_xlfd (SSDATA (fullname), font_object);
+      font_parse_xlfd (SSDATA (fullname), SBYTES (fullname), font_object);
       ASET (font_object, FONT_NAME_INDEX, fullname);
     }
   else
       ASET (font_object, FONT_NAME_INDEX, fullname);
     }
   else