summaryrefslogtreecommitdiff
path: root/usr.bin/less/mkhelp.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-04-13 18:21:23 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-04-13 18:21:23 +0000
commit6b9d6b99a4fdda2ee6d9a30dec452d8202fb2017 (patch)
treecdb36cd4fcb25c7a5a4783c61999265c2e6146de /usr.bin/less/mkhelp.c
parent9ca85a37bc7843c0b57b4b7297d82914d89f0826 (diff)
Stock less-390 with some unneeded DOS/Windoze files removed
Diffstat (limited to 'usr.bin/less/mkhelp.c')
-rw-r--r--usr.bin/less/mkhelp.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/usr.bin/less/mkhelp.c b/usr.bin/less/mkhelp.c
new file mode 100644
index 00000000000..d05cb49945c
--- /dev/null
+++ b/usr.bin/less/mkhelp.c
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 1984-2002 Mark Nudelman
+ *
+ * You may distribute under the terms of either the GNU General Public
+ * License or the Less License, as specified in the README file.
+ *
+ * For more information about less, or for information on how to
+ * contact the author, see the README file.
+ */
+
+
+/*
+ * Silly little program to generate the help.c source file
+ * from the less.hlp text file.
+ * help.c just contains a char array whose contents are
+ * the contents of less.hlp.
+ */
+
+#include <stdio.h>
+
+ int
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+ int ch;
+ int prevch;
+
+ printf("/* This file was generated by mkhelp from less.hlp */\n");
+ printf("#include \"less.h\"\n");
+ printf("constant char helpdata[] = {\n");
+ ch = 0;
+ while (prevch = ch, (ch = getchar()) != EOF)
+ {
+ switch (ch)
+ {
+ case '\'':
+ printf("'\\'',");
+ break;
+ case '\\':
+ printf("'\\\\',");
+ break;
+ case '\b':
+ printf("'\\b',");
+ break;
+ case '\t':
+ printf("'\\t',");
+ break;
+ case '\n':
+ if (prevch != '\r')
+ printf("'\\n',\n");
+ break;
+ case '\r':
+ if (prevch != '\n')
+ printf("'\\n',\n");
+ break;
+ default:
+ if (ch >= ' ' && ch < 0x7f)
+ printf("'%c',", ch);
+ else
+ printf("0x%02x,", ch);
+ break;
+ }
+ }
+ /* Add an extra null char to avoid having a trailing comma. */
+ printf(" 0 };\n");
+ printf("constant int size_helpdata = sizeof(helpdata) - 1;\n");
+ return (0);
+}