aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2008-06-15 12:26:28 +0000
committerKenichi Handa2008-06-15 12:26:28 +0000
commit9f2960826522ec553f16ad1f8aa64a041b2f0ac7 (patch)
treef6972964c46e5bb86d92c51835a3211228c28882 /src
parent574ec5652404df58cbe0f841062728ea1ba39ae6 (diff)
downloademacs-9f2960826522ec553f16ad1f8aa64a041b2f0ac7.tar.gz
emacs-9f2960826522ec553f16ad1f8aa64a041b2f0ac7.zip
(fontset_pattern_regexp): Escape `+' characters in pattern.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/fontset.c10
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 @@
12008-06-15 Naohiro Aota <nao.aota@gmail.com> (tiny change)
2
3 * fontset.c (fontset_pattern_regexp): Escape `+' characters in
4 pattern.
5
12008-06-15 Andreas Schwab <schwab@suse.de> 62008-06-15 Andreas Schwab <schwab@suse.de>
2 7
3 * font.c (font_update_drivers): Fix crash when no drivers match. 8 * 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)
1005 { 1005 {
1006 /* We must at first update the cached data. */ 1006 /* We must at first update the cached data. */
1007 unsigned char *regex, *p0, *p1; 1007 unsigned char *regex, *p0, *p1;
1008 int ndashes = 0, nstars = 0; 1008 int ndashes = 0, nstars = 0, nplus = 0;
1009 1009
1010 for (p0 = SDATA (pattern); *p0; p0++) 1010 for (p0 = SDATA (pattern); *p0; p0++)
1011 { 1011 {
@@ -1013,15 +1013,17 @@ fontset_pattern_regexp (pattern)
1013 ndashes++; 1013 ndashes++;
1014 else if (*p0 == '*') 1014 else if (*p0 == '*')
1015 nstars++; 1015 nstars++;
1016 else if (*p0 == '+')
1017 nplus++;
1016 } 1018 }
1017 1019
1018 /* If PATTERN is not full XLFD we conert "*" to ".*". Otherwise 1020 /* If PATTERN is not full XLFD we conert "*" to ".*". Otherwise
1019 we convert "*" to "[^-]*" which is much faster in regular 1021 we convert "*" to "[^-]*" which is much faster in regular
1020 expression matching. */ 1022 expression matching. */
1021 if (ndashes < 14) 1023 if (ndashes < 14)
1022 p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 1); 1024 p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 2 * nplus + 1);
1023 else 1025 else
1024 p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 1); 1026 p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 2 * nplus + 1);
1025 1027
1026 *p1++ = '^'; 1028 *p1++ = '^';
1027 for (p0 = SDATA (pattern); *p0; p0++) 1029 for (p0 = SDATA (pattern); *p0; p0++)
@@ -1036,6 +1038,8 @@ fontset_pattern_regexp (pattern)
1036 } 1038 }
1037 else if (*p0 == '?') 1039 else if (*p0 == '?')
1038 *p1++ = '.'; 1040 *p1++ = '.';
1041 else if (*p0 == '+')
1042 *p1++ = '\\', *p1++ = '+';
1039 else 1043 else
1040 *p1++ = *p0; 1044 *p1++ = *p0;
1041 } 1045 }