Sync up with r21-4-14-chise-0_21-25-si-same. r21-4-14-u2km-0_21-25-si-same
authortomo <tomo>
Thu, 3 Jun 2004 10:19:38 +0000 (10:19 +0000)
committertomo <tomo>
Thu, 3 Jun 2004 10:19:38 +0000 (10:19 +0000)
src/ChangeLog
src/chartab.c
src/text-coding.c

index f18a788..369ee79 100644 (file)
@@ -1,3 +1,24 @@
+2004-03-24  MORIOKA Tomohiko  <tomo@kanji.zinbun.kyoto-u.ac.jp>
+
+       * chartab.c (find_char_feature_in_family): New function.
+       (Fchar_feature): Use `find_char_feature_in_family' with
+       `->identical', `<-subsumptive' and `<-denotational'.
+
+2004-03-14  MORIOKA Tomohiko  <tomo@kanji.zinbun.kyoto-u.ac.jp>
+
+       * text-coding.c (char_encode_as_entity_reference): Allow prefix
+       within 8 characters; fix infinite loop.
+
+2004-03-10  MORIOKA Tomohiko  <tomo@kanji.zinbun.kyoto-u.ac.jp>
+
+       * chartab.c (Q_same): New variable.
+       (Q_same_of): New variable.
+       (Fput_char_attribute): Convert char-refs in value of `{->|<-}same'
+       to characters and put reverse links.
+       (Fsave_char_attribute_table): Use `Fchar_refs_simplify_char_specs'
+       for `{->|<-}same'.
+       (syms_of_chartab): Add new symbols `{->|<-}same'.
+
 2004-03-07  MORIOKA Tomohiko  <tomo@kanji.zinbun.kyoto-u.ac.jp>
 
        * chartab.c (Q_component): New variable.
index 82b3f21..1ce7474 100644 (file)
@@ -1144,6 +1144,8 @@ Lisp_Object Q_subsumptive;
 Lisp_Object Q_subsumptive_from;
 Lisp_Object Q_component;
 Lisp_Object Q_component_of;
+Lisp_Object Q_same;
+Lisp_Object Q_same_of;
 Lisp_Object Qto_ucs;
 Lisp_Object Q_ucs_unified;
 Lisp_Object Qcompat;
@@ -3279,6 +3281,41 @@ Return DEFAULT-VALUE if the value is not exist.
   return default_value;
 }
 
+static Lisp_Object
+find_char_feature_in_family (Lisp_Object character,
+                            Lisp_Object con_feature,
+                            Lisp_Object feature,
+                            Lisp_Object feature_rel_max)
+{
+  Lisp_Object ancestors
+    = Fget_char_attribute (character, con_feature, Qnil);
+
+  while (!NILP (ancestors))
+    {
+      Lisp_Object ancestor = XCAR (ancestors);
+      Lisp_Object ret;
+
+      if (EQ (ancestor, character))
+       return Qunbound;
+
+      ret = Fchar_feature (ancestor, feature, Qunbound,
+                          Qnil, make_int (0));
+      if (!UNBOUNDP (ret))
+       return ret;
+
+      ancestors = XCDR (ancestors);
+
+      ret = Fget_char_attribute (ancestor, Q_subsumptive_from, Qnil);
+      if (!NILP (ret))
+       ancestors = nconc2 (Fcopy_sequence (ancestors), ret);
+
+      ret = Fget_char_attribute (ancestor, Q_denotational_from, Qnil);
+      if (!NILP (ret))
+       ancestors = nconc2 (Fcopy_sequence (ancestors), ret);
+    }
+  return Qunbound;
+}
+
 DEFUN ("char-feature", Fchar_feature, 2, 5, 0, /*
 Return the value of CHARACTER's FEATURE.
 Return DEFAULT-VALUE if the value is not exist.
@@ -3329,38 +3366,20 @@ Return DEFAULT-VALUE if the value is not exist.
 
       if ( (name_str[0] != '=') || (name_str[1] == '>') )
        {
-         Lisp_Object ancestors
-           = Fget_char_attribute (character, Q_identical, Qnil);
-
-         if (NILP (ancestors))
-           ancestors
-             = Fget_char_attribute (character, Q_subsumptive_from, Qnil);
-
-         if (NILP (ancestors))
-           ancestors
-             = Fget_char_attribute (character, Q_denotational_from, Qnil);
+         ret = find_char_feature_in_family (character, Q_identical,
+                                            attribute, feature_rel_max);
+         if (!UNBOUNDP (ret))
+           return ret;
 
-         while (!NILP (ancestors))
-           {
-             Lisp_Object ancestor = XCAR (ancestors);
+         ret = find_char_feature_in_family (character, Q_subsumptive_from,
+                                            attribute, feature_rel_max);
+         if (!UNBOUNDP (ret))
+           return ret;
 
-             if (!EQ (ancestor, character))
-               {
-                 ret = Fchar_feature (ancestor, attribute, Qunbound,
-                                      Qnil, make_int (0));
-                 if (!UNBOUNDP (ret))
-                   return ret;
-
-                 ancestors = XCDR (ancestors);
-                 ret = Fget_char_attribute (ancestor,
-                                            Q_subsumptive_from, Qnil);
-                 if (!NILP (ret))
-                   ancestors = nconc2 (Fcopy_sequence (ancestors), ret);
-               }
-             else
-               return default_value;
-             /* ancestors = XCDR (ancestors); */
-           }
+         ret = find_char_feature_in_family (character, Q_denotational_from,
+                                            attribute, feature_rel_max);
+         if (!UNBOUNDP (ret))
+           return ret;
        }
     }
   return default_value;
@@ -3495,6 +3514,8 @@ Store CHARACTER's ATTRIBUTE with VALUE.
            EQ (attribute, Q_identical_from) ||
            EQ (attribute, Q_component) ||
            EQ (attribute, Q_component_of) ||
+           EQ (attribute, Q_same) ||
+           EQ (attribute, Q_same_of) ||
            !NILP (Fstring_match (build_string ("^<-simplified[^*]*$"),
                                  Fsymbol_name (attribute),
                                  Qnil, Qnil)) )
@@ -3521,6 +3542,10 @@ Store CHARACTER's ATTRIBUTE with VALUE.
        rev_feature = Q_component_of;
       else if (EQ (attribute, Q_component_of))
        rev_feature = Q_component;
+      else if (EQ (attribute, Q_same))
+       rev_feature = Q_same_of;
+      else if (EQ (attribute, Q_same_of))
+       rev_feature = Q_same;
       else
        {
          Lisp_String* name = symbol_name (XSYMBOL (attribute));
@@ -3805,6 +3830,8 @@ Save values of ATTRIBUTE into database file.
       if ( EQ (attribute, Qideographic_structure)
           || EQ (attribute, Q_identical)
           || EQ (attribute, Q_identical_from)
+          || EQ (attribute, Q_same)
+          || EQ (attribute, Q_same_of)
           || !NILP (Fstring_match
                     (build_string ("^\\(<-\\|->\\)simplified[^*]*$"),
                      Fsymbol_name (attribute),
@@ -4586,6 +4613,8 @@ syms_of_chartab (void)
   defsymbol (&Q_identical_from,                "<-identical");
   defsymbol (&Q_component,             "->ideographic-component-forms");
   defsymbol (&Q_component_of,          "<-ideographic-component-forms");
+  defsymbol (&Q_same,                  "->same");
+  defsymbol (&Q_same_of,               "<-same");
   defsymbol (&Qcomposition,            "composition");
   defsymbol (&Q_decomposition,         "->decomposition");
   defsymbol (&Qcompat,                 "compat");
index d8322a0..3c19e20 100644 (file)
@@ -3375,7 +3375,7 @@ char_encode_as_entity_reference (Emchar ch, char* buf)
   Lisp_Object ccs;
   Lisp_Object char_type;
   int format_columns, idx;
-  char format[18];
+  char format[20];
 
   while (!NILP (rest))
     {
@@ -3400,14 +3400,14 @@ char_encode_as_entity_reference (Emchar ch, char* buf)
 
              cell = Fcdr (cell);
              ret = Fcar (cell);
-             if (STRINGP (ret) && ((idx = XSTRING_LENGTH (ret)) <= 6))
+             if (STRINGP (ret) && ( (idx = XSTRING_LENGTH (ret)) <= 8 ))
                {
                  format[0] = '&';
                  strncpy (&format[1], XSTRING_DATA (ret), idx);
                  idx++;
                }
              else
-               continue;
+               goto try_next;
 
              cell = Fcdr (cell);
              ret = Fcar (cell);
@@ -3431,7 +3431,7 @@ char_encode_as_entity_reference (Emchar ch, char* buf)
              else if (EQ (ret, QX))
                format [idx++] = 'X';
              else
-               continue;
+               goto try_next;
              format [idx++] = ';';
              format [idx++] = 0;
 
@@ -3439,6 +3439,7 @@ char_encode_as_entity_reference (Emchar ch, char* buf)
              return;
            }
        }
+    try_next:
       rest = Fcdr (rest);
     }
   sprintf (buf, "&MCS-%08X;", ch);