From e8a11db943dfc7a469a761f98d606a4072a6ca43 Mon Sep 17 00:00:00 2001 From: Glenn Morris Date: Mon, 23 Feb 2015 23:13:49 -0800 Subject: [PATCH] f90.el: add some support for continued strings without leading '&' * lisp/progmodes/f90.el (f90-beginning-of-subprogram) (f90-end-of-subprogram, f90-match-end): Handle continued strings where the continuation does not start with "&" and happens to match our regexp. * test/automated/f90.el (f90-test-bug-19809): New test. Fixes: debbugs:19809 --- lisp/ChangeLog | 7 +++++++ lisp/progmodes/f90.el | 14 +++++++++++--- test/ChangeLog | 4 ++++ test/automated/f90.el | 16 ++++++++++++++++ 4 files changed, 38 insertions(+), 3 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 7e7bbb7486a..165c1ce96de 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,10 @@ +2015-02-24 Glenn Morris + + * progmodes/f90.el (f90-beginning-of-subprogram) + (f90-end-of-subprogram, f90-match-end): + Handle continued strings where the continuation does not start + with "&" and happens to match our regexp. (Bug#19809) + 2015-02-24 Bozhidar Batsov * comint.el (comint-clear-buffer): New command. diff --git a/lisp/progmodes/f90.el b/lisp/progmodes/f90.el index b923819ebb3..6264d3b7b82 100644 --- a/lisp/progmodes/f90.el +++ b/lisp/progmodes/f90.el @@ -1634,7 +1634,10 @@ Return (TYPE NAME), or nil if not found." (re-search-backward f90-program-block-re nil 'move)) (beginning-of-line) (skip-chars-forward " \t0-9") - (cond ((setq matching-beg (f90-looking-at-program-block-start)) + ;; Check if in string in case using non-standard feature where + ;; continued strings do not need "&" at start of continuations. + (cond ((f90-in-string)) + ((setq matching-beg (f90-looking-at-program-block-start)) (setq count (1- count))) ((f90-looking-at-program-block-end) (setq count (1+ count))))) @@ -1659,7 +1662,8 @@ Return (TYPE NAME), or nil if not found." (re-search-forward f90-program-block-re nil 'move)) (beginning-of-line) (skip-chars-forward " \t0-9") - (cond ((f90-looking-at-program-block-start) + (cond ((f90-in-string)) + ((f90-looking-at-program-block-start) (setq count (1+ count))) ((setq matching-end (f90-looking-at-program-block-end)) (setq count (1- count)))) @@ -2199,8 +2203,12 @@ Leave point at the end of line." (end-point (point)) (case-fold-search t) matching-beg beg-name end-name beg-block end-block end-struct) + ;; Check if in string in case using non-standard feature where + ;; continued strings do not need "&" at start of continuations. (when (save-excursion (beginning-of-line) (skip-chars-forward " \t0-9") - (setq end-struct (f90-looking-at-program-block-end))) + (unless (f90-in-string) + (setq end-struct + (f90-looking-at-program-block-end)))) (setq end-block (car end-struct) end-name (cadr end-struct)) (save-excursion diff --git a/test/ChangeLog b/test/ChangeLog index abc582c20fa..7ba14964c0a 100644 --- a/test/ChangeLog +++ b/test/ChangeLog @@ -1,3 +1,7 @@ +2015-02-24 Glenn Morris + + * automated/f90.el (f90-test-bug-19809): New test. + 2015-02-22 Michael Albinus * automated/tramp-tests.el (tramp-test17-insert-directory): diff --git a/test/automated/f90.el b/test/automated/f90.el index c6bc41f799a..1cb2f035a6b 100644 --- a/test/automated/f90.el +++ b/test/automated/f90.el @@ -173,4 +173,20 @@ end program prog") (f90-indent-subprogram) (should (= 0 (current-indentation))))) +(ert-deftest f90-test-bug-19809 () + "Test for http://debbugs.gnu.org/19809 ." + (with-temp-buffer + (f90-mode) + ;; The Fortran standard says that continued strings should have + ;; '&' at the start of continuation lines, but it seems gfortran + ;; allows them to be absent (albeit with a warning). + (insert "program prog + write (*,*), '& +end program prog' +end program prog") + (goto-char (point-min)) + (f90-end-of-subprogram) + (should (= (point) (point-max))))) + + ;;; f90.el ends here -- 2.39.2