diff options
author | June McEnroe <june@causal.agency> | 2019-02-08 22:59:02 -0500 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2019-02-08 22:59:02 -0500 |
commit | 76c9252b911670da493e0af94a689832af9a4589 (patch) | |
tree | 0eba7cf323d08e6e32cf527cb29995b1fde6b4d5 /bin | |
parent | Don't open folds when using {} (diff) | |
download | src-76c9252b911670da493e0af94a689832af9a4589.tar.gz src-76c9252b911670da493e0af94a689832af9a4589.zip |
Use X macros for hi classes
Diffstat (limited to '')
-rw-r--r-- | bin/hi.c | 43 |
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) { |