Add an EXFUN for `Ffind_char'.
[chise/xemacs-chise.git-] / src / insdel.c
index a656993..eeab025 100644 (file)
@@ -200,7 +200,6 @@ Boston, MA 02111-1307, USA.  */
 
 #include <config.h>
 #include "lisp.h"
-#include <limits.h>
 
 #include "buffer.h"
 #include "device.h"
@@ -1223,6 +1222,7 @@ bytind_to_bufpos (struct buffer *buf, Bytind x)
 Bufpos
 get_buffer_pos_char (struct buffer *b, Lisp_Object pos, unsigned int flags)
 {
+  /* Does not GC */
   Bufpos ind;
   Bufpos min_allowed, max_allowed;
 
@@ -1272,6 +1272,7 @@ void
 get_buffer_range_char (struct buffer *b, Lisp_Object from, Lisp_Object to,
                       Bufpos *from_out, Bufpos *to_out, unsigned int flags)
 {
+  /* Does not GC */
   Bufpos min_allowed, max_allowed;
 
   min_allowed = (flags & GB_ALLOW_PAST_ACCESSIBLE) ?
@@ -3133,8 +3134,8 @@ find_charsets_in_bufbyte_string (Charset_ID *charsets, const Bufbyte *str,
 }
 
 void
-find_charsets_in_emchar_string (Charset_ID *charsets, const Emchar *str,
-                               Charcount len)
+find_charsets_in_charc_string (Charset_ID *charsets, const Charc *str,
+                              Charcount len)
 {
 #ifndef MULE
   /* Telescope this. */
@@ -3147,18 +3148,13 @@ find_charsets_in_emchar_string (Charset_ID *charsets, const Emchar *str,
   /* #### SJT doesn't like this. */
   if (len == 0)
     {
-      charsets[XCHARSET_LEADING_BYTE (Vcharset_ascii) - MIN_LEADING_BYTE] = 1;
+      charsets[XCHARSET_ID (Vcharset_ascii) - MIN_LEADING_BYTE] = 1;
       return;
     }
 
   for (i = 0; i < len; i++)
     {
-#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
+      charsets[CHARC_CHARSET_ID (str[i]) - MIN_LEADING_BYTE] = 1;
     }
 #endif
 }
@@ -3184,14 +3180,14 @@ bufbyte_string_displayed_columns (const Bufbyte *str, Bytecount len)
 }
 
 int
-emchar_string_displayed_columns (const Emchar *str, Charcount len)
+charc_string_displayed_columns (const Charc *str, Charcount len)
 {
 #ifdef MULE
   int cols = 0;
   int i;
 
   for (i = 0; i < len; i++)
-    cols += CHAR_COLUMNS (str[i]);
+    cols += CHARC_COLUMNS (str[i]);
 
   return cols;
 #else  /* not MULE */
@@ -3202,15 +3198,14 @@ emchar_string_displayed_columns (const Emchar *str, Charcount len)
 /* NOTE: Does not reset the Dynarr. */
 
 void
-convert_bufbyte_string_into_emchar_dynarr (const Bufbyte *str, Bytecount len,
-                                          Emchar_dynarr *dyn)
+convert_bufbyte_string_into_charc_dynarr (const Bufbyte *str, Bytecount len,
+                                         Charc_dynarr *dyn)
 {
   const Bufbyte *strend = str + len;
 
   while (str < strend)
     {
-      Emchar ch = charptr_emchar (str);
-      Dynarr_add (dyn, ch);
+      Dynarr_add (dyn, CHAR_TO_CHARC (charptr_emchar (str)));
       INC_CHARPTR (str);
     }
 }
@@ -3235,15 +3230,15 @@ convert_bufbyte_string_into_emchar_string (const Bufbyte *str, Bytecount len,
    Does not add a terminating zero. */
 
 void
-convert_emchar_string_into_bufbyte_dynarr (Emchar *arr, int nels,
-                                         Bufbyte_dynarr *dyn)
+convert_charc_string_into_bufbyte_dynarr (Charc *arr, int nels,
+                                           Bufbyte_dynarr *dyn)
 {
   Bufbyte str[MAX_EMCHAR_LEN];
   int i;
 
   for (i = 0; i < nels; i++)
     {
-      Bytecount len = set_charptr_emchar (str, arr[i]);
+      Bytecount len = set_charptr_emchar (str, CHARC_TO_CHAR (arr[i]));
       Dynarr_add_many (dyn, str, len);
     }
 }
@@ -3255,7 +3250,7 @@ convert_emchar_string_into_bufbyte_dynarr (Emchar *arr, int nels,
    is one more than this: the returned string is zero-terminated. */
 
 Bufbyte *
-convert_emchar_string_into_malloced_string (Emchar *arr, int nels,
+convert_charc_string_into_malloced_string (Charc *arr, int nels,
                                           Bytecount *len_out)
 {
   /* Damn zero-termination. */
@@ -3266,7 +3261,9 @@ convert_emchar_string_into_malloced_string (Emchar *arr, int nels,
   int i;
 
   for (i = 0; i < nels; i++)
-    str += set_charptr_emchar (str, arr[i]);
+    {
+      str += set_charptr_emchar (str, CHARC_TO_CHAR (arr[i]));
+    }
   *str = '\0';
   len = str - strorig;
   str = (Bufbyte *) xmalloc (1 + len);