Skip to contentSkip to conversation

Add userdiff patterns for Ada

PATCH New Adrian Johnson 1 participant 1 message Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Add userdiff patterns for Ada

Add Ada xfuncname and wordRegex patterns to the list of builtin patterns.

---

Quoted 4 lines · Junio C Hamano

You could add test vectors to check if the built-in xfuncname catches beginning of functions in Ada correctly if you wanted to, but I think observing what appears on @@ lines in t4034 test vector would be a sufficient test.

I've added additional Ada code to the t4034 test to test xfuncname.

 Documentation/gitattributes.txt |  2 ++
 t/t4018-diff-funcname.sh        |  2 +-
 t/t4034-diff-words.sh           |  1 +
 t/t4034/ada/expect              | 56 ++++++++++++++++++++++++++++++++++++++
 t/t4034/ada/post                | 59 +++++++++++++++++++++++++++++++++++++++++
 t/t4034/ada/pre                 | 59 +++++++++++++++++++++++++++++++++++++++++
 userdiff.c                      |  9 +++++++
 7 files changed, 187 insertions(+), 1 deletion(-)
 create mode 100644 t/t4034/ada/expect
 create mode 100644 t/t4034/ada/post
 create mode 100644 t/t4034/ada/pre
Documentation/gitattributes.txt +2 -0
index 462b79c..99ed04d 100644
@@ -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.
t/t4018-diff-funcname.sh +1 -1
index 4bd2a1c..082d3e8 100755
@@ -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 &&
t/t4034-diff-words.sh +1 -0
index 30d42cb..40ab333 100755
@@ -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
t/t4034/ada/expect new file +56 -0

56 lines not on this page · raw message

t/t4034/ada/post new file +59 -0

59 lines not on this page · raw message

t/t4034/ada/pre new file +59 -0

59 lines not on this page · raw message

userdiff.c +9 -0
index 1e7184f..ed958ef 100644
@@ -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"
Signature · 1 line
1.7.12.465.g03a9b82