annotate src/fftw-3.3.8/doc/FAQ/bfnnconv.pl @ 84:08ae793730bd

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