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 == '?') |