Fix "emacsclient" typo. Replace problematic character.
[bpt/emacs.git] / src / fontset.c
index 2979afe..efa26ae 100644 (file)
@@ -352,9 +352,8 @@ fontset_add (fontset, range, elt, add)
       int from1, to1;
 
       do {
+       from1 = from, to1 = to;
        args[idx] = char_table_ref_and_range (fontset, from, &from1, &to1);
-       if (to < to1)
-         to1 = to;
        char_table_set_range (fontset, from, to1,
                              NILP (args[idx]) ? args[1 - idx]
                              : Fvconcat (2, args));
@@ -460,7 +459,7 @@ fontset_get_font_group (Lisp_Object fontset, int c)
 {
   Lisp_Object font_group;
   Lisp_Object base_fontset;
-  int from, to, i;
+  int from = 0, to = MAX_CHAR, i;
 
   xassert (! BASE_FONTSET_P (fontset));
   if (c >= 0)
@@ -516,9 +515,9 @@ fontset_find_font (fontset, c, face, id, fallback)
      int id, fallback;
 {
   Lisp_Object elt, vec, font_group;
-  int i;
-  FRAME_PTR f = XFRAME (FONTSET_FRAME (fontset));
-  int charset_matched = -1;
+  int i, charset_matched = -1;
+  FRAME_PTR f = (FRAMEP (FONTSET_FRAME (fontset)))
+    ? XFRAME (selected_frame) : XFRAME (FONTSET_FRAME (fontset));
 
   font_group = fontset_get_font_group (fontset, fallback ? -1 : c);
   if (! CONSP (font_group))
@@ -876,7 +875,11 @@ face_for_char (f, face, c, pos, object)
   int face_id;
   int id;
 
-  if (ASCII_CHAR_P (c))
+  /* If face->fontset is negative (that happens when no font is found
+     for face), just return face->ascii_face because we can't do
+     anything.  Perhaps, we should fix the callers to assure
+     that face->fontset is always valid.  */
+  if (ASCII_CHAR_P (c) || face->fontset < 0)
     return face->ascii_face->id;
 
   xassert (fontset_id_valid_p (face->fontset));
@@ -891,9 +894,7 @@ face_for_char (f, face, c, pos, object)
   else
     {
       charset = Fget_char_property (make_number (pos), Qcharset, object);
-      if (NILP (charset))
-       id = -1;
-      else if (CHARSETP (charset))
+      if (CHARSETP (charset))
        {
          Lisp_Object val;
 
@@ -902,6 +903,8 @@ face_for_char (f, face, c, pos, object)
            charset = XCDR (val);
          id = XINT (CHARSET_SYMBOL_ID (charset));
        }
+      else
+       id = -1;
     }
 
   font_deferred_log ("font for", Fcons (make_number (c), charset), Qnil);
@@ -963,9 +966,7 @@ font_for_char (face, c, pos, object)
   else
     {
       charset = Fget_char_property (make_number (pos), Qcharset, object);
-      if (NILP (charset))
-       id = -1;
-      else if (CHARSETP (charset))
+      if (CHARSETP (charset))
        {
          Lisp_Object val;
 
@@ -974,6 +975,8 @@ font_for_char (face, c, pos, object)
            charset = XCDR (val);
          id = XINT (CHARSET_SYMBOL_ID (charset));
        }
+      else
+       id = -1;
     }
 
   font_deferred_log ("font for", Fcons (make_number (c), charset), Qnil);
@@ -1853,13 +1856,11 @@ fontset.  The format is the same as above.  */)
     {
       for (c = 0; c <= MAX_CHAR; )
        {
-         int from, to;
+         int from = c, to = MAX_5_BYTE_CHAR;
 
          if (c <= MAX_5_BYTE_CHAR)
            {
              val = char_table_ref_and_range (fontsets[k], c, &from, &to);
-             if (to > MAX_5_BYTE_CHAR)
-               to = MAX_5_BYTE_CHAR;
            }
          else
            {