* alloc.c (pure_bytes_used_lisp, pure_bytes_used_non_lisp):
[bpt/emacs.git] / src / fontset.c
index f94bc95..7730f2e 100644 (file)
@@ -58,8 +58,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #undef xassert
 #ifdef FONTSET_DEBUG
 #define xassert(X)     do {if (!(X)) abort ();} while (0)
-#undef INLINE
-#define INLINE
 #else   /* not FONTSET_DEBUG */
 #define xassert(X)     (void) 0
 #endif /* not FONTSET_DEBUG */
@@ -233,14 +231,14 @@ fontset_id_valid_p (int id)
 /* Macros to access special values of (base) FONTSET.  */
 #define FONTSET_NAME(fontset)          XCHAR_TABLE (fontset)->extras[1]
 #define FONTSET_ASCII(fontset)         XCHAR_TABLE (fontset)->extras[4]
-#define FONTSET_SPEC(fontset)          XCHAR_TABLE (fontset)->extras[5]
+/* #define FONTSET_SPEC(fontset)       XCHAR_TABLE (fontset)->extras[5] */
 
 /* Macros to access special values of (realized) FONTSET.  */
 #define FONTSET_BASE(fontset)          XCHAR_TABLE (fontset)->extras[2]
 #define FONTSET_FRAME(fontset)         XCHAR_TABLE (fontset)->extras[3]
-#define FONTSET_OBJLIST(fontset)       XCHAR_TABLE (fontset)->extras[4]
+/* #define FONTSET_OBJLIST(fontset)    XCHAR_TABLE (fontset)->extras[4] */
 #define FONTSET_NOFONT_FACE(fontset)   XCHAR_TABLE (fontset)->extras[5]
-#define FONTSET_REPERTORY(fontset)     XCHAR_TABLE (fontset)->extras[6]
+/* #define FONTSET_REPERTORY(fontset)  XCHAR_TABLE (fontset)->extras[6] */
 #define FONTSET_DEFAULT(fontset)       XCHAR_TABLE (fontset)->extras[7]
 
 /* For both base and realized fontset.  */
@@ -266,7 +264,6 @@ fontset_id_valid_p (int id)
   ASET ((rfont_def), 0, make_number (face_id))
 #define RFONT_DEF_FONT_DEF(rfont_def) AREF (rfont_def, 1)
 #define RFONT_DEF_SPEC(rfont_def) FONT_DEF_SPEC (AREF (rfont_def, 1))
-#define RFONT_DEF_REPERTORY(rfont_def) FONT_DEF_REPERTORY (AREF (rfont_def, 1))
 #define RFONT_DEF_OBJECT(rfont_def) AREF (rfont_def, 2)
 #define RFONT_DEF_SET_OBJECT(rfont_def, object)        \
   ASET ((rfont_def), 2, (object))
@@ -419,9 +416,11 @@ reorder_font_vector (Lisp_Object font_group, struct font *font)
 
              for (tail = Vcharset_ordered_list;
                   ! EQ (tail, Vcharset_non_preferred_head) && CONSP (tail);
-                  score += 0x100, tail = XCDR (tail))
+                  tail = XCDR (tail))
                if (EQ (encoding, XCAR (tail)))
                  break;
+               else if (score <= MIN (INT_MAX, MOST_POSITIVE_FIXNUM) - 0x100)
+                 score += 0x100;
            }
          else
            {
@@ -450,7 +449,7 @@ reorder_font_vector (Lisp_Object font_group, struct font *font)
 /* Return a font-group (actually a cons (-1 . FONT-GROUP-VECTOR)) for
    character C in FONTSET.  If C is -1, return a fallback font-group.
    If C is not -1, the value may be Qt (FONTSET doesn't have a font
-   for C even in the fallback group, or 0 (a font for C may be found
+   for C even in the fallback group), or 0 (a font for C may be found
    only in the fallback group).  */
 
 static Lisp_Object
@@ -468,7 +467,9 @@ fontset_get_font_group (Lisp_Object fontset, int c)
   if (! NILP (font_group))
     return font_group;
   base_fontset = FONTSET_BASE (fontset);
-  if (c >= 0)
+  if (NILP (base_fontset))
+    font_group = Qnil;
+  else if (c >= 0)
     font_group = char_table_ref_and_range (base_fontset, c, &from, &to);
   else
     font_group = FONTSET_FALLBACK (base_fontset);
@@ -479,6 +480,8 @@ fontset_get_font_group (Lisp_Object fontset, int c)
        char_table_set_range (fontset, from, to, font_group);
       return font_group;
     }
