(Fcharset_name): Define `byte_offset' in non-UTF-2000 configuration.
[chise/xemacs-chise.git-] / src / insdel.c
index 7a7c3f9..b54678a 100644 (file)
@@ -3107,7 +3107,7 @@ barf_if_buffer_read_only (struct buffer *buf, Bufpos from, Bufpos to)
 }
 
 void
-find_charsets_in_bufbyte_string (unsigned char *charsets, CONST Bufbyte *str,
+find_charsets_in_bufbyte_string (Charset_ID *charsets, CONST Bufbyte *str,
                                 Bytecount len)
 {
 #ifndef MULE
@@ -3115,18 +3115,25 @@ find_charsets_in_bufbyte_string (unsigned char *charsets, CONST Bufbyte *str,
   charsets[0] = 1;
 #else
   CONST Bufbyte *strend = str + len;
-  memset (charsets, 0, NUM_LEADING_BYTES);
+  memset (charsets, 0, NUM_LEADING_BYTES * sizeof(Charset_ID));
 
   while (str < strend)
     {
-      charsets[CHAR_LEADING_BYTE (charptr_emchar (str)) - 128] = 1;
+#ifdef UTF2000
+      charsets[CHAR_CHARSET_ID (charptr_emchar (str))
+             - MIN_LEADING_BYTE] = 1;
+#else /* I'm not sure the definition for UTF2000 works with leading-byte
+        representation. */
+      charsets[CHAR_LEADING_BYTE (charptr_emchar (str))
+             - MIN_LEADING_BYTE] = 1;
+#endif
       INC_CHARPTR (str);
     }
 #endif
 }
 
 void
-find_charsets_in_emchar_string (unsigned char *charsets, CONST Emchar *str,
+find_charsets_in_emchar_string (Charset_ID *charsets, CONST Emchar *str,
                                Charcount len)
 {
 #ifndef MULE
@@ -3135,10 +3142,15 @@ find_charsets_in_emchar_string (unsigned char *charsets, CONST Emchar *str,
 #else
   int i;
 
-  memset (charsets, 0, NUM_LEADING_BYTES);
+  memset (charsets, 0, NUM_LEADING_BYTES * sizeof(Charset_ID));
   for (i = 0; i < len; i++)
     {
-      charsets[CHAR_LEADING_BYTE (str[i]) - 128] = 1;
+#ifdef UTF2000
+      charsets[CHAR_CHARSET_ID (str[i]) - MIN_LEADING_BYTE] = 1;
+#else /* I'm not sure the definition for UTF2000 works with leading-byte
+        representation. */
+      charsets[CHAR_LEADING_BYTE (str[i]) - MIN_LEADING_BYTE] = 1;
+#endif
     }
 #endif
 }
@@ -3153,7 +3165,7 @@ bufbyte_string_displayed_columns (CONST Bufbyte *str, Bytecount len)
     {
 #ifdef MULE
       Emchar ch = charptr_emchar (str);
-      cols += XCHARSET_COLUMNS (CHAR_CHARSET (ch));
+      cols += CHAR_COLUMNS (ch);
 #else
       cols++;
 #endif
@@ -3171,7 +3183,7 @@ emchar_string_displayed_columns (CONST Emchar *str, Charcount len)
   int i;
 
   for (i = 0; i < len; i++)
-    cols += XCHARSET_COLUMNS (CHAR_CHARSET (str[i]));
+    cols += CHAR_COLUMNS (str[i]);
 
   return cols;
 #else  /* not MULE */
@@ -3264,7 +3276,9 @@ convert_emchar_string_into_malloced_string (Emchar *arr, int nels,
 void
 vars_of_insdel (void)
 {
+#ifndef UTF2000
   int i;
+#endif
 
   inside_change_hook = 0;
   in_first_change = 0;