diff options
Diffstat (limited to 'userdiff.c')
-rw-r--r-- | userdiff.c | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/userdiff.c b/userdiff.c index 8578cb0d12..151d9a5278 100644 --- a/userdiff.c +++ b/userdiff.c @@ -7,12 +7,24 @@ static struct userdiff_driver *drivers; static int ndrivers; static int drivers_alloc; -#define PATTERNS(name, pattern, word_regex) \ - { name, NULL, -1, { pattern, REG_EXTENDED }, \ - word_regex "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" } -#define IPATTERN(name, pattern, word_regex) \ - { name, NULL, -1, { pattern, REG_EXTENDED | REG_ICASE }, \ - word_regex "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+" } +#define PATTERNS(lang, rx, wrx) { \ + .name = lang, \ + .binary = -1, \ + .funcname = { \ + .pattern = rx, \ + .cflags = REG_EXTENDED, \ + }, \ + .word_regex = wrx "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+", \ +} +#define IPATTERN(lang, rx, wrx) { \ + .name = lang, \ + .binary = -1, \ + .funcname = { \ + .pattern = rx, \ + .cflags = REG_EXTENDED | REG_ICASE, \ + }, \ + .word_regex = wrx "|[^[:space:]]|[\xc0-\xff][\x80-\xbf]+", \ +} /* * Built-in drivers for various languages, sorted by their names @@ -168,6 +180,18 @@ PATTERNS("java", "|[-+0-9.e]+[fFlL]?|0[xXbB]?[0-9a-fA-F]+[lL]?" "|[-+*/<>%&^|=!]=" "|--|\\+\\+|<<=?|>>>?=?|&&|\\|\\|"), +PATTERNS("kotlin", + "^[ \t]*(([a-z]+[ \t]+)*(fun|class|interface)[ \t]+.*)$", + /* -- */ + "[a-zA-Z_][a-zA-Z0-9_]*" + /* hexadecimal and binary numbers */ + "|0[xXbB][0-9a-fA-F_]+[lLuU]*" + /* integers and floats */ + "|[0-9][0-9_]*([.][0-9_]*)?([Ee][-+]?[0-9]+)?[fFlLuU]*" + /* floating point numbers beginning with decimal point */ + "|[.][0-9][0-9_]*([Ee][-+]?[0-9]+)?[fFlLuU]?" + /* unary and binary operators */ + "|[-+*/<>%&^|=!]==?|--|\\+\\+|<<=|>>=|&&|\\|\\||->|\\.\\*|!!|[?:.][.:]"), PATTERNS("markdown", "^ {0,3}#{1,6}[ \t].*", /* -- */ @@ -275,17 +299,13 @@ PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$", #undef IPATTERN static struct userdiff_driver driver_true = { - "diff=true", - NULL, - 0, - { NULL, 0 } + .name = "diff=true", + .binary = 0, }; static struct userdiff_driver driver_false = { - "!diff", - NULL, - 1, - { NULL, 0 } + .name = "!diff", + .binary = 1, }; struct find_by_namelen_data { |