On Sun, 26 May 2024 at 20:38, Richard Henderson <richard.hender...@linaro.org> wrote: > > Printing directly to STDOUT and STDERR will allow the > print destination to be selected elsewhere.
i.e. using 'select' to set the default filehandle for "print"? My instinct is to suspect that would be a bit confusing compared to passing in an explicit filehandle for whatever it is that we'd like to be able to print to other destinations. > Signed-off-by: Richard Henderson <richard.hender...@linaro.org> > --- > risugen_common.pm | 18 +++++++++--------- > 1 file changed, 9 insertions(+), 9 deletions(-) > > diff --git a/risugen_common.pm b/risugen_common.pm > index 71ee996..5207c0e 100644 > --- a/risugen_common.pm > +++ b/risugen_common.pm > @@ -76,7 +76,7 @@ sub progress_start($$) > ($proglen, $progmax) = @_; > $proglen -= 2; # allow for [] chars > $| = 1; # disable buffering so we can see the meter... > - print "[" . " " x $proglen . "]\r"; > + print STDOUT "[" . " " x $proglen . "]\r"; > $lastprog = 0; > } > > @@ -87,13 +87,13 @@ sub progress_update($) > my $barlen = int($proglen * $done / $progmax); > if ($barlen != $lastprog) { > $lastprog = $barlen; > - print "[" . "-" x $barlen . " " x ($proglen - $barlen) . "]\r"; > + print STDOUT "[" . "-" x $barlen . " " x ($proglen - $barlen) . > "]\r"; > } > } > > sub progress_end() > { > - print "[" . "-" x $proglen . "]\n"; > + print STDOUT "[" . "-" x $proglen . "]\n"; > $| = 0; > } These are the progress-bar indicators -- shouldn't they go to STDERR, not STDOUT, if we're going to be careful about where we send output? > @@ -163,20 +163,20 @@ sub dump_insn_details($$) > { > # Dump the instruction details for one insn > my ($insn, $rec) = @_; > - print "insn $insn: "; > + print STDOUT "insn $insn: "; > my $insnwidth = $rec->{width}; > my $fixedbits = $rec->{fixedbits}; > my $fixedbitmask = $rec->{fixedbitmask}; > my $constraint = $rec->{blocks}{"constraints"}; > - print sprintf(" insnwidth %d fixedbits %08x mask %08x ", $insnwidth, > $fixedbits, $fixedbitmask); > + print STDOUT sprintf(" insnwidth %d fixedbits %08x mask %08x ", > $insnwidth, $fixedbits, $fixedbitmask); > if (defined $constraint) { > - print "constraint $constraint "; > + print STDOUT "constraint $constraint "; > } > for my $tuple (@{ $rec->{fields} }) { > my ($var, $pos, $mask) = @$tuple; > - print "($var, $pos, " . sprintf("%08x", $mask) . ") "; > + print STDOUT "($var, $pos, " . sprintf("%08x", $mask) . ") "; > } > - print "\n"; > + print STDOUT "\n"; > } As a debug-print helper routine maybe this should be STDERR too? thanks -- PMM