3 # Convert Praat ManPages files to the equivalent CPP code.
4 # If no target file is given, uses STDOUT
7 # perl ManPages2CPP.pl <source-file> [target-file]
10 open(FILEOUT
, ">$TargetFile") || die "$TargetFile: $!\n";
12 my @currentTime = localtime(time);
13 my $currentYear = $currentTime[5] + 1900;
18 * Copyright (C) ${currentYear} R.J.J.H. van Son
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or (at
23 * your option) any later version.
25 * This program is distributed in the hope that it will be useful, but
26 * WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
28 * See the GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 #include \"ManPagesM.h\"
37 void manual_TEanalysis_init (ManPages me);
38 void manual_TEanalsyis_init (ManPages me) {
42 #print FILEOUT $Header;
45 while (my $SourceFile = shift(@ARGV))
47 open(FILEIN
, "<$SourceFile") || die "$SourceFile: $!\n";
51 if($line ne "ManPagesTextFile")
53 die "$SourceFile is not a valid Praat ManPage\n";
57 my ($Title, $Author, $Date, $Time);
58 if($line =~ /^\"([^\"]+)\" \"([^\"]*)\"\s+(\d{8,8})\s+(\d+)\s*$/)
67 die "$SourceFile is not a valid Praat ManPage\n";
79 my ($Startmarker, $Endmarker) = ("\"", "\"");
80 if(/^\s*\<([^\>]+)\>\s+(\".*)$/)
92 if($Text =~ /^\s*\"[^\"]/)
94 $Startmarker = "(L\"";
98 if($Text =~ /[^\"]\"\s*$/)
101 $Text =~ s/\"\s*$//g;
104 $ManPageText .= "$Macro $Startmarker$Text$Endmarker\n";
107 print FILEOUT
"MAN_BEGIN (L\"$Title\", L\"$Author\", $Date)\n";
108 print FILEOUT
$ManPageText;
109 print FILEOUT
"MAN_END\n\n";
113 # print FILEOUT "}\n";