{"thread":{"id":"28924","subject":"[PATCH] Add built-in diff patterns for MATLAB code","startedAt":"2011-11-13T13:42:44Z","lastAt":"2011-11-15T20:15:03Z","messageCount":5,"participants":["Gustaf Hendeby","Thomas Rast"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"179384","messageId":"1321191764-11972-1-git-send-email-hendeby@isy.liu.se","threadId":"28924","inReplyTo":null,"subject":"[PATCH] Add built-in diff patterns for MATLAB code","fromName":"Gustaf Hendeby","fromEmail":"hendeby@isy.liu.se","sentAt":"2011-11-13T13:42:44Z","receivedAt":"2011-11-13T13:42:44Z","isPatch":true,"sender":{"key":"hendeby@isy.liu.se","avatar":"https://avatars.githubusercontent.com/u/730316?v=4"},"body":"MATLAB is often used in industry and academia for scientific\ncomputations motivating it being included as a build in pattern.\n\nSigned-off-by: Gustaf Hendeby <hendeby@isy.liu.se>\n---\n Documentation/gitattributes.txt |    2 ++\n t/t4018-diff-funcname.sh        |    2 +-\n t/t4034-diff-words.sh           |    1 +\n t/t4034/matlab/expect           |   14 ++++++++++++++\n t/t4034/matlab/post             |    9 +++++++++\n t/t4034/matlab/pre              |    9 +++++++++\n userdiff.c                      |    3 +++\n 7 files changed, 39 insertions(+), 1 deletions(-)\n create mode 100644 t/t4034/matlab/expect\n create mode 100644 t/t4034/matlab/post\n create mode 100644 t/t4034/matlab/pre\n\ndiff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\nindex 25e46ae..a85b187 100644\n--- a/Documentation/gitattributes.txt\n+++ b/Documentation/gitattributes.txt\n@@ -500,6 +500,8 @@ patterns are available:\n \n - `java` suitable for source code in the Java language.\n \n+- `matlab` suitable for source code in the MATLAB language.\n+\n - `objc` suitable for source code in the Objective-C language.\n \n - `pascal` suitable for source code in the Pascal/Delphi language.\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex b68c56b..4bd2a1c 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -105,7 +105,7 @@ test_expect_funcname () {\n \tgrep \"^@@.*@@ $1\" diff\n }\n \n-for p in bibtex cpp csharp fortran html java objc pascal perl php python ruby tex\n+for p in bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex\n do\n \ttest_expect_success \"builtin $p pattern compiles\" '\n \t\techo \"*.java diff=$p\" >.gitattributes &&\ndiff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\nindex c374aa4..6f1e5a2 100755\n--- a/t/t4034-diff-words.sh\n+++ b/t/t4034-diff-words.sh\n@@ -299,6 +299,7 @@ test_language_driver csharp\n test_language_driver fortran\n test_language_driver html\n test_language_driver java\n+test_language_driver matlab\n test_language_driver objc\n test_language_driver pascal\n test_language_driver perl\ndiff --git a/t/t4034/matlab/expect b/t/t4034/matlab/expect\nnew file mode 100644\nindex 0000000..d846ce9\n--- /dev/null\n+++ b/t/t4034/matlab/expect\n@@ -0,0 +1,14 @@\n+<BOLD>diff --git a/pre b/post<RESET>\n+<BOLD>index ac2af08..0f07497 100644<RESET>\n+<BOLD>--- a/pre<RESET>\n+<BOLD>+++ b/post<RESET>\n+<CYAN>@@ -1,9 +1,9 @@<RESET>\n+(<RED>1<RESET><GREEN>0<RESET>) (<RED>-1e10<RESET><GREEN>-0e10<RESET>) '<RED>b<RESET><GREEN>y<RESET>';\n+[<RED>a<RESET><GREEN>x<RESET>] {<RED>a<RESET><GREEN>x<RESET>} <RED>a<RESET><GREEN>x<RESET>.<RED>b<RESET><GREEN>y<RESET>;\n+~<RED>a<RESET><GREEN>x<RESET>;\n+<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<RESET><GREEN>y<RESET>;\n+<RED>a<RESET><GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET><GREEN>y<RESET>;\n+<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>;\n+<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>;\n+<GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>~=<RED>b<RESET><GREEN>y<RESET>;\n+<RED>a<RESET><GREEN>x<RESET>,<RED>b<RESET><GREEN>y<RESET>;\ndiff --git a/t/t4034/matlab/post b/t/t4034/matlab/post\nnew file mode 100644\nindex 0000000..0f07497\n--- /dev/null\n+++ b/t/t4034/matlab/post\n@@ -0,0 +1,9 @@\n+(0) (-0e10) 'y';\n+[x] {x} x.y;\n+~x;\n+x*y x.*y x/y x./y x^y x.^y;\n+x+y x-y;\n+x&y x&&y x|y x||y;\n+x<y x<=y x>y x>=y;\n+x==y x~=y;\n+x,y;\ndiff --git a/t/t4034/matlab/pre b/t/t4034/matlab/pre\nnew file mode 100644\nindex 0000000..ac2af08\n--- /dev/null\n+++ b/t/t4034/matlab/pre\n@@ -0,0 +1,9 @@\n+(1) (-1e10) 'b';\n+[a] {a} a.b;\n+~a;\n+a*b a.*b a/b a./b a^b a.^b;\n+a+b a-b;\n+a&b a&&b a|b a||b;\n+a<b a<=b a>b a>=b;\n+==b a~=b;\n+a,b;\ndiff --git a/userdiff.c b/userdiff.c\nindex bf553ad..e0948e6 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -37,6 +37,9 @@ PATTERNS(\"java\",\n \t \"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?\"\n \t \"|[-+*/<>%&^|=!]=\"\n \t \"|--|\\\\+\\\\+|<<=?|>>>?=?|&&|\\\\|\\\\|\"),\n+PATTERNS(\"matlab\",\n+\t \"^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$\",\n+\t \"[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\\\|\\\\||&&\"),\n PATTERNS(\"objc\",\n \t /* Negate C statements that can look like functions */\n \t \"!^[ \\t]*(do|for|if|else|return|switch|while)\\n\"\n-- \n1.7.8.rc1.222.g29897\n"},{"id":"179499","messageId":"201111151337.07013.trast@student.ethz.ch","threadId":"28924","inReplyTo":"1321191764-11972-1-git-send-email-hendeby@isy.liu.se","subject":"Re: [PATCH] Add built-in diff patterns for MATLAB code","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2011-11-15T12:37:06Z","receivedAt":"2011-11-15T12:37:06Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Gustaf Hendeby wrote:\n> +PATTERNS(\"matlab\",\n> +\t \"^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$\",\n> +\t \"[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\\\|\\\\||&&\"),\n\nShouldn't you, for matlab, ensure that ./ \"sticks\" as a single word\nsince it is an operator?  At least we used the same logic for the C ||\nand && operators, which you copied.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"179500","messageId":"df238a1919b7c7d05749b4aa637fe2c7@isy.liu.se","threadId":"28924","inReplyTo":"201111151337.07013.trast@student.ethz.ch","subject":"Re: [PATCH] Add built-in diff patterns for MATLAB code","fromName":"Gustaf Hendeby","fromEmail":"hendeby@isy.liu.se","sentAt":"2011-11-15T12:47:48Z","receivedAt":"2011-11-15T12:47:48Z","isPatch":true,"sender":{"key":"hendeby@isy.liu.se","avatar":"https://avatars.githubusercontent.com/u/730316?v=4"},"body":" On Tue, 15 Nov 2011 13:37:06 +0100, Thomas Rast wrote:\n> Gustaf Hendeby wrote:\n>> +PATTERNS(\"matlab\",\n>> +\t \n>> \"^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$\",\n>> +\t \"[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\\\|\\\\||&&\"),\n>\n> Shouldn't you, for matlab, ensure that ./ \"sticks\" as a single word\n> since it is an operator?  At least we used the same logic for the C \n> ||\n> and && operators, which you copied.\n\n Good point Thomas, I forgot all about the .-operators.  I will add \n \\.[*/^'] as words, are there any other ones to consider?  Thanks for \n paying attention!\n\n /Gustaf\n"},{"id":"179501","messageId":"201111151414.34141.trast@student.ethz.ch","threadId":"28924","inReplyTo":"df238a1919b7c7d05749b4aa637fe2c7@isy.liu.se","subject":"Re: [PATCH] Add built-in diff patterns for MATLAB code","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2011-11-15T13:14:34Z","receivedAt":"2011-11-15T13:14:34Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Gustaf Hendeby wrote:\n>  On Tue, 15 Nov 2011 13:37:06 +0100, Thomas Rast wrote:\n> > Gustaf Hendeby wrote:\n> >> +PATTERNS(\"matlab\",\n> >> +\t \n> >> \"^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$\",\n> >> +\t \"[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\\\|\\\\||&&\"),\n> >\n> > Shouldn't you, for matlab, ensure that ./ \"sticks\" as a single word\n> > since it is an operator?  At least we used the same logic for the C \n> > ||\n> > and && operators, which you copied.\n> \n>  Good point Thomas, I forgot all about the .-operators.  I will add \n>  \\.[*/^'] as words, are there any other ones to consider?  Thanks for \n>  paying attention!\n\nUh, I'm afraid it's been years since I did matlab.  But\n\n  http://www.mathworks.ch/help/techdoc/matlab_prog/f0-40063.html\n\nseems to indicate you forgot '.\\'.\n\nPlease also update the testcases to whether this splits correctly,\ne.g., by changing './' to '/'.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"179529","messageId":"1321388103-32225-1-git-send-email-hendeby@isy.liu.se","threadId":"28924","inReplyTo":"201111151414.34141.trast@student.ethz.ch","subject":"[PATCH v2] Add built-in diff patterns for MATLAB code","fromName":"Gustaf Hendeby","fromEmail":"hendeby@isy.liu.se","sentAt":"2011-11-15T20:15:03Z","receivedAt":"2011-11-15T20:15:03Z","isPatch":true,"sender":{"key":"hendeby@isy.liu.se","avatar":"https://avatars.githubusercontent.com/u/730316?v=4"},"body":"MATLAB is often used in industry and academia for scientific\ncomputations motivating it being included as a build in pattern.\n\nSigned-off-by: Gustaf Hendeby <hendeby@isy.liu.se>\n---\n\nThis version of this commit adds the missing patterns to make the\n.-operators words and adds these to the test.  Lots of thanks Thomas\nfor keeping your eyes open and catching this.\n\n/Gustaf\n\n Documentation/gitattributes.txt |    2 ++\n t/t4018-diff-funcname.sh        |    2 +-\n t/t4034-diff-words.sh           |    1 +\n t/t4034/matlab/expect           |   14 ++++++++++++++\n t/t4034/matlab/post             |    9 +++++++++\n t/t4034/matlab/pre              |    9 +++++++++\n userdiff.c                      |    3 +++\n 7 files changed, 39 insertions(+), 1 deletions(-)\n create mode 100644 t/t4034/matlab/expect\n create mode 100644 t/t4034/matlab/post\n create mode 100644 t/t4034/matlab/pre\n\ndiff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt\nindex 25e46ae..a85b187 100644\n--- a/Documentation/gitattributes.txt\n+++ b/Documentation/gitattributes.txt\n@@ -500,6 +500,8 @@ patterns are available:\n \n - `java` suitable for source code in the Java language.\n \n+- `matlab` suitable for source code in the MATLAB language.\n+\n - `objc` suitable for source code in the Objective-C language.\n \n - `pascal` suitable for source code in the Pascal/Delphi language.\ndiff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh\nindex b68c56b..4bd2a1c 100755\n--- a/t/t4018-diff-funcname.sh\n+++ b/t/t4018-diff-funcname.sh\n@@ -105,7 +105,7 @@ test_expect_funcname () {\n \tgrep \"^@@.*@@ $1\" diff\n }\n \n-for p in bibtex cpp csharp fortran html java objc pascal perl php python ruby tex\n+for p in bibtex cpp csharp fortran html java matlab objc pascal perl php python ruby tex\n do\n \ttest_expect_success \"builtin $p pattern compiles\" '\n \t\techo \"*.java diff=$p\" >.gitattributes &&\ndiff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh\nindex c374aa4..6f1e5a2 100755\n--- a/t/t4034-diff-words.sh\n+++ b/t/t4034-diff-words.sh\n@@ -299,6 +299,7 @@ test_language_driver csharp\n test_language_driver fortran\n test_language_driver html\n test_language_driver java\n+test_language_driver matlab\n test_language_driver objc\n test_language_driver pascal\n test_language_driver perl\ndiff --git a/t/t4034/matlab/expect b/t/t4034/matlab/expect\nnew file mode 100644\nindex 0000000..72cf3e9\n--- /dev/null\n+++ b/t/t4034/matlab/expect\n@@ -0,0 +1,14 @@\n+<BOLD>diff --git a/pre b/post<RESET>\n+<BOLD>index dc204db..70e05f0 100644<RESET>\n+<BOLD>--- a/pre<RESET>\n+<BOLD>+++ b/post<RESET>\n+<CYAN>@@ -1,9 +1,9 @@<RESET>\n+(<RED>1<RESET><GREEN>0<RESET>) (<RED>-1e10<RESET><GREEN>-0e10<RESET>) '<RED>b<RESET><GREEN>y<RESET>';\n+[<RED>a<RESET><GREEN>x<RESET>] {<RED>a<RESET><GREEN>x<RESET>} <RED>a<RESET><GREEN>x<RESET>.<RED>b<RESET><GREEN>y<RESET>;\n+~<RED>a<RESET><GREEN>x<RESET>;\n+<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>.';\n+<RED>a<RESET><GREEN>x<RESET>+<RED>b a<RESET><GREEN>y x<RESET>-<RED>b<RESET><GREEN>y<RESET>;\n+<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>;\n+<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>;\n+<RED>a<RESET><GREEN>x<RESET>==<RED>b a<RESET><GREEN>y x<RESET>~=<RED>b<RESET><GREEN>y<RESET>;\n+<RED>a<RESET><GREEN>x<RESET>,<RED>b<RESET><GREEN>y<RESET>;\ndiff --git a/t/t4034/matlab/post b/t/t4034/matlab/post\nnew file mode 100644\nindex 0000000..70e05f0\n--- /dev/null\n+++ b/t/t4034/matlab/post\n@@ -0,0 +1,9 @@\n+(0) (-0e10) 'y';\n+[x] {x} x.y;\n+~x;\n+x*y x.*y x/y x./y x^y x.^y x.\\y x.';\n+x+y x-y;\n+x&y x&&y x|y x||y;\n+x<y x<=y x>y x>=y;\n+x==y x~=y;\n+x,y;\ndiff --git a/t/t4034/matlab/pre b/t/t4034/matlab/pre\nnew file mode 100644\nindex 0000000..dc204db\n--- /dev/null\n+++ b/t/t4034/matlab/pre\n@@ -0,0 +1,9 @@\n+(1) (-1e10) 'b';\n+[a] {a} a.b;\n+~a;\n+a*b a.*b a/b a./b a^b a.^b a.\\b a.';\n+a+b a-b;\n+a&b a&&b a|b a||b;\n+a<b a<=b a>b a>=b;\n+a==b a~=b;\n+a,b;\ndiff --git a/userdiff.c b/userdiff.c\nindex bf553ad..7c983c1 100644\n--- a/userdiff.c\n+++ b/userdiff.c\n@@ -37,6 +37,9 @@ PATTERNS(\"java\",\n \t \"|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?\"\n \t \"|[-+*/<>%&^|=!]=\"\n \t \"|--|\\\\+\\\\+|<<=?|>>>?=?|&&|\\\\|\\\\|\"),\n+PATTERNS(\"matlab\",\n+\t \"^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$\",\n+\t \"[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\\\.[*/\\\\^']|\\\\|\\\\||&&\"),\n PATTERNS(\"objc\",\n \t /* Negate C statements that can look like functions */\n \t \"!^[ \\t]*(do|for|if|else|return|switch|while)\\n\"\n-- \n1.7.8.rc2.209.geddc4\n"}]}