From e90d065e64702d09fbdfc7cfd1c97456c7faa74c Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Sun, 16 Sep 2012 13:24:15 +0930 Subject: [PATCH] Add userdiff patterns for Ada Add Ada xfuncname and wordRegex patterns to the list of builtin patterns. Signed-off-by: Adrian Johnson Signed-off-by: Junio C Hamano --- Documentation/gitattributes.txt | 2 ++ t/t4018-diff-funcname.sh | 2 +- t/t4034-diff-words.sh | 1 + t/t4034/ada/expect | 27 +++++++++++++++++++++++++++ t/t4034/ada/post | 13 +++++++++++++ t/t4034/ada/pre | 13 +++++++++++++ userdiff.c | 9 +++++++++ 7 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 t/t4034/ada/expect create mode 100644 t/t4034/ada/post create mode 100644 t/t4034/ada/pre diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt index e16f3e175b..c693bfb497 100644 --- a/Documentation/gitattributes.txt +++ b/Documentation/gitattributes.txt @@ -511,6 +511,8 @@ configuration file (you still need to enable this with the attribute mechanism, via `.gitattributes`). The following built in patterns are available: +- `ada` suitable for source code in the Ada language. + - `bibtex` suitable for files with BibTeX coded references. - `cpp` suitable for source code in the C and C++ languages. diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh index 4bd2a1c838..082d3e83bd 100755 --- a/t/t4018-diff-funcname.sh +++ b/t/t4018-diff-funcname.sh @@ -105,7 +105,7 @@ test_expect_funcname () { grep "^@@.*@@ $1" diff } -for p in bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex +for p in ada bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex do test_expect_success "builtin $p pattern compiles" ' echo "*.java diff=$p" >.gitattributes && diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh index 30d42cb3bf..40ab333a8a 100755 --- a/t/t4034-diff-words.sh +++ b/t/t4034-diff-words.sh @@ -298,6 +298,7 @@ test_expect_success 'unset default driver' ' test_unconfig diff.wordregex ' +test_language_driver ada test_language_driver bibtex test_language_driver cpp test_language_driver csharp diff --git a/t/t4034/ada/expect b/t/t4034/ada/expect new file mode 100644 index 0000000000..be2376e904 --- /dev/null +++ b/t/t4034/ada/expect @@ -0,0 +1,27 @@ +diff --git a/pre b/post +index d96fdd1..df21bb0 100644 +--- a/pre ++++ b/post +@@ -1,13 +1,13 @@ +Ada.Text_IO.Put_Line("Hello World!?"); +1 1e-10 16#FE12#E2 3.141_592 'xy' +ax+b ay x-b +ay +x*b ay x/b +ay +x**b +ay +x(by) +ax:=b +ay +x=b ay x/= b +ay +x<b ay x<=b ay x>b ay x>=b +ay +x,b +ay +x=>b +ay +x..b +ay +x<>by diff --git a/t/t4034/ada/post b/t/t4034/ada/post new file mode 100644 index 0000000000..df21bb044f --- /dev/null +++ b/t/t4034/ada/post @@ -0,0 +1,13 @@ +Ada.Text_IO.Put_Line("Hello World?"); +1 1e10 16#FE12#E2 3.141_592 'y' +x+y x-y +x*y x/y +x**y +x(y) +x:=y +x=y x/= y +xy x>=y +x,y +x=>y +x..y +x<>y diff --git a/t/t4034/ada/pre b/t/t4034/ada/pre new file mode 100644 index 0000000000..d96fdd1e8e --- /dev/null +++ b/t/t4034/ada/pre @@ -0,0 +1,13 @@ +Ada.Text_IO.Put_Line("Hello World!"); +1 1e-10 16#FE12#E2 3.141_592 'x' +a+b a-b +a*b a/b +a**b +a(b) +a:=b +a=b a/= b +ab a>=b +a,b +a=>b +a..b +a<>b diff --git a/userdiff.c b/userdiff.c index 1e7184f7f0..ed958ef6b8 100644 --- a/userdiff.c +++ b/userdiff.c @@ -14,6 +14,15 @@ static int drivers_alloc; { name, NULL, -1, { pattern, REG_EXTENDED | REG_ICASE }, \ word_regex "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" } static struct userdiff_driver builtin_drivers[] = { +IPATTERN("ada", + "!^(.*[ \t])?(is new|renames|is separate)([ \t].*)?$\n" + "!^[ \t]*with[ \t].*$\n" + "^[ \t]*((procedure|function)[ \t]+.*)$\n" + "^[ \t]*((package|protected|task)[ \t]+.*)$", + /* -- */ + "[a-zA-Z][a-zA-Z0-9_]*" + "|[0-9][-+0-9#_.eE]" + "|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"), IPATTERN("fortran", "!^([C*]|[ \t]*!)\n" "!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n" -- 2.11.4.GIT