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, *p0, *p1; |
unsigned char *regex, *p0, *p1; |
793 |
int ndashes = 0, nstars = 0; |
int ndashes = 0, nstars = 0; |
794 |
|
|
795 |
for (p0 = SDATA (pattern); *p0; p0++) |
for (p0 = SDATA (pattern); *p0; p0++) |
796 |
{ |
{ |
797 |
if (*p0 == '-') |
if (*p0 == '-') |
798 |
ndashes++; |
ndashes++; |
799 |
else if (*p0 == '*' && p0 > SDATA (pattern) && p0[-1] != '\\') |
else if (*p0 == '*') |
800 |
nstars++; |
nstars++; |
801 |
} |
} |
802 |
|
|
804 |
we convert "*" to "[^-]*" which is much faster in regular |
we convert "*" to "[^-]*" which is much faster in regular |
805 |
expression matching. */ |
expression matching. */ |
806 |
if (ndashes < 14) |
if (ndashes < 14) |
807 |
p1 = regex = (char *) alloca (SBYTES (pattern) + 2 * nstars + 1); |
p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 2 * nstars + 1); |
808 |
else |
else |
809 |
p1 = regex = (char *) alloca (SBYTES (pattern) + 5 * nstars + 1); |
p1 = regex = (unsigned char *) alloca (SBYTES (pattern) + 5 * nstars + 1); |
810 |
|
|
811 |
*p1++ = '^'; |
*p1++ = '^'; |
812 |
for (p0 = (char *) SDATA (pattern); *p0; p0++) |
for (p0 = SDATA (pattern); *p0; p0++) |
813 |
{ |
{ |
814 |
if (*p0 == '*' && p0 > SDATA (pattern) && p0[-1] != '\\') |
if (*p0 == '*') |
815 |
{ |
{ |
816 |
if (ndashes < 14) |
if (ndashes < 14) |
817 |
*p1++ = '.'; |
*p1++ = '.'; |
835 |
} |
} |
836 |
|
|
837 |
/* 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 |
838 |
fontset, return -1. */ |
fontset, return -1. NAME_PATTERN specifies how to treat NAME as this: |
839 |
|
0: pattern containing '*' and '?' as wildcards |
840 |
|
1: regular expression |
841 |
|
2: literal fontset name |
842 |
|
*/ |
843 |
|
|
844 |
int |
int |
845 |
fs_query_fontset (name, regexpp) |
fs_query_fontset (name, name_pattern) |
846 |
Lisp_Object name; |
Lisp_Object name; |
847 |
int regexpp; |
int name_pattern; |
848 |
{ |
{ |
849 |
Lisp_Object tem; |
Lisp_Object tem; |
850 |
int i; |
int i; |
851 |
|
|
852 |
name = Fdowncase (name); |
name = Fdowncase (name); |
853 |
if (!regexpp) |
if (name_pattern != 1) |
854 |
{ |
{ |
855 |
tem = Frassoc (name, Vfontset_alias_alist); |
tem = Frassoc (name, Vfontset_alias_alist); |
856 |
if (CONSP (tem) && STRINGP (XCAR (tem))) |
if (CONSP (tem) && STRINGP (XCAR (tem))) |
857 |
name = XCAR (tem); |
name = XCAR (tem); |
858 |
else |
else if (name_pattern == 0) |
859 |
{ |
{ |
860 |
tem = fontset_pattern_regexp (name); |
tem = fontset_pattern_regexp (name); |
861 |
if (STRINGP (tem)) |
if (STRINGP (tem)) |
862 |
{ |
{ |
863 |
name = tem; |
name = tem; |
864 |
regexpp = 1; |
name_pattern = 1; |
865 |
} |
} |
866 |
} |
} |
867 |
} |
} |
876 |
continue; |
continue; |
877 |
|
|
878 |
this_name = FONTSET_NAME (fontset); |
this_name = FONTSET_NAME (fontset); |
879 |
if (regexpp |
if (name_pattern == 1 |
880 |
? fast_string_match (name, this_name) >= 0 |
? fast_string_match (name, this_name) >= 0 |
881 |
: !strcmp (SDATA (name), SDATA (this_name))) |
: !strcmp (SDATA (name), SDATA (this_name))) |
882 |
return i; |
return i; |
967 |
{ |
{ |
968 |
Lisp_Object fontset, elements, ascii_font; |
Lisp_Object fontset, elements, ascii_font; |
969 |
Lisp_Object tem, tail, elt; |
Lisp_Object tem, tail, elt; |
970 |
|
int id; |
971 |
|
|
972 |
(*check_window_system_func) (); |
(*check_window_system_func) (); |
973 |
|
|
975 |
CHECK_LIST (fontlist); |
CHECK_LIST (fontlist); |
976 |
|
|
977 |
name = Fdowncase (name); |
name = Fdowncase (name); |
978 |
tem = Fquery_fontset (name, Qnil); |
id = fs_query_fontset (name, 2); |
979 |
if (!NILP (tem)) |
if (id >= 0) |
980 |
error ("Fontset `%s' matches the existing fontset `%s'", |
{ |
981 |
SDATA (name), SDATA (tem)); |
fontset = FONTSET_FROM_ID (id); |
982 |
|
tem = FONTSET_NAME (fontset); |
983 |
|
error ("Fontset `%s' matches the existing fontset `%s'", |
984 |
|
SDATA (name), SDATA (tem)); |
985 |
|
} |
986 |
|
|
987 |
/* Check the validity of FONTLIST while creating a template for |
/* Check the validity of FONTLIST while creating a template for |
988 |
fontset elements. */ |
fontset elements. */ |
1057 |
return Vdefault_fontset; |
return Vdefault_fontset; |
1058 |
|
|
1059 |
CHECK_STRING (name); |
CHECK_STRING (name); |
1060 |
id = fs_query_fontset (name, 0); |
/* First try NAME as literal. */ |
1061 |
|
id = fs_query_fontset (name, 2); |
1062 |
|
if (id < 0) |
1063 |
|
/* For backward compatibility, try again NAME as pattern. */ |
1064 |
|
id = fs_query_fontset (name, 0); |
1065 |
if (id < 0) |
if (id < 0) |
1066 |
error ("Fontset `%s' does not exist", SDATA (name)); |
error ("Fontset `%s' does not exist", SDATA (name)); |
1067 |
return FONTSET_FROM_ID (id); |
return FONTSET_FROM_ID (id); |