From: mike Date: Tue, 14 Sep 2004 12:28:23 +0000 (+0000) Subject: Support new command-line option, -l , to indicate the number X-Git-Tag: v1.5~152 X-Git-Url: http://git.indexdata.com/?a=commitdiff_plain;h=a72960f7daf8ee4839830facb042c970c25ee587;hp=03d306d1565094bbf47f997e4bb4c55c2d011ff2;p=cql-java-moved-to-github.git Support new command-line option, -l , to indicate the number of spaces to be used in indenting each level. --- diff --git a/test/regression/xmlpp.pl b/test/regression/xmlpp.pl index a4400c4..9e8abef 100755 --- a/test/regression/xmlpp.pl +++ b/test/regression/xmlpp.pl @@ -7,7 +7,7 @@ # for more information. # -# $Revision: 1.1 $ +# $Revision: 1.2 $ # # xmlpp: XML pretty printing # @@ -20,7 +20,7 @@ use FileHandle; use Fcntl; use Getopt::Std; -use vars qw($opt_h $opt_H $opt_s $opt_z $opt_t $opt_e $opt_S $opt_c $opt_n); +use vars qw($opt_h $opt_H $opt_s $opt_z $opt_t $opt_e $opt_S $opt_c $opt_n $opt_l); my $indent=0; my $textContent=''; @@ -29,10 +29,12 @@ my $output; my $inAnnotation = 0; -if (!getopts('nzhHsteSc') or $opt_h) { +if (!getopts('nzhHsteScl:') or $opt_h) { usage(); } +my $indentSize = $opt_l || 2; + if ($opt_s){ # expect to find attributeOrdering.txt file in same directory @@ -191,7 +193,7 @@ sub parseStart { $output .= "\n"; } - $output .= " " x $indent; + $output .= " " x ($indent * $indentSize); $output .= "<$s"; my @k = keys %attr; @@ -245,7 +247,7 @@ sub parseStart { } if ($splitAttributes) { - $output .= "\n"." " x $indent." "; + $output .= "\n"." " x ($indent * $indentSize) ." "; } if ($attr{$attr} =~ /'/) { $output .= " $attr=\"$attr{$attr}\""; @@ -254,7 +256,7 @@ sub parseStart { } } if ($splitAttributes and @k) { - $output .= "\n"." " x $indent; + $output .= "\n"." " x ($indent * $indentSize); } if ($selfclose) { $output .= " />"; @@ -284,7 +286,7 @@ sub parseEnd { printContent($textContent); if ($lastTag == 0) { $output .= "\n"; - $output .= " " x $indent; + $output .= " " x ($indent * $indentSize); } $output .= ""; $textContent = ''; @@ -396,7 +398,7 @@ options: -c place comments on new line. -n normalise whitespace (remove leading and trailing whitespace from nodes with text content. - + -l Indent each level by spaces [default: 2] EOF exit 1; }