From: "Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Brandon Casey <drafnel@gmail.com>,
Philippe Blain <levraiphilippeblain@gmail.com>,
Philippe Blain <levraiphilippeblain@gmail.com>
Subject: [PATCH 1/2] userdiff: add tests for Fortran xfuncname regex
Date: Wed, 12 Aug 2020 22:30:28 +0000 [thread overview]
Message-ID: <30cb5c5cd57162837efe1153bf88cb8863206323.1597271429.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.700.git.1597271429.gitgitgadget@gmail.com>
From: Philippe Blain <levraiphilippeblain@gmail.com>
The Fortran userdiff patterns, introduced in 909a5494f8 (userdiff.c: add
builtin fortran regex patterns, 2010-09-10), predate the test
infrastructure for xfuncname patterns, introduced in bfa7d01413 (t4018:
an infrastructure to test hunk headers, 2014-03-21).
Add tests for the Fortran xfuncname patterns. The test
't/t4018/fortran-comment-keyword' documents a shortcoming of the regex
that is fixed in a subsequent commit.
While at it, add descriptive comments for the different parts of the
regex.
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
---
t/t4018/fortran-block-data | 5 +++++
| 13 +++++++++++++
| 15 +++++++++++++++
| 13 +++++++++++++
| 13 +++++++++++++
t/t4018/fortran-external-function | 9 +++++++++
t/t4018/fortran-external-subroutine | 5 +++++
t/t4018/fortran-module | 5 +++++
t/t4018/fortran-module-procedure | 13 +++++++++++++
t/t4018/fortran-program | 5 +++++
userdiff.c | 4 ++++
11 files changed, 100 insertions(+)
create mode 100644 t/t4018/fortran-block-data
create mode 100644 t/t4018/fortran-comment
create mode 100644 t/t4018/fortran-comment-keyword
create mode 100644 t/t4018/fortran-comment-legacy
create mode 100644 t/t4018/fortran-comment-legacy-star
create mode 100644 t/t4018/fortran-external-function
create mode 100644 t/t4018/fortran-external-subroutine
create mode 100644 t/t4018/fortran-module
create mode 100644 t/t4018/fortran-module-procedure
create mode 100644 t/t4018/fortran-program
diff --git a/t/t4018/fortran-block-data b/t/t4018/fortran-block-data
new file mode 100644
index 0000000000..63d4e21d0a
--- /dev/null
+++ b/t/t4018/fortran-block-data
@@ -0,0 +1,5 @@
+ BLOCK DATA RIGHT
+
+ COMMON /B/ C, ChangeMe
+ DATA C, ChangeMe / 2.0, 6.0 /
+ END
--git a/t/t4018/fortran-comment b/t/t4018/fortran-comment
new file mode 100644
index 0000000000..7b10d17658
--- /dev/null
+++ b/t/t4018/fortran-comment
@@ -0,0 +1,13 @@
+ module a
+
+ contains
+
+ ! subroutine wrong
+ subroutine RIGHT
+ ! subroutine wrong
+
+ real ChangeMe
+
+ end subroutine RIGHT
+
+ end module a
--git a/t/t4018/fortran-comment-keyword b/t/t4018/fortran-comment-keyword
new file mode 100644
index 0000000000..c5dbdb4c61
--- /dev/null
+++ b/t/t4018/fortran-comment-keyword
@@ -0,0 +1,15 @@
+ module a
+
+ contains
+
+ subroutine RIGHT (funcA, funcB)
+
+ real funcA ! grid function a
+ real funcB ! grid function b
+
+ real ChangeMe
+ integer broken
+
+ end subroutine RIGHT
+
+ end module a
--git a/t/t4018/fortran-comment-legacy b/t/t4018/fortran-comment-legacy
new file mode 100644
index 0000000000..53cd062c1e
--- /dev/null
+++ b/t/t4018/fortran-comment-legacy
@@ -0,0 +1,13 @@
+ module a
+
+ contains
+
+C subroutine wrong
+ subroutine RIGHT
+C subroutine wrong
+
+ real ChangeMe
+
+ end subroutine RIGHT
+
+ end module a
--git a/t/t4018/fortran-comment-legacy-star b/t/t4018/fortran-comment-legacy-star
new file mode 100644
index 0000000000..2cbcdc3d8a
--- /dev/null
+++ b/t/t4018/fortran-comment-legacy-star
@@ -0,0 +1,13 @@
+ module a
+
+ contains
+
+* subroutine wrong
+ subroutine RIGHT
+* subroutine wrong
+
+ real ChangeMe
+
+ end subroutine RIGHT
+
+ end module a
diff --git a/t/t4018/fortran-external-function b/t/t4018/fortran-external-function
new file mode 100644
index 0000000000..5a2d85d3aa
--- /dev/null
+++ b/t/t4018/fortran-external-function
@@ -0,0 +1,9 @@
+function RIGHT(a, b) result(c)
+
+integer, intent(in) :: ChangeMe
+integer, intent(in) :: b
+integer, intent(out) :: c
+
+c = a+b
+
+end function RIGHT
diff --git a/t/t4018/fortran-external-subroutine b/t/t4018/fortran-external-subroutine
new file mode 100644
index 0000000000..4ce85fea13
--- /dev/null
+++ b/t/t4018/fortran-external-subroutine
@@ -0,0 +1,5 @@
+subroutine RIGHT
+
+real ChangeMe
+
+end subroutine RIGHT
diff --git a/t/t4018/fortran-module b/t/t4018/fortran-module
new file mode 100644
index 0000000000..c4b737dac3
--- /dev/null
+++ b/t/t4018/fortran-module
@@ -0,0 +1,5 @@
+module RIGHT
+
+use ChangeMe
+
+end module RIGHT
diff --git a/t/t4018/fortran-module-procedure b/t/t4018/fortran-module-procedure
new file mode 100644
index 0000000000..1ce6d854c2
--- /dev/null
+++ b/t/t4018/fortran-module-procedure
@@ -0,0 +1,13 @@
+ module RIGHT
+
+ implicit none
+ private
+
+ interface letters ! generic interface
+ module procedure aaaa, &
+ bbbb, &
+ ChangeMe, &
+ dddd
+ end interface
+
+end module RIGHT
diff --git a/t/t4018/fortran-program b/t/t4018/fortran-program
new file mode 100644
index 0000000000..4616895e4b
--- /dev/null
+++ b/t/t4018/fortran-program
@@ -0,0 +1,5 @@
+program RIGHT
+
+call ChangeMe
+
+end program RIGHT
diff --git a/userdiff.c b/userdiff.c
index 1df884ef0b..707d82435a 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -46,9 +46,13 @@ PATTERNS("elixir",
/* Not real operators, but should be grouped */
"|:?%[A-Za-z0-9_.]\\{\\}?"),
IPATTERN("fortran",
+ /* Don't match comment lines */
"!^([C*]|[ \t]*!)\n"
+ /* Don't match 'module procedure' lines */
"!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"
+ /* Program, module, block data */
"^[ \t]*((END[ \t]+)?(PROGRAM|MODULE|BLOCK[ \t]+DATA"
+ /* Subroutines and functions */
"|([^'\" \t]+[ \t]+)*(SUBROUTINE|FUNCTION))[ \t]+[A-Z].*)$",
/* -- */
"[a-zA-Z][a-zA-Z0-9_]*"
--
gitgitgadget
next prev parent reply other threads:[~2020-08-12 22:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-12 22:30 [PATCH 0/2] Improve and test Fortran xfuncname regex Philippe Blain via GitGitGadget
2020-08-12 22:30 ` Philippe Blain via GitGitGadget [this message]
2020-08-12 22:30 ` [PATCH 2/2] userdiff: improve " Philippe Blain via GitGitGadget
2020-08-13 2:10 ` Elijah Newren
2020-08-13 12:45 ` Philippe Blain
2020-08-13 14:04 ` Elijah Newren
2020-08-13 18:22 ` [PATCH 0/2] Improve and test " Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=30cb5c5cd57162837efe1153bf88cb8863206323.1597271429.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=drafnel@gmail.com \
--cc=git@vger.kernel.org \
--cc=levraiphilippeblain@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).