Git fork

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>

authored by

Marc-André Lureau and committed by
Junio C Hamano
d74e7860 ab15ad1a

+30
+2
Documentation/gitattributes.txt
··· 833 833 834 834 - `ruby` suitable for source code in the Ruby language. 835 835 836 + - `rust` suitable for source code in the Rust language. 837 + 836 838 - `tex` suitable for source code for LaTeX documents. 837 839 838 840
+1
t/t4018-diff-funcname.sh
··· 43 43 php 44 44 python 45 45 ruby 46 + rust 46 47 tex 47 48 custom1 48 49 custom2
+5
t/t4018/rust-fn
··· 1 + pub(self) fn RIGHT<T>(x: &[T]) where T: Debug { 2 + let _ = x; 3 + // a comment 4 + let a = ChangeMe; 5 + }
+5
t/t4018/rust-impl
··· 1 + impl<'a, T: AsRef<[u8]>> std::RIGHT for Git<'a> { 2 + 3 + pub fn ChangeMe(&self) -> () { 4 + } 5 + }
+5
t/t4018/rust-struct
··· 1 + #[derive(Debug)] 2 + pub(super) struct RIGHT<'a> { 3 + name: &'a str, 4 + age: ChangeMe, 5 + }
+5
t/t4018/rust-trait
··· 1 + unsafe trait RIGHT<T> { 2 + fn len(&self) -> u32; 3 + fn ChangeMe(&self, n: u32) -> T; 4 + fn iter<F>(&self, f: F) where F: Fn(T); 5 + }
+7
userdiff.c
··· 130 130 "(@|@@|\\$)?[a-zA-Z_][a-zA-Z0-9_]*" 131 131 "|[-+0-9.e]+|0[xXbB]?[0-9a-fA-F]+|\\?(\\\\C-)?(\\\\M-)?." 132 132 "|//=?|[-+*/<>%&^|=!]=|<<=?|>>=?|===|\\.{1,3}|::|[!=]~"), 133 + PATTERNS("rust", 134 + "^[\t ]*((pub(\\([^\\)]+\\))?[\t ]+)?((async|const|unsafe|extern([\t ]+\"[^\"]+\"))[\t ]+)?(struct|enum|union|mod|trait|fn|impl(<.+>)?)[ \t]+[^;]*)$", 135 + /* -- */ 136 + "[a-zA-Z_][a-zA-Z0-9_]*" 137 + "|[-+_0-9.eE]+(f32|f64|u8|u16|u32|u64|u128|usize|i8|i16|i32|i64|i128|isize)?" 138 + "|0[box]?[0-9a-fA-F_]+(u8|u16|u32|u64|u128|usize|i8|i16|i32|i64|i128|isize)?" 139 + "|[-+*\\/<>%&^|=!:]=|<<=?|>>=?|&&|\\|\\||->|=>|\\.{2}=|\\.{3}|::"), 133 140 PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$", 134 141 "[={}\"]|[^={}\" \t]+"), 135 142 PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",