[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

[MD:1447]A solution for "Bitmap kills emacs" problem.



Subject $B$NLdBj$K4X$7$F!"(BRichard $B$H$bOC$79g$C$?7k2L!"0J2<$N$h$&$J%Q%C%A(B
$B$r;H$&$3$H$K$J$j$^$7$?!#$^$"!"F($2$G$9$M!#(B^.^;;; $B$3$N%Q%C%A$r;n$;$kJ}(B
$B$O!";j5^(B bitmap.el $B$r%O!<%I$K;H$C$F!"LdBj$J$$$+$I$&$+3N$+$a$FD:$1$J$$(B
$B$G$7$g$&$+!#(B

$B!]!]!!$1$s$A$c$s!w#E#T#L(B
      handa@xxxxxxxxx

1999-09-16  Kenichi Handa  <handa@xxxxxxxxx>

	* charset.h: (register_composite_chars_region): Extern it.
	(register_composite_chars_string): Extern it.

	* charset.c (str_cmpchar_id): New argument REGISTERP.  Caller
	changed.
	(register_composite_chars_region): New function.
	(register_composite_chars_string): New function.

	* alloc.c (make_string): Call register_composite_chars_string for
	a multibyte string. 
	(make_multibyte_string): Likewise.
	(make_string_from_bytes): Likewise.
	(make_specified_string): Likewise.

	* buffer.c (Fset_buffer_multibyte): On setting the buffer
	multibyte, call register_composite_chars_region.

	* insdel.c (insert_1_both): Call register_composite_chars_region
	after the insertion.
	(adjust_after_replace): Likewise.

	* indent.c (MULTIBYTE_BYTES_WIDTH): Adjusted for the change of
	str_cmpchar_id.

Index: src/alloc.c
===================================================================
RCS file: /project/mule/cvsroot/emacs-20.4/src/alloc.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 alloc.c
*** alloc.c	1999/08/11 00:12:47	1.1.1.1
--- alloc.c	1999/09/13 11:38:42
***************
*** 1320,1325 ****
--- 1320,1327 ----
    bcopy (contents, XSTRING (val)->data, nbytes);
    if (STRING_BYTES (XSTRING (val)) == XSTRING (val)->size)
      SET_STRING_BYTES (XSTRING (val), -1);
+   else
+     register_composite_chars_string (val);
    return val;
  }
  
***************
*** 1348,1353 ****
--- 1350,1356 ----
    register Lisp_Object val;
    val = make_uninit_multibyte_string (nchars, nbytes);
    bcopy (contents, XSTRING (val)->data, nbytes);
+   register_composite_chars_string (val);
    return val;
  }
  
***************
*** 1365,1370 ****
--- 1368,1375 ----
    bcopy (contents, XSTRING (val)->data, nbytes);
    if (STRING_BYTES (XSTRING (val)) == XSTRING (val)->size)
      SET_STRING_BYTES (XSTRING (val), -1);
+   else
+     register_composite_chars_string (val);
    return val;
  }
  
***************
*** 1382,1387 ****
--- 1387,1394 ----
    bcopy (contents, XSTRING (val)->data, nbytes);
    if (!multibyte)
      SET_STRING_BYTES (XSTRING (val), -1);
+   else
+     register_composite_chars_string (val);
    return val;
  }
  
Index: src/buffer.c
===================================================================
RCS file: /project/mule/cvsroot/emacs-20.4/src/buffer.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 buffer.c
*** buffer.c	1999/08/11 00:12:47	1.1.1.1
--- buffer.c	1999/09/16 02:35:22
***************
*** 1828,1833 ****
--- 1828,1836 ----
  	TEMP_SET_PT_BOTH (pt, pt_byte);
        }
  
