Home | History | Annotate | Line # | Download | only in dist
      1      1.1   wiz #!/usr/bin/perl -w
      2      1.1   wiz #
      3      1.1   wiz # ------------------------------------------------------------------
      4      1.1   wiz # This file is part of bzip2/libbzip2, a program and library for
      5      1.1   wiz # lossless, block-sorting data compression.
      6      1.1   wiz #
      7  1.1.1.3  maya # bzip2/libbzip2 version 1.0.8 of 13 July 2019
      8  1.1.1.3  maya # Copyright (C) 1996-2019 Julian Seward <jseward (at] acm.org>
      9      1.1   wiz #
     10      1.1   wiz # Please read the WARNING, DISCLAIMER and PATENTS sections in the 
     11      1.1   wiz # README file.
     12      1.1   wiz #
     13      1.1   wiz # This program is released under the terms of the license contained
     14      1.1   wiz # in the file LICENSE.
     15      1.1   wiz # ------------------------------------------------------------------
     16      1.1   wiz #
     17      1.1   wiz use strict;
     18      1.1   wiz 
     19      1.1   wiz # get command line values:
     20      1.1   wiz if ( $#ARGV !=1 ) {
     21      1.1   wiz     die "Usage:  $0 xml_infile xml_outfile\n";
     22      1.1   wiz }
     23      1.1   wiz 
     24      1.1   wiz my $infile = shift;
     25      1.1   wiz # check infile exists
     26      1.1   wiz die "Can't find file \"$infile\""
     27      1.1   wiz   unless -f $infile;
     28      1.1   wiz # check we can read infile
     29      1.1   wiz if (! -r $infile) {
     30      1.1   wiz     die "Can't read input $infile\n";
     31      1.1   wiz }
     32      1.1   wiz # check we can open infile
     33      1.1   wiz open( INFILE,"<$infile" ) or 
     34      1.1   wiz     die "Can't input $infile $!";
     35      1.1   wiz 
     36      1.1   wiz #my $outfile = 'fmt-manual.xml';
     37      1.1   wiz my $outfile = shift;
     38      1.1   wiz #print "Infile: $infile, Outfile: $outfile\n";
     39      1.1   wiz # check we can write to outfile
     40      1.1   wiz open( OUTFILE,">$outfile" ) or 
     41      1.1   wiz     die "Can't output $outfile $! for writing";
     42      1.1   wiz 
     43      1.1   wiz my ($prev, $curr, $str);
     44      1.1   wiz $prev = ''; $curr = '';
     45      1.1   wiz while ( <INFILE> ) {
     46      1.1   wiz 
     47      1.1   wiz 		print OUTFILE $prev;
     48      1.1   wiz     $prev = $curr;
     49      1.1   wiz     $curr = $_;
     50      1.1   wiz     $str = '';
     51      1.1   wiz 
     52      1.1   wiz     if ( $prev =~ /<programlisting>$|<screen>$/ ) {
     53      1.1   wiz         chomp $prev;
     54      1.1   wiz         $curr = join( '', $prev, "<![CDATA[", $curr );
     55      1.1   wiz 				$prev = '';
     56      1.1   wiz         next;
     57      1.1   wiz     }
     58      1.1   wiz     elsif ( $curr =~ /<\/programlisting>|<\/screen>/ ) {
     59      1.1   wiz         chomp $prev;
     60      1.1   wiz         $curr = join( '', $prev, "]]>", $curr );
     61      1.1   wiz 				$prev = '';
     62      1.1   wiz         next;
     63      1.1   wiz     }
     64      1.1   wiz }
     65      1.1   wiz print OUTFILE $curr;
     66      1.1   wiz close INFILE;
     67      1.1   wiz close OUTFILE;
     68      1.1   wiz exit;
     69