Skip to content

Commit a711606

Browse files
Add the variables "$inext" for the translators.
1 parent b789084 commit a711606

File tree

4 files changed

+51
-21
lines changed

4 files changed

+51
-21
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
autolatex 31.1
1+
autolatex 31.2

pm/AutoLaTeX/Core/Translator.pm

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The provided functions are:
3737
=cut
3838
package AutoLaTeX::Core::Translator;
3939

40-
$VERSION = '17.0';
40+
$VERSION = '18.0';
4141
@ISA = ('Exporter');
4242
@EXPORT = qw( &getTranslatorFilesFrom &getLoadableTranslatorList &getTranslatorList
4343
&detectConflicts @ALL_LEVELS
@@ -912,6 +912,16 @@ sub _runTranslator($$$$$$$$) {
912912
}
913913
$environment{'in'} = $in;
914914
$environment{'out'} = $out;
915+
my $inext;
916+
while ((!$inext)&& ((undef,my $e) = each @{$translators->{"$transname"}{'transdef'}{'INPUT_EXTENSIONS'}{'value'}})) {
917+
if ($in =~ /\Q$e\E$/i) {
918+
$inext = $e;
919+
}
920+
}
921+
if (!$inext) {
922+
$inext = $translators->{"$transname"}{'transdef'}{'INPUT_EXTENSIONS'}{'value'}[0];
923+
}
924+
$environment{'inext'} = $inext;
915925
my $ext = $translators->{"$transname"}{'transdef'}{'OUTPUT_EXTENSIONS'}{'value'}[0] || '';
916926
$environment{'outbasename'} = basename($out, $ext);
917927
$environment{'outwoext'} = File::Spec->catfile(dirname($out), $environment{'outbasename'});
@@ -936,6 +946,15 @@ sub _runTranslator($$$$$$$$) {
936946
my $interpreter = $translators->{"$transname"}{'transdef'}{'TRANSLATOR_FUNCTION'}{'interpreter'};
937947

938948
my @inexts = @{$translators->{"$transname"}{'transdef'}{'INPUT_EXTENSIONS'}{'value'}};
949+
my $inext;
950+
while ((!$inext)&& ((undef,my $e) = each @inexts)) {
951+
if ($in =~ /\Q$e\E$/i) {
952+
$inext = $e;
953+
}
954+
}
955+
if (!$inext) {
956+
$inext = $inexts[0];
957+
}
939958
my $outext = $translators->{"$transname"}{'transdef'}{'OUTPUT_EXTENSIONS'}{'value'}[0];
940959
my @outexts = @{$translators->{"$transname"}{'transdef'}{'OUTPUT_EXTENSIONS'}{'value'}};
941960
my $ext = $translators->{"$transname"}{'transdef'}{'OUTPUT_EXTENSIONS'}{'value'}[0] || '';
@@ -996,6 +1015,7 @@ sub _runTranslator($$$$$$$$) {
9961015
$wrapper->define_global_variable('_in', $in);
9971016
$wrapper->define_global_variable('_out', $out);
9981017
$wrapper->define_global_variable('_inexts', \@inexts);
1018+
$wrapper->define_global_variable('_inext', $inext);
9991019
$wrapper->define_global_variable('_outext', $outext);
10001020
$wrapper->define_global_variable('_outexts', \@outexts);
10011021
$wrapper->define_global_variable('_ext', $ext);
@@ -1279,7 +1299,7 @@ S<GNU Public License (GPL)>
12791299
12801300
=head1 COPYRIGHT
12811301
1282-
S<Copyright (c) 1998-13 Stéphane Galland E<lt>[email protected]E<gt>>
1302+
S<Copyright (c) 1998-14 Stéphane Galland E<lt>[email protected]E<gt>>
12831303
12841304
=head1 SEE ALSO
12851305

pm/AutoLaTeX/Core/Util.pm

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ package AutoLaTeX::Core::Util;
3838

3939
our $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

6868
use AutoLaTeX::Core::IntUtils;
6969

70-
local *AUTOLATEXCONSOLE = *STDERR;
70+
my $autolatexUseSTDERR = 1;
7171
my $autoLaTeXName = undef;
7272
my $autoLaTeXDirectory = undef;
7373
my $autoLaTeXLaunchingName = undef;
@@ -80,6 +80,16 @@ my $lastListenerCheck = 0;
8080
# Array of launched subprocesses
8181
my %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
92102
sub redirectToSTDOUT() {
93-
*AUTOLATEXCONSOLE = *STDOUT;
94-
1;
103+
$autolatexUseSTDERR = 0;
95104
}
96105

97106
=pod
@@ -104,8 +113,7 @@ I<Returns:> None.
104113
105114
=cut
106115
sub 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
706714
sub 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
719727
sub 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);

translators/template.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
# Command line to invoke to translate the files from input to output.
4242
# $in is the environment variable for the input filename.
43+
# $inext is the environment variable for the extension of the input filename.
4344
# $out is the environment variable for the output filename.
4445
# $outbasename is the basename without the extension and the dirname of the output file.
4546
# $outwoext is the basename without the extension but with the dirname of the out file.
@@ -67,8 +68,9 @@
6768

6869
# Code to invoke to translate the files from input to output.
6970
# $in is the environment variable for the input filename.
71+
# $inext is the current extension of the input filename.
7072
# $out is the environment variable for the output filename.
71-
# $outbasename is the basename without the extension and the dirname of the out file.
73+
# $outbasename is the basename without the extension and without the dirname of the out file.
7274
# $outwoext is the basename without the extension but with the dirname of the out file.
7375
# @inexts is the array of the extensions defined in variable INPUT_EXTENSIONS.
7476
# $outext is the first extension defined in variable OUTPUT_EXTENSION.

0 commit comments

Comments
 (0)