changeset 84468:f3735c349e01

(diff-sanity-check-hunk): Also accept single-line hunks.
author Thien-Thi Nguyen <ttn@gnuvola.org>
date Tue, 11 Sep 2007 06:59:13 +0000
parents 2011b0174ead
children 2b16ed56368e
files lisp/diff-mode.el
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/diff-mode.el	Tue Sep 11 04:46:49 2007 +0000
+++ b/lisp/diff-mode.el	Tue Sep 11 06:59:13 2007 +0000
@@ -1217,26 +1217,30 @@
 
        ;; A context diff.
        ((eq (char-after) ?*)
-        (if (not (looking-at "\\*\\{15\\}\\(?: .*\\)?\n\\*\\*\\* \\([0-9]+\\),\\([0-9]+\\) \\*\\*\\*\\*"))
+        (if (not (looking-at "\\*\\{15\\}\\(?: .*\\)?\n\\*\\*\\* \\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? \\*\\*\\*\\*"))
             (error "Unrecognized context diff first hunk header format")
           (forward-line 2)
           (diff-sanity-check-context-hunk-half
-           (1+ (- (string-to-number (match-string 2))
-                  (string-to-number (match-string 1)))))
-          (if (not (looking-at "--- \\([0-9]+\\),\\([0-9]+\\) ----$"))
+	   (if (match-string 2)
+	       (1+ (- (string-to-number (match-string 2))
+		      (string-to-number (match-string 1))))
+	     1))
+          (if (not (looking-at "--- \\([0-9]+\\)\\(?:,\\([0-9]+\\)\\)? ----$"))
               (error "Unrecognized context diff second hunk header format")
             (forward-line)
             (diff-sanity-check-context-hunk-half
-             (1+ (- (string-to-number (match-string 2))
-                    (string-to-number (match-string 1))))))))
+	     (if (match-string 2)
+		 (1+ (- (string-to-number (match-string 2))
+			(string-to-number (match-string 1))))
+	       1)))))
 
        ;; A unified diff.
        ((eq (char-after) ?@)
         (if (not (looking-at
-                  "@@ -[0-9]+,\\([0-9]+\\) \\+[0-9]+,\\([0-9]+\\) @@"))
+                  "@@ -[0-9]+\\(?:,\\([0-9]+\\)\\)? \\+[0-9]+\\(?:,\\([0-9]+\\)\\)? @@"))
             (error "Unrecognized unified diff hunk header format")
-          (let ((before (string-to-number (match-string 1)))
-                (after (string-to-number (match-string 2))))
+          (let ((before (if (match-string 1) (string-to-number (match-string 1)) 1))
+                (after (if (match-string 2) (string-to-number (match-string 2)) 1)))
             (forward-line)
             (while
                 (case (char-after)