diff options
author | Johannes Sixt <j6t@kdbg.org> | 2019-05-30 18:44:35 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-05-30 09:53:26 -0700 |
commit | 33be7b38c23fbbaf75197f6150323e0d4c84bf12 (patch) | |
tree | 6fe384d0333f95ad2c83efe3cad2794d83046fd0 /userdiff.c | |
parent | userdiff: add built-in pattern for rust (diff) | |
download | tgif-33be7b38c23fbbaf75197f6150323e0d4c84bf12.tar.xz |
userdiff: two simplifications of patterns for rust
- Do not enforce (but assume) syntactic correctness of language
constructs that go into hunk headers: we only want to ensure that
the keywords actually are words and not just the initial part of
some identifier.
- In the word regex, match numbers only when they begin with a digit,
but then be liberal in what follows, assuming that the text that is
matched is syntactially correct.
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'userdiff.c')
-rw-r--r-- | userdiff.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/userdiff.c b/userdiff.c index 8d7e62e2a5..2bcf105caf 100644 --- a/userdiff.c +++ b/userdiff.c @@ -131,11 +131,10 @@ PATTERNS("ruby", "^[ \t]*((class|module|def)[ \t].*)$", "|[-+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]+[^;]*)$", + "^[\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)?" + "|[0-9][0-9_a-fA-Fiosuxz]*(\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?" "|[-+*\\/<>%&^|=!:]=|<<=?|>>=?|&&|\\|\\||->|=>|\\.{2}=|\\.{3}|::"), PATTERNS("bibtex", "(@[a-zA-Z]{1,}[ \t]*\\{{0,1}[ \t]*[^ \t\"@',\\#}{~%]*).*$", "[={}\"]|[^={}\" \t]+"), |