all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] Fix paternize problem of fontset_pattern_regexp()
@ 2008-06-14 21:10 Naohiro Aota
  2008-06-15 12:44 ` Kenichi Handa
  0 siblings, 1 reply; 2+ messages in thread
From: Naohiro Aota @ 2008-06-14 21:10 UTC (permalink / raw)
  To: emacs-devel

Hi,

I found that fontset_pattern_regexp() doesn't escape '+'. Because of
this bug, specifying a font whose name contains '+' [1] causes Emacs to
die.

This patch below would fix the problem.

Regards,
Naohiro Aota

[1] For example, try evaluating `(set-default-font "M+ 1c")' [2].

[2] You can get this font from
    http://mplus-fonts.sourceforge.jp/mplus-outline-fonts/index.html
    (Japanese page)

2008-06-15  Naohiro Aota  <nao.aota@gmail.com>

	* fontset.c (fontset_pattern_regexp): Escape `+' characters in pattern.

Index: src/fontset.c
===================================================================
RCS file: /sources/emacs/emacs/src/fontset.c,v
retrieving revision 1.132
diff -u -r1.132 fontset.c
--- src/fontset.c	8 Jun 2008 09:01:28 -0000	1.132
+++ src/fontset.c	14 Jun 2008 19:54:58 -0000
@@ -1005,7 +1005,7 @@
     {
       /* We must at first update the cached data.  */
       unsigned char *regex, *p0, *p1;
-      int ndashes = 0, nstars = 0;
+      int ndashes = 0, nstars = 0, nplus = 0;
 
       for (p0 = SDATA (pattern); *p0; p0++)
 	{
@@ -1013,15 +1013,17 @@
 	    ndashes++;
 	  else if (*p0 == '*')
 	    nstars++;
+	  else if (*p0 == '+')
+	    nplus++;
 	}
 
       /* If PATTERN is not full XLFD we conert "*" to ".*".  Otherwise
 	 we convert "*" to "[^-]*" which is much faster in regular
 	 expression matching.  */
       if (ndashes < 14)
-	p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 1);
+	p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 2 * nplus + 1);
       else
-	p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 1);
+	p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 2 * nplus + 1);
 
       *p1++ = '^';
       for (p0 = SDATA (pattern); *p0; p0++)
@@ -1036,6 +1038,8 @@
 	    }
 	  else if (*p0 == '?')
 	    *p1++ = '.';
+	  else if (*p0 == '+')
+	    *p1++ = '\\', *p1++ = '+';
 	  else
 	    *p1++ = *p0;
 	}




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix paternize problem of fontset_pattern_regexp()
  2008-06-14 21:10 [PATCH] Fix paternize problem of fontset_pattern_regexp() Naohiro Aota
@ 2008-06-15 12:44 ` Kenichi Handa
  0 siblings, 0 replies; 2+ messages in thread
From: Kenichi Handa @ 2008-06-15 12:44 UTC (permalink / raw)
  To: Naohiro Aota; +Cc: emacs-devel

In article <878wx7yb80.fsf@gmail.com>, Naohiro Aota <nao.aota@gmail.com> writes:

> I found that fontset_pattern_regexp() doesn't escape '+'. Because of
> this bug, specifying a font whose name contains '+' [1] causes Emacs to
> die.

Thank you for finding this bug.

> This patch below would fix the problem.

Ok, I've just installed it.

---
Kenichi Handa
handa@ni.aist.go.jp




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-15 12:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-14 21:10 [PATCH] Fix paternize problem of fontset_pattern_regexp() Naohiro Aota
2008-06-15 12:44 ` Kenichi Handa

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.