summaryrefslogtreecommitdiff
path: root/Utilities/cmbzip2/format.pl
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-10-30 15:39:57 -0700
committerAnas Nashif <anas.nashif@intel.com>2012-10-30 15:39:57 -0700
commit035c7fabc3b82cbc9a346c11abe2e9462b4c0379 (patch)
tree7e40f5a790eae329a8c5d3e59f046451767956ff /Utilities/cmbzip2/format.pl
downloadcmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.tar.gz
cmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.tar.bz2
cmake-035c7fabc3b82cbc9a346c11abe2e9462b4c0379.zip
Imported Upstream version 2.8.9upstream/2.8.9
Diffstat (limited to 'Utilities/cmbzip2/format.pl')
-rwxr-xr-xUtilities/cmbzip2/format.pl68
1 files changed, 68 insertions, 0 deletions
diff --git a/Utilities/cmbzip2/format.pl b/Utilities/cmbzip2/format.pl
new file mode 100755
index 000000000..2b391dad6
--- /dev/null
+++ b/Utilities/cmbzip2/format.pl
@@ -0,0 +1,68 @@
+#!/usr/bin/perl -w
+#
+# ------------------------------------------------------------------
+# This file is part of bzip2/libbzip2, a program and library for
+# lossless, block-sorting data compression.
+#
+# bzip2/libbzip2 version 1.0.5 of 10 December 2007
+# Copyright (C) 1996-2007 Julian Seward <jseward@bzip.org>
+#
+# Please read the WARNING, DISCLAIMER and PATENTS sections in the
+# README file.
+#
+# This program is released under the terms of the license contained
+# in the file LICENSE.
+# ------------------------------------------------------------------
+#
+use strict;
+
+# get command line values:
+if ( $#ARGV !=1 ) {
+ die "Usage: $0 xml_infile xml_outfile\n";
+}
+
+my $infile = shift;
+# check infile exists
+die "Can't find file \"$infile\""
+ unless -f $infile;
+# check we can read infile
+if (! -r $infile) {
+ die "Can't read input $infile\n";
+}
+# check we can open infile
+open( INFILE,"<$infile" ) or
+ die "Can't input $infile $!";
+
+#my $outfile = 'fmt-manual.xml';
+my $outfile = shift;
+#print "Infile: $infile, Outfile: $outfile\n";
+# check we can write to outfile
+open( OUTFILE,">$outfile" ) or
+ die "Can't output $outfile $! for writing";
+
+my ($prev, $curr, $str);
+$prev = ''; $curr = '';
+while ( <INFILE> ) {
+
+ print OUTFILE $prev;
+ $prev = $curr;
+ $curr = $_;
+ $str = '';
+
+ if ( $prev =~ /<programlisting>$|<screen>$/ ) {
+ chomp $prev;
+ $curr = join( '', $prev, "<![CDATA[", $curr );
+ $prev = '';
+ next;
+ }
+ elsif ( $curr =~ /<\/programlisting>|<\/screen>/ ) {
+ chomp $prev;
+ $curr = join( '', $prev, "]]>", $curr );
+ $prev = '';
+ next;
+ }
+}
+print OUTFILE $curr;
+close INFILE;
+close OUTFILE;
+exit;