Support for g++-4.1.
[gf1.git] / makehelptext.pl
blob816538f2de7f9d99631dc143e12fe4f5d3048e86
1 #!/usr/bin/perl
4 # $Id$
6 # this program takes a textfile with gf1-documentation, and converts
7 # it to an include-file
10 # Copyright (C) 1998 Kurt Van den Branden
12 # This program is free software; you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation; either version 2 of the License, or
15 # (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 if ($ARGV[0])
28 $infile = $ARGV[0];
30 else
32 $infile = 'gf1_doc.txt';
35 if ($ARGV[1])
37 $outfile = $ARGV[1];
39 else
41 $outfile = 'helptext.h';
44 open (IN, $infile) || die "ERROR: input not found ($infile)\n\n";
45 open (OUT, ">$outfile") || die "ERROR: can't create output ($outfile)\n\n";
47 print OUT "/*\n";
48 print OUT "** contains the text to display in the helpwindow from gf1\n";
49 print OUT "**\n";
50 print OUT "** this file is created automatically from the documentation\n";
51 print OUT "*/\n";
52 print OUT "/*\n";
53 print OUT "** Copyright (C) 1998 Kurt Van den Branden\n";
54 print OUT "**\n";
55 print OUT "** This program is free software; you can redistribute it and/or modify\n";
56 print OUT "** it under the terms of the GNU General Public License as published by\n";
57 print OUT "** the Free Software Foundation; either version 2 of the License, or\n";
58 print OUT "** (at your option) any later version.\n";
59 print OUT "** \n";
60 print OUT "** This program is distributed in the hope that it will be useful,\n";
61 print OUT "** but WITHOUT ANY WARRANTY; without even the implied warranty of\n";
62 print OUT "** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n";
63 print OUT "** GNU General Public License for more details.\n";
64 print OUT "** \n";
65 print OUT "** You should have received a copy of the GNU General Public License\n";
66 print OUT "** along with this program; if not, write to the Free Software\n";
67 print OUT "** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. \n";
68 print OUT "*/\n";
69 print OUT "\n";
70 print OUT "#ifndef _HELPTEXT_H_\n";
71 print OUT "#define _HELPTEXT_H_\n";
72 print OUT "\n";
73 print OUT "char * helplines[] = {\n";
74 print OUT " \"\",\n";
75 print OUT " \"\",\n";
77 $counter = 2;
78 $lasttext = 0;
79 @sections = ();
81 while ($line = <IN>)
83 $counter++;
85 chop ($line);
86 # replace " with \"
87 $line =~ s/\"/\\\"/g;
88 # cut all spaces from the start of the line
89 ($text) = $line =~ m/^\s*(.*)/;
90 if ($counter == 3)
92 print OUT " \"\@c\@m$line\",\n";
93 print OUT " \"\",\n";
94 push (@sections, [$text, $counter]);
95 $counter++;
97 elsif ($line =~ m/^\s*\d+\.\s+/)
99 print OUT " \"\@m$line\",\n";
100 push (@sections, [" $text", $counter]);
102 elsif ($line =~ m/^\s*\d+\.\d+\.\s+/)
104 print OUT " \"\@b$line\",\n";
105 push (@sections, [" $text", $counter]);
107 elsif ($line =~ m/^\s*\d+\.\d+\.\d+\.\s+/)
109 print OUT " \"$line\",\n";
110 push (@sections, [" $text", $counter]);
112 else
114 print OUT " \"$line\",\n";
117 if (length ($line) != 0)
119 $lasttext = $counter;
123 $lasttext += 5;
125 print OUT "};\n\n";
126 print OUT "#define NRHELPLINES $lasttext\n\n";
127 print OUT "struct sectiondata {\n";
128 print OUT " char line[100];\n";
129 print OUT " int offset;\n";
130 print OUT "} sectionlines[] = {\n";
132 foreach $item (@sections)
134 print OUT " {\"$item->[0]\", $item->[1]},\n";
137 print OUT "};\n\n";
138 $t = $#sections + 1;
139 print OUT "#define NRSECTIONLINES $t\n\n";
141 print OUT "#endif";
142 exit;