]> git.eshelyaron.com Git - emacs.git/commitdiff
font.c (font_unparse_xlfd): Exclude special characters from the generating XLFD name.
authorKenichi Handa <handa@gnu.org>
Tue, 13 Nov 2012 12:06:44 +0000 (21:06 +0900)
committerKenichi Handa <handa@gnu.org>
Tue, 13 Nov 2012 12:06:44 +0000 (21:06 +0900)
src/ChangeLog
src/font.c

index 1daeb7bc0b6c1b1f8d8ccaafa4535fbb8d1f7036..efe5e59cb73d47540d5a6934b244888f5743185d 100644 (file)
@@ -1,3 +1,8 @@
+2012-11-13  Kenichi Handa  <handa@gnu.org>
+
+       * font.c (font_unparse_xlfd): Exclude special characters from the
+       generating XLFD name.
+
 2012-11-06  Dmitry Antipov  <dmantipov@yandex.ru>
 
        * window.c (quad): New function.
index e960f9b3d134458b6a4b6ccd9094d8b8fd1bd37c..1ec5929506e576e1d956333ec34d8d2e02930aa2 100644 (file)
@@ -1185,7 +1185,7 @@ ptrdiff_t
 font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes)
 {
   char *p;
-  const char *f[XLFD_REGISTRY_INDEX + 1];
+  char *f[XLFD_REGISTRY_INDEX + 1];
   Lisp_Object val;
   int i, j, len;
 
@@ -1234,8 +1234,21 @@ font_unparse_xlfd (Lisp_Object font, int pixel_size, char *name, int nbytes)
        f[j] = "*";
       else
        {
+         int c, k, l;
+         ptrdiff_t alloc;
+
          val = SYMBOL_NAME (val);
-         f[j] = SSDATA (val);
+         alloc = SBYTES (val) + 1;
+         if (nbytes <= alloc)
+           return -1;
+         f[j] = alloca (alloc);
+         /* Copy the name while excluding '-', '?', ',', and '"'.  */
+         for (k = l = 0; k < alloc; k++)
+           {
+             c = SREF (val, k);
+             if (c != '-' && c != '?' && c != ',' && c != '"')
+               f[j][l++] = c;
+           }
        }
     }