From: Mike G. v. a. <we...@ma...> - 2010-06-04 00:39:58
|
Log Message: ----------- refactoring pretty_print some other minor changes Modified Files: -------------- pg/macros: PG.pl PGanswermacros.pl Revision Data ------------- Index: PG.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PG.pl,v retrieving revision 1.47 retrieving revision 1.48 diff -Lmacros/PG.pl -Lmacros/PG.pl -u -r1.47 -r1.48 --- macros/PG.pl +++ macros/PG.pl @@ -13,14 +13,15 @@ } sub not_null {PGcore::not_null(@_)}; +sub pretty_print {PGcore::pretty_print(@_)}; our $PG; sub DEBUG_MESSAGE { - $PG->append_debug_message(@_); + my @msg = @_; + $PG->debug_message(@msg); } - sub DOCUMENT { # get environment @@ -29,7 +30,6 @@ $PG = new PGcore($rh_envir, # can add key/value options to modify ); $PG->clear_internal_debug_messages; - # initialize main:: variables $ANSWER_PREFIX = $PG->{ANSWER_PREFIX}; @@ -128,7 +128,6 @@ sub inc_ans_rule_count { #$PG->{unlabeled_answer_blank_count}++; #my $num = $PG->{unlabeled_answer_blank_count}; - DEBUG_MESSAGE( " using PG to inc_ans_rule_count = $num ", caller(2)); warn " using PG to inc_ans_rule_count = $num ", caller(2); $PG->{unlabeled_answer_blank_count}; } Index: PGanswermacros.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGanswermacros.pl,v retrieving revision 1.73 retrieving revision 1.74 diff -Lmacros/PGanswermacros.pl -Lmacros/PGanswermacros.pl -u -r1.73 -r1.74 --- macros/PGanswermacros.pl +++ macros/PGanswermacros.pl @@ -1777,39 +1777,39 @@ # ^function pretty_print # ^uses lex_sort # ^uses pretty_print -sub pretty_print { - my $r_input = shift; - my $out = ''; - if ( not ref($r_input) ) { - $out = $r_input if defined $r_input; # not a reference - $out =~ s/</</g ; # protect for HTML output - } elsif ("$r_input" =~/hash/i) { # this will pick up objects whose '$self' is hash and so works better than ref($r_iput). - local($^W) = 0; - - $out .= "$r_input " ."<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; - - - foreach my $key (lex_sort( keys %$r_input )) { - $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}) . "</td></tr>"; - } - - - - $out .="</table>"; - } elsif (ref($r_input) eq 'ARRAY' ) { - my @array = @$r_input; - $out .= "( " ; - while (@array) { - $out .= pretty_print(shift @array) . " , "; - } - $out .= " )"; - } elsif (ref($r_input) eq 'CODE') { - $out = "$r_input"; - } else { - $out = $r_input; - $out =~ s/</</g ; # protect for HTML output - } - $out; -} +# sub pretty_print { +# my $r_input = shift; +# my $out = ''; +# if ( not ref($r_input) ) { +# $out = $r_input if defined $r_input; # not a reference +# $out =~ s/</</g ; # protect for HTML output +# } elsif ("$r_input" =~/hash/i) { # this will pick up objects whose '$self' is hash and so works better than ref($r_iput). +# local($^W) = 0; +# +# $out .= "$r_input " ."<TABLE border = \"2\" cellpadding = \"3\" BGCOLOR = \"#FFFFFF\">"; +# +# +# foreach my $key (lex_sort( keys %$r_input )) { +# $out .= "<tr><TD> $key</TD><TD>=></td><td> ".pretty_print($r_input->{$key}) . "</td></tr>"; +# } +# +# +# +# $out .="</table>"; +# } elsif (ref($r_input) eq 'ARRAY' ) { +# my @array = @$r_input; +# $out .= "( " ; +# while (@array) { +# $out .= pretty_print(shift @array) . " , "; +# } +# $out .= " )"; +# } elsif (ref($r_input) eq 'CODE') { +# $out = "$r_input"; +# } else { +# $out = $r_input; +# $out =~ s/</</g ; # protect for HTML output +# } +# $out; +# } 1; |