summaryrefslogtreecommitdiff
path: root/userdiff.c
diff options
context:
space:
mode:
authorMarc-André Lureau <mlureau@redhat.com>2019-05-16 23:58:15 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-05-17 03:54:02 (GMT)
commitd74e78602e3d562f5db64d553d4be21c201ef7b3 (patch)
treec720b811567ec4496d0c547bc0a6b2cba899f6c6 /userdiff.c
parentab15ad1a3b4b04a29415aef8c9afa2f64fc194a2 (diff)
downloadgit-d74e78602e3d562f5db64d553d4be21c201ef7b3.zip
git-d74e78602e3d562f5db64d553d4be21c201ef7b3.tar.gz
git-d74e78602e3d562f5db64d553d4be21c201ef7b3.tar.bz2
userdiff: add built-in pattern for rust
This adds xfuncname and word_regex patterns for Rust, a quite popular programming language. It also includes test cases for the xfuncname regex (t4018) and updated documentation. The word_regex pattern finds identifiers, integers, floats and operators, according to the Rust Reference Book. Cc: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'userdiff.c')
-rw-r--r--userdiff.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/userdiff.c b/userdiff.c
index 3a78fbf..8d7e62e 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -130,6 +130,13 @@ PATTERNS("ruby", "^[ \t]*((class|module|def)[ \t].*)$",
"(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*"
"|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?."
"|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"),
+PATTERNS("rust",
+ "^[\t ]*((pub(\\([^\\)]+\\))?[\t ]+)?((async|const|unsafe|extern([\t ]+\"[^\"]+\"))[\t ]+)?(struct|enum|union|mod|trait|fn|impl(<.+>)?)[ \t]+[^;]*)$",
+ /* -- */
+ "[a-zA-Z_][a-zA-Z0-9_]*"
+ "|[-+_0-9.eE]+(f32|f64|u8|u16|u32|u64|u128|usize|i8|i16|i32|i64|i128|isize)?"
+ "|0[box]?[0-9a-fA-F_]+(u8|u16|u32|u64|u128|usize|i8|i16|i32|i64|i128|isize)?"
+ "|[-+*\\/<>%&^|=!:]=|<<=?|>>=?|&&|\\|\\||->|=>|\\.{2}=|\\.{3}|::"),
PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$",
"[={}\"]|[^={}\" \t]+"),
PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",