Add built-in diff patterns for MATLAB code

MATLAB is often used in industry and academia for scientific
computations motivating it being included as a built-in pattern.

Signed-off-by: Gustaf Hendeby <hendeby@isy.liu.se>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Gustaf Hendeby 2011-11-15 21:15:03 +01:00 коммит произвёл Junio C Hamano
Родитель bc1bbe0c19
Коммит 53b10a1405
7 изменённых файлов: 39 добавлений и 1 удалений

Просмотреть файл

@ -500,6 +500,8 @@ patterns are available:
- `java` suitable for source code in the Java language.
- `matlab` suitable for source code in the MATLAB language.
- `objc` suitable for source code in the Objective-C language.
- `pascal` suitable for source code in the Pascal/Delphi language.

Просмотреть файл

@ -105,7 +105,7 @@ test_expect_funcname () {
grep "^@@.*@@ $1" diff
}
for p in bibtex cpp csharp fortran html java objc pascal perl php python ruby tex
for p in 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 &&

Просмотреть файл

@ -299,6 +299,7 @@ test_language_driver csharp
test_language_driver fortran
test_language_driver html
test_language_driver java
test_language_driver matlab
test_language_driver objc
test_language_driver pascal
test_language_driver perl

14
t/t4034/matlab/expect Normal file
Просмотреть файл

@ -0,0 +1,14 @@
<BOLD>diff --git a/pre b/post<RESET>
<BOLD>index dc204db..70e05f0 100644<RESET>
<BOLD>--- a/pre<RESET>
<BOLD>+++ b/post<RESET>
<CYAN>@@ -1,9 +1,9 @@<RESET>
(<RED>1<RESET><GREEN>0<RESET>) (<RED>-1e10<RESET><GREEN>-0e10<RESET>) '<RED>b<RESET><GREEN>y<RESET>';
[<RED>a<RESET><GREEN>x<RESET>] {<RED>a<RESET><GREEN>x<RESET>} <RED>a<RESET><GREEN>x<RESET>.<RED>b<RESET><GREEN>y<RESET>;
~<RED>a<RESET><GREEN>x<RESET>;
<RED>a<RESET><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 a<RESET><GREEN>y 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>a<RESET><GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET><GREEN>y<RESET>;
<RED>a<RESET><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><GREEN>y<RESET>;
<RED>a<RESET><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><GREEN>y<RESET>;
<RED>a<RESET><GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>~=<RED>b<RESET><GREEN>y<RESET>;
<RED>a<RESET><GREEN>x<RESET>,<RED>b<RESET><GREEN>y<RESET>;

9
t/t4034/matlab/post Normal file
Просмотреть файл

@ -0,0 +1,9 @@
(0) (-0e10) 'y';
[x] {x} x.y;
~x;
x*y x.*y x/y x./y x^y x.^y x.\y x.';
x+y x-y;
x&y x&&y x|y x||y;
x<y x<=y x>y x>=y;
x==y x~=y;
x,y;

9
t/t4034/matlab/pre Normal file
Просмотреть файл

@ -0,0 +1,9 @@
(1) (-1e10) 'b';
[a] {a} a.b;
~a;
a*b a.*b a/b a./b a^b a.^b a.\b a.';
a+b a-b;
a&b a&&b a|b a||b;
a<b a<=b a>b a>=b;
a==b a~=b;
a,b;

Просмотреть файл

@ -37,6 +37,9 @@ PATTERNS("java",
"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?"
"|[-+*/<>%&^|=!]="
"|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
PATTERNS("matlab",
"^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$",
"[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\.[*/\\^']|\\|\\||&&"),
PATTERNS("objc",
/* Negate C statements that can look like functions */
"!^[ \t]*(do|for|if|else|return|switch|while)\n"