# [PATCH] Add matchings for csharp

3 messages from 2009-06-21 to 2009-06-22. Participants: Adam Petaccia, Johannes Sixt, Paolo Bonzini.
Thread: https://gitlist.dev/t/19890

## Adam Petaccia, 2009-06-21 23:52

Subject: [PATCH] Add matchings for csharp
Message-ID: <1245628369.15870.1.camel@belthazor>
URL: https://gitlist.dev/e/1245628369.15870.1.camel%40belthazor

```
I'm not sure if this is the correct place to send patches, please direct 
me if I've addressed the wrong list.
---
 t/t4018-diff-funcname.sh |    2 +-
 userdiff.c               |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 5b10e97..704dae8 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -32,7 +32,7 @@ EOF
 
 sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java
 
-builtin_patterns="bibtex cpp html java objc pascal php python ruby tex"
+builtin_patterns="bibtex csharp cpp html java objc pascal php python ruby tex"
 for p in $builtin_patterns
 do
 	test_expect_success "builtin $p pattern compiles" '
diff --git a/userdiff.c b/userdiff.c
index 57529ae..d4151b2 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -79,6 +79,16 @@ PATTERNS("cpp",
 	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
 	 "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"
 	 "|[^[:space:]]|[\x80-\xff]+"),
+PATTERNS("csharp",
+	 "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
+	 "^([ \t]*(static|public|internal|private|protected|new|unsafe|readonly|volatile)[ \t]+(class|enum|interface|struct).*)$\n"
+	 "^([ \t]*(namespace)[ \t]+.*)$"
+	 ,
+	 /* -- */
+	 "[a-zA-Z_][a-zA-Z0-9_]*"
+	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
+	 "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"
+	 "|[^[:space:]]|[\x80-\xff]+"),
 { "default", NULL, -1, { NULL, 0 } },
 };
 #undef PATTERNS
-- 
1.6.0.4

```

## Johannes Sixt, 2009-06-22 06:24

Subject: Re: [PATCH] Add matchings for csharp
Message-ID: <4A3F238B.1020107@viscovery.net>
URL: https://gitlist.dev/e/4A3F238B.1020107%40viscovery.net
In-Reply-To: <1245628369.15870.1.camel@belthazor>

```
Thank you for you contribution.

Adam Petaccia schrieb:
> I'm not sure if this is the correct place to send patches, please direct 
> me if I've addressed the wrong list.

This part of a patch submission should contain a description *why* this
patch is an improvement (and must include a Signed-off-by statement; see
Documentation/SubmittingPatches). Perhaps you are aware of msysgit issue
281[1], that you are addressing here, and you could mention it.
Considering the complaint in that issue (that hunk headers always only
mention the containing namespace), an example in the commit message would
be useful.

To answer you question: This is the right place.

[1] http://code.google.com/p/msysgit/issues/detail?id=281

> @@ -79,6 +79,16 @@ PATTERNS("cpp",
>  	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
>  	 "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"
>  	 "|[^[:space:]]|[\x80-\xff]+"),
> +PATTERNS("csharp",
> +	 "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
> +	 "^([ \t]*(static|public|internal|private|protected|new|unsafe|readonly|volatile)[ \t]+(class|enum|interface|struct).*)$\n"
> +	 "^([ \t]*(namespace)[ \t]+.*)$"

I think the placement of parentheses could be improved in these two
expressions (but I don't know for sure because I don't know the code well
enough). Looking at the other examples in userdiff.c, I infer that the
*first* opening parentheses defines which part is copied to the hunk
header. Since you placed everything into parentheses (unnecessarily, I
think), the complete line would be copied to the hunk header, including
leading whitespace.

Disclaimer: I don't have C# source code to test this.

-- Hannes

```

## Paolo Bonzini, 2009-06-22 08:12

Subject: Re: [PATCH] Add matchings for csharp
Message-ID: <4A3F3CE2.1070704@gnu.org>
URL: https://gitlist.dev/e/4A3F3CE2.1070704%40gnu.org
In-Reply-To: <4A3F238B.1020107@viscovery.net>

```

>> @@ -79,6 +79,16 @@ PATTERNS("cpp",
>>  	 "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
>>  	 "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"
>>  	 "|[^[:space:]]|[\x80-\xff]+"),
>> +PATTERNS("csharp",
>> +	 "!^[ \t]*(catch|do|for|if|instanceof|new|return|switch|throw|while)\n"
>> +	 "^([ \t]*(static|public|internal|private|protected|new|unsafe|readonly|volatile)[ \t]+(class|enum|interface|struct).*)$\n"
>> +	 "^([ \t]*(namespace)[ \t]+.*)$"
> 
> I think the placement of parentheses could be improved in these two
> expressions (but I don't know for sure because I don't know the code well
> enough). Looking at the other examples in userdiff.c, I infer that the
> *first* opening parentheses defines which part is copied to the hunk
> header.

Yes.

> Since you placed everything into parentheses (unnecessarily, I
> think),

No, not unnecessarily because otherwise only "public" for example would 
be copied.  I agree though that leading whitespace should not be 
included in the parentheses.

Paolo

```
