diff options
author | Julian Seward <jseward@acm.org> | 2005-02-15 22:13:13 +0100 |
---|---|---|
committer | Julian Seward <jseward@acm.org> | 2005-02-15 22:13:13 +0100 |
commit | 4d540bfc95a4b0eefc1d1f388ec33534aaeb3a2f (patch) | |
tree | 3b7e9c650b4c61d114e1716c4698e40d5c8d7ef7 /format.pl | |
parent | 099d844292f60f9d58914da29e5773204dc55e7a (diff) | |
download | bzip2-4d540bfc95a4b0eefc1d1f388ec33534aaeb3a2f.tar.gz bzip2-4d540bfc95a4b0eefc1d1f388ec33534aaeb3a2f.tar.bz2 bzip2-4d540bfc95a4b0eefc1d1f388ec33534aaeb3a2f.zip |
bzip2-1.0.3bzip2-1.0.3
Diffstat (limited to 'format.pl')
-rwxr-xr-x | format.pl | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/format.pl b/format.pl new file mode 100755 index 0000000..8ab47ac --- /dev/null +++ b/format.pl | |||
@@ -0,0 +1,53 @@ | |||
1 | #!/usr/bin/perl -w | ||
2 | use strict; | ||
3 | |||
4 | # get command line values: | ||
5 | if ( $#ARGV !=1 ) { | ||
6 | die "Usage: $0 xml_infile xml_outfile\n"; | ||
7 | } | ||
8 | |||
9 | my $infile = shift; | ||
10 | # check infile exists | ||
11 | die "Can't find file \"$infile\"" | ||
12 | unless -f $infile; | ||
13 | # check we can read infile | ||
14 | if (! -r $infile) { | ||
15 | die "Can't read input $infile\n"; | ||
16 | } | ||
17 | # check we can open infile | ||
18 | open( INFILE,"<$infile" ) or | ||
19 | die "Can't input $infile $!"; | ||
20 | |||
21 | #my $outfile = 'fmt-manual.xml'; | ||
22 | my $outfile = shift; | ||
23 | #print "Infile: $infile, Outfile: $outfile\n"; | ||
24 | # check we can write to outfile | ||
25 | open( OUTFILE,">$outfile" ) or | ||
26 | die "Can't output $outfile $! for writing"; | ||
27 | |||
28 | my ($prev, $curr, $str); | ||
29 | $prev = ''; $curr = ''; | ||
30 | while ( <INFILE> ) { | ||
31 | |||
32 | print OUTFILE $prev; | ||
33 | $prev = $curr; | ||
34 | $curr = $_; | ||
35 | $str = ''; | ||
36 | |||
37 | if ( $prev =~ /<programlisting>$|<screen>$/ ) { | ||
38 | chomp $prev; | ||
39 | $curr = join( '', $prev, "<![CDATA[", $curr ); | ||
40 | $prev = ''; | ||
41 | next; | ||
42 | } | ||
43 | elsif ( $curr =~ /<\/programlisting>|<\/screen>/ ) { | ||
44 | chomp $prev; | ||
45 | $curr = join( '', $prev, "]]>", $curr ); | ||
46 | $prev = ''; | ||
47 | next; | ||
48 | } | ||
49 | } | ||
50 | print OUTFILE $curr; | ||
51 | close INFILE; | ||
52 | close OUTFILE; | ||
53 | exit; | ||