comparison src/fftw-3.3.3/doc/FAQ/m-ascii.pl @ 10:37bf6b4a2645

Add FFTW3
author Chris Cannam
date Wed, 20 Mar 2013 15:35:50 +0000
parents
children
comparison
equal deleted inserted replaced
9:c0fb53affa76 10:37bf6b4a2645
1 ## ASCII output
2 # Copyright (C) 1993-1995 Ian Jackson.
3
4 # This file is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8
9 # It is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with GNU Emacs; see the file COPYING. If not, write to
16 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 # Boston, MA 02111-1307, USA.
18
19 # (Note: I do not consider works produced using these BFNN processing
20 # tools to be derivative works of the tools, so they are NOT covered
21 # by the GPL. However, I would appreciate it if you credited me if
22 # appropriate in any documents you format using BFNN.)
23
24 sub ascii_init {
25 open(ASCII,">$prefix.ascii");
26 }
27
28 sub ascii_startmajorheading {
29 print ASCII '='x79,"\n\n";
30 $ascii_status= 'h';
31 &ascii_text($_[0] ? "Section $_[0]. " : '');
32 }
33
34 sub ascii_startminorheading {
35 print ASCII '-'x79,"\n\n";
36 $ascii_status= 'h';
37 }
38
39 sub ascii_italic { &ascii_text('*'); }
40 sub ascii_enditalic { $ascii_para .= '*'; }
41
42 sub ascii_email { &ascii_text('<'); } sub ascii_endemail { &ascii_text('>'); }
43
44 sub ascii_ftpon { } sub ascii_endftpon { }
45 sub ascii_ftpin { } sub ascii_endftpin { }
46 sub ascii_docref { } sub ascii_enddocref { }
47 sub ascii_courier { } sub ascii_endcourier { }
48 sub ascii_newsgroup { } sub ascii_endnewsgroup { }
49 sub ascii_ftpsilent { $ascii_ignore++; }
50 sub ascii_endftpsilent { $ascii_ignore--; }
51
52 sub ascii_text {
53 return if $ascii_ignore;
54 if ($ascii_status eq '') {
55 $ascii_status= 'p';
56 }
57 $ascii_para .= $_[0];
58 }
59
60 sub ascii_tab {
61 local ($n) = $_[0]-length($ascii_para);
62 $ascii_para .= ' 'x$n if $n>0;
63 }
64
65 sub ascii_newline {
66 return unless $ascii_status eq 'p';
67 &ascii_writepara;
68 }
69
70 sub ascii_writepara {
71 local ($thisline, $thisword, $rest);
72 for (;;) {
73 last unless $ascii_para =~ m/\S/;
74 $thisline= $ascii_indentstring;
75 for (;;) {
76 last unless $ascii_para =~ m/^(\s*\S+)/;
77 unless (length($1) + length($thisline) < 75 ||
78 length($thisline) == length($ascii_indentstring)) {
79 last;
80 }
81 $thisline .= $1;
82 $ascii_para= $';
83 }
84 $ascii_para =~ s/^\s*//;
85 print ASCII $thisline,"\n";
86 $ascii_indentstring= $ascii_nextindent;
87 last unless length($ascii_para);
88 }
89 $ascii_status= ''; $ascii_para= '';
90 }
91
92 sub ascii_endpara {
93 return unless $ascii_status eq 'p';
94 &ascii_writepara;
95 print ASCII "\n";
96 }
97
98 sub ascii_endheading {
99 $ascii_para =~ s/\s*$//;
100 print ASCII "$ascii_para\n\n";
101 $ascii_status= '';
102 $ascii_para= '';
103 }
104
105 sub ascii_endmajorheading { &ascii_endheading(@_); }
106 sub ascii_endminorheading { &ascii_endheading(@_); }
107
108 sub ascii_startverbatim {
109 $ascii_vstatus= $ascii_status;
110 &ascii_writepara;
111 }
112
113 sub ascii_verbatim {
114 print ASCII $_[0],"\n";
115 }
116
117 sub ascii_endverbatim {
118 $ascii_status= $ascii_vstatus;
119 }
120
121 sub ascii_finish {
122 close(ASCII);
123 }
124
125 sub ascii_startindex { $ascii_status= ''; }
126 sub ascii_endindex { $ascii_status= 'p'; }
127
128 sub ascii_endindexitem {
129 printf ASCII " %-11s %-.66s\n",$ascii_left,$ascii_para;
130 $ascii_status= 'p';
131 $ascii_para= '';
132 }
133
134 sub ascii_startindexitem {
135 $ascii_left= $_[1];
136 }
137
138 sub ascii_startindexmainitem {
139 $ascii_left= $_[1];
140 print ASCII "\n" if $ascii_status eq 'p';
141 }
142
143 sub ascii_startindent {
144 $ascii_istatus= $ascii_status;
145 &ascii_writepara;
146 $ascii_indentstring= " $ascii_indentstring";
147 $ascii_nextindent= " $ascii_nextindent";
148 }
149
150 sub ascii_endindent {
151 $ascii_indentstring =~ s/^ //;
152 $ascii_nextindent =~ s/^ //;
153 $ascii_status= $ascii_istatus;
154 }
155
156 sub ascii_startpackedlist { $ascii_plc=0; }
157 sub ascii_endpackedlist { &ascii_newline if !$ascii_plc; }
158 sub ascii_packeditem {
159 &ascii_newline if !$ascii_plc;
160 &ascii_tab($ascii_plc*40+5);
161 $ascii_plc= !$ascii_plc;
162 }
163
164 sub ascii_startlist {
165 &ascii_endpara;
166 $ascii_indentstring= " $ascii_indentstring";
167 $ascii_nextindent= " $ascii_nextindent";
168 }
169
170 sub ascii_endlist {
171 &ascii_endpara;
172 $ascii_indentstring =~ s/^ //;
173 $ascii_nextindent =~ s/^ //;
174 }
175
176 sub ascii_item {
177 &ascii_newline;
178 $ascii_indentstring =~ s/ $/* /;
179 }
180
181 sub ascii_pageref {
182 &ascii_text("Q$_[1] \`");
183 }
184
185 sub ascii_endpageref {
186 &ascii_text("'");
187 }
188
189 1;