]> code.delx.au - gnu-emacs/blobdiff - src/fontset.c
Merge from emacs-24
[gnu-emacs] / src / fontset.c
index e34719e5cdf7f627c39b0d25c688196b196d1742..c415fdfa8fde1ec1197124f817d792903fcaac07 100644 (file)
@@ -1079,10 +1079,11 @@ fontset_pattern_regexp (Lisp_Object pattern)
       /* If PATTERN is not full XLFD we convert "*" to ".*".  Otherwise
         we convert "*" to "[^-]*" which is much faster in regular
         expression matching.  */
-      if (ndashes < 14)
-       p1 = regex = alloca (SBYTES (pattern) + 2 * nstars + 2 * nescs + 1);
-      else
-       p1 = regex = alloca (SBYTES (pattern) + 5 * nstars + 2 * nescs + 1);
+      ptrdiff_t regexsize = (SBYTES (pattern)
+                            + (ndashes < 14 ? 2 : 5) * nstars
+                            + 2 * nescs + 1);
+      USE_SAFE_ALLOCA;
+      p1 = regex = SAFE_ALLOCA (regexsize);
 
       *p1++ = '^';
       for (p0 = SDATA (pattern); *p0; p0++)
@@ -1110,6 +1111,7 @@ fontset_pattern_regexp (Lisp_Object pattern)
 
       Vcached_fontset_data = Fcons (build_string (SSDATA (pattern)),
                                    build_string ((char *) regex));
+      SAFE_FREE ();
     }
 
   return CACHED_FONTSET_REGEX;
@@ -1460,8 +1462,8 @@ appended.  By default, FONT-SPEC overrides the previous settings.  */)
       registry = AREF (font_spec, FONT_REGISTRY_INDEX);
       if (! NILP (registry))
        registry = Fdowncase (SYMBOL_NAME (registry));
-      encoding = find_font_encoding (concat3 (family, build_string ("-"),
-                                             registry));
+      AUTO_STRING (dash, "-");
+      encoding = find_font_encoding (concat3 (family, dash, registry));
       if (NILP (encoding))
        encoding = Qascii;
 
@@ -1573,7 +1575,7 @@ appended.  By default, FONT-SPEC overrides the previous settings.  */)
 
   if (ascii_changed)
     {
-      Lisp_Object tail, fr, alist;
+      Lisp_Object tail, fr;
       int fontset_id = XINT (FONTSET_ID (fontset));
 
       set_fontset_ascii (fontset, fontname);
@@ -1596,8 +1598,8 @@ appended.  By default, FONT-SPEC overrides the previous settings.  */)
          if (! NILP (font_object))
            {
              update_auto_fontset_alist (font_object, fontset);
-             alist = list1 (Fcons (Qfont, Fcons (name, font_object)));
-             Fmodify_frame_parameters (fr, alist);
+             AUTO_FRAME_ARG (arg, Qfont, Fcons (name, font_object));
+             Fmodify_frame_parameters (fr, arg);
            }
        }
     }
@@ -1843,6 +1845,10 @@ DEFUN ("internal-char-font", Finternal_char_font, Sinternal_char_font, 1, 2, 0,
     return Qnil;
   if (!FRAME_WINDOW_P (f))
     return Qnil;
+  /* We need the basic faces to be valid below, so recompute them if
+     some code just happened to clear the face cache.  */
+  if (FRAME_FACE_CACHE (f)->used == 0)
+    recompute_basic_faces (f);
   face_id = FACE_FOR_CHAR (f, FACE_FROM_ID (f, face_id), c, pos, Qnil);
   face = FACE_FROM_ID (f, face_id);
   if (face->font)
@@ -1888,7 +1894,9 @@ format is the same as above.  */)
 
   /* Recode fontsets realized on FRAME from the base fontset FONTSET
      in the table `realized'.  */
-  realized[0] = alloca (word_size * ASIZE (Vfontset_table));
+  USE_SAFE_ALLOCA;
+  SAFE_ALLOCA_LISP (realized[0], 2 * ASIZE (Vfontset_table));
+  realized[1] = realized[0] + ASIZE (Vfontset_table);
   for (i = j = 0; i < ASIZE (Vfontset_table); i++)
     {
       elt = FONTSET_FROM_ID (i);
@@ -1899,7 +1907,6 @@ format is the same as above.  */)
     }
   realized[0][j] = Qnil;
 
-  realized[1] = alloca (word_size * ASIZE (Vfontset_table));
   for (i = j = 0; ! NILP (realized[0][i]); i++)
     {
       elt = FONTSET_DEFAULT (realized[0][i]);
@@ -1991,6 +1998,7 @@ format is the same as above.  */)
        break;
     }
 
+  SAFE_FREE ();
   return tables[0];
 }