summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/hi.c26
1 files changed, 13 insertions, 13 deletions
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(&regex, pattern, REG_EXTENDED | REG_NEWLINE | flags);
+	int error = regcomp(&regex, pattern, REG_EXTENDED | flags);
 	if (!error) return regex;
 	char buf[256];
 	regerror(error, &regex, 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);
 
dda7682d2ec85b6548cc&follow=1'>Sandbox calico with pledge(2) and unveil(2)June McEnroe 2020-08-27Add support for OpenBSDJune McEnroe 2020-08-27Remove rc scriptsJune McEnroe 2020-08-27contrib/palaver: Fix documented database pathJune McEnroe 2020-08-27contrib/palaver: Remove rc scriptJune McEnroe 2020-08-27contrib/palaver: Fix database search and creationJune McEnroe 2020-08-27contrib/palaver: Use pounce's XDG directoryJune McEnroe 2020-08-27contrib/palaver: Only allow HTTPSJune McEnroe 2020-08-25Support the pounce_env rc variableJune McEnroe 2020-08-25Remove deprecated option namesJune McEnroe The next release will be 2.0 so these can be removed now. 2020-08-25Document configuration and data file searchJune McEnroe 2020-08-24Use dataOpen for save fileJune McEnroe 2020-08-24Use configOpen to load localCAJune McEnroe 2020-08-24Use configPath to load client cert/privJune McEnroe 2020-08-24Use configOpen in getopt_configJune McEnroe 2020-08-24Import xdg.c from catgirlJune McEnroe 2020-08-23Replace “RAND_bytes” by “getentropy”Issam E. Maghni This removes the dependency on libcrypto. Signed-off-by: Issam E. Maghni <issam.e.maghni@mailbox.org> 2020-08-16contrib/palaver: Add no message preview flagsJune McEnroe 2020-08-13contrib/palaver: Don't set channel for PMsJune McEnroe 2020-08-13Fix unintended interception of NICK after registrationJune McEnroe Another bug caused by trying to support broken clients. I'm annoyed. 2020-08-12Add Additional Components section to READMEJune McEnroe 2020-08-12Document -L / palaver optionJune McEnroe 2020-08-11contrib/palaver: Document service configurationJune McEnroe 2020-08-11contrib/palaver: Add install target and rc scriptJune McEnroe 2020-08-11contrib/palaver: Implement command and notificationsJune McEnroe