From 9f2960826522ec553f16ad1f8aa64a041b2f0ac7 Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Sun, 15 Jun 2008 12:26:28 +0000 Subject: [PATCH] (fontset_pattern_regexp): Escape `+' characters in pattern. --- src/ChangeLog | 5 +++++ src/fontset.c | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index f3a7ec0468e..cdc44390434 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2008-06-15 Naohiro Aota (tiny change) + + * fontset.c (fontset_pattern_regexp): Escape `+' characters in + pattern. + 2008-06-15 Andreas Schwab * font.c (font_update_drivers): Fix crash when no drivers match. diff --git a/src/fontset.c b/src/fontset.c index a488e9c4a1d..9878569e7b7 100644 --- a/src/fontset.c +++ b/src/fontset.c @@ -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; + int ndashes = 0, nstars = 0, nplus = 0; for (p0 = SDATA (pattern); *p0; p0++) { @@ -1013,15 +1013,17 @@ fontset_pattern_regexp (pattern) 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 @@ fontset_pattern_regexp (pattern) } else if (*p0 == '?') *p1++ = '.'; + else if (*p0 == '+') + *p1++ = '\\', *p1++ = '+'; else *p1++ = *p0; } -- 2.39.2