+       /* Register all composite characters.  */
+       register_composite_chars_region (BEG, BEG_BYTE, Z, Z_BYTE);
+ 
        tail = markers = BUF_MARKERS (current_buffer);
  
        /* This prevents BYTE_TO_CHAR (that is, buf_bytepos_to_charpos) from
Index: src/charset.c
===================================================================
RCS file: /project/mule/cvsroot/emacs-20.4/src/charset.c,v
retrieving revision 1.2
diff -c -r1.2 charset.c
*** charset.c	1999/08/11 00:30:24	1.2
--- charset.c	1999/09/16 04:21:51
***************
*** 252,258 ****
  
        if (c == LEADING_CODE_COMPOSITION)
  	{
! 	  int cmpchar_id = str_cmpchar_id (begp, bytes);
  
  	  if (cmpchar_id >= 0)
  	    {
--- 252,258 ----
  
        if (c == LEADING_CODE_COMPOSITION)
  	{
! 	  int cmpchar_id = str_cmpchar_id (begp, bytes, 0);
  
  	  if (cmpchar_id >= 0)
  	    {
***************
*** 321,327 ****
  
    if (cs == LEADING_CODE_COMPOSITION)
      {
!       int cmpchar_id = str_cmpchar_id (str - 1, len);
  
        if (cmpchar_id < 0)
  	return -1;
--- 321,327 ----
  
    if (cs == LEADING_CODE_COMPOSITION)
      {
!       int cmpchar_id = str_cmpchar_id (str - 1, len, 0);
  
        if (cmpchar_id < 0)
  	return -1;
***************
*** 813,819 ****
        
        if (c == LEADING_CODE_COMPOSITION)
  	{
! 	  int cmpchar_id = str_cmpchar_id (str, len);
  	  GLYPH *glyph;
  
  	  if (cmpchar_id >= 0)
--- 813,819 ----
        
        if (c == LEADING_CODE_COMPOSITION)
  	{
! 	  int cmpchar_id = str_cmpchar_id (str, len, 0);
  	  GLYPH *glyph;
  
  	  if (cmpchar_id >= 0)
***************
*** 1275,1281 ****
      {
        if (*str == LEADING_CODE_COMPOSITION)
  	{
! 	  int id = str_cmpchar_id (str, endp - str);
  
  	  if (id < 0)
  	    {
--- 1275,1281 ----
      {
        if (*str == LEADING_CODE_COMPOSITION)
  	{
! 	  int id = str_cmpchar_id (str, endp - str, 0);
  
  	  if (id < 0)
  	    {
***************
*** 1500,1511 ****
  
  /* Return CMPCHAR-ID of the composite character in STR of the length
     LEN.  If the composite character has not yet been registered,
!    register it in `cmpchar_table' and assign new CMPCHAR-ID.  This
!    is the sole function for assigning CMPCHAR-ID.  */
  int
! str_cmpchar_id (str, len)
       const unsigned char *str;
       int len;
  {
    int hash_idx, *hashp;
    unsigned char *buf;
--- 1500,1513 ----
  
  /* Return CMPCHAR-ID of the composite character in STR of the length
     LEN.  If the composite character has not yet been registered,
!    register it in `cmpchar_table' and assign new CMPCHAR-ID (if
!    REGISTERP is nonzero), or return -1 (otherwise).  This is the sole
!    function for assigning CMPCHAR-ID.  */
  int
! str_cmpchar_id (str, len, registerp)
       const unsigned char *str;
       int len;
+      int registerp;
  {
    int hash_idx, *hashp;
    unsigned char *buf;
***************
*** 1562,1567 ****
--- 1564,1572 ----
  	  return CMPCHAR_HASH_CMPCHAR_ID (hashp, i);
        }
  
+   if (!registerp)
+     return -1;
+ 
    /* We have to register the composite character in cmpchar_table.  */
    if (n_cmpchars >= (CHAR_FIELD2_MASK | CHAR_FIELD3_MASK))
      /* No, we have no more room for a new composite character.  */
***************
*** 1716,1721 ****
--- 1721,1805 ----
    return n_cmpchars++;
  }
  
+ /* Register composite characters in the region specified by
+    positions FROM/FROM_BYTE and TO/TO_BYTE.  */
+ 
+ void
+ register_composite_chars_region (from, from_byte, to, to_byte)
+      int from, from_byte, to, to_byte;
+ {
+   int stop_byte;
+   unsigned char *p = BYTE_POS_ADDR (from_byte);
+   int id;
+   
+   if (to - from == to_byte - from_byte)
+     /*  There's no composite character in this range.  */
+     return;
+ 
+   if (to_byte < GPT_BYTE)
+     stop_byte = to_byte;
+   else
+     stop_byte = GPT_BYTE;
+ 
+   while (1)
+     {
+       if (from_byte >= stop_byte)
+ 	{
+ 	  if (stop_byte >= to_byte)
+ 	    break;
+ 	  stop_byte = to_byte;
+ 	  p = BYTE_POS_ADDR (from_byte);
+ 	}
+       if (*p == LEADING_CODE_COMPOSITION
+ 	  && (id = str_cmpchar_id (p, stop_byte - from_byte, 1)) >= 0)
+ 	{
+ 	  from_byte += cmpchar_table[id]->len;
+ 	  p = BYTE_POS_ADDR (from_byte);
+ 	}
+       else
+ 	{
+ 	  from_byte++;
+ 	  p++;
+ 	}
+     }
+ }
+ 
+ /* It is safe to call this when creating a string, because creating a
+    string can call xmalloc itself.  So anything that calls a string
+    creation function already needs to cope with the issue of
+    relocating buffers.  */
+ 
+ void
+ register_composite_chars_string (string)
+      Lisp_Object string;
+ {
+   int i_byte;
+   int len = STRING_BYTES (XSTRING (string));
+   unsigned char *p = XSTRING (string)->data;
+   int id;
+   
+   if (!STRING_MULTIBYTE (string)
+       || STRING_BYTES (XSTRING (string)) == XSTRING (string)->size)
+     /*  There's no composite character in STRING.  */
+     return;
+ 
+   i_byte = 0;
+   while (i_byte < len)
+     {
+       if (*p == LEADING_CODE_COMPOSITION
+ 	  && (id = str_cmpchar_id (p, len - i_byte, 1)) >= 0)
+ 	{
+ 	  i_byte += cmpchar_table[id]->len;
+ 	  p = XSTRING (string)->data + i_byte;
+ 	}
+       else
+ 	{
+ 	  i_byte++;
+ 	  p++;
+ 	}
+     }
+ }
+ 
  /* Return the Nth element of the composite character C.  If NOERROR is
     nonzero, return 0 on error condition (C is an invalid composite
     charcter, or N is out of range). */
