XEmacs 21.4.17 "Jumbo Shrimp".
[chise/xemacs-chise.git.1] / src / insdel.c
index d17322b..e20c22b 100644 (file)
@@ -218,9 +218,7 @@ Boston, MA 02111-1307, USA.  */
 #define MAX_BUFPOS_GAP_SIZE_3 (65535/3)
 #define MAX_BYTIND_GAP_SIZE_3 (3 * MAX_BUFPOS_GAP_SIZE_3)
 
-#ifndef UTF2000
 short three_to_one_table[1 + MAX_BYTIND_GAP_SIZE_3];
-#endif
 
 /* Various macros modelled along the lines of those in buffer.h.
    Purposefully omitted from buffer.h because files other than this
@@ -431,11 +429,7 @@ bufpos_to_bytind_func (struct buffer *buf, Bufpos x)
   bufmax = buf->text->mule_bufmax;
   bytmin = buf->text->mule_bytmin;
   bytmax = buf->text->mule_bytmax;
-#ifdef UTF2000
-  size = buf->text->mule_size;
-#else
   size = (1 << buf->text->mule_shifter) + !!buf->text->mule_three_p;
-#endif
 
   /* The basic idea here is that we shift the "known region" up or down
      until it overlaps the specified position.  We do this by moving
@@ -495,7 +489,7 @@ bufpos_to_bytind_func (struct buffer *buf, Bufpos x)
     }
 #ifdef ERROR_CHECK_BUFPOS
   else if (x >= bufmin)
-    abort ();
+    ABORT ();
 #endif
   else
     {
@@ -630,16 +624,11 @@ bufpos_to_bytind_func (struct buffer *buf, Bufpos x)
      discovered isn't too large, because we use a fixed-length
      table to divide by 3. */
 
