Git fork

userdiff: add Octave

Octave pattern is almost the same as matlab, except
that '%%%' and '##' can also be used to begin code sections,
in addition to '%%' that is understood by both. Octave
pattern is merged into Matlab pattern. Test cases for
the hunk header patterns of matlab and octave under
t/t4018 are added.

Signed-off-by: Boxuan Li <liboxuan@connect.hku.hk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Boxuan Li and committed by
Junio C Hamano
91bf382f ab15ad1a

+23 -2
+1 -1
Documentation/gitattributes.txt
··· 819 819 820 820 - `java` suitable for source code in the Java language. 821 821 822 - - `matlab` suitable for source code in the MATLAB language. 822 + - `matlab` suitable for source code in the MATLAB and Octave language. 823 823 824 824 - `objc` suitable for source code in the Objective-C language. 825 825
+5
t/t4018/matlab-class-definition
··· 1 + classdef RIGHT 2 + properties 3 + ChangeMe 4 + end 5 + end
+4
t/t4018/matlab-function
··· 1 + function y = RIGHT() 2 + x = 5; 3 + y = ChangeMe + x; 4 + end
+3
t/t4018/matlab-octave-section-1
··· 1 + %%% RIGHT section 2 + # this is octave script 3 + ChangeMe = 1;
+3
t/t4018/matlab-octave-section-2
··· 1 + ## RIGHT section 2 + # this is octave script 3 + ChangeMe = 1;
+3
t/t4018/matlab-section
··· 1 + %% RIGHT section 2 + % this is understood by both matlab and octave 3 + ChangeMe = 1;
+4 -1
userdiff.c
··· 58 58 "|[-+*/<>%&^|=!]=" 59 59 "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), 60 60 PATTERNS("matlab", 61 - "^[[:space:]]*((classdef|function)[[:space:]].*)$|^%%[[:space:]].*$", 61 + /* Octave pattern is mostly the same as matlab, except that '%%%' and 62 + * '##' can also be used to begin code sections, in addition to '%%' 63 + * that is understood by both. */ 64 + "^[[:space:]]*((classdef|function)[[:space:]].*)$|^(%%%?|##)[[:space:]].*$", 62 65 "[a-zA-Z_][a-zA-Z0-9_]*|[-+0-9.e]+|[=~<>]=|\\.[*/\\^']|\\|\\||&&"), 63 66 PATTERNS("objc", 64 67 /* Negate C statements that can look like functions */