Userdiff patterns for C#
Add userdiff patterns for C#. This code is an improved version of code by Adam Petaccia from 21 June 2009 mail to the list. Signed-off-by: Petr Onderka <gsvick@gmail.com> Acked-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Petr Onderka committed
Aug 16, 2010 at 17:01 UTC
b221207db9950cb0993a30f38540ff235a0af64e
3 files changed
+19
-1
Documentation/gitattributes.txt
+2
@@ -441,6 +441,8 @@ patterns are available:
441
442
- `cpp` suitable for source code in the C and C++ languages.
443
444
+- `csharp` suitable for source code in the C# language.
445
+
446
- `html` suitable for HTML/XHTML documents.
447
448
- `java` suitable for source code in the Java language.
t/t4018-diff-funcname.sh
+1
-1
@@ -32,7 +32,7 @@ EOF
32
33
sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java
34
35
-builtin_patterns="bibtex cpp html java objc pascal php python ruby tex"
35
+builtin_patterns="bibtex cpp csharp html java objc pascal php python ruby tex"
36
for p in $builtin_patterns
37
do
38
test_expect_success "builtin $p pattern compiles" '
userdiff.c
+16
@@ -82,6 +82,22 @@ PATTERNS("cpp",
82
"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
83
"|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"
84
"|[^[:space:]]|[\x80-\xff]+"),
85
+PATTERNS("csharp",
86
+ /* Keywords */
87
+ "!^[ \t]*(do|while|for|if|else|instanceof|new|return|switch|case|throw|catch|using)\n"
88
+ /* Methods and constructors */
89
+ "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[<>@._[:alnum:]]+[ \t]*\\(.*\\))[ \t]*$\n"
90
+ /* Properties */
91
+ "^[ \t]*(((static|public|internal|private|protected|new|virtual|sealed|override|unsafe)[ \t]+)*[][<>@.~_[:alnum:]]+[ \t]+[@._[:alnum:]]+)[ \t]*$\n"
92
+ /* Type definitions */
93
+ "^[ \t]*(((static|public|internal|private|protected|new|unsafe|sealed|abstract|partial)[ \t]+)*(class|enum|interface|struct)[ \t]+.*)$\n"
94
+ /* Namespace */
95
+ "^[ \t]*(namespace[ \t]+.*)$",
96
+ /* -- */
97
+ "[a-zA-Z_][a-zA-Z0-9_]*"
98
+ "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
99
+ "|[-+*/<>%&^|=!]=|--|\\+\\+|<<=?|>>=?|&&|\\|\\||::|->"
100
+ "|[^[:space:]]|[\x80-\xff]+"),
101
{ "default", NULL, -1, { NULL, 0 } },
102
};
103
#undef PATTERNS