93 |
|
|
94 |
# Keep this if you don't know what it does... |
# Keep this if you don't know what it does... |
95 |
# ------------------------------------------- |
# ------------------------------------------- |
96 |
$[ = 1; # set array base to 1 |
$[ = 1; # set array base to 1 |
97 |
$, = ' '; # set output field separator |
$, = ' '; # set output field separator |
98 |
$\ = "\n"; # set output record separator |
$\ = "\n"; # set output record separator |
99 |
|
|
100 |
# Set valid options lists |
# Set valid options lists |
101 |
# ----------------------- |
# ----------------------- |
102 |
$GlobOptions = 'hb'; # Global options (i.e for all files) |
$GlobOptions = 'hb'; # Global options (i.e for all files) |
103 |
$LangOptions = 'ACFS7'; # Options for setting programming languages |
$LangOptions = 'ACFS7'; # Options for setting programming languages |
104 |
$SwOptions = 'flinsx'; # Options that can change for each input |
$SwOptions = 'flinsx'; # Options that can change for each input file |
105 |
# file |
$RegOptions = "$GlobOptions$LangOptions"; |
|
$RegOptions = "$GlobOptions$LangOptions"; |
|
106 |
# Scan for global options until first first |
# Scan for global options until first first |
107 |
# file is processed. |
# file is processed. |
108 |
|
|
109 |
# Scan for global options |
# Scan for global options |
110 |
# ----------------------- |
# ----------------------- |
111 |
$NFiles = 0; |
$NFiles = 0; |
112 |
Arg: |
Arg: |
113 |
foreach $arg (@ARGV) { |
foreach $arg (@ARGV) { |
114 |
$option = &CheckOpts ( $arg, $RegOptions, $SwOptions ) + 1; |
$option = &CheckOpts ( $arg, $RegOptions, $SwOptions ) + 1; |
115 |
if ( $option ) { |
if ( $option ) { |
116 |
$rc = &GetOpts ( $arg, $GlobOptions ); |
$rc = &GetOpts ( $arg, $GlobOptions ); |
117 |
next Arg; } |
next Arg; |
118 |
|
} |
119 |
else { $NFiles++; |
else { |
120 |
}# end if |
$NFiles++; |
121 |
}# end foreach |
} |
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 |
126 |
# -------------------------------------------------- |
# -------------------------------------------------- |
127 |
if ( $NFiles == 0 ) { push (@ARGV, "-"); } |
if ( $NFiles == 0 ) { push (@ARGV, "-"); } |
128 |
|
|
129 |
# Implement help option |
# Implement help option |
130 |
# --------------------- |
# --------------------- |
131 |
if ( $opt_h ) { |
if ( $opt_h ) { |
132 |
&print_help(); |
&print_help(); |
133 |
exit(); |
exit(); |
134 |
}#end if |
} |
135 |
|
|
136 |
# Optional Prologue Keywords |
# Optional Prologue Keywords |
137 |
# -------------------------- |
# -------------------------- |
138 |
@keys = ( "!INTERFACE:", |
@keys = ( "!INTERFACE:", |
139 |
"!USES:", |
"!USES:", |
140 |
"!PUBLIC TYPES:", |
"!PUBLIC TYPES:", |
141 |
"!PRIVATE TYPES:", |
"!PRIVATE TYPES:", |
142 |
"!PUBLIC MEMBER FUNCTIONS:", |
"!PUBLIC MEMBER FUNCTIONS:", |
143 |
"!PRIVATE MEMBER FUNCTIONS:", |
"!PRIVATE MEMBER FUNCTIONS:", |
144 |
"!PUBLIC DATA MEMBERS:", |
"!PUBLIC DATA MEMBERS:", |
145 |
"!PARAMETERS:", |
"!PARAMETERS:", |
146 |
"!ARGUMENTS:", |
"!ARGUMENTS:", |
147 |
"!DEFINED PARAMETERS:", |
"!DEFINED PARAMETERS:", |
148 |
"!INPUT PARAMETERS:", |
"!INPUT PARAMETERS:", |
149 |
"!INPUT/OUTPUT PARAMETERS:", |
"!INPUT/OUTPUT PARAMETERS:", |
150 |
"!OUTPUT PARAMETERS:", |
"!OUTPUT PARAMETERS:", |
151 |
"!RETURN VALUE:", |
"!RETURN VALUE:", |
152 |
"!REVISION HISTORY:", |
"!REVISION HISTORY:", |
153 |
"!BUGS:", |
"!BUGS:", |
154 |
"!SEE ALSO:", |
"!SEE ALSO:", |
155 |
"!SYSTEM ROUTINES:", |
"!SYSTEM ROUTINES:", |
156 |
"!FILES USED:", |
"!FILES USED:", |
157 |
"!REMARKS:", |
"!REMARKS:", |
158 |
"!TO DO:", |
"!TO DO:", |
159 |
"!CALLING SEQUENCE:", |
"!CALLING SEQUENCE:", |
160 |
"!AUTHOR:", |
"!AUTHOR:", |
161 |
"!CALLED FROM:", |
"!CALLED FROM:", |
162 |
"!LOCAL VARIABLES:" ); |
"!LOCAL VARIABLES:" ); |
163 |
|
|
164 |
# Initialize these for clarity |
# Initialize these for clarity |
165 |
# ---------------------------- |
# ---------------------------- |
166 |
$intro = 0; # doing introduction? |
$intro = 0; # doing introduction? |
167 |
$prologue = 0; # doing prologue? |
$prologue = 0; # doing prologue? |
168 |
$first = 1; # first prologue? |
$first = 1; # first prologue? |
169 |
$source = 0; # source code mode? |
$source = 0; # source code mode? |
170 |
$verb = 0; # verbatim mode? |
$verb = 0; # verbatim mode? |
171 |
$tpage = 0; # title page? |
$tpage = 0; # title page? |
172 |
$begdoc = 0; # has \begin{document} been written? |
$begdoc = 0; # has \begin{document} been written? |
173 |
|
|
174 |
# Initial LaTeX stuff |
# Initial LaTeX stuff |
175 |
# ------------------- |
# ------------------- |
176 |
&print_notice(); |
&print_notice(); |
177 |
&print_preamble(); # \documentclass, text dimensions, etc. |
&print_preamble(); # \documentclass, text dimensions, etc. |
178 |
&print_macros(); # short-hand LaTeX macros |
&print_macros(); # short-hand LaTeX macros |
179 |
|
|
180 |
# Main loop -- for each command-line argument |
# Main loop -- for each command-line argument |
181 |
# ------------------------------------------- |
# ------------------------------------------- |
182 |
ARG: |
ARG: |
183 |
foreach $arg (@ARGV) { |
foreach $arg (@ARGV) { |
184 |
|
|
185 |
# Scan for non-global command-line options |
# Scan for non-global command-line options |
186 |
# ---------------------------------------- |
$option = &CheckOpts ( $arg, $RegOptions, $SwOptions, "quiet" ) + 1; |
187 |
$option = &CheckOpts ( $arg, $RegOptions, $SwOptions, "quiet" ) + 1; |
if ( $option ) { |
188 |
if ( $option ) { |
&GetOpts ( $arg, $SwOptions ); |
189 |
&GetOpts ( $arg, $SwOptions ); |
&SetOpt ( $arg, $LangOptions ); |
190 |
&SetOpt ( $arg, $LangOptions ); |
next ARG; |
191 |
next ARG; |
} |
192 |
|
|
193 |
}# end if |
# Determine the type of code, set corresponding search strings |
194 |
|
$comment_string = '!'; # DEFAULT is FORTRAN |
|
# Determine the type of code, set corresponding search strings |
|
|
# ------------------------------------------------------------ |
|
|
# if ( $opt_F ) { # FORTRAN |
|
|
$comment_string = '!'; # ------- |
|
195 |
$boi_string = '!BOI'; |
$boi_string = '!BOI'; |
196 |
$eoi_string = '!EOI'; |
$eoi_string = '!EOI'; |
197 |
$bop_string = '!BOP'; |
$bop_string = '!BOP'; |
200 |
$eopi_string = '!EOPI'; |
$eopi_string = '!EOPI'; |
201 |
$boc_string = '!BOC'; |
$boc_string = '!BOC'; |
202 |
$eoc_string = '!EOC'; |
$eoc_string = '!EOC'; |
|
#}# end if |
|
203 |
|
|
204 |
if ( $opt_7 ) { # f77 |
if ( $opt_7 ) { # f77 |
205 |
$comment_string = 'C'; # --- |
$comment_string = 'C'; # --- |
206 |
$boi_string = 'CBOI'; |
$boi_string = 'CBOI'; |
207 |
$eoi_string = 'CEOI'; |
$eoi_string = 'CEOI'; |
208 |
$bop_string = 'CBOP'; |
$bop_string = 'CBOP'; |
209 |
$eop_string = 'CEOP'; |
$eop_string = 'CEOP'; |
210 |
$bopi_string = 'CBOPI'; |
$bopi_string = 'CBOPI'; |
211 |
$eopi_string = 'CEOPI'; |
$eopi_string = 'CEOPI'; |
212 |
$boc_string = 'CBOC'; |
$boc_string = 'CBOC'; |
213 |
$eoc_string = 'CEOC'; |
$eoc_string = 'CEOC'; |
214 |
}# end if |
} |
215 |
|
|
216 |
if ( $opt_A ) { # ADA |
if ( $opt_A ) { # ADA |
217 |
$comment_string = '--'; # --- |
$comment_string = '--'; # --- |
218 |
$boi_string = '--BOI'; |
$boi_string = '--BOI'; |
219 |
$eoi_string = '--EOI'; |
$eoi_string = '--EOI'; |
220 |
$bop_string = '--BOP'; |
$bop_string = '--BOP'; |
221 |
$eop_string = '--EOP'; |
$eop_string = '--EOP'; |
222 |
$bopi_string = '--BOPI'; |
$bopi_string = '--BOPI'; |
223 |
$eopi_string = '--EOPI'; |
$eopi_string = '--EOPI'; |
224 |
$boc_string = '--BOC'; |
$boc_string = '--BOC'; |
225 |
$eoc_string = '--EOC'; |
$eoc_string = '--EOC'; |
226 |
}# end if |
} |
227 |
|
|
228 |
if ( $opt_C ) { |
if ( $opt_C ) { |
229 |
$comment_string = '//'; # C |
$comment_string = '//'; # C |
230 |
$boi_string = '//BOI'; # - |
$boi_string = '//BOI'; # - |
231 |
$eoi_string = '//EOI'; |
$eoi_string = '//EOI'; |
232 |
$bop_string = '//BOP'; |
$bop_string = '//BOP'; |
233 |
$eop_string = '//EOP'; |
$eop_string = '//EOP'; |
234 |
$bopi_string = '//BOPI'; |
$bopi_string = '//BOPI'; |
235 |
$eopi_string = '//EOPI'; |
$eopi_string = '//EOPI'; |
236 |
$boc_string = '//BOC'; |
$boc_string = '//BOC'; |
237 |
$eoc_string = '//EOC'; |
$eoc_string = '//EOC'; |
238 |
}# end if |
} |
239 |
|
|
240 |
if ( $opt_S ) { # Script |
if ( $opt_S ) { # Script |
241 |
$comment_string = '#'; # ------ |
$comment_string = '#'; # ------ |
242 |
$boi_string = '#BOI'; |
$boi_string = '#BOI'; |
243 |
$eoi_string = '#EOI'; |
$eoi_string = '#EOI'; |
244 |
$bop_string = '#BOP'; |
$bop_string = '#BOP'; |
245 |
$eop_string = '#EOP'; |
$eop_string = '#EOP'; |
246 |
$bopi_string = '#BOPI'; |
$bopi_string = '#BOPI'; |
247 |
$eopi_string = '#EOPI'; |
$eopi_string = '#EOPI'; |
248 |
$boc_string = '#BOC'; |
$boc_string = '#BOC'; |
249 |
$eoc_string = '#EOC'; |
$eoc_string = '#EOC'; |
250 |
}# end if |
} |
251 |
|
|
252 |
# Set file name parameters |
# Set file name parameters |
253 |
# ------------------------ |
$InputFile = $arg; |
254 |
$InputFile = $arg; |
@all_path_components = split( /\//, $InputFile ); |
255 |
@all_path_components = split( /\//, $InputFile ); |
$FileBaseName = pop ( @all_path_components ); |
256 |
$FileBaseName = pop ( @all_path_components ); |
$FileBaseName =~ s/_/\\_/g; |
257 |
$FileBaseName =~ s/_/\\_/g; |
if ( $InputFile eq "-" ) {$FileBaseName = "Standard Input";} |
258 |
if ( $InputFile eq "-" ) {$FileBaseName = "Standard Input";} |
|
259 |
|
# Set date |
260 |
# Set date |
$Date = `date`; |
261 |
# -------- |
|
262 |
$Date = `date`; |
# Open current file |
263 |
|
open ( InputFile, "$InputFile" ) |
264 |
# Open current file |
or print STDERR "Unable to open $InputFile: $!"; |
|
# ----------------- |
|
|
open ( InputFile, "$InputFile" ) |
|
|
or print STDERR "Unable to open $InputFile: $!"; |
|
|
|
|
|
# Print page header |
|
|
# ----------------- |
|
|
chomp($Date); |
|
|
printf "\n\\markboth{Left}{Source File: %s, Date: %s}\n\n", |
|
|
$FileBaseName, $Date; |
|
|
|
|
|
LINE: |
|
|
# Inner loop --- for processing each line of the input file |
|
|
# --------------------------------------------------------- |
|
|
while ( <InputFile> ) { |
|
|
chop; # strip record separator |
|
|
|
|
|
# !PARAMETERS: really mean !ARGUMENTS: |
|
|
# ------------------------------------ |
|
|
# s/!PARAMETERS:/!ARGUMENTS:/g; |
|
|
|
|
|
@Fld = split(' ', $_, 9999); |
|
|
|
|
|
# Straight quote |
|
|
# -------------- |
|
|
if ($Fld[1] eq '!QUOTE:') { |
|
|
for ($i = 2; $i <= $#Fld; $i++) { |
|
|
printf '%s ', $Fld[$i]; |
|
|
}# end for |
|
|
print " "; |
|
|
next LINE; |
|
|
}# end if |
|
|
|
|
|
# Handle optional Title Page and Introduction |
|
|
# ------------------------------------------- |
|
|
if ($Fld[1] eq $boi_string) { |
|
|
print ' '; |
|
|
$intro = 1; |
|
|
next LINE; |
|
|
}# end if |
|
|
|
|
|
if ($Fld[2] eq '!TITLE:') { |
|
|
if ( $intro ) { |
|
|
shift @Fld; |
|
|
shift @Fld; |
|
|
@title = @Fld; |
|
|
$tpage = 1; |
|
|
next LINE; |
|
|
}# end if |
|
|
}# end if |
|
|
|
|
|
if ($Fld[2] eq '!AUTHORS:') { |
|
|
if ( $intro ) { |
|
|
shift @Fld; |
|
|
shift @Fld; |
|
|
@author = @Fld; |
|
|
$tpage = 1; |
|
|
next LINE; |
|
|
}# end if |
|
|
}# end if |
|
|
|
|
|
if ($Fld[2] eq '!AFFILIATION:') { |
|
|
if ( $intro ) { |
|
|
shift @Fld; |
|
|
shift @Fld; |
|
|
@affiliation = @Fld; |
|
|
$tpage = 1; |
|
|
next LINE; |
|
|
}# end if |
|
|
}# end if |
|
|
|
|
|
if ($Fld[2] eq '!DATE:') { |
|
|
if ( $intro ) { |
|
|
shift @Fld; |
|
|
shift @Fld; |
|
|
@date = @Fld; |
|
|
$tpage = 1; |
|
|
next LINE; |
|
|
}# end if |
|
|
}# end if |
|
|
|
|
|
if ($Fld[2] eq '!INTRODUCTION:') { |
|
|
if ( $intro ) { |
|
|
&do_beg(); |
|
|
print ' '; |
|
|
print '%..............................................'; |
|
|
shift @Fld; |
|
|
shift @Fld; |
|
|
print "\\section{@Fld}"; |
|
|
next LINE; |
|
|
}# end if |
|
|
}# end if |
|
|
|
|
|
|
|
|
# End of introduction |
|
|
# ------------------- |
|
|
if ($Fld[1] eq $eoi_string) { |
|
|
print ' '; |
|
|
print '%/////////////////////////////////////////////////////////////'; |
|
|
print "\\newpage"; |
|
|
$intro = 0; |
|
|
next LINE; |
|
|
}# end if |
|
|
|
|
|
# Beginning of prologue |
|
|
# --------------------- |
|
|
if ($Fld[1] eq $bop_string) { |
|
|
if ( $source ) { &do_eoc(); } |
|
|
print ' '; |
|
|
print '%/////////////////////////////////////////////////////////////'; |
|
|
&do_beg(); |
|
|
if ($first == 0) { |
|
|
### print "\\newpage"; |
|
|
print " "; |
|
|
print "\\mbox{}\\hrulefill\\ "; |
|
|
print " ";} |
|
|
else { |
|
|
unless($opt_b){print "\\section{Routine/Function Prologues} \\label{app:ProLogues}";} |
|
|
}# end if |
|
265 |
|
|
266 |
$first = 0; |
# Print page header |
267 |
$prologue = 1; |
chomp($Date); |
268 |
$verb = 0; |
# printf "\n\\markboth{Left}{Source File: %s, Date: %s}\n\n", |
269 |
$source = 0; |
printf "\n\\markboth{Source File: %s}{Date: %s}\n\n", |
270 |
&set_missing(); # no required keyword yet |
$FileBaseName, $Date; |
271 |
next LINE; |
|
272 |
}# end if |
# Inner loop --- for processing each line of the input file |
273 |
|
LINE: |
274 |
# Beginning of internal prologue |
while ( <InputFile> ) { |
275 |
# ------------------------------ |
chop; # strip record separator |
276 |
if ($Fld[1] eq $bopi_string) { |
|
277 |
if ($opt_i) {$prologue = 0;} |
@Fld = split(' ', $_, 9999); |
278 |
else { |
|
279 |
if ($source) { &do_eoc(); } |
# Straight quote |
280 |
print ' '; |
if ($Fld[1] eq '!QUOTE:') { |
281 |
print '%/////////////////////////////////////////////////////////////'; |
for ($i = 2; $i <= $#Fld; $i++) { |
282 |
&do_beg(); |
printf '%s ', $Fld[$i]; |
283 |
if ($first ==0) { |
} |
284 |
### print "\\newpage"; |
print " "; |
285 |
print " "; |
next LINE; |
286 |
print "\\mbox{}\\hrulefill\\"; |
} |
287 |
print " ";} |
|
288 |
else { |
# Handle optional Title Page and Introduction |
289 |
unless($opt_b){print "\\section{Routine/Function Prologues} \\label{app:ProLogues}";} |
if ($Fld[1] eq $boi_string) { |
290 |
}# endif |
print ' '; |
291 |
$first = 0; |
$intro = 1; |
292 |
$prologue = 1; |
next LINE; |
293 |
$verb = 0; |
} |
294 |
$source = 0; |
|
295 |
&set_missing(); # no required keyword yet |
if ($Fld[2] eq '!TITLE:') { |
296 |
next LINE; |
if ( $intro ) { |
297 |
}# endelse |
shift @Fld; |
298 |
}# endif |
shift @Fld; |
299 |
|
@title = @Fld; |
300 |
# A new subroutine/function |
$tpage = 1; |
301 |
# ------------------------- |
next LINE; |
302 |
if ($Fld[2] eq '!ROUTINE:' ) { |
} |
303 |
if ($prologue) { |
} |
304 |
shift @Fld; |
|
305 |
shift @Fld; |
if ($Fld[2] eq '!AUTHORS:') { |
306 |
$_ = join(' ', @Fld); |
if ( $intro ) { |
307 |
$name_is = $_; |
shift @Fld; |
308 |
s/_/\\_/g; # Replace "_" with "\_" |
shift @Fld; |
309 |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
@author = @Fld; |
310 |
unless ($opt_f) {printf "\\subsubsection{%s (Source File: %s)}\n\n", $_, $FileBaseName;} |
$tpage = 1; |
311 |
else {printf "\\subsubsection{%s }\n\n", $_;} |
next LINE; |
312 |
$have_name = 1; |
} |
313 |
$not_first = 1; |
} |
314 |
next LINE; |
|
315 |
}# end if |
if ($Fld[2] eq '!AFFILIATION:') { |
316 |
}# end if |
if ( $intro ) { |
317 |
|
shift @Fld; |
318 |
# A new Module |
shift @Fld; |
319 |
# ------------ |
@affiliation = @Fld; |
320 |
if ($Fld[2] eq '!MODULE:' ) { |
$tpage = 1; |
321 |
if ($prologue) { |
next LINE; |
322 |
shift @Fld; |
} |
323 |
shift @Fld; |
} |
324 |
$_ = join(' ', @Fld); |
|
325 |
$name_is = $_; |
if ($Fld[2] eq '!DATE:') { |
326 |
s/_/\\_/g; # Replace "_" with "\_" |
if ( $intro ) { |
327 |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
shift @Fld; |
328 |
unless($opt_f) {printf "\\subsection{Fortran: Module Interface %s (Source File: %s)}\n\n", $_, $FileBaseName;} |
shift @Fld; |
329 |
else {printf "\\subsection{Fortran: Module Interface %s }\n\n", $_;} |
@date = @Fld; |
330 |
$have_name = 1; |
$tpage = 1; |
331 |
$have_intf = 1; # fake it, it does not need one. |
next LINE; |
332 |
$not_first = 1; |
} |
333 |
next LINE; |
} |
334 |
}# end if |
|
335 |
}# end if |
if ($Fld[2] eq '!INTRODUCTION:') { |
336 |
|
if ( $intro ) { |
337 |
# A new include file |
&do_beg(); |
338 |
# ------------------ |
print ' '; |
339 |
if ($Fld[2] eq '!INCLUDE:' ) { |
print '%..............................................'; |
340 |
if ($prologue) { |
shift @Fld; |
341 |
shift @Fld; |
shift @Fld; |
342 |
shift @Fld; |
print "\\section{@Fld}"; |
343 |
$_ = join(' ', @Fld); |
next LINE; |
344 |
$name_is = $_; |
} |
345 |
s/_/\\_/g; # Replace "_" with "\_" |
} |
346 |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
|
347 |
unless($opt_f) {printf "\\subsubsection{Include File %s (Source File: %s)}\n\n", $_, $FileBaseName;} |
|
348 |
else {printf "\\subsubsection{Include File %s }\n\n", $_;} |
# End of introduction |
349 |
$have_name = 1; |
if ($Fld[1] eq $eoi_string) { |
350 |
$have_intf = 1; # fake it, it does not need one. |
print ' '; |
351 |
$not_first = 1; |
print '%/////////////////////////////////////////////////////////////'; |
352 |
next LINE; |
print "\\newpage"; |
353 |
}# end if |
$intro = 0; |
354 |
}# end if |
next LINE; |
355 |
|
} |
356 |
# A new INTERNAL subroutine/function |
|
357 |
# ---------------------------------- |
# Beginning of prologue |
358 |
if ($Fld[2] eq '!IROUTINE:') { # Internal routine |
if ($Fld[1] eq $bop_string) { |
359 |
if ($prologue) { |
if ( $source ) { &do_eoc(); } |
360 |
shift @Fld; |
print ' '; |
361 |
shift @Fld; |
print '%/////////////////////////////////////////////////////////////'; |
362 |
$_ = join(' ', @Fld); |
&do_beg(); |
363 |
$name_is = $_; |
if ($first == 0) { |
364 |
s/_/\\_/g; # Replace "_" with "\_" |
### print "\\newpage"; |
365 |
@words = split " ", $_; |
print " "; |
366 |
printf "\\subsubsection [$words[1]] {$_}\n\n"; |
print "\\mbox{}\\hrulefill\\ "; |
367 |
$have_name = 1; |
print " ";} |
368 |
next LINE; |
else { |
369 |
}# end if |
unless($opt_b){ |
370 |
}# end if |
print |
371 |
|
"\\section{Routine/Function Prologues} \\label{app:ProLogues}"; |
372 |
# A new CLASS |
} |
373 |
# ------------ |
} |
374 |
if ($Fld[2] eq '!CLASS:' ) { |
$first = 0; |
375 |
if ($prologue) { |
$prologue = 1; |
376 |
shift @Fld; |
$verb = 0; |
377 |
shift @Fld; |
$source = 0; |
378 |
$_ = join(' ', @Fld); |
&set_missing(); # no required keyword yet |
379 |
$name_is = $_; |
next LINE; |
380 |
s/_/\\_/g; # Replace "_" with "\_" |
} |
381 |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
|
382 |
unless($opt_f) {printf "\\subsection{C++: Class Interface %s (Source File: %s)}\n\n", $_, $FileBaseName;} |
# Beginning of internal prologue |
383 |
else {printf "\\subsection{C++: Class Interface %s }\n\n", $_;} |
if ($Fld[1] eq $bopi_string) { |
384 |
$have_name = 1; |
if ($opt_i) {$prologue = 0;} |
385 |
$have_intf = 1; # fake it, it does not need one. |
else { |
386 |
$not_first = 1; |
if ($source) { &do_eoc(); } |
387 |
next LINE; |
print ' '; |
388 |
}# end if |
print '%/////////////////////////////////////////////////////////////'; |
389 |
}# end if |
&do_beg(); |
390 |
|
if ($first ==0) { |
391 |
# A new Method |
### print "\\newpage"; |
392 |
# ------------------------- |
print " "; |
393 |
if ($Fld[2] eq '!METHOD:' ) { |
print "\\mbox{}\\hrulefill\\"; |
394 |
if ($prologue) { |
print " ";} |
395 |
shift @Fld; |
else { |
396 |
shift @Fld; |
unless($opt_b) { |
397 |
$_ = join(' ', @Fld); |
print |
398 |
$name_is = $_; |
"\\section{Routine/Function Prologues} \\label{app:ProLogues}"; |
399 |
s/_/\\_/g; # Replace "_" with "\_" |
} |
400 |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
} |
401 |
unless ($opt_f) {printf "\\subsubsection{%s (Source File: %s)}\n\n", $_, $FileBaseName;} |
$first = 0; |
402 |
else {printf "\\subsubsection{%s }\n\n", $_;} |
$prologue = 1; |
403 |
$have_name = 1; |
$verb = 0; |
404 |
$not_first = 1; |
$source = 0; |
405 |
next LINE; |
&set_missing(); # no required keyword yet |
406 |
}# end if |
next LINE; |
407 |
}# end if |
} |
408 |
|
} |
409 |
# A new function |
|
410 |
# ------------------------- |
# A new subroutine/function |
411 |
if ($Fld[2] eq '!FUNCTION:' ) { |
if ($Fld[2] eq '!ROUTINE:' ) { |
412 |
if ($prologue) { |
if ($prologue) { |
413 |
shift @Fld; |
shift @Fld; |
414 |
shift @Fld; |
shift @Fld; |
415 |
$_ = join(' ', @Fld); |
$_ = join(' ', @Fld); |
416 |
$name_is = $_; |
$name_is = $_; |
417 |
s/_/\\_/g; # Replace "_" with "\_" |
s/_/\\_/g; |
418 |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
# Replace "_" with "\_" |
419 |
unless ($opt_f) {printf "\\subsubsection{%s (Source File: %s)}\n\n", $_, $FileBaseName;} |
if ( $opt_n && $not_first ) { |
420 |
else {printf "\\subsubsection{%s }\n\n", $_;} |
printf "\\newpage\n"; |
421 |
$have_name = 1; |
} |
422 |
$not_first = 1; |
unless ($opt_f) { |
423 |
next LINE; |
printf "\\subsubsection{%s (File: %s)}\n\n", $_, $FileBaseName; |
424 |
}# end if |
} |
425 |
}# end if |
else { |
426 |
|
printf "\\subsubsection{%s }\n\n", $_; |
427 |
# Description: what follows will be regular LaTeX (no verbatim) |
} |
428 |
# ------------------------------------------------------------- |
$have_name = 1; |
429 |
if (/!DESCRIPTION:/) { |
$not_first = 1; |
430 |
if ($prologue) { |
next LINE; |
431 |
if ($verb) { |
} |
432 |
printf "\\end{verbatim}"; |
} |
433 |
printf "\n{\\sf DESCRIPTION:\\\\ }\n\n"; |
|
434 |
$verb = 0; } |
# A new Module |
435 |
else { # probably never occurs |
if ($Fld[2] eq '!MODULE:' ) { |
436 |
}# end if |
if ($prologue) { |
437 |
if ($opt_x) { |
shift @Fld; |
438 |
printf "\\begin{verbatim} "; |
shift @Fld; |
439 |
$verb = 1; |
$_ = join(' ', @Fld); |
440 |
$first_verb = 1; } |
$name_is = $_; |
441 |
else { |
s/_/\\_/g; # Replace "_" with "\_" |
442 |
for ($i = 3; $i <= $#Fld; $i++) { |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
443 |
printf '%s ', $Fld[$i]; |
unless($opt_f) { |
444 |
}# end for |
printf |
445 |
}# end if |
"\\subsection{Fortran: Module Interface %s (File: %s)}\n\n", |
446 |
### print " "; |
$_, $FileBaseName; |
447 |
$have_desc = 1; |
} |
448 |
next LINE; |
else { |
449 |
}# end if |
printf "\\subsection{Fortran: Module Interface %s }\n\n", $_; |
450 |
}# end if |
} |
451 |
|
$have_name = 1; |
452 |
# Handle optional keywords (these will appear as verbatim) |
$have_intf = 1; # fake it, it does not need one. |
453 |
# -------------------------------------------------------- |
$not_first = 1; |
454 |
if ($prologue) { |
next LINE; |
455 |
KEY: foreach $key ( @keys ) { |
} |
456 |
if ( /$key/ ) { |
} |
457 |
if ($verb) { |
|
458 |
printf "\\end{verbatim}"; |
# A new include file |
459 |
$verb = 0; } |
if ($Fld[2] eq '!INCLUDE:' ) { |
460 |
else { |
if ($prologue) { |
461 |
printf "\n\\bigskip"; |
shift @Fld; |
462 |
}# end if |
shift @Fld; |
463 |
$k = sprintf('%s', $key); |
$_ = join(' ', @Fld); |
464 |
$ln = length($k); |
$name_is = $_; |
465 |
###printf "\\subsubsection*{%s}\n", substr($k, 2, $ln - 1); |
s/_/\\_/g; # Replace "_" with "\_" |
466 |
###printf "{\\Large \\em %s}\n", ucfirst lc substr($k, 2, $ln - 1); |
if ( $opt_n && $not_first ) { |
467 |
$_ = $key; |
printf "\\newpage\n"; |
468 |
if( /USES/ || /INPUT/ || /OUTPUT/ || /PARAMETERS/ || |
} |
469 |
/VALUE/ || /ARGUMENTS/ ) { |
unless($opt_f) { |
470 |
printf "{\\em %s}\n", substr($k, 2, $ln - 1); } # italics |
printf |
471 |
else { |
"\\subsubsection{Include File %s (File: %s)}\n\n", |
472 |
printf "{\\sf %s}\n", substr($k, 2, $ln - 1); # san serif |
$_, $FileBaseName;} |
473 |
}# end if |
else { |
474 |
|
printf "\\subsubsection{Include File %s }\n\n", $_; |
475 |
printf "\\begin{verbatim} "; |
} |
476 |
$verb = 1; |
$have_name = 1; |
477 |
$first_verb = 1; |
$have_intf = 1; # fake it, it does not need one. |
478 |
if ( $key eq "!INTERFACE:" ) { $have_intf = 1; } |
$not_first = 1; |
479 |
if ( $key eq "!CALLING SEQUENCE:" ) { $have_intf = 1; } |
next LINE; |
480 |
if ( $key eq "!REVISION HISTORY:" ) { $have_hist = 1; } |
} |
481 |
next LINE; |
} |
482 |
}# end if |
|
483 |
}# end foreach |
# A new INTERNAL subroutine/function |
484 |
}# end if |
if ($Fld[2] eq '!IROUTINE:') { # Internal routine |
485 |
|
if ($prologue) { |
486 |
# End of prologue |
shift @Fld; |
487 |
# --------------- |
shift @Fld; |
488 |
if ($Fld[1] eq $eop_string) { |
$_ = join(' ', @Fld); |
489 |
if ($verb) { |
$name_is = $_; |
490 |
print "\\end{verbatim}"; |
s/_/\\_/g; # Replace "_" with "\_" |
491 |
$verb = 0; |
@words = split " ", $_; |
492 |
}# end if |
printf "\\subsubsection [$words[1]] {$_}\n\n"; |
493 |
$prologue = 0; |
$have_name = 1; |
494 |
# &check_if_all_there(); # check if all required keywords are there. |
next LINE; |
495 |
if ( $opt_l ) { |
} |
496 |
$Fld[1] = $boc_string;} |
} |
497 |
else { next LINE; } |
|
498 |
}# end if |
# A new CLASS |
499 |
|
if ($Fld[2] eq '!CLASS:' ) { |
500 |
unless ( $opt_s ) { |
if ($prologue) { |
501 |
|
shift @Fld; |
502 |
# End of Internal Prologue |
shift @Fld; |
503 |
# ------------------------ |
$_ = join(' ', @Fld); |
504 |
|
$name_is = $_; |
505 |
if ($Fld[1] eq $eopi_string) { |
s/_/\\_/g; # Replace "_" with "\_" |
506 |
if ($verb) { |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
507 |
print "\\end{verbatim}"; |
unless($opt_f) { |
508 |
$verb = 0; |
printf |
509 |
}# endif |
"\\subsection{C++: Class Interface %s (File: %s)}\n\n", |
510 |
$prologue = 0; |
$_, $FileBaseName;} |
511 |
# &check_if_all_there(); # check if all required keywords are there. |
else { |
512 |
if ($opt_l) { |
printf "\\subsection{C++: Class Interface %s }\n\n", $_; |
513 |
$Fld[1] = $boc_string;} |
} |
514 |
else { next LINE; } |
$have_name = 1; |
515 |
}# endif |
$have_intf = 1; # fake it, it does not need one. |
516 |
|
$not_first = 1; |
517 |
# |
next LINE; |
518 |
# Beginning of source code section |
} |
519 |
# -------------------------------- |
} |
520 |
if ($Fld[1] eq $boc_string) { |
|
521 |
print ' '; |
# A new Method |
522 |
print '%/////////////////////////////////////////////////////////////'; |
if ($Fld[2] eq '!METHOD:' ) { |
523 |
$first = 0; |
if ($prologue) { |
524 |
$prologue = 0; |
shift @Fld; |
525 |
$source = 1; |
shift @Fld; |
526 |
### printf "\\subsubsection*{CONTENTS:}\n\n", $Fld[3]; |
$_ = join(' ', @Fld); |
527 |
printf "{\\sf CONTENTS:}"; |
$name_is = $_; |
528 |
printf "\n \\begin{verbatim}\n"; |
s/_/\\_/g; # Replace "_" with "\_" |
529 |
$verb = 1; |
if ( $opt_n && $not_first ) { printf "\\newpage\n"; } |
530 |
next LINE; |
unless ($opt_f) { |
531 |
}# end if |
printf "\\subsubsection{%s (File: %s)}\n\n", $_, $FileBaseName; |
532 |
|
} |
533 |
# End of source code |
else { |
534 |
# ------------------ |
printf "\\subsubsection{%s }\n\n", $_; |
535 |
if ($Fld[1] eq $eoc_string) { |
} |
536 |
&do_eoc(); |
$have_name = 1; |
537 |
$prologue = 0; |
$not_first = 1; |
538 |
next LINE; |
next LINE; |
539 |
}# end if |
} |
540 |
}# end unless |
} |
541 |
|
|
542 |
# Prologue or Introduction, print regular line (except for !) |
# A new function |
543 |
# ----------------------------------------------------------- |
if ($Fld[2] eq '!FUNCTION:' ) { |
544 |
if ($prologue||$intro) { |
if ($prologue) { |
545 |
if ( $verb && $#Fld == 1 && ( $Fld[1] eq $comment_string ) ) { |
shift @Fld; |
546 |
next LINE; # to eliminate excessive blanks |
shift @Fld; |
547 |
}# end if |
$_ = join(' ', @Fld); |
548 |
if ( $Fld[2] eq "\\ev" ) { # special handling |
$name_is = $_; |
549 |
$_ = $comment_string . " \\end{verbatim}"; |
s/_/\\_/g; # Replace "_" with "\_" |
550 |
}# end if |
if ( $opt_n && $not_first ) { |
551 |
s/^$comment_string/ /; # replace comment string with blank |
printf "\\newpage\n"; |
552 |
# $line = sprintf('%s', $_); # not necessary -- comment str is absent |
} |
553 |
# $ln = length($line); # not necessary -- comment str is absent |
unless ($opt_f) { |
554 |
unless ( $first_verb ) { printf "\n "; } |
printf |
555 |
printf '%s', $_; |
"\\subsubsection{%s (File: %s)}\n\n", |
556 |
# printf '%s', substr($line, 1, $ln - 1); # comment str is absent |
$_, $FileBaseName; |
557 |
$first_verb = 0; |
} |
558 |
next LINE; |
else { |
559 |
}# end if |
printf "\\subsubsection{%s }\n\n", $_; |
560 |
|
} |
561 |
# Source code: print the full line |
$have_name = 1; |
562 |
# -------------------------------- |
$not_first = 1; |
563 |
if ($source) { |
next LINE; |
564 |
print $_; |
} |
565 |
next LINE; |
} |
566 |
}# end if |
|
567 |
|
# Description: what follows will be regular LaTeX (no verbatim) |
568 |
}# end inner loop for processing each line of the input file |
if (/!DESCRIPTION:/) { |
569 |
# --------------------------------------------------------- |
if ($prologue) { |
570 |
|
if ($verb) { |
571 |
}# end main loop for each command-line argument |
&end_verbatim(); |
572 |
# -------------------------------------------- |
printf "\n{\\sf DESCRIPTION:\\\\ }\n\n"; |
573 |
print $_; |
} |
574 |
if ( $source ) { &do_eoc(); } |
else { # probably never occurs |
575 |
print '%...............................................................'; |
} |
576 |
|
if ($opt_x) { |
577 |
# see comment above where these are originally set. |
&begin_verbatim(); |
578 |
#print "\\setlength{\\parskip}{\\oldparskip}"; |
$first_verb = 1; |
579 |
#print "\\setlength{\\parindent}{\\oldparindent}"; |
} |
580 |
#print "\\setlength{\\baselineskip}{\\oldbaselineskip}"; |
else { |
581 |
|
for ($i = 3; $i <= $#Fld; $i++) { |
582 |
unless ( $opt_b ) { |
printf '%s ', $Fld[$i]; |
583 |
print "\\end{document}"; |
} |
584 |
}#end unless |
} |
585 |
|
### print " "; |
586 |
|
$have_desc = 1; |
587 |
|
next LINE; |
588 |
|
} |
589 |
|
} |
590 |
|
|
591 |
|
# Handle optional keywords (these will appear as verbatim) |
592 |
|
if ($prologue) { |
593 |
|
KEY: |
594 |
|
foreach $key ( @keys ) { |
595 |
|
if ( /$key/ ) { |
596 |
|
if ($verb) { |
597 |
|
&end_verbatim(); |
598 |
|
} |
599 |
|
else { |
600 |
|
printf "\n\\bigskip"; |
601 |
|
} |
602 |
|
$k = sprintf('%s', $key); |
603 |
|
$ln = length($k); |
604 |
|
###printf "\\subsubsection*{%s}\n", substr($k, 2, $ln - 1); |
605 |
|
###printf "{\\Large \\em %s}\n", ucfirst lc substr($k, 2, $ln - 1); |
606 |
|
$_ = $key; |
607 |
|
if( /USES/ || /INPUT/ || /OUTPUT/ || /PARAMETERS/ || |
608 |
|
/VALUE/ || /ARGUMENTS/ ) { |
609 |
|
printf "{\\em %s}\n", substr($k, 2, $ln - 1); } # italics |
610 |
|
else { |
611 |
|
printf "{\\sf %s}\n", substr($k, 2, $ln - 1); # san serif |
612 |
|
} |
613 |
|
&begin_verbatim(); |
614 |
|
$first_verb = 1; |
615 |
|
if ( $key eq "!INTERFACE:" ) { $have_intf = 1; } |
616 |
|
if ( $key eq "!CALLING SEQUENCE:" ) { $have_intf = 1; } |
617 |
|
if ( $key eq "!REVISION HISTORY:" ) { $have_hist = 1; } |
618 |
|
next LINE; |
619 |
|
} |
620 |
|
} |
621 |
|
} |
622 |
|
|
623 |
|
# End of prologue |
624 |
|
if ($Fld[1] eq $eop_string) { |
625 |
|
if ($verb) { |
626 |
|
&end_verbatim(); |
627 |
|
} |
628 |
|
$prologue = 0; |
629 |
|
# &check_if_all_there(); # check if all required keywords are there. |
630 |
|
if ( $opt_l ) { |
631 |
|
$Fld[1] = $boc_string;} |
632 |
|
else { |
633 |
|
next LINE; |
634 |
|
} |
635 |
|
} |
636 |
|
|
637 |
|
unless ( $opt_s ) { |
638 |
|
|
639 |
|
# End of Internal Prologue |
640 |
|
if ($Fld[1] eq $eopi_string) { |
641 |
|
if ($verb) { |
642 |
|
&end_verbatim(); |
643 |
|
} |
644 |
|
$prologue = 0; |
645 |
|
# &check_if_all_there(); # check if all required keywords are there. |
646 |
|
if ($opt_l) { |
647 |
|
$Fld[1] = $boc_string;} |
648 |
|
else { next LINE; } |
649 |
|
} |
650 |
|
|
651 |
|
# Beginning of source code section |
652 |
|
if ($Fld[1] eq $boc_string) { |
653 |
|
print ' '; |
654 |
|
print '%/////////////////////////////////////////////////////////////'; |
655 |
|
$first = 0; |
656 |
|
$prologue = 0; |
657 |
|
$source = 1; |
658 |
|
### printf "\\subsubsection*{CONTENTS:}\n\n", $Fld[3]; |
659 |
|
printf "{\\sf CONTENTS:}"; |
660 |
|
&begin_verbatim(); |
661 |
|
next LINE; |
662 |
|
} |
663 |
|
|
664 |
|
# End of source code |
665 |
|
if ($Fld[1] eq $eoc_string) { |
666 |
|
&do_eoc(); |
667 |
|
$prologue = 0; |
668 |
|
next LINE; |
669 |
|
} |
670 |
|
} |
671 |
|
|
672 |
|
# Prologue or Introduction, print regular line (except for !) |
673 |
|
if ($prologue||$intro) { |
674 |
|
if ( $verb && $#Fld == 1 && ( $Fld[1] eq $comment_string ) ) { |
675 |
|
next LINE; # to eliminate excessive blanks |
676 |
|
} |
677 |
|
if ( $Fld[2] eq "\\ev" ) { |
678 |
|
# special handling |
679 |
|
$_ = $comment_string . " \\end{verbatim}"; |
680 |
|
} |
681 |
|
s/^$comment_string/ /; # replace comment string with blank |
682 |
|
# $line = sprintf('%s', $_); # not necessary -- comment str is absent |
683 |
|
# $ln = length($line); # not necessary -- comment str is absent |
684 |
|
unless ( $first_verb ) { printf "\n "; } |
685 |
|
printf '%s', $_; |
686 |
|
# printf '%s', substr($line, 1, $ln - 1); # comment str is absent |
687 |
|
$first_verb = 0; |
688 |
|
next LINE; |
689 |
|
} |
690 |
|
|
691 |
|
# Source code: print the full line |
692 |
|
if ($source) { |
693 |
|
print $_; |
694 |
|
next LINE; |
695 |
|
} |
696 |
|
|
697 |
|
} # end inner loop for processing each line of the input file |
698 |
|
|
699 |
|
} # end main loop for each command-line argument |
700 |
|
|
701 |
|
print $_; |
702 |
|
if ( $source ) { &do_eoc(); } |
703 |
|
print '%...............................................................'; |
704 |
|
|
705 |
|
# see comment above where these are originally set. |
706 |
|
#print "\\setlength{\\parskip}{\\oldparskip}"; |
707 |
|
#print "\\setlength{\\parindent}{\\oldparindent}"; |
708 |
|
#print "\\setlength{\\baselineskip}{\\oldbaselineskip}"; |
709 |
|
|
710 |
|
unless ( $opt_b ) { |
711 |
|
print "\\end{document}"; |
712 |
|
} |
713 |
|
|
714 |
|
|
715 |
#---------------------------------------------------------------------- |
#---------------------------------------------------------------------- |
716 |
|
|
717 |
sub CheckOpts |
sub begin_verbatim |
718 |
# Checks options against a given list. Outputs error message |
{ |
719 |
# for any invalid option. |
printf "\n{\\small \\begin{verbatim} "; |
720 |
# |
$verb = 1; |
721 |
# Usage: |
return 0; |
722 |
# $rc = &CheckOpts ( options, valid_reg_options, |
} |
723 |
# valid_sw_options, |
|
724 |
# quiet_mode ) |
sub end_verbatim |
725 |
# |
{ |
726 |
# character: options - options to be checked. (e.g. -df+x) The |
printf "\\end{verbatim} }"; |
727 |
# list must begin with a positive or |
$verb = 0; |
728 |
# negative sign. If no sign appears at the |
return 0; |
729 |
# beginning or by itself, then the argument |
} |
730 |
# is not recognized as a list of options. |
|
731 |
# character: valid_reg_options - list of valid regular options. |
sub CheckOpts |
732 |
# (i.e. options that are associated only |
{ |
733 |
# eith negative sign.) |
# Checks options against a given list. Outputs error message |
734 |
# character: valid_sw_options - list of valid switch options. |
# for any invalid option. |
735 |
# (i.e. options that can be associated with |
# |
736 |
# either a positive or negative sign. |
# Usage: |
737 |
# logical: quiet mode (optional) If true then print no error |
# $rc = &CheckOpts ( options, valid_reg_options, |
738 |
# messages. |
# valid_sw_options, |
739 |
# integer: rc - return code |
# quiet_mode ) |
740 |
# = -1 if the arguement, options, is |
# |
741 |
# not recognized as a list of options |
# character: options - options to be checked. (e.g. -df+x) The |
742 |
# = 0 if all options are valid. |
# list must begin with a positive or |
743 |
# > 0 for the number of invalid options. |
# negative sign. If no sign appears at the |
744 |
# |
# beginning or by itself, then the argument |
745 |
{ local($options, |
# is not recognized as a list of options. |
746 |
$valid_reg_options, |
# character: valid_reg_options - list of valid regular options. |
747 |
$valid_sw_options, |
# (i.e. options that are associated only |
748 |
|
# eith negative sign.) |
749 |
|
# character: valid_sw_options - list of valid switch options. |
750 |
|
# (i.e. options that can be associated with |
751 |
|
# either a positive or negative sign. |
752 |
|
# logical: quiet mode (optional) If true then print no error |
753 |
|
# messages. |
754 |
|
# integer: rc - return code |
755 |
|
# = -1 if the arguement, options, is |
756 |
|
# not recognized as a list of options |
757 |
|
# = 0 if all options are valid. |
758 |
|
# > 0 for the number of invalid options. |
759 |
|
|
760 |
|
local($options, |
761 |
|
$valid_reg_options, |
762 |
|
$valid_sw_options, |
763 |
$quiet_mode ) = @_; |
$quiet_mode ) = @_; |
764 |
|
|
765 |
if ( $options eq "+" || |
if ( $options eq "+" || |
766 |
$options eq "-" ) {return -1} |
$options eq "-" ) {return -1} |
767 |
|
|
768 |
local(@Options) = split( / */, $options ); |
local(@Options) = split( / */, $options ); |
769 |
if ( $Options[ $[ ] ne "-" && |
if ( $Options[ $[ ] ne "-" && |
|
$Options[ $[ ] ne "+" ) {return -1;} |
|
|
|
|
|
local($option, $option_sign, $valid_list, $pos); |
|
|
local($errs) = 0; |
|
|
foreach $option ( @Options ) { |
|
|
if ( $option eq "-" || |
|
|
$option eq "+" ) {$option_sign = $option;} |
|
|
else { |
|
|
if ( $option_sign eq "-" ) |
|
|
{ $valid_list = $valid_reg_options |
|
|
. $valid_sw_options; } |
|
|
else |
|
|
{ $valid_list = $valid_sw_options; } |
|
|
$pos = index ($valid_list,$option); |
|
|
if ( $pos < $[ && |
|
|
$quiet_mode ) { |
|
|
$errs++; |
|
|
print STDERR "Invalid option: $option_sign$option \n"; |
|
|
|
|
|
}# end if |
|
|
}# end if |
|
|
}# end foreach |
|
|
return $errs; |
|
|
|
|
|
}#end sub GetOpts |
|
|
|
|
|
sub GetOpts |
|
|
# Gets options. If an option is valid, then opt_[option] is |
|
|
# set to 0 or 1 as a side effect if the option is preceeded by |
|
|
# a positive or negative sign. |
|
|
# |
|
|
# Usage: |
|
|
# $rc = &GetOpts ( options, valid_options ) |
|
|
# |
|
|
# character: options - options to be checked. (e.g. -df+x) The |
|
|
# list must begin with a positive or |
|
|
# negative sign. If no sign appears at the |
|
|
# beginning or by itself, then the argument |
|
|
# is not recognized as a list of options. |
|
|
# character: valid_options - list of valid options (e.g. dfhx) |
|
|
# integer: rc - return code |
|
|
# = -1 if the arguement, options, is |
|
|
# not recognized as a list of options. |
|
|
# = 0 otherwise |
|
|
# |
|
|
{ local($options,$valid_options) = @_; |
|
|
|
|
|
if ( $options eq "+" || |
|
|
$options eq "-" ) {return -1} |
|
|
|
|
|
local(@Options) = split( / */, $options ); |
|
|
if ( $Options[ $[ ] ne "-" && |
|
770 |
$Options[ $[ ] ne "+" ) {return -1;} |
$Options[ $[ ] ne "+" ) {return -1;} |
771 |
|
|
772 |
|
local($option, $option_sign, $valid_list, $pos); |
773 |
|
local($errs) = 0; |
774 |
|
foreach $option ( @Options ) { |
775 |
|
if ( $option eq "-" || |
776 |
|
$option eq "+" ) {$option_sign = $option;} |
777 |
|
else { |
778 |
|
if ( $option_sign eq "-" ) { |
779 |
|
$valid_list = $valid_reg_options |
780 |
|
. $valid_sw_options; |
781 |
|
} |
782 |
|
else { |
783 |
|
$valid_list = $valid_sw_options; |
784 |
|
} |
785 |
|
$pos = index ($valid_list,$option); |
786 |
|
if ( $pos < $[ && |
787 |
|
$quiet_mode ) { |
788 |
|
$errs++; |
789 |
|
print STDERR "Invalid option: $option_sign$option \n"; |
790 |
|
|
791 |
|
} |
792 |
|
} |
793 |
|
} |
794 |
|
return $errs; |
795 |
|
} |
796 |
|
|
797 |
|
|
798 |
|
sub GetOpts |
799 |
|
{ |
800 |
|
# Gets options. If an option is valid, then opt_[option] is |
801 |
|
# set to 0 or 1 as a side effect if the option is preceeded by |
802 |
|
# a positive or negative sign. |
803 |
|
# |
804 |
|
# Usage: |
805 |
|
# $rc = &GetOpts ( options, valid_options ) |
806 |
|
# |
807 |
|
# character: options - options to be checked. (e.g. -df+x) The |
808 |
|
# list must begin with a positive or |
809 |
|
# negative sign. If no sign appears at the |
810 |
|
# beginning or by itself, then the argument |
811 |
|
# is not recognized as a list of options. |
812 |
|
# character: valid_options - list of valid options (e.g. dfhx) |
813 |
|
# integer: rc - return code |
814 |
|
# = -1 if the arguement, options, is |
815 |
|
# not recognized as a list of options. |
816 |
|
# = 0 otherwise |
817 |
|
|
818 |
local($option, $option_sign); |
local($options,$valid_options) = @_; |
819 |
|
|
820 |
foreach $option ( @Options ) { |
if ( $options eq "+" || |
821 |
|
$options eq "-" ) {return -1} |
822 |
|
|
823 |
|
local(@Options) = split( / */, $options ); |
824 |
|
if ( $Options[ $[ ] ne "-" && |
825 |
|
$Options[ $[ ] ne "+" ) {return -1;} |
826 |
|
|
827 |
|
local($option, $option_sign); |
828 |
|
|
829 |
|
foreach $option ( @Options ) { |
830 |
|
|
831 |
if ( $option eq "-" || |
if ( $option eq "-" || |
832 |
$option eq "+" ) { |
$option eq "+" ) { |
833 |
$option_sign = $option; } |
$option_sign = $option; } |
834 |
|
|
835 |
else { |
else { |
836 |
|
|
837 |
|
if ( index ($valid_options,$option) >= $[ ) { |
838 |
|
if ( $option_sign eq "-" ) {${"opt_$option"} = 1;} |
839 |
|
if ( $option_sign eq "+" ) {${"opt_$option"} = 0;}; |
840 |
|
|
841 |
|
} |
842 |
|
} |
843 |
|
} |
844 |
|
return 0; |
845 |
|
} |
846 |
|
|
847 |
|
|
848 |
|
sub SetOpt |
849 |
|
{ |
850 |
|
# Sets option flags. For the last input option that is in a |
851 |
|
# list, the flag opt_[option] is set to 1 as a side effect. |
852 |
|
# For all other options in the list, opt_[option] is set to 0. |
853 |
|
# |
854 |
|
# Usage: |
855 |
|
# $rc = &SetOpt ( options, valid_options ) |
856 |
|
# |
857 |
|
# character: options - options to be checked. (e.g. -df+x) The |
858 |
|
# list must begin with a positive or |
859 |
|
# negative sign. If no sign appears at the |
860 |
|
# beginning or by itself, then the argument |
861 |
|
# is not recognized as a list of options. |
862 |
|
# character: valid_options - list of valid options (e.g. def ) |
863 |
|
# integer: rc - return code |
864 |
|
# = -1 if the arguement, options, is |
865 |
|
# not recognized as a list of options. |
866 |
|
# = 0 otherwise |
867 |
|
# Note: For the examples provided for the input arguments, |
868 |
|
# $opt_d = 0, $opt_e = 0, and $opt_f = 1, since the |
869 |
|
# input option, -f, was the last in the argument, |
870 |
|
# option. |
871 |
|
|
872 |
if ( index ($valid_options,$option) >= $[ ) { |
local($options,$valid_options) = @_; |
873 |
if ( $option_sign eq "-" ) {${"opt_$option"} = 1;} |
|
874 |
if ( $option_sign eq "+" ) {${"opt_$option"} = 0;}; |
if ( $options eq "+" || |
875 |
|
$options eq "-" ) {return -1} |
876 |
}# end if |
|
877 |
}# end if |
local(@Options) = split( / */, $options ); |
878 |
}# end foreach |
local(@ValidOptions) = split( / */, $valid_options ); |
879 |
|
if ( $Options[ $[ ] ne "-" && |
880 |
return 0; |
$Options[ $[ ] ne "+" ) {return -1;} |
881 |
}#end sub GetOpts |
|
882 |
|
local($option, $option_sign); |
883 |
sub SetOpt |
|
884 |
# Sets option flags. For the last input option that is in a |
foreach $option ( @Options ) { |
|
# list, the flag opt_[option] is set to 1 as a side effect. |
|
|
# For all other options in the list, opt_[option] is set to 0. |
|
|
# |
|
|
# Usage: |
|
|
# $rc = &SetOpt ( options, valid_options ) |
|
|
# |
|
|
# character: options - options to be checked. (e.g. -df+x) The |
|
|
# list must begin with a positive or |
|
|
# negative sign. If no sign appears at the |
|
|
# beginning or by itself, then the argument |
|
|
# is not recognized as a list of options. |
|
|
# character: valid_options - list of valid options (e.g. def ) |
|
|
# integer: rc - return code |
|
|
# = -1 if the arguement, options, is |
|
|
# not recognized as a list of options. |
|
|
# = 0 otherwise |
|
|
# Note: For the examples provided for the input arguments, |
|
|
# $opt_d = 0, $opt_e = 0, and $opt_f = 1, since the |
|
|
# input option, -f, was the last in the argument, |
|
|
# option. |
|
|
# |
|
|
{ local($options,$valid_options) = @_; |
|
|
|
|
|
if ( $options eq "+" || |
|
|
$options eq "-" ) {return -1} |
|
|
|
|
|
local(@Options) = split( / */, $options ); |
|
|
local(@ValidOptions) = split( / */, $valid_options ); |
|
|
if ( $Options[ $[ ] ne "-" && |
|
|
$Options[ $[ ] ne "+" ) {return -1;} |
|
|
|
|
|
local($option, $option_sign); |
|
|
|
|
|
foreach $option ( @Options ) { |
|
885 |
if ( $option ne "-" && |
if ( $option ne "-" && |
886 |
$option ne "+" ) { |
$option ne "+" ) { |
887 |
|
|
888 |
|
if ( index ($valid_options,$option) >= $[ ) { |
889 |
|
foreach $valid_option (@ValidOptions ) { |
890 |
|
${"opt_$valid_option"} = 0; |
891 |
|
|
892 |
|
} |
893 |
|
${"opt_$option"} = 1; |
894 |
|
} |
895 |
|
} |
896 |
|
} |
897 |
|
return 0; |
898 |
|
} |
899 |
|
|
|
if ( index ($valid_options,$option) >= $[ ) { |
|
|
foreach $valid_option (@ValidOptions ) { |
|
|
${"opt_$valid_option"} = 0; |
|
|
|
|
|
}# end foreach |
|
|
${"opt_$option"} = 1; |
|
|
}# end if |
|
|
}# end if |
|
|
}# end foreach |
|
|
|
|
|
return 0; |
|
|
}#end sub SetOpt |
|
|
|
|
|
sub print_help { |
|
900 |
|
|
901 |
|
sub print_help |
902 |
|
{ |
903 |
print "Usage: protex [-hbACFS] [+-nlsxf] [src_file(s)]"; |
print "Usage: protex [-hbACFS] [+-nlsxf] [src_file(s)]"; |
904 |
print " "; |
print " "; |
905 |
print " Options:"; |
print " Options:"; |
921 |
print " Each of the remaining options effects only the input from the"; |
print " Each of the remaining options effects only the input from the"; |
922 |
print " files listed after the option and prior to any overriding"; |
print " files listed after the option and prior to any overriding"; |
923 |
print " option. The plus sign turns off the option."; |
print " option. The plus sign turns off the option."; |
924 |
}# end sub print_help |
} |
|
|
|
|
sub print_notice { |
|
925 |
|
|
926 |
|
sub print_notice |
927 |
|
{ |
928 |
print "% **** IMPORTANT NOTICE *****" ; |
print "% **** IMPORTANT NOTICE *****" ; |
929 |
print "% This LaTeX file has been automatically produced by ProTeX v. 1.1"; |
print "% This LaTeX file has been automatically produced by ProTeX v. 1.1"; |
930 |
print "% Any changes made to this file will likely be lost next time"; |
print "% Any changes made to this file will likely be lost next time"; |
931 |
print "% this file is regenerated from its source. Send questions "; |
print "% this file is regenerated from its source. Send questions "; |
932 |
print "% to Arlindo da Silva, dasilva\@gsfc.nasa.gov"; |
print "% to Arlindo da Silva, dasilva\@gsfc.nasa.gov"; |
933 |
print " "; |
print " "; |
934 |
|
} |
935 |
|
|
936 |
}# sub print_notice |
sub print_preamble |
937 |
|
{ |
938 |
sub print_preamble { |
unless ( $opt_b ) { |
939 |
|
print "%------------------------ PREAMBLE --------------------------"; |
940 |
unless ( $opt_b ) { |
print "\\documentclass[11pt]{article}"; |
941 |
print "%------------------------ PREAMBLE --------------------------"; |
print "\\usepackage{amsmath}"; |
942 |
print "\\documentclass[11pt]{article}"; |
print "\\usepackage{epsfig}"; |
943 |
print "\\usepackage{amsmath}"; |
print "\\usepackage{hangcaption}"; |
944 |
print "\\usepackage{epsfig}"; |
print "\\textheight 9in"; |
945 |
print "\\usepackage{hangcaption}"; |
print "\\topmargin 0pt"; |
946 |
print "\\textheight 9in"; |
print "\\headsep 1cm"; |
947 |
print "\\topmargin 0pt"; |
print "\\headheight 0pt"; |
948 |
print "\\headsep 1cm"; |
print "\\textwidth 6in"; |
949 |
print "\\headheight 0pt"; |
print "\\oddsidemargin 0in"; |
950 |
print "\\textwidth 6in"; |
print "\\evensidemargin 0in"; |
951 |
print "\\oddsidemargin 0in"; |
print "\\marginparpush 0pt"; |
952 |
print "\\evensidemargin 0in"; |
print "\\pagestyle{myheadings}"; |
953 |
print "\\marginparpush 0pt"; |
print "\\markboth{}{}"; |
954 |
print "\\pagestyle{myheadings}"; |
print "%-------------------------------------------------------------"; |
955 |
print "\\markboth{}{}"; |
} |
|
print "%-------------------------------------------------------------"; |
|
|
}# end unless |
|
956 |
|
|
957 |
# in your main document before you include any protex-generated files |
# in your main document before you include any protex-generated files |
958 |
# for the first time, if you define these three variables as length |
# for the first time, if you define these three variables as length |
975 |
print "\\setlength{\\parindent}{0pt}"; |
print "\\setlength{\\parindent}{0pt}"; |
976 |
#print "\\setlength{\\oldbaselineskip}{\\baselineskip}"; |
#print "\\setlength{\\oldbaselineskip}{\\baselineskip}"; |
977 |
print "\\setlength{\\baselineskip}{11pt}"; |
print "\\setlength{\\baselineskip}{11pt}"; |
978 |
|
} |
979 |
|
|
|
}# end sub print_preamble |
|
|
|
|
|
sub print_macros { |
|
980 |
|
|
981 |
|
sub print_macros |
982 |
|
{ |
983 |
print " "; |
print " "; |
984 |
print "%--------------------- SHORT-HAND MACROS ----------------------"; |
print "%--------------------- SHORT-HAND MACROS ----------------------"; |
985 |
print "\\def\\bv{\\begin{verbatim}}"; |
print "\\def\\bv{\\begin{verbatim}}"; |
1004 |
print "\\def\\diag{\\mathop{\\rm diag}}"; |
print "\\def\\diag{\\mathop{\\rm diag}}"; |
1005 |
print "\\def\\tr{\\mathop{\\rm tr}}"; |
print "\\def\\tr{\\mathop{\\rm tr}}"; |
1006 |
print "%-------------------------------------------------------------"; |
print "%-------------------------------------------------------------"; |
1007 |
|
} |
1008 |
|
|
|
}# end sub print_macros |
|
1009 |
|
|
1010 |
sub do_beg { |
sub do_beg |
1011 |
|
{ |
1012 |
unless ( $opt_b ) { |
unless ( $opt_b ) { |
1013 |
if ( $begdoc == 0 ) { |
if ( $begdoc == 0 ) { |
1014 |
if ( $tpage ) { |
if ( $tpage ) { |
1015 |
print "\\title{@title}"; |
print "\\title{@title}"; |
1016 |
print "\\author{{\\sc @author}\\\\ {\\em @affiliation}}"; |
print "\\author{{\\sc @author}\\\\ {\\em @affiliation}}"; |
1017 |
print "\\date{@date}"; |
print "\\date{@date}"; |
1018 |
} |
} |
1019 |
print "\\begin{document}"; |
print "\\begin{document}"; |
1020 |
if ( $tpage ) { |
if ( $tpage ) { |
1021 |
print "\\maketitle"; |
print "\\maketitle"; |
1022 |
} |
} |
1023 |
print "\\tableofcontents"; |
print "\\tableofcontents"; |
1024 |
print "\\newpage"; |
print "\\newpage"; |
1025 |
$begdoc = 1; |
$begdoc = 1; |
1026 |
} |
} |
1027 |
} |
} |
1028 |
}# end sub do_beg |
} |
1029 |
|
|
1030 |
sub do_eoc { |
sub do_eoc |
1031 |
print ' '; |
{ |
1032 |
if ($verb) { |
print ' '; |
1033 |
print "\\end{verbatim}"; |
if ($verb) { |
1034 |
$verb = 0; |
&end_verbatim(); |
1035 |
} |
} |
1036 |
$source = 0; |
$source = 0; |
1037 |
}# end sub do_eoc |
} |
1038 |
|
|
|
sub set_missing { |
|
|
|
|
|
$have_name = 0; # have routine name? |
|
|
$have_desc = 0; # have description? |
|
|
$have_intf = 0; # have interface? |
|
|
$have_hist = 0; # have revision history? |
|
|
$name_is = "UNKNOWN"; |
|
|
|
|
|
}# end sub set_missing |
|
|
|
|
|
|
|
|
sub check_if_all_there { |
|
|
|
|
|
$have_name || |
|
|
die "ProTeX: invalid prologue, missing !ROUTINE: or !IROUTINE: in <$name_is>"; |
|
|
|
|
|
$have_desc || |
|
|
die "ProTeX: invalid prologue, missing !DESCRIPTION: in <$name_is>"; |
|
|
|
|
|
$have_intf || |
|
|
die "ProTeX: invalid prologue, missing !INTERFACE: in <$name_is>"; |
|
|
|
|
|
$have_hist || |
|
|
die "ProTeX: invalid prologue, missing !REVISION HISTORY: in <$name_is>"; |
|
1039 |
|
|
1040 |
}# end sub check_if_all_there |
sub set_missing |
1041 |
|
{ |
1042 |
|
$have_name = 0; # have routine name? |
1043 |
|
$have_desc = 0; # have description? |
1044 |
|
$have_intf = 0; # have interface? |
1045 |
|
$have_hist = 0; # have revision history? |
1046 |
|
$name_is = "UNKNOWN"; |
1047 |
|
} |
1048 |
|
|
1049 |
|
sub check_if_all_there |
1050 |
|
{ |
1051 |
|
$have_name || |
1052 |
|
die "ProTeX: invalid prologue, missing !ROUTINE: or !IROUTINE: in <$name_is>"; |
1053 |
|
|
1054 |
|
$have_desc || |
1055 |
|
die "ProTeX: invalid prologue, missing !DESCRIPTION: in <$name_is>"; |
1056 |
|
|
1057 |
|
$have_intf || |
1058 |
|
die "ProTeX: invalid prologue, missing !INTERFACE: in <$name_is>"; |
1059 |
|
|
1060 |
|
$have_hist || |
1061 |
|
die "ProTeX: invalid prologue, missing !REVISION HISTORY: in <$name_is>"; |
1062 |
|
} |