From 85b57ff197b7b0a1141938ce2bda2ae38e39bdb9 Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Sun, 10 Feb 2019 16:51:51 -0500 Subject: Replace uses of pattend with newline patterns --- bin/hi.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'bin') diff --git a/bin/hi.c b/bin/hi.c index 24f825ff..e72b2756 100644 --- a/bin/hi.c +++ b/bin/hi.c @@ -58,6 +58,7 @@ static const char *ClassName[ClassLen] = { struct Syntax { enum Class class; Set parent; + bool newline; size_t subexp; const char *pattern; const char *pattend; @@ -101,9 +102,8 @@ static const struct Syntax CSyntax[] = { }, { Comment, .parent = ~SET(String), .pattern = "//.*" }, - { Comment, .parent = ~SET(String), - .pattern = "/[*]", - .pattend = "[*]/" }, + { Comment, .parent = ~SET(String), .newline = true, + .pattern = "/[*]" "([^*]|[*][^/])*" "[*]/" }, { Todo, .parent = SET(Comment), .pattern = PATTERN_TODO }, }; @@ -177,9 +177,10 @@ static const struct Syntax ShSyntax[] = { ")" WB }, { String, .pattern = PATTERN_DQ }, - { String, .subexp = 1, - .pattern = "<<-?" WS "EOF.*(\n)", - .pattend = "^\t*EOF$" }, + { String, .newline = true, .subexp = 1, .pattern = + "<<-?" WS "EOF[^\n]*\n" + "(([^\n]|\n\t*[^E]|\n\t*E[^O]|\n\t*EO[^F]|\n\t*EOF[^\n])*)" + "\n\t*EOF\n" }, { Escape, .parent = SET(String), .pattern = "[\\][\"$\\`]" }, { String, .parent = ~SET(Escape), @@ -192,11 +193,10 @@ static const struct Syntax ShSyntax[] = { .pattern = "[$][(][^)]*[)]" "|" "`[^`]*`" }, { String, .pattern = "'[^']*'" }, - { String, .subexp = 1, - .pattern = "<<-?" WS "'EOF'.*(\n)", - .pattend = "^\t*EOF$" }, - { Normal, .parent = SET(String), - .pattern = "^\t*EOF$" }, + { String, .subexp = 1, .newline = true, .pattern = + "<<-?" WS "'EOF'[^\n]*\n" + "(([^\n]|\n\t*[^E]|\n\t*E[^O]|\n\t*EO[^F]|\n\t*EOF[^\n])*)" + "\n\t*EOF\n" }, { Comment, .parent = ~SET(String), .subexp = 2, .pattern = "(^|" WS ")" "(#.*)" }, { Todo, .parent = SET(Comment), @@ -218,7 +218,7 @@ static const struct Language { static regex_t compile(const char *pattern, int flags) { regex_t regex; - int error = regcomp(®ex, pattern, REG_EXTENDED | REG_NEWLINE | flags); + int error = regcomp(®ex, pattern, REG_EXTENDED | flags); if (!error) return regex; char buf[256]; regerror(error, ®ex, buf, sizeof(buf)); @@ -229,7 +229,7 @@ enum { SubsLen = 8 }; static void highlight(struct Language lang, enum Class *hi, const char *str) { for (size_t i = 0; i < lang.len; ++i) { struct Syntax syn = lang.syntax[i]; - regex_t regex = compile(syn.pattern, 0); + regex_t regex = compile(syn.pattern, syn.newline ? 0 : REG_NEWLINE); regex_t regend = {0}; if (syn.pattend) regend = compile(syn.pattend, 0); -- cgit 1.4.1 im?id=727506dbebb5afc8a81b72c81630a04a0feb8a54&follow=1'>Set the write variable for nvim man modeJune McEnroe 2019-10-13Add All Systems RedJune McEnroe 2019-10-10Add The Book of PhoenixJune McEnroe 2019-10-03Add two Kim Petras songsJune McEnroe 2019-10-02Update neovim 0.4.2June McEnroe 2019-10-02Claim to be curl(1) in titleJune McEnroe 2019-10-02Add The Red Threads of FortuneJune McEnroe 2019-09-28Add The Black Tides of HeavenJune McEnroe 2019-09-27Fail on HTTP failure status in titleJune McEnroe 2019-09-23Add Trail of LightningJune McEnroe 2019-09-22Revert "Enable cookies in title"June McEnroe 2019-09-20Enable cookies in titleJune McEnroe 2019-09-16Use sensitivity aliases in TF2June McEnroe 2019-09-16Add The Just CityJune McEnroe 2019-09-12Only GET the final redirect locationJune McEnroe 2019-09-12Consume entire bodyJune McEnroe 2019-09-10Add title -v flagJune McEnroe 2019-09-10Use curl error bufferJune McEnroe 2019-09-10Set Accept-Encoding in titleJune McEnroe 2019-09-08Set title User-AgentJune McEnroe 2019-09-07Add -x flag to titleJune McEnroe 2019-09-07Ignore SIGPIPE in relayJune McEnroe 2019-09-07Add A Memory Called EmpireJune McEnroe 2019-09-05Handle lack of Content-TypeJune McEnroe 2019-09-05Use CURLINFO_CONTENT_TYPEJune McEnroe 2019-09-05Decode entities in titlesJune McEnroe 2019-09-05Print title as soon as it's availableJune McEnroe 2019-09-05Use CURL_PREFIX to set flagsJune McEnroe 2019-09-05Add titleJune McEnroe 2019-09-04Add Avorter n'est pas tuerJune McEnroe 2019-08-29Unset executable on shell scriptsJune McEnroe 2019-08-29Add long-missing setopt to bin.7June McEnroe 2019-08-29Add editJune McEnroe