bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: address@hidden: Re: Crash calling md5 for a list of buffers]


From: Kenichi Handa
Subject: Re: address@hidden: Re: Crash calling md5 for a list of buffers]
Date: Fri, 23 Jan 2004 09:22:45 +0900 (JST)
User-agent: SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.2 Emacs/21.3 (sparc-sun-solaris2.6) MULE/5.0 (SAKAKI)

In article <address@hidden>, Richard Stallman <address@hidden> writes:

> Can you take a look at this?
> ------- Start of forwarded message -------
> To: address@hidden
> From: Kevin Rodgers <address@hidden>
> Newsgroups: gnu.emacs.bug
> Date: Wed, 21 Jan 2004 10:20:41 -0700
[...]
> Subject: Re: Crash calling md5 for a list of buffers
[...]
>>  Try to eval (mapcar '(lambda (b) (md5 b nil nil 'raw-text)) (buffer-list)).
>>  (mapcar 'md5 (buffer-list)) doesn't work for all buffers (really I don't 
>>  understand why - probably the coding system determined automagically is
>>  not always valid for Fmd5).

I found that function md5 (in fns.c) doesn't pay attention
to the case that the current buffer is different from OBJECT
arg.  Coding system has nothing to do with this bug.  As
I've just committed the atttached change, please try again.
As this bug is serious, I committed it also to RC branch.

> There is something screwy with that file that causes Emacs to
> think it has 1 more character (459097) than it really does (459096).

That's normal because buffer position starts from 1, not 0.

---
Ken'ichi HANDA
address@hidden

2004-01-23  Kenichi Handa  <address@hidden>

        * fns.c (Fmd5): If OBJECT is a buffer different from the current
        one, set buffer to OBJECT temporarily.

Index: fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/fns.c,v
retrieving revision 1.354
diff -u -c -r1.354 fns.c
cvs server: conflicting specifications of output style
*** fns.c       29 Dec 2003 13:51:54 -0000      1.354
--- fns.c       23 Jan 2004 00:09:20 -0000
***************
*** 5454,5465 ****
      }
    else
      {
        CHECK_BUFFER (object);
  
        bp = XBUFFER (object);
  
        if (NILP (start))
!       b = BUF_BEGV (bp);
        else
        {
          CHECK_NUMBER_COERCE_MARKER (start);
--- 5454,5471 ----
      }
    else
      {
+       struct buffer *prev = current_buffer;
+ 
+       record_unwind_protect (Fset_buffer, Fcurrent_buffer ());
+ 
        CHECK_BUFFER (object);
  
        bp = XBUFFER (object);
+       if (bp != current_buffer)
+       set_buffer_internal (bp);
  
        if (NILP (start))
!       b = BEGV;
        else
        {
          CHECK_NUMBER_COERCE_MARKER (start);
***************
*** 5467,5473 ****
        }
  
        if (NILP (end))
!       e = BUF_ZV (bp);
        else
        {
          CHECK_NUMBER_COERCE_MARKER (end);
--- 5473,5479 ----
        }
  
        if (NILP (end))
!       e = ZV;
        else
        {
          CHECK_NUMBER_COERCE_MARKER (end);
***************
*** 5477,5483 ****
        if (b > e)
        temp = b, b = e, e = temp;
  
!       if (!(BUF_BEGV (bp) <= b && e <= BUF_ZV (bp)))
        args_out_of_range (start, end);
  
        if (NILP (coding_system))
--- 5483,5489 ----
        if (b > e)
        temp = b, b = e, e = temp;
  
!       if (!(BEGV <= b && e <= ZV))
        args_out_of_range (start, end);
  
        if (NILP (coding_system))
***************
*** 5544,5549 ****
--- 5550,5560 ----
        }
  
        object = make_buffer_string (b, e, 0);
+       if (prev != current_buffer)
+       set_buffer_internal (prev);
+       /* Discard the unwind protect for recovering the current
+        buffer.  */
+       specpdl_ptr--;
  
        if (STRING_MULTIBYTE (object))
        object = code_convert_string1 (object, coding_system, Qnil, 1);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]