# [GSoC] Microproject: Add more builtin patterns for userdiff

2 messages from 2019-03-15 to 2019-03-15. Participants: Kapil Jain, Ævar Arnfjörð Bjarmason.
Thread: https://gitlist.dev/t/50745

## Kapil Jain, 2019-03-15 09:09

Subject: [GSoC] Microproject: Add more builtin patterns for userdiff
Message-ID: <CAMknYEMgJ88zWsebxBqsLq8LUwYzg0vN3RpsWVpbqvncrd5dGQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAMknYEMgJ88zWsebxBqsLq8LUwYzg0vN3RpsWVpbqvncrd5dGQ%40mail.gmail.com

```
Hi,

for the microproject: creating diff function support for different languages.
i wrote one for shell script, have tested it outside of git and it works fine.

query regarding accommodating the pattern in:
1) userdiff.c, it uses - #define PATTERNS(name, pattern, word_regex),
for defining patterns to locate functions.
what is the use of pattern and word_regex parameters ? i am guessing
that pattern parameter is the actual pattern to spot functions in a
file,
and word_regex is used to get function name. is that correct ?
please let me know.

```

## Ævar Arnfjörð Bjarmason, 2019-03-15 12:56

Subject: Re: [GSoC] Microproject: Add more builtin patterns for userdiff
Message-ID: <8736nob8k8.fsf@evledraar.gmail.com>
URL: https://gitlist.dev/e/8736nob8k8.fsf%40evledraar.gmail.com
In-Reply-To: <CAMknYEMgJ88zWsebxBqsLq8LUwYzg0vN3RpsWVpbqvncrd5dGQ@mail.gmail.com>

```

On Fri, Mar 15 2019, Kapil Jain wrote:

> Hi,
>
> for the microproject: creating diff function support for different languages.
> i wrote one for shell script, have tested it outside of git and it works fine.
>
> query regarding accommodating the pattern in:
> 1) userdiff.c, it uses - #define PATTERNS(name, pattern, word_regex),
> for defining patterns to locate functions.
> what is the use of pattern and word_regex parameters ? i am guessing
> that pattern parameter is the actual pattern to spot functions in a
> file,

Yes, except "functions". More like "logical start of
stuff". E.g. "package" statements for Perl etc.

So whatever makes the most sense to put in the "@" context line for diff
to give the user an idea of what "function" this is changing, in the
loosest possible sense of "function".

> and word_regex is used to get function name. is that correct ?
> please let me know.

No, it's whatever counts as a "token" in the language for the purpose of
"diff --word-diff". So it needs to match e.g. operators as one unit.

```
