20 |
# |
# |
21 |
# \begin{center} |
# \begin{center} |
22 |
# \begin{tabular}{|c|l|} \hline \hline |
# \begin{tabular}{|c|l|} \hline \hline |
23 |
# -h & Help mode: list command line options \\ \hline |
# -h & Help mode: list command line options \\ \hline |
24 |
# -b & Bare mode, meaning no preamble, etc. \\ \hline |
# -b & Bare mode, meaning no preamble, etc. \\ \hline |
25 |
# -i & internal mode: omit prologues marked !BOPI \\ \hline |
# -i & internal mode: omit prologues marked !BOPI \\ \hline |
26 |
# +/-n & New Page for each subsection (wastes paper) \\ \hline |
# +/-n & New Page for each subsection (wastes paper) \\ \hline |
27 |
# +/-l & Listing mode, default is prologues only \\ \hline |
# +/-l & Listing mode, default is prologues only \\ \hline |
28 |
# +/-s & Shut-up mode, i.e., ignore any code from BOC to EOC \\ \hline |
# +/-s & Shut-up mode, i.e., ignore any code from BOC to EOC \\ \hline |
29 |
# +/-x & No LaTeX mode, i.e., put !DESCRIPTION: in verbatim mode \\ \hline |
# +/-x & No LaTeX mode, i.e., put !DESCRIPTION: in verbatim mode \\ \hline |
30 |
# +/-f & No source file info \\ \hline |
# +/-f & No source file info \\ \hline |
31 |
# -A & Ada code \\ \hline |
# -A & Ada code \\ \hline |
32 |
# -C & C++ code \\ \hline |
# -C & C++ code \\ \hline |
33 |
# -F & F90 code (default) \\ \hline |
# -F & F90 code (default) \\ \hline |
34 |
# -7 & F77 code \\ \hline |
# -7 & F77 code \\ \hline |
35 |
# -S & Shell script \\ \hline \hline |
# -S & Shell script \\ \hline \hline |
36 |
|
# -v & Verbosity level (default=99) \\ \hline \hline |
37 |
# \end{tabular} |
# \end{tabular} |
38 |
# \end{center} |
# \end{center} |
39 |
# |
# |
100 |
|
|
101 |
# Set valid options lists |
# Set valid options lists |
102 |
# ----------------------- |
# ----------------------- |
103 |
$GlobOptions = 'hb'; # Global options (i.e for all files) |
$GlobOptions = 'hbv'; # Global options (i.e for all files) |
104 |
$LangOptions = 'ACFS7'; # Options for setting programming languages |
$LangOptions = 'ACFS7'; # Options for setting programming languages |
105 |
$SwOptions = 'flinsx'; # Options that can change for each input file |
$SwOptions = 'flinsx'; # Options that can change for each input file |
106 |
$RegOptions = "$GlobOptions$LangOptions"; |
$RegOptions = "$GlobOptions$LangOptions"; |
110 |
# Scan for global options |
# Scan for global options |
111 |
# ----------------------- |
# ----------------------- |
112 |
$NFiles = 0; |
$NFiles = 0; |
113 |
Arg: |
Arg: foreach $arg (@ARGV) { |
114 |
foreach $arg (@ARGV) { |
$option = &CheckOpts ( $arg, $RegOptions, $SwOptions ) + 1; |
115 |
$option = &CheckOpts ( $arg, $RegOptions, $SwOptions ) + 1; |
if ( $option ) { |
116 |
if ( $option ) { |
$rc = &GetOpts ( $arg, $GlobOptions ); |
117 |
$rc = &GetOpts ( $arg, $GlobOptions ); |
next Arg; |
118 |
next Arg; |
} |
119 |
} |
else { |
120 |
else { |
$NFiles++; |
121 |
$NFiles++; |
} |
122 |
} |
} |
|
} |
|
123 |
|
|
124 |
# If all input arguments are options, then assume the |
# If all input arguments are options, then assume the |
125 |
# filename, "-", for the standard input |
# filename, "-", for the standard input |
179 |
|
|
180 |
# Main loop -- for each command-line argument |
# Main loop -- for each command-line argument |
181 |
# ------------------------------------------- |
# ------------------------------------------- |
182 |
ARG: |
ARG: foreach $arg (@ARGV) { |
183 |
foreach $arg (@ARGV) { |
|
184 |
|
# Scan for non-global command-line options |
185 |
# Scan for non-global command-line options |
$option = &CheckOpts ( $arg, $RegOptions, $SwOptions, "quiet" ) + 1; |
186 |
$option = &CheckOpts ( $arg, $RegOptions, $SwOptions, "quiet" ) + 1; |
if ( $option ) { |
187 |
if ( $option ) { |
&GetOpts ( $arg, $SwOptions ); |
188 |
&GetOpts ( $arg, $SwOptions ); |
&SetOpt ( $arg, $LangOptions ); |
189 |
&SetOpt ( $arg, $LangOptions ); |
next ARG; |
190 |
next ARG; |
} |
191 |
} |
|
192 |
|
# Determine the type of code, set corresponding search strings |
193 |
# Determine the type of code, set corresponding search strings |
$comment_string = '!'; # DEFAULT is FORTRAN |
194 |
$comment_string = '!'; # DEFAULT is FORTRAN |
$boi_string = '!BOI'; |
195 |
$boi_string = '!BOI'; |
$eoi_string = '!EOI'; |
196 |
$eoi_string = '!EOI'; |
$bop_string = '!BOP'; |
197 |
$bop_string = '!BOP'; |
$eop_string = '!EOP'; |
198 |
$eop_string = '!EOP'; |
$bopi_string = '!BOPI'; |
199 |
$bopi_string = '!BOPI'; |
$eopi_string = '!EOPI'; |
200 |
$eopi_string = '!EOPI'; |
$boc_string = '!BOC'; |
201 |
$boc_string = '!BOC'; |
$eoc_string = '!EOC'; |
202 |
$eoc_string = '!EOC'; |
|
203 |
|
if ( $opt_7 ) { # f77 |
204 |
if ( $opt_7 ) { # f77 |
$comment_string = 'C'; |
205 |
$comment_string = 'C'; # --- |
$boi_string = 'CBOI'; |
206 |
$boi_string = 'CBOI'; |
$eoi_string = 'CEOI'; |
207 |
$eoi_string = 'CEOI'; |
$bop_string = 'CBOP'; |
208 |
$bop_string = 'CBOP'; |
$eop_string = 'CEOP'; |
209 |
$eop_string = 'CEOP'; |
$bopi_string = 'CBOPI'; |
210 |
$bopi_string = 'CBOPI'; |
$eopi_string = 'CEOPI'; |
211 |
$eopi_string = 'CEOPI'; |
$boc_string = 'CBOC'; |
212 |
$boc_string = 'CBOC'; |
$eoc_string = 'CEOC'; |
213 |
$eoc_string = 'CEOC'; |
} |
214 |
} |
|
215 |
|
if ( $opt_A ) { # ADA |
216 |
if ( $opt_A ) { # ADA |
$comment_string = '--'; |
217 |
$comment_string = '--'; # --- |
$boi_string = '--BOI'; |
218 |
$boi_string = '--BOI'; |
$eoi_string = '--EOI'; |
219 |
$eoi_string = '--EOI'; |
$bop_string = '--BOP'; |
220 |
$bop_string = '--BOP'; |
$eop_string = '--EOP'; |
221 |
$eop_string = '--EOP'; |
$bopi_string = '--BOPI'; |
222 |
$bopi_string = '--BOPI'; |
$eopi_string = '--EOPI'; |
223 |
$eopi_string = '--EOPI'; |
$boc_string = '--BOC'; |
224 |
$boc_string = '--BOC'; |
$eoc_string = '--EOC'; |
225 |
$eoc_string = '--EOC'; |
} |
226 |
} |
|
227 |
|
if ( $opt_C ) { |
228 |
if ( $opt_C ) { |
$comment_string = '//'; # C |
229 |
$comment_string = '//'; # C |
$boi_string = '//BOI'; |
230 |
$boi_string = '//BOI'; # - |
$eoi_string = '//EOI'; |
231 |
$eoi_string = '//EOI'; |
$bop_string = '//BOP'; |
232 |
$bop_string = '//BOP'; |
$eop_string = '//EOP'; |
233 |
$eop_string = '//EOP'; |
$bopi_string = '//BOPI'; |
234 |
$bopi_string = '//BOPI'; |
$eopi_string = '//EOPI'; |
235 |
$eopi_string = '//EOPI'; |
$boc_string = '//BOC'; |
236 |
$boc_string = '//BOC'; |
$eoc_string = '//EOC'; |
237 |
$eoc_string = '//EOC'; |
} |
238 |
} |
|
239 |
|
if ( $opt_S ) { # Script |
240 |
if ( $opt_S ) { # Script |
$comment_string = '#'; |
241 |
$comment_string = '#'; # ------ |
$boi_string = '#BOI'; |
242 |
$boi_string = '#BOI'; |
$eoi_string = '#EOI'; |
243 |
$eoi_string = '#EOI'; |
$bop_string = '#BOP'; |
244 |
$bop_string = '#BOP'; |
$eop_string = '#EOP'; |
245 |
$eop_string = '#EOP'; |
$bopi_string = '#BOPI'; |
246 |
$bopi_string = '#BOPI'; |
$eopi_string = '#EOPI'; |
247 |
$eopi_string = '#EOPI'; |
$boc_string = '#BOC'; |
248 |
$boc_string = '#BOC'; |
$eoc_string = '#EOC'; |
249 |
$eoc_string = '#EOC'; |
} |
250 |
} |
|
251 |
|
# Set file name parameters |
252 |
# Set file name parameters |
$InputFile = $arg; |
253 |
$InputFile = $arg; |
@all_path_components = split( /\//, $InputFile ); |
254 |
@all_path_components = split( /\//, $InputFile ); |
$FileBaseName = pop ( @all_path_components ); |
255 |
$FileBaseName = pop ( @all_path_components ); |
$FileBaseName =~ s/_/\\_/g; |
256 |
$FileBaseName =~ s/_/\\_/g; |
if ( $InputFile eq "-" ) {$FileBaseName = "Standard Input";} |
257 |
if ( $InputFile eq "-" ) {$FileBaseName = "Standard Input";} |
|
258 |
|
# Set date |
259 |
# Set date |
$Date = `date`; |
260 |
$Date = `date`; |
|
261 |
|
# Open current file |
262 |
# Open current file |
open ( InputFile, "$InputFile" ) |
263 |
open ( InputFile, "$InputFile" ) |
or print STDERR "Unable to open $InputFile: $!"; |
264 |
or print STDERR "Unable to open $InputFile: $!"; |
|
265 |
|
# Print page header |
266 |
# Print page header |
chomp($Date); |
267 |
chomp($Date); |
# printf "\n\\markboth{Left}{Source File: %s, Date: %s}\n\n", |
268 |
# printf "\n\\markboth{Left}{Source File: %s, Date: %s}\n\n", |
printf "\n\\markboth{Source File: %s}{Date: %s}\n\n", |
269 |
printf "\n\\markboth{Source File: %s}{Date: %s}\n\n", |
$FileBaseName, $Date; |
270 |
$FileBaseName, $Date; |
|
271 |
|
# Inner loop --- for processing each line of the input file |
272 |
# Inner loop --- for processing each line of the input file |
LINE: while ( <InputFile> ) { |
273 |
LINE: |
chop; # strip record separator |
274 |
while ( <InputFile> ) { |
|
275 |
chop; # strip record separator |
@Fld = split(' ', $_, 9999); |
276 |
|
|
277 |
@Fld = split(' ', $_, 9999); |
# Straight quote |
278 |
|
if ($Fld[1] eq '!QUOTE:') { |
279 |
# Straight quote |
for ($i = 2; $i <= $#Fld; $i++) { |
280 |
if ($Fld[1] eq '!QUOTE:') { |
printf '%s ', $Fld[$i]; |
281 |
for ($i = 2; $i <= $#Fld; $i++) { |
} |
282 |
printf '%s ', $Fld[$i]; |
print " "; |
283 |
} |
next LINE; |
284 |
print " "; |
} |
285 |
next LINE; |
|
286 |
} |
# Handle optional Title Page and Introduction |
287 |
|
if ($Fld[1] eq $boi_string) { |
288 |
# Handle optional Title Page and Introduction |
print ' '; |
289 |
if ($Fld[1] eq $boi_string) { |
$intro = 1; |
290 |
print ' '; |
next LINE; |
291 |
$intro = 1; |
} |
292 |
next LINE; |
|
293 |
} |
if ($Fld[2] eq '!TITLE:') { |
294 |
|
if ( $intro ) { |
295 |
if ($Fld[2] eq '!TITLE:') { |
shift @Fld; |
296 |
if ( $intro ) { |
shift @Fld; |
297 |
shift @Fld; |
@title = @Fld; |
298 |
shift @Fld; |
$tpage = 1; |
299 |
@title = @Fld; |
next LINE; |
300 |
$tpage = 1; |
} |
301 |
next LINE; |
} |
302 |
} |
|
303 |
} |
if ($Fld[2] eq '!AUTHORS:') { |
304 |
|
if ( $intro ) { |
305 |
if ($Fld[2] eq '!AUTHORS:') { |
shift @Fld; |
306 |
if ( $intro ) { |
shift @Fld; |
307 |
shift @Fld; |
@author = @Fld; |
308 |
shift @Fld; |
$tpage = 1; |
309 |
@author = @Fld; |
next LINE; |
310 |
$tpage = 1; |
} |
311 |
next LINE; |
} |
312 |
} |
|
313 |
} |
if ($Fld[2] eq '!AFFILIATION:') { |
314 |
|
if ( $intro ) { |
315 |
if ($Fld[2] eq '!AFFILIATION:') { |
shift @Fld; |
316 |
if ( $intro ) { |
shift @Fld; |
317 |
shift @Fld; |
@affiliation = @Fld; |
318 |
shift @Fld; |
$tpage = 1; |
319 |
@affiliation = @Fld; |
next LINE; |
320 |
$tpage = 1; |
} |
321 |
next LINE; |
} |
322 |
} |
|
323 |
} |
if ($Fld[2] eq '!DATE:') { |
324 |
|
if ( $intro ) { |
325 |
if ($Fld[2] eq '!DATE:') { |
shift @Fld; |
326 |
if ( $intro ) { |
shift @Fld; |
327 |
shift @Fld; |
@date = @Fld; |
328 |
shift @Fld; |
$tpage = 1; |
329 |
@date = @Fld; |
next LINE; |
330 |
$tpage = 1; |
} |
331 |
next LINE; |
} |
332 |
} |
|
333 |
} |
if ($Fld[2] eq '!INTRODUCTION:') { |
334 |
|
if ( $intro ) { |
335 |
if ($Fld[2] eq '!INTRODUCTION:') { |
&do_beg(); |
336 |
if ( $intro ) { |
print ' '; |
337 |
&do_beg(); |
print '%..............................................'; |
338 |
print ' '; |
shift @Fld; |
339 |
print '%..............................................'; |
shift @Fld; |
340 |
shift @Fld; |
print "\\section{@Fld}"; |
341 |
shift @Fld; |
next LINE; |
342 |
print "\\section{@Fld}"; |
} |
343 |
next LINE; |
} |
344 |
} |
|
345 |
} |
|
346 |
|
# End of introduction |
347 |
|
if ($Fld[1] eq $eoi_string) { |
348 |
# End of introduction |
print ' '; |
349 |
if ($Fld[1] eq $eoi_string) { |
print '%/////////////////////////////////////////////////////////////'; |
350 |
print ' '; |
print "\\newpage"; |
351 |
print '%/////////////////////////////////////////////////////////////'; |
$intro = 0; |
352 |
print "\\newpage"; |
next LINE; |
353 |
$intro = 0; |
} |
354 |
next LINE; |
|
355 |
} |
# Beginning of prologue |
356 |
|
if ( ($Fld[1] eq $bop_string) |
357 |
# Beginning of prologue |
&& (($Fld[2] eq "") || ($Fld[2] <= $opt_v)) ) { |
358 |
if ($Fld[1] eq $bop_string) { |
if ( $source ) { &do_eoc(); } |
359 |
if ( $source ) { &do_eoc(); } |
print ' '; |
360 |
print ' '; |
print '%/////////////////////////////////////////////////////////////'; |
361 |
print '%/////////////////////////////////////////////////////////////'; |
&do_beg(); |
362 |
&do_beg(); |
$first = 0; |
363 |
if ($first == 0) { |
if ($first == 0) { |
364 |
### print "\\newpage"; |
print " "; |
365 |
print " "; |
print "\\mbox{}\\hrulefill\\ "; |
366 |
print "\\mbox{}\\hrulefill\\ "; |
print " ";} |
367 |
print " ";} |
else { |
368 |
else { |
unless($opt_b){ |
369 |
unless($opt_b){ |
print |
370 |
print |
"\\section{Routine/Function Prologues} \\label{app:ProLogues}"; |
371 |
"\\section{Routine/Function Prologues} \\label{app:ProLogues}"; |
} |
372 |
} |
} |
373 |
} |
$first = 0; |
374 |
$first = 0; |
$prologue = 1; |
375 |
$prologue = 1; |
$verb = 0; |
376 |
$verb = 0; |
$source = 0; |
377 |
$source = 0; |
&set_missing(); # no required keyword yet |
378 |
&set_missing(); # no required keyword yet |
next LINE; |
379 |
next LINE; |
} |
380 |
} |
|
381 |
|
# Beginning of internal prologue |
382 |
# Beginning of internal prologue |
if ( ($Fld[1] eq $bopi_string)) { |
383 |
if ($Fld[1] eq $bopi_string) { |
if ($opt_i) {$prologue = 0;} |
384 |
if ($opt_i) {$prologue = 0;} |
else { |
385 |
else { |
if ($source) { &do_eoc(); } |
386 |
if ($source) { &do_eoc(); } |
print ' '; |
387 |
print ' '; |
print '%/////////////////////////////////////////////////////////////'; |
388 |
print '%/////////////////////////////////////////////////////////////'; |
&do_beg(); |
389 |
&do_beg(); |
if ($first ==0) { |
390 |
if ($first ==0) { |
### print "\\newpage"; |
391 |
### print "\\newpage"; |
print " "; |
392 |
print " "; |
print "\\mbox{}\\hrulefill\\"; |
393 |
print "\\mbox{}\\hrulefill\\"; |
print " ";} |
394 |
print " ";} |
else { |
395 |
else { |
unless($opt_b) { |
396 |
unless($opt_b) { |
print |
397 |
print |
"\\section{Routine/Function Prologues} \\label{app:ProLogues}"; |
398 |
"\\section{Routine/Function Prologues} \\label{app:ProLogues}"; |
} |
399 |
} |
} |
400 |
} |
$first = 0; |
401 |
$first = 0; |
$prologue = 1; |
402 |
$prologue = 1; |
$verb = 0; |
403 |
$verb = 0; |
$source = 0; |
404 |
$source = 0; |
&set_missing(); # no required keyword yet |
405 |
&set_missing(); # no required keyword yet |
next LINE; |
406 |
next LINE; |
} |
407 |
} |
} |
408 |
} |
|
409 |
|
# A new subroutine/function |
410 |
# A new subroutine/function |
if ($Fld[2] eq '!ROUTINE:' ) { |
411 |
if ($Fld[2] eq '!ROUTINE:' ) { |
if ($prologue) { |
412 |
if ($prologue) { |
shift @Fld; |
413 |
shift @Fld; |
shift @Fld; |
414 |
shift @Fld; |
$_ = join(' ', @Fld); |
415 |
$_ = join(' ', @Fld); |
$name_is = $_; |
416 |
$name_is = $_; |
s/_/\\_/g; |
417 |
s/_/\\_/g; |
# Replace "_" with "\_" |
418 |
# Replace "_" with "\_" |
if ( $opt_n && $not_first ) { |
419 |
if ( $opt_n && $not_first ) { |
printf "\\newpage\n"; |
420 |
printf "\\newpage\n"; |
} |
421 |
} |
unless ($opt_f) { |
422 |
unless ($opt_f) { |
printf "\\subsection{%s (File: %s)}\n\n", $_, $FileBaseName; |
423 |
printf "\\subsection{%s (File: %s)}\n\n", $_, $FileBaseName; |
} |
424 |
} |
else { |
425 |
else { |
printf "\\subsection{%s}\n\n", $_; |
426 |
printf "\\subsection{%s}\n\n", $_; |
printf "\n{\\sf FILE:} %s\n\\medskip\n", $FileBaseName; |
427 |
printf "\n{\\sf FILE:} %s\n\\medskip\n", $FileBaseName; |
} |
428 |
} |
$have_name = 1; |
429 |
$have_name = 1; |
$not_first = 1; |
430 |
$not_first = 1; |
next LINE; |
431 |
next LINE; |
} |
432 |
} |
} |
433 |
} |
|
434 |
|
# A new Module |
435 |
# A new Module |
if ($Fld[2] eq '!MODULE:' ) { |
436 |
if ($Fld[2] eq '!MODULE:' ) { |
if ($prologue) { |
437 |
if ($prologue) { |
shift @Fld; |
438 |
shift @Fld; |
shift @Fld; |
439 |
shift @Fld; |
$_ = join(' ', @Fld); |
440 |
$_ = join(' ', @Fld); |
$name_is = $_; |
441 |
$name_is = $_; |
s/_/\\_/g; # Replace "_" with "\_" |
442 |
s/_/\\_/g; # Replace "_" with "\_" |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
443 |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
unless($opt_f) { |
444 |
unless($opt_f) { |
printf |
445 |
printf |
"\\subsection{Fortran: Module Interface %s (File: %s)}\n\n", |
446 |
"\\subsection{Fortran: Module Interface %s (File: %s)}\n\n", |
$_, $FileBaseName; |
447 |
$_, $FileBaseName; |
} |
448 |
} |
else { |
449 |
else { |
printf "\\subsection{Fortran: Module Interface %s }\n\n", $_; |
450 |
printf "\\subsection{Fortran: Module Interface %s }\n\n", $_; |
} |
451 |
} |
$have_name = 1; |
452 |
$have_name = 1; |
$have_intf = 1; # fake it, it does not need one. |
453 |
$have_intf = 1; # fake it, it does not need one. |
$not_first = 1; |
454 |
$not_first = 1; |
next LINE; |
455 |
next LINE; |
} |
456 |
} |
} |
457 |
} |
|
458 |
|
# A new include file |
459 |
# A new include file |
if ($Fld[2] eq '!INCLUDE:' ) { |
460 |
if ($Fld[2] eq '!INCLUDE:' ) { |
if ($prologue) { |
461 |
if ($prologue) { |
shift @Fld; |
462 |
shift @Fld; |
shift @Fld; |
463 |
shift @Fld; |
$_ = join(' ', @Fld); |
464 |
$_ = join(' ', @Fld); |
$name_is = $_; |
465 |
$name_is = $_; |
s/_/\\_/g; # Replace "_" with "\_" |
466 |
s/_/\\_/g; # Replace "_" with "\_" |
if ( $opt_n && $not_first ) { |
467 |
if ( $opt_n && $not_first ) { |
printf "\\newpage\n"; |
468 |
printf "\\newpage\n"; |
} |
469 |
} |
unless($opt_f) { |
470 |
unless($opt_f) { |
printf |
471 |
printf |
"\\subsubsection{Include File %s (File: %s)}\n\n", |
472 |
"\\subsubsection{Include File %s (File: %s)}\n\n", |
$_, $FileBaseName;} |
473 |
$_, $FileBaseName;} |
else { |
474 |
else { |
printf "\\subsubsection{Include File %s }\n\n", $_; |
475 |
printf "\\subsubsection{Include File %s }\n\n", $_; |
} |
476 |
} |
$have_name = 1; |
477 |
$have_name = 1; |
$have_intf = 1; # fake it, it does not need one. |
478 |
$have_intf = 1; # fake it, it does not need one. |
$not_first = 1; |
479 |
$not_first = 1; |
next LINE; |
480 |
next LINE; |
} |
481 |
} |
} |
482 |
} |
|
483 |
|
# A new INTERNAL subroutine/function |
484 |
# A new INTERNAL subroutine/function |
if ($Fld[2] eq '!IROUTINE:') { # Internal routine |
485 |
if ($Fld[2] eq '!IROUTINE:') { # Internal routine |
if ($prologue) { |
486 |
if ($prologue) { |
shift @Fld; |
487 |
shift @Fld; |
shift @Fld; |
488 |
shift @Fld; |
$_ = join(' ', @Fld); |
489 |
$_ = join(' ', @Fld); |
$name_is = $_; |
490 |
$name_is = $_; |
s/_/\\_/g; # Replace "_" with "\_" |
491 |
s/_/\\_/g; # Replace "_" with "\_" |
@words = split " ", $_; |
492 |
@words = split " ", $_; |
printf "\\subsubsection [$words[1]] {$_}\n\n"; |
493 |
printf "\\subsubsection [$words[1]] {$_}\n\n"; |
$have_name = 1; |
494 |
$have_name = 1; |
next LINE; |
495 |
next LINE; |
} |
496 |
} |
} |
497 |
} |
|
498 |
|
# A new CLASS |
499 |
# A new CLASS |
if ($Fld[2] eq '!CLASS:' ) { |
500 |
if ($Fld[2] eq '!CLASS:' ) { |
if ($prologue) { |
501 |
if ($prologue) { |
shift @Fld; |
502 |
shift @Fld; |
shift @Fld; |
503 |
shift @Fld; |
$_ = join(' ', @Fld); |
504 |
$_ = join(' ', @Fld); |
$name_is = $_; |
505 |
$name_is = $_; |
s/_/\\_/g; # Replace "_" with "\_" |
506 |
s/_/\\_/g; # Replace "_" with "\_" |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
507 |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
unless($opt_f) { |
508 |
unless($opt_f) { |
printf |
509 |
printf |
"\\subsection{C++: Class Interface %s (File: %s)}\n\n", |
510 |
"\\subsection{C++: Class Interface %s (File: %s)}\n\n", |
$_, $FileBaseName;} |
511 |
$_, $FileBaseName;} |
else { |
512 |
else { |
printf "\\subsection{C++: Class Interface %s }\n\n", $_; |
513 |
printf "\\subsection{C++: Class Interface %s }\n\n", $_; |
} |
514 |
} |
$have_name = 1; |
515 |
$have_name = 1; |
$have_intf = 1; # fake it, it does not need one. |
516 |
$have_intf = 1; # fake it, it does not need one. |
$not_first = 1; |
517 |
$not_first = 1; |
next LINE; |
518 |
next LINE; |
} |
519 |
} |
} |
520 |
} |
|
521 |
|
# A new Method |
522 |
# A new Method |
if ($Fld[2] eq '!METHOD:' ) { |
523 |
if ($Fld[2] eq '!METHOD:' ) { |
if ($prologue) { |
524 |
if ($prologue) { |
shift @Fld; |
525 |
shift @Fld; |
shift @Fld; |
526 |
shift @Fld; |
$_ = join(' ', @Fld); |
527 |
$_ = join(' ', @Fld); |
$name_is = $_; |
528 |
$name_is = $_; |
s/_/\\_/g; # Replace "_" with "\_" |
529 |
s/_/\\_/g; # Replace "_" with "\_" |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
530 |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
unless ($opt_f) { |
531 |
unless ($opt_f) { |
printf "\\subsubsection{%s (File: %s)}\n\n", $_, $FileBaseName; |
532 |
printf "\\subsubsection{%s (File: %s)}\n\n", $_, $FileBaseName; |
} |
533 |
} |
else { |
534 |
else { |
printf "\\subsubsection{%s }\n\n", $_; |
535 |
printf "\\subsubsection{%s }\n\n", $_; |
} |
536 |
} |
$have_name = 1; |
537 |
$have_name = 1; |
$not_first = 1; |
538 |
$not_first = 1; |
next LINE; |
539 |
next LINE; |
} |
540 |
} |
} |
541 |
} |
|
542 |
|
# A new function |
543 |
# A new function |
if ($Fld[2] eq '!FUNCTION:' ) { |
544 |
if ($Fld[2] eq '!FUNCTION:' ) { |
if ($prologue) { |
545 |
if ($prologue) { |
shift @Fld; |
546 |
shift @Fld; |
shift @Fld; |
547 |
shift @Fld; |
$_ = join(' ', @Fld); |
548 |
$_ = join(' ', @Fld); |
$name_is = $_; |
549 |
$name_is = $_; |
s/_/\\_/g; # Replace "_" with "\_" |
550 |
s/_/\\_/g; # Replace "_" with "\_" |
if ( $opt_n && $not_first ) { |
551 |
if ( $opt_n && $not_first ) { |
printf "\\newpage\n"; |
552 |
printf "\\newpage\n"; |
} |
553 |
} |
unless ($opt_f) { |
554 |
unless ($opt_f) { |
printf |
555 |
printf |
"\\subsubsection{%s (File: %s)}\n\n", |
556 |
"\\subsubsection{%s (File: %s)}\n\n", |
$_, $FileBaseName; |
557 |
$_, $FileBaseName; |
} |
558 |
} |
else { |
559 |
else { |
printf "\\subsubsection{%s }\n\n", $_; |
560 |
printf "\\subsubsection{%s }\n\n", $_; |
} |
561 |
} |
$have_name = 1; |
562 |
$have_name = 1; |
$not_first = 1; |
563 |
$not_first = 1; |
next LINE; |
564 |
next LINE; |
} |
565 |
} |
} |
566 |
} |
|
567 |
|
# Description: what follows will be regular LaTeX (no verbatim) |
568 |
# Description: what follows will be regular LaTeX (no verbatim) |
if (/!DESCRIPTION:/) { |
569 |
if (/!DESCRIPTION:/) { |
if ($prologue) { |
570 |
if ($prologue) { |
if ($verb) { |
571 |
if ($verb) { |
&end_verbatim(); |
572 |
&end_verbatim(); |
printf "\n{\\sf DESCRIPTION: }\n\\medskip\n"; |
573 |
printf "\n{\\sf DESCRIPTION: }\n\\medskip\n"; |
} |
574 |
} |
else { # probably never occurs |
575 |
else { # probably never occurs |
} |
576 |
} |
if ($opt_x) { |
577 |
if ($opt_x) { |
&begin_verbatim(); |
578 |
&begin_verbatim(); |
$first_verb = 1; |
579 |
$first_verb = 1; |
} |
580 |
} |
else { |
581 |
else { |
for ($i = 3; $i <= $#Fld; $i++) { |
582 |
for ($i = 3; $i <= $#Fld; $i++) { |
printf '%s ', $Fld[$i]; |
583 |
printf '%s ', $Fld[$i]; |
} |
584 |
} |
} |
585 |
} |
### print " "; |
586 |
### print " "; |
$have_desc = 1; |
587 |
$have_desc = 1; |
next LINE; |
588 |
next LINE; |
} |
589 |
} |
} |
590 |
} |
|
591 |
|
# Handle optional keywords (these will appear as verbatim) |
592 |
# Handle optional keywords (these will appear as verbatim) |
if ($prologue) { |
593 |
if ($prologue) { |
KEY: |
594 |
KEY: |
foreach $key ( @keys ) { |
595 |
foreach $key ( @keys ) { |
if ( /$key/ ) { |
596 |
if ( /$key/ ) { |
if ($verb) { |
597 |
if ($verb) { |
&end_verbatim(); |
598 |
&end_verbatim(); |
} |
599 |
} |
else { |
600 |
else { |
printf "\n\\medskip\n"; |
601 |
printf "\n\\medskip\n"; |
} |
602 |
} |
$k = sprintf('%s', $key); |
603 |
$k = sprintf('%s', $key); |
$ln = length($k); |
604 |
$ln = length($k); |
###printf "\\subsubsection*{%s}\n", substr($k, 2, $ln - 1); |
605 |
###printf "\\subsubsection*{%s}\n", substr($k, 2, $ln - 1); |
###printf "{\\Large \\em %s}\n", ucfirst lc substr($k, 2, $ln - 1); |
606 |
###printf "{\\Large \\em %s}\n", ucfirst lc substr($k, 2, $ln - 1); |
$_ = $key; |
607 |
$_ = $key; |
printf "{\\sf %s}\n", substr($k, 2, $ln - 1); # san serif |
608 |
printf "{\\sf %s}\n", substr($k, 2, $ln - 1); # san serif |
&begin_verbatim(); |
609 |
&begin_verbatim(); |
$first_verb = 1; |
610 |
$first_verb = 1; |
if ( $key eq "!INTERFACE:" ) { $have_intf = 1; } |
611 |
if ( $key eq "!INTERFACE:" ) { $have_intf = 1; } |
if ( $key eq "!CALLING SEQUENCE:" ) { $have_intf = 1; } |
612 |
if ( $key eq "!CALLING SEQUENCE:" ) { $have_intf = 1; } |
if ( $key eq "!REVISION HISTORY:" ) { $have_hist = 1; } |
613 |
if ( $key eq "!REVISION HISTORY:" ) { $have_hist = 1; } |
next LINE; |
614 |
next LINE; |
} |
615 |
} |
} |
616 |
} |
} |
617 |
} |
|
618 |
|
# End of prologue |
619 |
# End of prologue |
if ($Fld[1] eq $eop_string) { |
620 |
if ($Fld[1] eq $eop_string) { |
if ($verb) { |
621 |
if ($verb) { |
&end_verbatim(); |
622 |
&end_verbatim(); |
} |
623 |
} |
$prologue = 0; |
624 |
$prologue = 0; |
# &check_if_all_there(); # check if all required keywords are there. |
625 |
# &check_if_all_there(); # check if all required keywords are there. |
if ( $opt_l ) { |
626 |
if ( $opt_l ) { |
$Fld[1] = $boc_string;} |
627 |
$Fld[1] = $boc_string;} |
else { |
628 |
else { |
next LINE; |
629 |
next LINE; |
} |
630 |
} |
} |
631 |
} |
|
632 |
|
unless ( $opt_s ) { |
633 |
unless ( $opt_s ) { |
|
634 |
|
# End of Internal Prologue |
635 |
# End of Internal Prologue |
if ($Fld[1] eq $eopi_string) { |
636 |
if ($Fld[1] eq $eopi_string) { |
if ($verb) { |
637 |
if ($verb) { |
&end_verbatim(); |
638 |
&end_verbatim(); |
} |
639 |
} |
$prologue = 0; |
640 |
$prologue = 0; |
# &check_if_all_there(); # check if all required keywords are there. |
641 |
# &check_if_all_there(); # check if all required keywords are there. |
if ($opt_l) { |
642 |
if ($opt_l) { |
$Fld[1] = $boc_string;} |
643 |
$Fld[1] = $boc_string;} |
else { next LINE; } |
644 |
else { next LINE; } |
} |
645 |
} |
|
646 |
|
# Beginning of source code section |
647 |
# Beginning of source code section |
if ($Fld[1] eq $boc_string) { |
648 |
if ($Fld[1] eq $boc_string) { |
print ' '; |
649 |
print ' '; |
print '%/////////////////////////////////////////////////////////////'; |
650 |
print '%/////////////////////////////////////////////////////////////'; |
$first = 0; |
651 |
$first = 0; |
$prologue = 0; |
652 |
$prologue = 0; |
$source = 1; |
653 |
$source = 1; |
### printf "\\subsubsection*{CONTENTS:}\n\n", $Fld[3]; |
654 |
### printf "\\subsubsection*{CONTENTS:}\n\n", $Fld[3]; |
printf "{\\sf CONTENTS:}"; |
655 |
printf "{\\sf CONTENTS:}"; |
&begin_verbatim(); |
656 |
&begin_verbatim(); |
next LINE; |
657 |
next LINE; |
} |
658 |
} |
|
659 |
|
# End of source code |
660 |
# End of source code |
if ($Fld[1] eq $eoc_string) { |
661 |
if ($Fld[1] eq $eoc_string) { |
&do_eoc(); |
662 |
&do_eoc(); |
$prologue = 0; |
663 |
$prologue = 0; |
next LINE; |
664 |
next LINE; |
} |
665 |
} |
} |
666 |
} |
|
667 |
|
# Prologue or Introduction, print regular line (except for !) |
668 |
# Prologue or Introduction, print regular line (except for !) |
if ($prologue||$intro) { |
669 |
if ($prologue||$intro) { |
if ( $verb && $#Fld == 1 && ( $Fld[1] eq $comment_string ) ) { |
670 |
if ( $verb && $#Fld == 1 && ( $Fld[1] eq $comment_string ) ) { |
next LINE; # to eliminate excessive blanks |
671 |
next LINE; # to eliminate excessive blanks |
} |
672 |
} |
if ( $Fld[2] eq "\\ev" ) { |
673 |
if ( $Fld[2] eq "\\ev" ) { |
# special handling |
674 |
# special handling |
$_ = $comment_string . " \\end{verbatim}"; |
675 |
$_ = $comment_string . " \\end{verbatim}"; |
} |
676 |
} |
s/^$comment_string/ /; # replace comment string with blank |
677 |
s/^$comment_string/ /; # replace comment string with blank |
# $line = sprintf('%s', $_); # not necessary -- comment str is absent |
678 |
# $line = sprintf('%s', $_); # not necessary -- comment str is absent |
# $ln = length($line); # not necessary -- comment str is absent |
679 |
# $ln = length($line); # not necessary -- comment str is absent |
unless ( $first_verb ) { printf "\n "; } |
680 |
unless ( $first_verb ) { printf "\n "; } |
printf '%s', $_; |
681 |
printf '%s', $_; |
# printf '%s', substr($line, 1, $ln - 1); # comment str is absent |
682 |
# printf '%s', substr($line, 1, $ln - 1); # comment str is absent |
$first_verb = 0; |
683 |
$first_verb = 0; |
next LINE; |
684 |
next LINE; |
} |
685 |
} |
|
686 |
|
# Source code: print the full line |
687 |
# Source code: print the full line |
if ($source) { |
688 |
if ($source) { |
print $_; |
689 |
print $_; |
next LINE; |
690 |
next LINE; |
} |
|
} |
|
691 |
|
|
692 |
} # end inner loop for processing each line of the input file |
} # end inner loop for processing each line of the input file |
693 |
|
|
694 |
} # end main loop for each command-line argument |
} # end main loop for each command-line argument |
695 |
|
|
696 |
print $_; |
print $_; |
697 |
if ( $source ) { &do_eoc(); } |
if ( $source ) { &do_eoc(); } |
900 |
print " Options:"; |
print " Options:"; |
901 |
print " -h Help mode: list command line options"; |
print " -h Help mode: list command line options"; |
902 |
print " -b Bare mode, meaning no preamble, etc."; |
print " -b Bare mode, meaning no preamble, etc."; |
903 |
|
print " +-v Verbosity level"; |
904 |
print " +-n New Page for each subsection (wastes paper)"; |
print " +-n New Page for each subsection (wastes paper)"; |
905 |
print " +-l Listing mode, default is prologues only"; |
print " +-l Listing mode, default is prologues only"; |
906 |
print " +-s Shut-up mode, i.e., ignore any code from BOC to EOC"; |
print " +-s Shut-up mode, i.e., ignore any code from BOC to EOC"; |