diff options
5 files changed, 193 insertions, 44 deletions
diff --git a/Build/source/texk/texlive/linked_scripts/latexpand/latexpand b/Build/source/texk/texlive/linked_scripts/latexpand/latexpand index f2e83c28a71..e8694e7fe25 100755 --- a/Build/source/texk/texlive/linked_scripts/latexpand/latexpand +++ b/Build/source/texk/texlive/linked_scripts/latexpand/latexpand @@ -1,6 +1,6 @@ #!/usr/bin/perl # Inspired by latexpand by D. Musliner, University of Michigan -# 2012, 2013, 2014 Matthieu Moy <Matthieu.Moy@imag.fr> +# 2012, 2013, 2014, 2015: Matthieu Moy <Matthieu.Moy@imag.fr> # BSD License use strict; @@ -26,6 +26,7 @@ my $expand_usepackage; my $expand_bbl; my $fatal; my $version; +my $makeatletter; GetOptions ( 'h' => \$help, @@ -42,6 +43,7 @@ GetOptions ( 'expand-bbl=s' => \$expand_bbl, 'fatal' => \$fatal, 'version' => \$version, + 'makeatletter' => \$makeatletter, ) or pod2usage(2); version() if $version; pod2usage(1) if $help; @@ -49,13 +51,15 @@ pod2usage(-exitstatus => 0, -verbose => 2) if $long_help; sub get_version { - my $VERSION = 'v1.1.1'; - if ($VERSION == '@LATEXPAND' . '_VERSION@') { + # $VERSION's value will be substituted by 'make dist', but the + # next line won't (the string has to be broken to avoid it). + my $VERSION = 'v1.2-1-g47e2cee'; + if ($VERSION eq '@LATEXPAND' . '_VERSION@') { my($vol,$dir,$file) = File::Spec->splitpath($0); chdir($dir); $VERSION = `git describe --tags HEAD 2>/dev/null`; } - if ($VERSION == '') { + if ($VERSION eq '') { $VERSION = '<unknown version>'; } $VERSION =~ s/^\s+|\s+$//g; @@ -68,8 +72,6 @@ sub version exit(0); } -my $comment_newline; - my $nl = ""; if ($empty_comments) { $nl = "%\n"; @@ -87,9 +89,14 @@ sub say } } +my $makeatletter_found; +my $in_preamble; + foreach my $file (@ARGV) { say "processing $file\n"; + $makeatletter_found = 0; + $in_preamble = 1; process_file($file, " "); } @@ -102,12 +109,12 @@ sub process_file open(FILE, $file) or die "could not open input file '$file'\n"; while (my $line = <FILE>) { if ($line =~ /^[ \t]*\\endinput/) { - $line =~ s/(\\endinput.*)\n/% $1/; - $in_comment = 1; - process_line($line, $prefix); - last; + $line =~ s/(\\endinput.*)\n/% $1/; + $in_comment = 1; + process_line($line, $prefix); + last; } - process_line($line, $prefix); + process_line($line, $prefix, $file); if ($line =~ /^%.*[^\n]\z/ || $line =~ /[^\\]%.*[^\n]\z/) { # file ends with a comment not ending with a newline print "\n"; @@ -117,7 +124,7 @@ sub process_file # to avoid e.g. \verb|\end{document}| from terminating # the file. if (!$keep_comments && $line =~ /^[ \t]*\\end{document}/) { - last; + last; } } close(FILE); @@ -126,8 +133,21 @@ sub process_file sub process_line { - my $prefix; - ($_, $prefix) = @_; + my ($_, $prefix, $file) = @_; + # Consider \makeatletter only in preamble, because we do want + # to warn on \someCommand{\makeatletter\command@with@arobase}. + if ($in_preamble && /^[^%]*\\makeatletter/) { + $makeatletter_found = 1; + } + if ($in_preamble && /^[^%]*\\makeatother/) { + $makeatletter_found = 0; + } + if (!$makeatletter && !$makeatletter_found + && (my ($command) = /^[^%]*(\\[[:alpha:]]*@[[:alpha:]]*)/)) { + print STDERR "Warning: command $command containing @ found in\n"; + print STDERR "Warning: $file.\n"; + print STDERR "Warning: consider using --makeatletter if the result is not compilable.\n"; + } unless ($keep_comments) { if ($empty_comments) { s/^%.*$/%/; @@ -213,6 +233,12 @@ sub process_line print STDERR "$full\n"; } } + if (/^[ \t]*\\begin{document}/) { + $in_preamble = 0; + if ($makeatletter) { + print '\makeatletter' . $nl; + } + } print; } @@ -270,7 +296,7 @@ latexpand [options] FILE... --keep-comments don't strip comments (comments are lines starting with %, and anything below \end{document}) - --empty-comments keep empty comments (i.e. % at end of lines) for clarity + --empty-comments keep empty comments (i.e. % at end of lines) for clarity --keep-includes don't expand \input and \include directives --expand-usepackage Expand \usepackage{...} directives if the @@ -288,7 +314,11 @@ latexpand [options] FILE... --graphics_extensions colon-separated list of possible graphics extensions (used by --show-graphics to find the actual graphics files) - --fatal Die in case a file can't be found. + --fatal Die in case a file can't be found. + --makeatletter Insert a \makeatletter in the preamble. In some + rare cases it may break your document, but it + may help fixing bad interactions between + @-commands and inclusion (see BUGS section). =head1 USES @@ -316,10 +346,14 @@ Please, report bugs to Matthieu Moy <Matthieu.Moy@imag.fr>. =head2 Known bugs +=head3 Verbatim + latexpand currently ignores \begin{verbatim} ... \end{verbatim}, and will therefore process any \include, \input, ... directives that appear within verbatim environments (while it shouldn't). +=head3 Comment environment + It would be nice to remove code between \begin{comment} and \end{comment} too if \usepackage{comment} is used. @@ -335,6 +369,30 @@ will produce the incorrect A workaround is to use --empty-comments when such tricky usage of the comments package is done. +=head3 \makeatletter and use with transfig/xfig with \scalebox{} + +If \input{} or \include{} appears as argument to a command, and the +file included contains \makeatletter, then after expansion, the +\makeatletter and the @-command appear as argument to the command, +which is forbidden because the argument is parsed (and the @-command +badly tokenized) before being executed. + +This happens with + + \scalebox{ \input{file-generated-by-xfig.pdf_t} } + +Workaround: add \makeatletter before the scalebox manually in your +code, like + + \makeatletter{} + \scalebox{ \input{file-generated-by-xfig.pdf_t} } + \makeatother{} + +In the case of xfig generated files, it is necessary only for the +first occurence. + +A more brute-force workaround is to use latexpand --makeatletter. + =head1 SEE ALSO Instructions to include only the relevant .bib items (french): @@ -343,4 +401,4 @@ https://lacl.fr/~caubert/notes/portabilite-du-tex.html#dependances =head1 VERSION -This is latexpand version v1.1.1. +This is latexpand version v1.2-1-g47e2cee. diff --git a/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl b/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl index 53d5d70ce8b..0cb6aad1739 100755 --- a/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl +++ b/Build/source/texk/texlive/linked_scripts/texlive/fmtutil.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# $Id: fmtutil.pl 37541 2015-06-15 00:00:42Z preining $ +# $Id: fmtutil.pl 37563 2015-06-16 13:21:24Z preining $ # fmtutil - utility to maintain format files. # (Maintained in TeX Live:Master/texmf-dist/scripts/texlive.) # @@ -25,11 +25,11 @@ BEGIN { } -my $svnid = '$Id: fmtutil.pl 37541 2015-06-15 00:00:42Z preining $'; -my $lastchdate = '$Date: 2015-06-15 02:00:42 +0200 (Mon, 15 Jun 2015) $'; +my $svnid = '$Id: fmtutil.pl 37563 2015-06-16 13:21:24Z preining $'; +my $lastchdate = '$Date: 2015-06-16 15:21:24 +0200 (Tue, 16 Jun 2015) $'; $lastchdate =~ s/^\$Date:\s*//; $lastchdate =~ s/ \(.*$//; -my $svnrev = '$Revision: 37541 $'; +my $svnrev = '$Revision: 37563 $'; $svnrev =~ s/^\$Revision:\s*//; $svnrev =~ s/\s*\$$//; my $version = "r$svnrev ($lastchdate)"; @@ -717,7 +717,8 @@ sub callback_enable_disable_format { my @engs = keys %{$alldata->{'merged'}{$fmt}}; if (($#engs > 0) || ($#engs == -1)) { print_warning("More engines given for format $fmt.\n"); - print_warning("Please specify one of the engines: @engs\n"); + print_warning("Possible engines: @engs\n"); + print_warning("Please select one by passing in $fmt/ENGINE\n"); print_warning("No changes done.\n"); return 0; } else { @@ -1169,8 +1170,11 @@ Commands: --byengine ENGINENAME (re)create formats using ENGINENAME --byfmt FORMATNAME (re)create format for FORMATNAME --byhyphen HYPHENFILE (re)create formats that depend on HYPHENFILE - --enablefmt FORMATNAME enable formatname in config file - --disablefmt FORMATNAME disable formatname in config file + --enablefmt FORMATNAME[/ENGINE] enable formatname in config file + --disablefmt FORMATNAME[/ENGINE] disable formatname in config file + If more formats share the same name but have + different engines, the ENGINE parameter is + obligatory. --listcfg list (enabled and disabled) configurations, filtered to available formats --catcfg output the content of the config file diff --git a/Master/texmf-dist/doc/support/latexpand/README b/Master/texmf-dist/doc/support/latexpand/README index 1103a78b5b9..9d96208d8ab 100644 --- a/Master/texmf-dist/doc/support/latexpand/README +++ b/Master/texmf-dist/doc/support/latexpand/README @@ -29,6 +29,10 @@ SYNOPSIS colon-separated list of possible graphics extensions (used by --show-graphics to find the actual graphics files) --fatal Die in case a file can't be found. + --makeatletter Insert a \makeatletter in the preamble. In some + rare cases it may break your document, but it + may help fixing bad interactions between + @-commands and inclusion (see BUGS section). USES The most common use of latexpand is to simplify distribution of source @@ -52,10 +56,12 @@ BUGS Please, report bugs to Matthieu Moy <Matthieu.Moy@imag.fr>. Known bugs + Verbatim latexpand currently ignores \begin{verbatim} ... \end{verbatim}, and will therefore process any \include, \input, ... directives that appear within verbatim environments (while it shouldn't). + Comment environment It would be nice to remove code between \begin{comment} and \end{comment} too if \usepackage{comment} is used. @@ -71,11 +77,34 @@ BUGS A workaround is to use --empty-comments when such tricky usage of the comments package is done. + \makeatletter and use with transfig/xfig with \scalebox{} + If \input{} or \include{} appears as argument to a command, and the file + included contains \makeatletter, then after expansion, the \makeatletter + and the @-command appear as argument to the command, which is forbidden + because the argument is parsed (and the @-command badly tokenized) + before being executed. + + This happens with + + \scalebox{ \input{file-generated-by-xfig.pdf_t} } + + Workaround: add \makeatletter before the scalebox manually in your code, + like + + \makeatletter{} + \scalebox{ \input{file-generated-by-xfig.pdf_t} } + \makeatother{} + + In the case of xfig generated files, it is necessary only for the first + occurence. + + A more brute-force workaround is to use latexpand --makeatletter. + SEE ALSO Instructions to include only the relevant .bib items (french): https://lacl.fr/~caubert/notes/portabilite-du-tex.html#dependances VERSION - This is latexpand version v1.1.1. + This is latexpand version v1.2-1-g47e2cee. diff --git a/Master/texmf-dist/doc/support/latexpand/version.txt b/Master/texmf-dist/doc/support/latexpand/version.txt index ddf593e422c..c3d559da51a 100644 --- a/Master/texmf-dist/doc/support/latexpand/version.txt +++ b/Master/texmf-dist/doc/support/latexpand/version.txt @@ -1,2 +1,2 @@ -latexpand version v1.1.1 (931b9665fee76da7e6f9c902c4d7f629f791def1). -Committed on Fri Jan 23 10:55:18 2015 +0100. +latexpand version v1.2-1-g47e2cee (47e2ceee9a43e8f7be9be9fc1c5bd191b96820bf). +Committed on Sun May 24 15:05:43 2015 +0200. diff --git a/Master/texmf-dist/scripts/latexpand/latexpand b/Master/texmf-dist/scripts/latexpand/latexpand index f2e83c28a71..e8694e7fe25 100755 --- a/Master/texmf-dist/scripts/latexpand/latexpand +++ b/Master/texmf-dist/scripts/latexpand/latexpand @@ -1,6 +1,6 @@ #!/usr/bin/perl # Inspired by latexpand by D. Musliner, University of Michigan -# 2012, 2013, 2014 Matthieu Moy <Matthieu.Moy@imag.fr> +# 2012, 2013, 2014, 2015: Matthieu Moy <Matthieu.Moy@imag.fr> # BSD License use strict; @@ -26,6 +26,7 @@ my $expand_usepackage; my $expand_bbl; my $fatal; my $version; +my $makeatletter; GetOptions ( 'h' => \$help, @@ -42,6 +43,7 @@ GetOptions ( 'expand-bbl=s' => \$expand_bbl, 'fatal' => \$fatal, 'version' => \$version, + 'makeatletter' => \$makeatletter, ) or pod2usage(2); version() if $version; pod2usage(1) if $help; @@ -49,13 +51,15 @@ pod2usage(-exitstatus => 0, -verbose => 2) if $long_help; sub get_version { - my $VERSION = 'v1.1.1'; - if ($VERSION == '@LATEXPAND' . '_VERSION@') { + # $VERSION's value will be substituted by 'make dist', but the + # next line won't (the string has to be broken to avoid it). + my $VERSION = 'v1.2-1-g47e2cee'; + if ($VERSION eq '@LATEXPAND' . '_VERSION@') { my($vol,$dir,$file) = File::Spec->splitpath($0); chdir($dir); $VERSION = `git describe --tags HEAD 2>/dev/null`; } - if ($VERSION == '') { + if ($VERSION eq '') { $VERSION = '<unknown version>'; } $VERSION =~ s/^\s+|\s+$//g; @@ -68,8 +72,6 @@ sub version exit(0); } -my $comment_newline; - my $nl = ""; if ($empty_comments) { $nl = "%\n"; @@ -87,9 +89,14 @@ sub say } } +my $makeatletter_found; +my $in_preamble; + foreach my $file (@ARGV) { say "processing $file\n"; + $makeatletter_found = 0; + $in_preamble = 1; process_file($file, " "); } @@ -102,12 +109,12 @@ sub process_file open(FILE, $file) or die "could not open input file '$file'\n"; while (my $line = <FILE>) { if ($line =~ /^[ \t]*\\endinput/) { - $line =~ s/(\\endinput.*)\n/% $1/; - $in_comment = 1; - process_line($line, $prefix); - last; + $line =~ s/(\\endinput.*)\n/% $1/; + $in_comment = 1; + process_line($line, $prefix); + last; } - process_line($line, $prefix); + process_line($line, $prefix, $file); if ($line =~ /^%.*[^\n]\z/ || $line =~ /[^\\]%.*[^\n]\z/) { # file ends with a comment not ending with a newline print "\n"; @@ -117,7 +124,7 @@ sub process_file # to avoid e.g. \verb|\end{document}| from terminating # the file. if (!$keep_comments && $line =~ /^[ \t]*\\end{document}/) { - last; + last; } } close(FILE); @@ -126,8 +133,21 @@ sub process_file sub process_line { - my $prefix; - ($_, $prefix) = @_; + my ($_, $prefix, $file) = @_; + # Consider \makeatletter only in preamble, because we do want + # to warn on \someCommand{\makeatletter\command@with@arobase}. + if ($in_preamble && /^[^%]*\\makeatletter/) { + $makeatletter_found = 1; + } + if ($in_preamble && /^[^%]*\\makeatother/) { + $makeatletter_found = 0; + } + if (!$makeatletter && !$makeatletter_found + && (my ($command) = /^[^%]*(\\[[:alpha:]]*@[[:alpha:]]*)/)) { + print STDERR "Warning: command $command containing @ found in\n"; + print STDERR "Warning: $file.\n"; + print STDERR "Warning: consider using --makeatletter if the result is not compilable.\n"; + } unless ($keep_comments) { if ($empty_comments) { s/^%.*$/%/; @@ -213,6 +233,12 @@ sub process_line print STDERR "$full\n"; } } + if (/^[ \t]*\\begin{document}/) { + $in_preamble = 0; + if ($makeatletter) { + print '\makeatletter' . $nl; + } + } print; } @@ -270,7 +296,7 @@ latexpand [options] FILE... --keep-comments don't strip comments (comments are lines starting with %, and anything below \end{document}) - --empty-comments keep empty comments (i.e. % at end of lines) for clarity + --empty-comments keep empty comments (i.e. % at end of lines) for clarity --keep-includes don't expand \input and \include directives --expand-usepackage Expand \usepackage{...} directives if the @@ -288,7 +314,11 @@ latexpand [options] FILE... --graphics_extensions colon-separated list of possible graphics extensions (used by --show-graphics to find the actual graphics files) - --fatal Die in case a file can't be found. + --fatal Die in case a file can't be found. + --makeatletter Insert a \makeatletter in the preamble. In some + rare cases it may break your document, but it + may help fixing bad interactions between + @-commands and inclusion (see BUGS section). =head1 USES @@ -316,10 +346,14 @@ Please, report bugs to Matthieu Moy <Matthieu.Moy@imag.fr>. =head2 Known bugs +=head3 Verbatim + latexpand currently ignores \begin{verbatim} ... \end{verbatim}, and will therefore process any \include, \input, ... directives that appear within verbatim environments (while it shouldn't). +=head3 Comment environment + It would be nice to remove code between \begin{comment} and \end{comment} too if \usepackage{comment} is used. @@ -335,6 +369,30 @@ will produce the incorrect A workaround is to use --empty-comments when such tricky usage of the comments package is done. +=head3 \makeatletter and use with transfig/xfig with \scalebox{} + +If \input{} or \include{} appears as argument to a command, and the +file included contains \makeatletter, then after expansion, the +\makeatletter and the @-command appear as argument to the command, +which is forbidden because the argument is parsed (and the @-command +badly tokenized) before being executed. + +This happens with + + \scalebox{ \input{file-generated-by-xfig.pdf_t} } + +Workaround: add \makeatletter before the scalebox manually in your +code, like + + \makeatletter{} + \scalebox{ \input{file-generated-by-xfig.pdf_t} } + \makeatother{} + +In the case of xfig generated files, it is necessary only for the +first occurence. + +A more brute-force workaround is to use latexpand --makeatletter. + =head1 SEE ALSO Instructions to include only the relevant .bib items (french): @@ -343,4 +401,4 @@ https://lacl.fr/~caubert/notes/portabilite-du-tex.html#dependances =head1 VERSION -This is latexpand version v1.1.1. +This is latexpand version v1.2-1-g47e2cee. |