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

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



YAMAGUCHI Shuhei <yamagus@xxxxxxxxxxxxxxxxxxxxxxx> writes:
(B
(B> >>>>> In [meadow-develop : No.1471] 
(B> >>>>>	Miyashita Hisashi($B5\2<(B $B>0(B:HIMI) <himi@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
(B> 
(B> himi> $B$4$a$s$J$5$$!"B?J,%P%$%J%j$N:n$jD>$7J}$r4V0c$($?$s$@$H;W$$$^$9!#(B;_;
(B> himi> $B$"!"$3$l$+$iK;$7$$$+$i!"Lk$^$G$K$O(Bswitch-frame$B4XO"$N%Q%C%A$H6&$K(B
(B> himi> ML$B$KN.$7$^$9!#(B
(B> 
(B> $BN;2r$7$^$7$?!#(B :-)
(B
(Bftp://ftp.m17n.org/pub/mule/Windows/beta
(B
$B$K(Btemacs-990920.exe.gz$B$rCV$-$^$7$?!#(B
(B
(B1.06b3$B$+$i$N%Q%C%A$O2<$KIU$1$F$*$-$^$9!#(B
(B
(B> $BSwSSSUS9SUSySbSwS~SQS/S;S5S:SySSyNS[SSSSSvShSZ(B? $BP5(B uvzv $BSdSD(B
(B
$B$3$&$$$&$3$H$O4?7^$7$^$9!#;d2K$J$$$7!#(B^^;;;
$B$I$s$I$s$$$m$$$m$d$C$F$/$@$5$$!#(B
(B
(Bfrom himi
Index: ChangeLog.Meadow
===================================================================
RCS file: g:/repdev/Meadow/src/ChangeLog.Meadow,v
retrieving revision 1.20
retrieving revision 1.21
diff -c -r1.20 -r1.21
*** ChangeLog.Meadow	1999/09/12 09:45:21	1.20
--- ChangeLog.Meadow	1999/09/20 13:34:43	1.21
***************
*** 1,3 ****
--- 1,56 ----
+ 1999-09-20  Miyashita Hisashi  <himi@xxxxxxxxxxxxxxxxxxxxxxxxx>
+ 
+ 	* mw32fns.c (Fx_create_frame):
+ 	Don't call Fselect_frame() on a newly created frame.
+ 
+ 	* keyboard.c (make_lispy_event[meadow_private_event]):
+ 	Currently, only return Qnil.
+ 
+ 	* mw32term.c (W32read_socket[WM_EMACS_ACTIVATE]):
+ 	Enable this message.  In order to raise switch-frame,
+ 	set meadow_private_event to event queue.
+ 
+ 	* termhooks.h (event_kind):
+ 	New event type for Meadow.
+ 
+ 1999-09-19  Miyashita Hisashi  <himi@xxxxxxxxxxxxxxxxxxxxxxxxx>
+ 
+ 	* charset.c (str_cmpchar_id): 
+ 	Before xmalloc(), copy str to buf where is safe against
+ 	memory realocation caused by r_alloc.  After cmpcharp->data is
+ 	prepared by xmalloc(), copy buf to here.
+ 
+ 1999-09-17  Kenichi Handa  <handa@xxxxxxxxx>
+ 
+ 	* insdel.c (insert_from_string_1): Comparing the current gap size
+ 	with outgoing_nbytes to check if we must enlange the gap.
+ 
+ 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.
+ 
  1999-09-09  Miyashita Hisashi  <himi@xxxxxxxxxxxxxxxxxxxxxxxxx>
  
  	* mw32fns.c (Fx_create_frame):
Index: alloc.c
===================================================================
RCS file: g:/repdev/Meadow/src/alloc.c,v
retrieving revision 1.1.1.3
retrieving revision 1.2
diff -c -r1.1.1.3 -r1.2
*** alloc.c	1999/02/04 06:42:32	1.1.1.3
--- alloc.c	1999/09/20 13:26:29	1.2
***************
*** 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: buffer.c
===================================================================
RCS file: g:/repdev/Meadow/src/buffer.c,v
retrieving revision 1.1.1.5
retrieving revision 1.2
diff -c -r1.1.1.5 -r1.2
*** buffer.c	1999/07/17 16:18:24	1.1.1.5
--- buffer.c	1999/09/20 13:26:31	1.2
***************
*** 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: charset.c
===================================================================
RCS file: g:/repdev/Meadow/src/charset.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -c -r1.12 -r1.13
*** charset.c	1999/07/28 01:27:54	1.12
--- charset.c	1999/09/20 13:26:32	1.13
***************
*** 221,227 ****
  
        if (c == LEADING_CODE_COMPOSITION)
  	{
! 	  int cmpchar_id = str_cmpchar_id (begp, bytes);
  
  	  if (cmpchar_id >= 0)
  	    {
--- 221,227 ----
  
        if (c == LEADING_CODE_COMPOSITION)
  	{
! 	  int cmpchar_id = str_cmpchar_id (begp, bytes, 0);
  
  	  if (cmpchar_id >= 0)
  	    {
***************
*** 290,296 ****
  
    if (cs == LEADING_CODE_COMPOSITION)
      {
!       int cmpchar_id = str_cmpchar_id (str - 1, len);
  
        if (cmpchar_id < 0)
  	return -1;
--- 290,296 ----
  
    if (cs == LEADING_CODE_COMPOSITION)
      {
!       int cmpchar_id = str_cmpchar_id (str - 1, len, 0);
  
        if (cmpchar_id < 0)
  	return -1;
***************
*** 782,788 ****
        
        if (c == LEADING_CODE_COMPOSITION)
  	{
! 	  int cmpchar_id = str_cmpchar_id (str, len);
  	  GLYPH *glyph;
  
  	  if (cmpchar_id >= 0)
--- 782,788 ----
        
        if (c == LEADING_CODE_COMPOSITION)
  	{
! 	  int cmpchar_id = str_cmpchar_id (str, len, 0);
  	  GLYPH *glyph;
  
  	  if (cmpchar_id >= 0)
***************
*** 1265,1271 ****
      {
        if (*str == LEADING_CODE_COMPOSITION)
  	{
! 	  int id = str_cmpchar_id (str, endp - str);
  
  	  if (id < 0)
  	    {
--- 1265,1271 ----
      {
        if (*str == LEADING_CODE_COMPOSITION)
  	{
! 	  int id = str_cmpchar_id (str, endp - str, 0);
  
  	  if (id < 0)
  	    {
***************
*** 1490,1501 ****
  
  /* 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;
--- 1490,1503 ----
  
  /* 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;
***************
*** 1552,1557 ****
--- 1554,1569 ----
  	  return CMPCHAR_HASH_CMPCHAR_ID (hashp, i);
        }
  
+   if (!registerp)
+     return -1;
+ 
+   /* First we must copy str data to safe area against memory
+      reallocation because str would be made invalid by succeeding
+      xmalloc()s when str points r_alloced memory, which is usually
+      buffer memory.  From now on, we must not trust str. */
+   buf = (unsigned char*) alloca(sizeof(unsigned char) * len);
+   bcopy (str, buf, len);
+ 
    /* 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.  */
***************
*** 1598,1604 ****
  
    cmpcharp->len = len;
    cmpcharp->data = (unsigned char *) xmalloc (len + 1);
!   bcopy (str, cmpcharp->data, len);
    cmpcharp->data[len] = 0;
    cmpcharp->glyph_len = chars;
    cmpcharp->glyph = (GLYPH *) xmalloc (sizeof (GLYPH) * chars);
--- 1610,1616 ----
  
    cmpcharp->len = len;
    cmpcharp->data = (unsigned char *) xmalloc (len + 1);
!   bcopy (buf, cmpcharp->data, len);
    cmpcharp->data[len] = 0;
    cmpcharp->glyph_len = chars;
    cmpcharp->glyph = (GLYPH *) xmalloc (sizeof (GLYPH) * chars);
***************
*** 1706,1711 ****
--- 1718,1802 ----
    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). */
***************
*** 1849,1855 ****
  	    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);
--- 1940,1946 ----
  	    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: charset.h
===================================================================
RCS file: g:/repdev/Meadow/src/charset.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -c -r1.4 -r1.5
*** charset.h	1999/07/17 13:32:14	1.4
--- charset.h	1999/09/20 13:26:34	1.5
***************
*** 762,767 ****
--- 762,771 ----
    /* Multi-byte form of the composite character.  */
    unsigned char *data;
  
+   /* 1 if all information (GLYPH, CMP_RULE, and COL_OFFSET) has
+      already been filled.  */
+   int filled_p;
+ 
    /* Length of glyph codes.  */
    int glyph_len;
  
***************
*** 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: indent.c
===================================================================
RCS file: g:/repdev/Meadow/src/indent.c,v
retrieving revision 1.1.1.4
retrieving revision 1.2
diff -c -r1.1.1.4 -r1.2
*** indent.c	1999/07/17 16:18:52	1.1.1.4
--- indent.c	1999/09/20 13:26:36	1.2
***************
*** 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: insdel.c
===================================================================
RCS file: g:/repdev/Meadow/src/insdel.c,v
retrieving revision 1.1.1.5
retrieving revision 1.2
diff -c -r1.1.1.5 -r1.2
*** insdel.c	1999/04/26 00:13:49	1.1.1.5
--- insdel.c	1999/09/20 13:26:37	1.2
***************
*** 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 ();
***************
*** 1250,1256 ****
  
    if (PT != GPT)
      move_gap_both (PT, PT_BYTE);
!   if (GAP_SIZE < nbytes)
      make_gap (outgoing_nbytes - GAP_SIZE);
    UNGCPRO;
  
--- 1252,1258 ----
  
    if (PT != GPT)
      move_gap_both (PT, PT_BYTE);
!   if (GAP_SIZE < outgoing_nbytes)
      make_gap (outgoing_nbytes - GAP_SIZE);
    UNGCPRO;
  
***************
*** 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. */
Index: keyboard.c
===================================================================
RCS file: g:/repdev/Meadow/src/keyboard.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -c -r1.8 -r1.9
*** keyboard.c	1999/09/08 01:15:36	1.8
--- keyboard.c	1999/09/20 13:34:17	1.9
***************
*** 4691,4696 ****
--- 4691,4701 ----
        return XCONS (event->frame_or_window)->cdr;
  #endif
  
+ #ifdef MEADOW
+     case meadow_private_event:
+       return Qnil;
+ #endif
+ 
      case user_signal:
        /* A user signal.  */
        return *lispy_user_signals[event->code];
Index: mw32fns.c
===================================================================
RCS file: g:/repdev/Meadow/src/mw32fns.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -c -r1.16 -r1.17
*** mw32fns.c	1999/09/12 09:45:17	1.16
--- mw32fns.c	1999/09/20 13:32:59	1.17
***************
*** 2779,2791 ****
  
      if (EQ (visibility, Qicon))
        x_iconify_frame (f);
!     else {
  	x_make_frame_visible (f);
  	w32_new_focus_frame (f);
  	SetForegroundWindow (FRAME_W32_WINDOW(f));
! 	Fselect_frame(frame, Qnil);
! 	/* To switch selected-frame  by himi */
!     }
    }
  
    return unbind_to (count, frame);
--- 2779,2790 ----
  
      if (EQ (visibility, Qicon))
        x_iconify_frame (f);
!     else
!       {
  	x_make_frame_visible (f);
  	w32_new_focus_frame (f);
  	SetForegroundWindow (FRAME_W32_WINDOW(f));
!       }
    }
  
    return unbind_to (count, frame);
Index: mw32term.c
===================================================================
RCS file: g:/repdev/Meadow/src/mw32term.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -c -r1.11 -r1.12
*** mw32term.c	1999/09/08 01:17:41	1.11
--- mw32term.c	1999/09/20 13:33:40	1.12
***************
*** 3778,3783 ****
--- 3778,3794 ----
  	  }
  
  	case WM_EMACS_ACTIVATE:
+ 	  if (f && numchars > 0)
+ 	    {
+ 	      bufp->kind = meadow_private_event;
+ 	      bufp->code = 0;
+ 	      bufp->modifiers = 0;
+ 	      XSETFRAME (bufp->frame_or_window, f);
+ 	      bufp->timestamp = msg.time;
+ 	      bufp++;
+ 	      numchars--;
+ 	      count++;
+ 	    }
  	  break;
  
  	case WM_COMMAND:
Index: termhooks.h
===================================================================
RCS file: g:/repdev/Meadow/src/termhooks.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -c -r1.3 -r1.4
*** termhooks.h	1999/04/25 13:35:36	1.3
--- termhooks.h	1999/09/20 13:33:59	1.4
***************
*** 303,308 ****
--- 303,313 ----
  				   the filenames of the dropped files.
  				   .timestamp gives a timestamp (in
  				   milliseconds) for the click.  */
+ #ifdef MEADOW
+   meadow_private_event,         /* Meadow uses this event for private use.
+ 				   At present, this is used for generating
+ 				   switch_frame */
+ #endif
    user_signal			/* A user signal.
  				   .code is a number identifying it,
  				   index into lispy_user_signals.  */