(U+8FB5): Unify BC-8A74.
[chise/xemacs-chise.git.1] / src / buffer.c
index 43eaac9..ecb204c 100644 (file)
@@ -2,6 +2,7 @@
    Copyright (C) 1985-1989, 1992-1995 Free Software Foundation, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
    Copyright (C) 1995, 1996 Ben Wing.
    Copyright (C) 1985-1989, 1992-1995 Free Software Foundation, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
    Copyright (C) 1995, 1996 Ben Wing.
+   Copyright (C) 1999,2000,2001 MORIOKA Tomohiko
 
 This file is part of XEmacs.
 
 
 This file is part of XEmacs.
 
@@ -29,6 +30,7 @@ Boston, MA 02111-1307, USA.  */
         list per frame.)
    Mly: a few changes for buffer-local vars, 19.8 or 19.9.
    Ben Wing: some changes and cleanups for Mule, 19.12.
         list per frame.)
    Mly: a few changes for buffer-local vars, 19.8 or 19.9.
    Ben Wing: some changes and cleanups for Mule, 19.12.
+   MORIOKA Tomohiko: some changes for XEmacs UTF-2000.
  */
 
 /* This file contains functions that work with buffer objects.
  */
 
 /* This file contains functions that work with buffer objects.
@@ -356,7 +358,7 @@ get_buffer (Lisp_Object name, int error_if_deleted_or_does_not_exist)
 struct buffer *
 decode_buffer (Lisp_Object buffer, int allow_string)
 {
 struct buffer *
 decode_buffer (Lisp_Object buffer, int allow_string)
 {
-  if (NILP (buffer))
+  if (NILP (buffer) || (!POINTER_TYPE_P( XTYPE(buffer))))
     return current_buffer;
 
   if (allow_string && STRINGP (buffer))
     return current_buffer;
 
   if (allow_string && STRINGP (buffer))
@@ -998,8 +1000,8 @@ The ordering is for this frame; If second optional argument FRAME
 is provided, then the ordering is for that frame.  If the second arg
 is t, then the global ordering is returned.
 
 is provided, then the ordering is for that frame.  If the second arg
 is t, then the global ordering is returned.
 
-Note: In FSF Emacs, this function takes two arguments: BUFFER and
-VISIBLE-OK.
+Note: In FSF Emacs, this function takes the arguments in the order of
+BUFFER, VISIBLE-OK and FRAME.
 */
        (buffer, frame, visible_ok))
 {
 */
        (buffer, frame, visible_ok))
 {
@@ -1256,9 +1258,11 @@ with `delete-process'.
 
     delete_from_buffer_alist (buf);
 
 
     delete_from_buffer_alist (buf);
 
-    /* #### This is a problem if this buffer is in a dedicated window.
-       Need to undedicate any windows of this buffer first (and delete them?)
-       */
+    /* Undedicate any windows of this buffer, and make sure no windows
+       show it.  */
+
+    undedicate_windows (buf, Qt);
+    
     GCPRO1 (buf);
     Freplace_buffer_in_windows (buf, Qnil, Qall);
     UNGCPRO;
     GCPRO1 (buf);
     Freplace_buffer_in_windows (buf, Qnil, Qall);
     UNGCPRO;
@@ -1859,11 +1863,17 @@ dfc_convert_to_external_format (dfc_conversion_type source_type,
        const Bufbyte *end;
        for (end = ptr + len; ptr < end;)
          {
        const Bufbyte *end;
        for (end = ptr + len; ptr < end;)
          {
+#ifdef UTF2000
+           Bufbyte c =
+             (*ptr < 0xc0) ? *ptr :
+             ((*ptr & 0x1f) << 6) | (*(ptr+1) & 0x3f);
+#else
            Bufbyte c =
              (BYTE_ASCII_P (*ptr))                ? *ptr :
              (*ptr == LEADING_BYTE_CONTROL_1)     ? (*(ptr+1) - 0x20) :
              (*ptr == LEADING_BYTE_LATIN_ISO8859_1) ? (*(ptr+1)) :
              '~';
            Bufbyte c =
              (BYTE_ASCII_P (*ptr))                ? *ptr :
              (*ptr == LEADING_BYTE_CONTROL_1)     ? (*(ptr+1) - 0x20) :
              (*ptr == LEADING_BYTE_LATIN_ISO8859_1) ? (*(ptr+1)) :
              '~';
+#endif
 
            Dynarr_add (conversion_out_dynarr, (Extbyte) c);
            INC_CHARPTR (ptr);
 
            Dynarr_add (conversion_out_dynarr, (Extbyte) c);
            INC_CHARPTR (ptr);
@@ -1999,6 +2009,15 @@ dfc_convert_to_internal_format (dfc_conversion_type source_type,
         {
           Bufbyte c = *ptr;
 
         {
           Bufbyte c = *ptr;
 
+#ifdef UTF2000
+         if (BYTE_ASCII_P (c))
+           Dynarr_add (conversion_in_dynarr, c);
+         else
+           {
+             Dynarr_add (conversion_in_dynarr, (c >> 6) | 0xC0);
+             Dynarr_add (conversion_in_dynarr, (c & 0x3F) | 0x80);
+           }
+#else
          if (BYTE_ASCII_P (c))
            Dynarr_add (conversion_in_dynarr, c);
          else if (BYTE_C1_P (c))
          if (BYTE_ASCII_P (c))
            Dynarr_add (conversion_in_dynarr, c);
          else if (BYTE_C1_P (c))
@@ -2011,6 +2030,7 @@ dfc_convert_to_internal_format (dfc_conversion_type source_type,
              Dynarr_add (conversion_in_dynarr, LEADING_BYTE_LATIN_ISO8859_1);
              Dynarr_add (conversion_in_dynarr, c);
            }
              Dynarr_add (conversion_in_dynarr, LEADING_BYTE_LATIN_ISO8859_1);
              Dynarr_add (conversion_in_dynarr, c);
            }
+#endif
         }
 #else
       Dynarr_add_many (conversion_in_dynarr, source->data.ptr, source->data.len);
         }
 #else
       Dynarr_add_many (conversion_in_dynarr, source->data.ptr, source->data.len);
@@ -2416,8 +2436,10 @@ common_init_complex_vars_of_buffer (void)
   defs->category_table = Vstandard_category_table;
 #endif /* MULE */
   defs->syntax_table = Vstandard_syntax_table;
   defs->category_table = Vstandard_category_table;
 #endif /* MULE */
   defs->syntax_table = Vstandard_syntax_table;
+#ifndef UTF2000
   defs->mirror_syntax_table =
     XCHAR_TABLE (Vstandard_syntax_table)->mirror_table;
   defs->mirror_syntax_table =
     XCHAR_TABLE (Vstandard_syntax_table)->mirror_table;
+#endif
   defs->modeline_format = build_string ("%-");  /* reset in loaddefs.el */
   defs->case_fold_search = Qt;
   defs->selective_display_ellipses = Qt;
   defs->modeline_format = build_string ("%-");  /* reset in loaddefs.el */
   defs->case_fold_search = Qt;
   defs->selective_display_ellipses = Qt;
@@ -2504,7 +2526,9 @@ common_init_complex_vars_of_buffer (void)
 
     /* #### Warning: 1<<31 is the largest number currently allowable
        due to the XINT() handling of this value.  With some
 
     /* #### Warning: 1<<31 is the largest number currently allowable
        due to the XINT() handling of this value.  With some
-       rearrangement you can get 3 more bits. */
+       rearrangement you can get 3 more bits.
+
+       #### 3 more?  34 bits???? -ben */
   }
 }
 
   }
 }
 
@@ -2674,12 +2698,6 @@ Automatically becomes buffer-local when set in any fashion.
   DEFVAR_BUFFER_LOCAL ("case-fold-search", case_fold_search /*
 *Non-nil if searches should ignore case.
 Automatically becomes buffer-local when set in any fashion.
   DEFVAR_BUFFER_LOCAL ("case-fold-search", case_fold_search /*
 *Non-nil if searches should ignore case.
 Automatically becomes buffer-local when set in any fashion.
-
-BUG: Under XEmacs/Mule, translations to or from non-ASCII characters
- (this includes chars in the range 128 - 255) are ignored by
- the string/buffer-searching routines.  Thus, `case-fold-search'
- will not correctly conflate a-umlaut and A-umlaut even if the
- case tables call for this.
 */ );
 
   DEFVAR_BUFFER_LOCAL ("fill-column", fill_column /*
 */ );
 
   DEFVAR_BUFFER_LOCAL ("fill-column", fill_column /*