annotate src/fftw-3.3.5/doc/FAQ/bfnnconv.pl @ 148:b4bfdf10c4b3

Update Win64 capnp builds to v0.6
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 22 May 2017 18:56:49 +0100
parents 7867fa7e1b6b
children
rev   line source
cannam@127 1 #!/usr/bin/perl --
cannam@127 2 # Copyright (C) 1993-1995 Ian Jackson.
cannam@127 3
cannam@127 4 # This file is free software; you can redistribute it and/or modify
cannam@127 5 # it under the terms of the GNU General Public License as published by
cannam@127 6 # the Free Software Foundation; either version 2, or (at your option)
cannam@127 7 # any later version.
cannam@127 8
cannam@127 9 # It is distributed in the hope that it will be useful,
cannam@127 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@127 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@127 12 # GNU General Public License for more details.
cannam@127 13
cannam@127 14 # You should have received a copy of the GNU General Public License
cannam@127 15 # along with GNU Emacs; see the file COPYING. If not, write to
cannam@127 16 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
cannam@127 17 # Boston, MA 02111-1307, USA.
cannam@127 18
cannam@127 19 # (Note: I do not consider works produced using these BFNN processing
cannam@127 20 # tools to be derivative works of the tools, so they are NOT covered
cannam@127 21 # by the GPL. However, I would appreciate it if you credited me if
cannam@127 22 # appropriate in any documents you format using BFNN.)
cannam@127 23
cannam@127 24 @outputs=('ascii','info','html');
cannam@127 25
cannam@127 26 while ($ARGV[0] =~ m/^\-/) {
cannam@127 27 $_= shift(@ARGV);
cannam@127 28 if (m/^-only/) {
cannam@127 29 @outputs= (shift(@ARGV));
cannam@127 30 } else {
cannam@127 31 warn "unknown option `$_' ignored";
cannam@127 32 }
cannam@127 33 }
cannam@127 34
cannam@127 35 $prefix= $ARGV[0];
cannam@127 36 $prefix= 'stdin' unless length($prefix);
cannam@127 37 $prefix =~ s/\.bfnn$//;
cannam@127 38
cannam@127 39 if (open(O,"$prefix.xrefdb")) {
cannam@127 40 @xrefdb= <O>;
cannam@127 41 close(O);
cannam@127 42 } else {
cannam@127 43 warn "no $prefix.xrefdb ($!)";
cannam@127 44 }
cannam@127 45
cannam@127 46 $section= -1;
cannam@127 47 for $thisxr (@xrefdb) {
cannam@127 48 $_= $thisxr;
cannam@127 49 chop;
cannam@127 50 if (m/^Q (\w+) ((\d+)\.(\d+)) (.*)$/) {
cannam@127 51 $qrefn{$1}= $2;
cannam@127 52 $qreft{$1}= $5;
cannam@127 53 $qn2ref{$3,$4}= $1;
cannam@127 54 $maxsection= $3;
cannam@127 55 $maxquestion[$3]= $4;
cannam@127 56 } elsif (m/^S (\d+) /) {
cannam@127 57 $maxsection= $1;
cannam@127 58 $sn2title{$1}=$';
cannam@127 59 }
cannam@127 60 }
cannam@127 61
cannam@127 62 open(U,">$prefix.xrefdb-new");
cannam@127 63
cannam@127 64 for $x (@outputs) { require("m-$x.pl"); }
cannam@127 65
cannam@127 66 &call('init');
cannam@127 67
cannam@127 68 while (<>) {
cannam@127 69 chop;
cannam@127 70 next if m/^\\comment\b/;
cannam@127 71 if (!m/\S/) {
cannam@127 72 &call('endpara');
cannam@127 73 next;
cannam@127 74 }
cannam@127 75 if (s/^\\section +//) {
cannam@127 76 $line= $_;
cannam@127 77 $section++; $question=0;
cannam@127 78 print U "S $section $line\n";
cannam@127 79 $|=1; print "S$section",' 'x10,"\r"; $|=0;
cannam@127 80 &call('endpara');
cannam@127 81 &call('startmajorheading',"$section",
cannam@127 82 "Section $section",
cannam@127 83 $section<$maxsection ? "Section ".($section+1) : '',
cannam@127 84 $section>1 ? 'Section '.($section-1) : 'Top');
cannam@127 85 &text($line);
cannam@127 86 &call('endmajorheading');
cannam@127 87 if ($section) {
cannam@127 88 &call('endpara');
cannam@127 89 &call('startindex');
cannam@127 90 for $thisxr (@xrefdb) {
cannam@127 91 $_= $thisxr;
cannam@127 92 chop;
cannam@127 93 if (m/^Q (\w+) (\d+)\.(\d+) (.*)$/) {
cannam@127 94 $ref= $1; $num1= $2; $num2= $3; $text= $4;
cannam@127 95 next unless $num1 == $section;
cannam@127 96 &call('startindexitem',$ref,"Q$num1.$num2","Question $num1.$num2");
cannam@127 97 &text($text);
cannam@127 98 &call('endindexitem');
cannam@127 99 }
cannam@127 100 }
cannam@127 101 &call('endindex');
cannam@127 102 }
cannam@127 103 } elsif (s/^\\question \d{2}[a-z]{3}((:\w+)?) +//) {
cannam@127 104 $line= $_;
cannam@127 105 $question++;
cannam@127 106 $qrefstring= $1;
cannam@127 107 $qrefstring= "q_${section}_$question" unless $qrefstring =~ s/^://;
cannam@127 108 print U "Q $qrefstring $section.$question $line\n";
cannam@127 109 $|=1; print "Q$section.$question",' 'x10,"\r"; $|=0;
cannam@127 110 &call('endpara');
cannam@127 111 &call('startminorheading',$qrefstring,
cannam@127 112 "Question $section.$question",
cannam@127 113 $question < $maxquestion[$section] ? "Question $section.".($question+1) :
cannam@127 114 $section < $maxsection ? "Question ".($section+1).".1" : '',
cannam@127 115 $question > 1 ? "Question $section.".($question-1) :
cannam@127 116 $section > 1 ? "Question ".($section-1).'.'.($maxquestion[$section-1]) :
cannam@127 117 'Top',
cannam@127 118 "Section $section");
cannam@127 119 &text("Question $section.$question. $line");
cannam@127 120 &call('endminorheading');
cannam@127 121 } elsif (s/^\\only +//) {
cannam@127 122 @saveoutputs= @outputs;
cannam@127 123 @outputs=();
cannam@127 124 for $x (split(/\s+/,$_)) {
cannam@127 125 push(@outputs,$x) if grep($x eq $_, @saveoutputs);
cannam@127 126 }
cannam@127 127 } elsif (s/^\\endonly$//) {
cannam@127 128 @outputs= @saveoutputs;
cannam@127 129 } elsif (s/^\\copyto +//) {
cannam@127 130 $fh= $';
cannam@127 131 while(<>) {
cannam@127 132 last if m/^\\endcopy$/;
cannam@127 133 while (s/^([^\`]*)\`//) {
cannam@127 134 print $fh $1;
cannam@127 135 m/([^\\])\`/ || warn "`$_'";
cannam@127 136 $_= $';
cannam@127 137 $cmd= $`.$1;
cannam@127 138 $it= `$cmd`; chop $it;
cannam@127 139 print $fh $it;
cannam@127 140 }
cannam@127 141 print $fh $_;
cannam@127 142 }
cannam@127 143 } elsif (m/\\index$/) {
cannam@127 144 &call('startindex');
cannam@127 145 for $thisxr (@xrefdb) {
cannam@127 146 $_= $thisxr;
cannam@127 147 chop;
cannam@127 148 if (m/^Q (\w+) (\d+\.\d+) (.*)$/) {
cannam@127 149 $ref= $1; $num= $2; $text= $3;
cannam@127 150 &call('startindexitem',$ref,"Q$num","Question $num");
cannam@127 151 &text($text);
cannam@127 152 &call('endindexitem');
cannam@127 153 } elsif (m/^S (\d+) (.*)$/) {
cannam@127 154 $num= $1; $text= $2;
cannam@127 155 next unless $num;
cannam@127 156 &call('startindexmainitem',"s_$num",
cannam@127 157 "Section $num.","Section $num");
cannam@127 158 &text($text);
cannam@127 159 &call('endindexitem');
cannam@127 160 } else {
cannam@127 161 warn $_;
cannam@127 162 }
cannam@127 163 }
cannam@127 164 &call('endindex');
cannam@127 165 } elsif (m/^\\call-(\w+) +(\w+)\s*(.*)$/) {
cannam@127 166 $fn= $1.'_'.$2;
cannam@127 167 eval { &$fn($3); };
cannam@127 168 warn $@ if length($@);
cannam@127 169 } elsif (m/^\\call +(\w+)\s*(.*)$/) {
cannam@127 170 eval { &call($1,$2); };
cannam@127 171 warn $@ if length($@);
cannam@127 172 } elsif (s/^\\set +(\w+)\s*//) {
cannam@127 173 $svalue= $'; $svari= $1;
cannam@127 174 eval("\$user_$svari=\$svalue"); $@ && warn "setting $svalue failed: $@\n";
cannam@127 175 } elsif (m/^\\verbatim$/) {
cannam@127 176 &call('startverbatim');
cannam@127 177 while (<>) {
cannam@127 178 chop;
cannam@127 179 last if m/^\\endverbatim$/;
cannam@127 180 &call('verbatim',$_);
cannam@127 181 }
cannam@127 182 &call('endverbatim');
cannam@127 183 } else {
cannam@127 184 s/\.$/\. /;
cannam@127 185 &text($_." ");
cannam@127 186 }
cannam@127 187 }
cannam@127 188
cannam@127 189 print ' 'x25,"\r";
cannam@127 190 &call('finish');
cannam@127 191 rename("$prefix.xrefdb-new","$prefix.xrefdb") || warn "rename xrefdb: $!";
cannam@127 192 exit 0;
cannam@127 193
cannam@127 194
cannam@127 195 sub text {
cannam@127 196 local($in,$rhs,$word,$refn,$reft,$fn,$style);
cannam@127 197 $in= "$holdover$_[0]";
cannam@127 198 $holdover= '';
cannam@127 199 while ($in =~ m/\\/) {
cannam@127 200 #print STDERR ">$`##$'\n";
cannam@127 201 $rhs=$';
cannam@127 202 &call('text',$`);
cannam@127 203 $_= $rhs;
cannam@127 204 if (m/^\w+ $/) {
cannam@127 205 $holdover= "\\$&";
cannam@127 206 $in= '';
cannam@127 207 } elsif (s/^fn\s+([^\s\\]*\w)//) {
cannam@127 208 $in= $_;
cannam@127 209 $word= $1;
cannam@127 210 &call('courier');
cannam@127 211 &call('text',$word);
cannam@127 212 &call('endcourier');
cannam@127 213 } elsif (s/^tab\s+(\d+)\s+//) {
cannam@127 214 $in= $_; &call('tab',$1);
cannam@127 215 } elsif (s/^nl\s+//) {
cannam@127 216 $in= $_; &call('newline');
cannam@127 217 } elsif (s/^qref\s+(\w+)//) {
cannam@127 218 $refn= $qrefn{$1};
cannam@127 219 $reft= $qreft{$1};
cannam@127 220 if (!length($refn)) {
cannam@127 221 warn "unknown question `$1'";
cannam@127 222 }
cannam@127 223 $in= "$`\\pageref:$1:$refn:$reft\\endpageref.$_";
cannam@127 224 } elsif (s/^pageref:(\w+):([^:\n]+)://) {
cannam@127 225 $in= $_;
cannam@127 226 &call('pageref',$1,$2);
cannam@127 227 } elsif (s/^endpageref\.//) {
cannam@127 228 $in= $_; &call('endpageref');
cannam@127 229 } elsif (s/^(\w+)\{//) {
cannam@127 230 $in= $_; $fn= $1;
cannam@127 231 eval { &call("$fn"); };
cannam@127 232 if (length($@)) { warn $@; $fn= 'x'; }
cannam@127 233 push(@styles,$fn);
cannam@127 234 } elsif (s/^\}//) {
cannam@127 235 $in= $_;
cannam@127 236 $fn= pop(@styles);
cannam@127 237 if ($fn ne 'x') { &call("end$fn"); }
cannam@127 238 } elsif (s/^\\//) {
cannam@127 239 $in= $_;
cannam@127 240 &call('text',"\\");
cannam@127 241 } elsif (s,^(\w+)\s+([-A-Za-z0-9.\@:/]*\w),,) {
cannam@127 242 #print STDERR "**$&**$_\n";
cannam@127 243 $in= $_;
cannam@127 244 $style=$1; $word= $2;
cannam@127 245 &call($style);
cannam@127 246 &call('text',$word);
cannam@127 247 &call("end$style");
cannam@127 248 } else {
cannam@127 249 warn "unknown control `\\$_'";
cannam@127 250 $in= $_;
cannam@127 251 }
cannam@127 252 }
cannam@127 253 &call('text',$in);
cannam@127 254 }
cannam@127 255
cannam@127 256
cannam@127 257 sub call {
cannam@127 258 local ($fnbase, @callargs) = @_;
cannam@127 259 local ($coutput);
cannam@127 260 for $coutput (@outputs) {
cannam@127 261 if ($fnbase eq 'text' && eval("\@${coutput}_cmds")) {
cannam@127 262 #print STDERR "special handling text (@callargs) for $coutput\n";
cannam@127 263 $evstrg= "\$${coutput}_args[\$#${coutput}_args].=\"\@callargs\"";
cannam@127 264 eval($evstrg);
cannam@127 265 length($@) && warn "call adding for $coutput (($evstrg)): $@";
cannam@127 266 } else {
cannam@127 267 $fntc= $coutput.'_'.$fnbase;
cannam@127 268 &$fntc(@callargs);
cannam@127 269 }
cannam@127 270 }
cannam@127 271 }
cannam@127 272
cannam@127 273
cannam@127 274 sub recurse {
cannam@127 275 local (@outputs) = $coutput;
cannam@127 276 local ($holdover);
cannam@127 277 &text($_[0]);
cannam@127 278 }
cannam@127 279
cannam@127 280
cannam@127 281 sub arg {
cannam@127 282 #print STDERR "arg($_[0]) from $coutput\n";
cannam@127 283 $cmd= $_[0];
cannam@127 284 eval("push(\@${coutput}_cmds,\$cmd); push(\@${coutput}_args,'')");
cannam@127 285 length($@) && warn "arg setting up for $coutput: $@";
cannam@127 286 }
cannam@127 287
cannam@127 288 sub endarg {
cannam@127 289 #print STDERR "endarg($_[0]) from $coutput\n";
cannam@127 290 $evstrg= "\$${coutput}_cmd= \$cmd= pop(\@${coutput}_cmds); ".
cannam@127 291 "\$${coutput}_arg= \$arg= pop(\@${coutput}_args); ";
cannam@127 292 eval($evstrg);
cannam@127 293 length($@) && warn "endarg extracting for $coutput (($evstrg)): $@";
cannam@127 294 #print STDERR ">call $coutput $cmd $arg< (($evstrg))\n";
cannam@127 295 $evstrg= "&${coutput}_do_${cmd}(\$arg)";
cannam@127 296 eval($evstrg);
cannam@127 297 length($@) && warn "endarg running ${coutput}_do_${cmd} (($evstrg)): $@";
cannam@127 298 }