summaryrefslogtreecommitdiff
path: root/lisp/diff-mode.el
diff options
context:
space:
mode:
authorThien-Thi Nguyen <ttn@gnuvola.org>2007-09-11 07:00:04 +0000
committerThien-Thi Nguyen <ttn@gnuvola.org>2007-09-11 07:00:04 +0000
commit7fb6ce6ef14a83c1aa62d2a4cb974bfddf9d20e0 (patch)
tree047f4503e17ed925e9ecb90c728ea9ed7b465360 /lisp/diff-mode.el
parent33ce5f113d09beeed039b9fac265ef974224c342 (diff)
downloademacs-7fb6ce6ef14a83c1aa62d2a4cb974bfddf9d20e0.tar.gz
emacs-7fb6ce6ef14a83c1aa62d2a4cb974bfddf9d20e0.tar.bz2
emacs-7fb6ce6ef14a83c1aa62d2a4cb974bfddf9d20e0.zip
(diff-sanity-check-hunk): Also accept single-line hunks.
Diffstat (limited to 'lisp/diff-mode.el')
-rw-r--r--lisp/diff-mode.el22
1 files changed, 13 insertions, 9 deletions
diff --git a/lisp/diff-mode.el b/lisp/diff-mode.el
index 68f7995a494..d4244126f23 100644
--- a/lisp/diff-mode.el
+++ b/lisp/diff-mode.el
@@ -1217,26 +1217,30 @@ Only works for unified diffs."
;; 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)