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, *p0, *p1; |
unsigned char *regex, *p0, *p1; |
1073 |
int ndashes = 0, nstars = 0; |
int ndashes = 0, nstars = 0; |
1074 |
|
|
1075 |
for (p0 = SDATA (pattern); *p0; p0++) |
for (p0 = SDATA (pattern); *p0; p0++) |
1076 |
{ |
{ |
1077 |
if (*p0 == '-') |
if (*p0 == '-') |
1078 |
ndashes++; |
ndashes++; |
1079 |
else if (*p0 == '*' && p0 > SDATA (pattern) && p0[-1] != '\\') |
else if (*p0 == '*') |
1080 |
nstars++; |
nstars++; |
1081 |
} |
} |
1082 |
|
|
1084 |
we convert "*" to "[^-]*" which is much faster in regular |
we convert "*" to "[^-]*" which is much faster in regular |
1085 |
expression matching. */ |
expression matching. */ |
1086 |
if (ndashes < 14) |
if (ndashes < 14) |
1087 |
p1 = regex = (char *) alloca (SBYTES (pattern) + 2 * nstars + 1); |
p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 1); |
1088 |
else |
else |
1089 |
p1 = regex = (char *) alloca (SBYTES (pattern) + 5 * nstars + 1); |
p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 1); |
1090 |
|
|
1091 |
*p1++ = '^'; |
*p1++ = '^'; |
1092 |
for (p0 = (char *) SDATA (pattern); *p0; p0++) |
for (p0 = SDATA (pattern); *p0; p0++) |
1093 |
{ |
{ |
1094 |
if (*p0 == '*' && p0 > SDATA (pattern) && p0[-1] != '\\') |
if (*p0 == '*') |
1095 |
{ |
{ |
1096 |
if (ndashes < 14) |
if (ndashes < 14) |
1097 |
*p1++ = '.'; |
*p1++ = '.'; |
1115 |
} |
} |
1116 |
|
|
1117 |
/* Return ID of the base fontset named NAME. If there's no such |
/* Return ID of the base fontset named NAME. If there's no such |
1118 |
fontset, return -1. */ |
fontset, return -1. NAME_PATTERN specifies how to treat NAME as this: |
1119 |
|
0: pattern containing '*' and '?' as wildcards |
1120 |
|
1: regular expression |
1121 |
|
2: literal fontset name |
1122 |
|
*/ |
1123 |
|
|
1124 |
int |
int |
1125 |
fs_query_fontset (name, regexpp) |
fs_query_fontset (name, name_pattern) |
1126 |
Lisp_Object name; |
Lisp_Object name; |
1127 |
int regexpp; |
int name_pattern; |
1128 |
{ |
{ |
1129 |
Lisp_Object tem; |
Lisp_Object tem; |
1130 |
int i; |
int i; |
1131 |
|
|
1132 |
name = Fdowncase (name); |
name = Fdowncase (name); |
1133 |
if (!regexpp) |
if (name_pattern != 1) |
1134 |
{ |
{ |
1135 |
tem = Frassoc (name, Vfontset_alias_alist); |
tem = Frassoc (name, Vfontset_alias_alist); |
1136 |
if (NILP (tem)) |
if (NILP (tem)) |
1137 |
tem = Fassoc (name, Vfontset_alias_alist); |
tem = Fassoc (name, Vfontset_alias_alist); |
1138 |
if (CONSP (tem) && STRINGP (XCAR (tem))) |
if (CONSP (tem) && STRINGP (XCAR (tem))) |
1139 |
name = XCAR (tem); |
name = XCAR (tem); |
1140 |
else |
else if (name_pattern == 0) |
1141 |
{ |
{ |
1142 |
tem = fontset_pattern_regexp (name); |
tem = fontset_pattern_regexp (name); |
1143 |
if (STRINGP (tem)) |
if (STRINGP (tem)) |
1144 |
{ |
{ |
1145 |
name = tem; |
name = tem; |
1146 |
regexpp = 1; |
name_pattern = 1; |
1147 |
} |
} |
1148 |
} |
} |
1149 |
} |
} |
1158 |
continue; |
continue; |
1159 |
|
|
1160 |
this_name = FONTSET_NAME (fontset); |
this_name = FONTSET_NAME (fontset); |
1161 |
if (regexpp |
if (name_pattern == 1 |
1162 |
? fast_string_match (name, this_name) >= 0 |
? fast_string_match (name, this_name) >= 0 |
1163 |
: !strcmp (SDATA (name), SDATA (this_name))) |
: !strcmp (SDATA (name), SDATA (this_name))) |
1164 |
return i; |
return i; |
1288 |
return Vdefault_fontset; |
return Vdefault_fontset; |
1289 |
|
|
1290 |
CHECK_STRING (name); |
CHECK_STRING (name); |
1291 |
id = fs_query_fontset (name, 0); |
/* First try NAME as literal. */ |
1292 |
|
id = fs_query_fontset (name, 2); |
1293 |
|
if (id < 0) |
1294 |
|
/* For backward compatibility, try again NAME as pattern. */ |
1295 |
|
id = fs_query_fontset (name, 0); |
1296 |
if (id < 0) |
if (id < 0) |
1297 |
error ("Fontset `%s' does not exist", SDATA (name)); |
error ("Fontset `%s' does not exist", SDATA (name)); |
1298 |
return FONTSET_FROM_ID (id); |
return FONTSET_FROM_ID (id); |