annotate src/bzip2-1.0.6/format.pl @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents e13257ea84a4
children
rev   line source
Chris@4 1 #!/usr/bin/perl -w
Chris@4 2 #
Chris@4 3 # ------------------------------------------------------------------
Chris@4 4 # This file is part of bzip2/libbzip2, a program and library for
Chris@4 5 # lossless, block-sorting data compression.
Chris@4 6 #
Chris@4 7 # bzip2/libbzip2 version 1.0.6 of 6 September 2010
Chris@4 8 # Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
Chris@4 9 #
Chris@4 10 # Please read the WARNING, DISCLAIMER and PATENTS sections in the
Chris@4 11 # README file.
Chris@4 12 #
Chris@4 13 # This program is released under the terms of the license contained
Chris@4 14 # in the file LICENSE.
Chris@4 15 # ------------------------------------------------------------------
Chris@4 16 #
Chris@4 17 use strict;
Chris@4 18
Chris@4 19 # get command line values:
Chris@4 20 if ( $#ARGV !=1 ) {
Chris@4 21 die "Usage: $0 xml_infile xml_outfile\n";
Chris@4 22 }
Chris@4 23
Chris@4 24 my $infile = shift;
Chris@4 25 # check infile exists
Chris@4 26 die "Can't find file \"$infile\""
Chris@4 27 unless -f $infile;
Chris@4 28 # check we can read infile
Chris@4 29 if (! -r $infile) {
Chris@4 30 die "Can't read input $infile\n";
Chris@4 31 }
Chris@4 32 # check we can open infile
Chris@4 33 open( INFILE,"<$infile" ) or
Chris@4 34 die "Can't input $infile $!";
Chris@4 35
Chris@4 36 #my $outfile = 'fmt-manual.xml';
Chris@4 37 my $outfile = shift;
Chris@4 38 #print "Infile: $infile, Outfile: $outfile\n";
Chris@4 39 # check we can write to outfile
Chris@4 40 open( OUTFILE,">$outfile" ) or
Chris@4 41 die "Can't output $outfile $! for writing";
Chris@4 42
Chris@4 43 my ($prev, $curr, $str);
Chris@4 44 $prev = ''; $curr = '';
Chris@4 45 while ( <INFILE> ) {
Chris@4 46
Chris@4 47 print OUTFILE $prev;
Chris@4 48 $prev = $curr;
Chris@4 49 $curr = $_;
Chris@4 50 $str = '';
Chris@4 51
Chris@4 52 if ( $prev =~ /<programlisting>$|<screen>$/ ) {
Chris@4 53 chomp $prev;
Chris@4 54 $curr = join( '', $prev, "<![CDATA[", $curr );
Chris@4 55 $prev = '';
Chris@4 56 next;
Chris@4 57 }
Chris@4 58 elsif ( $curr =~ /<\/programlisting>|<\/screen>/ ) {
Chris@4 59 chomp $prev;
Chris@4 60 $curr = join( '', $prev, "]]>", $curr );
Chris@4 61 $prev = '';
Chris@4 62 next;
Chris@4 63 }
Chris@4 64 }
Chris@4 65 print OUTFILE $curr;
Chris@4 66 close INFILE;
Chris@4 67 close OUTFILE;
Chris@4 68 exit;