summary refs log tree commit diff
path: root/bin/hi.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bin/hi.c43
1 files changed, 21 insertions, 22 deletions
diff --git a/bin/hi.c b/bin/hi.c
index 8a8b3f04..6fb0ee89 100644
--- a/bin/hi.c
+++ b/bin/hi.c
@@ -31,17 +31,22 @@
 typedef unsigned Set;
 #define SET(x) ((Set)1 << (x))
 
+#define ENUM_CLASS \
+	X(Normal)  \
+	X(Keyword) \
+	X(Macro)   \
+	X(String)  \
+	X(Escape)  \
+	X(Format)  \
+	X(Interp)  \
+	X(Comment) \
+	X(Todo)
+
 enum Class {
-	Normal,
-	Keyword,
-	Macro,
-	String,
-	Escape,
-	Format,
-	Interp,
-	Comment,
-	Todo,
-	ClassCount,
+#define X(class) class,
+	ENUM_CLASS
+#undef X
+	ClassLen,
 };
 
 struct Syntax {
@@ -197,7 +202,7 @@ static const struct Syntax ShSyntax[] = {
 	{ String, .parent = ~SET(Escape),
 		.pattern = "[\\]." },
 	{ Interp, .parent = ~SET(Escape),
-		.pattern = "[$]([!#$*-?@]|[_[:alnum:]]+)" },
+		.pattern = "[$]([!#$*?@-]|[_[:alnum:]]+)" },
 	{ Interp, .parent = ~SET(Escape),
 		.pattern = "[$][{][^}]*[}]" },
 	{ Interp, .parent = ~SET(Escape),
@@ -319,7 +324,7 @@ enum SGR {
 	SGRWhite,
 };
 
-static const enum SGR ANSIStyle[ClassCount][2] = {
+static const enum SGR ANSIStyle[ClassLen][2] = {
 	[Normal]  = { SGRReset },
 	[Keyword] = { SGRWhite },
 	[Macro]   = { SGRGreen },
@@ -454,16 +459,10 @@ static void htmlEscape(const char *str, size_t len) {
 	}
 }
 
-static const char *ClassName[ClassCount] = {
-	[Normal]  = "Normal",
-	[Keyword] = "Keyword",
-	[Macro]   = "Macro",
-	[String]  = "String",
-	[Escape]  = "Escape",
-	[Format]  = "Format",
-	[Interp]  = "Interp",
-	[Comment] = "Comment",
-	[Todo]    = "Todo",
+static const char *ClassName[ClassLen] = {
+#define X(class) [class] = #class,
+	ENUM_CLASS
+#undef X
 };
 
 static void htmlOutput(enum Class class, const char *str, size_t len) {
ass='nohover-highlight'> 2019-01-14Allow replacing empty string with fc old=newJune McEnroe 2019-01-13Enable warnings in libeditJune McEnroe 2019-01-13Show full path in RPS1June McEnroe 2019-01-13Shorten $HOME to ~ in prompt expansionJune McEnroe 2019-01-13Document PSlitJune McEnroe 2019-01-13Document PS0June McEnroe 2019-01-13Set PS0 in cashJune McEnroe 2019-01-13Add PS0June McEnroe 2019-01-13Change default ENV from cashrc to env.shJune McEnroe 2019-01-13Use colours in cash promptsJune McEnroe 2019-01-12Set PSlit like NetBSD shJune McEnroe 2019-01-12Install gnupg2 from pkgsrc and symlink gpgJune McEnroe 2019-01-12Reference cash builtin man pages in cash.1 SEE ALSOJune McEnroe 2019-01-12Restore cash builtin man page datesJune McEnroe 2019-01-12Use local libeditJune McEnroe 2019-01-12Replace libedit MakefileJune McEnroe 2019-01-11Import /usr/src/lib/libedit from NetBSD 8.0June McEnroe 2019-01-11Add PSlit for prompt escapesJune McEnroe 2019-01-11Don't make depend automaticallyJune McEnroe