aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2008-06-17 01:26:47 +0000
committerKenichi Handa2008-06-17 01:26:47 +0000
commit821bc4dbf13da00e16c76cec515f92e33ca3692e (patch)
tree38a7d8b06f9ff850d5cb5a25fdf7425b844b7bf1 /src
parent3554e566e3e24e7983ac8a64cb7301d5ae8e2ea9 (diff)
downloademacs-821bc4dbf13da00e16c76cec515f92e33ca3692e.tar.gz
emacs-821bc4dbf13da00e16c76cec515f92e33ca3692e.zip
(fontset_pattern_regexp): Escape some regexp characters.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/fontset.c20
2 files changed, 18 insertions, 7 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 16e9af14b29..0eebe5ce290 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
12008-06-17 Naohiro Aota <nao.aota@gmail.com> (tiny change)
2
3 * fontset.c (fontset_pattern_regexp): Escape some reg-expr
4 characters.
5
12008-06-16 Juanma Barranquero <lekktu@gmail.com> 62008-06-16 Juanma Barranquero <lekktu@gmail.com>
2 7
3 * dispextern.h (lookup_non_ascii_face, split_font_name_into_vector) 8 * dispextern.h (lookup_non_ascii_face, split_font_name_into_vector)
diff --git a/src/fontset.c b/src/fontset.c
index 9878569e7b7..e81f6e16c76 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, nplus = 0; 1008 int ndashes = 0, nstars = 0, nescs = 0;
1009 1009
1010 for (p0 = SDATA (pattern); *p0; p0++) 1010 for (p0 = SDATA (pattern); *p0; p0++)
1011 { 1011 {
@@ -1013,17 +1013,20 @@ fontset_pattern_regexp (pattern)
1013 ndashes++; 1013 ndashes++;
1014 else if (*p0 == '*') 1014 else if (*p0 == '*')
1015 nstars++; 1015 nstars++;
1016 else if (*p0 == '+') 1016 else if (*p0 == '['
1017 nplus++; 1017 || *p0 == '.' || *p0 == '\\'
1018 || *p0 == '+' || *p0 == '^'
1019 || *p0 == '$')
1020 nescs++;
1018 } 1021 }
1019 1022
1020 /* If PATTERN is not full XLFD we conert "*" to ".*". Otherwise 1023 /* If PATTERN is not full XLFD we conert "*" to ".*". Otherwise
1021 we convert "*" to "[^-]*" which is much faster in regular 1024 we convert "*" to "[^-]*" which is much faster in regular
1022 expression matching. */ 1025 expression matching. */
1023 if (ndashes < 14) 1026 if (ndashes < 14)
1024 p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 2 * nplus + 1); 1027 p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 2 * nescs + 1);
1025 else 1028 else
1026 p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 2 * nplus + 1); 1029 p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 2 * nescs + 1);
1027 1030
1028 *p1++ = '^'; 1031 *p1++ = '^';
1029 for (p0 = SDATA (pattern); *p0; p0++) 1032 for (p0 = SDATA (pattern); *p0; p0++)
@@ -1038,8 +1041,11 @@ fontset_pattern_regexp (pattern)
1038 } 1041 }
1039 else if (*p0 == '?') 1042 else if (*p0 == '?')
1040 *p1++ = '.'; 1043 *p1++ = '.';
1041 else if (*p0 == '+') 1044 else if (*p0 == '['
1042 *p1++ = '\\', *p1++ = '+'; 1045 || *p0 == '.' || *p0 == '\\'
1046 || *p0 == '+' || *p0 == '^'
1047 || *p0 == '$')
1048 *p1++ = '\\', *p1++ = *p0;
1043 else 1049 else
1044 *p1++ = *p0; 1050 *p1++ = *p0;
1045 } 1051 }