File: whitespace-readonly-infloop.diff

package info (click to toggle)
emacs21 21.4a%2B1-3etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 59,104 kB
  • ctags: 58,909
  • sloc: lisp: 493,229; ansic: 237,175; xml: 4,262; sh: 4,109; makefile: 2,479; perl: 1,069; cs: 776; asm: 254; csh: 9; sed: 4
file content (67 lines) | stat: -rw-r--r-- 2,239 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
* Emacs should no longer segfault sometimes when kill-read-only is set to t.
  Patch: whitespace-readonly-infloop.diff
  Author: Richard Stallman <rms@gnu.org>
  Provided-by: Romain Francoise <rfrancoise@debian.org>
  Applied-by: Jerome Marant <jerome@debian.org>
  Date: Tue, 09 Aug 2005 16:47:25 +0200
  Status: has been incorporated upstream

  Emacs should no longer go in to an infinite loop and then segfault
  under some conditions when kill-read-only is set to t.

diff -urNad --exclude=CVS --exclude=.svn ./lisp/whitespace.el /tmp/dpep-work.Gk47lX/emacs21-21.4a/lisp/whitespace.el
--- ./lisp/whitespace.el	2001-08-20 22:56:08.000000000 +0200
+++ /tmp/dpep-work.Gk47lX/emacs21-21.4a/lisp/whitespace.el	2005-08-09 16:45:25.000000000 +0200
@@ -504,17 +504,9 @@
 (defun whitespace-buffer-leading-cleanup ()
   "Remove any empty lines at the top of the file."
   (save-excursion
-    (let ((pmin nil)
-	  (pmax nil))
-      (goto-char (point-min))
-      (beginning-of-line)
-      (setq pmin (point))
-      (end-of-line)
-      (setq pmax (point))
-      (if (equal pmin pmax)
-	  (progn
-	    (kill-line)
-	    (whitespace-buffer-leading-cleanup))))))
+    (goto-char (point-min))
+    (skip-chars-forward "\n")
+    (delete-region (point-min) (point))))
 
 (defun whitespace-buffer-trailing ()
   "Check to see if are is more than one empty line at the bottom."
@@ -541,26 +533,11 @@
 (defun whitespace-buffer-trailing-cleanup ()
   "Delete all the empty lines at the bottom."
   (save-excursion
-    (let ((pmin nil)
-	  (pmax nil))
-      (goto-char (point-max))
-      (beginning-of-line)
-      (setq pmin (point))
-      (end-of-line)
-      (setq pmax (point))
-      (if (equal pmin pmax)
-	  (progn
-	    (goto-char (1- pmin))
-	    (beginning-of-line)
-	    (setq pmin (point))
-	    (end-of-line)
-	    (setq pmax (point))
-	    (if (equal pmin pmax)
-		(progn
-		  (goto-char (1- (point-max)))
-		  (beginning-of-line)
-		  (kill-line)
-		  (whitespace-buffer-trailing-cleanup))))))))
+    (goto-char (point-max))
+    (skip-chars-backward "\n")
+    (if (not (bolp))
+	(forward-char 1))
+    (delete-region (point) (point-max))))
 
 (defun whitespace-buffer-search (regexp)
   "Search for any given whitespace REGEXP."