git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] userdiff: improve Fortran xfuncname regex

From
Elijah Newren <newren@gmail.com>
Date
Aug 13, 2020, 02:10 UTC
Message-ID
<CABPp-BENKdxqXjH07yCNojRWQ3XO+_mm8x+LSVLTBx36m6nSSw@mail.gmail.com>
In-Reply-To
<69fe977b66f9744c914cfdfa2da4b9be5e720e4f.1597271429.git.gitgitgadget@gmail.com>

On Wed, Aug 12, 2020 at 3:34 PM Philippe Blain via GitGitGadget <gitgitgadget@gmail.com> wrote:

Show 34 quoted lines
>
> From: Philippe Blain <levraiphilippeblain@gmail.com>
>
> The third part of the Fortran xfuncname regex wants to match the
> beginning of a subroutine or function, so it allows for all characters
> except `'`, `"` or whitespace before the keyword 'function' or
> 'subroutine'. This is meant to match the 'recursive', 'elemental' or
> 'pure' keywords, as well as function return types, and to prevent
> matches inside strings.
>
> However, the negated set does not contain the `!` comment character,
> so a line with an end-of-line comment containing the keyword 'function' or
> 'subroutine' followed by another word is mistakenly chosen as a hunk header.
>
> Improve the regex by adding `!` to the negated set.
>
> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
> ---
>  t/t4018/fortran-comment-keyword | 1 -
>  userdiff.c                      | 2 +-
>  2 files changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/t/t4018/fortran-comment-keyword b/t/t4018/fortran-comment-keyword
> index c5dbdb4c61..e9206a5379 100644
> --- a/t/t4018/fortran-comment-keyword
> +++ b/t/t4018/fortran-comment-keyword
> @@ -8,7 +8,6 @@
>        real funcB  ! grid function b
>
>        real ChangeMe
> -      integer broken
>
>        end subroutine RIGHT
>

This change seems orthogonal to the explanation in the commit message. What is its purpose, and does it belong in this commit or a different one?

Show 15 quoted lines
> diff --git a/userdiff.c b/userdiff.c
> index 707d82435a..fde02f225b 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -53,7 +53,7 @@ IPATTERN("fortran",
>          /* Program, module, block data */
>          "^[ \t]*((END[ \t]+)?(PROGRAM|MODULE|BLOCK[ \t]+DATA"
>                 /* Subroutines and functions */
> -               "|([^'\" \t]+[ \t]+)*(SUBROUTINE|FUNCTION))[ \t]+[A-Z].*)$",
> +               "|([^!'\" \t]+[ \t]+)*(SUBROUTINE|FUNCTION))[ \t]+[A-Z].*)$",
>          /* -- */
>          "[a-zA-Z][a-zA-Z0-9_]*"
>          "|\\.([Ee][Qq]|[Nn][Ee]|[Gg][TtEe]|[Ll][TtEe]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|[Aa][Nn][Dd]|[Oo][Rr]|[Nn]?[Ee][Qq][Vv]|[Nn][Oo][Tt])\\."
> --
> gitgitgadget
Previous: Philippe Blain via GitGitGadgetNext: Philippe Blain
Message 4 of 7 in “Improve and test Fortran xfuncname regex”
  1. 0/2 Improve and test Fortran xfuncname regexPhilippe Blain via GitGitGadget, Aug 12, 2020
  2. 1/2 userdiff: add tests for Fortran xfuncname regexPhilippe Blain via GitGitGadget, Aug 12, 2020
  3. 2/2 userdiff: improve Fortran xfuncname regexPhilippe Blain via GitGitGadget, Aug 12, 2020
  4. Elijah NewrenAug 13, 2020
  5. Philippe BlainAug 13, 2020
  6. Elijah NewrenAug 13, 2020
  7. Junio C HamanoAug 13, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.