* [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.
@ 2008-08-01 19:45 Avery Pennarun
2008-08-01 20:16 ` Junio C Hamano
2008-08-01 20:20 ` Petr Baudis
0 siblings, 2 replies; 6+ messages in thread
From: Avery Pennarun @ 2008-08-01 19:45 UTC (permalink / raw)
To: gitster, git; +Cc: Avery Pennarun
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.
2008-08-01 19:45 Avery Pennarun
@ 2008-08-01 20:16 ` Junio C Hamano
2008-08-01 20:38 ` Avery Pennarun
2008-08-01 20:20 ` Petr Baudis
1 sibling, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2008-08-01 20:16 UTC (permalink / raw)
To: Avery Pennarun; +Cc: gitster, git
"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").
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.
2008-08-01 19:45 Avery Pennarun
2008-08-01 20:16 ` Junio C Hamano
@ 2008-08-01 20:20 ` Petr Baudis
2008-08-01 20:40 ` Avery Pennarun
1 sibling, 1 reply; 6+ messages in thread
From: Petr Baudis @ 2008-08-01 20:20 UTC (permalink / raw)
To: Avery Pennarun; +Cc: gitster, git
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.
2008-08-01 20:16 ` Junio C Hamano
@ 2008-08-01 20:38 ` Avery Pennarun
0 siblings, 0 replies; 6+ messages in thread
From: Avery Pennarun @ 2008-08-01 20:38 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.
2008-08-01 20:20 ` Petr Baudis
@ 2008-08-01 20:40 ` Avery Pennarun
0 siblings, 0 replies; 6+ messages in thread
From: Avery Pennarun @ 2008-08-01 20:40 UTC (permalink / raw)
To: Petr Baudis; +Cc: gitster, git
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Add Pascal/Delphi (.pas file) funcname pattern.
@ 2008-08-01 21:00 Avery Pennarun
0 siblings, 0 replies; 6+ messages in thread
From: Avery Pennarun @ 2008-08-01 21:00 UTC (permalink / raw)
To: gitster, git, pasky; +Cc: Avery Pennarun
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>
---
diff.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
Changes since v1:
- Tried using '\n' to separate the two parts of the regex, but it doesn't
work. Seems the lines are combined with AND instead of OR. Also can't
reduce the number of parens since only the part in parens is returned
as the result string.
- Rename 'pas' type to 'pascal'
- Remove unnecessary 'type' match.
diff --git a/diff.c b/diff.c
index cbf2547..2f88e6d 100644
--- a/diff.c
+++ b/diff.c
@@ -1380,6 +1380,12 @@ static struct builtin_funcname_pattern {
"^[ ]*\\(\\([ ]*"
"[A-Za-z_][A-Za-z_0-9]*\\)\\{2,\\}"
"[ ]*([^;]*\\)$" },
+ { "pascal", "^\\(\\(procedure\\|function\\|constructor\\|"
+ "destructor\\|interface\\|implementation\\|"
+ "initialization\\|finalization\\)[ \t]*.*\\)$"
+ "\\|"
+ "^\\(.*=[ \t]*\\(class\\|record\\).*\\)$"
+ },
{ "tex", "^\\(\\\\\\(sub\\)*section{.*\\)$" },
};
--
1.5.6
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2008-08-01 21:01 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-01 21:00 [PATCH] Add Pascal/Delphi (.pas file) funcname pattern Avery Pennarun
-- strict thread matches above, loose matches on Subject: below --
2008-08-01 19:45 Avery Pennarun
2008-08-01 20:16 ` Junio C Hamano
2008-08-01 20:38 ` Avery Pennarun
2008-08-01 20:20 ` Petr Baudis
2008-08-01 20:40 ` Avery Pennarun
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).