2005-06-20 16:25:50 +02:00
|
|
|
use strict;
|
|
|
|
use File::Basename;
|
|
|
|
|
2009-07-17 17:10:01 +02:00
|
|
|
my $src = $ENV{"src"};
|
2005-06-20 16:25:50 +02:00
|
|
|
my $out = $ENV{"out"};
|
2007-03-12 18:55:08 +01:00
|
|
|
my $path = $ENV{"searchRelativeTo"};
|
2005-06-20 16:25:50 +02:00
|
|
|
|
|
|
|
open OUT, ">$out" or die;
|
|
|
|
print OUT "[\n";
|
|
|
|
|
2009-07-17 17:10:01 +02:00
|
|
|
open FILE, "< $src" or die;
|
2005-06-20 16:25:50 +02:00
|
|
|
|
2009-07-17 17:10:01 +02:00
|
|
|
sub addName {
|
|
|
|
my ($type, $name) = @_;
|
|
|
|
print OUT "{ type = \"$type\"; name = \"$name\"; }\n";
|
2006-11-22 08:06:10 +01:00
|
|
|
}
|
2005-06-20 16:25:50 +02:00
|
|
|
|
2009-07-17 17:10:01 +02:00
|
|
|
while (<FILE>) {
|
|
|
|
if (/\\input\{(.*)\}/) {
|
|
|
|
my $fn2 = $1;
|
|
|
|
die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";
|
|
|
|
addName "tex", "$fn2";
|
|
|
|
} elsif (/\\usepackage(\[.*\])?\{(.*)\}/) {
|
|
|
|
my $fn2 = $2;
|
|
|
|
die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";
|
|
|
|
addName "misc", "$fn2.sty";
|
|
|
|
} elsif (/\\documentclass(\[.*\])?\{(.*)\}/) {
|
|
|
|
my $fn2 = $2;
|
|
|
|
die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";
|
|
|
|
addName "misc", "$fn2.cls";
|
|
|
|
} elsif (/\\bibliographystyle\{(.*)\}/) {
|
|
|
|
my $fn2 = $1;
|
|
|
|
die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";
|
|
|
|
addName "misc", "$fn2.bst";
|
|
|
|
} elsif (/\\bibliography\{(.*)\}/) {
|
|
|
|
foreach my $bib (split /,/, $1) {
|
|
|
|
$bib =~ s/^\s+//; # remove leading / trailing whitespace
|
|
|
|
$bib =~ s/\s+$//;
|
|
|
|
addName "misc", "$bib.bib";
|
2005-06-20 17:20:37 +02:00
|
|
|
}
|
2009-07-17 17:10:01 +02:00
|
|
|
} elsif (/\\includegraphics(\[.*\])?\{(.*)\}/) {
|
|
|
|
my $fn2 = $2;
|
|
|
|
die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";
|
|
|
|
addName "img", "$fn2";
|
|
|
|
} elsif (/\\pgfdeclareimage(\[.*\])?\{.*\}\{(.*)\}/) {
|
|
|
|
my $fn2 = $2;
|
|
|
|
die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";
|
|
|
|
addName "img", "$fn2";
|
|
|
|
} elsif (/\\pgfimage(\[.*\])?\{(.*)\}/) {
|
|
|
|
my $fn2 = $2;
|
|
|
|
die "absolute path! $fn2" if substr($fn2, 0, 1) eq "/";
|
|
|
|
addName "img", "$fn2";
|
2005-06-20 16:25:50 +02:00
|
|
|
}
|
2009-07-17 17:10:01 +02:00
|
|
|
# !!! also support \usepackage
|
2005-06-20 16:25:50 +02:00
|
|
|
}
|
|
|
|
|
2009-07-17 17:10:01 +02:00
|
|
|
close FILE;
|
|
|
|
|
2005-06-20 16:25:50 +02:00
|
|
|
print OUT "]\n";
|
|
|
|
close OUT;
|