Skip to content

Commit 2f47531

Browse files
committed
Merge branch 'bl/userdiff-octave'
The pattern "git diff/grep" use to extract funcname and words boundary for Matlab has been extend to cover Octave, which is more or less equivalent. * bl/userdiff-octave: userdiff: fix grammar and style issues userdiff: add Octave
2 parents 9476094 + 2731a78 commit 2f47531

7 files changed

+25
-2
lines changed

Documentation/gitattributes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ patterns are available:
819819

820820
- `java` suitable for source code in the Java language.
821821

822-
- `matlab` suitable for source code in the MATLAB language.
822+
- `matlab` suitable for source code in the MATLAB and Octave languages.
823823

824824
- `objc` suitable for source code in the Objective-C language.
825825

t/t4018/matlab-class-definition

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
classdef RIGHT
2+
properties
3+
ChangeMe
4+
end
5+
end

t/t4018/matlab-function

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
function y = RIGHT()
2+
x = 5;
3+
y = ChangeMe + x;
4+
end

t/t4018/matlab-octave-section-1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%%% RIGHT section
2+
# this is octave script
3+
ChangeMe = 1;

t/t4018/matlab-octave-section-2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## RIGHT section
2+
# this is octave script
3+
ChangeMe = 1;

t/t4018/matlab-section

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
%% RIGHT section
2+
% this is understood by both matlab and octave
3+
ChangeMe = 1;

userdiff.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ PATTERNS("java",
5858
"|[-+*/<>%&^|=!]="
5959
"|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"),
6060
PATTERNS("matlab",
61-
"^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$",
61+
/*
62+
* Octave pattern is mostly the same as matlab, except that '%%%' and
63+
* '##' can also be used to begin code sections, in addition to '%%'
64+
* that is understood by both.
65+
*/
66+
"^[[:space:]]*((classdef|function)[[:space:]].*)$|^(%%%?|##)[[:space:]].*$",
6267
"[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\.[*/\\^']|\\|\\||&&"),
6368
PATTERNS("objc",
6469
/* Negate C statements that can look like functions */

0 commit comments

Comments
 (0)