changeset 58025:bcd053632eb2

(fontset_pattern_regexp): Cancel my previous change; don't pay attention to '\' before '*'. (fontset_pattern_regexp): Change the meaning of the second arg. (Fnew_fontset): Call fs_query_fontset, not Fquery_fontset. (check_fontset_name): Try NAME as literal at first, and if it failes, try NAME as pattern.
author Kenichi Handa <handa@m17n.org>
date Mon, 08 Nov 2004 00:38:26 +0000
parents df06a7fc82e9
children 07a92f2a7e6e
files src/fontset.c
diffstat 1 files changed, 27 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/fontset.c	Mon Nov 08 00:27:05 2004 +0000
+++ b/src/fontset.c	Mon Nov 08 00:38:26 2004 +0000
@@ -796,7 +796,7 @@
 	{
 	  if (*p0 == '-')
 	    ndashes++;
-	  else if (*p0 == '*' && p0 > SDATA (pattern) && p0[-1] != '\\')
+	  else if (*p0 == '*')
 	    nstars++;
 	}
 
@@ -811,7 +811,7 @@
       *p1++ = '^';
       for (p0 = SDATA (pattern); *p0; p0++)
 	{
-	  if (*p0 == '*' && p0 > SDATA (pattern) && p0[-1] != '\\')
+	  if (*p0 == '*')
 	    {
 	      if (ndashes < 14)
 		*p1++ = '.';
@@ -835,29 +835,33 @@
 }
 
 /* Return ID of the base fontset named NAME.  If there's no such
-   fontset, return -1.  */
+   fontset, return -1.  NAME_PATTERN specifies how to treat NAME as this:
+     0: pattern containing '*' and '?' as wildcards
+     1: regular expression
+     2: literal fontset name
+*/
 
 int
-fs_query_fontset (name, regexpp)
+fs_query_fontset (name, name_pattern)
      Lisp_Object name;
-     int regexpp;
+     int name_pattern;
 {
   Lisp_Object tem;
   int i;
 
   name = Fdowncase (name);
-  if (!regexpp)
+  if (name_pattern != 1)
     {
       tem = Frassoc (name, Vfontset_alias_alist);
       if (CONSP (tem) && STRINGP (XCAR (tem)))
 	name = XCAR (tem);
-      else
+      else if (name_pattern == 0)
 	{
 	  tem = fontset_pattern_regexp (name);
 	  if (STRINGP (tem))
 	    {
 	      name = tem;
-	      regexpp = 1;
+	      name_pattern = 1;
 	    }
 	}
     }
@@ -872,7 +876,7 @@
 	continue;
 
       this_name = FONTSET_NAME (fontset);
-      if (regexpp
+      if (name_pattern == 1
 	  ? fast_string_match (name, this_name) >= 0
 	  : !strcmp (SDATA (name), SDATA (this_name)))
 	return i;
@@ -963,6 +967,7 @@
 {
   Lisp_Object fontset, elements, ascii_font;
   Lisp_Object tem, tail, elt;
+  int id;
 
   (*check_window_system_func) ();
 
@@ -970,10 +975,14 @@
   CHECK_LIST (fontlist);
 
   name = Fdowncase (name);
-  tem = Fquery_fontset (name, Qnil);
-  if (!NILP (tem))
-    error ("Fontset `%s' matches the existing fontset `%s'",
-	   SDATA (name), SDATA (tem));
+  id = fs_query_fontset (name, 2);
+  if (id >= 0)
+    {
+      fontset = FONTSET_FROM_ID (id);
+      tem = FONTSET_NAME (fontset);
+      error ("Fontset `%s' matches the existing fontset `%s'",
+	     SDATA (name),  SDATA (tem));
+    }
 
   /* Check the validity of FONTLIST while creating a template for
      fontset elements.  */
@@ -1048,7 +1057,11 @@
     return Vdefault_fontset;
 
   CHECK_STRING (name);
-  id = fs_query_fontset (name, 0);
+  /* First try NAME as literal.  */
+  id = fs_query_fontset (name, 2);
+  if (id < 0)
+    /* For backward compatibility, try again NAME as pattern.  */
+    id = fs_query_fontset (name, 0);
   if (id < 0)
     error ("Fontset `%s' does not exist", SDATA (name));
   return FONTSET_FROM_ID (id);