+  if (!VECTORP (font_group))
+    return font_group;
   font_group = Fcopy_sequence (font_group);
   for (i = 0; i < ASIZE (font_group); i++)
     if (! NILP (AREF (font_group, i)))
@@ -713,7 +716,7 @@ fontset_find_font (Lisp_Object fontset, int c, struct face *face, int id, int fa
 static Lisp_Object
 fontset_font (Lisp_Object fontset, int c, struct face *face, int id)
 {
-  Lisp_Object rfont_def, default_rfont_def;
+  Lisp_Object rfont_def, default_rfont_def IF_LINT (= Qnil);
   Lisp_Object base_fontset;
 
   /* Try a font-group of FONTSET. */
@@ -786,7 +789,7 @@ make_fontset (Lisp_Object frame, Lisp_Object name, Lisp_Object base)
   while (!NILP (AREF (Vfontset_table, id))) id++;
 
   if (id + 1 == size)
-    Vfontset_table = larger_vector (Vfontset_table, size + 32, Qnil);
+    Vfontset_table = larger_vector (Vfontset_table, 1, -1);
 
   fontset = Fmake_char_table (Qfontset, Qnil);
 
@@ -836,9 +839,10 @@ fontset_ascii (int id)
   return elt;
 }
 
-void
+static void
 free_realized_fontset (FRAME_PTR f, Lisp_Object fontset)
 {
+#if 0
   Lisp_Object tail;
 
   if (0)
@@ -847,6 +851,7 @@ free_realized_fontset (FRAME_PTR f, Lisp_Object fontset)
        xassert (FONT_OBJECT_P (XCAR (tail)));
        font_close_object (f, XCAR (tail));
       }
+#endif
 }
 
 /* Free fontset of FACE defined on frame F.  Called from
@@ -882,6 +887,7 @@ free_face_fontset (FRAME_PTR f, struct face *face)
 }
 
 
+#if 0
 /* Return 1 if FACE is suitable for displaying character C.
    Otherwise return 0.  Called from the macro FACE_SUITABLE_FOR_CHAR_P
    when C is not an ASCII character.  */
@@ -897,6 +903,7 @@ face_suitable_for_char_p (struct face *face, int c)
          && INTEGERP (RFONT_DEF_FACE (rfont_def))
          && face->id == XINT (RFONT_DEF_FACE (rfont_def)));
 }
+#endif
 
 
 /* Return ID of face suitable for displaying character C on frame F.
@@ -1166,7 +1173,7 @@ fs_query_fontset (Lisp_Object name, int name_pattern)
       this_name = FONTSET_NAME (fontset);
       if (name_pattern == 1
          ? fast_string_match_ignore_case (name, this_name) >= 0
-         : !xstrcasecmp (SDATA (name), SDATA (this_name)))
+         : !xstrcasecmp (SSDATA (name), SSDATA (this_name)))
        return i;
     }
   return -1;
@@ -1583,14 +1590,14 @@ appended.  By default, FONT-SPEC overrides the previous settings.  */)
 
   if (ascii_changed)
     {
-      Lisp_Object tail, frame, alist;
+      Lisp_Object tail, fr, alist;
       int fontset_id = XINT (FONTSET_ID (fontset));
 
       FONTSET_ASCII (fontset) = fontname;
       name = FONTSET_NAME (fontset);
-      FOR_EACH_FRAME (tail, frame)
+      FOR_EACH_FRAME (tail, fr)
        {
-         FRAME_PTR f = XFRAME (frame);
+         FRAME_PTR f = XFRAME (fr);
          Lisp_Object font_object;
          struct face *face;
 
@@ -1607,7 +1614,7 @@ appended.  By default, FONT-SPEC overrides the previous settings.  */)
            {
              update_auto_fontset_alist (font_object, fontset);
              alist = Fcons (Fcons (Qfont, Fcons (name, font_object)), Qnil);
-             Fmodify_frame_parameters (frame, alist);
+             Fmodify_frame_parameters (fr, alist);
            }
        }
     }
@@ -1695,7 +1702,7 @@ FONT-SPEC is a vector, a cons, or a string.  See the documentation of
 static Lisp_Object auto_fontset_alist;
 
 /* Number of automatically created fontsets.  */
