]> code.delx.au - gnu-emacs/commitdiff
(Fmd5): If OBJECT is a buffer different from the current
authorKenichi Handa <handa@m17n.org>
Fri, 23 Jan 2004 00:14:48 +0000 (00:14 +0000)
committerKenichi Handa <handa@m17n.org>
Fri, 23 Jan 2004 00:14:48 +0000 (00:14 +0000)
one, set buffer to OBJECT temporarily.

src/ChangeLog
src/fns.c

index 3f6f23e139554c8ec4ffa6c6ad8f8581cdd716e2..a15f25fbde859d020b7e3531bd3c9357fa7b664b 100644 (file)
@@ -1,3 +1,8 @@
+2004-01-23  Kenichi Handa  <handa@m17n.org>
+
+       * fns.c (Fmd5): If OBJECT is a buffer different from the current
+       one, set buffer to OBJECT temporarily.
+
 2004-01-21  Stefan Monnier  <monnier@iro.umontreal.ca>
 
        * keyboard.c (kbd_buffer_gcpro): Remove.
index ff40c706edd372fc642bc404bdec3533c97b245f..6383e09302b0701af3b87e4ad5ca57164fa6733a 100644 (file)
--- a/src/fns.c
+++ b/src/fns.c
@@ -5454,12 +5454,18 @@ guesswork fails.  Normally, an error is signaled in such case.  */)
     }
   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 = BUF_BEGV (bp);
+       b = BEGV;
       else
        {
          CHECK_NUMBER_COERCE_MARKER (start);
@@ -5467,7 +5473,7 @@ guesswork fails.  Normally, an error is signaled in such case.  */)
        }
 
       if (NILP (end))
-       e = BUF_ZV (bp);
+       e = ZV;
       else
        {
          CHECK_NUMBER_COERCE_MARKER (end);
@@ -5477,7 +5483,7 @@ guesswork fails.  Normally, an error is signaled in such case.  */)
       if (b > e)
        temp = b, b = e, e = temp;
 
-      if (!(BUF_BEGV (bp) <= b && e <= BUF_ZV (bp)))
+      if (!(BEGV <= b && e <= ZV))
        args_out_of_range (start, end);
 
       if (NILP (coding_system))
@@ -5544,6 +5550,11 @@ guesswork fails.  Normally, an error is signaled in such case.  */)
        }
 
       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);