[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Fix paternize problem of fontset_pattern_regexp()
From: |
Naohiro Aota |
Subject: |
[PATCH] Fix paternize problem of fontset_pattern_regexp() |
Date: |
Sun, 15 Jun 2008 06:10:07 +0900 |
User-agent: |
Gnus/5.110011 (No Gnus v0.11) Emacs/23.0.60 (gnu/linux) |
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 <address@hidden>
* 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;
}
- [PATCH] Fix paternize problem of fontset_pattern_regexp(),
Naohiro Aota <=