summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-01-23 22:12:07 +0000
committerKarl Berry <karl@freefriends.org>2015-01-23 22:12:07 +0000
commitc6f0d41b73cecfa8ec748d22ab7400584af6e6b4 (patch)
treed9ddfca77fc956456fbf65e4cde40aa3abc4d8b9 /Master
parenta317a3b32d93430517e8391a51cb4cd60b854d6d (diff)
latexpand (23jan15)
git-svn-id: svn://tug.org/texlive/trunk@36125 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/support/latexpand/Makefile15
-rw-r--r--Master/texmf-dist/doc/support/latexpand/README12
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/README3
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/df-conflict/a.tex7
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/df-conflict/b.tex1
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/df-conflict/b/README-df-conflict.txt1
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/foo.tex3
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/includegraphic.tex8
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/includer.tex21
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/just-comment.tex1
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/my-package.sty2
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/no-eol.tex1
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/package-user.tex8
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/smile.pdfbin6301 -> 0 bytes
-rw-r--r--Master/texmf-dist/doc/support/latexpand/tests/text-after-end.tex16
-rw-r--r--Master/texmf-dist/doc/support/latexpand/version.txt4
-rwxr-xr-xMaster/texmf-dist/scripts/latexpand/latexpand114
17 files changed, 103 insertions, 114 deletions
diff --git a/Master/texmf-dist/doc/support/latexpand/Makefile b/Master/texmf-dist/doc/support/latexpand/Makefile
deleted file mode 100644
index 08145b7b103..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-all: dist/latexpand.zip
-
-dist/latexpand/README: latexpand
- pod2text latexpand > $@
-
-.PHONY: all force
-dist/latexpand.zip: force
- -$(RM) -r dist/
- mkdir -p dist/latexpand
- @$(MAKE) dist/latexpand/README
- @echo "latexpand version $$(git rev-parse HEAD).\n\
-Commited on $$(git show -s HEAD --pretty=format:'%cd')." > dist/latexpand/version.txt
- git ls-files | grep -v '\.gitignore' | tar -cf - -T - | (cd dist/latexpand/ && tar xf -)
- cd dist && zip -r latexpand.zip latexpand/
-force:
diff --git a/Master/texmf-dist/doc/support/latexpand/README b/Master/texmf-dist/doc/support/latexpand/README
index 673177188bd..1103a78b5b9 100644
--- a/Master/texmf-dist/doc/support/latexpand/README
+++ b/Master/texmf-dist/doc/support/latexpand/README
@@ -15,7 +15,8 @@ SYNOPSIS
--expand-usepackage
Expand \usepackage{...} directives if the
corresponding .sty file is found in
- $TEXINPUTS
+ $TEXINPUTS (or the current directory if
+ $TEXINPUTS is not set)
--expand-bbl FILE
Expand the bibliography by inlining FILE
(should be a *.bbl file)
@@ -27,6 +28,7 @@ SYNOPSIS
--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.
USES
The most common use of latexpand is to simplify distribution of source
@@ -69,3 +71,11 @@ BUGS
A workaround is to use --empty-comments when such tricky usage of the
comments package is done.
+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.
+
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/README b/Master/texmf-dist/doc/support/latexpand/tests/README
deleted file mode 100644
index b43baccb369..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/README
+++ /dev/null
@@ -1,3 +0,0 @@
-Set of files to test latexpand.
-
-Tests are currently not automated :-(.
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/df-conflict/a.tex b/Master/texmf-dist/doc/support/latexpand/tests/df-conflict/a.tex
deleted file mode 100644
index a91beee2607..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/df-conflict/a.tex
+++ /dev/null
@@ -1,7 +0,0 @@
-\documentclass{article}
-\begin{document}
-
-Hello
-\input{b}
-
-\end{document}
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/df-conflict/b.tex b/Master/texmf-dist/doc/support/latexpand/tests/df-conflict/b.tex
deleted file mode 100644
index 1aa90fca797..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/df-conflict/b.tex
+++ /dev/null
@@ -1 +0,0 @@
-world.
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/df-conflict/b/README-df-conflict.txt b/Master/texmf-dist/doc/support/latexpand/tests/df-conflict/b/README-df-conflict.txt
deleted file mode 100644
index 8097e2eb5fc..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/df-conflict/b/README-df-conflict.txt
+++ /dev/null
@@ -1 +0,0 @@
-This directory is likely to confuse latexpand.
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/foo.tex b/Master/texmf-dist/doc/support/latexpand/tests/foo.tex
deleted file mode 100644
index e1bf33402dc..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/foo.tex
+++ /dev/null
@@ -1,3 +0,0 @@
-foo content
-\def\foo@bar{foo bar}
-\foo@bar{}
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/includegraphic.tex b/Master/texmf-dist/doc/support/latexpand/tests/includegraphic.tex
deleted file mode 100644
index 213ad14c823..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/includegraphic.tex
+++ /dev/null
@@ -1,8 +0,0 @@
-\documentclass{article}
-
-\usepackage{graphicx}
-\begin{document}
-test includegraphics:
-\includegraphics{smile.pdf}
-\includegraphics[scale=2]{smile.pdf}
-\end{document}
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/includer.tex b/Master/texmf-dist/doc/support/latexpand/tests/includer.tex
deleted file mode 100644
index 29c60aa6bd9..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/includer.tex
+++ /dev/null
@@ -1,21 +0,0 @@
-\documentclass{article}
-
-\begin{document}
-beforeinput\input{foo}afterinput
-
-beforeinput.tex\input{foo.tex}afterinput.tex
-
-before inclusion of just-comment\input just-comment.tex after inclusion of just-comment
-
-before inclusion of no-eol\input no-eol after inclusion of no-eol.
-
-before inclusion of no-eol\input{no-eol}after inclusion of no-eol (braces).
-
-beforeinclude\include{foo}afterinclude
-
-\end{document}
-
-%%% Local Variables:
-%%% mode: latex
-%%% TeX-master: t
-%%% End:
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/just-comment.tex b/Master/texmf-dist/doc/support/latexpand/tests/just-comment.tex
deleted file mode 100644
index 743ee4e4472..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/just-comment.tex
+++ /dev/null
@@ -1 +0,0 @@
-%just comment (no EOL) \ No newline at end of file
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/my-package.sty b/Master/texmf-dist/doc/support/latexpand/tests/my-package.sty
deleted file mode 100644
index ab135ab069f..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/my-package.sty
+++ /dev/null
@@ -1,2 +0,0 @@
-% My package content
-\def\foo{bar}
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/no-eol.tex b/Master/texmf-dist/doc/support/latexpand/tests/no-eol.tex
deleted file mode 100644
index 5910948883b..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/no-eol.tex
+++ /dev/null
@@ -1 +0,0 @@
-text without EOL \ No newline at end of file
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/package-user.tex b/Master/texmf-dist/doc/support/latexpand/tests/package-user.tex
deleted file mode 100644
index 87df974b679..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/package-user.tex
+++ /dev/null
@@ -1,8 +0,0 @@
-\documentclass{article}
-
-\usepackage{lmodern}
-\usepackage{my-package}
-
-\begin{document}
-
-\end{document}
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/smile.pdf b/Master/texmf-dist/doc/support/latexpand/tests/smile.pdf
deleted file mode 100644
index 9224e22a794..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/smile.pdf
+++ /dev/null
Binary files differ
diff --git a/Master/texmf-dist/doc/support/latexpand/tests/text-after-end.tex b/Master/texmf-dist/doc/support/latexpand/tests/text-after-end.tex
deleted file mode 100644
index 16bd1b73398..00000000000
--- a/Master/texmf-dist/doc/support/latexpand/tests/text-after-end.tex
+++ /dev/null
@@ -1,16 +0,0 @@
-\documentclass{article}
-
-\begin{document}
-should be displayed
-\verb|\end{document}|
-should be displayed too.
-\end{document} end of line discarded.
-
-should not be displayed.
-\end{document}
-should not be displayed either.
-
-%%% Local Variables:
-%%% mode: latex
-%%% TeX-master: t
-%%% End:
diff --git a/Master/texmf-dist/doc/support/latexpand/version.txt b/Master/texmf-dist/doc/support/latexpand/version.txt
index b56d2f73afb..ddf593e422c 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 ac5896be7dc7c7481695c1ac23da838a31b5c50b.
-Commited on Fri Apr 4 09:58:49 2014 +0200.
+latexpand version v1.1.1 (931b9665fee76da7e6f9c902c4d7f629f791def1).
+Committed on Fri Jan 23 10:55:18 2015 +0100.
diff --git a/Master/texmf-dist/scripts/latexpand/latexpand b/Master/texmf-dist/scripts/latexpand/latexpand
index 23ac416868f..f2e83c28a71 100755
--- a/Master/texmf-dist/scripts/latexpand/latexpand
+++ b/Master/texmf-dist/scripts/latexpand/latexpand
@@ -24,6 +24,8 @@ my $show_graphics;
my $graphics_extensions = ":.pdf:.png:.jpg:.eps";
my $expand_usepackage;
my $expand_bbl;
+my $fatal;
+my $version;
GetOptions (
'h' => \$help,
@@ -38,10 +40,34 @@ GetOptions (
'graphics-extensions' => \$graphics_extensions,
'expand-usepackage' => \$expand_usepackage,
'expand-bbl=s' => \$expand_bbl,
+ 'fatal' => \$fatal,
+ 'version' => \$version,
) or pod2usage(2);
+version() if $version;
pod2usage(1) if $help;
pod2usage(-exitstatus => 0, -verbose => 2) if $long_help;
+sub get_version
+{
+ my $VERSION = 'v1.1.1';
+ if ($VERSION == '@LATEXPAND' . '_VERSION@') {
+ my($vol,$dir,$file) = File::Spec->splitpath($0);
+ chdir($dir);
+ $VERSION = `git describe --tags HEAD 2>/dev/null`;
+ }
+ if ($VERSION == '') {
+ $VERSION = '<unknown version>';
+ }
+ $VERSION =~ s/^\s+|\s+$//g;
+ return $VERSION;
+}
+
+sub version
+{
+ print "latexpand version ". get_version() .".\n";
+ exit(0);
+}
+
my $comment_newline;
my $nl = "";
@@ -71,11 +97,18 @@ sub process_file
{
my $file = shift;
my $prefix = (shift || "");
+ my $in_comment = 0;
local(*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;
+ }
process_line($line, $prefix);
- if (/^%.*[^\n]\z/ || /[^\\]%.*[^\n]\z/) {
+ if ($line =~ /^%.*[^\n]\z/ || $line =~ /[^\\]%.*[^\n]\z/) {
# file ends with a comment not ending with a newline
print "\n";
}
@@ -88,11 +121,13 @@ sub process_file
}
}
close(FILE);
+ return $in_comment;
}
sub process_line
{
- my ($_, $prefix) = @_;
+ my $prefix;
+ ($_, $prefix) = @_;
unless ($keep_comments) {
if ($empty_comments) {
s/^%.*$/%/;
@@ -107,34 +142,48 @@ sub process_line
if (my ($before, $ignored, $full_filename, $after)
= /^(([^%]|[^\\]%)*)\\include[{\s]+(.*?)[\s}](.*)$/) {
$full_filename = find_tex_file($full_filename . ".tex");
- say $prefix . "Found include for file: $full_filename\n";
- print $before . $nl;
- print '\clearpage{}' . $nl;
- print '\makeatletter{}' . $nl;
- print "% start include $full_filename\n" if ($explain);
- process_file($full_filename, $prefix . " ");
- print "% end include $full_filename\n" if ($explain);
- print '\clearpage{}' . $nl;
- print $nl . $after . "\n";
- $_ = "";
+ if ($full_filename) {
+ say $prefix . "Found include for file: $full_filename\n";
+ print $before . $nl;
+ print '\clearpage{}' . $nl;
+ print "% start include $full_filename\n" if ($explain);
+ my $in_comment = process_file($full_filename, $prefix . " ");
+ if ($explain) {
+ print " % end include $full_filename\n";
+ } elsif ($in_comment) {
+ print "\n";
+ }
+ print '\clearpage{}' . $nl;
+ print $nl . $after . "\n";
+ $_ = "";
+ }
} elsif (my ($before, $ignored, $full_filename, $after)
= /^(([^%]|[^\\]%)*)\\input[{\s]+(.*?)[\s}](.*)$/) {
$full_filename = find_tex_file($full_filename, ":.tex");
- say $prefix . "Found input for file: $full_filename\n";
- print $before . $nl;
- print '\makeatletter{}' . $nl;
- print "% start input $full_filename\n" if ($explain);
- process_file($full_filename, $prefix . " ");
- print "% end input $full_filename\n" if ($explain);
- # LaTeX produces this space, so let's do it also
- print " " . $nl . $after . "\n";
- $_ = "";
+ if ($full_filename) {
+ say $prefix . "Found input for file: $full_filename\n";
+ print $before . $nl;
+ print "% start input $full_filename\n" if ($explain);
+ my $in_comment = process_file($full_filename, $prefix . " ");
+ if ($explain) {
+ print " % end input $full_filename\n";
+ } elsif ($in_comment) {
+ print "\n";
+ }
+ if ($after =~ /[^\s]/) {
+ # LaTeX produces this space, so let's do it also
+ print " " . $nl . $after . "\n";
+ } else {
+ print " ";
+ }
+ $_ = "";
+ }
}
}
if ($expand_usepackage) {
# Don't bother with before and after text, we just require the
# usepackage to be alone on its line.
- if (my ($package_name) = /^\s*\\usepackage{([^}]*)}\s*$/) {
+ if (my ($package_name) = /^\s*\\usepackage{([^}]*)}\s*(%.*)?$/) {
my $full = find_file($package_name . ".sty", $TEXINPUTS);
if ($full) {
say $prefix . "Found package file: $full\n";
@@ -178,7 +227,12 @@ sub find_tex_file
return $full;
}
}
- die "ERROR: Could not find file [$file]\n";
+ if ($fatal) {
+ die "ERROR: Could not find file [$file]\n";
+ } else {
+ print STDERR "Warning: Could not find file [$file]\n";
+ return undef;
+ }
}
sub find_file
@@ -221,7 +275,8 @@ latexpand [options] FILE...
--expand-usepackage
Expand \usepackage{...} directives if the
corresponding .sty file is found in
- $TEXINPUTS
+ $TEXINPUTS (or the current directory if
+ $TEXINPUTS is not set)
--expand-bbl FILE
Expand the bibliography by inlining FILE
(should be a *.bbl file)
@@ -233,6 +288,7 @@ 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.
=head1 USES
@@ -278,3 +334,13 @@ will produce the incorrect
A workaround is to use --empty-comments when such tricky usage of the
comments package is done.
+
+=head1 SEE ALSO
+
+Instructions to include only the relevant .bib items (french):
+
+https://lacl.fr/~caubert/notes/portabilite-du-tex.html#dependances
+
+=head1 VERSION
+
+This is latexpand version v1.1.1.