mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-08 20:50:52 -08:00
(fontset_pattern_regexp): Escape some regexp characters.
This commit is contained in:
parent
3554e566e3
commit
821bc4dbf1
2 changed files with 18 additions and 7 deletions
|
|
@ -1,3 +1,8 @@
|
|||
2008-06-17 Naohiro Aota <nao.aota@gmail.com> (tiny change)
|
||||
|
||||
* fontset.c (fontset_pattern_regexp): Escape some reg-expr
|
||||
characters.
|
||||
|
||||
2008-06-16 Juanma Barranquero <lekktu@gmail.com>
|
||||
|
||||
* dispextern.h (lookup_non_ascii_face, split_font_name_into_vector)
|
||||
|
|
|
|||
|
|
@ -1005,7 +1005,7 @@ fontset_pattern_regexp (pattern)
|
|||
{
|
||||
/* We must at first update the cached data. */
|
||||
unsigned char *regex, *p0, *p1;
|
||||
int ndashes = 0, nstars = 0, nplus = 0;
|
||||
int ndashes = 0, nstars = 0, nescs = 0;
|
||||
|
||||
for (p0 = SDATA (pattern); *p0; p0++)
|
||||
{
|
||||
|
|
@ -1013,17 +1013,20 @@ fontset_pattern_regexp (pattern)
|
|||
ndashes++;
|
||||
else if (*p0 == '*')
|
||||
nstars++;
|
||||
else if (*p0 == '+')
|
||||
nplus++;
|
||||
else if (*p0 == '['
|
||||
|| *p0 == '.' || *p0 == '\\'
|
||||
|| *p0 == '+' || *p0 == '^'
|
||||
|| *p0 == '$')
|
||||
nescs++;
|
||||
}
|
||||
|
||||
/* 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 + 2 * nplus + 1);
|
||||
p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 2 * nescs + 1);
|
||||
else
|
||||
p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 2 * nplus + 1);
|
||||
p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 2 * nescs + 1);
|
||||
|
||||
*p1++ = '^';
|
||||
for (p0 = SDATA (pattern); *p0; p0++)
|
||||
|
|
@ -1038,8 +1041,11 @@ fontset_pattern_regexp (pattern)
|
|||
}
|
||||
else if (*p0 == '?')
|
||||
*p1++ = '.';
|
||||
else if (*p0 == '+')
|
||||
*p1++ = '\\', *p1++ = '+';
|
||||
else if (*p0 == '['
|
||||
|| *p0 == '.' || *p0 == '\\'
|
||||
|| *p0 == '+' || *p0 == '^'
|
||||
|| *p0 == '$')
|
||||
*p1++ = '\\', *p1++ = *p0;
|
||||
else
|
||||
*p1++ = *p0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue