Unbreak the umlauts

Michael Sperber <[email protected]> Sat, 25 Oct 2014 16:02:19 +0200
Newsgroups gmane.emacs.xemacs.patches
Message-ID <[email protected]>
This patch ...

2014-10-18  Stephen J. Turnbull  <[email protected]>

	* fontcolor-xlike-inc.c (xft_find_charset_font):
	* fontcolor-x.c (x_font_instance_truename):

	* font-mgr.c (Ffc_name_unparse):
	Protect Ffc_name_unparse from FcNameUnparse crash on charset property.

... caused some breakage for me.  In particular, the test whether a
particular font implements a charset would always fail.  The reason is
that fc patterns passed as arguments are modified in place.  This patch
fixes that.

I'll push on Monday if nobody objects.

2014-10-25  Michael Sperber  <[email protected]>

	* fontcolor-x.c (x_font_instance_truename): 
	* font-mgr.c (Ffc_name_unparse): 
	* font-mgr.h (PRINT_XFT_PATTERN): Don't modify
	fontconfig pattern passed in in place.

-- 
Regards,
Mike

diff --git a/src/font-mgr.c b/src/font-mgr.c
--- a/src/font-mgr.c
+++ b/src/font-mgr.c
@@ -266,9 +266,12 @@
 
   CHECK_FC_PATTERN (pattern);
   /* #### Could use multiple values here to extract and return charset? */
-  FcPatternDel (XFC_PATTERN_PTR (pattern), FC_CHARSET);
-
-  name = FcNameUnparse (XFC_PATTERN_PTR (pattern));
+  {
+    FcPattern* temp = FcPatternDuplicate (XFC_PATTERN_PTR (pattern));
+    FcPatternDel (temp, FC_CHARSET);
+    name = FcNameUnparse (XFC_PATTERN_PTR (pattern));
+    FcPatternDestroy (temp);
+  }
   result = build_fcapi_string (name);
   xfree (name);
   return result;
diff --git a/src/font-mgr.h b/src/font-mgr.h
--- a/src/font-mgr.h
+++ b/src/font-mgr.h
@@ -145,8 +145,10 @@
   do {								\
     DECLARE_EISTRING (eistrpxft_name);				\
     Extbyte *name;						\
-    FcPatternDel(pattern, FC_CHARSET);				\
-    name = (Extbyte *) FcNameUnparse (pattern);			\
+    FcPattern* temp = FcPatternDuplicate (pattern);		\
+    FcPatternDel (temp, FC_CHARSET);				\
+    name = (Extbyte *) FcNameUnparse (temp);			\
+    FcPatternDestroy (temp);					\
     eicpy_ext(eistrpxft_name,					\
               name ? name : "FONT WITH NULL NAME",		\
               Qfc_font_name_encoding);				\
diff --git a/src/fontcolor-x.c b/src/fontcolor-x.c
--- a/src/fontcolor-x.c
+++ b/src/fontcolor-x.c
@@ -763,8 +763,12 @@
 			      "Xft font present but lacks pattern",
 			      wrap_font_instance(f), Qfont, errb);
 	}
-      FcPatternDel (pattern, FC_CHARSET);  /* FcNameUnparse may choke */
-      res = FcNameUnparse (pattern);
+      {
+	FcPattern* temp = FcPatternDuplicate (pattern);
+	FcPatternDel (temp, FC_CHARSET);  /* FcNameUnparse may choke */
+	res = FcNameUnparse (temp);
+	FcPatternDestroy (temp);
+      }
       if (res)
 	{
 	  FONT_INSTANCE_TRUENAME (f) =

_______________________________________________
XEmacs-Patches mailing list
[email protected]
http://lists.xemacs.org/mailman/listinfo/xemacs-patches