summaryrefslogtreecommitdiff
path: root/gen-manpage-opts.c
diff options
context:
space:
mode:
authorAaron Plattner <aplattner@nvidia.com>2008-02-13 10:20:37 -0800
committerAaron Plattner <aplattner@nvidia.com>2008-02-13 10:20:37 -0800
commit58f3afadfc05de52e9e241dbe92f0351490fd4b1 (patch)
tree82b943ae508b8a4d5e7fbebec346bb34ac1ee476 /gen-manpage-opts.c
parent04551d8594d642b17f99fcef8019ae780b24a557 (diff)
1.0-87561.0-8756
Diffstat (limited to 'gen-manpage-opts.c')
-rw-r--r--gen-manpage-opts.c59
1 files changed, 54 insertions, 5 deletions
diff --git a/gen-manpage-opts.c b/gen-manpage-opts.c
index d49576a..440502e 100644
--- a/gen-manpage-opts.c
+++ b/gen-manpage-opts.c
@@ -3,12 +3,18 @@
*/
#include <stdio.h>
#include <ctype.h>
+#include <string.h>
#include "nvidia-installer.h"
#include "option_table.h"
static void print_option(const NVOption *o)
{
+ char scratch[64], *s;
+ int j, len;
+
+ int omitWhiteSpace;
+
printf(".TP\n.BI ");
/* Print the name of the option */
/* XXX We should backslashify the '-' characters in o->name. */
@@ -24,15 +30,58 @@ static void print_option(const NVOption *o)
}
if (o->flags & NVOPT_HAS_ARGUMENT) {
- printf("=\" \"%s", o->name);
+ len = strlen(o->name);
+ for (j = 0; j < len; j++) scratch[j] = toupper(o->name[j]);
+ scratch[len] = '\0';
+ printf("=\" \"%s", scratch);
}
printf("\"\n");
- /* Print the option description */
- /* XXX Each sentence should be on its own line! */
- /* XXX We need to backslashify the '-' characters here. */
- printf("%s\n", o->description);
+ /*
+ * Print the option description: write each character one at a
+ * time (ugh) so that we can special-case a few characters:
+ *
+ * "[" --> "\n.I "
+ * "]" --> "\n"
+ * "-" --> "\-"
+ *
+ * Brackets are used to mark the text inbetween as italics.
+ * '-' is special cased so that we can backslashify it.
+ *
+ * XXX Each sentence should be on its own line!
+ */
+
+ omitWhiteSpace = 0;
+
+ for (s = o->description; s && *s; s++) {
+
+ switch (*s) {
+ case '[':
+ printf("\n.I ");
+ omitWhiteSpace = 0;
+ break;
+ case ']':
+ printf("\n");
+ omitWhiteSpace = 1;
+ break;
+ case '-':
+ printf("\\-");
+ omitWhiteSpace = 0;
+ break;
+ case ' ':
+ if (!omitWhiteSpace) {
+ printf("%c", *s);
+ }
+ break;
+ default:
+ printf("%c", *s);
+ omitWhiteSpace = 0;
+ break;
+ }
+ }
+
+ printf("\n");
}
int main(int argc, char* argv[])