Skip to content

Commit f3a70e9

Browse files
committed
Merge branch 'bc/fortran-userdiff' into maint
* bc/fortran-userdiff: userdiff.c: add builtin fortran regex patterns
2 parents 5501bf8 + 909a549 commit f3a70e9

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

Documentation/gitattributes.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,8 @@ patterns are available:
477477

478478
- `csharp` suitable for source code in the C# language.
479479

480+
- `fortran` suitable for source code in the Fortran language.
481+
480482
- `html` suitable for HTML/XHTML documents.
481483

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

t/t4018-diff-funcname.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ EOF
3232

3333
sed 's/beer\\/beer,\\/' < Beer.java > Beer-correct.java
3434

35-
builtin_patterns="bibtex cpp csharp html java objc pascal php python ruby tex"
35+
builtin_patterns="bibtex cpp csharp fortran html java objc pascal php python ruby tex"
3636
for p in $builtin_patterns
3737
do
3838
test_expect_success "builtin $p pattern compiles" '

userdiff.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,23 @@ static int drivers_alloc;
99

1010
#define PATTERNS(name, pattern, word_regex) \
1111
{ name, NULL, -1, { pattern, REG_EXTENDED }, word_regex }
12+
#define IPATTERN(name, pattern, word_regex) \
13+
{ name, NULL, -1, { pattern, REG_EXTENDED | REG_ICASE }, word_regex }
1214
static struct userdiff_driver builtin_drivers[] = {
15+
IPATTERN("fortran",
16+
"!^([C*]|[ \t]*!)\n"
17+
"!^[ \t]*MODULE[ \t]+PROCEDURE[ \t]\n"
18+
"^[ \t]*((END[ \t]+)?(PROGRAM|MODULE|BLOCK[ \t]+DATA"
19+
"|([^'\" \t]+[ \t]+)*(SUBROUTINE|FUNCTION))[ \t]+[A-Z].*)$",
20+
/* -- */
21+
"[a-zA-Z][a-zA-Z0-9_]*"
22+
"|\\.([Ee][Qq]|[Nn][Ee]|[Gg][TtEe]|[Ll][TtEe]|[Tt][Rr][Uu][Ee]|[Ff][Aa][Ll][Ss][Ee]|[Aa][Nn][Dd]|[Oo][Rr]|[Nn]?[Ee][Qq][Vv]|[Nn][Oo][Tt])\\."
23+
/* numbers and format statements like 2E14.4, or ES12.6, 9X.
24+
* Don't worry about format statements without leading digits since
25+
* they would have been matched above as a variable anyway. */
26+
"|[-+]?[0-9.]+([AaIiDdEeFfLlTtXx][Ss]?[-+]?[0-9.]*)?(_[a-zA-Z0-9][a-zA-Z0-9_]*)?"
27+
"|//|\\*\\*|::|[/<>=]="
28+
"|[^[:space:]]|[\x80-\xff]+"),
1329
PATTERNS("html", "^[ \t]*(<[Hh][1-6][ \t].*>.*)$",
1430
"[^<>= \t]+|[^[:space:]]|[\x80-\xff]+"),
1531
PATTERNS("java",
@@ -101,6 +117,7 @@ PATTERNS("csharp",
101117
{ "default", NULL, -1, { NULL, 0 } },
102118
};
103119
#undef PATTERNS
120+
#undef IPATTERN
104121

105122
static struct userdiff_driver driver_true = {
106123
"diff=true",

0 commit comments

Comments
 (0)