/[emacs]/emacs/src/fontset.c
ViewVC logotype

Diff of /emacs/src/fontset.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.88 by handa, Mon Oct 18 12:27:46 2004 UTC revision 1.89 by handa, Mon Oct 25 02:03:32 2004 UTC
# Line 789  fontset_pattern_regexp (pattern) Line 789  fontset_pattern_regexp (pattern)
789        || strcmp (SDATA (pattern), CACHED_FONTSET_NAME))        || strcmp (SDATA (pattern), CACHED_FONTSET_NAME))
790      {      {
791        /* We must at first update the cached data.  */        /* We must at first update the cached data.  */
792        char *regex = (char *) alloca (SCHARS (pattern) * 2 + 3);        char *regex, *p0, *p1;
793        char *p0, *p1 = regex;        int ndashes = 0, nstars = 0;
794          
795          for (p0 = SDATA (pattern); *p0; p0++)
796            {
797              if (*p0 == '-')
798                ndashes++;
799              else if (*p0 == '*')
800                nstars++;
801            }
802    
803          /* If PATTERN is not full XLFD we conert "*" to ".*".  Otherwise
804             we convert "*" to "[^-]*" which is much faster in regular
805             expression matching.  */
806          if (ndashes < 14)
807            p1 = regex = (char *) alloca (SBYTES (pattern) + 2 * nstars + 1);
808          else
809            p1 = regex = (char *) alloca (SBYTES (pattern) + 5 * nstars + 1);
810    
       /* Convert "*" to ".*", "?" to ".".  */  
811        *p1++ = '^';        *p1++ = '^';
812        for (p0 = (char *) SDATA (pattern); *p0; p0++)        for (p0 = (char *) SDATA (pattern); *p0; p0++)
813          {          {
814            if (*p0 == '*')            if (*p0 == '*')
815              {              {
816                *p1++ = '.';                if (ndashes < 14)
817                    *p1++ = '.';
818                  else
819                    *p1++ = '[', *p1++ = '^', *p1++ = '-', *p1++ = ']';
820                *p1++ = '*';                *p1++ = '*';
821              }              }
822            else if (*p0 == '?')            else if (*p0 == '?')

Legend:
Removed from v.1.88  
changed lines
  Added in v.1.89

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26