19
19
use warnings;
20
20
21
21
use File::Basename;
22
+ use Getopt::Long;
22
23
23
24
use FindBin;
24
25
use lib " $FindBin::RealBin /../catalog" ;
25
26
26
27
use Catalog; # for RenameTempFile
27
28
29
+ my $output_path = ' .' ;
30
+
31
+ GetOptions(
32
+ ' outdir:s' => \$output_path )
33
+ or die " $0 : wrong arguments" ;
34
+
28
35
29
36
# Test whether first argument is element of the list in the second
30
37
# argument
@@ -576,7 +583,7 @@ sub elem
576
583
# nodetags.h
577
584
578
585
push @output_files , ' nodetags.h' ;
579
- open my $nt , ' >' , ' nodetags.h' . $tmpext or die $! ;
586
+ open my $nt , ' >' , " $output_path / nodetags.h$tmpext " or die " $output_path /nodetags.h $tmpext : $! " ;
580
587
581
588
printf $nt $header_comment , ' nodetags.h' ;
582
589
@@ -620,13 +627,13 @@ sub elem
620
627
# copyfuncs.c, equalfuncs.c
621
628
622
629
push @output_files , ' copyfuncs.funcs.c' ;
623
- open my $cff , ' >' , ' copyfuncs.funcs.c' . $tmpext or die $! ;
630
+ open my $cff , ' >' , " $output_path / copyfuncs.funcs.c$tmpext " or die $! ;
624
631
push @output_files , ' equalfuncs.funcs.c' ;
625
- open my $eff , ' >' , ' equalfuncs.funcs.c' . $tmpext or die $! ;
632
+ open my $eff , ' >' , " $output_path / equalfuncs.funcs.c$tmpext " or die $! ;
626
633
push @output_files , ' copyfuncs.switch.c' ;
627
- open my $cfs , ' >' , ' copyfuncs.switch.c' . $tmpext or die $! ;
634
+ open my $cfs , ' >' , " $output_path / copyfuncs.switch.c$tmpext " or die $! ;
628
635
push @output_files , ' equalfuncs.switch.c' ;
629
- open my $efs , ' >' , ' equalfuncs.switch.c' . $tmpext or die $! ;
636
+ open my $efs , ' >' , " $output_path / equalfuncs.switch.c$tmpext " or die $! ;
630
637
631
638
printf $cff $header_comment , ' copyfuncs.funcs.c' ;
632
639
printf $eff $header_comment , ' equalfuncs.funcs.c' ;
@@ -819,13 +826,13 @@ sub elem
819
826
# outfuncs.c, readfuncs.c
820
827
821
828
push @output_files , ' outfuncs.funcs.c' ;
822
- open my $off , ' >' , ' outfuncs.funcs.c' . $tmpext or die $! ;
829
+ open my $off , ' >' , " $output_path / outfuncs.funcs.c$tmpext " or die $! ;
823
830
push @output_files , ' readfuncs.funcs.c' ;
824
- open my $rff , ' >' , ' readfuncs.funcs.c' . $tmpext or die $! ;
831
+ open my $rff , ' >' , " $output_path / readfuncs.funcs.c$tmpext " or die $! ;
825
832
push @output_files , ' outfuncs.switch.c' ;
826
- open my $ofs , ' >' , ' outfuncs.switch.c' . $tmpext or die $! ;
833
+ open my $ofs , ' >' , " $output_path / outfuncs.switch.c$tmpext " or die $! ;
827
834
push @output_files , ' readfuncs.switch.c' ;
828
- open my $rfs , ' >' , ' readfuncs.switch.c' . $tmpext or die $! ;
835
+ open my $rfs , ' >' , " $output_path / readfuncs.switch.c$tmpext " or die $! ;
829
836
830
837
printf $off $header_comment , ' outfuncs.funcs.c' ;
831
838
printf $rff $header_comment , ' readfuncs.funcs.c' ;
@@ -1130,7 +1137,7 @@ sub elem
1130
1137
# now rename the temporary files to their final names
1131
1138
foreach my $file (@output_files )
1132
1139
{
1133
- Catalog::RenameTempFile($ file , $tmpext );
1140
+ Catalog::RenameTempFile(" $output_path / $ file" , $tmpext );
1134
1141
}
1135
1142
1136
1143
@@ -1144,7 +1151,7 @@ END
1144
1151
{
1145
1152
foreach my $file (@output_files )
1146
1153
{
1147
- unlink ($ file . $tmpext );
1154
+ unlink (" $output_path / $ file$tmpext" );
1148
1155
}
1149
1156
}
1150
1157
0 commit comments