-static int num_auto_fontsets;
+static ptrdiff_t num_auto_fontsets;
 
 /* Retun a fontset synthesized from FONT-OBJECT.  This is called from
    x_new_font when FONT-OBJECT is used for the default ASCII font of a
@@ -1710,7 +1717,7 @@ int
 fontset_from_font (Lisp_Object font_object)
 {
   Lisp_Object font_name = font_get_name (font_object);
-  Lisp_Object font_spec = Fcopy_font_spec (font_object);
+  Lisp_Object font_spec = copy_font_spec (font_object);
   Lisp_Object registry = AREF (font_spec, FONT_REGISTRY_INDEX);
   Lisp_Object fontset_spec, alias, name, fontset;
   Lisp_Object val;
@@ -1722,12 +1729,12 @@ fontset_from_font (Lisp_Object font_object)
     alias = intern ("fontset-startup");
   else
     {
-      char temp[32];
+      char temp[sizeof "fontset-auto" + INT_STRLEN_BOUND (ptrdiff_t)];
 
-      sprintf (temp, "fontset-auto%d", num_auto_fontsets - 1);
+      sprintf (temp, "fontset-auto%"pD"d", num_auto_fontsets - 1);
       alias = intern (temp);
     }
-  fontset_spec = Fcopy_font_spec (font_spec);
+  fontset_spec = copy_font_spec (font_spec);
   ASET (fontset_spec, FONT_REGISTRY_INDEX, alias);
   name = Ffont_xlfd_name (fontset_spec, Qnil);
   if (NILP (name))
@@ -1811,12 +1818,11 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
        doc: /* For internal use only.  */)
   (Lisp_Object position, Lisp_Object ch)
 {
-  EMACS_INT pos, pos_byte, dummy;
+  ptrdiff_t pos, pos_byte, dummy;
   int face_id;
   int c;
   struct frame *f;
   struct face *face;
-  int cs_id;
 
   if (NILP (position))
     {
@@ -1825,17 +1831,16 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
       f = XFRAME (selected_frame);
       face_id = lookup_basic_face (f, DEFAULT_FACE_ID);
       pos = -1;
-      cs_id = -1;
     }
   else
     {
-      Lisp_Object window, charset;
+      Lisp_Object window;
       struct window *w;
 
       CHECK_NUMBER_COERCE_MARKER (position);
-      pos = XINT (position);
-      if (pos < BEGV || pos >= ZV)
+      if (! (BEGV <= XINT (position) && XINT (position) < ZV))
        args_out_of_range_3 (position, make_number (BEGV), make_number (ZV));
+      pos = XINT (position);
       pos_byte = CHAR_TO_BYTE (pos);
       if (NILP (ch))
        c = FETCH_CHAR (pos_byte);
@@ -1851,13 +1856,8 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
       f = XFRAME (w->frame);
       face_id = face_at_buffer_position (w, pos, -1, -1, &dummy,
                                         pos + 100, 0, -1);
-      charset = Fget_char_property (position, Qcharset, Qnil);
-      if (CHARSETP (charset))
-       cs_id = XINT (CHARSET_SYMBOL_ID (charset));
-      else
-       cs_id = -1;
     }
-  if (! CHAR_VALID_P (c, 0))
+  if (! CHAR_VALID_P (c))
     return Qnil;
   face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil);
   face = FACE_FROM_ID (f, face_id);
@@ -1865,17 +1865,11 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
     {
       unsigned code = face->font->driver->encode_char (face->font, c);
       Lisp_Object font_object;
-      /* Assignment to EMACS_INT stops GCC whining about limited range
-        of data type.  */
-      EMACS_INT cod = code;
 
       if (code == FONT_INVALID_CODE)
        return Qnil;
       XSETFONT (font_object, face->font);
-      if (cod <= MOST_POSITIVE_FIXNUM)
-       return Fcons (font_object, make_number (code));
-      return Fcons (font_object, Fcons (make_number (code >> 16),
-                                    make_number (code & 0xFFFF)));
+      return Fcons (font_object, INTEGER_TO_CONS (code));
     }
   return Qnil;
 }
@@ -1901,7 +1895,6 @@ information about the derived fonts from the default fontset.  The
 format is the same as above.  */)
   (Lisp_Object fontset, Lisp_Object frame)
 {
-  FRAME_PTR f;
   Lisp_Object *realized[2], fontsets[2], tables[2];
   Lisp_Object val, elt;
   int c, i, j, k;
@@ -1909,7 +1902,6 @@ format is the same as above.  */)
   (*check_window_system_func) ();
 
   fontset = check_fontset_name (fontset, &frame);
-  f = XFRAME (frame);
 
   /* Recode fontsets realized on FRAME from the base fontset FONTSET
      in the table `realized'.  */
@@ -2114,6 +2106,8 @@ DEFUN ("fontset-list", Ffontset_list, Sfontset_list, 0, 0, 0,
 
 #ifdef FONTSET_DEBUG
 
+Lisp_Object dump_fontset (Lisp_Object) EXTERNALLY_VISIBLE;
+
 Lisp_Object
 dump_fontset (Lisp_Object fontset)
 {