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

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

Re: Buffer corruption with jka-compr.el and revert-buffer


From: Stephen J. Turnbull
Subject: Re: Buffer corruption with jka-compr.el and revert-buffer
Date: Mon, 26 May 2003 18:36:27 +0900
User-agent: Gnus/5.1001 (Gnus v5.10.1) XEmacs/21.5 (carrot, linux)

Thanks for your report, Martin.

>>>>> "Martin" == Martin Schwenke <martin@meltin.net> writes:

    Martin> I've had a look at revert-buffer and nothing jumps out.
    Martin> I've also had a look at jka-compr.el and I've run away
    Martin> screaming...  I suspect it would be a lot simpler without
    Martin> all that coding system stuff...  :-)

The REPLACE semantics of j-c-insert-file-contents were simply wrong.

This fixes that, and a couple of minor bugs like the truncated
argument list and the missing docstring.  It's not really ready for
prime time; see the #### comments.  However, it's strictly better than
the existing code in XEmacs, and jka-compr will probably be obsolete
in XEmacs 21.5.

Caveat Emacsers.  I have no idea whether this is correct for GNU Emacs.

Index: xemacs-packages/os-utils/ChangeLog
===================================================================
RCS file: /pack/xemacscvs/XEmacs/packages/xemacs-packages/os-utils/ChangeLog,v
retrieving revision 1.38
diff -u -U0 -r1.38 ChangeLog
--- xemacs-packages/os-utils/ChangeLog  21 Mar 2003 05:51:13 -0000      1.38
+++ xemacs-packages/os-utils/ChangeLog  26 May 2003 09:24:01 -0000
@@ -0,0 +1,5 @@
+2003-05-26  Stephen J. Turnbull  <stephen@xemacs.org>
+
+       * jka-compr.el (jka-compr-insert-file-contents): New docstring.
+       Implement REPLACE argument correctly.
+

Index: xemacs-packages/os-utils/jka-compr.el
===================================================================
RCS file: 
/pack/xemacscvs/XEmacs/packages/xemacs-packages/os-utils/jka-compr.el,v
retrieving revision 1.8
diff -u -r1.8 jka-compr.el
--- xemacs-packages/os-utils/jka-compr.el       27 Mar 2000 13:11:15 -0000      
1.8
+++ xemacs-packages/os-utils/jka-compr.el       26 May 2003 09:24:08 -0000
@@ -517,7 +517,31 @@
                                          )))))
 
 
-(defun jka-compr-insert-file-contents (file &optional visit beg end replace)
+;; #### Should error or warn if the ignore-me arguments are supplied.
+(defun jka-compr-insert-file-contents (file &optional visit beg end replace
+                                      ignore-me ignore-me-too)
+  "Insert contents of FILE in current buffer after point.
+Returns list of absolute file name and length of data inserted.
+
+If second argument VISIT is non-nil, the buffer's visited filename
+and last save file modtime are set, and it is marked unmodified.
+If visiting and the file does not exist, visiting is completed
+before the error is signaled.
+
+The optional third and fourth arguments START and END
+specify what portion of the file to insert.
+If VISIT is non-nil, START and END must be nil.
+If optional fifth argument REPLACE is non-nil,
+it means replace the current buffer contents (in the accessible portion)
+with the file contents.  This is better than simply deleting and inserting
+the whole thing because (1) it preserves some marker positions
+and (2) it puts less data in the undo list.  (#### Is (2) true?)
+
+Coding system arguments are completely ignored (see documentation of the
+6th and 7th arguments to `insert-file-contents').  The coding system is set
+to 'undecided unless `coding-system-for-read' is bound.  WARNING: That means
+this function is badly broken under Mule.  Use jka-compr at your own risk
+in Mule Emacsen."
   (barf-if-buffer-read-only)
 
   (and (or beg end)
@@ -571,7 +594,7 @@
 
                    (progn
                      (if replace
-                         (goto-char (point-min)))
+                         (delete-region (point-min) (point-max)))
                      (setq start (point))
                      (if (or beg end)
                          (jka-compr-partial-uncompress uncompress-program
@@ -595,12 +618,6 @@
                                                  t
                                                  nil
                                                  uncompress-args)))
-                     (setq size (- (point) start))
-                     (if replace
-                         (let* ((del-beg (point))
-                                (del-end (+ del-beg size)))
-                           (delete-region del-beg
-                                          (min del-end (point-max)))))
                      (goto-char start))
                  (error
                   (if (and (eq (car error-code) 'file-error)



-- 
Institute of Policy and Planning Sciences     http://turnbull.sk.tsukuba.ac.jp
University of Tsukuba                    Tennodai 1-1-1 Tsukuba 305-8573 JAPAN
               Ask not how you can "do" free software business;
              ask what your business can "do for" free software.




reply via email to

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