4 # Silly little program to generate the help.c source file
5 # from the less.hlp text file.
6 # The output of this script is a C program defining a char array
7 # whose content is the input to this script.
10 my ($sec,$min,$hour,$mday,$mon,$year) = gmtime();
11 printf "/* This file was generated by mkhelp.pl from less.hlp at %d:%02d on %d/%d/%d */\n",
12 $hour, $min, $year+1900, $mon+1, $mday;
13 print "#include \"less.h\"\n";
14 print "constant char helpdata[] = {\n";
20 last if not defined $ch;
23 } elsif ($ch eq "\\") {
25 } elsif ($ch eq "\b") {
27 } elsif ($ch eq "\t") {
29 } elsif ($ch eq "\n") {
30 print "'\\n',\n" if $prevch ne "\r";
31 } elsif ($ch eq "\r") {
32 print "'\\n',\n" if $prevch ne "\n";
34 if (ord($ch) >= ord(' ') && ord($ch) < 0x7f) {
37 printf "0x%02x,", ord($ch);
41 # Add an extra null char to avoid having a trailing comma.
43 print "constant int size_helpdata = sizeof(helpdata) - 1;\n";