changeset 95961:27b852856cdf

(fontset_pattern_regexp): Escape `+' characters in pattern.
author Kenichi Handa <handa@m17n.org>
date Sun, 15 Jun 2008 12:23:27 +0000
parents f104cdfcb450
children 59534766a799
files src/fontset.c
diffstat 1 files changed, 7 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/fontset.c	Sun Jun 15 10:57:06 2008 +0000
+++ b/src/fontset.c	Sun Jun 15 12:23:27 2008 +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;
 	}