Deleted Added
full compact
mkhelp.c (221715) mkhelp.c (237613)
1/*
1/*
2 * Copyright (C) 1984-2011 Mark Nudelman
2 * Copyright (C) 1984-2012 Mark Nudelman
3 *
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Less License, as specified in the README file.
6 *
3 *
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Less License, as specified in the README file.
6 *
7 * For more information about less, or for information on how to
8 * contact the author, see the README file.
7 * For more information, see the README file.
9 */
10
11
12/*
13 * Silly little program to generate the help.c source file
14 * from the less.hlp text file.
15 * help.c just contains a char array whose contents are
16 * the contents of less.hlp.
17 */
18
19#include <stdio.h>
20
21 int
22main(argc, argv)
23 int argc;
24 char *argv[];
25{
26 int ch;
27 int prevch;
28
29 printf("/* This file was generated by mkhelp from less.hlp */\n");
30 printf("#include \"less.h\"\n");
31 printf("constant char helpdata[] = {\n");
32 ch = 0;
33 while (prevch = ch, (ch = getchar()) != EOF)
34 {
35 switch (ch)
36 {
37 case '\'':
38 printf("'\\'',");
39 break;
40 case '\\':
41 printf("'\\\\',");
42 break;
43 case '\b':
44 printf("'\\b',");
45 break;
46 case '\t':
47 printf("'\\t',");
48 break;
49 case '\n':
50 if (prevch != '\r')
51 printf("'\\n',\n");
52 break;
53 case '\r':
54 if (prevch != '\n')
55 printf("'\\n',\n");
56 break;
57 default:
58 if (ch >= ' ' && ch < 0x7f)
59 printf("'%c',", ch);
60 else
61 printf("0x%02x,", ch);
62 break;
63 }
64 }
65 /* Add an extra null char to avoid having a trailing comma. */
66 printf(" 0 };\n");
67 printf("constant int size_helpdata = sizeof(helpdata) - 1;\n");
68 return (0);
69}
8 */
9
10
11/*
12 * Silly little program to generate the help.c source file
13 * from the less.hlp text file.
14 * help.c just contains a char array whose contents are
15 * the contents of less.hlp.
16 */
17
18#include <stdio.h>
19
20 int
21main(argc, argv)
22 int argc;
23 char *argv[];
24{
25 int ch;
26 int prevch;
27
28 printf("/* This file was generated by mkhelp from less.hlp */\n");
29 printf("#include \"less.h\"\n");
30 printf("constant char helpdata[] = {\n");
31 ch = 0;
32 while (prevch = ch, (ch = getchar()) != EOF)
33 {
34 switch (ch)
35 {
36 case '\'':
37 printf("'\\'',");
38 break;
39 case '\\':
40 printf("'\\\\',");
41 break;
42 case '\b':
43 printf("'\\b',");
44 break;
45 case '\t':
46 printf("'\\t',");
47 break;
48 case '\n':
49 if (prevch != '\r')
50 printf("'\\n',\n");
51 break;
52 case '\r':
53 if (prevch != '\n')
54 printf("'\\n',\n");
55 break;
56 default:
57 if (ch >= ' ' && ch < 0x7f)
58 printf("'%c',", ch);
59 else
60 printf("0x%02x,", ch);
61 break;
62 }
63 }
64 /* Add an extra null char to avoid having a trailing comma. */
65 printf(" 0 };\n");
66 printf("constant int size_helpdata = sizeof(helpdata) - 1;\n");
67 return (0);
68}