makewhatis(8): replace mdoc(7) OS text macros
authorFranco Fichtner <franco@lastsummer.de>
Mon, 9 Dec 2013 18:40:33 +0000 (18:40 +0000)
committerFranco Fichtner <franco@lastsummer.de>
Mon, 9 Dec 2013 17:55:30 +0000 (18:55 +0100)
usr.sbin/makewhatis/makewhatis.c

index e5e2027..003b4df 100644 (file)
@@ -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) {