Add userdiff patterns for Ada
Add Ada xfuncname and wordRegex patterns to the list of builtin patterns. Signed-off-by: Adrian Johnson <ajohnson@redneon.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Adrian Johnson committed
Sep 16, 2012 at 13:24 UTC
e90d065e64702d09fbdfc7cfd1c97456c7faa74c
7 files changed
+66
-1
Documentation/gitattributes.txt
+2
@@ -511,6 +511,8 @@ configuration file (you still need to enable this with the
511
attribute mechanism, via `.gitattributes`). The following built in
512
patterns are available:
513
514
+- `ada` suitable for source code in the Ada language.
515
+
516
- `bibtex` suitable for files with BibTeX coded references.
517
518
- `cpp` suitable for source code in the C and C++ languages.
t/t4018-diff-funcname.sh
+1
-1
@@ -105,7 +105,7 @@ test_expect_funcname () {
105
grep "^@@.*@@ $1" diff
106
}
107
108
-for p in bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex
108
+for p in ada bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex
109
do
110
test_expect_success "builtin $p pattern compiles" '
111
echo "*.java diff=$p" >.gitattributes &&
t/t4034-diff-words.sh
+1
@@ -298,6 +298,7 @@ test_expect_success 'unset default driver' '
298
test_unconfig diff.wordregex
299
'
300
301
+test_language_driver ada
302
test_language_driver bibtex
303
test_language_driver cpp
304
test_language_driver csharp
t/t4034/ada/expect
new
+27
@@ -0,0 +1,27 @@
1
+<BOLD>diff --git a/pre b/post<RESET>
2
+<BOLD>index d96fdd1..df21bb0 100644<RESET>
3
+<BOLD>--- a/pre<RESET>
4
+<BOLD>+++ b/post<RESET>
5
+<CYAN>@@ -1,13 +1,13 @@<RESET>
6
+Ada.Text_IO.Put_Line("Hello World<RED>!<RESET><GREEN>?<RESET>");
7
+1 1e<RED>-<RESET>10 16#FE12#E2 3.141_592 '<RED>x<RESET><GREEN>y<RESET>'
8
+<RED>a<RESET><GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET>
9
+<RED>a<RESET><GREEN>y<RESET>
10
+<GREEN>x<RESET>*<RED>b a<RESET><GREEN>y x<RESET>/<RED>b<RESET>
11
+<RED>a<RESET><GREEN>y<RESET>
12
+<GREEN>x<RESET>**<RED>b<RESET>
13
+<RED>a<RESET><GREEN>y<RESET>
14
+<GREEN>x<RESET>(<RED>b<RESET><GREEN>y<RESET>)
15
+<RED>a<RESET><GREEN>x<RESET>:=<RED>b<RESET>
16
+<RED>a<RESET><GREEN>y<RESET>
17
+<GREEN>x<RESET>=<RED>b a<RESET><GREEN>y x<RESET>/= <RED>b<RESET>
18
+<RED>a<RESET><GREEN>y<RESET>
19
+<GREEN>x<RESET><<RED>b a<RESET><GREEN>y x<RESET><=<RED>b a<RESET><GREEN>y x<RESET>><RED>b a<RESET><GREEN>y x<RESET>>=<RED>b<RESET>
20
+<RED>a<RESET><GREEN>y<RESET>
21
+<GREEN>x<RESET>,<RED>b<RESET>
22
+<RED>a<RESET><GREEN>y<RESET>
23
+<GREEN>x<RESET>=><RED>b<RESET>
24
+<RED>a<RESET><GREEN>y<RESET>
25
+<GREEN>x<RESET>..<RED>b<RESET>
26
+<RED>a<RESET><GREEN>y<RESET>
27
+<GREEN>x<RESET><><RED>b<RESET><GREEN>y<RESET>
t/t4034/ada/post
new
+13
@@ -0,0 +1,13 @@
1
+Ada.Text_IO.Put_Line("Hello World?");
2
+1 1e10 16#FE12#E2 3.141_592 'y'
3
+x+y x-y
4
+x*y x/y
5
+x**y
6
+x(y)
7
+x:=y
8
+x=y x/= y
9
+x<y x<=y x>y x>=y
10
+x,y
11
+x=>y
12
+x..y
13
+x<>y
t/t4034/ada/pre
new
+13
@@ -0,0 +1,13 @@
1
+Ada.Text_IO.Put_Line("Hello World!");
2
+1 1e-10 16#FE12#E2 3.141_592 'x'
3
+a+b a-b
4
+a*b a/b
5
+a**b
6
+a(b)
7
+a:=b
8
+a=b a/= b
9
+a<b a<=b a>b a>=b
10
+a,b
11
+a=>b
12
+a..b
13
+a<>b
userdiff.c
+9
@@ -14,6 +14,15 @@ static int drivers_alloc;
14
{ name, NULL, -1, { pattern, REG_EXTENDED | REG_ICASE }, \
15
word_regex "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" }
16
static struct userdiff_driver builtin_drivers[] = {
17
+IPATTERN("ada",
18
+ "!^(.*[ \t])?(is new|renames|is separate)([ \t].*)?$\n"
19
+ "!^[ \t]*with[ \t].*$\n"
20
+ "^[ \t]*((procedure|function)[ \t]+.*)$\n"
21
+ "^[ \t]*((package|protected|task)[ \t]+.*)$",
22
+ /* -- */
23
+ "[a-zA-Z][a-zA-Z0-9_]*"
24
+ "|[0-9][-+0-9#_.eE]"
25
+ "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"),
26
IPATTERN("fortran",
27
"!^([C*]|[ \t]*!)\n"
28
"!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"