aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/calendar
diff options
context:
space:
mode:
authorUlf Jasper2015-12-05 16:55:49 +0100
committerUlf Jasper2015-12-05 17:00:44 +0100
commit0daba4888771e29f2edf170216adaf3d33040bea (patch)
treeec8f5223cc06b8773bca95ac42c4194ec53a612a /lisp/calendar
parent21c042bc6d42ad0d1562a1ac259025b72fcd4e3c (diff)
downloademacs-0daba4888771e29f2edf170216adaf3d33040bea.tar.gz
emacs-0daba4888771e29f2edf170216adaf3d33040bea.zip
Fix Bug#22092.
* lisp/calendar/icalendar.el (icalendar--get-unfolded-buffer): Clean up inconsistent line endings. (Bug#22092) (icalendar--clean-up-line-endings): New. * test/automated/icalendar-tests.el (icalendar-real-world): Add test for Bug#22092.
Diffstat (limited to 'lisp/calendar')
-rw-r--r--lisp/calendar/icalendar.el13
1 files changed, 12 insertions, 1 deletions
diff --git a/lisp/calendar/icalendar.el b/lisp/calendar/icalendar.el
index 0c7a0636b08..ca6669d0c40 100644
--- a/lisp/calendar/icalendar.el
+++ b/lisp/calendar/icalendar.el
@@ -321,18 +321,29 @@ other sexp entries are enumerated in any case."
321 "Return a new buffer containing the unfolded contents of a buffer. 321 "Return a new buffer containing the unfolded contents of a buffer.
322Folding is the iCalendar way of wrapping long lines. In the 322Folding is the iCalendar way of wrapping long lines. In the
323created buffer all occurrences of CR LF BLANK are replaced by the 323created buffer all occurrences of CR LF BLANK are replaced by the
324empty string. Argument FOLDED-ICAL-BUFFER is the unfolded input 324empty string. Argument FOLDED-ICAL-BUFFER is the folded input
325buffer." 325buffer."
326 (let ((unfolded-buffer (get-buffer-create " *icalendar-work*"))) 326 (let ((unfolded-buffer (get-buffer-create " *icalendar-work*")))
327 (save-current-buffer 327 (save-current-buffer
328 (set-buffer unfolded-buffer) 328 (set-buffer unfolded-buffer)
329 (erase-buffer) 329 (erase-buffer)
330 (insert-buffer-substring folded-ical-buffer) 330 (insert-buffer-substring folded-ical-buffer)
331 (icalendar--clean-up-line-endings)
331 (goto-char (point-min)) 332 (goto-char (point-min))
332 (while (re-search-forward "\r?\n[ \t]" nil t) 333 (while (re-search-forward "\r?\n[ \t]" nil t)
333 (replace-match "" nil nil))) 334 (replace-match "" nil nil)))
334 unfolded-buffer)) 335 unfolded-buffer))
335 336
337(defun icalendar--clean-up-line-endings ()
338 "Replace DOS- and MAC-like line endings with unix line endings.
339All occurrences of (CR LF) and (LF CF) are replaced with LF in
340the current buffer. This is necessary in buffers which contain a
341mix of different line endings."
342 (save-excursion
343 (goto-char (point-min))
344 (while (re-search-forward "\r\n\\|\n\r" nil t)
345 (replace-match "\n" nil nil))))
346
336(defsubst icalendar--rris (regexp rep string &optional fixedcase literal) 347(defsubst icalendar--rris (regexp rep string &optional fixedcase literal)
337 "Replace regular expression in string. 348 "Replace regular expression in string.
338Pass arguments REGEXP REP STRING FIXEDCASE LITERAL to 349Pass arguments REGEXP REP STRING FIXEDCASE LITERAL to