All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Sixt <j6t@kdbg.org>
To: Marius Ungureanu <marius.ungureanu@xamarin.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Updated C# userdiff patterns.
Date: Sat, 26 Apr 2014 19:49:52 +0200	[thread overview]
Message-ID: <535BF1C0.7080204@kdbg.org> (raw)
In-Reply-To: <97789B23-A375-46B1-99FD-A851A15C2D85@xamarin.com>

Am 26.04.2014 11:55, schrieb Marius Ungureanu:
> On 26 Apr 2014, at 10:10, Johannes Sixt <j6t@kdbg.org> wrote:
>> Am 26.04.2014 01:25, schrieb Marius Ungureanu:
>>> diff --git a/userdiff.c b/userdiff.c
>>> index fad52d6..7612c5d 100644
>>> --- a/userdiff.c
>>> +++ b/userdiff.c
>>> @@ -133,14 +133,14 @@ PATTERNS("cpp",
>>> 	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lLuU]*"
>>> 	 "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->\\*?|\\.\\*"),
>>> PATTERNS("csharp",
>>> -	 /* Keywords */
>>> -	 "!^[ \t]*(do|while|for|if|else|instanceof|new|return|switch|case|throw|catch|using)\n"
>>> 	 /* Methods and constructors */
>>> -	 "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[<>@._[:alnum:]]+[ \t]*\\(.*\\))[ \t]*$\n"
>>> -	 /* Properties */
>>> -	 "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[@._[:alnum:]]+)[ \t]*$\n"
>>> +	 "^[ \t]*(((abstract|extern|internal|new|override|private|protected|public|sealed|static|unsafe|virtual)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[<>@._[:alnum:]]+[ \t]*\\(.*\\))[ \t]*$\n"
>>> +	 /* Properties, events, delegates */
>>> +	 "^[ \t]*(((abstract|internal|new|override|private|protected|public|sealed|static|unsafe|virtual)[ \t]+)*((delegate|event)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[@._[:alnum:]]+)[ \t]*$\n"
>>> 	 /* Type definitions */
>>> -	 "^[ \t]*(((static|public|internal|private|protected|new|unsafe|sealed|abstract|partial)[ \t]+)*(class|enum|interface|struct)[ \t]+.*)$\n"
>>> +	 "^[ \t]*(((abstract|internal|new|override|partial|private|protected|public|sealed|static|unsafe)[ \t]+)*(class|enum|interface|struct)[ \t]+.*)$\n"
>>> +	 /* Keywords */
>>> +	 "!^[ \t]*(as|base|break|case|catch|checked|continue|default|delegate|do|else|finally|fixed|for|foreach|if|in|is|lock|new|null|out|readonly|ref|return|switch|this|throw|try|typeof|unchecked|unsafe|using|var|while)\n"
>>> 	 /* Namespace */
>>> 	 "^[ \t]*(namespace[ \t]+.*)$",
>>> 	 /* -- */
> 
> ...
> Modifier parsing can contain keywords, so just to be sure, I moved the
> keywords after modifier parsing, so it uses the keywords as a fallback.
> If this is not what should happen, please tell.

For each line, patterns are are scanned in order, and the first match
determines the outcome: If it is a negative pattern (i.e., it begins
with an exclamation mark), the line is not a hunk header; if it is a
positive pattern, the line is a hunk header. If no pattern matches, the
line is not a hunk header, either; it is as if the list were terminated
by a negative catch-all pattern.

Due to these rules, negative patterns in the list are only necessary
when you want to make an exception to a positive pattern in the list,
and then the negative pattern must be listed before the positive pattern.

In the csharp case, I do not see a pattern of which the keyword pattern
would make an exception (neither the old version nor your new version).
Therefore, you could drop the keyword pattern entirely.

-- Hannes

  parent reply	other threads:[~2014-04-26 17:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-25 23:25 [PATCH] Updated C# userdiff patterns Marius Ungureanu
2014-04-26  7:10 ` Johannes Sixt
2014-04-26  9:55   ` Marius Ungureanu
2014-04-26 10:49     ` Marius Ungureanu
2014-04-26 17:49     ` Johannes Sixt [this message]
2014-04-26 18:33       ` Marius Ungureanu
2014-04-26 18:50         ` Johannes Sixt
2014-04-26 18:52           ` Marius Ungureanu
2014-04-27 13:43           ` Marius Ungureanu
2014-04-27 13:45           ` [PATCH 1/2] update " Marius Ungureanu
2014-04-27 13:48             ` [PATCH 2/2] add csharp userdiff tests Marius Ungureanu
2014-04-27 13:47           ` Marius Ungureanu
2014-04-27 16:19             ` Johannes Sixt
2014-04-27 16:46               ` Marius Ungureanu
2014-04-27 20:12                 ` Johannes Sixt
2014-04-27 17:11               ` Marius Ungureanu

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=535BF1C0.7080204@kdbg.org \
    --to=j6t@kdbg.org \
    --cc=git@vger.kernel.org \
    --cc=marius.ungureanu@xamarin.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.