beta-0.89.2
[luatex.git] / source / texk / texlive / tl_scripts / e2pall.pl
blob2997f8b11026cb0922a50ede937d8ec5b7e5e805
1 #!/usr/bin/env perl
3 # Author: Jody Klymak <jklymak@apl.washington.edu>, publisted by a posting
4 # to the pdftex mailinglist.
6 # recursively finds all your eps files. Looks down \input{fname}.
7 # CAVEATS:
8 # 1) cannot handle \input{fname} split over more than one line.
9 # 1.5) cannot handle multiple \input{} or \includegraphics{} on one line.
10 # 2) Must be run from same directory as the Latex file.
11 # 3) Does not look down $TEXINPUTS or anything fancy like that...
12 # 4) Handling of \include is untested (though I guess its trivial)
13 # 5) Assumes *all* your graphics inclusions are [e]ps. But don't
14 # fret, because if they are not epstopdf dies anyhow....
15 # 6) Does not distinguish between percent (\%) and comment (%).
17 # Changelog:
18 # 20030103 -- Lachlan Andrew <lha@users.sourceforge.net>
19 # * Only append '.tex' if $fname doesn't exist.
20 # * Correctly handle lines with '}' after the \includegraphics{}
21 # * Allow multiple extensions for graphics files. .eps -> .ps -> none
22 # (Should try them in the same order as \includegraphics does
23 # -- given by \DeclareGraphicsExtensions{}?)
24 # * Allow \include the same way as \input
25 # * Allow \includegraphics{} to be split over multiple lines
26 # * Check that commands begin with '\', and allow spaces before arguments
28 # EDIT these two lines for your system....
30 $Eps2PdfCom = "epstopdf";
31 $ThisFunCom = "e2pall";
33 $fname=$ARGV[0];
35 # check for a *.tex at the end...
36 if ((-f "$fname")=="" && $fname !~ /.tex$/){
37 $fname = "$fname.tex";
40 open(TEXFILE,$fname) or die "Cannot open file $fname";
41 # print "Finding *.eps files in $fname\n";
43 $seekingArg = 0;
44 while($line=<TEXFILE>){
45 # truncate $line after % sign....
46 $line=~s/%.*//;
47 # check for /input....
48 if ($line=~/\\input *{([^}]*)}/){
49 print `$ThisFunCom $1`;
51 # check for /include....
52 if ($line=~/\\include *{([^}]*)}/){
53 print `$ThisFunCom $1`;
56 $base = "";
57 if ($line=~/\\includegraphics.*{([^}]*)}/){
58 $base = $1;
60 elsif ($seekingArg==1 && ($line=~/{([^}]*)}/)){
61 $base = $1;
63 elsif ($line=~/\\includegraphics/){
64 $seekingArg = 1;
67 if ($base ne "") {
68 $seekingArg = 0;
69 if ((-f "$base.eps")!="") {
70 $srcfile = "$base.eps";
72 elsif ((-f "$base.ps")!=""){
73 $srcfile = "$base.ps";
75 else {
76 $srcfile = $base;
78 # check that the [e]ps version is newer than the pdf version....
79 if ((-M "$base.pdf")=="" || (-M "$base.pdf") >= (-M "$srcfile")){
80 print "Constructing \t $base.pdf from $srcfile\n";
81 print `$Eps2PdfCom $srcfile`;
83 else{
84 print "$base.pdf \t is up to date with $srcfile\n";
89 close(TEXFILE);