-#ifdef UTF2000
-  buf->text->mule_size = size;
-#endif
   if (size == 3)
     {
       int gap = bytmax - bytmin;
-#ifndef UTF2000
       buf->text->mule_three_p = 1;
       buf->text->mule_shifter = 1;
-#endif
 
       if (gap > MAX_BYTIND_GAP_SIZE_3)
        {
@@ -657,13 +646,11 @@ bufpos_to_bytind_func (struct buffer *buf, Bufpos x)
     }
   else
     {
-#ifndef UTF2000
       buf->text->mule_three_p = 0;
       if (size == 4)
        buf->text->mule_shifter = 2;
       else
        buf->text->mule_shifter = size - 1;
-#endif
     }
 
   buf->text->mule_bufmin = bufmin;
@@ -719,11 +706,7 @@ bytind_to_bufpos_func (struct buffer *buf, Bytind x)
   bufmax = buf->text->mule_bufmax;
   bytmin = buf->text->mule_bytmin;
   bytmax = buf->text->mule_bytmax;
-#ifdef UTF2000
-  size = buf->text->mule_size;
-#else
   size = (1 << buf->text->mule_shifter) + !!buf->text->mule_three_p;
-#endif
 
   /* The basic idea here is that we shift the "known region" up or down
      until it overlaps the specified position.  We do this by moving
@@ -783,7 +766,7 @@ bytind_to_bufpos_func (struct buffer *buf, Bytind x)
     }
 #ifdef ERROR_CHECK_BUFPOS
   else if (x >= bytmin)
-    abort ();
+    ABORT ();
 #endif
   else
     {
@@ -918,16 +901,11 @@ bytind_to_bufpos_func (struct buffer *buf, Bytind x)
      discovered isn't too large, because we use a fixed-length
      table to divide by 3. */
 
-#ifdef UTF2000
-  buf->text->mule_size = size;
-  #endif
   if (size == 3)
     {
       int gap = bytmax - bytmin;
-#ifndef UTF2000
       buf->text->mule_three_p = 1;
       buf->text->mule_shifter = 1;
-#endif
 
       if (gap > MAX_BYTIND_GAP_SIZE_3)
        {
@@ -945,13 +923,11 @@ bytind_to_bufpos_func (struct buffer *buf, Bytind x)
     }
   else
     {
-#ifndef UTF2000
       buf->text->mule_three_p = 0;
       if (size == 4)
        buf->text->mule_shifter = 2;
       else
        buf->text->mule_shifter = size - 1;
-#endif
     }
 
   buf->text->mule_bufmin = bufmin;
@@ -987,11 +963,7 @@ buffer_mule_signal_inserted_region (struct buffer *buf, Bufpos start,
                                    Bytecount bytelength,
                                    Charcount charlength)
 {
-#ifdef UTF2000
-  int size = buf->text->mule_size;
-#else
   int size = (1 << buf->text->mule_shifter) + !!buf->text->mule_three_p;
-#endif
   int i;
 
   /* Adjust the cache of known positions. */
@@ -1825,7 +1797,7 @@ static void
 move_gap (struct buffer *buf, Bytind pos)
 {
   if (! BUF_BEG_ADDR (buf))
-    abort ();
+    ABORT ();
   if (pos < BI_BUF_GPT (buf))
     gap_left (buf, pos);
   else if (pos > BI_BUF_GPT (buf))
@@ -3100,7 +3072,7 @@ barf_if_buffer_read_only (struct buffer *buf, Bufpos from, Bufpos to)
 }
 
 void
-find_charsets_in_bufbyte_string (Charset_ID *charsets, const Bufbyte *str,
+find_charsets_in_bufbyte_string (unsigned char *charsets, const Bufbyte *str,
                                 Bytecount len)
 {
 #ifndef MULE
@@ -3108,33 +3080,26 @@ find_charsets_in_bufbyte_string (Charset_ID *charsets, const Bufbyte *str,
   charsets[0] = 1;
 #else
   const Bufbyte *strend = str + len;
-  memset (charsets, 0, NUM_LEADING_BYTES * sizeof(Charset_ID));
+  memset (charsets, 0, NUM_LEADING_BYTES);
 
   /* #### SJT doesn't like this. */
   if (len == 0)
     {
-      charsets[XCHARSET_LEADING_BYTE (Vcharset_ascii) - MIN_LEADING_BYTE] = 1;
+      charsets[XCHARSET_LEADING_BYTE (Vcharset_ascii) - 128] = 1;
       return;
     }
 
   while (str < strend)
     {
-#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
+      charsets[CHAR_LEADING_BYTE (charptr_emchar (str)) - 128] = 1;
       INC_CHARPTR (str);
     }
 #endif
 }
 
 void
-find_charsets_in_charc_string (Charset_ID *charsets, const Charc *str,
-                              Charcount len)
+find_charsets_in_emchar_string (unsigned char *charsets, const Emchar *str,
+                               Charcount len)
 {
 #ifndef MULE
   /* Telescope this. */
@@ -3142,18 +3107,18 @@ find_charsets_in_charc_string (Charset_ID *charsets, const Charc *str,
 #else
   int i;
 
-  memset (charsets, 0, NUM_LEADING_BYTES * sizeof(Charset_ID));
+  memset (charsets, 0, NUM_LEADING_BYTES);
 
   /* #### SJT doesn't like this. */
   if (len == 0)
     {
-      charsets[XCHARSET_ID (Vcharset_ascii) - MIN_LEADING_BYTE] = 1;
+      charsets[XCHARSET_LEADING_BYTE (Vcharset_ascii) - 128] = 1;
       return;
     }
 
   for (i = 0; i < len; i++)
     {
-      charsets[CHARC_CHARSET_ID (str[i]) - MIN_LEADING_BYTE] = 1;
+      charsets[CHAR_LEADING_BYTE (str[i]) - 128] = 1;
     }
 #endif
 }
@@ -3168,7 +3133,7 @@ bufbyte_string_displayed_columns (const Bufbyte *str, Bytecount len)
     {
 #ifdef MULE
       Emchar ch = charptr_emchar (str);
-      cols += CHAR_COLUMNS (ch);
+      cols += XCHARSET_COLUMNS (CHAR_CHARSET (ch));
 #else
       cols++;
 #endif
@@ -3179,14 +3144,14 @@ bufbyte_string_displayed_columns (const Bufbyte *str, Bytecount len)
 }
 
 int
-charc_string_displayed_columns (const Charc *str, Charcount len)
+emchar_string_displayed_columns (const Emchar *str, Charcount len)
 {
 #ifdef MULE
   int cols = 0;
   int i;
 
   for (i = 0; i < len; i++)
-    cols += CHARC_COLUMNS (str[i]);
+    cols += XCHARSET_COLUMNS (CHAR_CHARSET (str[i]));
 
   return cols;
 #else  /* not MULE */
@@ -3197,14 +3162,15 @@ charc_string_displayed_columns (const Charc *str, Charcount len)
 /* NOTE: Does not reset the Dynarr. */
 
 void
-convert_bufbyte_string_into_charc_dynarr (const Bufbyte *str, Bytecount len,
-                                         Charc_dynarr *dyn)
+convert_bufbyte_string_into_emchar_dynarr (const Bufbyte *str, Bytecount len,
+                                          Emchar_dynarr *dyn)
 {
   const Bufbyte *strend = str + len;
 
   while (str < strend)
     {
-      Dynarr_add (dyn, CHAR_TO_CHARC (charptr_emchar (str)));
+      Emchar ch = charptr_emchar (str);
+      Dynarr_add (dyn, ch);
       INC_CHARPTR (str);
     }
 }
@@ -3229,15 +3195,15 @@ convert_bufbyte_string_into_emchar_string (const Bufbyte *str, Bytecount len,
    Does not add a terminating zero. */
 
 void
-convert_charc_string_into_bufbyte_dynarr (Charc *arr, int nels,
-                                           Bufbyte_dynarr *dyn)
+convert_emchar_string_into_bufbyte_dynarr (Emchar *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, CHARC_TO_CHAR (arr[i]));
+      Bytecount len = set_charptr_emchar (str, arr[i]);
       Dynarr_add_many (dyn, str, len);
     }
 }
@@ -3249,7 +3215,7 @@ convert_charc_string_into_bufbyte_dynarr (Charc *arr, int nels,
    is one more than this: the returned string is zero-terminated. */
 
 Bufbyte *
-convert_charc_string_into_malloced_string (Charc *arr, int nels,
+convert_emchar_string_into_malloced_string (Emchar *arr, int nels,
                                           Bytecount *len_out)
 {
   /* Damn zero-termination. */
@@ -3260,9 +3226,7 @@ convert_charc_string_into_malloced_string (Charc *arr, int nels,
   int i;
 
   for (i = 0; i < nels; i++)
-    {
-      str += set_charptr_emchar (str, CHARC_TO_CHAR (arr[i]));
-    }
+    str += set_charptr_emchar (str, arr[i]);
   *str = '\0';
   len = str - strorig;
   str = (Bufbyte *) xmalloc (1 + len);
@@ -3280,17 +3244,13 @@ convert_charc_string_into_malloced_string (Charc *arr, int nels,
 void
 reinit_vars_of_insdel (void)
 {
-#ifndef UTF2000
   int i;
-#endif
 
   inside_change_hook = 0;
   in_first_change = 0;
 
-#ifndef UTF2000
   for (i = 0; i <= MAX_BYTIND_GAP_SIZE_3; i++)
     three_to_one_table[i] = i / 3;
-#endif
 }
 
 void
@@ -3320,12 +3280,8 @@ init_buffer_text (struct buffer *b)
 
        b->text->mule_bufmin = b->text->mule_bufmax = 1;
        b->text->mule_bytmin = b->text->mule_bytmax = 1;
-#ifdef UTF2000
-       b->text->mule_size = 0;
-#else
        b->text->mule_shifter = 0;
        b->text->mule_three_p = 0;
-#endif
 
        for (i = 0; i < 16; i++)
          {