1069 |
|| strcmp (SDATA (pattern), CACHED_FONTSET_NAME)) |
|| strcmp (SDATA (pattern), CACHED_FONTSET_NAME)) |
1070 |
{ |
{ |
1071 |
/* We must at first update the cached data. */ |
/* We must at first update the cached data. */ |
1072 |
char *regex = (char *) alloca (SCHARS (pattern) * 2 + 3); |
char *regex, *p0, *p1; |
1073 |
char *p0, *p1 = regex; |
int ndashes = 0, nstars = 0; |
1074 |
|
|
1075 |
|
for (p0 = SDATA (pattern); *p0; p0++) |
1076 |
|
{ |
1077 |
|
if (*p0 == '-') |
1078 |
|
ndashes++; |
1079 |
|
else if (*p0 == '*') |
1080 |
|
nstars++; |
1081 |
|
} |
1082 |
|
|
1083 |
|
/* If PATTERN is not full XLFD we conert "*" to ".*". Otherwise |
1084 |
|
we convert "*" to "[^-]*" which is much faster in regular |
1085 |
|
expression matching. */ |
1086 |
|
if (ndashes < 14) |
1087 |
|
p1 = regex = (char *) alloca (SBYTES (pattern) + 2 * nstars + 1); |
1088 |
|
else |
1089 |
|
p1 = regex = (char *) alloca (SBYTES (pattern) + 5 * nstars + 1); |
1090 |
|
|
|
/* Convert "*" to ".*", "?" to ".". */ |
|
1091 |
*p1++ = '^'; |
*p1++ = '^'; |
1092 |
for (p0 = (char *) SDATA (pattern); *p0; p0++) |
for (p0 = (char *) SDATA (pattern); *p0; p0++) |
1093 |
{ |
{ |
1094 |
if (*p0 == '*') |
if (*p0 == '*') |
1095 |
{ |
{ |
1096 |
*p1++ = '.'; |
if (ndashes < 14) |
1097 |
|
*p1++ = '.'; |
1098 |
|
else |
1099 |
|
*p1++ = '[', *p1++ = '^', *p1++ = '-', *p1++ = ']'; |
1100 |
*p1++ = '*'; |
*p1++ = '*'; |
1101 |
} |
} |
1102 |
else if (*p0 == '?') |
else if (*p0 == '?') |