mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
Cmake export tests: Omit underlines in temporary file names
Also try to copy all versions of an included reference. The example is the search for CV-image in Modern_CV.lyx. The two file (CV-image.eps and CV-image.png) have to be copied while keeping the same base name.
This commit is contained in:
parent
aed6755f59
commit
6b12a48a51
@ -277,6 +277,7 @@ sub checkForLayoutStart($)
|
|||||||
unshift(@stack, \%selem);
|
unshift(@stack, \%selem);
|
||||||
if ($selem{name} =~ /^(Picture|Photo)$/ ) {
|
if ($selem{name} =~ /^(Picture|Photo)$/ ) {
|
||||||
my $rElem = newMatch("ext" => [".eps", ".png"],
|
my $rElem = newMatch("ext" => [".eps", ".png"],
|
||||||
|
"filetype" => "copy_only",
|
||||||
"search" => qr/^(.+)/,
|
"search" => qr/^(.+)/,
|
||||||
"result" => ["", "", ""]);
|
"result" => ["", "", ""]);
|
||||||
setMatching([$rElem]);
|
setMatching([$rElem]);
|
||||||
|
@ -53,10 +53,10 @@ sub copyFoundSubdocuments($);
|
|||||||
sub copyJob($$);
|
sub copyJob($$);
|
||||||
sub isrelativeFix($$$);
|
sub isrelativeFix($$$);
|
||||||
sub isrelative($$$);
|
sub isrelative($$$);
|
||||||
sub createTemporaryFileName($$);
|
sub createTemporaryFileName($$$);
|
||||||
sub copyJobPending($$);
|
sub copyJobPending($$);
|
||||||
sub addNewJob($$$$$);
|
sub addNewJob($$$$$);
|
||||||
sub addFileCopyJob($$$$);
|
sub addFileCopyJob($$$$$);
|
||||||
sub getNewNameOf($$);
|
sub getNewNameOf($$);
|
||||||
sub getlangs($$);
|
sub getlangs($$);
|
||||||
sub simplifylangs($);
|
sub simplifylangs($);
|
||||||
@ -128,8 +128,9 @@ if (! -d $destdir) {
|
|||||||
my $destdirOfSubdocuments;
|
my $destdirOfSubdocuments;
|
||||||
{
|
{
|
||||||
my ($name, $pat, $suffix) = fileparse($source, qr/\.[^.]*/);
|
my ($name, $pat, $suffix) = fileparse($source, qr/\.[^.]*/);
|
||||||
my $ext = $format . "_$lang";
|
my $ext = $format . "-$lang";
|
||||||
$destdirOfSubdocuments = "$destdir/tmp_$ext" . "_$name"; # Global var, something TODO here
|
$name =~ s/_/-/g;
|
||||||
|
$destdirOfSubdocuments = "$destdir/tmp-$ext" . "-$name"; # Global var, something TODO here
|
||||||
}
|
}
|
||||||
|
|
||||||
if(-d $destdirOfSubdocuments) {
|
if(-d $destdirOfSubdocuments) {
|
||||||
@ -205,14 +206,27 @@ sub interpretedCopy($$$$)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
my ($newname, $res1);
|
my ($newname, $res1);
|
||||||
($newname, $res1) = addFileCopyJob("$sourcedir/$f$ext",
|
my @extlist = ();
|
||||||
|
if (defined($rStatus->{ext}->[1])) {
|
||||||
|
@extlist = @{$rStatus->{ext}};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
@extlist = ($ext);
|
||||||
|
}
|
||||||
|
my $created = 0;
|
||||||
|
for my $extx (@extlist) {
|
||||||
|
if (-e "$sourcedir/$f$extx") {
|
||||||
|
($newname, $res1) = addFileCopyJob("$sourcedir/$f$extx",
|
||||||
"$destdirOfSubdocuments",
|
"$destdirOfSubdocuments",
|
||||||
$rStatus->{"filetype"},
|
$rStatus->{"filetype"},
|
||||||
$rFiles);
|
$rFiles, $created);
|
||||||
print "Added ($res1) file \"$sourcedir/$f$ext\" to be copied to \"$newname\"\n";
|
print "Added ($res1) file \"$sourcedir/$f$ext\" to be copied to \"$newname\"\n";
|
||||||
if ($ext ne "") {
|
if (!$created && $extx ne "") {
|
||||||
$newname =~ s/$ext$//;
|
$newname =~ s/$extx$//;
|
||||||
}
|
}
|
||||||
|
$created = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
$f = $newname;
|
$f = $newname;
|
||||||
$res += $res1;
|
$res += $res1;
|
||||||
}
|
}
|
||||||
@ -237,7 +251,12 @@ sub interpretedCopy($$$$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($foundrelative) {
|
if ($foundrelative) {
|
||||||
$rF->[$fidx] = join($separator, @{$filelist});
|
# The result can be relative too
|
||||||
|
my @rel_list = ();
|
||||||
|
for my $fr (@{$filelist}) {
|
||||||
|
push(@rel_list, File::Spec->abs2rel($fr, $destdir));
|
||||||
|
}
|
||||||
|
$rF->[$fidx] = join($separator, @rel_list);
|
||||||
$l = join('', @{$rF});
|
$l = join('', @{$rF});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -293,7 +312,7 @@ sub copyJob($$)
|
|||||||
$rFiles->{$source}->{$k . "copied"} = 1;
|
$rFiles->{$source}->{$k . "copied"} = 1;
|
||||||
my $dest = $rFiles->{$source}->{$k};
|
my $dest = $rFiles->{$source}->{$k};
|
||||||
push(@dest, $dest);
|
push(@dest, $dest);
|
||||||
if ($k eq "copyonly") {
|
if ($k =~ /^copyonly/) {
|
||||||
diestack("Could not copy \"$source\" to \"$dest\"") if (! cp($source, $dest));
|
diestack("Could not copy \"$source\" to \"$dest\"") if (! cp($source, $dest));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -333,15 +352,24 @@ sub isrelative($$$)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sub createTemporaryFileName($$)
|
my $oldfname = "";
|
||||||
|
|
||||||
|
sub createTemporaryFileName($$$)
|
||||||
{
|
{
|
||||||
my ($source, $destdir) = @_;
|
my ($source, $destdir, $created) = @_;
|
||||||
|
|
||||||
# get the basename to be used for the template
|
# get the basename to be used for the template
|
||||||
my ($name, $path, $suffix) = fileparse($source, qr/\.[^.]*/);
|
my ($name, $path, $suffix) = fileparse($source, qr/\.[^.]*/);
|
||||||
#print "source = $source, name = $name, path = $path, suffix = $suffix\n";
|
#print "source = $source, name = $name, path = $path, suffix = $suffix\n";
|
||||||
my $template = "xx_$name" . "_";
|
my $template = "xx-$name" . "-";
|
||||||
my $fname = File::Temp::tempnam($destdir, $template);
|
my $fname;
|
||||||
|
if (! $created) {
|
||||||
|
$fname = File::Temp::tempnam($destdir, $template);
|
||||||
|
$oldfname = $fname;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$fname = $oldfname;
|
||||||
|
}
|
||||||
|
|
||||||
# Append extension from source
|
# Append extension from source
|
||||||
if ($suffix ne "") {
|
if ($suffix ne "") {
|
||||||
@ -371,9 +399,9 @@ sub addNewJob($$$$$)
|
|||||||
$rFiles->{$source} = $rJob;
|
$rFiles->{$source} = $rJob;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub addFileCopyJob($$$$)
|
sub addFileCopyJob($$$$$)
|
||||||
{
|
{
|
||||||
my ($source, $destdirOfSubdocuments, $filetype, $rFiles) = @_;
|
my ($source, $destdirOfSubdocuments, $filetype, $rFiles, $created) = @_;
|
||||||
my ($res, $newname) = (0, undef);
|
my ($res, $newname) = (0, undef);
|
||||||
my $rJob = $rFiles->{$source};
|
my $rJob = $rFiles->{$source};
|
||||||
|
|
||||||
@ -383,7 +411,7 @@ sub addFileCopyJob($$$$)
|
|||||||
}
|
}
|
||||||
if (!defined($rJob->{$hashname})) {
|
if (!defined($rJob->{$hashname})) {
|
||||||
addNewJob($source,
|
addNewJob($source,
|
||||||
createTemporaryFileName($source, $destdirOfSubdocuments),
|
createTemporaryFileName($source, $destdirOfSubdocuments, $created),
|
||||||
"$hashname", $rJob, $rFiles);
|
"$hashname", $rJob, $rFiles);
|
||||||
$res = 1;
|
$res = 1;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user