|
1 #!/usr/local/dist/DIR/perl4/bin/perl |
|
2 'di'; |
|
3 'ig00'; |
|
4 ############################################### |
|
5 # Title: Tools/8bit/perl/generators/gen-isa2latex |
|
6 # ID: $Id$ |
|
7 # Author: Franz Regensburger |
|
8 # Copyright 1996 TU Muenchen |
|
9 # |
|
10 # configures the converter isa2latex with user provided settings |
|
11 # |
|
12 # Franz Regensburger <regensbu@informatik.tu-muenchen.de> 8.3.95 |
|
13 # |
|
14 ############################################### |
|
15 |
|
16 # I like to see the output as it happens (flushed output) |
|
17 |
|
18 $| = 1; |
|
19 |
|
20 # cash current working directory |
|
21 require "pwd.pl"; |
|
22 &initpwd; |
|
23 |
|
24 $initial_dir = $ENV{'PWD'}; |
|
25 |
|
26 ######################## |
|
27 # comand line processing |
|
28 # processes all known switches and ingnores others. |
|
29 # first non-switch which is the name of a text file is |
|
30 # interpreted as name of configuration file. |
|
31 # |
|
32 |
|
33 # initialize |
|
34 $config_file=""; |
|
35 $do_debug = 0; |
|
36 $do_ddebug = 0; |
|
37 #$install_source = 0; |
|
38 #$cleanup = 0; |
|
39 |
|
40 while (@ARGV){ |
|
41 $cur_arg = shift @ARGV; |
|
42 if ($cur_arg eq '-d') {$do_debug = 1;} |
|
43 elsif ($cur_arg eq '-dd') {$do_debug = 1; $do_ddebug = 1;} |
|
44 # elsif ($cur_arg eq '-c') {$cleanup = 1;} |
|
45 # elsif ($cur_arg eq '-s') {$install_source = 1;} |
|
46 elsif ((-T $cur_arg) && !$config_file) {$config_file = $cur_arg;} |
|
47 } |
|
48 |
|
49 # complain if no configuration file is found |
|
50 |
|
51 if ($config_file eq "") { |
|
52 print "\nno configuration file suplied or argument is not a text file\n\n"; |
|
53 print "usage gen-isa2latex [-d -dd ] configfile\n", |
|
54 # print "usage gen-isa2latex [-d -dd -s -c ] configfile\n", |
|
55 "options must be separated by blanks!"; |
|
56 die "\n"; |
|
57 } |
|
58 |
|
59 print "debug mode is on\n" if $do_debug; |
|
60 print "double debug mode is on\n" if $do_ddebug; |
|
61 print "name of configuration file is $config_file\n" if $do_debug; |
|
62 |
|
63 ######################## |
|
64 # open the configuration file |
|
65 |
|
66 open(CONFIG,$config_file) || die "can't open $config_file: $!\n"; |
|
67 print "opened configuration file,\nprocessing\n" if $do_debug; |
|
68 |
|
69 ######################## |
|
70 # search for general setup variables |
|
71 |
|
72 print "\ngeneral setup\n" if $do_debug; |
|
73 |
|
74 ######################## |
|
75 # search for CONV_SOURCE_DIR |
|
76 |
|
77 $conv_source_dir = |
|
78 &look_for_value('^\s*CONV_SOURCE_DIR\s*"(.*)"',"CONV_SOURCE_DIR"); |
|
79 |
|
80 if ($conv_source_dir eq "") { |
|
81 die "\ncan't find CONV_SOURCE_DIR in configuration file\n";} |
|
82 |
|
83 if (! (-d $conv_source_dir)){ |
|
84 die "\nCONV_SOURCE_DIR is not a directory\n";} |
|
85 |
|
86 if (! (-r $conv_source_dir)){ |
|
87 die "\nno read permission for directory CONV_SOURCE_DIR \n";} |
|
88 |
|
89 #if ($install_source && !(-w $conv_source_dir)){ |
|
90 # die "\noption -s used but no write permission for directory CONV_SOURCE_DIR\n";} |
|
91 |
|
92 |
|
93 ######################## |
|
94 # search for CONV_TEMP_DIR |
|
95 |
|
96 #$conv_temp_dir = &look_for_value('^\s*CONV_TEMP_DIR\s*"(.*)"',"CONV_TEMP_DIR"); |
|
97 |
|
98 #if ($conv_temp_dir eq "") { |
|
99 # die "\ncan't find CONV_TEMP_DIR in configuration file\n";} |
|
100 |
|
101 #if (! (-d $conv_temp_dir)){ |
|
102 # die "\nCONV_TEMP_DIR is not a directory\n";} |
|
103 |
|
104 #if (!(-r $conv_temp_dir && -w $conv_temp_dir && -x $conv_temp_dir)){ |
|
105 # die "\nneed read, write and execute permission for directory CONV_TEMP_DIR\n";} |
|
106 |
|
107 |
|
108 ######################## |
|
109 # search for CONV_SUB_DIR |
|
110 |
|
111 #$conv_sub_dir = &look_for_value('^\s*CONV_SUB_DIR\s*"(.*)"',"CONV_SUB_DIR"); |
|
112 |
|
113 #if ($conv_sub_dir eq "") { |
|
114 # die "\ncan't find CONV_SUB_DIR in configuration file\n";} |
|
115 |
|
116 ######################## |
|
117 # process switsch -c for cleanup |
|
118 |
|
119 #if ($cleanup) { # cleanup $conv_sub_dir |
|
120 # chdir $conv_temp_dir || die "can't cd to $conv_temp_dir: $!\n"; |
|
121 # $status = system("rm -rf $conv_sub_dir/*; rmdir $conv_sub_dir"); |
|
122 # if ($status) {die "can't remove subdirectory $conv_sub_dir: $!\n";} |
|
123 # print "cleanup done, exit configuration script\n"; |
|
124 # exit(0); |
|
125 #} |
|
126 |
|
127 |
|
128 ######################## |
|
129 # configuration of LOW_TABLE |
|
130 print "\nsetup for LOW_TABLE\n" if $do_debug; |
|
131 |
|
132 ######################## |
|
133 # search for START_LOW_TABLE |
|
134 |
|
135 $start_low_table = |
|
136 &look_for_value('^\s*START_LOW_TABLE\s*"(\d+)"',"START_LOW_TABLE"); |
|
137 |
|
138 if ($start_low_table eq "") { |
|
139 die "\ncan't find START_LOW_TABLE in configuration file\n";} |
|
140 |
|
141 if ($start_low_table < 32 || 127 < $start_low_table) { |
|
142 die "\nSTART_LOW_TABLE not in range 32 .. 127\n";} |
|
143 |
|
144 |
|
145 ######################## |
|
146 # search for BEGIN_LOW_TABLE |
|
147 |
|
148 $found = &look_for_label('^\s*BEGIN_LOW_TABL(E)',"BEGIN_LOW_TABLE"); |
|
149 |
|
150 if ($found eq "") { |
|
151 die "\ncan't find BEGIN_LOW_TABLE in configuration file\n";} |
|
152 |
|
153 ######################## |
|
154 # read the LOW_TABLE |
|
155 |
|
156 $index = 0; |
|
157 $found = 0; |
|
158 $end_low_table = 0; |
|
159 $pattern = '^>\s*"([^"]*)"'; |
|
160 |
|
161 while (<CONFIG> ){ |
|
162 if (/^\s*END_LOW_TABLE/){ |
|
163 print "line $.: END_LOW_TABLE found\n" if $do_debug; |
|
164 $found = 1; |
|
165 $end_low_table = $start_low_table + $index - 1; |
|
166 last;} |
|
167 elsif (($temp) = /$pattern/){ |
|
168 $low_table[$index]= &double_bs($temp); |
|
169 # backslashes are duplicated |
|
170 print "line $.: \"$low_table[$index]\"\n" if $do_ddebug; |
|
171 $index +=1; |
|
172 } |
|
173 } |
|
174 if (!$found){ |
|
175 die "\ncan't find END_LOW_TABLE in configuration file\n";} |
|
176 |
|
177 if ($end_low_table < $start_low_table || 127 < $end_low_table){ |
|
178 die "\nEND_LOW_TABLE $end_low_table not in range $start_low_table .. 127\n";} |
|
179 else {print |
|
180 "computed index for END_LOW_TABLE is $end_low_table\n" if $do_debug;} |
|
181 |
|
182 ######################## |
|
183 # configuration of HI_TABLE |
|
184 print "\nsetup for HI_TABLE\n" if $do_debug; |
|
185 |
|
186 ######################## |
|
187 # search for START_HI_TABLE |
|
188 # |
|
189 $start_hi_table = |
|
190 &look_for_value('^\s*START_HI_TABLE\s*"(\d+)"',"START_HI_TABLE"); |
|
191 |
|
192 if ($start_hi_table eq "") { |
|
193 die "\ncan't find START_HI_TABLE in configuration file\n";} |
|
194 |
|
195 if ($start_hi_table < 128 || 255 < $start_hi_table) { |
|
196 die "\nSTART_HI_TABLE not in range 128 .. 255\n";} |
|
197 |
|
198 ######################## |
|
199 # search for BEGIN_HI_TABLE |
|
200 |
|
201 $found = &look_for_label('^\s*BEGIN_HI_TABL(E)',"BEGIN_HI_TABLE"); |
|
202 |
|
203 if ($found eq "") { |
|
204 die "\ncan't find BEGIN_HI_TABLE in configuration file\n";} |
|
205 |
|
206 ######################## |
|
207 # read the HI_TABLE |
|
208 |
|
209 $index = 0; |
|
210 $max_hi_len1 = 0; # for pretty printing |
|
211 $max_hi_len2 = 0; # for pretty printing |
|
212 $max_hi_len3 = 0; # for pretty printing |
|
213 $found = 0; |
|
214 $end_hi_table = 0; |
|
215 $pattern = '^>\s*"([^"]*)"\s*"([^"]*)"\s*"([^"]*)"'; |
|
216 |
|
217 while (<CONFIG> ){ |
|
218 if (/^\s*END_HI_TABLE/){ |
|
219 print "line $.: END_HI_TABLE found\n" if $do_debug; |
|
220 $found = 1; |
|
221 $end_hi_table = $start_hi_table + $index - 1; |
|
222 last;} |
|
223 elsif (($temp_1,$temp_2,$temp_3) = /$pattern/){ |
|
224 $temp1 = $temp_1 ; |
|
225 $temp2 = &double_bs($temp_2); |
|
226 $temp3 = &double_bs($temp_3); |
|
227 $max_hi_len1 = length($temp1) if $max_hi_len1 < length($temp1); |
|
228 $max_hi_len2 = length($temp2) if $max_hi_len2 < length($temp2); |
|
229 $max_hi_len3 = length($temp3) if $max_hi_len3 < length($temp3); |
|
230 $hi_table[$index]= join('"',$temp1, $temp2, $temp3); |
|
231 # the " as seperator is perfect since it cannot occur inside the strings |
|
232 # backslashes are duplicated |
|
233 printf "line $.: \"%s\" \t\t \"%s\" \t\t \"%s\"\n", |
|
234 $temp1, $temp2, $temp3 if $do_ddebug; |
|
235 $index +=1; |
|
236 } |
|
237 } |
|
238 |
|
239 if (!$found){ |
|
240 die "\ncan't find END_HI_TABLE in configuration file\n";} |
|
241 |
|
242 if ($end_hi_table < $start_hi_table || 255 < $end_hi_table ){ |
|
243 die "\nEND_HI_TABLE $end_hi_table not in range $start_low_table .. 255\n";} |
|
244 else |
|
245 {print "computed index for END_HI_TABLE is $end_hi_table\n" if $do_debug; } |
|
246 |
|
247 |
|
248 |
|
249 ######################## |
|
250 # configuration of SEQ_TABLE |
|
251 print "\nsetup for SEQ_TABLE\n" if $do_debug; |
|
252 |
|
253 ######################## |
|
254 # search for BEGIN_SEQ_TABLE |
|
255 |
|
256 $found = &look_for_label('^\s*BEGIN_SEQ_TABL(E)',"BEGIN_SEQ_TABLE"); |
|
257 |
|
258 if ($found eq "") { |
|
259 die "\ncan't find BEGIN_SEQ_TABLE in configuration file\n";} |
|
260 |
|
261 |
|
262 ######################## |
|
263 # read the SEQ_TABLE |
|
264 |
|
265 $index = 0; |
|
266 $max_seq_len1 = 0; # for pretty printing |
|
267 $max_seq_len2 = 0; # for pretty printing |
|
268 $max_seq_len3 = 0; # for pretty printing |
|
269 $max_seq_len4 = 0; # for pretty printing |
|
270 $found = 0; |
|
271 $seq_table = 0; |
|
272 $pattern = '^>\s*"([^"]*)"\s*"([^"]*)"\s*"([^"]*)"\s*"([^"]*)"'; |
|
273 |
|
274 while (<CONFIG> ){ |
|
275 if (/^\s*END_SEQ_TABLE/){ |
|
276 print "line $.: END_SEQ_TABLE found\n" if $do_debug; |
|
277 $found = 1; |
|
278 $seq_table = $index; |
|
279 last;} |
|
280 elsif (($temp_1,$temp_2,$temp_3,$temp_4) = /$pattern/){ |
|
281 $temp1 = $temp_1 ; |
|
282 $temp2 = $temp_2 ; |
|
283 $temp3 = &double_bs($temp_3) ; |
|
284 $temp4 = &double_bs($temp_4); |
|
285 $max_seq_len1 = length($temp1) if $max_seq_len1 < length($temp1); |
|
286 $max_seq_len2 = length($temp2) if $max_seq_len2 < length($temp2); |
|
287 $max_seq_len3 = length($temp4) if $max_seq_len3 < length($temp3); |
|
288 $max_seq_len4 = length($temp3) if $max_seq_len4 < length($temp4); |
|
289 $seq_table[$index]= join('"',$temp1, $temp2, $temp3, $temp4); |
|
290 # the " as seperator is perfect since it cannot occur inside the strings |
|
291 # backslashes are only expanded in the latex replacement |
|
292 printf "line $.: \"%s\" \t\t \"%s\" \t\t \"%s\" \t\t \"%s\"\n", |
|
293 $temp1, $temp2, $temp3, $temp4 if $do_ddebug; |
|
294 $index +=1; |
|
295 } |
|
296 } |
|
297 |
|
298 if ($found == 0) { |
|
299 die "\ncan't find END_SEQ_TABLE in configuration file\n";} |
|
300 else {print "computed index for SEQ_TABLE is $seq_table\n" if $do_debug; } |
|
301 |
|
302 |
|
303 ######################## |
|
304 # we reached the end of the configuration file |
|
305 |
|
306 print "\nprocessing of configuration file completed\n" if $do_debug; |
|
307 |
|
308 ######################## |
|
309 # close the handle for config file |
|
310 close(CONFIG); |
|
311 print "closed configuration file\n" if $do_debug; |
|
312 |
|
313 ####################################################################### |
|
314 # copy sources and modify them |
|
315 ####################################################################### |
|
316 |
|
317 ######################## |
|
318 # change to temporary directory, |
|
319 # make subdir and copy sources |
|
320 # change to subdir |
|
321 |
|
322 #print "\ncopying sources\n" if $do_debug; |
|
323 |
|
324 #chdir $conv_temp_dir || die "can't cd to $conv_temp_dir: $!\n"; |
|
325 |
|
326 # cleanup if directory exists |
|
327 |
|
328 #if (-d $conv_sub_dir){ # directory exists |
|
329 # $status = system("rm -rf $conv_sub_dir/*; rmdir $conv_sub_dir"); |
|
330 # if ($status) {die "can't remove subdirectory $conv_sub_dir: $!\n";} |
|
331 #} |
|
332 |
|
333 # make the new sub dir |
|
334 |
|
335 #mkdir($conv_sub_dir,0755) || die "can't create subdirectory $conv_sub_dir: $!\n"; |
|
336 |
|
337 #$status = system("cp -r $conv_source_dir/* $conv_sub_dir") ; |
|
338 #if ($status) { die "can't copy files from CONV_SOURCE_DIR to CONV_SUB_DIR: $!\n";} |
|
339 |
|
340 #chdir $conv_sub_dir || die "can't cd to $conv_sub_dir: $!\n"; |
|
341 chdir $conv_source_dir || die "can't cd to $conv_source_dir: $!\n"; |
|
342 |
|
343 print "\nconfiguring sources\n" if $do_debug; |
|
344 |
|
345 ######################## |
|
346 # configure conv-defs.h |
|
347 # |
|
348 |
|
349 $filename = "conv-defs.h"; |
|
350 |
|
351 print "\nconfiguring $filename\n" if $do_debug; |
|
352 |
|
353 open(INFILE ,$filename) || die "can't open $filename in CONV_SOURCE_DIR: $!\n"; |
|
354 print "opened $filename for reading\n" if $do_ddebug; |
|
355 open(OUTFILE,">tmp.txt") || die "can't open temporary file tmp.txt: $!\n"; |
|
356 print "opened tmp.txt for writing\n" if $do_ddebug; |
|
357 |
|
358 $found = &replicate_until('^\s*\/\*\s*BEGIN\s*gen-isa2late(x)','BEGIN gen-isa2latex'); |
|
359 if ($found eq "") { |
|
360 die "\ncan't find BEGIN gen-isa2latex\n";} |
|
361 |
|
362 ## replace |
|
363 printf(OUTFILE "%s\n", "/* BEGIN gen-isa2latex */"); |
|
364 printf(OUTFILE "#define START_LOW_TABLE %s\n", $start_low_table); |
|
365 printf(OUTFILE "#define END_LOW_TABLE %s\n", $end_low_table); |
|
366 printf(OUTFILE "#define START_HI_TABLE %s\n", $start_hi_table); |
|
367 printf(OUTFILE "#define END_HI_TABLE %s\n", $end_hi_table); |
|
368 printf(OUTFILE "#define SEQ_TABLE %s\n", $seq_table); |
|
369 printf(OUTFILE "%s\n", "/* END gen-isa2latex */"); |
|
370 |
|
371 $found = &skip_until('^\s*\/\*\s*END\s*gen-isa2late(x)','END gen-isa2latex'); |
|
372 if ($found eq "") { |
|
373 die "\ncan't find END gen-isa2latex\n";} |
|
374 |
|
375 ## the rest |
|
376 while (<INFILE> ){printf(OUTFILE "%s",$_);} |
|
377 |
|
378 close(INFILE); |
|
379 close(OUTFILE); |
|
380 print "closed $filename and tmp.txt\n" if $do_ddebug; |
|
381 |
|
382 $status = system("cp tmp.txt $filename") ; |
|
383 if ($status) { die "can't copy tmp.txt to $filename: $!\n";} |
|
384 |
|
385 ######################## |
|
386 # configure conv-tables.h |
|
387 # |
|
388 |
|
389 $filename = "conv-tables.h"; |
|
390 |
|
391 print "\nconfiguring $filename\n" if $do_debug; |
|
392 |
|
393 open(INFILE ,$filename) || die "can't open $filename in CONV_SOURCE_DIR: $!\n"; |
|
394 print "opened $filename for reading\n" if $do_ddebug; |
|
395 open(OUTFILE,">tmp.txt") || die "can't open temporary file tmp.txt: $!\n"; |
|
396 print "opened tmp.txt for writing\n" if $do_ddebug; |
|
397 |
|
398 ### LOW TABLE |
|
399 $found = &replicate_until('^\s*\/\*\s*BEGIN_OF_LOW_TABL(E)','BEGIN_OF_LOW_TABLE'); |
|
400 if ($found eq "") { |
|
401 die "\ncan't find BEGIN_OF_LOW_TABLE\n";} |
|
402 |
|
403 ## replace |
|
404 printf(OUTFILE "%s\n", "/* BEGIN_OF_LOW_TABLE */"); |
|
405 printf(OUTFILE "%s\n", |
|
406 "char *translationTableLow[END_LOW_TABLE - START_LOW_TABLE + 1] = {"); |
|
407 $index = $start_low_table; |
|
408 $sep = ",\n"; |
|
409 while ($index <= $end_low_table) { |
|
410 $sep = "\n" if $index == $end_low_table; |
|
411 printf(OUTFILE " \"%s\"".$sep, $low_table[$index - $start_low_table]); |
|
412 $index++; |
|
413 } |
|
414 printf(OUTFILE "%s\n","};"); |
|
415 printf(OUTFILE "%s\n", "/* END_OF_LOW_TABLE */"); |
|
416 |
|
417 $found = &skip_until('^\s*\/\*\s*END_OF_LOW_TABL(E)','END_OF_LOW_TABLE'); |
|
418 if ($found eq "") { |
|
419 die "\ncan't find END_OF_LOW_TABLE\n";} |
|
420 |
|
421 ### HI TABLE |
|
422 $found = &replicate_until('^\s*\/\*\s*BEGIN_OF_HI_TABL(E)','BEGIN_OF_HI_TABLE'); |
|
423 if ($found eq "") { |
|
424 die "\ncan't find BEGIN_OF_HI_TABLE\n";} |
|
425 |
|
426 ## replace |
|
427 printf(OUTFILE "%s\n", "/* BEGIN_OF_HI_TABLE */"); |
|
428 printf(OUTFILE "%s\n", |
|
429 "char *translationTableHi[END_HI_TABLE - START_HI_TABLE + 1][2] = {"); |
|
430 |
|
431 $index = $start_hi_table; |
|
432 $sep = ",\n"; |
|
433 while ($index <= $end_hi_table) { |
|
434 $sep = "\n" if $index == $end_hi_table; |
|
435 ($temp1,$temp2,$temp3) = split(/\"/,$hi_table[$index - $start_hi_table]); |
|
436 printf(OUTFILE " {%-".($max_hi_len2+3)."s,%s}".$sep, |
|
437 "\"".$temp2."\"","\"".$temp3."\""); |
|
438 $index++; |
|
439 } |
|
440 printf(OUTFILE "%s\n","};"); |
|
441 printf(OUTFILE "%s\n", "/* END_OF_HI_TABLE */"); |
|
442 |
|
443 $found = &skip_until('^\s*\/\*\s*END_OF_HI_TABL(E)','END_OF_HI_TABLE'); |
|
444 if ($found eq "") { |
|
445 die "\ncan't find END_OF_HI_TABLE\n";} |
|
446 |
|
447 ### SEQ TABLE |
|
448 $found = &replicate_until('^\s*\/\*\s*BEGIN_OF_SEQ_TABL(E)','BEGIN_OF_SEQ_TABLE'); |
|
449 if ($found eq "") { |
|
450 die "\ncan't find BEGIN_OF_SEQ_TABLE\n";} |
|
451 |
|
452 ## replace |
|
453 printf(OUTFILE "%s\n", "/* BEGIN_OF_SEQ_TABLE */"); |
|
454 printf(OUTFILE "%s\n", |
|
455 "char *translationTableSeq[SEQ_TABLE][2] = {"); |
|
456 |
|
457 $index = 0; |
|
458 $sep = ",\n"; |
|
459 while ($index <= $seq_table - 1) { |
|
460 $sep = "\n" if $index == $seq_table - 1; |
|
461 ($temp1,$temp2,$temp3,$temp4) = split(/\"/,$seq_table[$index]); |
|
462 printf(OUTFILE " {%-".($max_seq_len3+3)."s,%s}".$sep, |
|
463 "\"".$temp3."\"","\"".$temp4."\""); |
|
464 $index++; |
|
465 } |
|
466 printf(OUTFILE "%s\n","};"); |
|
467 printf(OUTFILE "%s\n", "/* END_OF_SEQ_TABLE */"); |
|
468 |
|
469 $found = &skip_until('^\s*\/\*\s*END_OF_SEQ_TABL(E)','END_OF_SEQ_TABLE'); |
|
470 if ($found eq "") { |
|
471 die "\ncan't find END_OF_SEQ_TABLE\n";} |
|
472 ## the rest |
|
473 while (<INFILE> ){printf(OUTFILE "%s",$_);} |
|
474 |
|
475 close(INFILE); |
|
476 close(OUTFILE); |
|
477 print "closed $filename and tmp.txt\n" if $do_ddebug; |
|
478 |
|
479 $status = system("cp tmp.txt $filename") ; |
|
480 if ($status) { die "can't copy tmp.txt to $filename: $!\n";} |
|
481 |
|
482 ######################## |
|
483 # configure conv-lex.x |
|
484 # |
|
485 |
|
486 $filename = "conv-lex.x"; |
|
487 |
|
488 print "\nconfiguring $filename\n" if $do_debug; |
|
489 |
|
490 open(INFILE ,$filename) || die "can't open $filename in CONV_SOURCE_DIR: $!\n"; |
|
491 print "opened $filename for reading\n" if $do_ddebug; |
|
492 open(OUTFILE,">tmp.txt") || die "can't open temporary file tmp.txt: $!\n"; |
|
493 print "opened tmp.txt for writing\n" if $do_ddebug; |
|
494 |
|
495 |
|
496 ### HI TABLE |
|
497 $found = &replicate_until('^\s*\/\*\s*BEGIN_OF_HI_TABL(E)','BEGIN_OF_HI_TABLE'); |
|
498 if ($found eq "") { |
|
499 die "\ncan't find BEGIN_OF_HI_TABLE\n";} |
|
500 ## replace |
|
501 printf(OUTFILE "%s\n", " /* BEGIN_OF_HI_TABLE */"); |
|
502 $index = $start_hi_table; |
|
503 while ($index <= $end_hi_table) { |
|
504 ($temp1,$temp2,$temp3) = split(/\"/,$hi_table[$index-$start_hi_table]); |
|
505 printf(OUTFILE "<ISAA>%-".($max_hi_len1+3)."s\t"."put((char)%d,FALSE,0);\n", |
|
506 $temp1,$index); |
|
507 $index++; |
|
508 } |
|
509 printf(OUTFILE "%s\n", " /* END_OF_HI_TABLE */"); |
|
510 $found = &skip_until('^\s*\/\*\s*END_OF_HI_TABL(E)','END_OF_HI_TABLE'); |
|
511 if ($found eq "") { |
|
512 die "\ncan't find END_OF_SEQ_TABLE\n";} |
|
513 |
|
514 |
|
515 ### SEQ TABLE |
|
516 $found = &replicate_until('^\s*\/\*\s*BEGIN_OF_SEQ_TABL(E)','BEGIN_OF_SEQ_TABLE'); |
|
517 if ($found eq "") { |
|
518 die "\ncan't find BEGIN_OF_SEQ_TABLE\n";} |
|
519 ## replace |
|
520 printf(OUTFILE "%s\n", " /* BEGIN_OF_SEQ_TABLE */"); |
|
521 $index = 0; |
|
522 while ($index < $seq_table ) { |
|
523 ($temp1,$temp2,$temp3,$temp4) = split(/\"/,$seq_table[$index]); |
|
524 printf(OUTFILE "<ISA,ISAA>%-".($max_seq_len1+3)."s\t"."put((char)32,TRUE,%d);\n", |
|
525 $temp1,$index); |
|
526 printf(OUTFILE "<ISAA>%-".($max_seq_len2+3)."s \t"."put((char)32,TRUE,%d);\n", |
|
527 $temp2,$index); |
|
528 $index++; |
|
529 } |
|
530 printf(OUTFILE "%s\n", " /* END_OF_SEQ_TABLE */"); |
|
531 $found = &skip_until('^\s*\/\*\s*END_OF_SEQ_TABL(E)','END_OF_SEQ_TABLE'); |
|
532 if ($found eq "") { |
|
533 die "\ncan't find END_OF_SEQ_TABLE\n";} |
|
534 |
|
535 |
|
536 ## the rest |
|
537 while (<INFILE> ){printf(OUTFILE "%s",$_);} |
|
538 |
|
539 close(INFILE); |
|
540 close(OUTFILE); |
|
541 print "closed $filename and tmp.txt\n" if $do_ddebug; |
|
542 |
|
543 $status = system("cp tmp.txt $filename") ; |
|
544 if ($status) { die "can't copy tmp.txt to $filename: $!\n";} |
|
545 |
|
546 ######################## |
|
547 # execute Makefile |
|
548 # |
|
549 print "\nexecuting Makefile\n" if $do_debug; |
|
550 $status = system("gmake") ; |
|
551 if ($status) { die "\"gmake\" executed abnormally: $!\n";} |
|
552 |
|
553 #$status = system("cp $conv_temp_dir/$conv_sub_dir/isa2latex $conv_source_dir"); |
|
554 # if ($status) { die "can't copy binary file to CONV_SOURCE_DIR: $!\n";} |
|
555 |
|
556 #print "\nexecuting Makefile, cleaning up\n" if $do_debug; |
|
557 #$status = system("gmake clean"); |
|
558 #if ($status) { die "\"gmake clean\" executed abnormally: $!\n";} |
|
559 |
|
560 ####################################################################### |
|
561 # process -s option |
|
562 ####################################################################### |
|
563 |
|
564 #if ($install_source){ |
|
565 # print "\ninstall new files in CONV_SOURCE_DIR due to -s option\n" if $do_debug; |
|
566 # $status = system("cp -r $conv_temp_dir/$conv_sub_dir/* $conv_source_dir"); |
|
567 # if ($status) { die "can't copy new files to CONV_SOURCE_DIR: $!\n";} |
|
568 |
|
569 # print "copied new files to CONV_SOURCE_DIR\n" if $do_debug; |
|
570 |
|
571 # chdir $initial_dir || die "can't cd to initial dir $initial_dir: $!\n"; |
|
572 # $status = system("cp $config_file $conv_source_dir"); |
|
573 # if ($status) { die "can't copy configuration file to CONV_SOURCE_DIR: $!\n";} |
|
574 # |
|
575 # print "copied configuration file to CONV_SOURCE_DIR\n" if $do_debug; |
|
576 |
|
577 #} |
|
578 |
|
579 |
|
580 ######################## |
|
581 # END of script |
|
582 # |
|
583 |
|
584 print "\nconfiguration and generation of isa2latex properly terminated\n". |
|
585 "have fun with isa2latex!\n\n"; |
|
586 exit(0); |
|
587 |
|
588 ####################################################################### |
|
589 # subroutines |
|
590 ####################################################################### |
|
591 |
|
592 sub look_for_value { |
|
593 local ($pattern,$label) = @_; |
|
594 local ($temp) = ""; |
|
595 |
|
596 while (<CONFIG> ){ |
|
597 if (($temp) = /$pattern/){ |
|
598 print "line $.: $label is $temp\n" if $do_debug; |
|
599 last;} |
|
600 } |
|
601 return $temp; |
|
602 } |
|
603 |
|
604 |
|
605 sub look_for_label { |
|
606 local ($pattern,$label) = @_; |
|
607 local ($temp) = ""; |
|
608 |
|
609 while (<CONFIG> ){ |
|
610 if (($temp) = /$pattern/){ |
|
611 print "line $.: $label found\n" if $do_debug; |
|
612 last;} |
|
613 } |
|
614 return $temp; |
|
615 } |
|
616 |
|
617 sub replicate_until { |
|
618 local ($pattern,$label) = @_; |
|
619 local ($temp) = ""; |
|
620 |
|
621 while (<INFILE> ){ |
|
622 if (($temp) = /$pattern/){ |
|
623 print "line $.: $label found\n" if $do_debug; |
|
624 last;} |
|
625 else {printf(OUTFILE "%s",$_);} |
|
626 } |
|
627 return $temp; |
|
628 } |
|
629 |
|
630 sub skip_until { |
|
631 local ($pattern,$label) = @_; |
|
632 local ($temp) = ""; |
|
633 |
|
634 while (<INFILE> ){ |
|
635 if (($temp) = /$pattern/){ |
|
636 print "line $.: $label found\n" if $do_debug; |
|
637 last;} |
|
638 } |
|
639 return $temp; |
|
640 } |
|
641 |
|
642 sub double_bs { |
|
643 local ($string) = @_; |
|
644 local ($element); |
|
645 local (@temp1); |
|
646 local (@temp2) = (); |
|
647 |
|
648 # find the hex-numbers |
|
649 @temp1 = split(/(\\x[0-9a-fA-F][0-9a-fA-F])/,$string); |
|
650 |
|
651 #duplicate all backslashes in elements which are not hexnumbers |
|
652 while(@temp1) { |
|
653 $element = shift(@temp1); |
|
654 if ($element =~ /\\x[0-9a-fA-F][0-9a-fA-F]/){ |
|
655 push(@temp2,$element);} |
|
656 else{ |
|
657 $element =~ s/\\/\\\\/g; |
|
658 push(@temp2,$element);} |
|
659 } |
|
660 return (join('',@temp2)); |
|
661 } |
|
662 |
|
663 ############################################################### |
|
664 |
|
665 # These next few lines are legal in both Perl and nroff. |
|
666 |
|
667 .00; # finish .ig |
|
668 |
|
669 'di \" finish diversion--previous line must be blank |
|
670 .nr nl 0-1 \" fake up transition to first page again |
|
671 .nr % 0 \" start at page 1 |
|
672 '; __END__ ##### From here on it's a standard manual page ##### |