From 48dba2f7367a45f534ab7a002fa4f6d28bde546c Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 17 Jun 2015 22:45:48 +0000 Subject: latexpand (24may15) git-svn-id: svn://tug.org/texlive/trunk@37592 c570f23f-e606-0410-a88d-b1316a301751 --- .../texlive/linked_scripts/latexpand/latexpand | 92 ++++++++++++++++++---- .../texk/texlive/linked_scripts/texlive/fmtutil.pl | 18 +++-- 2 files changed, 86 insertions(+), 24 deletions(-) (limited to 'Build') 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 +# 2012, 2013, 2014, 2015: Matthieu Moy # 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 = ''; } $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 = ) { 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 . =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 -- cgit v1.2.3