summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/hi.c53
-rw-r--r--bin/man1/hi.110
2 files changed, 52 insertions, 11 deletions
diff --git a/bin/hi.c b/bin/hi.c
index 8793196d..ffc4709f 100644
--- a/bin/hi.c
+++ b/bin/hi.c
@@ -34,6 +34,7 @@ enum Class {
 	String,
 	Escape,
 	Format,
+	Interp,
 	Comment,
 	Todo,
 	ClassCount,
@@ -47,20 +48,22 @@ struct Syntax {
 	size_t subexp;
 };
 
-#define CKB "(^|[^[:alnum:]_]|\n)"
+#define WB "(^|[^[:alnum:]_]|\n)"
+#define TODO_PATTERN "FIXME|TODO|XXX"
+
 static const struct Syntax CSyntax[] = {
 	{ Keyword, .subexp = 2,
-		.pattern = CKB"(auto|extern|register|static|(_T|t)hread_local)"CKB },
+		.pattern = WB"(auto|extern|register|static|(_T|t)hread_local)"WB },
 	{ Keyword, .subexp = 2,
-		.pattern = CKB"(const|inline|restrict|volatile)"CKB },
+		.pattern = WB"(const|inline|restrict|volatile)"WB },
 	{ Keyword, .subexp = 2,
-		.pattern = CKB"((_A|a)lignas|_Atomic|(_N|n)oreturn)"CKB },
+		.pattern = WB"((_A|a)lignas|_Atomic|(_N|n)oreturn)"WB },
 	{ Keyword, .subexp = 2,
-		.pattern = CKB"(enum|struct|typedef|union)"CKB },
+		.pattern = WB"(enum|struct|typedef|union)"WB },
 	{ Keyword, .subexp = 2,
-		.pattern = CKB"(case|default|do|else|for|if|switch|while)"CKB },
+		.pattern = WB"(case|default|do|else|for|if|switch|while)"WB },
 	{ Keyword, .subexp = 2,
-		.pattern = CKB"(break|continue|goto|return)"CKB },
+		.pattern = WB"(break|continue|goto|return)"WB },
 	{ Macro,
 		.pattern = "^#.*" },
 	{ String, .subexp = 1,
@@ -87,7 +90,36 @@ static const struct Syntax CSyntax[] = {
 	{ Comment,
 		.pattern = "^#if 0", .pattend = "^#endif" },
 	{ Todo, .parent = Comment,
-		.pattern = "FIXME|TODO|XXX" },
+		.pattern = TODO_PATTERN },
+};
+
+static const struct Syntax MakeSyntax[] = {
+	{ Keyword, .subexp = 2,
+		.pattern = WB"(\\.(PHONY|PRECIOUS|SUFFIXES))"WB },
+	{ Macro,
+		.pattern = "^ *-?include" },
+	{ String, .subexp = 1,
+		.pattern = "[[:alnum:]._]+[[:blank:]]*[!+:?]?=[[:blank:]]*(.*)" },
+	{ Normal,
+		.pattern = "^\t.*" },
+	{ String,
+		.pattern = "'([^']|\\\\')*'" },
+	{ String,
+		.pattern = "\"([^\"]|\\\\\")*\"" },
+	{ Interp,
+		.pattern = "\\$[^$]" },
+	// These Interp patterns handle one level of nesting with the same
+	// delimiter.
+	{ Interp,
+		.pattern = "\\$\\((" "[^$)]" "|" "\\$\\([^)]*\\)" ")*\\)" },
+	{ Interp,
+		.pattern = "\\$\\{(" "[^$}]" "|" "\\$\\{[^}]*\\}" ")*\\}" },
+	{ Escape,
+		.pattern = "\\$\\$" },
+	{ Comment,
+		.pattern = "#.*" },
+	{ Todo, .parent = Comment,
+		.pattern = TODO_PATTERN },
 };
 
 static const struct Language {
@@ -97,6 +129,7 @@ static const struct Language {
 	size_t len;
 } Languages[] = {
 	{ "c", "\\.[ch]$", CSyntax, ARRAY_LEN(CSyntax) },
+	{ "make", "Makefile$", MakeSyntax, ARRAY_LEN(MakeSyntax) },
 };
 
 static regex_t compile(const char *pattern, int flags) {
@@ -194,6 +227,7 @@ static const enum SGR ansiStyle[ClassCount][2] = {
 	[String]  = { ANSICyan },
 	[Escape]  = { ANSIDefault },
 	[Format]  = { ANSICyan, ANSIBold },
+	[Interp]  = { ANSIGreen },
 	[Comment] = { ANSIBlue },
 	[Todo]    = { ANSIBlue, ANSIBold },
 };
@@ -242,6 +276,7 @@ static const enum IRC ircStyle[ClassCount][2] = {
 	[String]  = { IRCCyan },
 	[Escape]  = { IRCDefault },
 	[Format]  = { IRCCyan, IRCBold },
+	[Interp]  = { IRCGreen },
 	[Comment] = { IRCBlue },
 	[Todo]    = { IRCBlue, IRCBold },
 };
@@ -299,6 +334,7 @@ static const char *ClassName[ClassCount] = {
 	[String]  = "String",
 	[Escape]  = "Escape",
 	[Format]  = "Format",
+	[Interp]  = "Interp",
 	[Comment] = "Comment",
 	[Todo]    = "Todo",
 };
@@ -322,6 +358,7 @@ static void htmlDocumentHeader(const char *path) {
 		".hi.String  { color: teal; }\n"
 		".hi.Escape  { color: black; }\n"
 		".hi.Format  { color: teal; font-weight: bold }\n"
+		".hi.Interp  { color: green; }\n"
 		".hi.Comment { color: navy; }\n"
 		".hi.Todo    { color: navy; font-weight: bold }\n"
 		"</style>\n"
diff --git a/bin/man1/hi.1 b/bin/man1/hi.1
index 2a97ba77..a40e3674 100644
--- a/bin/man1/hi.1
+++ b/bin/man1/hi.1
@@ -1,4 +1,4 @@
-.Dd February 6, 2019
+.Dd February 7, 2019
 .Dt HI 1
 .Os
 .
@@ -21,6 +21,8 @@ highlights the contents of a
 or standard input
 and formats it
 on standard output.
+A maximum of 32K
+is read from standard input.
 .
 .Pp
 The arguments are as follows:
@@ -44,7 +46,8 @@ may be inferred from its name.
 .
 .Pp
 The following languages are supported:
-.Cm c .
+.Cm c ,
+.Cm make .
 .
 .Pp
 The output formats are as follows:
@@ -60,5 +63,6 @@ fragment with
 .Sy <span>
 classes.
 .It Cm html-document
-HTML document with default styles.
+HTML document with
+.Sy <style> .
 .El
n.lua?h=1.4.1&id=9dde6d38e9fc273fc62386eeda0da2e89a2cebfc&follow=1'>auth: document tweakables in lua scriptJason A. Donenfeld Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-17repolist: make owner clickable to searchJason A. Donenfeld Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-17ui-shared: move about tab all the way to the leftJason A. Donenfeld There were no objections (at the time of committing this): http://lists.zx2c4.com/pipermail/cgit/2013-May/001393.html http://lists.zx2c4.com/pipermail/cgit/2014-January/001904.html Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-17filter: don't forget to reap the auth filterJason A. Donenfeld Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-17cgit.c: free tmp variableJason A. Donenfeld Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-17Switch to exclusively using global ctxLukas Fleischer Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_print_http_headers() * cgit_print_docstart() * cgit_print_pageheader() Remove context parameter from all commands Drop the context parameter from the following functions (and all static helpers used by them) and use the global context instead: * cgit_get_cmd() * All cgit command functions. * cgit_clone_info() * cgit_clone_objects() * cgit_clone_head() * cgit_print_plain() * cgit_show_stats() In initialization routines, use the global context variable instead of passing a pointer around locally. Remove callback data parameter for cache slots This is no longer needed since the context is always read from the global context variable. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2014-01-16auth: have cgit calculate login addressJason A. Donenfeld This way we're sure to use virtual root, or any other strangeness encountered. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-16auth: lua string comparisons are time invariantJason A. Donenfeld By default, strings are compared by hash, so we can remove this comment. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-16authentication: use hidden form instead of refererJason A. Donenfeld This also gives us some CSRF protection. Note that we make use of the hmac to protect the redirect value. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-16auth: add basic authentication filter frameworkJason A. Donenfeld This leverages the new lua support. See filters/simple-authentication.lua for explaination of how this works. There is also additional documentation in cgitrc.5.txt. Though this is a cookie-based approach, cgit's caching mechanism is preserved for authenticated pages. Very plugable and extendable depending on user needs. The sample script uses an HMAC-SHA1 based cookie to store the currently logged in user, with an expiration date. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> 2014-01-16t0111: Additions and fixesLukas Fleischer * Rename the capitalize-* filters to dump.* since they also dump the arguments. * Add full argument validation to the email filters. Signed-off-by: Lukas Fleischer <cgit@cryptocrack.de> 2014-01-16parsing.c: Remove leading space from committerLukas Fleischer