@@ -38,7 +38,7 @@ package AutoLaTeX::Core::Util;
3838
3939our $INTERNAL_MESSAGE_PREFIX = ' ' ;
4040
41- our $VERSION = ' 12 .0' ;
41+ our $VERSION = ' 14 .0' ;
4242
4343@ISA = (' Exporter' );
4444@EXPORT = qw( &isHash &isArray &removeFromArray &arrayContains &getAutoLaTeXDir
@@ -67,7 +67,7 @@ use Data::Dumper;
6767
6868use AutoLaTeX::Core::IntUtils;
6969
70- local *AUTOLATEXCONSOLE = * STDERR ;
70+ my $autolatexUseSTDERR = 1 ;
7171my $autoLaTeXName = undef ;
7272my $autoLaTeXDirectory = undef ;
7373my $autoLaTeXLaunchingName = undef ;
@@ -80,6 +80,16 @@ my $lastListenerCheck = 0;
8080# Array of launched subprocesses
8181my %launchedSubProcesses = ();
8282
83+
84+ sub __print (@) {
85+ if ($autolatexUseSTDERR ) {
86+ print STDOUT (@_ );
87+ }
88+ else {
89+ print STDERR (@_ );
90+ }
91+ }
92+
8393=pod
8494
8595=item B<redirectToSTDOUT() >
@@ -90,8 +100,7 @@ I<Returns:> None.
90100
91101=cut
92102sub redirectToSTDOUT () {
93- *AUTOLATEXCONSOLE = *STDOUT ;
94- 1;
103+ $autolatexUseSTDERR = 0;
95104}
96105
97106=pod
@@ -104,8 +113,7 @@ I<Returns:> None.
104113
105114=cut
106115sub redirectToSTDERR () {
107- *AUTOLATEXCONSOLE = *STDERR ;
108- 1;
116+ $autolatexUseSTDERR = 1;
109117}
110118
111119=pod
@@ -262,11 +270,11 @@ sub setAutoLaTeXInfo($$$) {
262270 close (*VERSIONFILE);
263271 }
264272 else {
265- print AUTOLATEXCONSOLE formatText(_T(" No read access to the VERSION file of AutoLaTeX. AutoLaTeX should not be properly installed. Assuming version: {}\n " ),$autoLaTeXVersion );
273+ __print( formatText(_T(" No read access to the VERSION file of AutoLaTeX. AutoLaTeX should not be properly installed. Assuming version: {}\n " ),$autoLaTeXVersion ) );
266274 }
267275 }
268276 else {
269- print AUTOLATEXCONSOLE formatText(_T(" Unable to find the VERSION file of AutoLaTeX. AutoLaTeX should not be properly installed. Assuming version: {}\n " ), $autoLaTeXVersion );
277+ __print( formatText(_T(" Unable to find the VERSION file of AutoLaTeX. AutoLaTeX should not be properly installed. Assuming version: {}\n " ), $autoLaTeXVersion ) );
270278 }
271279}
272280
@@ -304,7 +312,7 @@ sub showManual(@) {
304312 my ($localePod ,$localeLang );
305313 local *DIR;
306314 opendir (*DIR,File::Spec-> catfile(@_ ))
307- or die (_T(" no manual page found\n " ));
315+ or die (_T(" no manual page found\n " ).File::Spec -> catfile( @_ ). " : $! \n " );
308316 while (my $file = readdir (*DIR)) {
309317 if (($file ne ' .' )&&($file ne ' ..' )) {
310318 if ($file =~ / ^\Q $filename \E [._\- ]\Q $currentLocale$ext \E $ / ) {
@@ -337,7 +345,7 @@ sub showManual(@) {
337345 exit (0);
338346 }
339347 }
340- print AUTOLATEXCONSOLE _T(" no manual page found\n " );
348+ __print( _T(" no manual page found\n " ) );
341349 exit (255);
342350}
343351
@@ -652,7 +660,7 @@ sub printDbgFor($@) {
652660 if ($debugLevel >=$requestedLevel ) {
653661 my @text = makeMessage(60,$dbgIndent ,@_ );
654662 foreach my $p (@text ) {
655- print AUTOLATEXCONSOLE ($INTERNAL_MESSAGE_PREFIX , _T(" [AutoLaTeX]" ), " $p " , " \n " );
663+ __print ($INTERNAL_MESSAGE_PREFIX , _T(" [AutoLaTeX]" ), " $p " , " \n " );
656664 $INTERNAL_MESSAGE_PREFIX = ' ' ;
657665 }
658666 }
@@ -672,7 +680,7 @@ sub dumpDbgFor($@) {
672680 use Data::Dumper;
673681 my @text = makeMessage(60,$dbgIndent ,Dumper(@_ ));
674682 foreach my $p (@text ) {
675- print AUTOLATEXCONSOLE ($INTERNAL_MESSAGE_PREFIX , _T(" [AutoLaTeX]" ), " $p " , " \n " );
683+ __print ($INTERNAL_MESSAGE_PREFIX , _T(" [AutoLaTeX]" ), " $p " , " \n " );
676684 $INTERNAL_MESSAGE_PREFIX = ' ' ;
677685 }
678686 }
@@ -704,7 +712,7 @@ display an error message and exit. The parameters will be displayed separated by
704712
705713=cut
706714sub printErr (@) {
707- print AUTOLATEXCONSOLE formatErr(@_ );
715+ __print( formatErr(@_ ) );
708716 exit (255);
709717 undef ;
710718}
@@ -719,7 +727,7 @@ display a warning message. The parameters will be displayed separated by a space
719727sub printWarn (@) {
720728 my @text = makeMessage(50,0,@_ );
721729 foreach my $p (@text ) {
722- print AUTOLATEXCONSOLE ($INTERNAL_MESSAGE_PREFIX , _T(" [AutoLaTeX]" ), ' ' , formatText(_T(" Warning: {}" )," $p " ), " \n " );
730+ __print ($INTERNAL_MESSAGE_PREFIX , _T(" [AutoLaTeX]" ), ' ' , formatText(_T(" Warning: {}" )," $p " ), " \n " );
723731 $INTERNAL_MESSAGE_PREFIX = ' ' ;
724732 }
725733 1;
@@ -770,7 +778,7 @@ sub runCommandOrFailRedirectTo($@) {
770778 if ($exitcode !=0) {
771779 open (*LOGFILE, " < autolatex_exec_stderr.log" ) or printErr(formatText(_T(" {}: {}" ), " autolatex_exec_stderr.log" , $! ));
772780 while (my $line = <LOGFILE>) {
773- print AUTOLATEXCONSOLE $INTERNAL_MESSAGE_PREFIX .$line ;
781+ __print( $INTERNAL_MESSAGE_PREFIX .$line ) ;
774782 $INTERNAL_MESSAGE_PREFIX = ' ' ;
775783 }
776784 close (*LOGFILE);
@@ -880,7 +888,7 @@ sub runCommandOrFail(@) {
880888 close (*LOGFILE);
881889 open (*LOGFILE, " < autolatex_exec_stderr.log" ) or printErr(formatText(_T(" {}: {}" ), " autolatex_exec_stderr.log" , $! ));
882890 while (my $line = <LOGFILE>) {
883- print AUTOLATEXCONSOLE $INTERNAL_MESSAGE_PREFIX .$line ;
891+ __print( $INTERNAL_MESSAGE_PREFIX .$line ) ;
884892 $INTERNAL_MESSAGE_PREFIX = ' ' ;
885893 }
886894 close (*LOGFILE);
@@ -962,7 +970,7 @@ sub runCommandOrFailFromInput($@) {
962970 close (*LOGFILE);
963971 open (*LOGFILE, " < autolatex_exec_stderr.log" ) or printErr(formatText(_T(" {}: {}" ), " autolatex_exec_stderr.log" , $! ));
964972 while (my $line = <LOGFILE>) {
965- print AUTOLATEXCONSOLE $INTERNAL_MESSAGE_PREFIX .$line ;
973+ __print( $INTERNAL_MESSAGE_PREFIX .$line ) ;
966974 $INTERNAL_MESSAGE_PREFIX = ' ' ;
967975 }
968976 close (*LOGFILE);
0 commit comments