From 8948d93345839088f9bd9ccadd15efb9c78393fd Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Mon, 9 Dec 2013 18:40:33 +0000 Subject: [PATCH 1/1] makewhatis(8): replace mdoc(7) OS text macros --- usr.sbin/makewhatis/makewhatis.c | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/usr.sbin/makewhatis/makewhatis.c b/usr.sbin/makewhatis/makewhatis.c index e5e2027e68..003b4df508 100644 --- a/usr.sbin/makewhatis/makewhatis.c +++ b/usr.sbin/makewhatis/makewhatis.c @@ -617,6 +617,38 @@ process_man_line(char *line) } } +struct mdoc_text { + const char *mdoc; + const char *text; +}; + +static int +process_mdoc_macro(char *line) +{ + static const struct mdoc_text list[] = { + { ".At", "AT&T UNIX" }, + { ".Bsx", "BSD/OS" }, + { ".Bx", "BSD" }, + { ".Dx", "DragonFly" }, + { ".Fx", "FreeBSD" }, + { ".Nx", "NetBSD" }, + { ".Ox", "OpenBSD" }, + { ".Ux", "UNIX" }, + }; + unsigned int i; + + for (i = 0; i < sizeof(list) / sizeof(list[0]); ++i) { + if (!strcmp(line, list[i].mdoc)) { + sbuf_append(whatis_proto, list[i].text, + strlen(list[i].text)); + sbuf_append(whatis_proto, " ", 1); + return (1); + } + } + + return (0); +} + /* * Processes a new-style mdoc(7) line. */ @@ -636,6 +668,9 @@ process_mdoc_line(char *line) sbuf_append(whatis_proto, " ", 1); return; } + if (process_mdoc_macro(line)) { + return; + } xref = strncmp(line, ".Xr", 3) == 0; line += 3; while ((line = skip_spaces(line)) < line_end) { -- 2.41.0