# [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.

5 messages from 2008-08-01 to 2008-08-01. Participants: Avery Pennarun, Junio C Hamano, Petr Baudis.
Thread: https://gitlist.dev/t/14795

## Avery Pennarun, 2008-08-01 19:45

Subject: [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.
Message-ID: <1217619915-9331-1-git-send-email-apenwarr@gmail.com>
URL: https://gitlist.dev/e/1217619915-9331-1-git-send-email-apenwarr%40gmail.com

```
Finds classes, records, functions, procedures, and sections.  Most lines
need to start at the first column, or else there's no way to differentiate
a procedure's definition from its declaration.

Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
---

The Ruby funcname pattern patch inspired me.  Although unlike him, I didn't
check with anyone else for confirmation.  How many Pascal programmers can
there possibly be? :)

 diff.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/diff.c b/diff.c
index cbf2547..c73ba69 100644
--- a/diff.c
+++ b/diff.c
@@ -1380,6 +1380,10 @@ static struct builtin_funcname_pattern {
 			"^[ 	]*\\(\\([ 	]*"
 			"[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
 			"[ 	]*([^;]*\\)$" },
+	{ "pas", "\\(^\\(procedure\\|function\\|constructor\\|"
+			"destructor\\|interface\\|implementation\\|"
+			"type|initialization|finalization\\).*$\\)"
+			"\\|\\(^.*=[ \t]*\\(class\\|record\\).*$\\)" },
 	{ "tex", "^\\(\\\\\\(sub\\)*section{.*\\)$" },
 };
 
-- 
1.6.0.rc1.34.g23b24.dirty

```

## Junio C Hamano, 2008-08-01 20:16

Subject: Re: [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.
Message-ID: <7v8wvgsd6s.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v8wvgsd6s.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <1217619915-9331-1-git-send-email-apenwarr@gmail.com>

```
"Avery Pennarun" <apenwarr@gmail.com> writes:

> Finds classes, records, functions, procedures, and sections.  Most lines
> need to start at the first column, or else there's no way to differentiate
> a procedure's definition from its declaration.
>
> Signed-off-by: Avery Pennarun <apenwarr@gmail.com>
> ---
>
> The Ruby funcname pattern patch inspired me.  Although unlike him, I didn't
> check with anyone else for confirmation.  How many Pascal programmers can
> there possibly be? :)

> +	{ "pas", "\\(^\\(procedure\\|function\\|constructor\\|"
> +			"destructor\\|interface\\|implementation\\|"
> +			"type|initialization|finalization\\).*$\\)"
> +			"\\|\\(^.*=[ \t]*\\(class\\|record\\).*$\\)" },

Is Delphi the only surviving Pascal?  Why is the name "pas", not "pascal"
or even "delphi-pascal"?

The keys are not file extensions ("ruby" example did the right thing by
not saying "rb").

```

## Petr Baudis, 2008-08-01 20:20

Subject: Re: [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.
Message-ID: <20080801202059.GS32184@machine.or.cz>
URL: https://gitlist.dev/e/20080801202059.GS32184%40machine.or.cz
In-Reply-To: <1217619915-9331-1-git-send-email-apenwarr@gmail.com>

```
On Fri, Aug 01, 2008 at 03:45:15PM -0400, Avery Pennarun wrote:
> diff --git a/diff.c b/diff.c
> index cbf2547..c73ba69 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -1380,6 +1380,10 @@ static struct builtin_funcname_pattern {
>  			"^[ 	]*\\(\\([ 	]*"
>  			"[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
>  			"[ 	]*([^;]*\\)$" },
> +	{ "pas", "\\(^\\(procedure\\|function\\|constructor\\|"
> +			"destructor\\|interface\\|implementation\\|"
> +			"type|initialization|finalization\\).*$\\)"
> +			"\\|\\(^.*=[ \t]*\\(class\\|record\\).*$\\)" },
>  	{ "tex", "^\\(\\\\\\(sub\\)*section{.*\\)$" },
>  };
>  

Wouldn't it be better to make the second pattern start on new line
instead of the outer \(\|\)?

Why "type"?

-- 
		Petr "Pasky, but not writing in Pascal anymore!" Baudis
As in certain cults it is possible to kill a process if you know
its true name.  -- Ken Thompson and Dennis M. Ritchie

```

## Avery Pennarun, 2008-08-01 20:38

Subject: Re: [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.
Message-ID: <32541b130808011338t17a45e51sd0df245dc456b087@mail.gmail.com>
URL: https://gitlist.dev/e/32541b130808011338t17a45e51sd0df245dc456b087%40mail.gmail.com
In-Reply-To: <7v8wvgsd6s.fsf@gitster.siamese.dyndns.org>

```
On 8/1/08, Junio C Hamano <gitster@pobox.com> wrote:
> Is Delphi the only surviving Pascal?  Why is the name "pas", not "pascal"
>  or even "delphi-pascal"?

No, but all surviving Pascals pretty much support the same syntax, so
when I say Pascal/Delphi, I mean either one.  And Delphi does use the
.pas extension.

>  The keys are not file extensions ("ruby" example did the right thing by
>  not saying "rb").

Will fix.

Avery

```

## Avery Pennarun, 2008-08-01 20:40

Subject: Re: [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.
Message-ID: <32541b130808011340j38715970k8dda59fc01ce6918@mail.gmail.com>
URL: https://gitlist.dev/e/32541b130808011340j38715970k8dda59fc01ce6918%40mail.gmail.com
In-Reply-To: <20080801202059.GS32184@machine.or.cz>

```
On 8/1/08, Petr Baudis <pasky@suse.cz> wrote:
> On Fri, Aug 01, 2008 at 03:45:15PM -0400, Avery Pennarun wrote:
>  > +     { "pas", "\\(^\\(procedure\\|function\\|constructor\\|"
>  > +                     "destructor\\|interface\\|implementation\\|"
>  > +                     "type|initialization|finalization\\).*$\\)"
>  > +                     "\\|\\(^.*=[ \t]*\\(class\\|record\\).*$\\)" },
>
> Wouldn't it be better to make the second pattern start on new line
>  instead of the outer \(\|\)?

I didn't even know that was possible, but suddenly I understand the
"java" pattern a lot better.  Thanks!

>  Why "type"?

Well, it's a subsection, but it's always followed by a class or record
definition anyway, so I guess it makes more sense to omit it, now that
you bring it up.

Have fun,

Avery

```