***************
*** 1859,1865 ****
  	    error ("Can't compose a rule-based composition character");
  	  ptemp = p;
  	  while (! CHAR_HEAD_P (*p)) p++;
! 	  if (str_cmpchar_id (ptemp - 1, p - ptemp + 1) < 0)
  	    error ("Can't compose an invalid composition character");
  	  if (i + (p - ptemp) >= MAX_LENGTH_OF_MULTI_BYTE_FORM)
  	    error ("Too long string to be composed: %s", XSTRING (str)->data);
--- 1943,1949 ----
  	    error ("Can't compose a rule-based composition character");
  	  ptemp = p;
  	  while (! CHAR_HEAD_P (*p)) p++;
! 	  if (str_cmpchar_id (ptemp - 1, p - ptemp + 1, 0) < 0)
  	    error ("Can't compose an invalid composition character");
  	  if (i + (p - ptemp) >= MAX_LENGTH_OF_MULTI_BYTE_FORM)
  	    error ("Too long string to be composed: %s", XSTRING (str)->data);
Index: src/charset.h
===================================================================
RCS file: /project/mule/cvsroot/emacs-20.4/src/charset.h,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 charset.h
*** charset.h	1999/08/11 00:12:51	1.1.1.1
--- charset.h	1999/09/16 02:25:49
***************
*** 810,816 ****
  					 int));
  extern int non_ascii_char_to_string P_ ((int, unsigned char *, unsigned char **));
  extern int multibyte_form_length P_ ((const unsigned char *, int));
! extern int str_cmpchar_id P_ ((const unsigned char *, int));
  extern int get_charset_id P_ ((Lisp_Object));
  extern int cmpchar_component P_ ((int, int, int));
  extern int find_charset_in_str P_ ((unsigned char *, int, int *,
--- 814,822 ----
  					 int));
  extern int non_ascii_char_to_string P_ ((int, unsigned char *, unsigned char **));
  extern int multibyte_form_length P_ ((const unsigned char *, int));
! extern int str_cmpchar_id P_ ((const unsigned char *, int, int));
! extern void register_composite_chars_region P_ ((int, int, int, int));
! extern void register_composite_chars_string P_ ((Lisp_Object));
  extern int get_charset_id P_ ((Lisp_Object));
  extern int cmpchar_component P_ ((int, int, int));
  extern int find_charset_in_str P_ ((unsigned char *, int, int *,
Index: src/indent.c
===================================================================
RCS file: /project/mule/cvsroot/emacs-20.4/src/indent.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 indent.c
*** indent.c	1999/08/11 00:12:48	1.1.1.1
--- indent.c	1999/09/14 11:48:06
***************
*** 284,290 ****
      									\
      if (c == LEADING_CODE_COMPOSITION)					\
        {									\
! 	int id = str_cmpchar_id (p, pend - p);				\
  	int ch = MAKE_COMPOSITE_CHAR (id);				\
  									\
  	if (id >= 0)							\
--- 284,290 ----
      									\
      if (c == LEADING_CODE_COMPOSITION)					\
        {									\
! 	int id = str_cmpchar_id (p, pend - p, 0);			\
  	int ch = MAKE_COMPOSITE_CHAR (id);				\
  									\
  	if (id >= 0)							\
Index: src/insdel.c
===================================================================
RCS file: /project/mule/cvsroot/emacs-20.4/src/insdel.c,v
retrieving revision 1.1.1.1
diff -c -r1.1.1.1 insdel.c
*** insdel.c	1999/08/11 00:12:48	1.1.1.1
--- insdel.c	1999/09/16 02:17:43
***************
*** 1174,1179 ****
--- 1174,1181 ----
  
      if (combined_before_bytes)
        combine_bytes (pos, pos_byte, combined_before_bytes);
+ 
+     register_composite_chars_region (pos, pos_byte, PT, PT_BYTE);
    }
  
    CHECK_MARKERS ();
***************
*** 1730,1735 ****
--- 1732,1740 ----
        }
      if (combined_before_bytes)
        combine_bytes (from, from_byte, combined_before_bytes);
+ 
+     register_composite_chars_region (from, from_byte,
+ 				     from + len, from_byte + len_byte);
    }
  
    /* As byte combining will decrease Z, we must check this again. */