File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change
1
+ use strict;
2
+ use warnings;
3
+
4
+ my $format = $ARGV [0] or die " $0 : missing required argument: format\n " ;
5
+ my $input = $ARGV [1] or die " $0 : missing required argument: input\n " ;
6
+ my $output = $ARGV [2] or die " $0 : missing required argument: output\n " ;
7
+
8
+ # FIXME: better argument handling
9
+ if (not ($format eq ' aix' or $format eq ' darwin' or $format eq ' gnu' ))
10
+ {
11
+ die " $0 : $format is not yet handled (only aix, darwin, gnu are)\n " ;
12
+ }
13
+
14
+ open (my $input_handle , ' <' , $input )
15
+ or die " $0 : could not open input file '$input ': $! \n " ;
16
+
17
+ open (my $output_handle , ' >' , $output )
18
+ or die " $0 : could not open output file '$output ': $! \n " ;
19
+
20
+
21
+ if ($format eq ' gnu' )
22
+ {
23
+ print $output_handle " {
24
+ global:
25
+ " ;
26
+ }
27
+
28
+ while (<$input_handle >)
29
+ {
30
+ if (/ ^#/ )
31
+ {
32
+ # don't do anything with a comment
33
+ }
34
+ elsif (/ ^([^\s ]+)\s +([^\s ]+)/ )
35
+ {
36
+ if ($format eq ' aix' )
37
+ {
38
+ print $output_handle " $1 \n " ;
39
+ }
40
+ elsif ($format eq ' darwin' )
41
+ {
42
+ print $output_handle " _$1 \n " ;
43
+ }
44
+ elsif ($format eq ' gnu' )
45
+ {
46
+ print $output_handle " $1 ;\n " ;
47
+ }
48
+ }
49
+ else
50
+ {
51
+ die " $0 : unexpected line $_ \n " ;
52
+ }
53
+ }
54
+
55
+ if ($format eq ' gnu' )
56
+ {
57
+ print $output_handle " local: *;
58
+ };
59
+ " ;
60
+ }
61
+
62
+ exit (0);
You can’t perform that action at this time.
0 commit comments