changeset 17117:f03002ec3404

(Faref, Faset): Handle a composite char correctly in char-table.
author Kenichi Handa <handa@m17n.org>
date Thu, 27 Feb 1997 10:45:19 +0000
parents 321ebfc346eb
children dcfb481ee914
files src/data.c
diffstat 1 files changed, 8 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/data.c	Thu Feb 27 10:44:19 1997 +0000
+++ b/src/data.c	Thu Feb 27 10:45:19 1997 +0000
@@ -1567,8 +1567,8 @@
 	}
       else
 	{
-	  int idx[4];		/* For charset, code1, code2, and anchor.  */
-	  int i;
+	  int idx[3];		/* For charset, code1, and code2.  */
+	  int i, len;
 	  Lisp_Object sub_array;
 
 	  /* There's no reason to treat a composite character
@@ -1580,11 +1580,11 @@
 	    idxval = cmpchar_component (idxval, 0);
 #endif
 	  SPLIT_NON_ASCII_CHAR (idxval, idx[0], idx[1], idx[2]);
-	  idx[3] = 0;
+	  len = (COMPOSITE_CHAR_P (idxval) || idx[2]) ? 3 : (idx[1] ? 2 : 1);
 
 	try_parent_char_table:
 	  sub_array = array;
-	  for (i = 0; idx[i]; i++)
+	  for (i = 0; i < len; i++)
 	    {
 	      val = XCHAR_TABLE (sub_array)->contents[idx[i]];
 	      if (NILP (val))
@@ -1677,14 +1677,14 @@
 	XCHAR_TABLE (array)->contents[idxval] = newelt;
       else
 	{
-	  int idx[4];		/* For charset, code1, code2, and anchor.  */
-	  int i;
+	  int idx[3];		/* For charset, code1, and code2.  */
+	  int i, len;
 	  Lisp_Object val;
 
 	  SPLIT_NON_ASCII_CHAR (idxval, idx[0], idx[1], idx[2]);
-	  idx[3] = 0;
+	  len = (COMPOSITE_CHAR_P (idxval) || idx[2]) ? 2 : (idx[1] ? 1 : 0);
 
-	  for (i = 0; idx[i + 1]; i++)
+	  for (i = 0; i < len; i++)
 	    {
 	      val = XCHAR_TABLE (array)->contents[idx[i]];
 	      if (CHAR_TABLE_P (val))