mirror of
https://github.com/git/git.git
synced 2024-05-04 18:16:11 +02:00
Merge branch 've/userdiff-bash'
The userdiff pattern learned to identify the function definition in POSIX shells and bash. * ve/userdiff-bash: userdiff: support Bash
This commit is contained in:
commit
292e53fa9d
|
@ -802,6 +802,9 @@ patterns are available:
|
||||||
|
|
||||||
- `ada` suitable for source code in the Ada language.
|
- `ada` suitable for source code in the Ada language.
|
||||||
|
|
||||||
|
- `bash` suitable for source code in the Bourne-Again SHell language.
|
||||||
|
Covers a superset of POSIX shell function definitions.
|
||||||
|
|
||||||
- `bibtex` suitable for files with BibTeX coded references.
|
- `bibtex` suitable for files with BibTeX coded references.
|
||||||
|
|
||||||
- `cpp` suitable for source code in the C and C++ languages.
|
- `cpp` suitable for source code in the C and C++ languages.
|
||||||
|
|
|
@ -27,6 +27,7 @@ test_expect_success 'setup' '
|
||||||
|
|
||||||
diffpatterns="
|
diffpatterns="
|
||||||
ada
|
ada
|
||||||
|
bash
|
||||||
bibtex
|
bibtex
|
||||||
cpp
|
cpp
|
||||||
csharp
|
csharp
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
RIGHT() ((
|
||||||
|
|
||||||
|
ChangeMe = "$x" + "$y"
|
||||||
|
))
|
|
@ -0,0 +1,6 @@
|
||||||
|
function RIGHT {
|
||||||
|
function InvalidSyntax{
|
||||||
|
:
|
||||||
|
echo 'ChangeMe'
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
function RIGHT {
|
||||||
|
:
|
||||||
|
echo 'ChangeMe'
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
function RIGHT ( ) {
|
||||||
|
|
||||||
|
ChangeMe
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
RIGHT() [[ \
|
||||||
|
|
||||||
|
"$a" > "$ChangeMe"
|
||||||
|
]]
|
|
@ -0,0 +1,6 @@
|
||||||
|
function RIGHT {
|
||||||
|
functionInvalidSyntax {
|
||||||
|
:
|
||||||
|
echo 'ChangeMe'
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
function RIGHT(){
|
||||||
|
:
|
||||||
|
echo 'ChangeMe'
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
function RIGHT() {
|
||||||
|
|
||||||
|
ChangeMe
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
outer() {
|
||||||
|
RIGHT() {
|
||||||
|
:
|
||||||
|
echo 'ChangeMe'
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
_RIGHT_0n() {
|
||||||
|
|
||||||
|
ChangeMe
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
RIGHT(){
|
||||||
|
|
||||||
|
ChangeMe
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
RIGHT() {
|
||||||
|
|
||||||
|
ChangeMe
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
RIGHT ( ) {
|
||||||
|
|
||||||
|
ChangeMe
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
RIGHT() (
|
||||||
|
|
||||||
|
ChangeMe=2
|
||||||
|
)
|
|
@ -0,0 +1,4 @@
|
||||||
|
RIGHT() { # Comment
|
||||||
|
|
||||||
|
ChangeMe
|
||||||
|
}
|
21
userdiff.c
21
userdiff.c
|
@ -23,6 +23,27 @@ IPATTERN("ada",
|
||||||
"[a-zA-Z][a-zA-Z0-9_]*"
|
"[a-zA-Z][a-zA-Z0-9_]*"
|
||||||
"|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?"
|
"|[-+]?[0-9][0-9#_.aAbBcCdDeEfF]*([eE][+-]?[0-9_]+)?"
|
||||||
"|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"),
|
"|=>|\\.\\.|\\*\\*|:=|/=|>=|<=|<<|>>|<>"),
|
||||||
|
PATTERNS("bash",
|
||||||
|
/* Optional leading indentation */
|
||||||
|
"^[ \t]*"
|
||||||
|
/* Start of captured text */
|
||||||
|
"("
|
||||||
|
"("
|
||||||
|
/* POSIX identifier with mandatory parentheses */
|
||||||
|
"[a-zA-Z_][a-zA-Z0-9_]*[ \t]*\\([ \t]*\\))"
|
||||||
|
"|"
|
||||||
|
/* Bashism identifier with optional parentheses */
|
||||||
|
"(function[ \t]+[a-zA-Z_][a-zA-Z0-9_]*(([ \t]*\\([ \t]*\\))|([ \t]+))"
|
||||||
|
")"
|
||||||
|
/* Optional whitespace */
|
||||||
|
"[ \t]*"
|
||||||
|
/* Compound command starting with `{`, `(`, `((` or `[[` */
|
||||||
|
"(\\{|\\(\\(?|\\[\\[)"
|
||||||
|
/* End of captured text */
|
||||||
|
")",
|
||||||
|
/* -- */
|
||||||
|
/* Characters not in the default $IFS value */
|
||||||
|
"[^ \t]+"),
|
||||||
PATTERNS("dts",
|
PATTERNS("dts",
|
||||||
"!;\n"
|
"!;\n"
|
||||||
"!=\n"
|
"!=\n"
|
||||||
|
|
Loading…
Reference in New Issue